Skip to content

Commit 6051626

Browse files
authored
Add Aerodrome positions and new tokens (DefiLlama#14758)
1 parent 994fa7e commit 6051626

File tree

1 file changed

+71
-9
lines changed

1 file changed

+71
-9
lines changed

projects/degenPrime/index.js

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ const getAllOwnedAssetsAbi = "function getAllOwnedAssets() view returns (bytes32
77
const getLoansAbi = "function getLoans(uint256 _from, uint256 _count) view returns (address[] _loans)"
88
const getPrimeAccountsLengthAbi = 'uint256:getLoansLength';
99

10-
10+
// Aerodrome position ABIs
11+
const getOwnedStakedAerodromeTokenIdsAbi = "function getOwnedStakedAerodromeTokenIds() public view returns (uint256[] memory)"
12+
const getPositionCompositionAbi = "function getPositionCompositionSimplified(uint256 positionId) public view returns (tuple(address token0, address token1, uint256 token0Amount, uint256 token1Amount) positionComposition)"
1113

1214
const assetToAddressMappingBase = {
1315
"cbBTC": ADDRESSES.base.cbBTC,
@@ -24,7 +26,17 @@ const assetToAddressMappingBase = {
2426
"VIRTUAL": "0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
2527
"MOG": "0x2Da56AcB9Ea78330f947bD57C54119Debda7AF71",
2628
"AIXBT": "0x4F9Fd6Be4a90f2620860d680c0d4d5Fb53d1A825",
27-
"KAITO": "0x98d0baa52b2D063E780DE12F615f963Fe8537553"
29+
"KAITO": "0x98d0baa52b2D063E780DE12F615f963Fe8537553",
30+
"ezETH": "0x2416092f143378750bb29b79eD961ab195CcEea5",
31+
"weETH": "0x04C0599Ae5A44757c0af6F9eC3b93da8976c150A",
32+
"EUROC": "0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",
33+
"VVV": "0xacfe6019ed1a7dc6f7b508c02d1b04ec88cc21bf",
34+
"COOKIE": "0xc0041ef357b183448b235a8ea73ce4e4ec8c265f",
35+
"BNKR": "0x22af33fe49fd1fa80c7149773dde5890d3c76f3b",
36+
"ZORA": "0x1111111111166b7fe7bd91427724b487980afc69",
37+
"DINO": "0x85E90a5430AF45776548ADB82eE4cD9E33B08077",
38+
"DRB": "0x3ec2156d4c0a9cbdab4a016633b7bcf6a8d68ea2",
39+
"CLANKER": "0x1bc0c42215582d5a085795f4badbac3ff36d1bcb",
2840
}
2941

3042
// Base
@@ -37,11 +49,60 @@ const KAITO_POOL_TUP_CONTRACT = '0x293E41F1405Dde427B41c0074dee0aC55D064825';
3749

3850
const SMART_LOANS_FACTORY_TUP_BASE = '0x5A6a0e2702cF4603a098C3Df01f3F0DF56115456';
3951

40-
/**
41-
* TVL for Base
42-
* @param {Object} api - api object from sdk
43-
* @returns {Promise<Object>} - TVL object
44-
*/
52+
/**
53+
* Add Aerodrome LP positions to TVL calculation
54+
* @param {Object} api - api object from sdk
55+
* @param {Array} accounts - array of account addresses
56+
*/
57+
async function addAerodromePositions({ api, accounts }) {
58+
// Get all owned Aerodrome token IDs for each account
59+
const ownedTokenIds = await api.multiCall({
60+
abi: getOwnedStakedAerodromeTokenIdsAbi,
61+
calls: accounts
62+
});
63+
64+
const positionCalls = [];
65+
66+
// Prepare calls for getPositionCompositionSimplified for each token ID
67+
ownedTokenIds.forEach((tokenIds, accountIndex) => {
68+
const account = accounts[accountIndex];
69+
tokenIds.forEach(tokenId => {
70+
positionCalls.push({
71+
target: account,
72+
params: [tokenId]
73+
});
74+
});
75+
});
76+
77+
if (positionCalls.length === 0) {
78+
sdk.log('No Aerodrome positions found');
79+
return;
80+
}
81+
82+
// Get position compositions
83+
const positionCompositions = await api.multiCall({
84+
abi: getPositionCompositionAbi,
85+
calls: positionCalls
86+
});
87+
88+
// Add token amounts to balances
89+
positionCompositions.forEach(({ token0, token1, token0Amount, token1Amount }) => {
90+
if (token0Amount > 0) {
91+
api.add(token0, token0Amount);
92+
}
93+
if (token1Amount > 0) {
94+
api.add(token1, token1Amount);
95+
}
96+
});
97+
98+
sdk.log(`Added ${positionCalls.length} Aerodrome positions to TVL`);
99+
}
100+
101+
/**
102+
* TVL for Base
103+
* @param {Object} api - api object from sdk
104+
* @returns {Promise<Object>} - TVL object
105+
*/
45106
async function tvlBase(api) {
46107
const tokensAndOwners = [
47108
[assetToAddressMappingBase.USDC, USDC_POOL_TUP_CONTRACT],
@@ -68,6 +129,8 @@ async function tvlBase(api) {
68129

69130
sdk.log(accounts.length)
70131

132+
// Add Aerodrome positions to TVL calculation
133+
await addAerodromePositions({ api, accounts });
71134

72135
const ownedAssets = await api.multiCall({ abi: getAllOwnedAssetsAbi, calls: accounts })
73136
accounts.forEach((o, i) => {
@@ -86,9 +149,8 @@ async function tvlBase(api) {
86149
return sumTokens2({ api, tokensAndOwners: tokensAndOwners })
87150
}
88151

89-
90152
module.exports = {
91-
methodology: 'Counts TVL of DegenPrime\'s lending pools and individual PrimeAccount contracts\'',
153+
methodology: 'Counts TVL of DegenPrime\'s lending pools and individual PrimeAccount contracts including Aerodrome LP positions',
92154
base: {
93155
tvl: tvlBase,
94156
},

0 commit comments

Comments
 (0)