diff --git a/projects/helper/chains.json b/projects/helper/chains.json index 51b48cf4117..3c59565406d 100644 --- a/projects/helper/chains.json +++ b/projects/helper/chains.json @@ -264,6 +264,7 @@ "xpla", "zeniq", "zilliqa", + "zkfair", "zksync", "zyx" ] diff --git a/projects/helper/env.js b/projects/helper/env.js index e8c51b1447d..eb87ad19882 100644 --- a/projects/helper/env.js +++ b/projects/helper/env.js @@ -15,7 +15,8 @@ const DEFAULTS = { CORE_RPC: "https://rpc.coredao.org,https://rpc.ankr.com/core,https://1rpc.io/core,https://rpc-core.icecreamswap.com", BITGERT_RPC: "https://flux-rpc2.brisescan.com,https://mainnet-rpc.brisescan.com,https://chainrpc.com,https://serverrpc.com,https://flux-rpc.brisescan.com", LYRA_RPC: "https://rpc.lyra.finance", - BITCHAIN_RPC: "https://rpc.bitchain.biz/" + BITCHAIN_RPC: "https://rpc.bitchain.biz/", + ZKFAIR_RPC: "https://rpc.zkfair.io/", } const ENV_KEYS = [ diff --git a/projects/helper/tokenMapping.js b/projects/helper/tokenMapping.js index ad1bd6eb0a1..e4ad2bff9fa 100644 --- a/projects/helper/tokenMapping.js +++ b/projects/helper/tokenMapping.js @@ -150,6 +150,10 @@ const fixBalancesTokens = { [ADDRESSES.jbc.JFIN]: { coingeckoId: 'jfin-coin', decimals: 18 }, [ADDRESSES.jbc.KUB]: { coingeckoId: 'bitkub-coin', decimals: 18 }, }, + zkfair: { + [ADDRESSES.null]: { coingeckoId: 'usd-coin', decimals: 18 }, + '0xD33Db7EC50A98164cC865dfaa64666906d79319C': { coingeckoId: 'usd-coin', decimals: 18 }, + } } ibcChains.forEach(chain => fixBalancesTokens[chain] = { ...ibcMappings, ...(fixBalancesTokens[chain] || {}) }) diff --git a/projects/izumi-iziswap/index.js b/projects/izumi-iziswap/index.js index 0805b866566..3bccec39041 100644 --- a/projects/izumi-iziswap/index.js +++ b/projects/izumi-iziswap/index.js @@ -27,11 +27,14 @@ const poolHelpers = { 'manta': ['0x19b683A2F45012318d9B2aE1280d68d3eC54D663'], 'scroll': ['0x1502d025BfA624469892289D45C0352997251728'], 'base': ['0x110dE362cc436D7f54210f96b8C7652C2617887D'], + 'zkfair': ['0x110dE362cc436D7f54210f96b8C7652C2617887D'], } // iziswap liquidityManager contracts const blacklistedTokens = [ ADDRESSES.bsc.iUSD, '0x1382628e018010035999A1FF330447a0751aa84f', + '0x0A3BB08b3a15A19b4De82F8AcFc862606FB69A2D', // mantle iUSD + '0x078f712f038A95BeEA94F036cADB49188a90604b', // manta iUSD ] const tvl = async (_, _1, _2, { api }) => { diff --git a/projects/magma/index.js b/projects/magma/index.js new file mode 100644 index 00000000000..c73bbdc5cbf --- /dev/null +++ b/projects/magma/index.js @@ -0,0 +1,9 @@ +const { getLiquityTvl } = require('../helper/liquity') +// const { staking } = require('../helper/staking') + +module.exports = { + iotex: { + tvl: getLiquityTvl('0xAeB0B38040aDdc4a2b520919f13944D9bC944435'), + // staking: staking('0x109e342FE7132585abFa785887E2c05c85Fbcf71', '0x20143c45c2ce7984799079f256d8a68a918eeee6'), // disabled as backing of WEN is already counted towards tvl + }, +}; diff --git a/projects/sideswap-fi/index.js b/projects/sideswap-fi/index.js new file mode 100644 index 00000000000..77b6923cb05 --- /dev/null +++ b/projects/sideswap-fi/index.js @@ -0,0 +1,3 @@ +const { uniTvlExport } = require('../helper/unknownTokens') + +module.exports = uniTvlExport('zkfair', '0x3F5a6e62cccD2C9AAF3dE431e127D65BC457000a') diff --git a/projects/zkswap-2/index.js b/projects/zkswap-2/index.js index 2e2c45966d2..8eadd5d8a5e 100644 --- a/projects/zkswap-2/index.js +++ b/projects/zkswap-2/index.js @@ -6,4 +6,5 @@ const zks = ""; module.exports = { misrepresentedTokens: true, era: { tvl: getUniTVL({ factory, useDefaultCoreAssets: true, }) }, + zkfair: { tvl: getUniTVL({ factory: '0x028e8aB8C7556C7F42315f5afe08bB7392aA6878', useDefaultCoreAssets: true, }) }, }; \ No newline at end of file diff --git a/projects/zkswap/index.js b/projects/zkswap/index.js index e76444b1cd8..300059846f4 100644 --- a/projects/zkswap/index.js +++ b/projects/zkswap/index.js @@ -1,29 +1,22 @@ -const BigNumber = require('bignumber.js') +const { getLogs } = require('../helper/cache/getLogs') +const sdk = require('@defillama/sdk') +const ADDRESSES = require('../helper/coreAssets.json') -const v1TVL = require('./v1'); -const v2TVL = require('./v2'); - -async function tvl(timestamp, block, _1, { api }) { - const [v1, v2] = await Promise.all([v1TVL(timestamp, block, _1, { api }), v2TVL(timestamp, block, _1, { api })]); - - const tokenAddresses = new Set(Object.keys(v1).concat(Object.keys(v2))); - - const balances = ( - Array - .from(tokenAddresses) - .reduce((accumulator, tokenAddress) => { - const v1Balance = new BigNumber(v1[tokenAddress] || '0'); - const v2Balance = new BigNumber(v2[tokenAddress] || '0'); - accumulator[tokenAddress] = v1Balance.plus(v2Balance).toFixed(); - - return accumulator - }, {}) - ); - - return balances; -} +const configs = [ + { governance: '0x02ecef526f806f06357659fFD14834fe82Ef4B04', main: '0x8ECa806Aecc86CE90Da803b080Ca4E3A9b8097ad', fromBlock: 11841962, }, + { governance: '0x86E527BC3C43E6Ba3eFf3A8CAd54A7Ed09cD8E8B', main: '0x6dE5bDC580f55Bc9dAcaFCB67b91674040A247e3', fromBlock: 12810001, }, +] module.exports = { start: 1613135160, // 02/12/2021 @ 01:06pm UTC - ethereum: { tvl }, + ethereum: { + tvl: sdk.util.sumChainTvls(configs.map(i => { + return async function tvl(timestamp, block, _1, { api }) { + const logs = await getLogs({ api, target: i.governance, eventAbi: 'event NewToken (address indexed token, uint16 indexed tokenId)', onlyArgs: true, fromBlock: i.fromBlock, }) + const tokens = logs.map(log => log.token) + tokens.push(ADDRESSES.null) + return api.sumTokens({ owner: i.main, tokens }) + } + })) + }, }; diff --git a/projects/zkswap/v1.js b/projects/zkswap/v1.js deleted file mode 100644 index 1157345192d..00000000000 --- a/projects/zkswap/v1.js +++ /dev/null @@ -1,43 +0,0 @@ -const ADDRESSES = require('../helper/coreAssets.json') -const sdk = require('@defillama/sdk'); -const { getLogs } = require('../helper/cache/getLogs') - -const MAIN = '0x8ECa806Aecc86CE90Da803b080Ca4E3A9b8097ad'; -const GOVERNANCE = '0x02ecef526f806f06357659fFD14834fe82Ef4B04'; -const START_BLOCK = 11841962; - -module.exports = async function tvl(timestamp, block, _1, { api }) { - // ETH - const ETHBalance = (await sdk.api.eth.getBalance({target: MAIN, block})).output; - const balances = { - [ADDRESSES.null]: ETHBalance - } - - // ERC20 - const topic = 'NewToken(address,uint16)'; - const logs = ( - await getLogs({ - api, - target: GOVERNANCE, - fromBlock: START_BLOCK, - topic, - }) - ); - - const tokenAddresses = logs.map(log => `0x${log.topics[1].slice(64 - 40 + 2, 64 + 2)}`.toLowerCase()); - - const calls = tokenAddresses.map(tokenAddress => ({ - target: tokenAddress, - params: MAIN - })); - - const ERC20Balances = await sdk.api.abi.multiCall({ - block, - calls, - abi: 'erc20:balanceOf' - }); - - sdk.util.sumMultiBalanceOf(balances, ERC20Balances); - - return balances; -} diff --git a/projects/zkswap/v2.js b/projects/zkswap/v2.js deleted file mode 100644 index 6f26e8d5b99..00000000000 --- a/projects/zkswap/v2.js +++ /dev/null @@ -1,43 +0,0 @@ -const ADDRESSES = require('../helper/coreAssets.json') -const sdk = require('@defillama/sdk'); -const { getLogs } = require('../helper/cache/getLogs') - -const MAIN = '0x6dE5bDC580f55Bc9dAcaFCB67b91674040A247e3'; -const GOVERNANCE = '0x86E527BC3C43E6Ba3eFf3A8CAd54A7Ed09cD8E8B'; -const START_BLOCK = 12810001 ; - -module.exports = async function tvl(timestamp, block, _1, { api }) { - // ETH - const ETHBalance = (await sdk.api.eth.getBalance({target: MAIN, block})).output; - const balances = { - [ADDRESSES.null]: ETHBalance - } - - // ERC20 - const topic = 'NewToken(address,uint16)'; - const logs = ( - await getLogs({ - api, - target: GOVERNANCE, - fromBlock: START_BLOCK, - topic, - }) - ); - - const tokenAddresses = logs.map(log => `0x${log.topics[1].slice(64 - 40 + 2, 64 + 2)}`.toLowerCase()); - - const calls = tokenAddresses.map(tokenAddress => ({ - target: tokenAddress, - params: MAIN - })); - - const ERC20Balances = await sdk.api.abi.multiCall({ - block, - calls, - abi: 'erc20:balanceOf' - }); - - sdk.util.sumMultiBalanceOf(balances, ERC20Balances); - - return balances; -}