Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add LiquiX #9400

Closed
wants to merge 3 commits into from
Closed
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
63 changes: 63 additions & 0 deletions projects/liquix/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const { getLogs } = require('../helper/cache/getLogs')
const { covalentGetTokens } = require('../helper/token')
const { sleep } = require("../helper/utils");
const { getUniqueAddresses } = require('../helper/utils');

const config = {
arbitrum: {
network: "arbitrum",
factory: "0x37215Af590CED3f50a4e3Af8BE903E4307C71C1F",
helper: "0x6376f97fc9bc9a0ebd03fa89eF8a653A79b41e98",
fromBlock: 145653947,
},
};

const blacklistedTokens = [
]

module.exports = {
doublecounted: true,
misrepresentedTokens: true,
timetravel: false,
};

async function getTokens(api, owners) {
let tokens = []
for (let i = 0; i < owners.length; i++) {
const owner = owners[i];
let new_tokens = await covalentGetTokens(owner, api, { onlyWhitelisted: true, });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a better way to get token list? covalentGetTokens is expensive and we like to keep its usage to a minium

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nevermind, this method is not even used

tokens.push(...new_tokens);
await sleep(300)
}
console.log(tokens)
tokens = getUniqueAddresses(tokens)
return tokens
}

Object.keys(config).forEach((chain) => {
const { factory, helper, fromBlock } = config[chain];
module.exports[chain] = {
tvl: async (_, _b, _cb, { api }) => {
const logs = await getLogs({
api,
target: factory,
topics: [
"0x14db5e0167c5e77f0a48cedd835dd30b2dcd630caff2e8e5d2411b892a094324",
],
eventAbi:
"event VaultCreated(string name, address proxyAddress)",
onlyArgs: true,
fromBlock,
});
const vaults = logs.map(i => i.proxyAddress)
for (let i = 0; i < vaults.length; i++) {
const balances = await api.call({ abi: 'function totalUnderlying(address vault_) external view returns ((address,uint256)[] memory)', target: helper, params: vaults[i] });
for (let j = 0; j < balances.length; j++) {
const token0 = balances[j][0];
const balance = balances[j][1];
api.add(token0, balance)
}
}
}
}
});
Loading