From 33e0291db1a61b9bfad2eb912d1af9f6d7c76bc9 Mon Sep 17 00:00:00 2001 From: Keref Date: Mon, 29 Jul 2024 15:34:17 +0800 Subject: [PATCH] Update: Monroe Protocol V2 (#11129) * feat: monroeprotocol * feat: Monroe prod * MonroeProtocol: new chains deployments * feat: Monroe v2 --- projects/monroeprotocol/index.js | 45 +++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/projects/monroeprotocol/index.js b/projects/monroeprotocol/index.js index ae9ce664015e..6d2e2fc9d25d 100644 --- a/projects/monroeprotocol/index.js +++ b/projects/monroeprotocol/index.js @@ -1,33 +1,49 @@ const { createIncrementArray } = require("../helper/utils"); const { getLogs } = require('../helper/cache/getLogs') -const CHAINS = ["ethereum", "manta", "avax", "iotex"] +const V1_CHAINS = ["ethereum", "manta", "avax"] +const V2_CHAINS = ["manta", "avax"] +const CHAINS = [...new Set([...V2_CHAINS,...V1_CHAINS])] // Where possible contracts are deployed using deterministic addresses -const DEFAULT_ADDRESSES = { +const V1_ADDRESSES = { controller: "0xb2E609ef662889a32452598F0131863035974878", monusd: "0xDf3d57c3480951958Cef19905E4cf7FC1bA9ad42" } -const SPECIAL_ADDRESSES = { +const V1_SPECIAL_ADDRESSES = { zklink: { controller: "0xD620b0613568406F427a6f5d4ecA301870a1A3d5", monusd: "0x051baaA86328Fc7F522431932B8010F66f260A6a" } } +// V2 +const roeUSD = "0xF88DF111343BffE7a2d89FB770d77A264d53f043" async function tvl(api) { - const addresses = SPECIAL_ADDRESSES.hasOwnProperty(api.chain) ? SPECIAL_ADDRESSES[api.chain] : DEFAULT_ADDRESSES - const vaultLength = await api.call({ abi: "uint:getVaultsLength", target: addresses.controller }) - const vaultCalls = createIncrementArray(vaultLength) - const owners = [] const tokens = [] - - const vaults = await api.multiCall({ abi: "function mintVaults(uint vaultId) view returns (address)", calls: vaultCalls, target: addresses.monusd}) - const _tokens = await api.multiCall({ abi: 'address:collateralAsset', calls: vaults}) - tokens.push(..._tokens) - owners.push(...vaults) - + + // V1 + if (V1_CHAINS.indexOf(api.chain) > -1){ + const addresses = V1_SPECIAL_ADDRESSES.hasOwnProperty(api.chain) ? V1_SPECIAL_ADDRESSES[api.chain] : V1_ADDRESSES + const vaultLength = await api.call({ abi: "uint:getVaultsLength", target: addresses.controller }) + const vaultCalls = createIncrementArray(vaultLength) + + const vaults = await api.multiCall({ abi: "function mintVaults(uint vaultId) view returns (address)", calls: vaultCalls, target: addresses.monusd}) + const _tokens = await api.multiCall({ abi: 'address:collateralAsset', calls: vaults}) + tokens.push(..._tokens) + owners.push(...vaults) + } + + // V2 + if (V2_CHAINS.indexOf(api.chain) > -1) { + const vaultLengthV2 = await api.call({ abi: "uint:getVaultsLength", target: roeUSD }) + const vaultCallsV2 = createIncrementArray(vaultLengthV2) + const vaultsV2 = await api.multiCall({ abi: "function vaults(uint vaultId) view returns (address)", calls: vaultCallsV2, target: roeUSD}) + const _tokensV2 = await api.multiCall({ abi: 'address:collateralAsset', calls: vaultsV2}) + tokens.push(..._tokensV2) + owners.push(...vaultsV2) + } return api.sumTokens({ tokensAndOwners2: [tokens, owners]}) } @@ -37,6 +53,9 @@ module.exports = { methodology: "Adds up the total value locked as collateral in Monroe vaults", start: 1710288000, // March 13, 2024 00:00 GMT + hallmarks: [ + [1722000000, "V2 Launch"] + ], }; CHAINS.forEach((chain) => {