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 Oct 13, 2023
2 parents 6cd82d4 + 8bb6133 commit b340ff7
Show file tree
Hide file tree
Showing 82 changed files with 665 additions and 210 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

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

62 changes: 42 additions & 20 deletions projects/altitude/index.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,66 @@
const { stakings } = require("../helper/staking");
const { pool2 } = require("../helper/pool2");

const stakingContracts = [
"0xbc2B1262C90ab34757dC7eb2CB7CE595660Ff44e",
];

const ALTD_USDC_UNIV2 = "0xC180869eeff55eE737e4B4f10D93B27B10bF976b";
const ALTD = "0x8929e9DbD2785e3BA16175E596CDD61520feE0D1";

const contract = '0xF80E51AFb613D764FA61751Affd3313C190A86BB'
const GENERAL_CONTRACT = '0xF80E51AFb613D764FA61751Affd3313C190A86BB';
const EXTRA_CONTRACTS = {
arbitrum: ['0xd6e501F92CE58623EE5D36f6BAdBcd35d87Ea522'],
mantle: ['0xf0dbc067D21319068e1C2617e13FC28db83C18FE'],
};

const CHAINS = ["ethereum", "bsc", "polygon", "arbitrum", "avax", "optimism", "fantom", "linea"];
const CHAINS = ["ethereum", "bsc", "polygon", "arbitrum", "avax", "optimism", "fantom", "linea", "mantle"];
const chainPathsAbi = "function chainPaths(uint256) view returns (bool ready, address srcToken, uint16 dstChainId, address dstToken, uint256 remoteLiquidity, uint256 localLiquidity, uint256 rewardPoolSize, address lpToken, bool stopSwap)";

let output = {};

CHAINS.forEach(chain => {
output[chain] = {
tvl: async (_, _b, _cb, { api, }) => {
const tokens = [];
let hasMoreTokens = false;
let currentStart = 0;
const fetchSize = 5;
do {
let res = await api.fetchList({ itemAbi: chainPathsAbi, target: contract, itemCount: fetchSize + currentStart, start: currentStart, permitFailure: true });
res = res.filter(i => i).map(i => i.srcToken);
tokens.push(...res);
currentStart += fetchSize;
hasMoreTokens = res.length === fetchSize;
} while (hasMoreTokens);
return api.sumTokens({ owner: contract, tokens });
// Define a function to fetch tokens given a contract address
const fetchTokens = async (contract) => {
const tokens = [];
let hasMoreTokens = false;
let currentStart = 0;
const fetchSize = 5;
do {
let res = await api.fetchList({
itemAbi: chainPathsAbi,
target: contract,
itemCount: fetchSize + currentStart,
start: currentStart,
permitFailure: true
});
res = res.filter(i => i).map(i => i.srcToken);
tokens.push(...res);
currentStart += fetchSize;
hasMoreTokens = res.length === fetchSize;
} while (hasMoreTokens);
return tokens;
};

// Fetch tokens from the general contract
let tokens = await fetchTokens(GENERAL_CONTRACT);

// If there are extra contracts for this chain, fetch those tokens too
if(EXTRA_CONTRACTS[chain]) {
for(const extraContract of EXTRA_CONTRACTS[chain]) {
const extraTokens = await fetchTokens(extraContract);
tokens = [...tokens, ...extraTokens];
}
}

// Sum tokens for TVL
return api.sumTokens({ owner: GENERAL_CONTRACT, tokens });
}
};
});


output.ethereum.staking = stakings(stakingContracts, ALTD);
// output.ethereum.pool2 = pool2(
// null, // No staking contract
// ALTD_USDC_UNIV2 // Address of the LP token
// );

output.methodology = "Fetches the localLiquidity of each token in the Altitude contract across multiple chains and computes the TVL.";

Expand Down
7 changes: 4 additions & 3 deletions projects/amphora/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const ADDRESSES = require('../helper/coreAssets.json')
const { sumTokens2 } = require('../helper/unwrapLPs');

