Skip to content

Commit

Permalink
fix defisaver
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Jan 25, 2025
1 parent ae03482 commit d9abbbf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions projects/defisaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ async function tvl(api) {
//
// By getting subscription data from the first package you can calculate balances for each position using `get${protocol_name_here}AccountBalances` method from the second package

const response = await fetch(`https://stats.defisaver.com/api/automation/tvl/per-asset?chainId=${chainId}&block=${block}`);
const response = await fetch(`https://stats.defisaver.com/api/automation/tvl/per-asset?chainId=${chainId}&block=${block - 10000}`);
const data = await response.json();

if (response.status !== 200) {
if (response.status !== 200)
throw new Error(data.message || 'Error not handled');
}

return data.balances;
Object.entries(data.balances).forEach(([token, balance]) => {
api.add(token, +balance)
})
}

module.exports = {
Expand Down

0 comments on commit d9abbbf

Please sign in to comment.