1
- const { sumTokens2, unwrapSlipstreamNFT, } = require ( "../helper/unwrapLPs" ) ;
1
+ const { sumTokens2, unwrapSlipstreamNFT } = require ( "../helper/unwrapLPs" ) ;
2
2
3
3
const config = {
4
- base : {
5
- factory : "0xDa14Fdd72345c4d2511357214c5B89A919768e59" ,
6
- pools : {
7
- wethPool : "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2" ,
8
- usdcPool : "0x3ec4a293Fb906DD2Cd440c20dECB250DeF141dF1" ,
9
- cbbtcPool : "0xa37E9b4369dc20940009030BfbC2088F09645e3B"
10
- } ,
11
- uniNFT : "0x03a520b32c04bf3beef7beb72e919cf822ed34f1" ,
12
- alienBaseNFT : "0xb7996d1ecd07fb227e8dca8cd5214bdfb04534e5" ,
13
- slipNFT : "0x827922686190790b37229fd06084350e74485b72" ,
14
- wAeroNFT : "0x17B5826382e3a5257b829cF0546A08Bd77409270" . toLowerCase ( ) ,
15
- sAeroNFT : "0x9f42361B7602Df1A8Ae28Bf63E6cb1883CD44C27" . toLowerCase ( ) ,
16
- sSlipNFT : "0x1Dc7A0f5336F52724B650E39174cfcbbEdD67bF1" . toLowerCase ( ) ,
17
- } ,
4
+ factory : "0xDa14Fdd72345c4d2511357214c5B89A919768e59" ,
5
+ uniNFT : "0x03a520b32c04bf3beef7beb72e919cf822ed34f1" ,
6
+ alienBaseNFT : "0xb7996d1ecd07fb227e8dca8cd5214bdfb04534e5" ,
7
+ slipNFT : "0x827922686190790b37229fd06084350e74485b72" ,
8
+ wAeroNFT : "0x17B5826382e3a5257b829cF0546A08Bd77409270" . toLowerCase ( ) ,
9
+ sAeroNFT : "0x9f42361B7602Df1A8Ae28Bf63E6cb1883CD44C27" . toLowerCase ( ) ,
10
+ sSlipNFT : "0x1Dc7A0f5336F52724B650E39174cfcbbEdD67bF1" . toLowerCase ( ) ,
11
+ pools : [
12
+ "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2" , // wethPool
13
+ "0x3ec4a293Fb906DD2Cd440c20dECB250DeF141dF1" , // usdcPool
14
+ "0xa37E9b4369dc20940009030BfbC2088F09645e3B" // cbbtcPool
15
+ ]
18
16
} ;
19
17
20
- async function unwrapArcadiaAeroLP ( { api, ownerIds, } ) {
21
- const { wAeroNFT, sAeroNFT, sSlipNFT } = config [ api . chain ]
18
+ async function unwrapArcadiaAeroLP ( { api, ownerIds } ) {
19
+ const { wAeroNFT, sAeroNFT, sSlipNFT } = config
22
20
const wAERONFTIds = [ ]
23
21
const sAERONFTIds = [ ]
24
22
const sSlipNftIds = [ ]
@@ -45,53 +43,57 @@ async function unwrapArcadiaAeroLP({ api, ownerIds, }) {
45
43
}
46
44
}
47
45
48
- const wrappedData = await api . multiCall ( { abi : abi . wrappedAeroPositionState , calls : wAERONFTIds , target : wAeroNFT , } ) ;
49
- const stakedData = await api . multiCall ( { abi : abi . stakedAeroPositionState , calls : sAERONFTIds , target : sAeroNFT , } ) ;
46
+ const wrappedData = await api . multiCall ( { abi : abi . positionState , calls : wAERONFTIds , target : wAeroNFT } ) ;
47
+ const stakedData = await api . multiCall ( { abi : abi . stakedAeroPositionState , calls : sAERONFTIds , target : sAeroNFT } ) ;
50
48
wrappedData . forEach ( ( data ) => api . add ( data . pool , data . amountWrapped ) ) ;
51
49
stakedData . forEach ( ( data ) => api . add ( data . pool , data . amountStaked ) ) ;
52
50
53
- await uwrapStakedSlipstreamLP ( { api, sSlipNftIds, } ) ;
51
+ await uwrapStakedSlipstreamLP ( { api, sSlipNftIds } ) ;
54
52
}
55
53
56
54
async function uwrapStakedSlipstreamLP ( { api, sSlipNftIds, } ) {
57
- const { slipNFT } = config [ api . chain ] ;
55
+ const { slipNFT } = config ;
58
56
const balances = api . getBalances ( ) ;
59
57
60
58
// Arcadia's staked slipstream NFT wrapper issues a position with the same ID as the wrapped NFT
61
59
// -> fetch the values of the wrapped IDs by simply fetching the values of those IDs on the native slipstream NFT
62
60
await unwrapSlipstreamNFT ( { balances : balances , positionIds : sSlipNftIds , nftAddress : slipNFT , chain : 'base' , blacklistedTokens : [ ] , whitelistedTokens : [ ] , uniV3ExtraConfig : { } } ) ;
63
61
}
64
62
65
- async function tvl ( api ) {
66
- let { factory, pools, uniNFT, slipNFT, wAeroNFT, sAeroNFT, sSlipNFT, alienBaseNFT } = config [ api . chain ] ;
67
- pools = Object . values ( pools ) ;
63
+ async function tvl ( api ) {
64
+ const { factory, pools, uniNFT, slipNFT, wAeroNFT, sAeroNFT, sSlipNFT, alienBaseNFT } = config ;
65
+ const ownerTokens = [ ]
66
+ const ownerIds = [ ]
67
+ const accs = [ ]
68
+
68
69
const uTokens = await api . multiCall ( { abi : "address:asset" , calls : pools } ) ;
69
- await api . sumTokens ( { tokensAndOwners2 : [ uTokens , pools ] } ) ;
70
- const accounts = await api . fetchList ( { lengthAbi : 'allAccountsLength' , itemAbi : 'allAccounts' , target : factory , } ) ;
70
+ const accounts = await api . fetchList ( { lengthAbi : 'allAccountsLength' , itemAbi : 'allAccounts' , target : factory , } )
71
+ const assetDatas = await api . multiCall ( { abi : abi . generateAssetData , calls : accounts , permitFailure : true } )
72
+
73
+ accounts . forEach ( ( account , i ) => {
74
+ const assetData = assetDatas [ i ] ;
75
+ if ( ! assetData || ! assetData . assets || ! assetData . assets . length ) return ;
76
+ ownerTokens . push ( [ assetData . assets , account ] )
77
+ if ( ! assetData [ 0 ] . length || ! assetData [ 1 ] . length ) return ;
78
+ ownerIds . push ( [ assetData [ 0 ] , assetData [ 1 ] , account ] )
79
+ accs . push ( account )
80
+ } )
81
+
71
82
if ( alienBaseNFT )
72
- await sumTokens2 ( { api, owners : accounts , uniV3ExtraConfig : { nftAddress : alienBaseNFT } } )
73
-
74
- const assetData = await api . multiCall ( { abi : abi . assetData , calls : accounts , } ) ;
75
- const ownerTokens = accounts . map ( ( account , i ) => [ assetData [ i ] . assets , account ] )
76
- const ownerIds = accounts . map ( ( account , i ) => [
77
- assetData [ i ] [ 0 ] ,
78
- assetData [ i ] [ 1 ] ,
79
- account ,
80
- ] ) ;
83
+ await sumTokens2 ( { api, owners : accs , uniV3ExtraConfig : { nftAddress : alienBaseNFT } } )
84
+
81
85
// add all simple ERC20s
82
- await api . sumTokens ( { ownerTokens, blacklistedTokens : [ uniNFT , slipNFT , wAeroNFT , sAeroNFT , sSlipNFT , alienBaseNFT , ] , } ) ;
86
+ await api . sumTokens ( { ownerTokens, blacklistedTokens : [ uniNFT , slipNFT , wAeroNFT , sAeroNFT , sSlipNFT , alienBaseNFT ] , tokensAndOwners2 : [ uTokens , pools ] } ) ;
83
87
84
88
// add all Arcadia-wrapped LP positions
85
89
await unwrapArcadiaAeroLP ( { api, ownerIds } ) ;
86
90
87
91
// add all native LP positions
88
- return sumTokens2 ( { api, owners : accounts , resolveUniV3 : true , resolveSlipstream : true } )
89
-
92
+ return sumTokens2 ( { api, owners : accs , resolveUniV3 : true , resolveSlipstream : true } )
90
93
}
91
94
92
95
module . exports = {
93
- methodology :
94
- "TVL is calculated as the sum of all Account values and the available balance in the liquidity pools. Assets are not double counted." ,
96
+ methodology : "TVL is calculated as the sum of all Account values and the available balance in the liquidity pools. Assets are not double counted." ,
95
97
base : { tvl } ,
96
98
start : '2024-03-25' , // Mon Mar 25 2024 18:00:00 GMT+0000
97
99
hallmarks : [
@@ -100,10 +102,7 @@ module.exports = {
100
102
} ;
101
103
102
104
const abi = {
103
- assetData :
104
- "function generateAssetData() view returns (address[] assets, uint256[], uint256[])" ,
105
- wrappedAeroPositionState :
106
- "function positionState(uint256 tokenId) view returns ((uint128 fee0PerLiquidity, uint128 fee1PerLiquidity, uint128 fee0, uint128 fee1, uint128 amountWrapped, address pool))" ,
107
- stakedAeroPositionState :
108
- "function positionState(uint256 tokenId) view returns ((address pool, uint128 amountStaked, uint128 lastRewardPerTokenPosition, uint128 lastRewardPosition))" ,
109
- } ;
105
+ generateAssetData : 'function generateAssetData() view returns (address[] assets, uint256[], uint256[])' ,
106
+ positionState : 'function positionState(uint256 tokenId) view returns ((uint128 fee0PerLiquidity, uint128 fee1PerLiquidity, uint128 fee0, uint128 fee1, uint128 amountWrapped, address pool))' ,
107
+ stakedAeroPositionState : 'function positionState(uint256 tokenId) view returns ((address pool, uint128 amountStaked, uint128 lastRewardPerTokenPosition, uint128 lastRewardPosition))'
108
+ }
0 commit comments