Skip to content

Commit

Permalink
Merge branch 'DefiLlama:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
bill-clippy authored Apr 16, 2024
2 parents 60f5dbe + 2d05843 commit f388b78
Show file tree
Hide file tree
Showing 35 changed files with 330 additions and 514 deletions.
118 changes: 41 additions & 77 deletions projects/airpuff/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//import utils
const { staking } = require('../helper/staking')
const ADDRESSES = require("../helper/coreAssets.json");
const contractAbis = {
readOraclePrice: "function read() view returns (int224 value, uint32 timestamp)",
Expand All @@ -10,11 +10,26 @@ const contractAbis = {
getMswEthPrice: "function exchangeRateToNative() external view returns (uint256)",
getMswBalance: "function getAllEigeinPieCycleDepositAmounts() external view returns (uint256)",
getUnderlyingPrice: "function getUnderlyingPrice(address cToken) view returns (uint256)",
getUniswapPrice:
"function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 observationCardinalityNext, uint8 observationCardinalityNext)",
};

module.exports = {
misrepresentedTokens: true,

zklink: {
tvl: async (api) => {
const pufEth1x = {
vault: "0xD06E74D03a98A085C6060C4148902d2048C2D458",
reStakingToken: "0x1B49eCf1A8323Db4abf48b2F5EFaA33F7DdAB3FC",
};

await api.sumTokens({
tokensAndOwners: [[pufEth1x.reStakingToken, pufEth1x.vault]],
});
},
},

mode: {
tvl: async (api) => {
const lendingMode = {
Expand Down Expand Up @@ -71,33 +86,18 @@ module.exports = {
eth: "0xdeF3AA48bad043e53207d359dcDFdE46F50b6C02", //ETH
sUSD: "0x7c2a7009ffE52a69a8C877b47B07D5dB59C0e3b3", // Not lending pool, staking pool
};
await api.sumTokens({
tokensAndOwners: [
[ADDRESSES.ethereum.WETH, lendingMain.eth],
[ADDRESSES.ethereum.sUSDe, lendingMain.sUSD],
],
});
const tokensAndOwners = [
[ADDRESSES.ethereum.WETH, lendingMain.eth],
[ADDRESSES.ethereum.sUSDe, lendingMain.sUSD],
];

const eETH = {
vault: "0xE543eBa28a3793d5ae747A2164A306DB1767cDAe",
reStakingToken: "0xeA1A6307D9b18F8d1cbf1c3Dd6aad8416C06a221",
oracle: "0xb09cbB6Aa95A004F9aeE4349DF431aF5ad03ECe4",
};
tokensAndOwners.push([eETH.reStakingToken, eETH.vault]);

const eETHPrice = await api.call({
target: eETH.oracle,
abi: contractAbis.getPrice,
});

const eETHBal = await api.call({
abi: contractAbis.balanceOf,
target: eETH.reStakingToken,
params: [eETH.vault],
});

const eETHBalInETH = (eETHBal * eETHPrice) / 1e18;

api.add(ADDRESSES.ethereum.WETH, eETHBalInETH);
// leverage users
const ezETH = {
vault: "0x32a0ce2bDfc37eE606aB905b4f9fC286049A774f",
Expand Down Expand Up @@ -159,37 +159,6 @@ module.exports = {
oracle: "svETH",
};

const svETHPrice = await api.call({
abi: contractAbis.getVectorSharePrice,
target: svETH.vault,
});

const strategies = [ezETH, weETH, rsETH, ezETH1x, weETH1x, rsETH1x, bedRockETH, bedRockETH1x, svETH1x, svETH];

for (const strategy of strategies) {
const bal = await api.call({
abi: contractAbis.balanceOf,
target: strategy.reStakingToken,
params: [strategy.vault],
});

let lrETHPriceInETH;

if (strategy.oracle == "svETH") {
lrETHPriceInETH = svETHPrice;
} else {
lrETHPriceInETH = await api.call({
target: strategy.oracle,
abi: contractAbis.readOraclePrice,
});
lrETHPriceInETH = lrETHPriceInETH.value;
}

const balInETH = (bal * lrETHPriceInETH) / 1e18;

api.add(ADDRESSES.ethereum.WETH, balInETH);
}

const mswETH = {
vault: "0x7c505E03460aEF7FE88e218CC5fcEeCCcA4C4394",
reStakingToken: "0x32bd822d615A3658A68b6fDD30c2fcb2C996D678",
Expand All @@ -199,35 +168,30 @@ module.exports = {
vault: "0x1100195fbdA2f22AA6f394E6C65f168779Fe572c",
reStakingToken: "0x32bd822d615A3658A68b6fDD30c2fcb2C996D678",
};
const strategies = [ezETH, weETH, rsETH, ezETH1x, weETH1x, rsETH1x, bedRockETH, bedRockETH1x, svETH1x, svETH, mswETH, mswETH1x, ];
strategies.forEach(({ vault, reStakingToken}) => tokensAndOwners.push([reStakingToken, vault]));

const mswETHPrice = await api.call({
abi: contractAbis.getMswEthPrice,
target: mswETH.reStakingToken,
});
// mswETH1x

for (const msw of [mswETH, mswETH1x]) {
if (msw.vault == "0x1100195fbdA2f22AA6f394E6C65f168779Fe572c") {
const bal = await api.call({
abi: contractAbis.balanceOf,
target: msw.reStakingToken,
params: [msw.vault],
});
const balInETH = (bal * mswETHPrice) / 1e18;
api.add(ADDRESSES.ethereum.WETH, balInETH);
continue;
}

const mswETHBal = await api.call({
abi: contractAbis.getMswBalance,
target: msw.vault,
});
//new strats on pendle v2
const pTweETH = {
vault: "0xE9E2087CD1179378C847C1f3B73CCA929e3deb95",
pendleAddress: "0xc69Ad9baB1dEE23F4605a82b3354F8E40d1E5966",
};

const mswETHBalInETH = (mswETHBal * mswETHPrice) / 1e18;
const pTezETH = {
vault: "0x679EB9b7C57d9B98684034CDAfC2F4a72ABfEBD6",
pendleAddress: "0xeee8aed1957ca1545a0508afb51b53cca7e3c0d1",
};

api.add(ADDRESSES.ethereum.WETH, mswETHBalInETH);
}
const pTsETH = {
vault: "0x72Da018b1C7FAACEAa141DEc753F1fFe88c493AD",
pendleAddress: "0xb05cabcd99cf9a73b19805edefc5f67ca5d1895e",
};

const tokensAndOwners2 = [pTweETH, pTezETH, pTsETH].map((i) => [i.pendleAddress, i.vault]);
tokensAndOwners.push(...tokensAndOwners2);
await api.sumTokens({ tokensAndOwners });
},
staking: staking('0x296281cC6EB049F33aB278D946F18d9cacCFcfB5', '0x2BE056e595110B30ddd5eaF674BdAC54615307d9')
},
//-----------------------------------------------------------------------//

Expand Down
3 changes: 2 additions & 1 deletion projects/alta-finance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ module.exports = {
}

const config = {
polygon: { investments: ['0xcf152E9f60E197A44FAdce961c6B822Dcb6c9dcc'], debts: ['0xE92F580C930dd24aACB38Ab0EA18F6c1dEf31369','0x64D6583b81716a4d141f07E264805CaCd3f484bB'], token: ADDRESSES.polygon.USDC },
polygon: { investments: ['0xcf152E9f60E197A44FAdce961c6B822Dcb6c9dcc'], debts: [], token: ADDRESSES.polygon.USDC },
base: { investments: ['0xF36d1AdDA798Ea9340069207806dcBB137d31212'], debts: [], token: ADDRESSES.base.USDC }
}

Object.keys(config).forEach(chain => {
Expand Down
5 changes: 2 additions & 3 deletions projects/angle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,11 @@ async function tvl(api) {
})

// Treasury - Stablecoins
const treasuriesTokens = stablecoins
stablecoins
.map(({ treasury, treasuryTokens }) =>
treasuryTokens?.[chain]?.map((token) => [token, treasury])
)
.flat(2)
tokensAndOwners.push(treasuriesTokens)
.flat(1).forEach((tokenAndOwner) => tokensAndOwners.push(tokenAndOwner))

return sumTokens2({
api,
Expand Down
46 changes: 17 additions & 29 deletions projects/baryon/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const utils = require('../helper/utils');
const { stakings, staking } = require('../helper/staking');
const { stakings } = require('../helper/staking');
const { getUniTVL } = require('../helper/unknownTokens')
const { getConfig } = require('../helper/cache')

Expand All @@ -9,33 +8,22 @@ async function fetchData(chain) {
return data[chain]
}

async function stakingTomo(...args) {
const lpTokenTomo = await fetchData('tomo')

return stakings(lpTokenTomo.stakeContract, lpTokenTomo.lpToken)(...args)
const config = {
bitkub: { factory: '0xf7eEe3A8363731C611A24CdDfCBcaDE9C153Cfe8', key: 'bitkub' },
ancient8: { factory: '0xAE12C5930881c53715B369ceC7606B70d8EB229f', key: 'ancient8Mainnet' },
tomochain: { factory: '0xFe48A2E66EE2f90334d3565E56E0c9d0081447e8', key: 'tomo' },
bsc: { factory: '0x03879e2a3944fd601e7638dfcbc9253fb793b599', key: 'binanceSmart' },
}

async function stakingBsc(...args) {
const lpTokenTomo = await fetchData('binanceSmart')

return stakings(lpTokenTomo.stakeContract, lpTokenTomo.lpToken)(...args)
}

module.exports = {
bsc: {
misrepresentedTokens: true,
staking: stakingBsc,
tvl: getUniTVL({
factory: '0x03879e2a3944fd601e7638dfcbc9253fb793b599',
useDefaultCoreAssets: true,
})
},
tomochain: {
misrepresentedTokens: true,
staking: stakingTomo,
tvl: getUniTVL({
factory: '0xFe48A2E66EE2f90334d3565E56E0c9d0081447e8',
useDefaultCoreAssets: true,
})
Object.keys(config).forEach(chain => {
const { factory, key } = config[chain]
module.exports[chain] = {
tvl: getUniTVL({ factory, useDefaultCoreAssets: true }),
staking: async (...args) => {
const { stakeContract, lpToken } = await fetchData(key)
return stakings(stakeContract, lpToken)(...args)
}
}
}
})

module.exports.misrepresentedTokens = true
8 changes: 8 additions & 0 deletions projects/breadchain/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { sumTokensExport } = require('../helper/unwrapLPs')
const ADDRESSES = require('../helper/coreAssets.json')

module.exports = {
xdai: {
tvl: sumTokensExport({ owner: '0xa555d5344f6fb6c65da19e403cb4c1ec4a1a5ee3', tokens: [ADDRESSES.xdai.DAI, '0xaf204776c7245bf4147c2612bf6e5972ee483701']})
},
}
33 changes: 4 additions & 29 deletions projects/candycity/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
const sdk = require("@defillama/sdk");
const BigNumber = require("bignumber.js");
const { toUSDTBalances } = require('../helper/balances')
const { get } = require('../helper/http');
const { staking, stakings } = require("../helper/staking");
const { staking, } = require("../helper/staking");
const { getUniTVL } = require('../helper/unknownTokens')

const chainTvl = getUniTVL({
Expand All @@ -12,8 +8,6 @@ const chainTvl = getUniTVL({

const CANDY_TOKEN = '0x06C04B0AD236e7Ca3B3189b1d049FE80109C7977';

const CMC_API_URL = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/market-pairs/latest?slug=bored-candy-city'

const STAKING_CONTRACTS = [
'0xDAf7c0e2882818b46c36AdBCe95399821Eca08F8', // masterchef
'0x8FEf43b1f3046F8f58A76c64aD01Bc8d82ff0ad1', // candy vault
Expand All @@ -28,32 +22,13 @@ const VESTING_CONTRACTS = [
'0x427f1230A547566a51F5Ffd5698BB65c06acA2D2', // candy vesting
]

async function fetchTvl(timestamp, ethBlock, chainBlocks) {
let cmc_response = await get(CMC_API_URL)
const candyPrice = cmc_response.data.marketPairs[0].price
const balances = await stakings(STAKING_CONTRACTS, CANDY_TOKEN)(timestamp, ethBlock, chainBlocks)
const candyBalances = Object.values(balances)[0]

return toUSDTBalances(BigNumber(candyBalances).times(BigNumber(candyPrice)).div(1e18));
}

async function fetchVesting(timestamp, ethBlock, chainBlocks) {
let cmc_response = await get(CMC_API_URL)
const candyPrice = cmc_response.data.marketPairs[0].price
const balances = await stakings(VESTING_CONTRACTS, CANDY_TOKEN)(timestamp, ethBlock, chainBlocks)
const candyBalances = Object.values(balances)[0]

return toUSDTBalances(BigNumber(candyBalances).times(BigNumber(candyPrice)).div(1e18));
}

module.exports = {
misrepresentedTokens: true,
methodology:
"Factory address (0x84343b84EEd78228CCFB65EAdEe7659F246023bf) is used to find the LP pairs. TVL is equal to the liquidity on the AMM and the candy tokens in the staking pools / vault / vesting contract / lock contract.",
cronos: {
tvl: chainTvl,
staking: fetchTvl,
vesting: fetchVesting

staking: staking(STAKING_CONTRACTS, CANDY_TOKEN),
vesting: staking(VESTING_CONTRACTS, CANDY_TOKEN),
},
}; // node test.js projects/crodex/index.js
}
46 changes: 3 additions & 43 deletions projects/championfinance/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const sdk = require("@defillama/sdk");
const { unwrapUniswapLPs } = require("../helper/unwrapLPs");
const { pool2 } = require('../helper/pool2')
const { stakings } = require("../helper/staking");

const avicTokenAddress = "0x59B18817CA9f4ad2dEE6FBf30132dF6AEb9D763d";
const chamTokenAddress = "0xc65bC1E906771e105fBAcBD8dfE3862Ee7BE378E";
const chamRewardPoolAddress = "0x649EfBF7D96B06a2bD0fB134621AC9dD031923A4";
const boardroomAddress = [
Expand All @@ -16,49 +14,11 @@ const lps = [
"0xd6F18CDe9A52A9D815dd3C03C2325D453E32BDef", //CHAMUsdcLpAddress
"0x8392a728aEe00a26E99AF8e837c33591944e033a", // EVIC-WETH.e Address
];
const shareLps = "0xd6F18CDe9A52A9D815dd3C03C2325D453E32BDef";

async function calcPool2(masterchef, lps, block, chain) {
let balances = {};
const lpBalances = (
await sdk.api.abi.multiCall({
calls: lps.map((p) => ({
target: p,
params: masterchef,
})),
abi: "erc20:balanceOf",
block,
chain,
})
).output;
let lpPositions = [];
lpBalances.forEach((p) => {
lpPositions.push({
balance: p.output,
token: p.input.target,
});
});
await unwrapUniswapLPs(
balances,
lpPositions,
block,
chain,
(addr) => `${chain}:${addr}`
);
return balances;
}

async function pool2(timestamp, block, chainBlocks) {
return await calcPool2(chamRewardPoolAddress, lps, chainBlocks.avax);
}
async function tvl(timestamp, block, chainBlocks) {
let balances = {};
return balances;
}
module.exports = {
avax: {
tvl: tvl,
pool2: pool2,
tvl: () => ({}),
pool2: pool2(chamRewardPoolAddress, lps),
staking: stakings(boardroomAddress, chamTokenAddress)
}
};
Loading

0 comments on commit f388b78

Please sign in to comment.