diff --git a/package-lock.json b/package-lock.json index 794800f1dd..92ea6e763e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "ISC", "dependencies": { "@coral-xyz/anchor": "^0.30.1", - "@defillama/sdk": "latest", + "@defillama/sdk": "*", "@project-serum/anchor": "^0.26.0", "@solana/web3.js": "^1.87.6", "@solendprotocol/solend-sdk": "^0.4.3", @@ -4028,9 +4028,10 @@ } }, "node_modules/undici": { - "version": "5.28.4", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", - "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", + "version": "5.28.5", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz", + "integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==", + "license": "MIT", "dependencies": { "@fastify/busboy": "^2.0.0" }, diff --git a/projects/euler/v2.js b/projects/euler/v2.js new file mode 100644 index 0000000000..f2bf78e519 --- /dev/null +++ b/projects/euler/v2.js @@ -0,0 +1,45 @@ +const { ethereum } = require('.') +const { getLogs } = require('../helper/cache/getLogs') +const { sumTokens2 } = require('../helper/unwrapLPs') + +const EULER_FACTORY = "0x29a56a1b8214D9Cf7c5561811750D5cBDb45CC8e" +module.exports = { + methodology: `TVL is supply balance minus borrows the euler contract.`, + ethereum: { + tvl, + borrowed + } +}; + +async function tvl(api) { + const logs = await getLogs({ + api, + target: EULER_FACTORY, + fromBlock: 20529225, + eventAbi: "event ProxyCreated(address indexed proxy, bool upgradeable, address implementation, bytes trailingData)", + onlyArgs: true + }); + + const vaults = logs.map(log => log.proxy); + const underlyingAssets = await api.multiCall({ abi: "address:asset", calls: vaults}) + const tokensAndOwners = underlyingAssets.map((underlying, i) => [underlying, vaults[i]]); + + return sumTokens2({ api, tokensAndOwners }); +} + +async function borrowed(api) { + const logs = await getLogs({ + api, + target: EULER_FACTORY, + fromBlock: 20529225, + eventAbi: "event ProxyCreated(address indexed proxy, bool upgradeable, address implementation, bytes trailingData)", + onlyArgs: true + }); + + const vaults = logs.map(log => log.proxy); + const underlyingAssets = await api.multiCall({ abi: "address:asset", calls: vaults}) + const borrows = await api.multiCall({ abi: "uint256:totalBorrows", calls: vaults}) + + api.addTokens(underlyingAssets, borrows); + return api.getBalances(); +} \ No newline at end of file