Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
test committed Apr 5, 2024
2 parents 4e96b8c + 0074e41 commit fc34ee8
Show file tree
Hide file tree
Showing 108 changed files with 1,057 additions and 1,395 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
File renamed without changes.
4 changes: 2 additions & 2 deletions projects/MeowMiner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ 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: () => ({}),
staking: sumTokensExport({ owner: MEOW_MINER_CONTRACT, tokens: [MEOW_TOKEN_CONTRACT], lps: [LP_MEOW_WAVAX], useDefaultCoreAssets: true, })
staking: 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
}),
},
};
18 changes: 14 additions & 4 deletions projects/aloe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,25 @@ async function getVaults(api) {

async function tvl(api) {
const vaults = await getVaults(api);
return api.erc4626Sum({ calls: vaults, isOG4626: true });
return api.erc4626Sum({ calls: vaults, tokenAbi: 'address:asset', balanceAbi: 'uint256:lastBalance' });
}

async function borrowed(api) {
const vaults = await getVaults(api);
const tokens = await api.multiCall({ calls: vaults, abi: "address:asset" });
const stats = await api.multiCall({
calls: vaults,
abi: "function stats() view returns (uint72 borrowIndex, uint256 totalAssets, uint256 totalBorrows, uint256 totalSupply)",
});
api.addTokens(tokens, stats.map(x => x.totalBorrows));
}

module.exports = {
doublecounted: true,
doublecounted: false,
methodology:
"Sums up deposits and borrows across Aloe's ERC4626 lending vaults to get TVL. Does not include collateral value.",
"Sums up deposits and borrows across Aloe's ERC4626 lending vaults to get TVL and Borrowed amounts, respectively. Does not include collateral value.",
};

Object.keys(config).forEach(chain => {
module.exports[chain] = { tvl }
module.exports[chain] = { tvl, borrowed }
})
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
1 change: 1 addition & 0 deletions projects/archly-finance-v2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const config = {
metis: { lp: '0xA152A0Ee0Bc15A937D5365DEB8507D063467A68d' },
neon_evm: { lp: '0x9a08ab9b8b9A90bF9fe836D28E85808Db29Dc1aD' },
mode: { lp: '0xC6FA6454E76cF425a020fdb1EF61FeB0e551912C' },
zora: { lp: '0x577B2E4C7Ddd23d2fA9D56b4456505e420851046' },
}

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"],
},
})
1 change: 1 addition & 0 deletions projects/aura-finance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const config = {
polygon: { factory: '0x22625eedd92c81a219a83e1dc48f88d54786b017', fromBlock: 40687417, voterProxy: '0xC181Edc719480bd089b94647c2Dc504e2700a2B0' },
xdai: { factory: '0x83E443EF4f9963C77bd860f94500075556668cb8', fromBlock: 27088527, voterProxy: '0xC181Edc719480bd089b94647c2Dc504e2700a2B0' },
polygon_zkevm: { factory: '0x2498A2B0d6462d2260EAC50aE1C3e03F4829BA95', fromBlock: 203652, voterProxy: '0xC181Edc719480bd089b94647c2Dc504e2700a2B0' },
avax: { factory: '0xf23b4DB826DbA14c0e857029dfF076b1c0264843', fromBlock: 32558551, voterProxy: '0xC181Edc719480bd089b94647c2Dc504e2700a2B0' },
}

module.exports = {
Expand Down
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
31 changes: 31 additions & 0 deletions projects/blackwing/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const ADDRESSES = require('../helper/coreAssets.json')
const { sumTokensExport } = require("../helper/unwrapLPs");

const BLACKWING_VAULT_ARBITRUM = '0xc6aDE8A68026d582AB37B879D188caF7e405dD09'
const BLACKWING_VAULT_ETH = '0xc6aDE8A68026d582AB37B879D188caF7e405dD09'
const BLACKWING_VAULT_BSC = '0xD00789260984160a64DcF19A03896DfF73BF4514'

const ARBITRUM_WEETH = "0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe";
const ARBITRUM_EZETH = "0x2416092f143378750bb29b79eD961ab195CcEea5";

const ETHEREUM_MAINNET_RSWETH = '0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0';
const ETHEREUM_MAINNET_RSETH = "0xa1290d69c65a6fe4df752f95823fae25cb99e5a7";
const ETHEREUM_MAINNET_WEETH = "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee";
const ETHEREUM_MAINNET_EZETH = "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110";

module.exports = {
arbitrum: {
tvl: sumTokensExport({ tokens: [ADDRESSES.arbitrum.USDC_CIRCLE, ADDRESSES.arbitrum.USDC, ADDRESSES.arbitrum.WETH, ARBITRUM_EZETH, ARBITRUM_WEETH,], owner: BLACKWING_VAULT_ARBITRUM, fetchCoValentTokens: true, }),
},
ethereum: {
tvl: sumTokensExport({
tokens: [ADDRESSES.ethereum.USDC, ADDRESSES.ethereum.WETH, ETHEREUM_MAINNET_RSWETH, ETHEREUM_MAINNET_RSETH, ETHEREUM_MAINNET_EZETH, ADDRESSES.ethereum.EETH, ETHEREUM_MAINNET_WEETH, ADDRESSES.ethereum.sUSDe,
], owner: BLACKWING_VAULT_ETH, fetchCoValentTokens: true,
})
},
bsc: {
tvl: sumTokensExport({
tokens: [ADDRESSES.bsc.USDT, ADDRESSES.bsc.WBNB,], owner: BLACKWING_VAULT_BSC, fetchCoValentTokens: true,
})
}
}
4 changes: 2 additions & 2 deletions projects/blast/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { nullAddress } = require("../helper/treasury");

const farm = "0x5f6ae08b8aeb7078cf2f96afb089d7c9f51da47d";

async function tvl(_, _a, _b, {api}){
async function tvl(api) {
const dsr = await api.call({
target: "0x373238337bfe1146fb49989fc222523f83081ddb",
abi: "function pieOf(address) external view returns (int256)",
Expand All @@ -23,5 +23,5 @@ async function tvl(_, _a, _b, {api}){
}

module.exports = {
ethereum: {tvl}
ethereum: { tvl }
}
2 changes: 1 addition & 1 deletion projects/brrr/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { sumTokensExport } = require('../helper/unwrapLPs')
const ADDRESSES = require('../helper/coreAssets.json')

const NFT_CONTRACT = "0x47efb5793b3aa8e15808c6fa794e6d7c93394047";
const NFT_CONTRACT = "0x58ebebd033dC43aa9ab41ff739C7052eB0A72cd7";

module.exports = {
blast: {
Expand Down
7 changes: 7 additions & 0 deletions projects/c14/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { aaveExports } = require('../helper/aave');
const methodologies = require('../helper/methodologies');

module.exports = {
methodology: methodologies.lendingMarket,
astrzk: aaveExports('astrzk', "0x12922D7d8762090Cb27E7e1e824EC9c373664704", undefined, ['0x7B47bfB3F6C4ff74bb39395676759d4aFbD9f071'], { v3: true }),
}
Loading

0 comments on commit fc34ee8

Please sign in to comment.