Skip to content

Commit 05f66f9

Browse files
authored
Add USP TVL calculation for Ethereum (#1) (DefiLlama#16907)
1 parent 53056dd commit 05f66f9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

projects/piku-dao/index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const ADDRESSES = require('../helper/coreAssets.json')
2+
3+
const USP_TOKEN = '0x098697bA3Fee4eA76294C5d6A466a4e3b3E95FE6'
4+
const ORACLE = '0x433471901bA1A8BDE764E8421790C7D9bAB33552'
5+
6+
async function tvl(api) {
7+
// Get USP total supply and oracle price in parallel
8+
const [totalSupply, decimals, pricePerToken] = await Promise.all([
9+
api.call({ target: USP_TOKEN, abi: 'erc20:totalSupply' }),
10+
api.call({ target: USP_TOKEN, abi: 'uint256:decimals' }),
11+
api.call({ target: ORACLE, abi: 'function getPriceForIssuance() view returns (uint256)' })
12+
])
13+
14+
// Calculate TVL in USDC
15+
// totalSupply is in 18 decimals, pricePerToken is in 6 decimals (USDC format)
16+
// Result should be in USDC's 6 decimals
17+
// Formula: (totalSupply * price) / 10^18 = TVL in USDC (6 decimals)
18+
const tvlInUsdc = (totalSupply * pricePerToken) / (10 ** decimals)
19+
20+
// Report as USDC for proper USD valuation
21+
api.add(ADDRESSES.ethereum.USDC, tvlInUsdc)
22+
}
23+
24+
module.exports = {
25+
methodology: "TVL is calculated by multiplying USP stablecoin's total supply with its oracle price (getPriceForIssuance). The oracle price is manually updated and reflects the yield-bearing value of USP backed by USDC.",
26+
start: 23081800,
27+
timetravel: true,
28+
misrepresentedTokens: false,
29+
ethereum: {
30+
tvl,
31+
}
32+
}

0 commit comments

Comments
 (0)