Skip to content

Commit

Permalink
Merge branch 'main' of github.com:DefiLlama/DefiLlama-Adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Aug 2, 2024
2 parents 4f1a93b + 29baefb commit 9d95e5f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
26 changes: 16 additions & 10 deletions projects/clip-finance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,33 @@ const VaultType = {
Aero: 4,
LynexAlgebra: 5,
NileCl: 6,
ZeroLend: 7,
StargateFarming: 8,
};

const typesDataInterfaces = {
any: ["uint256"], // has only vaultType
amm: ["uint256", "address"], // vaultType, amm pool address
vaultBased: ["uint256", "address"], // vaultType, strategy address
[VaultType.PancakeV3]: ["uint256", "address"], // vaultType, v3 pool address
[VaultType.Stargate]: ["uint256"], // vaultType
[VaultType.MendiLending]: ["uint256", "address"], //vaultType, mendiLeverage address
[VaultType.MendiLending]: ["uint256", "address"], //vaultType, mendi strategy address
[VaultType.Aero]: ["uint256"], //vaultType
[VaultType.LynexAlgebra]: ["uint256", "address"], // vaultType, algebra pool address
[VaultType.NileCl]: ["uint256", "address", "address"], // vaultType, nileCl pool address, stacking contract address
[VaultType.ZeroLend]: ["uint256", "address"], // vaultType, ZeroLend strategy address
[VaultType.StargateFarming]: ["uint256", "address"] // vaultType, Stargate strategy address
};

const tvl = async (api) => {
const { vaultRegistry } = config[api.chain];
const vaultDatas = await api.call({ abi: abis.getVaults, target: vaultRegistry });
const decoder = ethers.AbiCoder.defaultAbiCoder();
//for DefiLlama's reviewer: it is better to check vault type using vaultType instead of existence of certain
//function. We are not sure that we will not add the same function to other vault type.
// for DefiLlama's reviewer: it is better to check vault type using vaultType instead of existence of certain
// function. We are not sure that we will not add the same function to other vault type.
const vaults = vaultDatas.map((i) => ({ ...i, vaultType: decoder.decode(typesDataInterfaces.any, i.data) }));

//ammVaults
// ammVaults
const ammTypes = [VaultType.PancakeV3, VaultType.LynexAlgebra, VaultType.NileCl];
const ammVaults = vaults.filter((i) => ammTypes.includes(Number(i.vaultType.toString()))).map((i) => i.vault);
const ammPools = vaults
Expand All @@ -56,7 +61,7 @@ const tvl = async (api) => {
api.add(ammToken1s[i], pool.total1);
});

//Aerodrom Vaults
// Aerodrom Vaults
const aerodromVaults = vaults.filter((i) => i.vaultType == VaultType.Aero).map((i) => i.vault);
const tokenAs = await api.multiCall({ abi: "address:tokenA", calls: aerodromVaults });

Expand Down Expand Up @@ -112,11 +117,12 @@ const tvl = async (api) => {
}
});

//Mendi Vaults
const mendiVaults = vaults.filter((i) => i.vaultType == VaultType.MendiLending).map((i) => i.vault);
const depositTokens = await api.multiCall({ abi: "address:depositToken", calls: mendiVaults });
const TVLs = await api.multiCall({ abi: "uint256:TVL", calls: mendiVaults });
mendiVaults.forEach((_, i) => {
// Vault Based Vaults
const vaultBasedTypes = [VaultType.MendiLending, VaultType.ZeroLend, VaultType.StargateFarming];
const vaultBasedVaults = vaults.filter((i) => vaultBasedTypes.includes(Number(i.vaultType.toString()))).map((i) => i.vault);
const depositTokens = await api.multiCall({ abi: "address:depositToken", calls: vaultBasedVaults });
const TVLs = await api.multiCall({ abi: "uint256:TVL", calls: vaultBasedVaults });
vaultBasedVaults.forEach((_, i) => {
api.add(depositTokens[i], TVLs[i]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
"GM_ARB_ARB_USDC": "0xC25cEf6061Cf5dE5eb761b50E4743c1F5D7E5407",
"GM_LINK_LINK_USDC": "0x7f1fa204bb700853D36994DA19F830b6Ad18455C",
"GM_UNI_UNI_USDC": "0xc7Abb2C5f3BF3CEB389dF0Eecd6120D451170B50",
"GM_SOL_SOL_USDC": "0x09400D9DB990D5ed3f35D7be61DfAEB900Af03C9",
"GM_BTC_WBTC_USDC": "0x47c031236e19d024b42f8AE6780E44A573170703",
"GM_SOL_SOL_USDC": "0x09400D9DB990D5ed3f35D7be61DfAEB900Af03C9",
"GM_NEAR_WETH_USDC": "0x63Dc80EE90F26363B3FCD609007CC9e14c8991BE",
"GM_ATOM_WETH_USDC": "0x248C35760068cE009a13076D573ed3497A47bCD4",
"GM_GMX_GMX_USDC": "0x55391D178Ce46e7AC8eaAEa50A72D1A5a8A622Da",
"GM_ETH_WETH": "0x450bb6774Dd8a756274E0ab4107953259d2ac541",
"GM_BTC_WBTC": "0x7C11F78Ce78768518D743E81Fdfa2F860C6b9A77",
"arbSnrLLP": "0x5573405636F4b895E511C9C54aAfbefa0E7Ee458",
"arbMzeLLP": "0xb076f79f8D1477165E2ff8fa99930381FB7d94c1",
"arbJnrLLP": "0x502697AF336F7413Bb4706262e7C506Edab4f3B9",
Expand Down

0 comments on commit 9d95e5f

Please sign in to comment.