Skip to content

Commit aaee55c

Browse files
committed
add: total FXRP across Kinetic, SpeakDex (v2/v3), and Firelight
1 parent 960b6c7 commit aaee55c

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

projects/fasset-fxrp/addresses.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
// FXRP Token
3+
FXRP: '0xAd552A648C74D49E10027AB8a618A3ad4901c5bE',
4+
5+
// Kinetic ISO Market (isoFXRP cToken)
6+
KINETIC_ISO_FXRP: '0x870f7B89F0d408D7CA2E6586Df26D00Ea03aA358',
7+
8+
// SparkDEX V3-1 Pools (FXRP pairs)
9+
SPARKDEX_V3_POOLS: [
10+
'0xECe100A0b337bdfa0297654f2ce49bb3936d2364', // FXRP/WFLR 0.01%
11+
'0x589689984a06E4640593eDec64e415c415940C7F', // FXRP/WFLR 0.05%
12+
'0xDAD1976C48cf93A7D90f106382C60Cd2c888b2dc', // FXRP/WFLR 0.3%
13+
'0x08E6cB0c6b91dba21B9b5DFF5694faB75fA91440', // FXRP/WFLR 1%
14+
'0xE419b154cf5a27e93966Fce28E253cADcDBE5CCF', // FXRP/USDT0 0.01%
15+
'0x88D46717b16619B37fa2DfD2F038DEFB4459F1F7', // FXRP/USDT0 0.05%
16+
'0x8F7E2dCbbb1A1BCacE7832e4770ec31D8C6937cB', // FXRP/USDT0 0.3%
17+
'0x38dE858370813ae58af11245962a9b03B661a9Ae', // FXRP/USDT0 1%
18+
],
19+
20+
// SparkDEX V2 Pool
21+
SPARKDEX_V2_FXRP_WFLR: '0xa76a120567ed3ab3065759d3ad3ab2acd79530bf',
22+
23+
// Firelight stXRP
24+
STXRP: '0x4C18Ff3C89632c3Dd62E796c0aFA5c07c4c1B2b3',
25+
};

projects/fasset-fxrp/index.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const { ChainApi } = require('@defillama/sdk');
2+
const ADDRESSES = require('../helper/coreAssets.json');
3+
const { FXRP, KINETIC_ISO_FXRP, SPARKDEX_V3_POOLS, SPARKDEX_V2_FXRP_WFLR, STXRP } = require('./addresses');
4+
5+
async function tvl(api) {
6+
// Create Flare API to call contracts on Flare chain
7+
const flareApi = new ChainApi({ chain: 'flare', timestamp: api.timestamp });
8+
await flareApi.getBlock();
9+
10+
// Kinetic: getCash() + totalBorrows() = total FXRP supplied
11+
const [kineticCash, kineticBorrows] = await Promise.all([
12+
flareApi.call({ abi: 'uint256:getCash', target: KINETIC_ISO_FXRP }),
13+
flareApi.call({ abi: 'uint256:totalBorrows', target: KINETIC_ISO_FXRP }),
14+
]);
15+
16+
// SparkDEX V3-1: FXRP balance in each pool
17+
const v3Balances = await flareApi.multiCall({
18+
abi: 'erc20:balanceOf',
19+
calls: SPARKDEX_V3_POOLS.map(pool => ({ target: FXRP, params: [pool] })),
20+
});
21+
22+
// SparkDEX V2: FXRP balance in pool
23+
const v2Balance = await flareApi.call({
24+
abi: 'erc20:balanceOf',
25+
target: FXRP,
26+
params: [SPARKDEX_V2_FXRP_WFLR],
27+
});
28+
29+
// Firelight: stXRP totalSupply (backed 1:1 by FXRP)
30+
const stxrpSupply = await flareApi.call({ abi: 'uint256:totalSupply', target: STXRP });
31+
32+
// Sum all FXRP and add as XRP to ripple chain
33+
const totalFxrp = BigInt(kineticCash) + BigInt(kineticBorrows) +
34+
v3Balances.reduce((sum, b) => sum + BigInt(b), 0n) +
35+
BigInt(v2Balance) + BigInt(stxrpSupply);
36+
37+
api.add(ADDRESSES.ripple.XRP, totalFxrp.toString());
38+
return api.getBalances();
39+
}
40+
41+
module.exports = {
42+
ripple: {
43+
tvl,
44+
},
45+
methodology: "Counts total FXRP across Flare DeFi: Kinetic (lending), SparkDEX V2/V3 (liquidity pools), and Firelight (staking). FXRP is 1:1 backed by XRP.",
46+
};

0 commit comments

Comments
 (0)