Skip to content
Open
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
32 changes: 32 additions & 0 deletions projects/piku-dao/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const ADDRESSES = require('../helper/coreAssets.json')

const USP_TOKEN = '0x098697bA3Fee4eA76294C5d6A466a4e3b3E95FE6'
const ORACLE = '0x433471901bA1A8BDE764E8421790C7D9bAB33552'

async function tvl(api) {
// Get USP total supply and oracle price in parallel
const [totalSupply, decimals, pricePerToken] = await Promise.all([
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible for us to count underlying asset deposits rather than receipt token total supply?

Copy link
Author

Choose a reason for hiding this comment

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

Hi! We use a dynamic mint and redeem mechanism for USP, which is why using the total supply is accurate in this case.
You can verify this on Etherscan (writeProxyContract - buy function)
— specifically the buy (0xd6febde8) function.

Here are example transactions for reference:
• Mint: 0x7defc233f2f62780664446503b3f58786714e5dbbb785be16ab94b4c3e4abaea

• Redeem: 0x0220adc3e42cb0ab2ab1f1a9047b0d2c1f2ea6e46d4f922ea9a804891ac5ec7c#eventlog

If that’s not convincing enough, I can walk you through the contract architecture in more detail.

api.call({ target: USP_TOKEN, abi: 'erc20:totalSupply' }),
api.call({ target: USP_TOKEN, abi: 'uint256:decimals' }),
api.call({ target: ORACLE, abi: 'function getPriceForIssuance() view returns (uint256)' })
])

// Calculate TVL in USDC
// totalSupply is in 18 decimals, pricePerToken is in 6 decimals (USDC format)
// Result should be in USDC's 6 decimals
// Formula: (totalSupply * price) / 10^18 = TVL in USDC (6 decimals)
const tvlInUsdc = (totalSupply * pricePerToken) / (10 ** decimals)

// Report as USDC for proper USD valuation
api.add(ADDRESSES.ethereum.USDC, tvlInUsdc)
}

module.exports = {
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.",
start: 23081800,
timetravel: true,
misrepresentedTokens: false,
ethereum: {
tvl,
}
}
Loading