async function tvl(_, _1, _2, { api }) {
const ownerAddress = "0xA905f9f0b525420d4E5214E73d70dfFe8438D8C8";
const tokensAndOwners = [
["0xb2f30a7c980f052f02563fb518dcc39e6bf38175", "0xD842D9651F69cEBc0b2Cffc291fC3D3Fe7b5D226"],
["0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F", ownerAddress],
[ADDRESSES.ethereum.SNX, ownerAddress],
["0xba100000625a3754423978a60c9317c58a424e3D", ownerAddress],
["0xD533a949740bb3306d119CC777fa900bA034cd52", ownerAddress,],
["0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B", ownerAddress,],
[ADDRESSES.ethereum.CRV, ownerAddress,],
[ADDRESSES.ethereum.CVX, ownerAddress,],
["0xD842D9651F69cEBc0b2Cffc291fC3D3Fe7b5D226", ownerAddress,]
];

Expand Down
12 changes: 6 additions & 6 deletions projects/apex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const walletAddresses = {
};

const tokenAddress = {
bsc: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
polygon: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
arbitrum: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8',
avax: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E',
optimism: '0x7F5c764cBc14f9669B88837ca1490cCa17c31607',
mantle: '0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9',
bsc: ADDRESSES.bsc.USDC,
polygon: ADDRESSES.polygon.USDC,
arbitrum: ADDRESSES.arbitrum.USDC,
avax: ADDRESSES.avax.USDC,
optimism: ADDRESSES.optimism.USDC,
mantle: ADDRESSES.mantle.USDC,
}

module.exports = {
Expand Down
7 changes: 4 additions & 3 deletions projects/arcanum/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const ADDRESSES = require('../helper/coreAssets.json')
const { sumTokensExport } = require('../helper/unwrapLPs')
const ARBI_CONTRACT = '0xfc2f1678f7c0d78c3911090c92b86bca7cc3a8b7';
const ARBI_CONTRACT = '0xB1947d7596840D0a14D30cCA91be69ddC24ab75d';
const ASSETS_CONTRACTS = [
'0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a',
ADDRESSES.arbitrum.GMX,
'0x11cdb42b0eb46d95f990bedd4695a6e3fa034978',
'0x18c11fd286c5ec11c3b683caa813b77f5163a122',
'0xb64e280e9d1b5dbec4accedb2257a87b400db149',
Expand All @@ -13,6 +14,6 @@ module.exports = {
methodology: 'counts the quantities of all tokens in multipool contracts.',
start: 1000235,
arbitrum: {
tvl: sumTokensExport({ owner: ARBI_CONTRACT, tokens: ASSETS_CONTRACTS}),
tvl: sumTokensExport({ owner: ARBI_CONTRACT, tokens: ASSETS_CONTRACTS }),
}
};
9 changes: 8 additions & 1 deletion projects/bassexhcnage/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
const { staking } = require("../helper/staking");
const { stakings } = require("../helper/staking");
const { sumTokens2 } = require('../helper/unwrapLPs')

const asssets = "0xb11f5E642EF4cF963e45A83E55A8fedCd58F9A9c"

const stakingContracts = [
'0xa5895B5fF267041B968aA82d37A141F08f344333',
'0xB6D7406F2e4B2680fFCCA3Ad3c3FAB5eE07f2832',
]
const bass = '0x1F23B787053802108fED5B67CF703f0778AEBaD8'

async function tvl(timestamp, ethereumBlock, chainBlocks, { api }) {
const tokensAndOwners = await api.call({
target: asssets,
Expand All @@ -14,5 +20,6 @@ async function tvl(timestamp, ethereumBlock, chainBlocks, { api }) {
module.exports = {
base: {
tvl,
staking: stakings(stakingContracts, bass),
},
};
7 changes: 4 additions & 3 deletions projects/blex/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const ADDRESSES = require("../helper/coreAssets.json");
const { sumTokensExport } = require('../helper/unwrapLPs')
const { sumTokensExport } = require("../helper/unwrapLPs");

const contracts = [
"0x4d377340a2875b875e1C104B9905F74FD716F59e", //CoreVault
Expand All @@ -12,6 +12,7 @@ const contracts = [
const tokens = [ADDRESSES.arbitrum.USDT];

module.exports = {
start: 118461883,
arbitrum: { tvl: sumTokensExport({ tokens, owners: contracts, }) },
start: 1691240820,
arbitrum: { tvl: sumTokensExport({ tokens, owners: contracts }) },
hallmarks: [[1691240820, "Blex Protocol Deployed on Arbitrum"]],
};
3 changes: 2 additions & 1 deletion projects/cbETH/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const ADDRESSES = require('../helper/coreAssets.json')
const { default: axios } = require("axios")
const token = '0xbe9895146f7af43049ca1c1ae358b0541ea49704'
const token = ADDRESSES.ethereum.cbETH

module.exports = {
ethereum: {
Expand Down
2 changes: 1 addition & 1 deletion projects/celerbridge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const liquidityBridgeTokens = [
{
// LYRA
ethereum: "0x01ba67aac7f75f647d94220cc98fb30fcc5105bf",
optimism: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
optimism: ADDRESSES.base.DAI,
},
{
// IMX
Expand Down
70 changes: 70 additions & 0 deletions projects/contrax-finance/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const ADDRESSES = require('../helper/coreAssets.json')
const { sumTokens2 } = require("../helper/unwrapLPs");
const Vaults = [
"0x5cc3543656EfA30144965C6c538F4d8379F83138",
"0x3C0c76ceb491Cb0Bacb31F8e7dc6407A25FD87C0",
"0x286d24B99b5CB6fE081f0e6Bd44EcbfCC1171A56",
"0x8f2CC9FC5ecf3D30aC83c96189cdd6EC2810E2f8",
"0x3F9012f9bF3172c26B1B7246B8bc62148842B013",
"0xeb952db71c594299cEEe7c03C3AA26FE0fDBC8eb",
"0xdf9d86bC4765a9C64e85323A9408dbee0115d22E",
"0xb58004E106409B00b854aBBF8CCB8618673d9346",
"0xf8bDcf1Cf4134b2864cdbE685A8128F90ED0E16e",
"0x46910A4AbA500b71F213150A0E99201Fd5c8FCec",
"0xfd3573bebDc8bF323c65Edf2408Fd9a8412a8694",
"0x8ca3f11485Bd85Dd0E952C6b21981DEe8CD1E901",
"0x1dda3B8A728a62a30f79d1E2a10e3d6B85ef4C5d",
"0x6C416e46424aF2676E9603F9D707f8d4808Bb5d8",
];
const HOP_MAGIC_VAULT = "0x2d79B76841191c9c22238535a93Ee8169096A5Cc";
const GMX_VAULT = "0x8CdF8d10ea6Cd3492e67C4250481A695c2a75C4a";
const GMX = ADDRESSES.arbitrum.GMX;

async function getHopMagicData(api) {
const tokenAddress = await api.call({
abi: "function token() view returns (address token)",
target: HOP_MAGIC_VAULT,
params: [],
});
const balance = await api.call({
abi: "erc20:balanceOf",
target: tokenAddress,
params: [HOP_MAGIC_VAULT],
});
api.add(tokenAddress, balance);
}

async function getGMXData(api) {
const balance = await api.call({
abi: "erc20:balanceOf",
target: GMX,
params: [GMX_VAULT],
});
api.add(GMX, balance);
}

async function tvl(_, _1, _2, { api }) {
let tokens = await api.multiCall({ abi: "address:token", calls: Vaults });
// Controllers
let targets = await api.multiCall({
abi: "address:controller",
calls: Vaults,
});

const bals = await api.multiCall({
abi: "erc20:balanceOf",
calls: tokens.map((t, i) => ({ target: targets[i], params: [t] })),
});
await getHopMagicData(api);
await getGMXData(api);

api.addTokens(tokens, bals);
return sumTokens2({ api, resolveLP: true });
}

module.exports = {
methodology: "gets the lp balance of all vaults/controller/treasuries",
arbitrum: {
tvl,
},
};
19 changes: 19 additions & 0 deletions projects/deepp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { sumTokensExport } = require("../helper/unwrapLPs");
const ADDRESSES = require("../helper/coreAssets.json");

module.exports = {
methodology: 'Lists the number of owned USDC tokens in the Deepp LP and BetLock contracts.',
start: 1696118400,
arbitrum: {
tvl: sumTokensExport({
owners: Object.values({
BET_LP_CONTRACT: '0x84a512E120294C2017a88a8f1af2219Ec250CBaa',
BET_BOX_ADDRESS: '0x05E1F51067a3Af2f9d0994a97779a78a2E26f921',
BET_FEE_HANDLER_1_ADDRESS: '0x42e27a7D424C22ED3658970CAB01260f8C0EC5Bc',
BET_FEE_HANDLER_2_ADDRESS: '0xD5750d44D9F2ed117FB3441D80B423acD7634Cf5',
LP_FEE_HANDLER_1_ADDRESS: '0x80e674e6277A7e9073A6Dff5C98e08816c0D73f5',
LP_FEE_HANDLER_2_ADDRESS: '0xAb5e18D29C20709954eA380e998FFFeaeB4FF691',
}), tokens: [ADDRESSES.arbitrum.USDC_CIRCLE]
}),
}
}; // node test.js projects/deepp/index.js
5 changes: 3 additions & 2 deletions projects/diva/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const ADDRESSES = require('../helper/coreAssets.json')
const { sumTokensExport } = require('../helper/unwrapLPs')

module.exports = {
Expand All @@ -7,8 +8,8 @@ module.exports = {
"0x1ce8aafb51e79f6bdc0ef2ebd6fd34b00620f6db",
"0x16770d642e882e1769ce4ac8612b8bc0601506fc"
], tokens: [
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"0xae7ab96520de3a18e5e111b5eaab095312d7fe84"
ADDRESSES.ethereum.WETH,
ADDRESSES.ethereum.STETH
]}),
}
};
2 changes: 1 addition & 1 deletion projects/dopex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async function arbTvl(timestamp, block, chainBlocks) {
await ssovTvl(balances, ssovs, chainBlocks.arbitrum, "arbitrum");
await crvTvls(balances, crvPools, chainBlocks.arbitrum, "arbitrum");
await sumTokens(balances, [
["0x912ce59144191c1204e64559fe8253a0e49e6548", "0xDF3d96299275E2Fb40124b8Ad9d270acFDcc6148"],
[ADDRESSES.arbitrum.ARB, "0xDF3d96299275E2Fb40124b8Ad9d270acFDcc6148"],
["0x6c2c06790b3e3e3c38e12ee22f8183b37a13ee55", "0x05E7ACeD3b7727f9129E6d302B488cd8a1e0C817"],
["0x32eb7902d4134bf98a28b963d26de779af92a212", "0xd74c61ca8917Be73377D74A007E6f002c25Efb4e"]
], chainBlocks.arbitrum, "arbitrum")
Expand Down
51 changes: 51 additions & 0 deletions projects/entities/gsr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const { treasuryExports } = require("../helper/treasury")

const config = {
ethereum: {
owners: [
"0xD8D6fFE342210057BF4DCc31DA28D006f253cEF0",
],
},
bsc: {
owners: [
"0xD8D6fFE342210057BF4DCc31DA28D006f253cEF0",
],
},
arbitrum: {
owners: [
"0xD8D6fFE342210057BF4DCc31DA28D006f253cEF0",
],
},
celo: {
owners: [
"0xD8D6fFE342210057BF4DCc31DA28D006f253cEF0",
],
},
optimism: {
owners: [
"0xD8D6fFE342210057BF4DCc31DA28D006f253cEF0",
],
},
polygon: {
owners: [
"0xD8D6fFE342210057BF4DCc31DA28D006f253cEF0",
],
},
avax: {
owners: [
"0xD8D6fFE342210057BF4DCc31DA28D006f253cEF0",
],
},
moonriver: {
owners: [
"0xD8D6fFE342210057BF4DCc31DA28D006f253cEF0",
],
},
aurora: {
owners: [
"0xD8D6fFE342210057BF4DCc31DA28D006f253cEF0",
],
},
}

module.exports = treasuryExports(config)
Loading

0 comments on commit b340ff7

Please sign in to comment.