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
waynebruce0x authored Apr 5, 2024
2 parents 5c059d6 + 2ef981e commit 8f2e6d5
Show file tree
Hide file tree
Showing 68 changed files with 721 additions and 1,221 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"treasury": "cd utils;npm i; cd ..; node utils/testInteractive treasury",
"entities": "cd utils;npm i; cd ..; node utils/testInteractive entities",
"useTokenLabels": "node utils/scripts/useTokenLabels.js",
"biggest-files": "find ./projects -name '*.js' -not -path './projects/helper/*' -not -path './projects/curve/*' -not -path './projects/sigmao/*' -exec du -sh {} \\; | sort -rh | head -n 100",
"postinstall": "echo 'run \"npm update @defillama/sdk\" if you want lastest sdk changes' "
},
"author": "",
Expand Down
3 changes: 2 additions & 1 deletion projects/3a-dao/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { getLogs } = require('../helper/cache/getLogs')

const config = {
polygon: { factory: '0x4760847023fa0833221ae76E01Db1E483A5D20e0', fromBlock: 49852705 },
linea: { factory: '0x65c6FD9B3a2A892096881e28f07c732ed128893E', fromBlock: 3045954 },
}

Object.keys(config).forEach(chain => {
Expand All @@ -16,7 +17,7 @@ Object.keys(config).forEach(chain => {
fromBlock,
})
const vaults = logs.map(log => log.vault)
const tokens = await api.multiCall({ abi: 'address[]:collaterals', calls: vaults})
const tokens = await api.multiCall({ abi: 'address[]:collaterals', calls: vaults })
const ownerTokens = tokens.map((token, i) => [token, vaults[i]])
return api.sumTokens({ ownerTokens })
}
Expand Down
4 changes: 2 additions & 2 deletions projects/MeowMiner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const LP_MEOW_WAVAX = "0xbbf8e4b9AD041edE1F5270CAf5b7B41F0e55f719"

module.exports = {
methodology: 'counts the number of MEOW tokens in the Meow Miner contract.',
start: 1000235,
start: 1710293916,
avax: {
tvl: sumTokensExport({ owner: MEOW_MINER_CONTRACT, tokens: [MEOW_TOKEN_CONTRACT], lps: [LP_MEOW_WAVAX], useDefaultCoreAssets: true, })
tvl: sumTokensExport({ owner: MEOW_MINER_CONTRACT, tokens: [MEOW_TOKEN_CONTRACT], lps: [LP_MEOW_WAVAX], useDefaultCoreAssets: true, }),
}
}
3 changes: 3 additions & 0 deletions projects/Zenonswap/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { uniTvlExport } = require('../helper/unknownTokens')

module.exports = uniTvlExport('degen', '0x97B162AD1443737B0500A5E726344D608eB9e255')
36 changes: 36 additions & 0 deletions projects/ainn-layer2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const sdk = require('@defillama/sdk');
const { sumTokensExport } = require('../helper/sumTokens');

const BTCOwners = [
"bc1q6dtp7ayaj5k2zv0z5ayhkdsvmtvdqgyaa9zs53",
"3H8cmLndtkBs7kiHByhHAddTzy8taUwYPt",
"bc1pepsapf26n8y2f4uftlmhy60ksghx6rqlxdcj4uacfqrkcg6pmncs52rzuu",
"bc1qcmmkxfp2rawrp6yx55rez9jcqdnxtam8jhu2v2d9kz46upf948wq2usauv",
"bc1qu4ru2sph5jatscx5xuf0ttka36yvuql7hl5h4c",
"1JA46eiDpfx589wawn5RvtEXgwc518QfhZ",
"bc1qaajdlp5yrj5f77wq2ndtfqnmsamvvxhpy95662zkzykn9qhvdgys580hcs",
"368vZZKUWDFZRLWMFNRJzHo1HnibNeAJir",
"33hE9Wq65kjbiLsGD1NYwwNatP6hbsZv5H",
"32GU8Jux7SbsEbaAaLUnEQmc6JemLF6BUb",
"3CP5WJ2JSLCew7SETWUe5FxpBGrekMBiwk",
"39Fvw2Ho1fEkyDsos5sNTN5iMJZKzTL526",
"3Kptt4TZZRcjuGH8ikoQ8mV1TVxq45dnuS",
"3G4sMXWAAVTvTXTksr8u9zuu7W8RKsicEz",
"335DRGzLLG2tu4H4PnFBHYAwcj5pvV8zei"
];


module.exports = {
methodology: "Staking tokens via AINN Layer2 Dataset counts as TVL.",
bitcoin: {
tvl: sdk.util.sumChainTvls([
sumTokensExport({ owners: BTCOwners }),
]),
},
zklink: {
tvl: sumTokensExport({
owners: ["0xc698c23d7cDE4203EafD8F45d8bab8fA86D413d1"],
tokens: ["0xEbc45Ef3B6D7E31573DAa9BE81825624725939f9"] //wbtc
}),
},
};
93 changes: 88 additions & 5 deletions projects/airpuff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const contractAbis = {
}, //
balanceOf: "function balanceOf(address) external view returns (uint256)",
getPrice: "function answer() external view returns (uint256)",
getTotalSupply: "function totalSupply() external view returns (uint256)",
getTotalAssets: "function totalAssets() external view returns (uint256)",
getVectorSharePrice: "function getVectorSharePrice() external view returns (uint256)",
getMswEthPrice: "function exchangeRateToNative() external view returns (uint256)",
getMswBalance: "function getAllEigeinPieCycleDepositAmounts() external view returns (uint256)",
};

