1
+ const CHAIN = 'xp' ;
2
+ const LOCKUP = '0x43A15af1D18B8159bA06df4ec66190451e1f4D70' ;
3
+ const NATIVE_ADDR = '0x8c290B96768210Dc1Ab64970Ff62F0F97be00431' ;
4
+ const BATCH_SIZE = 100 ;
5
+
6
+ const ABI = {
7
+ getLockedAccountsCount : 'uint256:getLockedAccountsCount' ,
8
+ getLockedAccounts : 'function getLockedAccounts(uint256 offset, uint256 limit) view returns (address[])' ,
9
+ } ;
10
+
11
+ async function tvl ( _ts , _eb , _cb , { api } ) {
12
+ const total = Number ( await api . call ( {
13
+ target : LOCKUP ,
14
+ abi : ABI . getLockedAccountsCount ,
15
+ } ) ) ;
16
+
17
+ const owners = [ ] ;
18
+ for ( let i = 0 ; i < total ; i += BATCH_SIZE ) {
19
+ const batch = await api . call ( {
20
+ target : LOCKUP ,
21
+ abi : ABI . getLockedAccounts ,
22
+ params : [ i , BATCH_SIZE ] ,
23
+ } ) ;
24
+ owners . push ( ...batch ) ;
25
+ }
26
+
27
+ let sum = 0n ;
28
+ for ( const addr of owners ) {
29
+ const balance = await api . provider . getBalance ( addr ) ;
30
+ console . log ( `Address: ${ addr } , Balance: ${ balance } ` ) ;
31
+ sum += BigInt ( balance . toString ( ) ) ;
32
+ }
33
+
34
+ return {
35
+ [ `${ CHAIN } :${ NATIVE_ADDR } ` ] : sum . toString ( )
36
+ } ;
37
+ }
38
+
39
+ module . exports = {
40
+ timetravel : true ,
41
+ start : 1744859889 ,
42
+ methodology : `
43
+ 1. Retrieve all locked user addresses by calling getLockedAccountsCount and getLockedAccounts from the Lockup contract.
44
+ 2. For each address, fetch the current XP balance using api.provider.getBalance, which reflects both the locked amount and accrued rewards.
45
+ 3. Sum all balances to calculate the total value of native XP held across the locked accounts, and return this as the protocol’s TVL.
46
+ ` ,
47
+ [ CHAIN ] : { tvl } ,
48
+ } ;
0 commit comments