1
- const { pool2 } = require ( '../helper/pool2' )
2
- const { staking } = require ( '../helper/staking' )
3
- const LANDSHARE_TOKEN_CONTRACT = '0xA73164DB271931CF952cBaEfF9E8F5817b42fA5C'
4
- const LANDSHARE_STAKING_CONTRACT = '0x3f9458892fB114328Bc675E11e71ff10C847F93b'
5
- const LANDSHARE_LP_TOKEN_CONTRACT = '0x13f80c53b837622e899e1ac0021ed3d1775caefa'
1
+ const ADDRESSES = require ( '../helper/coreAssets.json' ) ;
2
+
3
+ const MASTER_CHEF = '0x3f9458892fB114328Bc675E11e71ff10C847F93b' ;
4
+ const LAND_TOKEN = '0xA73164DB271931CF952cBaEfF9E8F5817b42fA5C' ;
5
+ const LAND_BNB_LP = '0x13F80c53b837622e899E1ac0021ED3D1775CAeFA' ;
6
+ const USDT = ADDRESSES . bsc . USDT ; // Use standard USDT address
7
+ const LSRWA_USDT_LP = '0x89bad177367736C186F7b41a9fba7b23474A1b35' ;
8
+ const API_CONSUMER = '0x61f8c9fE835e4CA722Db3A81a2746260b0D77735' ;
9
+ const WBNB = ADDRESSES . bsc . WBNB ; // Use standard WBNB address
6
10
7
11
module . exports = {
12
+ timetravel : false ,
13
+ misrepresentedTokens : false ,
14
+ methodology : 'TVL includes LAND-BNB LP in MasterChef, staked LAND, RWA value, and LSRWA-USDT LP balance.' ,
8
15
bsc : {
9
- tvl : ( ) => ( { } ) ,
10
- staking : staking ( LANDSHARE_STAKING_CONTRACT , LANDSHARE_TOKEN_CONTRACT ) ,
11
- pool2 : pool2 ( LANDSHARE_STAKING_CONTRACT , LANDSHARE_LP_TOKEN_CONTRACT ) ,
16
+ tvl : async ( api ) => {
17
+ try {
18
+ // 1. LAND-BNB LP in MasterChef (PID 1) - get WBNB amount and multiply by 2
19
+ const [ bnbInLP , totalLPSupply , lpStakedAmount ] = await Promise . all ( [
20
+ api . call ( { abi : 'erc20:balanceOf' , target : WBNB , params : [ LAND_BNB_LP ] } ) ,
21
+ api . call ( { abi : 'erc20:totalSupply' , target : LAND_BNB_LP } ) ,
22
+ // Get total LP tokens held by MasterChef (all staked LP tokens)
23
+ api . call ( { abi : 'erc20:balanceOf' , target : LAND_BNB_LP , params : [ MASTER_CHEF ] } )
24
+ ] ) ;
25
+
26
+ console . log ( `LP Staked Amount: ${ lpStakedAmount } ` ) ;
27
+ console . log ( `Total LP Supply: ${ totalLPSupply } ` ) ;
28
+ console . log ( `BNB in LP: ${ bnbInLP } ` ) ;
29
+
30
+ if ( Number ( lpStakedAmount ) > 0 ) {
31
+ // Calculate staked LP ratio and get BNB portion
32
+ const lpRatio = Number ( lpStakedAmount ) / Number ( totalLPSupply ) ;
33
+ const stakedBnbInLP = Number ( bnbInLP ) * lpRatio ;
34
+
35
+ console . log ( `LP Ratio: ${ lpRatio } ` ) ;
36
+ console . log ( `BNB in staked LP: ${ stakedBnbInLP } ` ) ;
37
+ console . log ( `LP Value (BNB * 2): ${ stakedBnbInLP * 2 } ` ) ;
38
+
39
+ // Add BNB amount * 2 to represent full LP value (will show as WBNB in output)
40
+ api . add ( WBNB , stakedBnbInLP * 2 ) ;
41
+ }
42
+
43
+ // 2. LAND token staked - use totalStaked() function from MasterChef
44
+ const totalLandStaked = await api . call ( {
45
+ abi : 'function totalStaked() view returns (uint256)' ,
46
+ target : MASTER_CHEF
47
+ } ) ;
48
+
49
+ console . log ( `Total LAND staked: ${ totalLandStaked } ` ) ;
50
+ if ( Number ( totalLandStaked ) > 0 ) {
51
+ api . add ( LAND_TOKEN , totalLandStaked ) ;
52
+ }
53
+
54
+ // 3. RWA value - from getTotalValue() converted via formatEther
55
+ const rwaValue = await api . call ( {
56
+ abi : 'function getTotalValue() view returns (uint256)' ,
57
+ target : API_CONSUMER
58
+ } ) ;
59
+
60
+ console . log ( `RWA Value: ${ rwaValue } ` ) ;
61
+ if ( Number ( rwaValue ) > 0 ) {
62
+ api . addUSDValue ( Number ( rwaValue ) / 1e18 ) ;
63
+ }
64
+
65
+ // 4. LSRWA-USDT LP - add the LP token itself, not just USDT balance
66
+ const lsrwaUsdtLPBalance = await api . call ( {
67
+ abi : 'erc20:balanceOf' ,
68
+ target : LSRWA_USDT_LP ,
69
+ params : [ MASTER_CHEF ] // Or wherever it's staked
70
+ } ) ;
71
+
72
+ console . log ( `LSRWA-USDT LP Balance: ${ lsrwaUsdtLPBalance } ` ) ;
73
+ if ( Number ( lsrwaUsdtLPBalance ) > 0 ) {
74
+ api . add ( LSRWA_USDT_LP , lsrwaUsdtLPBalance ) ;
75
+ }
76
+
77
+ return api . getBalances ( ) ;
78
+
79
+ } catch ( error ) {
80
+ console . error ( 'Error in TVL calculation:' , error ) ;
81
+ throw error ;
82
+ }
83
+ } ,
12
84
} ,
13
- }
85
+ } ;
0 commit comments