Skip to content

Commit 2c39910

Browse files
committed
acc. changes
1 parent e56bd7d commit 2c39910

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

projects/cbETH/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
const ADDRESSES = require('../helper/coreAssets.json')
22
const { get } = require('../helper/http')
3-
const token = ADDRESSES.ethereum.cbETH
3+
const BigNumber = require('bignumber.js')
4+
5+
const ETH = ADDRESSES.null
46

57
module.exports = {
68
timetravel: false,
79
ethereum: {
810
tvl: async () => {
911
const data = await get("https://api.exchange.coinbase.com/wrapped-assets/CBETH")
10-
// Convert cbETH supply to underlying ETH using the conversion rate
11-
const underlyingETH = data.circulating_supply * data.conversion_rate
12+
// Convert circulating cbETH to the amount of underlying ETH backing the wrapper
13+
const circulatingSupply = new BigNumber(data.circulating_supply || 0)
14+
const conversionRate = new BigNumber(data.conversion_rate || 0)
15+
const underlyingETH = circulatingSupply.times(conversionRate)
16+
1217
return {
13-
[token]: underlyingETH * 1e18
18+
[ETH]: underlyingETH.shiftedBy(18).toFixed(0),
1419
}
1520
}
1621
}

0 commit comments

Comments
 (0)