-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Add PumpSpace adapter (Avalanche) with V2 + V3 TVL and token mapping support #16805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 18 commits
94a262d
9985e74
c712bb7
bb8370c
bdfd36d
0a77c11
0f6144d
49a49bb
4f6353b
f8ad4d7
c9bed2d
7e6ce16
261fcd3
9ec2c94
f7cb315
2e9629b
cbc3dac
cbabb11
7854cdc
8e1e265
4486442
6e55f10
5d2e175
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // projects/aquabank/index.js | ||
| const ADDRESSES = require('../helper/coreAssets.json') | ||
|
|
||
| const USDt = ADDRESSES.avax.USDt // 0x9702230A8Ea53601f5Cd2dc00fDBc13d4dF4A8c7 | ||
|
|
||
| // Vaults that hold receipt tokens (not the underlying) | ||
| const BENQI_VAULT = '0x7D336B49879a173626E51BFF780686D88b8081ec' | ||
| const EULER_VAULT = '0x61E8f77eD693d3edeCBCc2dd9c55c1d987c47775' | ||
|
|
||
| // Protocol receipt tokens (convertible to USDt underlying) | ||
| const BENQI_RECEIPT = '0xd8fcDa6ec4Bdc547C0827B8804e89aCd817d56EF' | ||
| const EULER_RECEIPT = '0xa446938b0204Aa4055cdFEd68Ddf0E0d1BAB3E9E' | ||
|
|
||
|
|
||
| // ABIs | ||
| const erc20Bal = 'function balanceOf(address) view returns (uint256)' | ||
|
|
||
| const benqiAbi = { | ||
| // Compound-style exchange rate (scaled by 1e18) | ||
| exchangeRateStored: 'function exchangeRateStored() view returns (uint256)', | ||
| underlying: 'function underlying() view returns (address)', | ||
| } | ||
|
|
||
| const eulerAbi = { | ||
| // ERC4626-style conversion from shares to assets | ||
| convertToAssets: 'function convertToAssets(uint256 shares) view returns (uint256)', | ||
| asset: 'function asset() view returns (address)', | ||
| } | ||
|
|
||
| const toStr = (x) => (x?.toString?.() ?? String(x)) | ||
| const toBN = (x) => BigInt(toStr(x)) | ||
|
|
||
| // TVL: sum USDt underlying represented by Benqi/Euler receipt tokens held in the vaults | ||
| async function tvl(api) { | ||
|
|
||
| // 1) Read receipt balances held by the two vaults | ||
| const [benqiShares, eulerShares] = await Promise.all([ | ||
| api.call({ target: BENQI_RECEIPT, abi: erc20Bal, params: BENQI_VAULT, permitFailure: true }), | ||
| api.call({ target: EULER_RECEIPT, abi: erc20Bal, params: EULER_VAULT, permitFailure: true }), | ||
| ]) | ||
|
|
||
| // 2) Convert Benqi shares -> USDt underlying using Compound-style exchange rate | ||
| let benqiUnderlying = 0n | ||
| if (benqiShares) { | ||
| const rate = await api.call({ target: BENQI_RECEIPT, abi: benqiAbi.exchangeRateStored, permitFailure: true }) | ||
| if (rate) { | ||
| // underlying = shares * rate / 1e18 | ||
| benqiUnderlying = (toBN(benqiShares) * toBN(rate)) / 10n**18n | ||
| } | ||
| } | ||
|
|
||
| // 3) Convert Euler shares -> USDt underlying using ERC4626 conversion | ||
| let eulerUnderlying = 0n | ||
| if (eulerShares) { | ||
| const out = await api.call({ | ||
| target: EULER_RECEIPT, abi: eulerAbi.convertToAssets, params: eulerShares, permitFailure: true | ||
| }) | ||
| if (out) eulerUnderlying = toBN(out) | ||
| } | ||
|
|
||
| // 4) Add both underlyings as USDt | ||
| if (benqiUnderlying > 0n) api.add(USDt, benqiUnderlying) | ||
|
||
| if (eulerUnderlying > 0n) api.add(USDt, eulerUnderlying) | ||
|
|
||
| return api.getBalances() | ||
| } | ||
|
|
||
| module.exports = { | ||
| methodology: | ||
| 'TVL = USDt underlying represented by Benqi/Euler receipt tokens held in vaults (Benqi: shares*exchangeRate/1e18, Euler: convertToAssets).', | ||
| avax: { | ||
| tvl, | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // projects/pumpspace/index.js | ||
| const ADDRESSES = require('../helper/coreAssets.json') | ||
| const { staking } = require('../helper/staking') | ||
| const { getUniTVL } = require('../helper/unknownTokens'); | ||
| const { getTridentTVL } = require('../helper/sushi-trident') | ||
| const sdk = require('@defillama/sdk') | ||
|
|
||
| const CHAIN = 'avax' | ||
|
|
||
| // --- FACTORIES / CONTRACTS --- | ||
| const PUMP_FACTORY = '0x26B42c208D8a9d8737A2E5c9C57F4481484d4616' // V2 | ||
| const PUMP_V3 = '0xE749c1cA2EA4f930d1283ad780AdE28625037CeD' // V3/Trident | ||
|
|
||
| // If you later expose staking for other MasterChefs, add here | ||
| const MASTERCHEFS = [ | ||
| '0x40a58fc672F7878F068bD8ED234a47458Ec33879', // SHELL | ||
| '0x56b54a1384d35C63cD95b39eDe9339fEf7df3E42', // KRILL | ||
| '0x06C551B19239fE6a425b3c45Eb8b49d28e8283C6', // PEARL | ||
| ] | ||
|
|
||
| // --- TOKENS (project/local wrappers + protocol tokens) --- | ||
| const TOKENS = { | ||
| SHELL: '0xaD4CB79293322c07973ee83Aed5DF66A53214dc6', | ||
| } | ||
|
|
||
|
|
||
| module.exports = { | ||
| misrepresentedTokens: true, | ||
| methodology: ` | ||
| TVL is computed by summing reserves across PumpSpace V2 and V3 (Trident) factories on Avalanche. | ||
| Single-asset staking (if enabled) reflects tokens deposited in the respective MasterChef contracts. | ||
| `, | ||
| avax: { | ||
| tvl: sdk.util.sumChainTvls([ | ||
| // v2FactoryTVL, | ||
| // v3FactoryTVL, | ||
| getUniTVL({ factory: PUMP_FACTORY, useDefaultCoreAssets: true }), | ||
| getTridentTVL({ chain: CHAIN, factory:PUMP_V3 }), | ||
| ]), | ||
| staking: sdk.util.sumChainTvls([ | ||
| // If you later add KRILL/PEARL single-asset staking, append similar lines here. | ||
| staking([MASTERCHEFS[0]], [TOKENS.SHELL]), | ||
| ]) | ||
| }, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we price both of these too, you can just export a balance of the receipt tokens, no need for conversion