Skip to content

Commit 2126a82

Browse files
committed
Update Landshare
1 parent b41d229 commit 2126a82

File tree

1 file changed

+25
-79
lines changed

1 file changed

+25
-79
lines changed

projects/landshare/index.js

Lines changed: 25 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,31 @@
1-
const ADDRESSES = require('../helper/coreAssets.json');
1+
const { staking } = require("../helper/staking");
2+
const { pool2s } = require("../helper/pool2");
23

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';
4+
const LANDSHARE_TOKEN_CONTRACT = '0xA73164DB271931CF952cBaEfF9E8F5817b42fA5C';
5+
const LANDSHARE_STAKING_CONTRACT = '0x3f9458892fB114328Bc675E11e71ff10C847F93b';
6+
const LANDSHARE_LP_TOKEN_CONTRACT = '0x13f80c53b837622e899e1ac0021ed3d1775caefa';
87
const API_CONSUMER = '0x61f8c9fE835e4CA722Db3A81a2746260b0D77735';
9-
const WBNB = ADDRESSES.bsc.WBNB; // Use standard WBNB address
10-
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.',
15-
bsc: {
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-
}
8+
const USDT = '0x55d398326f99059fF775485246999027B3197955';
9+
const LSRWA_USDT_LP = '0x89bad177367736C186F7b41a9fba7b23474A1b35';
5310

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-
}
6411

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-
}
12+
async function tvl(api) {
13+
// RWA property value from on-chain API consumer
14+
const rwaValue = await api.call({
15+
abi: 'function getTotalValue() view returns (uint256)',
16+
target: API_CONSUMER,
17+
});
18+
if (Number(rwaValue) > 0) {
19+
api.addUSDValue(Number(rwaValue) / 1e18);
20+
}
21+
}
7622

77-
return api.getBalances();
7823

79-
} catch (error) {
80-
console.error('Error in TVL calculation:', error);
81-
throw error;
82-
}
83-
},
84-
},
85-
};
24+
module.exports = {
25+
methodology: 'Counts LP Tokens (LAND-BNB and LSRWA-USDT), staked LAND, and LSRWA TVL',
26+
bsc: {
27+
staking: staking(LANDSHARE_STAKING_CONTRACT, LANDSHARE_TOKEN_CONTRACT),
28+
pool2: pool2s([LANDSHARE_STAKING_CONTRACT], [LANDSHARE_LP_TOKEN_CONTRACT, LSRWA_USDT_LP]),
29+
tvl,
30+
}
31+
};

0 commit comments

Comments
 (0)