Skip to content

Commit

Permalink
Merge branch 'main' into hedgehog-markets
Browse files Browse the repository at this point in the history
  • Loading branch information
Juici committed Sep 24, 2024
2 parents 6c0f65d + 4313fce commit 78ee5dc
Show file tree
Hide file tree
Showing 25 changed files with 343 additions and 235 deletions.
13 changes: 8 additions & 5 deletions projects/aave/v3.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function v3(chain) {
params = ['0xFBedc64AeE24921cb43004312B9eF367a4162b57', undefined, ['0xa99F4E69acF23C6838DE90dD1B5c02EA928A53ee']]
else if (chain === 'bsc')
params = ['0x117684358D990E42Eb1649E7e8C4691951dc1E71', undefined, ['0x41585C50524fb8c3899B43D7D797d9486AAc94DB']]
else if (chain === 'era')
params = ['0x0753E3637ddC6efc40759D9c347251046644F25F', undefined, ['0x48B96565291d1B23a014bb9f68E07F4B2bb3Cd6D']]
const section = borrowed => aaveChainTvl(chain, ...params, borrowed, true);
return {
tvl: section(false),
Expand All @@ -28,13 +30,14 @@ function v3(chain) {
module.exports = mergeExports({
methodology: methodologies.lendingMarket,
avax: v3("avax"),
...["optimism", "fantom", "harmony", "arbitrum", "polygon", "ethereum", "metis", "base", "xdai", "scroll", "bsc"].reduce((t, c) => ({ ...t, [c]: v3(c) }), {}),
hallmarks: [
[1659630089, "Start OP Rewards"],
[1650471689, "Start AVAX Rewards"]
],
...["optimism", "fantom", "harmony", "arbitrum", "polygon", "ethereum", "metis", "base", "xdai", "scroll", "bsc", "era"].reduce((t, c) => ({ ...t, [c]: v3(c) }), {}),
}, {
// Lido pool
ethereum: aaveExports(undefined, "0x770ef9f4fe897e59daCc474EF11238303F9552b6", undefined, ["0xa3206d66cF94AA1e93B21a9D8d409d6375309F4A"], { v3: true, }),
});

module.exports.hallmarks = [
[1659630089, "Start OP Rewards"],
[1650471689, "Start AVAX Rewards"]
]
// node test.js projects/aave/index.js
3 changes: 2 additions & 1 deletion projects/ampleswap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ module.exports = {
staking: staking(MasterChefContract, AMPLE),
},
alv: { tvl: getUniTVL({ factory: '0x01dC97C89DF7d3C616a696dD53F600aB3FF12983', useDefaultCoreAssets: true }), },
dsc: { tvl: getUniTVL({ factory: '0x232Ba9f3B3643ab28d28ED7ee18600708D60E5fe', useDefaultCoreAssets: true, }), },
dsc: { tvl: () => ({}) }
// dsc: { tvl: getUniTVL({ factory: '0x232Ba9f3B3643ab28d28ED7ee18600708D60E5fe', useDefaultCoreAssets: true, }), },
};
4 changes: 2 additions & 2 deletions projects/awaken/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { request, gql } = require("graphql-request");
const { toUSDTBalances } = require("../helper/balances");

const GRAPH_QUERY = gql`
query get_tvl($dto: GetTotalValueLockedDto) {
query get_tvl($dto: GetTotalValueLockedDto!) {
totalValueLocked(dto: $dto) {
value
}
Expand Down Expand Up @@ -32,7 +32,7 @@ function getChainTvl(graphUrls) {
}

const v2graph = getChainTvl({
aelf: "https://dapp.awaken.finance/AElfIndexer_Swap/SwapIndexerSchema/graphql",
aelf: "https://app.aefinder.io/awaken/995f8e7e957d43d6b1706a4e351e2e47/graphql",
});

module.exports = {
Expand Down
2 changes: 2 additions & 0 deletions projects/cybro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const vaults = [
'0x9cc62ef691e869c05fd2ec41839889d4e74c3a3f',
'0x3500e1d4e93c9f45aa8198efda16842cb73fa1bc',
'0x6654cddf2a14a06307af6a8d7731dd4e059962a1',
'0xdb5e7d5ac4e09206fed80efd7abd9976357e1c03',
'0x3db2bd838c2bed431dcfa012c3419b7e94d78456',
]

async function tvl(api) {
Expand Down
112 changes: 30 additions & 82 deletions projects/darkcrypto/farm-utils.js
Original file line number Diff line number Diff line change
@@ -1,90 +1,38 @@
const sdk = require('@defillama/sdk');
const BigNumber = require('bignumber.js');
const farmCronos = require('./farm-cronos.json');
const abi = {
getReserves: "function getReserves() view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)",
poolInfo: "function poolInfo(uint256) view returns (address token, uint256 allocPoint, uint256 lastRewardTime, uint256 accSkyPerShare, bool isStarted)"
}

const farmLPBalance = async (
chain,
block,
masterChef,
lpToken,
token0,
token1,
) => {
const balances = (
await sdk.api.abi.multiCall({
abi: 'erc20:balanceOf',
calls: [
{
target: token0,
params: [lpToken],
},
{
target: token1,
params: [lpToken],
},
{
target: lpToken,
params: [masterChef],
},
],
block,
chain: chain,
})
).output;

const lpTotalSuply = (
await sdk.api.abi.call({
target: lpToken,
abi: 'erc20:totalSupply',
chain: chain,
block,
})
).output;
const token0Locked = (balances[2].output * balances[0].output) / lpTotalSuply;
const token1Locked = (balances[2].output * balances[1].output) / lpTotalSuply;
return [
{ token: `${chain}:${token0}`, locked: token0Locked },
{ token: `${chain}:${token1}`, locked: token1Locked },
];
};
const pool2Balances = async (api, masterChef) => {
const calls = Array.from({ length: 9 }, (_, i) => ({ target: masterChef, params: [i] }));
const poolsInfos = await api.multiCall({ calls, abi: abi.poolInfo })
const pools = poolsInfos.map(({ token }) => token)

const [token0s, token1s, balances, reserves, supplies] = await Promise.all([
api.multiCall({ calls: pools.map((p) => ({ target: p })), abi: 'address:token0', permitFailure: true }),
api.multiCall({ calls: pools.map((p) => ({ target: p })), abi: 'address:token1', permitFailure: true }),
api.multiCall({ calls: pools.map((p) => ({ target: p, params: [masterChef] })), abi: 'erc20:balanceOf', permitFailure:true }),
api.multiCall({ calls: pools.map((p) => ({ target: p })), abi: abi.getReserves, permitFailure:true }),
api.multiCall({ calls: pools.map((p) => ({ target: p })), abi: 'erc20:totalSupply', permitFailure:true })
])

const farmLocked = async (block) => {
const balances = {};
const tokens = farmCronos.tokens;
pools.forEach((_, i) => {
const token0 = token0s[i]
const token1 = token1s[i]
const balance = balances[i]
const reserve = reserves[i]
const supply = supplies[i]
if (!token0 || !token1 || !balance || !reserve || !supply) return

const allPools = farmCronos.farms
.map((t) => {
return t.pools.map((pool) => {
return Object.assign(pool, {
masterChef: t.masterChef,
});
});
})
.reduce((acc, current) => [...acc, ...current], []);
const promises = allPools.map((item) => {
return farmLPBalance(
'cronos',
block,
item.masterChef,
item.lpToken,
tokens[item.token0],
tokens[item.token1],
);
});
const _balance0 = Math.round(reserve[0] * balance / supply)
const _balance1 = Math.round(reserve[1] * balance / supply)

const data = await Promise.all(promises);
data.forEach((farm) => {
farm.forEach((item) => {
balances[item.token] = new BigNumber(balances[item.token] || 0)
.plus(item.locked || 0)
.toFixed(0);
});
});
api.add(token0, _balance0)
api.add(token1, _balance1)
})
}

return balances;
};

module.exports = {
farmLocked,
};
pool2Balances
}
31 changes: 3 additions & 28 deletions projects/darkcrypto/index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
const ADDRESSES = require('../helper/coreAssets.json')
const { stakingUnknownPricedLP } = require("../helper/staking");
const farmUtils = require("./farm-utils");
const vaultUtils = require("./vault-utils")
const { pool2Balances } = require("./farm-utils");

const sdk = require("@defillama/sdk");
const sky = "0x9D3BBb0e988D9Fb2d55d07Fe471Be2266AD9c81c";
const boardroom = "0x2e7d17ABCb9a2a40ec482B2ac9a9F811c12Bf630";


async function pool2(timestamp, block, chainBlocks) {
// SKY POOL
const farmTvl = await farmUtils.farmLocked(chainBlocks["cronos"]);
let balances = {};

//add CRO balance in LP pool
sdk.util.sumSingleBalance(
balances,
"cronos:" + ADDRESSES.cronos.WCRO_1,
farmTvl["cronos:" + ADDRESSES.cronos.WCRO_1]
);

//add Dark and Sky balance in LP pool
sdk.util.sumSingleBalance(
balances,
"cronos:" + ADDRESSES.cronos.WCRO_1,
farmTvl["cronos:" + ADDRESSES.cronos.WCRO_1],
);

return balances;
}
const masterChef = "0x42B652A523367e7407Fb4BF2fA1F430781e7db8C"

async function vault(api){
return vaultUtils.vaultLocked(api)
Expand All @@ -38,13 +14,12 @@ module.exports = {
doublecounted: true,
cronos: {
tvl:vault,
pool2,
pool2: (api) => pool2Balances(api, masterChef),
staking: stakingUnknownPricedLP(
boardroom,
sky,
"cronos",
"0xaA0845EE17e4f1D4F3A8c22cB1e8102baCf56a77"
),

},
};
7 changes: 6 additions & 1 deletion projects/eris-protocol/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ const config = {
coinGeckoId: "chihuahua-token",
hub: "chihuahua1nktfhalzvtx82kyn4dh6l8htcl0prfpnu380a39zj52nzu3j467qqg23ry",
},
nibiru: {
coinGeckoId: "nibiru",
hub: "nibi1udqqx30cw8nwjxtl4l28ym9hhrp933zlq8dqxfjzcdhvl8y24zcqpzmh8m",
},
};

let assetDecimals = {
Expand Down Expand Up @@ -399,7 +403,7 @@ async function productsTvl(chain) {

module.exports = {
timetravel: false,
methodology: "Liquid Staking and Arbitrage Protocol",
methodology: "Liquid Staking and Arbitrage Protocol",
terra2: { tvl: () => productsTvl("terra2") },
terra: { tvl: () => productsTvl("terra") },
kujira: { tvl: () => productsTvl("kujira") },
Expand All @@ -411,4 +415,5 @@ module.exports = {
chihuahua: { tvl: () => productsTvl("chihuahua") },
archway: { tvl: () => productsTvl("archway") },
sei: { tvl: () => productsTvl("sei") },
nibiru: { tvl: () => productsTvl("nibiru") },
};
5 changes: 3 additions & 2 deletions projects/evaa/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const { sumTokensExport } = require("../helper/chain/ton");
const ADDRESSES = require("../helper/coreAssets.json");

const evaaScAddr = "EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr"
const evaaMainPool = "EQC8rUZqR_pWV1BylWUlPNBzyiTYVoBEmQkMIQDZXICfnuRr"
const evaaLpPool = "EQBIlZX2URWkXCSg3QF2MJZU-wC5XkBoLww-hdWk2G37Jc6N"

module.exports = {
methodology: 'Counts EVAA smartcontract balance as TVL.',
ton: {
tvl: sumTokensExport({ owner: evaaScAddr, tokens: [ADDRESSES.null]}),
tvl: sumTokensExport({ owners: [evaaMainPool, evaaLpPool], tokens: [ADDRESSES.null]}),
}
}
10 changes: 10 additions & 0 deletions projects/filament/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { sumTokensExport } = require("../helper/unwrapLPs");

const USDC_CONTRACT = '0x3894085Ef7Ff0f0aeDf52E2A2704928d1Ec074F1';
const FILAMENT_VAULT_CONTRACT = '0xbeB6A6273c073815eBe288d2dF4e5E8bc027DA11';

module.exports = {
sei: {
tvl: sumTokensExport({ owner: FILAMENT_VAULT_CONTRACT, tokens: [USDC_CONTRACT] }),
},
}
16 changes: 16 additions & 0 deletions projects/four-meme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const ADDRESSES = require('../helper/coreAssets.json');
const { sumTokensExport } = require("../helper/unwrapLPs");

const config = {
bsc: {
owners: Object.values({
tokenManager: "0xEC4549caDcE5DA21Df6E6422d448034B5233bFbC",
tokenManager2: "0x5c952063c7fc8610FFDB798152D69F0B9550762b",
}),
tokens: [ADDRESSES.null, ADDRESSES.bsc.USDT,],
},
};

Object.keys(config).forEach(chain => {
module.exports[chain] = { tvl: sumTokensExport(config[chain]) }
})
Loading

0 comments on commit 78ee5dc

Please sign in to comment.