From 14ed4733279576c8576d7f03c44659ed5402dc62 Mon Sep 17 00:00:00 2001 From: CronosLabsDev Date: Fri, 27 Dec 2024 10:30:29 +0800 Subject: [PATCH] feat: with sumTokens2 function --- projects/moonlander/index.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 projects/moonlander/index.js diff --git a/projects/moonlander/index.js b/projects/moonlander/index.js new file mode 100644 index 000000000000..cf9a03163be0 --- /dev/null +++ b/projects/moonlander/index.js @@ -0,0 +1,32 @@ +const { sumTokens2 } = require("../helper/unwrapLPs"); + +const CRO_ZKEVM_MOONLANDER_ADDR = '0x02ae2e56bfDF1ee4667405eE7e959CD3fE717A05'; + +function tvl({moonlander,}) { + return async (api) => { + const poolTokens = await api.call({ + abi: abis.totalValue, + target: moonlander, + }) + + const addresses = []; + const valuesUsd = []; + + poolTokens.forEach((poolToken) => { + addresses.push(poolToken.tokenAddress); + valuesUsd.push(poolToken.valueUsd); + }); + + return sumTokens2({ api, owner: moonlander, tokens: addresses, balances: valuesUsd}) + } +} + +const abis = { + totalValue: 'function totalValue() view returns (tuple(address tokenAddress, int256 value, uint8 decimals, int256 valueUsd, uint16 targetWeight, uint16 feeBasisPoints, uint16 taxBasisPoints, bool dynamicFee)[])' +} + +module.exports = { + cronos_zkevm: { + tvl: tvl({ moonlander: CRO_ZKEVM_MOONLANDER_ADDR, }), + }, + } \ No newline at end of file