-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into hedgehog-markets
- Loading branch information
Showing
25 changed files
with
343 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]}), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] }), | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) } | ||
}) |
Oops, something went wrong.