mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-04-29 21:36:44 +08:00
MonroeProtocol: new chains deployments (#9985)
* feat: monroeprotocol * feat: Monroe prod * MonroeProtocol: new chains deployments
This commit is contained in:
@@ -1,33 +1,33 @@
|
||||
const { createIncrementArray } = require("../helper/utils");
|
||||
const { getLogs } = require('../helper/cache/getLogs')
|
||||
|
||||
// Controllers[chain]
|
||||
const CONTROLLERS = {
|
||||
manta: "0xb2E609ef662889a32452598F0131863035974878",
|
||||
const CHAINS = ["ethereum", "manta", "avax", "iotex"]
|
||||
|
||||
// Where possible contracts are deployed using deterministic addresses
|
||||
const DEFAULT_ADDRESSES = {
|
||||
controller: "0xb2E609ef662889a32452598F0131863035974878",
|
||||
monusd: "0xDf3d57c3480951958Cef19905E4cf7FC1bA9ad42"
|
||||
}
|
||||
const SPECIAL_ADDRESSES = {
|
||||
zklink: {
|
||||
controller: "0xD620b0613568406F427a6f5d4ecA301870a1A3d5",
|
||||
monusd: "0x051baaA86328Fc7F522431932B8010F66f260A6a"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function tvl(api) {
|
||||
const logs = await getLogs({
|
||||
api,
|
||||
target: CONTROLLERS[api.chain],
|
||||
eventAbi: "event CreatedSynth(address newSynth, string name, address oracle)",
|
||||
onlyArgs: true,
|
||||
fromBlock: 1548740
|
||||
});
|
||||
const synthAddresses = logs.map(log => log.newSynth);
|
||||
|
||||
const vaultLength = await api.call({ abi: "uint:getVaultsLength", target: CONTROLLERS[api.chain] })
|
||||
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 = []
|
||||
await Promise.all(synthAddresses.map(async (synth) => {
|
||||
const vaults = await api.multiCall({ abi: "function mintVaults(uint vaultId) view returns (address)", calls: vaultCalls, target: synth})
|
||||
const _tokens = await api.multiCall({ abi: 'address:collateralAsset', calls: vaults})
|
||||
tokens.push(..._tokens)
|
||||
owners.push(...vaults)
|
||||
}))
|
||||
|
||||
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)
|
||||
|
||||
|
||||
return api.sumTokens({ tokensAndOwners2: [tokens, owners]})
|
||||
}
|
||||
@@ -39,6 +39,6 @@ module.exports = {
|
||||
start: 1710288000, // March 13, 2024 00:00 GMT
|
||||
};
|
||||
|
||||
Object.keys(CONTROLLERS).forEach((chain) => {
|
||||
CHAINS.forEach((chain) => {
|
||||
module.exports[chain] = { tvl };
|
||||
});
|
||||
Reference in New Issue
Block a user