Skip to content

Commit

Permalink
CreampanFinance Update index.js (#12902)
Browse files Browse the repository at this point in the history
Co-authored-by: g1nt0ki <[email protected]>
  • Loading branch information
Creamapan and g1nt0ki authored Jan 5, 2025
1 parent 710c766 commit 38ac20e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions projects/CreampanFinance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@ const accounts = Object.values({
account3: 'cro1pduq0ga2ans0sspph6r5hcf77cqypz6de7n64y',
account4: 'cro1fncg0fsr8vt30qaqmzqxunnrkxr6a7xxkfpr7y',
account5: 'cro1hhfh6xaflg8zwhwvrs7sgur2pyfunjqeu8wsd6',
account6: 'cro1a2vawclcntewtjd5jfjf44dr6mdfdyg8xzfe5t',
account7: 'cro1wc43z84u8keas3ffw4ynapwe0hzfen3xx03dpd',
account8: 'cro1ujkwlnfnl3mmka4twqx07azxk6djlplddcn48h',
account9: 'cro16wzuj3a9tdqk9z3edx587athz2kk75gj2l6etk',
account10: 'cro1hfx8t4nldtfk5w6h6eherfts4gtelvcn0dypc3',
})

async function tvl(api) {
const data = await Promise.all(accounts.map(account => queryV1Beta1({ chain: 'cronos', url: `/staking/v1beta1/delegations/${account}`, })));
const factroy_contract_address = '0x66f5997b7810723aceeeb8a880846fc117081bd0';
const data2 = await Promise.all(accounts.map(account => queryV1Beta1({ chain: 'cronos', url: `/staking/v1beta1/delegators/${account}/unbonding_delegations`, })));
const factory_contract_address = '0x66f5997b7810723aceeeb8a880846fc117081bd0';
const factoryV2_contract_address = '0xfd3300b2441072b35554f1043c3d3a413fd5c219';
data.map(i => i.delegation_responses).flat().forEach(i => api.add(ADDRESSES.cronos.WCRO, i.balance.amount * 1e10))
return api.sumTokens({ owner: factroy_contract_address, tokens: [ADDRESSES.cronos.WCRO_1]})

for (let j = 0; j < accounts.length; j++) {
if (Number(data2[j].pagination.total) > 0) {
data2[j].unbonding_responses[0].entries.flat().forEach(i => api.add(ADDRESSES.cronos.WCRO, i.balance * 1e10))
}
}

return api.sumTokens({ owners: [factory_contract_address, factoryV2_contract_address], tokens: [ADDRESSES.cronos.WCRO_1] })
}

module.exports = {
Expand Down

0 comments on commit 38ac20e

Please sign in to comment.