module.exports = {
Expand All @@ -23,9 +28,13 @@ module.exports = {
tvl: async (api) => {
const lendingMain = {
eth: "0xdeF3AA48bad043e53207d359dcDFdE46F50b6C02", //ETH
sUSD: "0x7c2a7009ffE52a69a8C877b47B07D5dB59C0e3b3", // Not lending pool, staking pool
};
await api.sumTokens({
tokensAndOwners: [[ADDRESSES.ethereum.WETH, lendingMain.eth]],
tokensAndOwners: [
[ADDRESSES.ethereum.WETH, lendingMain.eth],
[ADDRESSES.ethereum.sUSDe, lendingMain.sUSD],
],
});

const eETH = {
Expand Down Expand Up @@ -97,6 +106,23 @@ module.exports = {
oracle: "0x1bEB65b15689cCAeb5dA191c9fd5F94513923Cab",
};

const svETH = {
vault: "0xaF33b6372354149c33893B6fA6959Be0607D53dE",
reStakingToken: "0x6733F0283711F225A447e759D859a70b0c0Fd2bC",
oracle: "svETH",
};

const svETH1x = {
vault: "0x060Feab7904378e2A487974e7Ba98251aD65247F",
reStakingToken: "0x6733F0283711F225A447e759D859a70b0c0Fd2bC",
oracle: "svETH",
};

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

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

for (const strategy of strategies) {
Expand All @@ -106,15 +132,72 @@ module.exports = {
params: [strategy.vault],
});

const lrETHPriceInETH = await api.call({
target: strategy.oracle,
abi: contractAbis.readOraclePrice,
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);
}
//strategy with no oracle, but can calculate price using erc4626 totalSupply and totalAssets
const LiquidETH = {
vault: "0xE543eBa28a3793d5ae747A2164A306DB1767cDAe",
reStakingToken: "0xeA1A6307D9b18F8d1cbf1c3Dd6aad8416C06a221",
};

const erc4626Strategies = [LiquidETH];

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

const balInETH = (bal * lrETHPriceInETH.value) / 1e18;
const totalAssets = await api.call({
abi: contractAbis.getTotalAssets,
target: erc4626strategy.reStakingToken,
});

const totalSupply = await api.call({
abi: contractAbis.getTotalSupply,
target: erc4626strategy.reStakingToken,
});

const price = totalAssets / totalSupply;

const balInETH = bal * price;

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

const mswETH = {
valut: "0x7c505E03460aEF7FE88e218CC5fcEeCCcA4C4394",
reStakingToken: "0x32bd822d615A3658A68b6fDD30c2fcb2C996D678",
};

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

const mswETHBal = await api.call({
abi: contractAbis.getMswBalance,
target: mswETH.valut,
});

const mswETHBalInETH = (mswETHBal * mswETHPrice) / 1e18;

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

Expand Down
5 changes: 2 additions & 3 deletions projects/alpaca-finance-v2/moneyMarket.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const sdk = require("@defillama/sdk");
const abi = require("./abi.json");
const { getConfig } = require("../helper/cache");
const { sumTokens2 } = require('../helper/unwrapLPs')
Expand All @@ -7,12 +6,12 @@ async function getMoneyMarketData() {
return (await getConfig("alpaca-finance-2.0", "https://raw.githubusercontent.com/alpaca-finance/alpaca-v2-money-market/main/.mainnet.json")).moneyMarket;
}

async function lendingTvl(ts, _, _1, {api}) {
async function lendingTvl(api) {
const { moneyMarketDiamond, markets } = await getMoneyMarketData();
return sumTokens2({ api, owner: moneyMarketDiamond, tokens: markets.map(i => i.token)})
}

async function borrowTvl(ts, _, _1, {api}) {
async function borrowTvl(api) {
const { moneyMarketDiamond, markets } = await getMoneyMarketData();
const tokens = markets.map(i => i.token)

Expand Down
51 changes: 7 additions & 44 deletions projects/arbis.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
const { staking } = require('./helper/staking')
const sdk = require('@defillama/sdk')
const { unwrapLPsAuto } = require('./helper/unwrapLPs')
const { getChainTransform } = require('./helper/portedTokens')

const chain = 'arbitrum'


async function tvl(_, _b, { [chain]: block}) {
const balances = {}
const transformAddress = await getChainTransform(chain)
async function tvl(api) {
const vaults1 = [
'0x47a156668F1Ecc659Efbbf4910508Ace1b46a49b',
'0xdc2d66044e894d0726570bdc03d2123ab8f2cd51',
Expand All @@ -26,41 +18,12 @@ async function tvl(_, _b, { [chain]: block}) {
'0xb970E280F9ddAA3349ab9F3ecf778970cDE46655',
]

const { output: tokens } = await sdk.api.abi.multiCall({
abi: abi.stakedToken,
calls: vaults.map(i => ({ target: i})),
chain, block,
})

const { output: deposits } = await sdk.api.abi.multiCall({
abi: abi.totalSupply,
calls: vaults.map(i => ({ target: i})),
chain, block,
})

const { output: tokens1 } = await sdk.api.abi.multiCall({
abi: abi.depositToken,
calls: vaults1.map(i => ({ target: i})),
chain, block,
})

const { output: deposits1 } = await sdk.api.abi.multiCall({
abi: abi.totalDeposits,
calls: vaults1.map(i => ({ target: i})),
chain, block,
})

tokens.forEach((data, i) => {
sdk.util.sumSingleBalance(balances, transformAddress(data.output), deposits[i].output)
})

tokens1.forEach((data, i) => {
sdk.util.sumSingleBalance(balances, transformAddress(data.output), deposits1[i].output)
})

await unwrapLPsAuto({ balances, block, chain, })

return balances
const tokens = await api.multiCall({ abi: abi.stakedToken, calls: vaults})
const bals = await api.multiCall({ abi: abi.totalSupply, calls: vaults})
api.add(tokens, bals)
const tokens1 = await api.multiCall({ abi: abi.depositToken, calls: vaults1})
const bals1 = await api.multiCall({ abi: abi.totalDeposits, calls: vaults1})
api.add(tokens1, bals1)
}

module.exports = {
Expand Down
26 changes: 26 additions & 0 deletions projects/ash-perp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { cachedGraphQuery } = require('../helper/cache')
const { sumTokens } = require('../helper/sumTokens')

const API_URL = 'https://api.ashperp.trade/graphql';

const TVLQuery = `query Vault {
vault {
_address
getAssetTokenId
}
}`

async function tvl() {
const data = await cachedGraphQuery('ashperp', API_URL, TVLQuery)
const owners = Object.values(data).flat().map(i => i._address);
const token = Object.values(data).flat().map(i => i.getAssetTokenId);
return sumTokens({ owners, chain: 'elrond', tokens: [token]})
}

module.exports = {
misrepresentedTokens: true,
timetravel: false,
elrond: {
tvl
},
}
8 changes: 8 additions & 0 deletions projects/astaria-v2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { treasuryExports } = require("../helper/treasury");
const ADDRESSES = require('../helper/coreAssets.json')

module.exports = treasuryExports({
base: {
owners: ["0x0000000000A6F0986c92cf1EC4d2e77aFBE1466D"],
},
})
4 changes: 2 additions & 2 deletions projects/autobark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const tokenAPI = "address:want"

module.exports = {
[chain]: {
tvl: async (_, _b, { [chain]: block }) => {
tvl: async (api) => {
const pools = await getConfig('autobark','https://raw.githubusercontent.com/autobark-finance/autobark-app-pub/main/src/features/config/vault/dogechain_pools.js')
const vaults = pools
.split('\n')
.filter(i => i.includes('earnedTokenAddress'))
.map(i => i.split('\'').filter(i => i.startsWith('0x'))[0])
return yieldHelper({ vaults, chain, block, tokenAPI, useDefaultCoreAssets: true, })
return yieldHelper({ ...api, vaults, tokenAPI, useDefaultCoreAssets: true, })
}
}
}
4 changes: 2 additions & 2 deletions projects/based-finance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const treasuryTokens = [
wftmAddress,
];

async function treasury(_, _b, { fantom: block }) {
return sumTokens2({ owner: treasuryAddress, tokens: treasuryTokens, block, chain, })
async function treasury(api) {
return sumTokens2({ owner: treasuryAddress, tokens: treasuryTokens, api })
}

module.exports = {
Expand Down
1 change: 1 addition & 0 deletions projects/beefy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const chains = {
heco: 128,
polygon: 137,
fantom: 250,
fraxtal: 252,
zksync: 324,
metis: 1088,
polygon_zkevm: 1101,
Expand Down
7 changes: 3 additions & 4 deletions projects/bitgert/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ const { sumTokens2, nullAddress } = require('../helper/unwrapLPs')
module.exports = {
bsc: {
tvl: () => ({}),
staking: staking('0xd578bf8cc81a89619681c5969d99ea18a609c0c3', '0x8FFf93E810a2eDaaFc326eDEE51071DA9d398E83', 'bsc'),
staking: staking('0xd578bf8cc81a89619681c5969d99ea18a609c0c3', '0x8FFf93E810a2eDaaFc326eDEE51071DA9d398E83'),
},
bitgert: {
staking: async (_, _b, { bitgert: block }) => sumTokens2({
chain: 'bitgert',
block,
staking: async (api) => sumTokens2({
api,
owner: '0x8Ed91b2f3d9f6a5Ee426B4705F981090a7403795',
tokens: [nullAddress],
})
Expand Down
Loading

0 comments on commit 8f2e6d5

Please sign in to comment.