Skip to content

Commit dc42bd8

Browse files
fix denario
1 parent 372262a commit dc42bd8

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

projects/denario/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@ async function tvl(api) {
3636
// target: goldAddress,
3737
// })
3838

39-
const silverDecimals = await api.call({
40-
target: silverAddress,
41-
abi: 'erc20:decimals'
42-
})
4339
const silverPrice = await api.call({
4440
target: priceOracle,
4541
params: 'silvercoin/latest/USD',
46-
abi: 'function getValue(string key) view returns (uint128,uint128)'
42+
abi: priceOracleABI[0]
4743
}).then(res => res[0])
48-
const silverPriceInUSD = silverPrice / 10 ** silverDecimals
49-
silverAddress.price = silverPriceInUSD
44+
45+
// Oracle price is in 8 decimals (standard for USD prices)
46+
const silverPriceInUSD = silverPrice / 1e8
47+
48+
// Calculate total value in USD and add to balances
49+
const totalValueInUSD = (totalSilverSupply * silverPriceInUSD) / 1e18 // token has 18 decimals
50+
api.add(ADDRESSES.polygon.USDC, totalValueInUSD * 1e6) // USDC has 6 decimals
5051

5152
return {
5253
[silverAddress]: totalSilverSupply,

0 commit comments

Comments
 (0)