Skip to content

Commit

Permalink
feat: add Seamless Morpho vaults to TVL (#13129)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredwes authored Jan 24, 2025
1 parent 822c971 commit 7e599e8
Showing 1 changed file with 55 additions and 4 deletions.
59 changes: 55 additions & 4 deletions projects/seamless/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const { aaveExports } = require("../helper/aave");
const { getLogs2 } = require("../helper/cache/getLogs");
const { sumTokens2 } = require("../helper/unwrapLPs");
const abi = require("./abis.json");
const { mergeExports } = require("../helper/utils");
const methodologies = require("../helper/methodologies");

const SEAMLESS_GOVERNOR_SHORT_TIMELOCK = "0x639d2dD24304aC2e6A691d8c1cFf4a2665925fee";
const MORPHO_VAULTS_FACTORY_v1_1 = "0xFf62A7c278C62eD665133147129245053Bbf5918";

const AAVE_ADDRESSES_PROVIDER_REGISTRY = "0x90C5055530C0465AbB077FA016a3699A3F53Ef99";
const AAVE_POOL_DATA_PROVIDER = "0x2A0979257105834789bC6b9E1B00446DFbA8dFBa";
const GEYSER_REGISTRY = "0xD5815fC3D736120d07a1fA92bA743c1167dA89d8";
Expand Down Expand Up @@ -44,7 +48,54 @@ async function geyserTvl(api) {

const baseAAVE = aaveExports("base", AAVE_ADDRESSES_PROVIDER_REGISTRY, undefined, [AAVE_POOL_DATA_PROVIDER], { v3: true });

module.exports = mergeExports([{
methodology: methodologies.lendingMarket,
base: baseAAVE,
}, { base: { tvl: geyserTvl } }]);
const SeamlesMorphoVaultsTVL = async (api) => {
const allVaults = (
await getLogs2({
api,
factory: MORPHO_VAULTS_FACTORY_v1_1,
eventAbi:
"event CreateMetaMorpho(address indexed metaMorpho, address indexed caller, address initialOwner, uint256 initialTimelock, address indexed asset, string name, string symbol, bytes32 salt)",
fromBlock: 24831748,
})
).map((log) => log.metaMorpho);

const allVaultOwners = await api.multiCall({
calls: allVaults,
abi: "function owner() public view returns (address)",
});

const seamlessMorphoVaults = allVaults.filter(
(_, i) =>
allVaultOwners[i].toLowerCase() ===
SEAMLESS_GOVERNOR_SHORT_TIMELOCK.toLowerCase()
);

const underlyingAssets = await api.multiCall({
calls: seamlessMorphoVaults,
abi: "function asset() public view returns (address)",
});
const totalAssets = await api.multiCall({
calls: seamlessMorphoVaults,
abi: "function totalAssets() public view returns (uint256)",
});

underlyingAssets.forEach((asset, i) => {
api.add(asset, totalAssets[i]);
});

return api.getBalances();
};

const methodology = `Counts the tokens deposited in Seamless Protocol owned vaults even when those vaults exist on other protocols (this is marked as double counted). Other sources of TVL are not double counted such as lending market TVL which follows uses the following methodology: ${methodologies.lendingMarket}`;

module.exports = mergeExports([
{
base: baseAAVE,
},
{ base: { tvl: geyserTvl } },
{
doublecounted: true,
base: { tvl: SeamlesMorphoVaultsTVL },
},
{ methodology },
]);

0 comments on commit 7e599e8

Please sign in to comment.