From 0a0c357705df28d35841cc0f719d8ca016a2b858 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:04:17 +0200 Subject: [PATCH] Add support for fCOIN on multiple chains (#11268) * report nav for fCOIN on all deployed chains * merge fortunafi adapters --------- Co-authored-by: eukadish --- projects/fortunafi-fbill/index.js | 32 --------------------------- projects/fortunafi-ifbill/index.js | 31 -------------------------- projects/fortunafi/index.js | 35 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 63 deletions(-) delete mode 100644 projects/fortunafi-fbill/index.js delete mode 100644 projects/fortunafi-ifbill/index.js create mode 100644 projects/fortunafi/index.js diff --git a/projects/fortunafi-fbill/index.js b/projects/fortunafi-fbill/index.js deleted file mode 100644 index 208728f2e2f6..000000000000 --- a/projects/fortunafi-fbill/index.js +++ /dev/null @@ -1,32 +0,0 @@ -const ADDRESSES = require('../helper/coreAssets.json') - -const contracts = { - canto: { - token: '0x79ECCE8E2D17603877Ff15BC29804CbCB590EC08' - }, - arbitrum: { - token: '0x79ECCE8E2D17603877Ff15BC29804CbCB590EC08' - }, - blast: { - token: '0x79ECCE8E2D17603877Ff15BC29804CbCB590EC08' - } -} - -const tvl = async (api) => { - const nav = await api.call({ target: contracts[api.chain].token, abi: 'function nav() external view returns (uint256)' }); - - switch (api.chain) { - case 'blast': - api.add(ADDRESSES['blast'].USDB, nav); - break; - default: - api.add(ADDRESSES[api.chain].USDC, nav / 1e12); - } -} - -module.exports = { - misrepresentedTokens: true, - canto: { tvl }, - arbitrum: { tvl }, - blast: { tvl } -}; diff --git a/projects/fortunafi-ifbill/index.js b/projects/fortunafi-ifbill/index.js deleted file mode 100644 index 0b20c6c11da9..000000000000 --- a/projects/fortunafi-ifbill/index.js +++ /dev/null @@ -1,31 +0,0 @@ -const ADDRESSES = require('../helper/coreAssets.json') - -const contracts = { - canto: { - token: '0x45bafad5a6a531Bc18Cf6CE5B02C58eA4D20589b' - }, - arbitrum: { - token: '0x45bafad5a6a531Bc18Cf6CE5B02C58eA4D20589b' - }, - blast: { - token: '0x45bafad5a6a531Bc18Cf6CE5B02C58eA4D20589b' - } -}; - -const tvl = async (_, _1, _2, { api }) => { - const nav = await api.call({ target: contracts[api.chain].token, abi: 'function nav() external view returns (uint256)' }); - - switch (api.chain) { - case 'blast': - api.add(ADDRESSES['blast'].USDB, nav); - break; - default: - api.add(ADDRESSES[api.chain].USDC, nav / 1e12); - } -} - -module.exports = { - canto: { tvl }, - arbitrum: { tvl }, - blast: { tvl } -}; diff --git a/projects/fortunafi/index.js b/projects/fortunafi/index.js new file mode 100644 index 000000000000..16071d86359a --- /dev/null +++ b/projects/fortunafi/index.js @@ -0,0 +1,35 @@ + +const config = { + canto: { + fbill: '0x79ECCE8E2D17603877Ff15BC29804CbCB590EC08', + fCOIN: '0x855EA9979189383ef5A85eB74Ed3a02E2604EA81', + ifBill: '0x45bafad5a6a531Bc18Cf6CE5B02C58eA4D20589b', + }, + arbitrum: { + fbill: '0x79ECCE8E2D17603877Ff15BC29804CbCB590EC08', + fCOIN: '0x108Ec61bd5A91F5596F824832524C6b6002E3F03', + ifBill: '0x45bafad5a6a531Bc18Cf6CE5B02C58eA4D20589b', + }, + blast: { + fbill: '0x79ECCE8E2D17603877Ff15BC29804CbCB590EC08', + fCOIN: '0xE85Ae7e8Fa0Ee69426019b7D3E77843673807ABE', + ifBill: '0x45bafad5a6a531Bc18Cf6CE5B02C58eA4D20589b', + }, + ethereum: { + fCOIN: '0x2378aC4EEAAe44695E1e3d0fcAEEd6ba8b0F5108', + }, +} + +module.exports = { + misrepresentedTokens: true, +} + +Object.keys(config).forEach(chain => { + const tConfig = config[chain] + module.exports[chain] = { + tvl: async (api) => { + const nav = await api.multiCall({ abi: 'uint256:nav', calls: Object.values(tConfig), permitFailure: true }) + api.addCGToken('tether', nav.reduce((acc, i) => acc + (i ?? 0)/1e18, 0)) + } + } +})