From b64164171c950c75d81eeff1123bc914c01b3920 Mon Sep 17 00:00:00 2001 From: Define101 Date: Fri, 9 Aug 2024 10:03:26 +0100 Subject: [PATCH 1/2] add git checkout -b pancake-stryke --- projects/pancake-stryke/index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 projects/pancake-stryke/index.js diff --git a/projects/pancake-stryke/index.js b/projects/pancake-stryke/index.js new file mode 100644 index 000000000000..67d9463bcbb4 --- /dev/null +++ b/projects/pancake-stryke/index.js @@ -0,0 +1,17 @@ +const { sumTokens2, nullAddress } = require('../helper/unwrapLPs') +const ADDRESSES = require('../helper/coreAssets.json') + +const WETHUSDC = "0x501B03BdB431154b8Df17BF1c00756E3a8F21744" +const WBTCUSDC = "0x550e7E236912DaA302F7d5D0d6e5D7b6EF191f04" +const ARBUSDC = "0x4eed3A2b797Bf5630517EcCe2e31C1438A76bb92" + +async function tvl(api) { + return sumTokens2({ tokens: [nullAddress, ADDRESSES.arbitrum.WETH, ADDRESSES.arbitrum.USDC, ADDRESSES.arbitrum.WBTC, ADDRESSES.arbitrum.ARB], owners: [WETHUSDC, WBTCUSDC, ARBUSDC], api }) +} + +module.exports = { + methodology: `We count the Tokens on ${WETHUSDC, WBTCUSDC, ARBUSDC}`, + arbitrum: { + tvl + } +} \ No newline at end of file From b3878e83c04d83d07a5a4f3c18f372d8139f2512 Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Fri, 9 Aug 2024 11:57:05 +0200 Subject: [PATCH 2/2] code refactor --- projects/pancake-stryke/index.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/projects/pancake-stryke/index.js b/projects/pancake-stryke/index.js index 67d9463bcbb4..c73068a60ff7 100644 --- a/projects/pancake-stryke/index.js +++ b/projects/pancake-stryke/index.js @@ -1,17 +1,21 @@ -const { sumTokens2, nullAddress } = require('../helper/unwrapLPs') -const ADDRESSES = require('../helper/coreAssets.json') - -const WETHUSDC = "0x501B03BdB431154b8Df17BF1c00756E3a8F21744" -const WBTCUSDC = "0x550e7E236912DaA302F7d5D0d6e5D7b6EF191f04" -const ARBUSDC = "0x4eed3A2b797Bf5630517EcCe2e31C1438A76bb92" - -async function tvl(api) { - return sumTokens2({ tokens: [nullAddress, ADDRESSES.arbitrum.WETH, ADDRESSES.arbitrum.USDC, ADDRESSES.arbitrum.WBTC, ADDRESSES.arbitrum.ARB], owners: [WETHUSDC, WBTCUSDC, ARBUSDC], api }) +const config = { + arbitrum: { + pools: [ + "0x501B03BdB431154b8Df17BF1c00756E3a8F21744", // WETHUSDC + "0x550e7E236912DaA302F7d5D0d6e5D7b6EF191f04", // WBTCUSDC + "0x4eed3A2b797Bf5630517EcCe2e31C1438A76bb92", // ARBUSDC + ], + }, } -module.exports = { - methodology: `We count the Tokens on ${WETHUSDC, WBTCUSDC, ARBUSDC}`, - arbitrum: { - tvl +Object.keys(config).forEach(chain => { + const { pools } = config[chain] + module.exports[chain] = { + tvl: async (api) => { + const callAssets = await api.multiCall({ abi: 'address:callAsset', calls: pools }) + const putAssets = await api.multiCall({ abi: 'address:putAsset', calls: pools }) + + return api.sumTokens({ tokensAndOwners2: [callAssets.concat(putAssets), pools.concat(pools)]}) + } } -} \ No newline at end of file +}) \ No newline at end of file