From aaee55c185ed202074a3f76908b58a8020f6fcd8 Mon Sep 17 00:00:00 2001 From: amadiaflare Date: Fri, 5 Dec 2025 12:44:48 -0500 Subject: [PATCH] add: total FXRP across Kinetic, SpeakDex (v2/v3), and Firelight --- projects/fasset-fxrp/addresses.js | 25 +++++++++++++++++ projects/fasset-fxrp/index.js | 46 +++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 projects/fasset-fxrp/addresses.js create mode 100644 projects/fasset-fxrp/index.js diff --git a/projects/fasset-fxrp/addresses.js b/projects/fasset-fxrp/addresses.js new file mode 100644 index 00000000000..92490005ef3 --- /dev/null +++ b/projects/fasset-fxrp/addresses.js @@ -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', +}; diff --git a/projects/fasset-fxrp/index.js b/projects/fasset-fxrp/index.js new file mode 100644 index 00000000000..0188f283044 --- /dev/null +++ b/projects/fasset-fxrp/index.js @@ -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.", +};