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

Added UFarm Digital Protocol #11198

Closed
wants to merge 2 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
61 changes: 61 additions & 0 deletions projects/ufarm-digital/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const ADDRESSES = require('../helper/coreAssets.json')
const START_BLOCK = 211275856;
const config = {
arbitrum: {
ufarmCore: '0x46Df84E70deDB8a17eA859F1B07B00FB83b8a81F',
valueToken: ADDRESSES.arbitrum.USDT,
},
};

const chainedTVLs = () => {
const result = {};
for(const chain of Object.keys(config)) {
result[chain] = { tvl: async (api) => {
const END_BLOCK = await api.getBlock();
const params = [];
// get the list of funds
const fundCreated = await api.getLogs({
target: config[chain].ufarmCore,
chain: chain,
skipCache: true,
fromBlock: START_BLOCK,
toBlock: END_BLOCK,
eventAbi: 'event FundCreated(bytes32 indexed,uint256,address)',
});

for (const fundLog of fundCreated) {
const fundAddress = fundLog.args[2];
// get the list of pools
const poolCreated = await api.getLogs({
target: fundAddress,
chain: chain,
skipCache: false,
fromBlock: START_BLOCK,
toBlock: END_BLOCK,
eventAbi: 'event PoolCreated(string,string,uint256,uint256,uint256,uint256,uint256,uint256,address,address)',
});
for (const poolLog of poolCreated) {
const poolAddress = poolLog.args[8];
// collect the pool addresses
params.push({ target: poolAddress });
}
}

// get TVL of each pool at one call
const balances = await api.multiCall({
abi: 'function getTotalCost() public view returns (uint256)',
calls: params,
block: END_BLOCK,
skipCache: false,
});
api.addTokens(balances.map( b => config[chain].valueToken ), balances);
}};
}
return result;
};

module.exports = {
methodology: 'Counts the AUM of all pools registered in the UFarm Protocol',
start: START_BLOCK,
...chainedTVLs()
};
Loading