Skip to content

Commit

Permalink
track zkfair projects
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Dec 28, 2023
1 parent 0c99522 commit 649de2d
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 111 deletions.
1 change: 1 addition & 0 deletions projects/helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
"xpla",
"zeniq",
"zilliqa",
"zkfair",
"zksync",
"zyx"
]
3 changes: 2 additions & 1 deletion projects/helper/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
4 changes: 4 additions & 0 deletions projects/helper/tokenMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] || {}) })
Expand Down
3 changes: 3 additions & 0 deletions projects/izumi-iziswap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
9 changes: 9 additions & 0 deletions projects/magma/index.js
Original file line number Diff line number Diff line change
@@ -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
},
};
3 changes: 3 additions & 0 deletions projects/sideswap-fi/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { uniTvlExport } = require('../helper/unknownTokens')

module.exports = uniTvlExport('zkfair', '0x3F5a6e62cccD2C9AAF3dE431e127D65BC457000a')
1 change: 1 addition & 0 deletions projects/zkswap-2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ const zks = "";
module.exports = {
misrepresentedTokens: true,
era: { tvl: getUniTVL({ factory, useDefaultCoreAssets: true, }) },
zkfair: { tvl: getUniTVL({ factory: '0x028e8aB8C7556C7F42315f5afe08bB7392aA6878', useDefaultCoreAssets: true, }) },
};
41 changes: 17 additions & 24 deletions projects/zkswap/index.js
Original file line number Diff line number Diff line change
@@ -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 })
}
}))
},
};
43 changes: 0 additions & 43 deletions projects/zkswap/v1.js

This file was deleted.

43 changes: 0 additions & 43 deletions projects/zkswap/v2.js

This file was deleted.

0 comments on commit 649de2d

Please sign in to comment.