Skip to content

Commit

Permalink
adding pendle pools and vault to earnETH (#12115)
Browse files Browse the repository at this point in the history
Co-authored-by: g1nt0ki <[email protected]>
  • Loading branch information
darvinrio and g1nt0ki authored Oct 31, 2024
1 parent 22cb3e6 commit c58355c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 22 deletions.
4 changes: 1 addition & 3 deletions projects/helper/unwrapLPs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const BigNumber = require("bignumber.js");
const token0 = 'address:token0'
const symbol = 'string:symbol'
const { getPoolTokens, getPoolId, bPool, getCurrentTokens, } = require('./abis/balancer.json')
const { requery } = require('./requery')
const { getChainTransform, getFixBalances } = require('./portedTokens')
const { getUniqueAddresses, normalizeAddress } = require('./tokenMapping')
const creamAbi = require('./abis/cream.json')
Expand Down Expand Up @@ -192,7 +191,7 @@ async function unwrapUniswapV3NFT({ balances, owner, owners, nftAddress, block,

let positionIds = uniV3ExtraConfig.positionIds
if (!positionIds) {
if (!owners && owner) owners = [owner]
if (!owners?.length && owner) owners = [owner]
owners = getUniqueAddresses(owners, chain)
const { output: lengths } = await sdk.api.abi.multiCall({
block, chain, abi: wildCreditABI.balanceOf,
Expand All @@ -214,7 +213,6 @@ async function unwrapUniswapV3NFT({ balances, owner, owners, nftAddress, block,
block, chain, abi: wildCreditABI.positions, target: nftAddress,
calls: positionIds.map((position) => ({ params: [position] })),
})).output.map(positionsCall => positionsCall.output)

const lpInfo = {}
positions.forEach(position => lpInfo[getKey(position)] = position)
const lpInfoArray = Object.values(lpInfo)
Expand Down
40 changes: 31 additions & 9 deletions projects/swell-earn-eth/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
const { sumTokens2, PANCAKE_NFT_ADDRESS } = require('../helper/unwrapLPs')
const ADDRESSES = require('../helper/coreAssets.json')
const { sumTokens2 } = require('../helper/unwrapLPs')

const earnETHVault = '0x9Ed15383940CC380fAEF0a75edacE507cC775f22';
const pancakeswapMasterChef = '0x556B9306565093C855AEA9AE92A594704c2Cd59e'

const ethTokens = [
'0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0', // rswETH
'0xf951E335afb289353dc249e82926178EaC7DEd78', // swETH
ADDRESSES.ethereum.WSTETH, // wstETH
ADDRESSES.ethereum.WETH, // WETH
]

const pendleLPTokens = [
"0x7C7FbB2d11803C35Aa3e283985237aD27f64406B", //rswETH 26Dec2024
"0x0e1C5509B503358eA1Dac119C1D413e28Cc4b303", //swETH 26December2024
]

const vaultTokens = [
"0x78Fc2c2eD1A4cDb5402365934aE5648aDAd094d0", // Re7 WETH
]

const tokens = [
'0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0', // rswETH
'0xf951E335afb289353dc249e82926178EaC7DEd78', // swETH
ADDRESSES.ethereum.WSTETH, // wstETH
ADDRESSES.ethereum.WETH, // WETH
...ethTokens,
...pendleLPTokens,
...vaultTokens,
]


const tvl = async (api) => {
return sumTokens2({ api, tokens, owner: earnETHVault })
return sumTokens2({
api,
owner: earnETHVault, tokens,
uniV3nftsAndOwners: [[PANCAKE_NFT_ADDRESS, earnETHVault]],
uniV3ExtraConfig: { nftIdFetcher: pancakeswapMasterChef }
})
}

module.exports = {
methodology: 'TVL represents the sum of tokens deposited in the vault',
doublecounted: true,
ethereum : { tvl }
methodology: 'TVL represents the sum of tokens deposited in the vault + LP positions',
doublecounted: true,
ethereum: { tvl }
}
16 changes: 6 additions & 10 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function validateHallmarks(hallmark) {
const year = new Date(timestamp * 1000).getFullYear()
const currentYear = new Date().getFullYear()
if (year < 2010 || year > currentYear) {
throw new Error("Hallmark timestamp should be between 2010 and "+ currentYear + " but got " + year)
throw new Error("Hallmark timestamp should be between 2010 and " + currentYear + " but got " + year)
}

if (typeof text !== 'string') {
Expand All @@ -124,16 +124,12 @@ function validateHallmarks(hallmark) {

(async () => {
let module = {};
try {
module = require(passedFile)
} catch (e) {
console.log(e)
}
module = require(passedFile)
if (module.hallmarks) {
if (!Array.isArray(module.hallmarks)) {
throw new Error("Hallmarks should be an array of arrays")
}
if(module.hallmarks.length > 6){
if (module.hallmarks.length > 6) {
console.error("WARNING: Hallmarks should only be set for events that led to a big change in TVL, please reduce hallmarks to only those that meet this condition")
}

Expand All @@ -146,7 +142,7 @@ function validateHallmarks(hallmark) {
let unixTimestamp = Math.round(Date.now() / 1000) - 60;
let chainBlocks = {}
const passedTimestamp = process.argv[3]
if(passedTimestamp !== undefined){
if (passedTimestamp !== undefined) {
unixTimestamp = Number(passedTimestamp)
const res = await getBlocks(unixTimestamp, chains)
chainBlocks = res.chainBlocks
Expand Down Expand Up @@ -244,8 +240,8 @@ function validateHallmarks(hallmark) {
entries = entries.slice(0, 30)
}
entries.forEach(([symbol, balance]) => {
console.log(symbol.padEnd(25, " "), humanizeNumber(balance));
});
console.log(symbol.padEnd(25, " "), humanizeNumber(balance));
});
console.log("Total:", humanizeNumber(usdTvls[chain]), "\n");
});
console.log(`------ TVL ------`);
Expand Down

0 comments on commit c58355c

Please sign in to comment.