File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -36,17 +36,18 @@ async function tvl(api) {
36
36
// target: goldAddress,
37
37
// })
38
38
39
- const silverDecimals = await api . call ( {
40
- target : silverAddress ,
41
- abi : 'erc20:decimals'
42
- } )
43
39
const silverPrice = await api . call ( {
44
40
target : priceOracle ,
45
41
params : 'silvercoin/latest/USD' ,
46
- abi : 'function getValue(string key) view returns (uint128,uint128)'
42
+ abi : priceOracleABI [ 0 ]
47
43
} ) . 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
50
51
51
52
return {
52
53
[ silverAddress ] : totalSilverSupply ,
You can’t perform that action at this time.
0 commit comments