Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dexs/bifrost-dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const fetch = async (_: any, _1: any, options: FetchOptions) => {
const startTime = new Date(options.startTimestamp * 1000).toISOString().split("T")[0]
if (!res)
res = fetchURL('https://dapi.bifrost.io/api/dapp/stats/swap')
const v = (await res).volume.find(v => v.date === startTime)
const v = (await res).volume.find((v: any) => v.date === startTime)

return { dailyVolume: v.amount };
};
Expand Down
2 changes: 1 addition & 1 deletion fees/bifrost-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const fetch = async (_: any, _1: any, options: FetchOptions) => {
const startTime = new Date(options.startTimestamp * 1000).toISOString().split("T")[0]
if (!res)
res = fetchURL('https://dapi.bifrost.io/api/dapp/stats/overview')
const v = (await res).find(v => v.date === startTime)
const v = (await res).find((v: any) => v.date === startTime)

return { dailyFees: +v.txFee };
};
Expand Down
7 changes: 5 additions & 2 deletions helpers/curators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,16 @@ async function getVaultERC4626Info(options: FetchOptions, vaults: Array<string>)
for (let i = 0; i < vaults.length; i++) {
const asset = assets[i]
if (asset) {
const assetDecimals = Number(decimals[i]);
const decimalAdjustment = BigInt(10 ** (18 - assetDecimals));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are using decimalAdjustment like this? Can you share an example vault need this fix?

The current logic is USDC has 6 decimals, totalAssets or totalSupply return 6 decimals
The rate always have 18 decimals

Copy link
Contributor Author

@jimboevans jimboevans Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, of course. Re; why I was doing it like this:

Problem:
convertToAssets takes in 18 decimal shares as input, but it returns values in the asset's native decimals. So rate doesn't always have 18 decimals.

Example:
Vault (hyperliquid, morpho, usdt0): 0xfc5126377f0efc0041c0969ef9ba903ce67d151e

// Start Date:     Mon, 10 Nov 2025 20:47:56 GMT
// End Date:       Tue, 11 Nov 2025 20:47:56 GMT

balance = 35,702,570,836,010
rateBefore = 1,045,623
rateAfter  = 1,045,837
growthRate = 214

// Original calculation:
interestEarnedIncludingFees = balance * growthRate / BigInt(10**18)
               = 35,702,570,836,010 * 214 / 1e18
               = 0

// With decimalAdjustment:
interestEarnedIncludingFees = balance * growthRate / BigInt(10**18)
               = 35,702,570,836,010 * 214,000,000,000,000 / 1e18
               = 7,640,350,158
               = 7,640.35 // convert from 6 decimals to USD

This should only impact <18 decimal assets.

Thank you!


vaultInfo.push({
vault: vaults[i],
asset,
assetDecimals: Number(decimals[i]),
balance: BigInt(balances[i] ? balances[i] : 0),
rateBefore: BigInt(ratesBefore[i] ? ratesBefore[i] : 0),
rateAfter: BigInt(ratesAfter[i] ? ratesAfter[i] : 0),
rateBefore: BigInt(ratesBefore[i] ? ratesBefore[i] : 0) * decimalAdjustment,
rateAfter: BigInt(ratesAfter[i] ? ratesAfter[i] : 0) * decimalAdjustment,
})
}
}
Expand Down
22 changes: 15 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading