Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions projects/fasset-fxrp/addresses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
// FXRP Token
FXRP: '0xAd552A648C74D49E10027AB8a618A3ad4901c5bE',

// Kinetic ISO Market (isoFXRP cToken)
KINETIC_ISO_FXRP: '0x870f7B89F0d408D7CA2E6586Df26D00Ea03aA358',

// SparkDEX V3-1 Pools (FXRP pairs)
SPARKDEX_V3_POOLS: [
'0xECe100A0b337bdfa0297654f2ce49bb3936d2364', // FXRP/WFLR 0.01%
'0x589689984a06E4640593eDec64e415c415940C7F', // FXRP/WFLR 0.05%
'0xDAD1976C48cf93A7D90f106382C60Cd2c888b2dc', // FXRP/WFLR 0.3%
'0x08E6cB0c6b91dba21B9b5DFF5694faB75fA91440', // FXRP/WFLR 1%
'0xE419b154cf5a27e93966Fce28E253cADcDBE5CCF', // FXRP/USDT0 0.01%
'0x88D46717b16619B37fa2DfD2F038DEFB4459F1F7', // FXRP/USDT0 0.05%
'0x8F7E2dCbbb1A1BCacE7832e4770ec31D8C6937cB', // FXRP/USDT0 0.3%
'0x38dE858370813ae58af11245962a9b03B661a9Ae', // FXRP/USDT0 1%
],

// SparkDEX V2 Pool
SPARKDEX_V2_FXRP_WFLR: '0xa76a120567ed3ab3065759d3ad3ab2acd79530bf',

// Firelight stXRP
STXRP: '0x4C18Ff3C89632c3Dd62E796c0aFA5c07c4c1B2b3',
};
46 changes: 46 additions & 0 deletions projects/fasset-fxrp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const { ChainApi } = require('@defillama/sdk');
const ADDRESSES = require('../helper/coreAssets.json');
const { FXRP, KINETIC_ISO_FXRP, SPARKDEX_V3_POOLS, SPARKDEX_V2_FXRP_WFLR, STXRP } = require('./addresses');

async function tvl(api) {
// Create Flare API to call contracts on Flare chain
const flareApi = new ChainApi({ chain: 'flare', timestamp: api.timestamp });
await flareApi.getBlock();

// Kinetic: getCash() + totalBorrows() = total FXRP supplied
const [kineticCash, kineticBorrows] = await Promise.all([
flareApi.call({ abi: 'uint256:getCash', target: KINETIC_ISO_FXRP }),
flareApi.call({ abi: 'uint256:totalBorrows', target: KINETIC_ISO_FXRP }),
]);

// SparkDEX V3-1: FXRP balance in each pool
const v3Balances = await flareApi.multiCall({
abi: 'erc20:balanceOf',
calls: SPARKDEX_V3_POOLS.map(pool => ({ target: FXRP, params: [pool] })),
});

// SparkDEX V2: FXRP balance in pool
const v2Balance = await flareApi.call({
abi: 'erc20:balanceOf',
target: FXRP,
params: [SPARKDEX_V2_FXRP_WFLR],
});

// Firelight: stXRP totalSupply (backed 1:1 by FXRP)
const stxrpSupply = await flareApi.call({ abi: 'uint256:totalSupply', target: STXRP });

// Sum all FXRP and add as XRP to ripple chain
const totalFxrp = BigInt(kineticCash) + BigInt(kineticBorrows) +
v3Balances.reduce((sum, b) => sum + BigInt(b), 0n) +
BigInt(v2Balance) + BigInt(stxrpSupply);

api.add(ADDRESSES.ripple.XRP, totalFxrp.toString());
return api.getBalances();
}

module.exports = {
ripple: {
tvl,
},
methodology: "Counts total FXRP across Flare DeFi: Kinetic (lending), SparkDEX V2/V3 (liquidity pools), and Firelight (staking). FXRP is 1:1 backed by XRP.",
};
Loading