mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-04-29 05:15:28 +08:00
Merge branch 'main' into token_label
This commit is contained in:
16
package-lock.json
generated
16
package-lock.json
generated
@@ -169,9 +169,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@defillama/sdk": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.10.tgz",
|
||||
"integrity": "sha512-d+xTcUvuar3WVSmouJdsVGkGjZc44/tW/REQCjSKn0wplB0ugEjGWdZ/LbbxpCbqRiifwkp2IoFrf1DpNVjuyQ==",
|
||||
"version": "4.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.13.tgz",
|
||||
"integrity": "sha512-J30sy9VAITb7Es8jQDEt7RJ9B22ylryx24lgQLj0sBXq7iqhF302IiyoM7t66G9pFKtsAOIwdRFH9uNIhBNAyA==",
|
||||
"dependencies": {
|
||||
"@supercharge/promise-pool": "^2.1.0",
|
||||
"ethers": "^5.4.5",
|
||||
@@ -5466,9 +5466,9 @@
|
||||
}
|
||||
},
|
||||
"@defillama/sdk": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.10.tgz",
|
||||
"integrity": "sha512-d+xTcUvuar3WVSmouJdsVGkGjZc44/tW/REQCjSKn0wplB0ugEjGWdZ/LbbxpCbqRiifwkp2IoFrf1DpNVjuyQ==",
|
||||
"version": "4.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.13.tgz",
|
||||
"integrity": "sha512-J30sy9VAITb7Es8jQDEt7RJ9B22ylryx24lgQLj0sBXq7iqhF302IiyoM7t66G9pFKtsAOIwdRFH9uNIhBNAyA==",
|
||||
"requires": {
|
||||
"@supercharge/promise-pool": "^2.1.0",
|
||||
"ethers": "^5.4.5",
|
||||
@@ -8590,7 +8590,7 @@
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"@jest/types": "^26.6.2",
|
||||
"ansi-regex": "5.0.1",
|
||||
"ansi-regex": "^5.0.0",
|
||||
"ansi-styles": "^4.0.0",
|
||||
"react-is": "^17.0.1"
|
||||
}
|
||||
@@ -8885,7 +8885,7 @@
|
||||
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "5.0.1"
|
||||
"ansi-regex": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"strip-json-comments": {
|
||||
|
||||
@@ -1,57 +1,27 @@
|
||||
const { sumTokens2, } = require('./helper/unwrapLPs')
|
||||
const sdk = require('@defillama/sdk')
|
||||
const { createIncrementArray } = require('./helper/utils')
|
||||
const { getLogs } = require('./helper/cache/getLogs')
|
||||
|
||||
const abi = require("./mooniswap/abi.json");
|
||||
const config = require("./1inch/config");
|
||||
|
||||
module.exports = {}
|
||||
const minIndexes = {
|
||||
ethereum: 30,
|
||||
bsc: 136,
|
||||
}
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const { MooniswapFactory, blacklistedTokens } = config[chain]
|
||||
const { blacklistedTokens = [], factories } = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (_, _b, { [chain]: block }) => {
|
||||
const toa = []
|
||||
const pools = []
|
||||
const length = 10
|
||||
let i = minIndexes[chain]
|
||||
|
||||
const { output: data1 } = await sdk.api.abi.multiCall({
|
||||
target: MooniswapFactory,
|
||||
abi: abi.getPool,
|
||||
calls: createIncrementArray(i * length).map(j => ({ params: j})),
|
||||
chain, block,
|
||||
})
|
||||
pools.push(...data1.map(i => i.output))
|
||||
let currentPools
|
||||
do {
|
||||
|
||||
const { output: data } = await sdk.api.abi.multiCall({
|
||||
tvl: async (_, _b, _2, { api }) => {
|
||||
const ownerTokens = []
|
||||
for (const { MooniswapFactory, fromBlock} of factories) {
|
||||
const logs = await getLogs({
|
||||
api,
|
||||
target: MooniswapFactory,
|
||||
abi: abi.getPool,
|
||||
calls: createIncrementArray(length).map(j => ({ params: j + i*length})),
|
||||
chain, block,
|
||||
topic: 'Deployed(address,address,address)',
|
||||
eventAbi: 'event Deployed(address indexed mooniswap, address indexed token1, address indexed token2)',
|
||||
onlyArgs: true,
|
||||
fromBlock,
|
||||
})
|
||||
currentPools = data.map(i => i.output).filter(i => i)
|
||||
pools.push(...currentPools)
|
||||
i++
|
||||
} while(currentPools.length === length)
|
||||
|
||||
const calls = pools.map(i => ({ target: i }))
|
||||
const { output: tokensAll } = await sdk.api.abi.multiCall({
|
||||
abi: abi.getTokens,
|
||||
calls, chain, block,
|
||||
})
|
||||
|
||||
tokensAll.forEach(({ output: tokens, input: { target: pool } }) => {
|
||||
tokens.forEach(i => toa.push([i, pool]))
|
||||
})
|
||||
|
||||
return sumTokens2({ chain, block, tokensAndOwners: toa, blacklistedTokens, })
|
||||
logs.forEach(i => ownerTokens.push([[i.token1, i.token2], i.mooniswap]))
|
||||
}
|
||||
return sumTokens2({ api, ownerTokens, blacklistedTokens, })
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,7 +1 @@
|
||||
const { getExports } = require('../helper/heroku-api')
|
||||
|
||||
module.exports = {
|
||||
timetravel: false,
|
||||
misrepresentedTokens: true,
|
||||
...getExports("1inch", ['bsc', 'ethereum']),
|
||||
}
|
||||
module.exports = require('../1inch.js')
|
||||
@@ -1,53 +1 @@
|
||||
const abi = require("../mooniswap/abi.json");
|
||||
const config = require("./config")
|
||||
const { sumTokens2, } = require('../helper/unwrapLPs')
|
||||
const sdk = require('@defillama/sdk')
|
||||
const { createIncrementArray } = require('../helper/utils')
|
||||
const { getCache, setCache, } = require("../helper/cache");
|
||||
|
||||
const project = 'bulky/1inch'
|
||||
|
||||
module.exports = {}
|
||||
Object.keys(config).forEach(chain => {
|
||||
const { MooniswapFactory, blacklistedTokens } = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (_, _b, { [chain]: block }) => {
|
||||
const cache = await getCache(project, chain) || { pools: {} }
|
||||
if (!cache.pools) cache.pools = {}
|
||||
const toa = []
|
||||
const pools = []
|
||||
const length = 5
|
||||
|
||||
let i = cache.lastI || Math.floor(Object.keys(cache.pools).length / length)
|
||||
let currentPools
|
||||
do {
|
||||
const { output: data } = await sdk.api.abi.multiCall({
|
||||
target: MooniswapFactory,
|
||||
abi: abi.getPool,
|
||||
calls: createIncrementArray(length).map(j => ({ params: j + i * length })),
|
||||
chain, block,
|
||||
})
|
||||
currentPools = data.map(i => i.output).filter(i => i)
|
||||
pools.push(...currentPools)
|
||||
i++
|
||||
} while (currentPools.length === length)
|
||||
|
||||
cache.lastI = i-1
|
||||
const calls = pools.map(i => ({ target: i }))
|
||||
const { output: tokensAll } = await sdk.api.abi.multiCall({
|
||||
abi: abi.getTokens,
|
||||
calls, chain, block,
|
||||
})
|
||||
|
||||
tokensAll.forEach(({ output: tokens, input: { target: pool } }) => {
|
||||
cache.pools[pool.toLowerCase()] = tokens
|
||||
})
|
||||
|
||||
for (const [pool, tokens] of Object.entries(cache.pools))
|
||||
tokens.forEach(i => toa.push([i, pool]))
|
||||
|
||||
await setCache(project, chain, cache)
|
||||
return sumTokens2({ chain, block, tokensAndOwners: toa, blacklistedTokens, })
|
||||
}
|
||||
}
|
||||
})
|
||||
module.exports = require('../1inch.js')
|
||||
@@ -2,11 +2,26 @@ const ADDRESSES = require('../helper/coreAssets.json')
|
||||
|
||||
module.exports = {
|
||||
ethereum: {
|
||||
MooniswapFactory: '0xbaf9a5d4b0052359326a6cdab54babaa3a3a9643',
|
||||
blacklistedTokens: ['0x58730ae0faa10d73b0cddb5e7b87c3594f7a20cb', '0x77777feddddffc19ff86db637967013e6c6a116c',],
|
||||
factories: [{
|
||||
MooniswapFactory: '0xbaf9a5d4b0052359326a6cdab54babaa3a3a9643',
|
||||
fromBlock: 11607841,
|
||||
}]
|
||||
},
|
||||
// polygon: {
|
||||
// factories: [{
|
||||
// MooniswapFactory: '0xbaf9a5d4b0052359326a6cdab54babaa3a3a9643',
|
||||
// fromBlock: 36040621,
|
||||
// }]
|
||||
// },
|
||||
bsc: {
|
||||
MooniswapFactory: '0xd41b24bba51fac0e4827b6f94c0d6ddeb183cd64',
|
||||
factories: [{
|
||||
MooniswapFactory: '0xd41b24bba51fac0e4827b6f94c0d6ddeb183cd64',
|
||||
fromBlock: 4994614,
|
||||
}, {
|
||||
MooniswapFactory: '0xbaf9a5d4b0052359326a6cdab54babaa3a3a9643',
|
||||
fromBlock: 10588911,
|
||||
}],
|
||||
blacklistedTokens: [
|
||||
ADDRESSES.ethereum.DAI,
|
||||
ADDRESSES.ethereum.STETH,
|
||||
|
||||
@@ -8,7 +8,8 @@ const USDC_ADDRESS = ADDRESSES.cronos.USDC;
|
||||
module.exports = {
|
||||
start: 6949784,
|
||||
cronos: {
|
||||
tvl: sumTokensExport({ owner: BOC_TREASURY_ADDRESS, tokens: [CUSD_ADDRESS, USDC_ADDRESS]}),
|
||||
// tvl: sumTokensExport({ owner: BOC_TREASURY_ADDRESS, tokens: [CUSD_ADDRESS, USDC_ADDRESS]}),
|
||||
tvl: () => 0
|
||||
},
|
||||
methodology:
|
||||
"CDP collateral value + treasury mv",
|
||||
|
||||
35
projects/E3/index.js
Normal file
35
projects/E3/index.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
|
||||
const factories = {
|
||||
fantom: '0x8597dB3ba8dE6BAAdEDa8cBa4dAC653E24a0e57B'
|
||||
///zkevm: tbd
|
||||
}
|
||||
async function tvl(_, _b, _cb, { api, }) {
|
||||
const pools = await api.fetchList({
|
||||
target: factories[api.chain],
|
||||
itemAbi: 'function getLBPairAtIndex(uint256) view returns (address)',
|
||||
lengthAbi: 'uint256:getNumberOfLBPairs',
|
||||
})
|
||||
const tokenA = await api.multiCall({
|
||||
abi: 'address:getTokenX',
|
||||
calls: pools,
|
||||
})
|
||||
const tokenB = await api.multiCall({
|
||||
abi: 'address:getTokenY',
|
||||
calls: pools,
|
||||
})
|
||||
const toa = []
|
||||
tokenA.map((_, i) => {
|
||||
toa.push([tokenA[i], pools[i]])
|
||||
toa.push([tokenB[i], pools[i]])
|
||||
})
|
||||
return sumTokens2({ api, tokensAndOwners: toa, })
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
methodology: 'Only the tokens inside our Liquidity Pools are counted in our TVL.',
|
||||
}
|
||||
|
||||
Object.keys(factories).forEach(chain => {
|
||||
module.exports[chain] = { tvl }
|
||||
})
|
||||
20
projects/KyborgExchange/index.js
Normal file
20
projects/KyborgExchange/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { getLogs } = require('../helper/cache/getLogs');
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs');
|
||||
|
||||
const config = {
|
||||
arbitrum: { factory: '0x25620d76654caC426229C85bE8eAEB010Ea25c8F', fromBlock: 89067435 },
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
methodology: `Counts the tokens balances of the KyborgHub contract`,
|
||||
};
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const { factory, fromBlock } = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (_, _b, _cb, { api, }) => {
|
||||
const logs = await getLogs({ api, target: factory, onlyArgs: true, eventAbi: 'event PoolCreated (address indexed token0, address indexed token1, bytes32 indexed poolId)', topics: ['0xec5dc6309c83a50f60f4a1fae9422b2c406da78c579b9b12b92d033db37c7194'], fromBlock, })
|
||||
return sumTokens2({ api, owner: factory, tokens: logs.map(i => [i.token0, i.token1]).flat()})
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -6,6 +6,8 @@ function v3(chain) {
|
||||
let params = v3params
|
||||
if (chain === 'ethereum')
|
||||
params = ['0xbaA999AC55EAce41CcAE355c77809e68Bb345170', undefined, ['0x7B4EB56E7CD4b454BA8ff71E4518426369a138a3']]
|
||||
else if (chain === 'metis')
|
||||
params = ['0x9E7B73ffD9D2026F3ff4212c29E209E09C8A91F5', undefined, ['0x99411FC17Ad1B56f49719E3850B2CDcc0f9bBFd8']]
|
||||
const section = borrowed => aaveChainTvl(chain, ...params, borrowed, true);
|
||||
return {
|
||||
tvl: section(false),
|
||||
@@ -16,7 +18,7 @@ function v3(chain) {
|
||||
module.exports = {
|
||||
methodology: `Counts the tokens locked in the contracts to be used as collateral to borrow or to earn yield. Borrowed coins are not counted towards the TVL, so only the coins actually locked in the contracts are counted. There's multiple reasons behind this but one of the main ones is to avoid inflating the TVL through cycled lending`,
|
||||
avax: v3("avax"),
|
||||
...["optimism", "fantom", "harmony", "arbitrum", "polygon", "ethereum", ].reduce((t, c) => ({ ...t, [c]: v3(c) }), {}),
|
||||
...["optimism", "fantom", "harmony", "arbitrum", "polygon", "ethereum", "metis"].reduce((t, c) => ({ ...t, [c]: v3(c) }), {}),
|
||||
hallmarks: [
|
||||
[1659630089, "Start OP Rewards"],
|
||||
[1650471689, "Start AVAX Rewards"]
|
||||
|
||||
28
projects/affine-defi/index.js
Normal file
28
projects/affine-defi/index.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
|
||||
async function tvl(_, _b, _cb, { api, }) {
|
||||
const vaults = ['0x829363736a5A9080e05549Db6d1271f070a7e224']
|
||||
const tokens = await api.multiCall({ abi: 'address:asset', calls: vaults })
|
||||
const bals = await api.multiCall({ abi: 'uint256:totalAssets', calls: vaults })
|
||||
api.addTokens(tokens, bals)
|
||||
const ownerTokens = [
|
||||
[['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619', '0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6'], '0x1F9b1057cd93fb2d07d18810903B791b56acc2E1']
|
||||
]
|
||||
return sumTokens2({ api, ownerTokens })
|
||||
}
|
||||
|
||||
async function ethTvl(_, _b, _cb, { api, }) {
|
||||
const ethBaskets = [
|
||||
'0x61A18EE9d6d51F838c7e50dFD750629Fd141E944', '0x78Bb94Feab383ccEd39766a7d6CF31dED177Ad0c', '0x72D51B2233c5feA8a702FDd0E51B0adE95638f2c'
|
||||
]
|
||||
const tokens = await api.multiCall({ abi: 'address:asset', calls: ethBaskets })
|
||||
const bals = await api.multiCall({ abi: 'uint256:totalAssets', calls: ethBaskets })
|
||||
api.addTokens(tokens, bals)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
doublecounted: true,
|
||||
methodology: 'Counts the tokens in the Affine baskets',
|
||||
polygon: { tvl },
|
||||
ethereum: { tvl: ethTvl }
|
||||
}
|
||||
35
projects/ajira-pay-finance/index.js
Normal file
35
projects/ajira-pay-finance/index.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const { staking } = require("../helper/staking");
|
||||
|
||||
const AJP_CONTRACT_ADDRESS = "0x9DBC0Ad09184226313FbDe094E7c3DD75c94f997"
|
||||
const KAVA_STAKING_CONTRACT = "0xD1cAf204721A02016993796663EDb00E6Ad9dac4"
|
||||
const BSC_STAKING_CONTRACT = '0xEbD5a0bAED48747ea10feEB61a09a93550Fddcef'
|
||||
|
||||
const ammLpData = {
|
||||
arbitrum: {
|
||||
poolAddress: '0x0C36cB133CFF5D36313eFF3FF1761F9d391DF8Fc',
|
||||
},
|
||||
bsc: {
|
||||
poolAddress: '0x808A234665c7684A5e0Ed5e6BB551dBA1cc9d3e4',
|
||||
},
|
||||
polygon: {
|
||||
poolAddress: '0x2aDA82d11f6bC2bd357E7F3A6674983C372a50A3',
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
methodology: "Ajira Pay Finance TVL Calculations are based on AJP Staking pool and Liquidity pool balances respectively on the AMMs",
|
||||
kava: {
|
||||
staking: staking(KAVA_STAKING_CONTRACT, AJP_CONTRACT_ADDRESS),
|
||||
tvl: () => ({})
|
||||
},
|
||||
bsc: {
|
||||
staking: staking(BSC_STAKING_CONTRACT, AJP_CONTRACT_ADDRESS),
|
||||
tvl: () => ({})
|
||||
},
|
||||
polygon: {
|
||||
tvl: () => ({}),
|
||||
},
|
||||
arbitrum: {
|
||||
tvl: () => ({}),
|
||||
}
|
||||
};
|
||||
@@ -1,8 +1,8 @@
|
||||
const ADDRESSES = require('../helper/coreAssets.json')
|
||||
const sdk = require("@defillama/sdk");
|
||||
const { staking } = require("../helper/staking");
|
||||
const { getConfig } = require("../helper/cache");
|
||||
const { sumTokens2 } = require("../helper/unwrapLPs");
|
||||
const { getUniqueAddresses } = require("../helper/tokenMapping");
|
||||
|
||||
const ANGLE = "0x31429d1856ad1377a8a0079410b297e1a9e214c2";
|
||||
const veANGLE = "0x0C462Dbb9EC8cD1630f1728B2CFD2769d09f0dd5";
|
||||
@@ -36,60 +36,63 @@ async function getVaultManagersFromAPI(chain) {
|
||||
return calls;
|
||||
}
|
||||
|
||||
async function tvl(chain, block) {
|
||||
async function tvl(_, _1, _2, { api }) {
|
||||
const chain = api.chain
|
||||
const balances = {};
|
||||
const tokensAndOwners = [];
|
||||
if (chain === "ethereum") {
|
||||
// Registry will be released in next sdk of Angle + graphql endpoint to come
|
||||
const collaterals = {
|
||||
dai: ADDRESSES.ethereum.DAI,
|
||||
usdc: ADDRESSES.ethereum.USDC,
|
||||
frax: "0x853d955acef822db058eb8505911ed77f175b99e",
|
||||
fei: "0x956F47F50A910163D8BF957Cf5846D573E7f87CA",
|
||||
weth: ADDRESSES.ethereum.WETH,
|
||||
};
|
||||
|
||||
const agEUR = {
|
||||
contract: "0x1a7e4e63778B4f12a199C062f3eFdD288afCBce8",
|
||||
stableMasterFront: "0x5adDc89785D75C86aB939E9e15bfBBb7Fc086A87",
|
||||
poolManagers: {
|
||||
dai: "0xc9daabC677F3d1301006e723bD21C60be57a5915", // DAI
|
||||
usdc: "0xe9f183FC656656f1F17af1F2b0dF79b8fF9ad8eD", // USDC
|
||||
// usdc: "0xe9f183FC656656f1F17af1F2b0dF79b8fF9ad8eD", // USDC disabled because of EULER hack
|
||||
fei: "0x53b981389Cfc5dCDA2DC2e903147B5DD0E985F44", // FEI
|
||||
frax: "0x6b4eE7352406707003bC6f6b96595FD35925af48", // FRAX
|
||||
weth: "0x3f66867b4b6eCeBA0dBb6776be15619F73BC30A2", // WETH
|
||||
},
|
||||
};
|
||||
|
||||
const agTokens = [agEUR];
|
||||
const tokenMapping = {};
|
||||
agTokens.map((t) => {
|
||||
return Object.entries(t.poolManagers).forEach(([key, value]) => {
|
||||
tokenMapping[value] = collaterals[key];
|
||||
});
|
||||
});
|
||||
// count the USDC in pool manager contract
|
||||
tokensAndOwners.push(['0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', '0xe9f183FC656656f1F17af1F2b0dF79b8fF9ad8eD']) // add USDC in USDC manager
|
||||
const poolManagers = getUniqueAddresses([agEUR].map(i => Object.values(i.poolManagers)).flat())
|
||||
|
||||
let { output: assets } = await sdk.api.abi.multiCall({
|
||||
calls: Object.keys(tokenMapping).map((i) => ({ target: i })),
|
||||
let assets = await api.multiCall({
|
||||
calls: poolManagers,
|
||||
abi: poolManagers_abi["getTotalAsset"],
|
||||
chain,
|
||||
block,
|
||||
});
|
||||
let { output: tokens } = await sdk.api.abi.multiCall({
|
||||
calls: Object.keys(tokenMapping).map((i) => ({ target: i })),
|
||||
let tokens = await api.multiCall({
|
||||
calls: poolManagers,
|
||||
abi: poolManagers_abi["token"],
|
||||
chain,
|
||||
block,
|
||||
});
|
||||
|
||||
assets.forEach(({ output }, i) =>
|
||||
sdk.util.sumSingleBalance(balances, tokens[i].output, output)
|
||||
assets.forEach((output, i) =>
|
||||
sdk.util.sumSingleBalance(balances, tokens[i], output)
|
||||
);
|
||||
|
||||
// AMOs
|
||||
const EUROC = "0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c";
|
||||
const curvePool = "0xBa3436Fd341F2C8A928452Db3C5A3670d1d5Cc73";
|
||||
const sdagEUREUROC = "0x63f222079608EEc2DDC7a9acdCD9344a21428Ce7";
|
||||
const cvxagEUREUROCstaker = "0xA91fccC1ec9d4A2271B7A86a7509Ca05057C1A98";
|
||||
const AngleagEUREUROCStaker = "0xC1e8Dba1cbF29f1CaA8343CAe96d5AdFD9bca736";
|
||||
// pool TVL
|
||||
const [agEurBal, eurocBal, totPoolTokenSupply, sdagEUREUROCTVL, cvxagEUREUROCstakerTVL] = await Promise.all([
|
||||
api.call({ abi: 'erc20:balanceOf', target: agEUR.contract, params: curvePool }),
|
||||
api.call({ abi: 'erc20:balanceOf', target: EUROC, params: curvePool }),
|
||||
api.call({ abi: 'erc20:totalSupply', target: curvePool }),
|
||||
// Angle holdings of Curve agEUREUROC LP tokens (staked on Stake DAO and Convex)
|
||||
api.call({ abi: 'erc20:balanceOf', target: sdagEUREUROC, params: AngleagEUREUROCStaker }),
|
||||
api.call({ abi: 'erc20:balanceOf', target: cvxagEUREUROCstaker, params: AngleagEUREUROCStaker }),
|
||||
])
|
||||
const eurocBalance = eurocBal * (+sdagEUREUROCTVL + +cvxagEUREUROCstakerTVL) / totPoolTokenSupply
|
||||
sdk.util.sumSingleBalance(balances, EUROC, eurocBalance);
|
||||
}
|
||||
|
||||
// Borrowing module
|
||||
tokensAndOwners.push(...(await getVaultManagersFromAPI(chain)));
|
||||
return sumTokens2({ balances, chain, block, tokensAndOwners });
|
||||
return sumTokens2({ balances, api, tokensAndOwners });
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -98,16 +101,16 @@ If not, the API call defaults to mainnet and the blockchain calls fail and retur
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
hallmarks: [
|
||||
[Math.floor(new Date('2023-03-13') / 1e3), 'Euler was hacked'],
|
||||
],
|
||||
ethereum: {
|
||||
staking: staking(veANGLE, ANGLE, "ethereum"),
|
||||
},
|
||||
methodology: `TVL is retrieved on-chain by querying the total assets managed by the Core module, and the balances of the vaultManagers of the Borrowing module.`,
|
||||
};
|
||||
|
||||
["ethereum", "polygon", "optimism", "arbitrum", "avax"].forEach(
|
||||
(chain) => {
|
||||
if (!module.exports[chain]) module.exports[chain] = {};
|
||||
module.exports[chain].tvl = async (_, _b, { [chain]: block }) =>
|
||||
tvl(chain, block);
|
||||
}
|
||||
);
|
||||
["ethereum", "polygon", "optimism", "arbitrum", "avax"].forEach((chain) => {
|
||||
if (!module.exports[chain]) module.exports[chain] = {};
|
||||
module.exports[chain].tvl = tvl
|
||||
});
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
const { dexExport } = require('../helper/chain/aptos')
|
||||
const { dexExport: dexExportSUI } = require('../helper/chain/sui')
|
||||
const { mergeExports } = require('../helper/utils')
|
||||
|
||||
module.exports = dexExport({
|
||||
const aptosExports = dexExport({
|
||||
account: '0x796900ebe1a1a54ff9e932f19c548f5c1af5c6e7d34965857ac2f7b1d1ab2cbf',
|
||||
poolStr: 'AnimeSwapPoolV1::LiquidityPool',
|
||||
})
|
||||
|
||||
const suiExprots = dexExportSUI({
|
||||
account: '0xdd7e3a071c6a090a157eccc3c9bbc4d2b3fb5ac9a4687b1c300bf74be6a58945',
|
||||
poolStr: 'animeswap::LiquidityPool',
|
||||
})
|
||||
|
||||
module.exports = mergeExports([suiExprots, aptosExports])
|
||||
|
||||
8
projects/arbitrumexchange-v3/index.js
Normal file
8
projects/arbitrumexchange-v3/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const { uniV3Export } = require("../helper/uniswapV3");
|
||||
|
||||
module.exports = uniV3Export({
|
||||
arbitrum: {
|
||||
factory: "0x855f2c70cf5cb1d56c15ed309a4dfefb88ed909e",
|
||||
fromBlock: 86863305,
|
||||
},
|
||||
});
|
||||
10
projects/archi-finance/abi.json
Normal file
10
projects/archi-finance/abi.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"getTokenPrice": "function getTokenPrice(address _token) view returns (uint256)",
|
||||
"getGlpPrice": "function getGlpPrice(bool _isBuying) view returns (uint256 price)",
|
||||
"borrowedRewardPool": "address:borrowedRewardPool",
|
||||
"supplyRewardPool": "address:supplyRewardPool",
|
||||
"workingBalance": "function workingBalance(address[] _vaults) view returns (address[], uint256[])",
|
||||
"borrowedBalance": "function borrowedBalance(address[] _vaults) view returns (address[], uint256[])",
|
||||
"lockedBalance": "function lockedBalance(address[] _vaults) view returns (address[], uint256[])",
|
||||
"debtBalance": "function debtBalance(address[] _vaults) view returns (address[], uint256[])"
|
||||
}
|
||||
50
projects/archi-finance/index.js
Normal file
50
projects/archi-finance/index.js
Normal file
@@ -0,0 +1,50 @@
|
||||
const { sumTokens2 } = require("../helper/unwrapLPs");
|
||||
const ABI = require("./abi.json");
|
||||
|
||||
const addresses = {
|
||||
vaultInfo: "0x73956FF7375476EBFD5e82d80Ea9065a5bCc3d2b",
|
||||
collateralPoolAddress: "0xbd198617aD1dc75B0f7A0A67BbE31993919Cd716",
|
||||
fsGlpAddress: "0x1addd80e6039594ee970e5872d247bf0414c8903",
|
||||
fsGlpHolders: ["0x65C59eE732BD249224718607Ee0EC0e293309923", "0x49EE14e37Cb47bff8c512B3A0d672302A3446eb1"],
|
||||
vaults: [
|
||||
// weth pool
|
||||
"0x7674Ccf6cAE51F20d376644C42cd69EC7d4324f4",
|
||||
// usdt pool
|
||||
"0x179bD8d1d654DB8aa1603f232E284FF8d53a0688",
|
||||
// usdc pool
|
||||
"0xa7490e0828Ed39DF886b9032ebBF98851193D79c",
|
||||
// wbtc pool
|
||||
"0xee54A31e9759B0F7FDbF48221b72CD9F3aEA00AB",
|
||||
// dai pool
|
||||
"0x4262BA30d5c1bba98e9E9fc3c40602a7E09Ca49F",
|
||||
// link pool
|
||||
"0xB86a783C329d5D0CE84093757586F5Fd5364cd71",
|
||||
// uni pool
|
||||
"0xAf2a336AE86eF90a3958F4bFC6EFc23cD6190951",
|
||||
// frax pool
|
||||
"0x2032998a5312B88f6b4d2b86638Be31B20d1B573",
|
||||
// mim pool
|
||||
"0xbd70E8712264D6A62a7A6BD255A59992068adCAd"
|
||||
]
|
||||
}
|
||||
|
||||
async function tvl(timestamp, block, chainBlocks, { api }) {
|
||||
const tokens = await api.multiCall({ abi: 'address:underlyingToken', calls: addresses.vaults })
|
||||
const tokensAndOwners = tokens.map((v, i) => [v, addresses.vaults[i]])
|
||||
addresses.fsGlpHolders.forEach(i => tokensAndOwners.push([addresses.fsGlpAddress, i]))
|
||||
|
||||
return sumTokens2({ api, tokensAndOwners})
|
||||
}
|
||||
|
||||
async function borrowed(timestamp, block, chainBlocks, { api }) {
|
||||
const borrowedBalance = await api.call({ target: addresses.vaultInfo, abi: ABI.borrowedBalance, params: [addresses.vaults] });
|
||||
api.addTokens(borrowedBalance[0], borrowedBalance[1]);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
methodology: "The TVL (Total Value Locked) of ArchiFinance is calculated by adding the total liquidity and borrowing amount.",
|
||||
arbitrum: {
|
||||
tvl,
|
||||
borrowed,
|
||||
},
|
||||
};
|
||||
5
projects/astarexchangev3/index.js
Normal file
5
projects/astarexchangev3/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const { uniV3Export } = require('../helper/uniswapV3')
|
||||
|
||||
module.exports = uniV3Export({
|
||||
astar: { factory: '0x0bA242809B5b8AC2C362372807bc616fc620DB97', fromBlock: 3333333, },
|
||||
})
|
||||
8
projects/atlas-usv/api.js
Normal file
8
projects/atlas-usv/api.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const index = require('./index')
|
||||
|
||||
module.exports = {
|
||||
polygon: {
|
||||
tvl: () => 0,
|
||||
staking: index.polygon.staking,
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ const chains = {
|
||||
heco: 128,
|
||||
polygon: 137,
|
||||
fantom: 250,
|
||||
zksync: 324,
|
||||
metis: 1088,
|
||||
moonbeam: 1284,
|
||||
moonriver: 1285,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { request, gql } = require("graphql-request");
|
||||
const { toUSDTBalances } = require('../helper/balances');
|
||||
const { sumTokensExport } = require("../helper/unwrapLPs");
|
||||
|
||||
const graphUrl = 'https://api.thegraph.com/subgraphs/name/arrenv/behodler'
|
||||
const graphQuery = gql`
|
||||
@@ -28,9 +29,26 @@ async function tvl(timestamp, block) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
misrepresentedTokens: true,
|
||||
methodology: `ERC20 tokens deposited as liquidity on the AMM. You can see this on https://analytics.behodler.io/#/, pulling the data from the 'arrenv/behodler' subgraph`,
|
||||
ethereum:{
|
||||
tvl,
|
||||
tvl: sumTokensExport({
|
||||
owner: '0x1B8568FbB47708E9E9D31Ff303254f748805bF21',
|
||||
tokens: [
|
||||
'0xaFEf0965576070D1608F374cb14049EefaD218Ec',
|
||||
'0x4f5704D9D2cbCcAf11e70B34048d41A0d572993F',
|
||||
'0x0D8775F648430679A709E98d2b0Cb6250d2887EF',
|
||||
'0x319eAd06eb01E808C80c7eb9bd77C5d8d163AddB',
|
||||
'0xF047ee812b21050186f86106f6cABDfEc35366c6',
|
||||
'0x155ff1A85F440EE0A382eA949f24CE4E0b751c65',
|
||||
'0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2',
|
||||
'0x514910771AF9Ca656af840dff83E8264EcF986CA',
|
||||
'0x4575f41308EC1483f3d399aa9a2826d74Da13Deb',
|
||||
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
||||
'0x93ED3FBe21207Ec2E8f2d3c3de6e058Cb73Bc04d',
|
||||
'0x42476F744292107e34519F9c357927074Ea3F75D',
|
||||
'0x890ff7533Ca0C44F33167FdEEeaB1cA7E690634F',
|
||||
],
|
||||
resolveLP: true,
|
||||
}),
|
||||
},
|
||||
}
|
||||
21
projects/beluga-dex/index.js
Normal file
21
projects/beluga-dex/index.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const { staking } = require("../helper/staking");
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
const asssetsContract = "0xF6Eb0eE167e3b8a43E74999C47720140A9431448"
|
||||
|
||||
async function tvl(timestamp, ethereumBlock, chainBlocks, { api }) {
|
||||
const tokensAndOwners = await api.call({
|
||||
target: asssetsContract,
|
||||
abi: "function getAssets() view returns (address[][])",
|
||||
})
|
||||
return sumTokens2({ api, tokensAndOwners, })
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
arbitrum:{
|
||||
tvl,
|
||||
staking: staking(
|
||||
"0x7fbdEb84D5966c1C325D8CB2E01593D74c9A41Cd", //vetoken
|
||||
"0x09090e22118b375f2c7b95420c04414E4bf68e1A", //bela
|
||||
),
|
||||
},
|
||||
};
|
||||
@@ -1,18 +1,43 @@
|
||||
const { getExports } = require('../helper/heroku-api')
|
||||
const { nullAddress } = require('../helper/unwrapLPs')
|
||||
const BigNumber = require("bignumber.js");
|
||||
|
||||
module.exports = {
|
||||
timetravel: false,
|
||||
...getExports("bifrost-staking", ['bifrost']),
|
||||
bifrost: {
|
||||
tvl: async () => {
|
||||
const { bifrost } = getExports("bifrost-staking", ['bifrost'])
|
||||
const tvl = await bifrost.tvl()
|
||||
return { 'bifrost-native-coin': tvl['bifrost-native-coin'], polkadot: tvl.polkadot, kusama: tvl.kusama }
|
||||
}
|
||||
},
|
||||
ethereum: {
|
||||
tvl: async (_, _1, _2, { api }) => {
|
||||
const vETH = await api.call({ target: '0x4bc3263eb5bb2ef7ad9ab6fb68be80e43b43801f', abi: 'uint256:totalSupply' })
|
||||
const vETH_v1 = await api.call({ target: '0xc3d088842dcf02c13699f936bb83dfbbc6f721ab', abi: 'uint256:totalSupply' })
|
||||
|
||||
return {
|
||||
[nullAddress]: new BigNumber(vETH).plus(vETH_v1).toString(),
|
||||
[nullAddress]: vETH,
|
||||
}
|
||||
}
|
||||
},
|
||||
filecoin: {
|
||||
tvl: async () => {
|
||||
const { bifrost } = getExports("bifrost-staking", ['bifrost'])
|
||||
const { filecoin } = await bifrost.tvl()
|
||||
return { filecoin }
|
||||
}
|
||||
},
|
||||
moonbeam: {
|
||||
tvl: async () => {
|
||||
const { bifrost } = getExports("bifrost-staking", ['bifrost'])
|
||||
const { moonbeam } = await bifrost.tvl()
|
||||
return { moonbeam }
|
||||
}
|
||||
},
|
||||
moonriver: {
|
||||
tvl: async () => {
|
||||
const { bifrost } = getExports("bifrost-staking", ['bifrost'])
|
||||
const { moonriver } = await bifrost.tvl()
|
||||
return { moonriver }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
projects/binance-staked-eth/index.js
Normal file
15
projects/binance-staked-eth/index.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const sdk = require("@defillama/sdk")
|
||||
const token = '0xa2E3356610840701BDf5611a53974510Ae27E2e1'
|
||||
|
||||
module.exports = {
|
||||
ethereum: {
|
||||
tvl: async (_, block) => ({
|
||||
"ethereum:0x0000000000000000000000000000000000000000": (await sdk.api.erc20.totalSupply({ target: token, block})).output
|
||||
})
|
||||
},
|
||||
bsc: {
|
||||
tvl: async (_, block, chainBlocks) => ({
|
||||
"ethereum:0x0000000000000000000000000000000000000000": (await sdk.api.erc20.totalSupply({ target: token, chain:"bsc", block: chainBlocks.bsc})).output
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,11 @@ const assetList = [
|
||||
["BTC", "BTC", "3JFJPpH8Chwo7CDbyYQ4XcfgcjEP1FGRMJ"],
|
||||
["BTC", "BTC", "34HpHYiyQwg69gFmCq2BGHjF1DZnZnBeBP"],
|
||||
["BTC", "BTC", "bc1qm34lsc65zpw79lxes69zkqmk6ee3ewf0j77s3h"],
|
||||
["BTC", "BTC", "38Xnrq8MZiKmYmwobbYdZQ5nnCbX1qvQfE"],
|
||||
["BTC", "BTC", "3EbJfpmFgufYtzW9UFvf1GAfm2ted1Rwnr"],
|
||||
["BTC", "BTC", "38DN2uFMZPiHLHJigfv4kWC9JWJrNnhLcn"],
|
||||
["BTC", "BTC", "3Qxak1CZhLyZ7GVckKphLURdLBCjMfz9bA"],
|
||||
["BTC", "BTC", "36zSLdRv1jyewjaC12fqK5fptn7PqewunL"],
|
||||
["ETH", "ETH", "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8"],
|
||||
["ETH", "ETH", "0xf977814e90da44bfa03b6295a0616a897441acec"],
|
||||
["ETH", "ETH", "0x5a52e96bacdabb82fd05763e25335261b270efcb"],
|
||||
|
||||
15
projects/blazestake/index.js
Normal file
15
projects/blazestake/index.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const { getTokenSupply } = require("../helper/solana")
|
||||
|
||||
async function tvl(_, _1, _2, { api }) {
|
||||
const bSOL = 'bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1'
|
||||
const supply = await getTokenSupply(bSOL)
|
||||
api.add(bSOL, supply * 1e9)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
timetravel: false,
|
||||
methodology: "bSOL total supply as it's equal to the SOL staked",
|
||||
solana: {
|
||||
tvl
|
||||
},
|
||||
};
|
||||
6
projects/blend/index.js
Normal file
6
projects/blend/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const { sumTokensExport } = require('../helper/unwrapLPs')
|
||||
const contract = '0x29469395eaf6f95920e59f858042f0e28d98a20b'
|
||||
|
||||
module.exports = {
|
||||
ethereum: { tvl: sumTokensExport({ owner: contract, resolveNFTs: true, }) }
|
||||
}
|
||||
20
projects/bluemove-dex/index.js
Normal file
20
projects/bluemove-dex/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const { dexExport } = require('../helper/chain/sui')
|
||||
const { mergeExports } = require('../helper/utils')
|
||||
|
||||
module.exports = mergeExports([
|
||||
dexExport({
|
||||
account: '0x3f2d9f724f4a1ce5e71676448dc452be9a6243dac9c5b975a588c8c867066e92',
|
||||
poolStr: '::swap::Pool',
|
||||
token0Reserve: i => i.fields.reserve_x,
|
||||
token1Reserve: i => i.fields.reserve_y,
|
||||
eventType: "0xb24b6789e088b876afabca733bed2299fbc9e2d6369be4d1acfa17d8145454d9::swap::Created_Pool_Event",
|
||||
eventTransform: i => i.pool_id
|
||||
}),
|
||||
dexExport({
|
||||
account: '0x5a7eca40df453efe6bb1feae99e5b8fc072d1252cbd1979eb187d625dc9b47c9',
|
||||
poolStr: 'stable_swap::Stable_Pool',
|
||||
token0Reserve: i => i.fields.token_x,
|
||||
token1Reserve: i => i.fields.token_y,
|
||||
isAMM: false,
|
||||
})
|
||||
])
|
||||
11
projects/blur-lend/index.js
Normal file
11
projects/blur-lend/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const { sumTokensExport } = require('../helper/unwrapLPs')
|
||||
|
||||
const collateralProxy = "0x29469395eAf6f95920E59F858042f0e28D98a20B"
|
||||
|
||||
module.exports = {
|
||||
misrepresentedTokens: true,
|
||||
methodology: 'TVL counts NFTs used as collateral to take out loans',
|
||||
ethereum: {
|
||||
tvl: sumTokensExport({ owners: [collateralProxy], resolveNFTs: true, }),
|
||||
}
|
||||
}
|
||||
22
projects/bubbleswap-v2/index.js
Normal file
22
projects/bubbleswap-v2/index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const { default: axios } = require('axios');
|
||||
|
||||
async function fetch(){
|
||||
|
||||
const response = await axios.get('https://api.bubbleswap.io/v2/backend/api/v1/tvl', {
|
||||
headers: {
|
||||
//I would prefer the user agengt to be set to something like axios, or DefiLlama, but our WAF only allows the bellow
|
||||
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'
|
||||
}
|
||||
})
|
||||
return response.data.data.sumTVL
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetch,
|
||||
timetravel: false,
|
||||
methodology: "Data is retrieved from the api at https://api.bubbleswap.io/",
|
||||
hallmarks: [
|
||||
[1683288000, "V2 Launch"],
|
||||
]
|
||||
}
|
||||
@@ -1,34 +1,9 @@
|
||||
const { default: axios } = require('axios');
|
||||
async function fetch(){
|
||||
|
||||
const response = await axios.get('https://api.bubbleswap.io/analytics/api/v1/analytics/aggregate/liquidity/year', {
|
||||
headers: {
|
||||
//I would prefer the user agengt to be set to something like axios, or DefiLlama, but our WAF only allows the bellow
|
||||
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'
|
||||
}
|
||||
});
|
||||
|
||||
if(!response?.data?.ok
|
||||
|| !response?.data?.data
|
||||
|| !Array.isArray(response?.data?.data)
|
||||
|| !response?.data?.data?.length > 0) {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
const lastItem = response.data.data[response.data.data.length - 1];
|
||||
|
||||
if(isNaN(lastItem[1])){
|
||||
return null;
|
||||
}
|
||||
|
||||
return Number(lastItem[1]);
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
methodology: "Data is retrieved from the api at https://analytics.bubbleswap.io/",
|
||||
timetravel: false,
|
||||
fetch
|
||||
fetch: () => 0,
|
||||
timetravel: false,
|
||||
methodology: "Data is retrieved from the api at https://api.bubbleswap.io",
|
||||
hallmarks: [
|
||||
[1666569600, "Start V1 Rewards"],
|
||||
[1683813600, "V1 Deprecation"],
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
const { getLogs, } = require('../helper/cache/getLogs')
|
||||
const { sumTokens2, nullAddress } = require('../helper/unwrapLPs')
|
||||
const sdk = require('@defillama/sdk')
|
||||
const { getUniqueAddresses } = require('../helper/utils')
|
||||
|
||||
async function tvl(_, _b, _cb, { api, }) {
|
||||
const factory = '0xa964d6e8d90e5cd12592a8ef2b1735dae9ba0840'
|
||||
@@ -7,18 +9,16 @@ async function tvl(_, _b, _cb, { api, }) {
|
||||
api,
|
||||
target: factory,
|
||||
topics: ['0x94e35d08a6788cb2901c35019eb1105f35dcfdac00943412ebe0236470ee420f'],
|
||||
fromBlock: 16480338,
|
||||
fromBlock: 16480338,
|
||||
eventAbi: 'event Create (address indexed nft, address indexed baseToken, bytes32 indexed merkleRoot)',
|
||||
onlyArgs: true,
|
||||
})
|
||||
const calls = logs.map(i => ([i.nft, i.baseToken, i.merkleRoot]))
|
||||
const pools = await api.multiCall({ abi: "function pairs(address, address, bytes32) view returns (address)", calls: calls.map(i => ({ params: i})), target: factory })
|
||||
|
||||
const balances = await sumTokens2({ api, owners: pools, tokens: [nullAddress]})
|
||||
const ethKey = 'ethereum:'+nullAddress
|
||||
const pools = await api.multiCall({ abi: "function pairs(address, address, bytes32) view returns (address)", calls: calls.map(i => ({ params: i })), target: factory })
|
||||
let { output: balances } = await sdk.api.eth.getBalances({ block: _b, targets: getUniqueAddresses(pools) })
|
||||
balances = balances.reduce((agg, i) => agg + i.balance/1e18, 0)
|
||||
return {
|
||||
...balances,
|
||||
[ethKey]: (balances[ethKey] ?? 0) * 2
|
||||
ethereum: balances * 2,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
8
projects/cega/abi.json
Normal file
8
projects/cega/abi.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"sumVaultUnderlyingAmounts": "uint256:sumVaultUnderlyingAmounts",
|
||||
"queuedDepositsTotalAmount": "uint256:queuedDepositsTotalAmount",
|
||||
"getProductNames": "string[]:getProductNames",
|
||||
"products": "function products(string) view returns (address)",
|
||||
"getLOVVaultMetadata": "function getLOVVaultMetadata(address productAddress, uint256 leverage) view returns (tuple(uint256 vaultStart, uint256 tradeDate, uint256 tradeExpiry, uint256 aprBps, uint256 tenorInDays, uint256 underlyingAmount, uint256 currentAssetAmount, uint256 totalCouponPayoff, uint256 vaultFinalPayoff, uint256 queuedWithdrawalsSharesAmount, uint256 queuedWithdrawalsCount, uint256 optionBarriersCount, uint256 leverage, address vaultAddress, uint8 vaultStatus, bool isKnockedIn, tuple(uint256 barrierBps, uint256 barrierAbsoluteValue, uint256 strikeBps, uint256 strikeAbsoluteValue, string asset, string oracleName, uint8 barrierType)[] optionBarriers)[])",
|
||||
"getLOVProductQueuedDeposits": "function getLOVProductQueuedDeposits(address fcnProductAddress, uint256 leverage) view returns (uint256 totalQueuedDeposits)"
|
||||
}
|
||||
83
projects/cega/evm.js
Normal file
83
projects/cega/evm.js
Normal file
@@ -0,0 +1,83 @@
|
||||
const abi = require("./abi.json");
|
||||
|
||||
const maxLeverage = 5;
|
||||
const LOV_SUFFIX = "-lov";
|
||||
const CEGA_STATE = "0x0730AA138062D8Cc54510aa939b533ba7c30f26B";
|
||||
const CEGA_PRODUCT_VIEWER = "0x31C73c07Dbd8d026684950b17dD6131eA9BAf2C4";
|
||||
const usdcAddress = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
|
||||
|
||||
// Funds are not lent out
|
||||
const FCN_PURE_OPTIONS_ADDRESSES = [
|
||||
'0x042021d59731d3fFA908c7c4211177137Ba362Ea', // supercharger
|
||||
'0x56F00A399151EC74cf7bE8DC38225363E84975E6', // go fast
|
||||
'0x784e3C592A6231D92046bd73508B3aAe3A7cc815', // insanic
|
||||
];
|
||||
|
||||
// Funds are lent out 100%
|
||||
const FCN_BOND_AND_OPTIONS_ADDRESSES = [
|
||||
'0xAB8631417271Dbb928169F060880e289877Ff158', // starboard
|
||||
'0xcf81b51AecF6d88dF12Ed492b7b7f95bBc24B8Af', // autopilot
|
||||
'0x80ec1c0da9bfBB8229A1332D40615C5bA2AbbEA8', // cruise control
|
||||
'0x94C5D3C2fE4EF2477E562EEE7CCCF07Ee273B108', // genesis basket
|
||||
];
|
||||
|
||||
async function getProducts(api) {
|
||||
const productNames = await api.call({ target: CEGA_STATE, abi: abi.getProductNames, })
|
||||
const LOVProductNames = productNames.filter(v => v.includes(LOV_SUFFIX))
|
||||
return api.multiCall({ target: CEGA_STATE, abi: abi.products, calls: LOVProductNames })
|
||||
}
|
||||
|
||||
|
||||
async function getSumFCNProductDeposits(fcnProducts, api) {
|
||||
return api.multiCall({ calls: fcnProducts, abi: abi.sumVaultUnderlyingAmounts, })
|
||||
}
|
||||
|
||||
async function getSumFCNProductQueuedDeposits(fcnProducts, api) {
|
||||
return api.multiCall({ calls: fcnProducts, abi: abi.queuedDepositsTotalAmount, })
|
||||
}
|
||||
|
||||
function getLOVCalls(lovProducts) {
|
||||
const calls = []
|
||||
for (const product of lovProducts)
|
||||
for (let i = 2; i < maxLeverage; i++)
|
||||
calls.push([product, i])
|
||||
return calls.map(i => ({ params: i}))
|
||||
}
|
||||
|
||||
async function getSumLOVProductDeposits(lovProducts, api) {
|
||||
const calls = getLOVCalls(lovProducts)
|
||||
return (await api.multiCall({ target: CEGA_PRODUCT_VIEWER, abi: abi.getLOVVaultMetadata, calls })).map(i => i.map(j => j.underlyingAmount)).flat()
|
||||
}
|
||||
|
||||
async function getSumLOVProductQueuedDeposits(lovProducts, api) {
|
||||
const calls = getLOVCalls(lovProducts)
|
||||
return await api.multiCall({ target: CEGA_PRODUCT_VIEWER, abi: abi.getLOVProductQueuedDeposits, calls })
|
||||
}
|
||||
|
||||
async function getEthereumTvl(_, _1, _2, { api }) {
|
||||
const lovProducts = await getProducts(api);
|
||||
const results = await Promise.all([
|
||||
getSumFCNProductDeposits(FCN_PURE_OPTIONS_ADDRESSES, api),
|
||||
getSumFCNProductQueuedDeposits(FCN_PURE_OPTIONS_ADDRESSES, api),
|
||||
getSumLOVProductDeposits(lovProducts, api),
|
||||
getSumLOVProductQueuedDeposits(lovProducts, api)
|
||||
]);
|
||||
const sum = results.flat().flat().reduce((total, currentValue) => total + +currentValue, 0);
|
||||
api.add(usdcAddress, sum)
|
||||
}
|
||||
|
||||
async function getBorrowedTvl(_, _1, _2, { api }) {
|
||||
const results = await Promise.all([
|
||||
getSumFCNProductDeposits(FCN_BOND_AND_OPTIONS_ADDRESSES, api),
|
||||
getSumFCNProductQueuedDeposits(FCN_BOND_AND_OPTIONS_ADDRESSES, api),
|
||||
]);
|
||||
const sum = results.flat().flat().reduce((total, currentValue) => total + +currentValue, 0);
|
||||
api.add(usdcAddress, sum)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ethereum: {
|
||||
tvl: getEthereumTvl,
|
||||
borrowed: getBorrowedTvl,
|
||||
}
|
||||
}
|
||||
@@ -1,68 +1,8 @@
|
||||
const ADDRESSES = require('../helper/coreAssets.json')
|
||||
const { Program } = require("@project-serum/anchor");
|
||||
const { getProvider, sumTokens2, getTokenBalance, } = require("../helper/solana");
|
||||
const sdk = require('@defillama/sdk')
|
||||
const idl = require("./idl.json");
|
||||
const MM_multisigs = [
|
||||
'0xBdaF8c2BAA14f322e1429Ae3869B005590Ea1FF8',
|
||||
'0x0fEcA1Ff36AbA721BAEd6C6248b6745C88AF1dDF',
|
||||
'0x1d14E27221F1b3c690Fc3cced827bEE4892d0698',
|
||||
'0x60daD1DF74F20fd6d6C07e6FC6153078Cd14a57c',
|
||||
'0xC6589ad1eed78c50f28249D743A585f7053e7D2C',
|
||||
]
|
||||
|
||||
const vaultMintAuthority = '4nhbsUdKEwVQXuYDotgdQHoMWW83GvjXENwLsf9QrRJT'
|
||||
const usdcTokenSpl = ADDRESSES.solana.USDC
|
||||
|
||||
async function tvl() {
|
||||
const products = await getProducts()
|
||||
const tokenAccounts = []
|
||||
products.forEach(({ account: i }) => {
|
||||
if (!i.isActive || Buffer.from(i.productName).toString().trim().includes("demo")) return;
|
||||
tokenAccounts.push(i.productUnderlyingTokenAccount.toString())
|
||||
});
|
||||
|
||||
return sumTokens2({ balances: {
|
||||
['solana:'+usdcTokenSpl]: await getMMbalance()
|
||||
}, owner: vaultMintAuthority, tokens: [usdcTokenSpl], tokenAccounts, });
|
||||
}
|
||||
|
||||
async function borrowed() {
|
||||
const products = await getProducts()
|
||||
const balances = {}
|
||||
const usdcBalance = await getTokenBalance(usdcTokenSpl, vaultMintAuthority)
|
||||
sdk.util.sumSingleBalance(balances, usdcTokenSpl, -1 * usdcBalance, 'solana')
|
||||
sdk.util.sumSingleBalance(balances, usdcTokenSpl, -1 * await getMMbalance(), 'solana')
|
||||
products.forEach(({ account: i }) => {
|
||||
if (!i.isActive || Buffer.from(i.productName).toString().trim().includes("demo")) return;
|
||||
sdk.util.sumSingleBalance(balances,i.underlyingMint.toString(),+i.underlyingAmount, 'solana')
|
||||
});
|
||||
return balances
|
||||
}
|
||||
|
||||
async function getProducts() {
|
||||
const provider = getProvider();
|
||||
const programId = "3HUeooitcfKX1TSCx2xEpg2W31n6Qfmizu7nnbaEWYzs";
|
||||
const program = new Program(idl, programId, provider);
|
||||
return program.account.product.all();
|
||||
|
||||
}
|
||||
|
||||
async function getMMbalance() {
|
||||
const { output: bals } = await sdk.api.abi.multiCall({
|
||||
target: ADDRESSES.ethereum.USDC,
|
||||
abi: 'erc20:balanceOf',
|
||||
calls: MM_multisigs.map(i => ({ params: i})),
|
||||
})
|
||||
let total = 0
|
||||
bals.forEach(({ output: i}) => total += +i)
|
||||
return total
|
||||
}
|
||||
const evm = require("./evm");
|
||||
const solana = require("./solana");
|
||||
|
||||
module.exports = {
|
||||
timetravel: false,
|
||||
solana: {
|
||||
tvl,
|
||||
borrowed,
|
||||
},
|
||||
};
|
||||
...evm,
|
||||
...solana,
|
||||
};
|
||||
64
projects/cega/solana.js
Normal file
64
projects/cega/solana.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const { Program } = require("@project-serum/anchor");
|
||||
const { getProvider} = require("../helper/solana");
|
||||
const sdk = require('@defillama/sdk')
|
||||
const idl = require("./idl.json");
|
||||
|
||||
const usdcAddress = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
||||
const PURE_OPTIONS_PRODUCTS = [
|
||||
'insanic-2',
|
||||
'supercharger',
|
||||
'go-fast-2'
|
||||
]
|
||||
|
||||
const OPTIONS_AND_BONDS_PRODUCTS = [
|
||||
'genesis-basket-2',
|
||||
'starboard',
|
||||
'cruise-control-2',
|
||||
'autopilot'
|
||||
]
|
||||
|
||||
async function getProducts() {
|
||||
const provider = getProvider();
|
||||
const programId = "3HUeooitcfKX1TSCx2xEpg2W31n6Qfmizu7nnbaEWYzs";
|
||||
const program = new Program(idl, programId, provider);
|
||||
return program.account.product.all();
|
||||
}
|
||||
|
||||
async function getSolanaTvl() {
|
||||
const balances = {};
|
||||
const products = await getProducts()
|
||||
let totalAmount = 0;
|
||||
products.forEach(({ account: i }) => {
|
||||
const productName = Buffer.from(i.productName).toString().trim();
|
||||
if (!i.isActive || productName.includes("test")) return;
|
||||
const underlyingAmount = i.underlyingAmount.toNumber();
|
||||
if(PURE_OPTIONS_PRODUCTS.includes(productName)){
|
||||
totalAmount += underlyingAmount;
|
||||
}
|
||||
});
|
||||
await sdk.util.sumSingleBalance(balances, usdcAddress, totalAmount, "solana");
|
||||
return balances;
|
||||
}
|
||||
|
||||
async function getBorrowedTvl() {
|
||||
const balances = {};
|
||||
const products = await getProducts()
|
||||
let totalAmount = 0;
|
||||
products.forEach(({ account: i }) => {
|
||||
const productName = Buffer.from(i.productName).toString().trim();
|
||||
if (!i.isActive || productName.includes("test")) return;
|
||||
const underlyingAmount = i.underlyingAmount.toNumber();
|
||||
if(OPTIONS_AND_BONDS_PRODUCTS.includes(productName)){
|
||||
totalAmount += underlyingAmount;
|
||||
}
|
||||
});
|
||||
await sdk.util.sumSingleBalance(balances, usdcAddress, totalAmount, "solana");
|
||||
return balances;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
solana: {
|
||||
tvl: getSolanaTvl,
|
||||
borrowed: getBorrowedTvl,
|
||||
}
|
||||
}
|
||||
14
projects/cells/index.js
Normal file
14
projects/cells/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const { yieldHelper, } = require("../helper/yieldHelper")
|
||||
|
||||
const contract = '0xAcb845A2a46F6De8cbAe8eA234b632a99ef93D31'
|
||||
const cells = '0x3022d80e02075F5A2a442A318229487f9Ea66D82'
|
||||
|
||||
module.exports = yieldHelper({
|
||||
project: 'cells-finance',
|
||||
chain: 'bsc',
|
||||
masterchef: contract,
|
||||
nativeToken: cells,
|
||||
abis: {
|
||||
poolInfo: 'function poolInfo(uint256) view returns (address want, uint256 , uint256 , uint256 , uint256 , uint256 , uint256 , uint256 amount, uint256 , address strat, address )',
|
||||
}
|
||||
})
|
||||
8
projects/cerberusdao/api.js
Normal file
8
projects/cerberusdao/api.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const index = require('./index')
|
||||
|
||||
module.exports = {
|
||||
ethereum: {
|
||||
tvl: () => 0,
|
||||
staking: index.ethereum.staking,
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
const { dexExport, getResources } = require('../helper/chain/aptos')
|
||||
const sui = require('../helper/chain/sui')
|
||||
const { transformDexBalances } = require('../helper/portedTokens')
|
||||
const { PromisePool } = require('@supercharge/promise-pool')
|
||||
const sdk = require('@defillama/sdk')
|
||||
@@ -17,9 +18,9 @@ async function tvl() {
|
||||
async function addPool(poolAddr) {
|
||||
const res = await getResources(poolAddr)
|
||||
const val = res.find(i => i.type.includes('::pool::Pool'))
|
||||
const [token0, token1 ] = val.type.split('::pool::Pool<')[1].replace('>', '').split(', ')
|
||||
const [token0, token1] = val.type.split('::pool::Pool<')[1].replace('>', '').split(', ')
|
||||
data.push({
|
||||
token0,
|
||||
token0,
|
||||
token1,
|
||||
token0Bal: val.data.coin_a.value,
|
||||
token1Bal: val.data.coin_b.value,
|
||||
@@ -27,6 +28,19 @@ async function tvl() {
|
||||
}
|
||||
}
|
||||
|
||||
async function suiTVL() {
|
||||
const { api } = arguments[3]
|
||||
const poolObjectID = '0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0'
|
||||
const { fields: { list: { fields: listObject } } } = await sui.getObject(poolObjectID)
|
||||
const items = (await sui.getDynamicFieldObjects({ parent: listObject.id.id })).map(i => i.fields.value.fields.value)
|
||||
const poolInfo = await sui.getObjects(items.map(i => i.fields.pool_id))
|
||||
poolInfo.forEach(({ type: typeStr, fields }) => {
|
||||
const [coinA, coinB] = typeStr.replace('>', '').split('<')[1].split(', ')
|
||||
api.add(coinA, fields.coin_a)
|
||||
api.add(coinB, fields.coin_b)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = dexExport({
|
||||
account: '0xec42a352cc65eca17a9fa85d0fc602295897ed6b8b8af6a6c79ef490eb8f9eba',
|
||||
poolStr: 'amm_swap::Pool<',
|
||||
@@ -37,5 +51,8 @@ module.exports = dexExport({
|
||||
module.exports = {
|
||||
aptos: {
|
||||
tvl: sdk.util.sumChainTvls([module.exports.aptos.tvl, tvl])
|
||||
},
|
||||
sui: {
|
||||
tvl: suiTVL,
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"nonce":"uint256:nonce",
|
||||
"computeTokenAddress": "function computeTokenAddress(uint256) view returns (address)",
|
||||
"market":"address:market",
|
||||
"baseToken":"address:baseToken",
|
||||
"quoteToken":"address:quoteToken"
|
||||
|
||||
@@ -1,13 +1,42 @@
|
||||
const abi = require("./abi.json");
|
||||
const { ethers } = require("ethers");
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
|
||||
const FACTORY = "0x93A43391978BFC0bc708d5f55b0Abe7A9ede1B91"
|
||||
const contractV1DeployedChainIds = [1, 137, 42161]
|
||||
const contractV1_1DeployedChainIds = [137, 1101, 42161]
|
||||
|
||||
function calculateSalt(chainId, nonce) {
|
||||
return ethers.utils.solidityKeccak256(['uint256', 'uint256'], [chainId, nonce])
|
||||
}
|
||||
|
||||
async function fetchTokenAddressesV1_0(api, chainId){
|
||||
if(!contractV1DeployedChainIds.includes(chainId)){
|
||||
return []
|
||||
}
|
||||
return await api.fetchList({
|
||||
lengthAbi: abi.nonce,
|
||||
itemAbi: "function computeTokenAddress(uint256) view returns (address)",
|
||||
target: "0x93A43391978BFC0bc708d5f55b0Abe7A9ede1B91"
|
||||
})
|
||||
}
|
||||
|
||||
async function fetchTokenAddressesV1_1(api, chainId){
|
||||
if (!contractV1_1DeployedChainIds.includes(chainId)) {
|
||||
return []
|
||||
}
|
||||
const maxNonce = await api.call({ abi: abi.nonce, target: "0x24aC0938C010Fb520F1068e96d78E0458855111D" })
|
||||
return await api.multiCall({
|
||||
abi: "function computeTokenAddress(bytes32) view returns (address)",
|
||||
calls: Array.from({length: maxNonce}, (_, i) => i ).map((i, v) => ({ target: "0x58ed1f4913e652baF17C154551bd8E9dbc73fC56", params: calculateSalt(chainId, v) })),
|
||||
})
|
||||
}
|
||||
|
||||
async function tvl(_, _b, _cb, { api }) {
|
||||
let tokenAddresses = await api.fetchList({ lengthAbi: abi.nonce, itemAbi: abi.computeTokenAddress, target: FACTORY})
|
||||
const chainId = await api.getChainId()
|
||||
let tokenAddresses = [...await fetchTokenAddressesV1_0(api, chainId), ...await fetchTokenAddressesV1_1(api, chainId)]
|
||||
tokenAddresses = tokenAddresses.flat()
|
||||
const markets = await api.multiCall({ abi: abi.market, calls: tokenAddresses })
|
||||
const base = await api.multiCall({ abi: abi.baseToken, calls: markets})
|
||||
const base = await api.multiCall({ abi: abi.baseToken, calls: markets})
|
||||
const quote = await api.multiCall({ abi: abi.quoteToken, calls: markets})
|
||||
const tokens = [base, quote].flat()
|
||||
const symbols = await api.multiCall({ abi: 'erc20:symbol', calls: tokens})
|
||||
@@ -22,5 +51,6 @@ module.exports = {
|
||||
methodology: "TVL consists of assets deposited into market contracts",
|
||||
ethereum: { tvl },
|
||||
polygon: { tvl },
|
||||
arbitrum: { tvl }
|
||||
arbitrum: { tvl },
|
||||
polygon_zkevm: { tvl }
|
||||
}
|
||||
@@ -171,7 +171,7 @@ async function tvl(timestamp, block) {
|
||||
module.exports = {
|
||||
hallmarks: [
|
||||
[1632873600, "Comptroller vulnerability exploit"],
|
||||
[1623715200, "Liquidity mining begins"]
|
||||
[1592226000, "COMP distribution begins"]
|
||||
],
|
||||
timetravel: true,
|
||||
ethereum: {
|
||||
|
||||
25
projects/cozy-v2/index.js
Normal file
25
projects/cozy-v2/index.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const { getLogs, getAddress } = require('../helper/cache/getLogs');
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs');
|
||||
|
||||
const config = {
|
||||
optimism: {factory: '0xdebe19b57e8b7eb6ea6ebea67b12153e011e6447', fromBlock: 96818459,},
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
};
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const {factory, fromBlock} = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (_, _b, _cb, { api, }) => {
|
||||
const logs = await getLogs({
|
||||
api,
|
||||
target: factory,
|
||||
topics: ['0x1bf8fff61a482f21edcb49226d708f5255b3e06bb9c6485892a057058b494790'],
|
||||
fromBlock,
|
||||
})
|
||||
const tokensAndOwners = logs.map(i => [i.topics[1], i.data].map(getAddress))
|
||||
return sumTokens2({ api, tokensAndOwners})
|
||||
}
|
||||
}
|
||||
})
|
||||
10
projects/crETH2/index.js
Normal file
10
projects/crETH2/index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const sdk = require("@defillama/sdk")
|
||||
const token = '0x49d72e3973900a195a155a46441f0c08179fdb64'
|
||||
|
||||
module.exports = {
|
||||
ethereum: {
|
||||
tvl: async (_, block) => ({
|
||||
ethereum: (await sdk.api.erc20.totalSupply({ target: token, block})).output/1e18
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -68,37 +68,18 @@ async function ethereumTvl(timestamp, block) {
|
||||
token: underlyings[idx].output,
|
||||
balance: cashVal.output,
|
||||
});
|
||||
} else if (underlyings[idx].output === crvIB) {
|
||||
return; // https://twitter.com/0xngmi/status/1398565590856515585
|
||||
} else if (underlyings[idx].output === crvIB || underlyings[idx].output === CRETH2) {
|
||||
return; // Exclude CRETH2 //https://twitter.com/0xngmi/status/1398565590856515585
|
||||
} else {
|
||||
const token =
|
||||
replacements[underlyings[idx].output] || underlyings[idx].output;
|
||||
sdk.util.sumSingleBalance(balances, token, cashVal.output);
|
||||
}
|
||||
});
|
||||
|
||||
await unwrapUniswapLPs(balances, lpPositions, block);
|
||||
|
||||
// --- Grab the accumulated on CRETH2 (ETH balance and update proper balances key) ---
|
||||
const accumCRETH2 = (
|
||||
await sdk.api.abi.call({
|
||||
block,
|
||||
target: CRETH2,
|
||||
abi: abiCereth2["accumulated"],
|
||||
})
|
||||
).output;
|
||||
|
||||
/*
|
||||
In theory the ETH deposited in `0xcBc1065255cBc3aB41a6868c22d1f1C573AB89fd` mints CRETH2 which later,
|
||||
but represents the same ETH portion, so we should deduct from the total value given by `accumulated()``
|
||||
the amount of ETH already deployed in the ethereum market place, otherwise it will account a certain %
|
||||
twice. Only certain portion can be considered "idle" in the eth deposit contract to account again as extra
|
||||
eth tvl
|
||||
*/
|
||||
const iddleInETHDepositContract = +accumCRETH2 - +(balances[CRETH2] ?? 0)
|
||||
|
||||
sdk.util.sumSingleBalance(balances, nullAddress, +iddleInETHDepositContract)
|
||||
|
||||
|
||||
|
||||
return balances;
|
||||
}
|
||||
|
||||
|
||||
39
projects/croswap/index.js
Normal file
39
projects/croswap/index.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const { staking } = require("../helper/staking");
|
||||
const { getLogs, getAddress } = require('../helper/cache/getLogs');
|
||||
const { transformDexBalances } = require("../helper/portedTokens");
|
||||
|
||||
module.exports = {
|
||||
misrepresentedTokens: true,
|
||||
}
|
||||
|
||||
async function tvl(_, _b, _cb, { api, }) {
|
||||
const { factory, fromBlock }= config[api.chain]
|
||||
|
||||
const logs = await getLogs({
|
||||
api,
|
||||
target: factory,
|
||||
topics: ['0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9'],
|
||||
fromBlock,
|
||||
})
|
||||
const pools = logs.map(i => getAddress(i.data.slice(0, 64 + 2)))
|
||||
const token0s = await api.multiCall({ abi: 'address:token0', calls: pools})
|
||||
const token1s = await api.multiCall({ abi: 'address:token1', calls: pools})
|
||||
const reserves = await api.multiCall({ abi: 'function getReserves() view returns (uint112, uint112, uint32)', calls: pools})
|
||||
const data = reserves.map(([token0Bal, token1Bal], i) => ({ token0Bal, token1Bal, token1: token1s[i], token0: token0s[i]}))
|
||||
return transformDexBalances({ ...api, data, })
|
||||
}
|
||||
|
||||
const config = {
|
||||
arbitrum: { factory: '0x8f6ecb066f2bfe31bf87e022c76f63bc4642d8bc', fromBlock: 82954506, stakingContracts: ['0x8e9DA87f58A8480dD6b8878Aa37144a5Fb2F122D'], cros: '0x780469101caBD2bFe4B596D98d4777C2a142e012'},
|
||||
cronos: { factory: '0x4ae2bd26e60741890edb9e5c7e984bb396ec26e3', fromBlock: 4807004, stakingContracts: ['0xedfe968033fd2b9a98371d052cd7f32a711e533a'], cros: '0x1Ba477CA252C0FF21c488d41759795E7E7812aB4'},
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
};
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const {stakingContracts, cros,} = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl, staking: staking(stakingContracts, cros)
|
||||
}
|
||||
})
|
||||
38
projects/crv-usd/index.js
Normal file
38
projects/crv-usd/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const { getLogs } = require('../helper/cache/getLogs')
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
|
||||
const config = {
|
||||
ethereum: {
|
||||
pools: [
|
||||
{ factory: '0x818709b85052ddc521fae9c78737b27316337e3a', fromBlock: 17182152 },
|
||||
{ factory: '0x30a2F3c3AA6D12C0a36Bed210dCF1B32EF6228Cc', fromBlock: 17187330 },
|
||||
{ factory: '0xfa3e2db8eb6c646e0d24046c1a185934d41a8f7a', fromBlock: 17187330 },
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
};
|
||||
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const { pools} = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (_, _b, _cb, { api, }) => {
|
||||
const logs = await Promise.all(pools.map(getLogs_))
|
||||
|
||||
return sumTokens2({ api, tokensAndOwners: logs.flat().map(i => [i.collateral, i.amm]) })
|
||||
|
||||
async function getLogs_({ factory, fromBlock }) {
|
||||
return getLogs({
|
||||
api,
|
||||
target: factory,
|
||||
topics: ['0xebbe0dfde9dde641808b7a803882653420f3a5b12bb405d238faed959e1e3aa3'],
|
||||
eventAbi: 'event AddMarket (address indexed collateral, address controller, address amm, address monetary_policy, uint256 ix)',
|
||||
onlyArgs: true,
|
||||
fromBlock,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -8,6 +8,8 @@ const sdk = require("@defillama/sdk");
|
||||
const abi = require("./abi.json");
|
||||
const erc20Abi = require("../helper/abis/erc20.json");
|
||||
const contracts = require("./contracts.json");
|
||||
const { getLogs } = require('../helper/cache/getLogs')
|
||||
|
||||
const chains = [
|
||||
"ethereum", //-200M
|
||||
"polygon", //-40M
|
||||
@@ -37,6 +39,7 @@ async function getDecimals(chain, token) {
|
||||
return decimalsCache[key]
|
||||
}
|
||||
|
||||
|
||||
const gasTokens = [
|
||||
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
||||
ADDRESSES.null,
|
||||
@@ -62,7 +65,7 @@ async function getNames(chain, tokens) {
|
||||
res.forEach((name, i) => {
|
||||
const key = chain + '-' + missing[i]
|
||||
nameCache[key] = name ?? ''
|
||||
mapping[missing[i]] = nameCache[key]
|
||||
mapping[missing[i]] = nameCache[key]
|
||||
})
|
||||
|
||||
return mapping
|
||||
@@ -71,7 +74,7 @@ async function getNames(chain, tokens) {
|
||||
const registryIdsReverse = Object.fromEntries(Object.entries(registryIds).map(i => i.reverse()))
|
||||
|
||||
async function getPool({ chain, block, registry }) {
|
||||
const data = await sdk.api2.abi.fetchList({ chain, block, target: registry, itemAbi: abi.pool_list, lengthAbi: abi.pool_count, withMetadata: true, })
|
||||
const data = await sdk.api2.abi.fetchList({ chain, block, target: registry, itemAbi: abi.pool_list, lengthAbi: abi.pool_count, withMetadata: true, })
|
||||
return data.filter(i => i.output)
|
||||
}
|
||||
|
||||
@@ -157,7 +160,7 @@ async function unwrapPools({ poolList, registry, chain, block }) {
|
||||
let calls = aggregateBalanceCalls({ coins, nCoins, wrapped });
|
||||
const allTokens = getUniqueAddresses(calls.map(i => i[0]))
|
||||
const tokenNames = await getNames(chain, allTokens)
|
||||
const blacklistedTokens = [...blacklist, ...(Object.values(metapoolBases))]
|
||||
const blacklistedTokens = [...blacklist, ...(Object.values(metapoolBases))]
|
||||
Object.entries(tokenNames).forEach(([token, name]) => {
|
||||
if ((name ?? '').startsWith('Curve.fi ')) {
|
||||
sdk.log(chain, 'blacklisting', name)
|
||||
@@ -168,11 +171,40 @@ async function unwrapPools({ poolList, registry, chain, block }) {
|
||||
}
|
||||
|
||||
const blacklists = {
|
||||
ethereum: [ '0x6b8734ad31d42f5c05a86594314837c416ada984', ],
|
||||
ethereum: ['0x6b8734ad31d42f5c05a86594314837c416ada984', '0x95ECDC6caAf7E4805FCeF2679A92338351D24297', '0x5aa00dce91409b58b6a1338639b9daa63eb22be7', '0xEf1385D2b5dc6D14d5fecB86D53CdBefeCA20fcC'],
|
||||
}
|
||||
|
||||
const config = {
|
||||
ethereum: {
|
||||
plainFactoryConfig: [
|
||||
{ plainFactory: '0x528baca578523855a64ee9c276826f934c86a54c', fromBlock: 17182168 },
|
||||
{ plainFactory: '0x0145fd99f1dd6e2491e44fca608c481c9c5b97a9', fromBlock: 17182168 },
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
async function addPlainFactoryConfig({ api, tokensAndOwners, plainFactoryConfig = [] }) {
|
||||
return Promise.all(plainFactoryConfig.map(async ({ plainFactory, fromBlock }) => {
|
||||
const logs = await getLogs({
|
||||
api,
|
||||
target: plainFactory,
|
||||
topics: ['0xb8f6972d6e56d21c47621efd7f02fe68f07a17c999c42245b3abd300f34d61eb'],
|
||||
eventAbi: 'event PlainPoolDeployed(address[4] coins, uint256 A, uint256 fee, address deployer, address pool)',
|
||||
onlyArgs: true,
|
||||
fromBlock,
|
||||
})
|
||||
logs.forEach(log => {
|
||||
log.coins.forEach((coin, i) => {
|
||||
if (i > 1 && coin === nullAddress) return;
|
||||
tokensAndOwners.push([coin, log.pool])
|
||||
})
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
function tvl(chain) {
|
||||
return async (_t, _e, { [chain]: block }) => {
|
||||
const { plainFactoryConfig = [] } = config[chain] ?? {}
|
||||
return async (_t, _e, { [chain]: block }, { api }) => {
|
||||
let balances = {};
|
||||
const transform = await getChainTransform(chain);
|
||||
const poolLists = await getPools(block, chain);
|
||||
@@ -186,7 +218,8 @@ function tvl(chain) {
|
||||
const blacklistedTokens = res.map(i => i.blacklistedTokens).flat()
|
||||
if (blacklists[chain])
|
||||
blacklistedTokens.push(...blacklists[chain])
|
||||
await sumTokens2({ balances, chain, block, tokensAndOwners, transformAddress: transform, blacklistedTokens })
|
||||
await addPlainFactoryConfig({ api, tokensAndOwners, plainFactoryConfig })
|
||||
await sumTokens2({ balances, chain, block, tokensAndOwners, transformAddress: transform, blacklistedTokens })
|
||||
await handleUnlistedFxTokens(balances, chain);
|
||||
return balances;
|
||||
};
|
||||
|
||||
92
projects/debtdao/index.js
Normal file
92
projects/debtdao/index.js
Normal file
@@ -0,0 +1,92 @@
|
||||
const { getLogs } = require('../helper/cache/getLogs')
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
|
||||
const config = {
|
||||
ethereum: {
|
||||
moduleFactory: '0x00A3699F677C252CA32B887F9f66621920D392f8',
|
||||
moduleFactoryStart: 16970379,
|
||||
lineFactory: '0xc9ef6509a09b92043cedce689dfaa760048abd7f',
|
||||
lineFactoryStart: 16970396,
|
||||
},
|
||||
// xdai: {
|
||||
// moduleFactory: '0x00A3699F677C252CA32B887F9f66621920D392f8',
|
||||
// moduleFactoryStart: 27253390,
|
||||
// lineFactory: '0xc9ef6509a09b92043cedce689dfaa760048abd7f',
|
||||
// lineFactoryStart: 27253485,
|
||||
// },
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
};
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const { moduleFactory, moduleFactoryStart, lineFactory, lineFactoryStart, } = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (_, _b, _cb, { api, }) => {
|
||||
const ownerTokens = []
|
||||
const escrowLogs = await getLogs({
|
||||
api,
|
||||
target: moduleFactory,
|
||||
topics: ['0x795112e1546f70e94f47252ccd7189f90d711b2e6557885dc3def7b589c7f7ac'],
|
||||
eventAbi: 'event DeployedEscrow (address indexed deployedAt, uint32 indexed minCRatio, address indexed oracle, address owner)',
|
||||
onlyArgs: true,
|
||||
fromBlock: moduleFactoryStart,
|
||||
})
|
||||
const lineLogs = await getLogs({
|
||||
api,
|
||||
target: lineFactory,
|
||||
topics: ['0xc043ebb31424e42a4ec1454f0de8a7ab9ba0443b8b556c538484c873ae8e64b5'],
|
||||
eventAbi: 'event DeployedSecuredLine (address indexed deployedAt, address indexed escrow, address indexed spigot, address swapTarget, uint8 revenueSplit)',
|
||||
onlyArgs: true,
|
||||
fromBlock: lineFactoryStart,
|
||||
})
|
||||
|
||||
await Promise.all(escrowLogs.map(async (log) => {
|
||||
const escrow = log.deployedAt
|
||||
const tokenLogs = await getLogs({
|
||||
api,
|
||||
target: escrow,
|
||||
topic: 'EnableCollateral(address)',
|
||||
eventAbi: 'event EnableCollateral(address indexed token)',
|
||||
onlyArgs: true,
|
||||
fromBlock: moduleFactoryStart,
|
||||
})
|
||||
ownerTokens.push([tokenLogs.map(i => i.token), escrow])
|
||||
}))
|
||||
await Promise.all(lineLogs.map(async (log) => {
|
||||
const target = log.deployedAt
|
||||
const counts = await api.call({ abi: "function counts() view returns (uint256, uint256)", target })
|
||||
const calls = []
|
||||
for (let i = 0; i < counts[0]; i++) calls.push(i)
|
||||
const proposals = await api.multiCall({ abi: "function ids(uint256) view returns (bytes32)", calls, target })
|
||||
const credits = await api.multiCall({ abi: "function credits(bytes32) view returns (uint256 deposit, uint256 principal, uint256 interestAccrued, uint256 interestRepaid, uint8 decimals, address token, address lender, bool isOpen)", calls: proposals, target })
|
||||
ownerTokens.push([credits.map(i => i.token), target])
|
||||
}))
|
||||
return sumTokens2({ api, ownerTokens })
|
||||
},
|
||||
borrowed: async (_, _b, _cb, { api, }) => {
|
||||
const lineLogs = await getLogs({
|
||||
api,
|
||||
target: lineFactory,
|
||||
topics: ['0xc043ebb31424e42a4ec1454f0de8a7ab9ba0443b8b556c538484c873ae8e64b5'],
|
||||
eventAbi: 'event DeployedSecuredLine (address indexed deployedAt, address indexed escrow, address indexed spigot, address swapTarget, uint8 revenueSplit)',
|
||||
onlyArgs: true,
|
||||
fromBlock: lineFactoryStart,
|
||||
})
|
||||
|
||||
await Promise.all(lineLogs.map(async (log) => {
|
||||
const target = log.deployedAt
|
||||
const counts = await api.call({ abi: "function counts() view returns (uint256, uint256)", target })
|
||||
const calls = []
|
||||
for (let i = 0; i < counts[0]; i++) calls.push(i)
|
||||
const proposals = await api.multiCall({ abi: "function ids(uint256) view returns (bytes32)", calls, target })
|
||||
const credits = await api.multiCall({ abi: "function credits(bytes32) view returns (uint256 deposit, uint256 principal, uint256 interestAccrued, uint256 interestRepaid, uint8 decimals, address token, address lender, bool isOpen)", calls: proposals, target })
|
||||
credits.map(i => {
|
||||
api.add(i.token, i.principal)
|
||||
// api.add(i.token, i.interestAccrued)
|
||||
// api.add(i.token, i.interestRepaid * -1)
|
||||
})
|
||||
}))
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,7 +1,7 @@
|
||||
const sdk = require("@defillama/sdk");
|
||||
|
||||
const DCBToken = "0xEAc9873291dDAcA754EA5642114151f3035c67A2";
|
||||
const stakingPool = "0x22B551fE288c93A3Ac9172aD998A1D9ce1A882e5";
|
||||
const stakingPool = "0xD1748192aE1dB982be2FB8C3e6d893C75330884a";
|
||||
|
||||
async function staking (timestamp, block, chainBlocks) {
|
||||
let balances = {};
|
||||
@@ -24,4 +24,4 @@ module.exports = {
|
||||
staking
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
7
projects/direct-exchange/index.js
Normal file
7
projects/direct-exchange/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const { getUniTVL } = require('../helper/unknownTokens')
|
||||
module.exports = {
|
||||
misrepresentedTokens: true,
|
||||
kava: {
|
||||
tvl: getUniTVL({ factory: '0xcE08c3d20Ff00a9Cf0D28922768bD606592B5D4C', fetchBalances: true, useDefaultCoreAssets: true, })
|
||||
},
|
||||
}
|
||||
5
projects/djed-alliance/abi.json
Normal file
5
projects/djed-alliance/abi.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"Djed": {
|
||||
"reserve": "function R(uint256 cpa) view returns (uint256 balance)"
|
||||
}
|
||||
}
|
||||
10
projects/djed-alliance/config.json
Normal file
10
projects/djed-alliance/config.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"djedAddress": {
|
||||
"milkomeda": "0x67A30B399F5Ed499C1a6Bc0358FA6e42Ea4BCe76",
|
||||
"milkomeda_a1": "0x..."
|
||||
},
|
||||
"reserveTokenAddress": {
|
||||
"milkomeda": "0xAE83571000aF4499798d1e3b0fA0070EB3A3E3F9",
|
||||
"milkomeda_a1": "0x..."
|
||||
}
|
||||
}
|
||||
37
projects/djed-alliance/index.js
Normal file
37
projects/djed-alliance/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const sdk = require('@defillama/sdk');
|
||||
const utils = require('../helper/utils');
|
||||
const { sumTokensExport } = require("../helper/chain/cardano");
|
||||
const { transformBalances } = require('../helper/portedTokens');
|
||||
|
||||
const abi = require('./abi.json');
|
||||
const config = require("./config.json");
|
||||
|
||||
async function tvl(chain, chainBlocks) {
|
||||
const balances = {};
|
||||
|
||||
const reserve = (await sdk.api.abi.call({
|
||||
abi: abi.Djed.reserve, chain: chain, target: config.djedAddress[chain], params: [ 0 ], block: chainBlocks[chain],
|
||||
})).output;
|
||||
|
||||
sdk.util.sumSingleBalance(balances, config.reserveTokenAddress[chain], reserve); // Using WADA address instead of mADA
|
||||
return transformBalances(chain, balances);
|
||||
}
|
||||
|
||||
async function ergotvl() {
|
||||
const {data: { confirmed }} = await utils.fetchURL('https://api.ergoplatform.com/api/v1/addresses/MUbV38YgqHy7XbsoXWF5z7EZm524Ybdwe5p9WDrbhruZRtehkRPT92imXer2eTkjwPDfboa1pR3zb3deVKVq3H7Xt98qcTqLuSBSbHb7izzo5jphEpcnqyKJ2xhmpNPVvmtbdJNdvdopPrHHDBbAGGeW7XYTQwEeoRfosXzcDtiGgw97b2aqjTsNFmZk7khBEQywjYfmoDc9nUCJMZ3vbSspnYo3LarLe55mh2Np8MNJqUN9APA6XkhZCrTTDRZb1B4krgFY1sVMswg2ceqguZRvC9pqt3tUUxmSnB24N6dowfVJKhLXwHPbrkHViBv1AKAJTmEaQW2DN1fRmD9ypXxZk8GXmYtxTtrj3BiunQ4qzUCu1eGzxSREjpkFSi2ATLSSDqUwxtRz639sHM6Lav4axoJNPCHbY8pvuBKUxgnGRex8LEGM8DeEJwaJCaoy8dBw9Lz49nq5mSsXLeoC4xpTUmp47Bh7GAZtwkaNreCu74m9rcZ8Di4w1cmdsiK1NWuDh9pJ2Bv7u3EfcurHFVqCkT3P86JUbKnXeNxCypfrWsFuYNKYqmjsix82g9vWcGMmAcu5nagxD4iET86iE2tMMfZZ5vqZNvntQswJyQqv2Wc6MTh4jQx1q2qJZCQe4QdEK63meTGbZNNKMctHQbp3gRkZYNrBtxQyVtNLR8xEY8zGp85GeQKbb37vqLXxRpGiigAdMe3XZA4hhYPmAAU5hpSMYaRAjtvvMT3bNiHRACGrfjvSsEG9G2zY5in2YWz5X9zXQLGTYRsQ4uNFkYoQRCBdjNxGv6R58Xq74zCgt19TxYZ87gPWxkXpWwTaHogG1eps8WXt8QzwJ9rVx6Vu9a5GjtcGsQxHovWmYixgBU8X9fPNJ9UQhYyAWbjtRSuVBtDAmoV1gCBEPwnYVP5GCGhCocbwoYhZkZjFZy6ws4uxVLid3FxuvhWvQrVEDYp7WRvGXbNdCbcSXnbeTrPMey1WPaXX/balance/total');
|
||||
return { ergo: confirmed.nanoErgs / 1e9 };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
methodology: 'The TVL of each Djed deployment is the reserve belonging to the deployment. The TVL within a given blockchain is the sum of the TVLs of all known Djed deployments within that blockchain. The total TVL is the sum of the Djed TVLs on all blockchains.',
|
||||
ergo:{
|
||||
tvl: ergotvl
|
||||
},
|
||||
cardano: {
|
||||
tvl: sumTokensExport({ owner: 'addr1z9s3v9vyyctzr4xagvrayw87yvzre6qcq7qw2uvqfznf92qm5kjdmrpmng059yellupyvwgay2v0lz6663swmds7hp0q2jjlf4', tokens: ['lovelace']}),
|
||||
},
|
||||
milkomeda: {
|
||||
start: 10440400,
|
||||
tvl: (timestamp, block, chainBlocks) => tvl('milkomeda', chainBlocks)
|
||||
},
|
||||
};
|
||||
@@ -1,92 +1,33 @@
|
||||
const sdk = require("@defillama/sdk")
|
||||
const { post } = require('../helper/http')
|
||||
const { toUSDTBalances } = require('../helper/balances')
|
||||
const { sumTokens } = require("../helper/unwrapLPs")
|
||||
const { getChainTransform, getFixBalances } = require("../helper/portedTokens")
|
||||
const { sumTokens2 } = require("../helper/unwrapLPs")
|
||||
const abi = require("../mooniswap/abi.json")
|
||||
|
||||
const query = factory => `query emiswapFactories { emiswapFactories(where: {id: "${factory}"}) { id totalLiquidityUSD }}`
|
||||
const { staking } = require('../helper/staking')
|
||||
|
||||
const chainConfig = {
|
||||
ethereum: {
|
||||
factory: '0x1771dff85160768255F0a44D20965665806cBf48',
|
||||
url: 'https://api.thegraph.com/subgraphs/name/lombardi22/emiswap8'
|
||||
},
|
||||
kcc: {
|
||||
factory: '0x945316F2964ef5C6C84921b435a528DD1790E93a',
|
||||
url: 'https://thegraph.kcc.network/subgraphs/name/emiswap/emiswap1'
|
||||
},
|
||||
polygon: {
|
||||
factory: '0x23c1b313152e276e0CF61665dc3AC160b3c5aB19',
|
||||
url: 'https://api.thegraph.com/subgraphs/name/lombardi22/polygon',
|
||||
},
|
||||
shiden: {
|
||||
factory: '0x7449314B698f918E98c76279B5570613b243eECf',
|
||||
url: 'https://shiden-graph.emiswap.com/subgraphs/name/shiden',
|
||||
},
|
||||
avax: {
|
||||
factory: '0xaD6b9b31832A88Bb59dB4ACD820F8df2CfA84f0f',
|
||||
},
|
||||
astar: {
|
||||
factory: '0xb4BcA5955F26d2fA6B57842655d7aCf2380Ac854',
|
||||
},
|
||||
aurora: {
|
||||
factory: '0x979e5d41595263f6Dfec4F4D48419C555B80D95c',
|
||||
url: 'https://api.thegraph.com/subgraphs/name/lombardi22/aurora',
|
||||
},
|
||||
ethereum: { factory: '0x1771dff85160768255F0a44D20965665806cBf48', },
|
||||
kcc: { factory: '0x945316F2964ef5C6C84921b435a528DD1790E93a', },
|
||||
polygon: { factory: '0x23c1b313152e276e0CF61665dc3AC160b3c5aB19', },
|
||||
shiden: { factory: '0x7449314B698f918E98c76279B5570613b243eECf', },
|
||||
avax: { factory: '0xaD6b9b31832A88Bb59dB4ACD820F8df2CfA84f0f', },
|
||||
astar: { factory: '0xb4BcA5955F26d2fA6B57842655d7aCf2380Ac854', },
|
||||
aurora: { factory: '0x979e5d41595263f6Dfec4F4D48419C555B80D95c', },
|
||||
}
|
||||
|
||||
|
||||
const moduleExports = {}
|
||||
|
||||
Object.keys(chainConfig).forEach(chain => {
|
||||
const { factory, url } = chainConfig[chain]
|
||||
async function tvl() {
|
||||
const body = { query: query(factory), operationName: "emiswapFactories", variables: {} }
|
||||
const response = await post(url, body)
|
||||
return toUSDTBalances(response.data.emiswapFactories[0].totalLiquidityUSD)
|
||||
}
|
||||
|
||||
async function computeTvl(ts, _block, chainBlocks) {
|
||||
const balances = {}
|
||||
const block = chainBlocks[chain]
|
||||
const transformAddress = await getChainTransform(chain)
|
||||
const fixBalances = await getFixBalances(chain)
|
||||
|
||||
const getAllpools = (await sdk.api.abi.call({ abi: abi.getAllPools, target: factory, block, chain, })).output
|
||||
const getTokens = (await sdk.api.abi.multiCall({ abi: abi.getTokens, calls: getAllpools.map(pool => ({ target: pool })), block, chain, })).output
|
||||
const tokensAndOwners = []
|
||||
getTokens.forEach(({ output: tokens }, i) => {
|
||||
const owner = getAllpools[i]
|
||||
tokens.forEach(token => tokensAndOwners.push([token, owner]))
|
||||
})
|
||||
|
||||
await sumTokens(balances, tokensAndOwners, block, chain, transformAddress)
|
||||
fixBalances(balances)
|
||||
return balances
|
||||
}
|
||||
|
||||
moduleExports[chain] = { tvl: url ? tvl : computeTvl }
|
||||
})
|
||||
const eswToken = "0x5a75a093747b72a0e14056352751edf03518031d";
|
||||
const stakingPool = "0xe094E3E16e813a40E2d6cC4b89bfeAe0142044e1";
|
||||
|
||||
async function ethStaking(timestamp, block) {
|
||||
let balances = {};
|
||||
|
||||
let { output: balance } = await sdk.api.erc20.balanceOf({
|
||||
target: eswToken,
|
||||
owner: stakingPool,
|
||||
block,
|
||||
});
|
||||
sdk.util.sumSingleBalance(balances, eswToken, balance);
|
||||
|
||||
return balances;
|
||||
}
|
||||
|
||||
moduleExports.ethereum.staking = ethStaking
|
||||
|
||||
module.exports = {
|
||||
methodology: "ETH and KCC TVL are the total liquidity from the LPs according to the subgraph. Staking TVL would be ESW value in the staking pool.",
|
||||
...moduleExports
|
||||
};
|
||||
};
|
||||
|
||||
Object.keys(chainConfig).forEach(chain => {
|
||||
const { factory } = chainConfig[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (_, _b, _cb, { api, }) => {
|
||||
const pools = await api.call({ target: factory, abi: abi.getAllPools, })
|
||||
const tokens = await api.multiCall({ calls: pools, abi: abi.getTokens, })
|
||||
return sumTokens2({ api, ownerTokens: pools.map((v, i) => [tokens[i], v]) })
|
||||
}
|
||||
}
|
||||
})
|
||||
module.exports.ethereum.staking = staking(stakingPool, eswToken)
|
||||
14
projects/entities/mt-gox.js
Normal file
14
projects/entities/mt-gox.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const { cexExports } = require('../helper/cex')
|
||||
|
||||
const config = {
|
||||
bitcoin: {
|
||||
owners: [
|
||||
"bc1qa5wkgaew2dkv56kfvj49j0av5nml45x9ek9hz6", //https://www.reddit.com/r/CryptoCurrency/comments/li1fw7/btc_silkroad_stash_seized_nov_2020_by_the_feds/
|
||||
'bc1qmxjefnuy06v345v6vhwpwt05dztztmx4g3y7wp',
|
||||
'bc1qf2yvj48mzkj7uf8lc2a9sa7w983qe256l5c8fs',
|
||||
'bc1qe7nk2nlnjewghgw4sgm0r89zkjzsurda7z4rdg'
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = cexExports(config)
|
||||
@@ -3,7 +3,7 @@ const {toUSDTBalances} = require('./helper/balances')
|
||||
|
||||
async function tvl() {
|
||||
var totalTvl = await utils.fetchURL('https://api.spectrum.fi/v1/amm/platform/stats');
|
||||
return toUSDTBalances(totalTvl.data.tvl.value/100);
|
||||
return toUSDTBalances(totalTvl.data.tvl.value);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
@@ -13,4 +13,4 @@ module.exports = {
|
||||
tvl
|
||||
},
|
||||
methodology: `Spectrum Finance TVL is achieved by making a call to its API: https://api.spectrum.fi/v1/amm/platform/stats.`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ const { queryContract } = require("../helper/chain/terra");
|
||||
const {
|
||||
queryContract: queryContractCosmos,
|
||||
getBalance,
|
||||
getBalance2,
|
||||
} = require("../helper/chain/cosmos");
|
||||
|
||||
// For testing run
|
||||
@@ -55,19 +56,31 @@ const config = {
|
||||
coinGeckoId: "juno-network",
|
||||
hub: "juno17cya4sw72h4886zsm2lk3udxaw5m8ssgpsl6nd6xl6a4ukepdgkqeuv99x",
|
||||
},
|
||||
migaloo: {
|
||||
coinGeckoId: "white-whale",
|
||||
hub: "migaloo1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshqdky4",
|
||||
voteEscrow:
|
||||
"migaloo1hntfu45etpkdf8prq6p6la9tsnk3u3muf5378kds73c7xd4qdzysuv567q",
|
||||
ampToken:
|
||||
"factory/migaloo1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshqdky4/ampWHALE",
|
||||
},
|
||||
};
|
||||
|
||||
async function tvlHub(chain) {
|
||||
let chainConfig = config[chain];
|
||||
let coinGeckoId = chainConfig.coinGeckoId;
|
||||
|
||||
const res = await queryContractCosmos({
|
||||
contract: chainConfig.hub,
|
||||
async function getState(chain, contract) {
|
||||
return queryContractCosmos({
|
||||
contract,
|
||||
chain,
|
||||
data: { state: {} },
|
||||
});
|
||||
}
|
||||
|
||||
let tvl = +(res.tvl_uluna ?? res.tvl_utoken ?? 0) / 1e6;
|
||||
async function tvlHub(chain, state) {
|
||||
let chainConfig = config[chain];
|
||||
let coinGeckoId = chainConfig.coinGeckoId;
|
||||
|
||||
state ||= await getState(chain, chainConfig.hub);
|
||||
|
||||
let tvl = +(state.tvl_uluna ?? state.tvl_utoken ?? 0) / 1e6;
|
||||
return {
|
||||
[coinGeckoId]: tvl,
|
||||
};
|
||||
@@ -77,11 +90,7 @@ async function tvlArbVault(chain) {
|
||||
let chainConfig = config[chain];
|
||||
let coinGeckoId = chainConfig.coinGeckoId;
|
||||
|
||||
const res = await queryContractCosmos({
|
||||
contract: chainConfig.arbVault,
|
||||
chain,
|
||||
data: { state: {} },
|
||||
});
|
||||
const res = await getState(chain, chainConfig.arbVault);
|
||||
|
||||
let tvl = +(res.balances.tvl_utoken ?? 0) / 1e6;
|
||||
return {
|
||||
@@ -89,20 +98,40 @@ async function tvlArbVault(chain) {
|
||||
};
|
||||
}
|
||||
|
||||
async function tvlAmpGovernance(chain) {
|
||||
async function tvlAmpGovernance(chain, state) {
|
||||
let chainConfig = config[chain];
|
||||
let coinGeckoId = chainConfig.coinGeckoIdAmp;
|
||||
|
||||
const res = await getBalance({
|
||||
owner: chainConfig.voteEscrow,
|
||||
token: chainConfig.ampToken,
|
||||
chain,
|
||||
});
|
||||
let isTokenFactory = chainConfig.ampToken.startsWith("factory");
|
||||
|
||||
let tvl = +(res.tvl_uluna ?? res.tvl_utoken ?? 0) / 1e6;
|
||||
return {
|
||||
[coinGeckoId]: tvl,
|
||||
};
|
||||
let ampAmount = 0;
|
||||
|
||||
if (isTokenFactory) {
|
||||
let balances = await getBalance2({
|
||||
owner: chainConfig.voteEscrow,
|
||||
token: isTokenFactory,
|
||||
chain,
|
||||
});
|
||||
|
||||
ampAmount = +(balances[chainConfig.ampToken] ?? 0);
|
||||
} else {
|
||||
ampAmount = await getBalance({
|
||||
owner: chainConfig.voteEscrow,
|
||||
token: chainConfig.ampToken,
|
||||
chain,
|
||||
});
|
||||
}
|
||||
|
||||
if (chainConfig.coinGeckoIdAmp) {
|
||||
return {
|
||||
[chainConfig.coinGeckoIdAmp]: ampAmount / 1e6,
|
||||
};
|
||||
} else {
|
||||
state ||= await getState(chain, chainConfig.hub);
|
||||
let amount = (ampAmount / 1e6) * +state.exchange_rate;
|
||||
return {
|
||||
[chainConfig.coinGeckoId]: amount,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async function farm2Tvl(farm) {
|
||||
@@ -183,6 +212,16 @@ function junoTvl() {
|
||||
return mergePromises([tvlHub("juno")]);
|
||||
}
|
||||
|
||||
async function migalooTvl() {
|
||||
let chain = "migaloo";
|
||||
let chainConfig = config[chain];
|
||||
let state = await getState(chain, chainConfig.hub);
|
||||
return await mergePromises([
|
||||
tvlHub(chain, state),
|
||||
tvlAmpGovernance(chain, state),
|
||||
]);
|
||||
}
|
||||
|
||||
function terra2Tvl() {
|
||||
return mergePromises([
|
||||
tvlHub("terra2"),
|
||||
@@ -200,4 +239,5 @@ module.exports = {
|
||||
terra: { tvl: terraTvl },
|
||||
kujira: { tvl: kujiraTvl },
|
||||
juno: { tvl: junoTvl },
|
||||
migaloo: { tvl: migalooTvl },
|
||||
};
|
||||
|
||||
12
projects/ethx/index.js
Normal file
12
projects/ethx/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const { staking } = require('../helper/staking')
|
||||
|
||||
module.exports = {
|
||||
ethereum: {
|
||||
tvl: staking('0x7b0Eff0C991F0AA880481FdFa5624Cb0BC9b10e1', [
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
'0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84',
|
||||
'0x5E8422345238F34275888049021821E8E08CAa1f',
|
||||
'0xae78736Cd615f374D3085123A210448E74Fc6393',
|
||||
]),
|
||||
}
|
||||
}
|
||||
44
projects/extra/index.js
Normal file
44
projects/extra/index.js
Normal file
@@ -0,0 +1,44 @@
|
||||
const { getLogs } = require('../helper/cache/getLogs')
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
|
||||
const config = {
|
||||
optimism: { factory: '0xbb505c54d71e9e599cb8435b4f0ceec05fc71cbd', fromBlock: 96265067, vaultFactory: '0x155620a2e6a9392c754b73296d9655061525729b', positionViewer: '0xf9cfb8a62f50e10adde5aa888b44cf01c5957055' },
|
||||
}
|
||||
|
||||
module.exports = {};
|
||||
|
||||
const getVaultAbi = "function getVault(uint256 vaultId) view returns (tuple(address gauge, address pair, address token0, address token1, bool stable, bool paused, bool frozen, bool borrowingEnabled, bool liquidateWithTWAP, uint16 maxLeverage, uint16 premiumMaxLeverage, uint16 maxPriceDiff, uint16 liquidateDebtRatio, uint16 withdrawFeeRate, uint16 compoundFeeRate, uint16 liquidateFeeRate, uint16 rangeStopFeeRate, uint16 protocolFeeRate, uint256 premiumRequirement, uint256 protocolFee0Accumulated, uint256 protocolFee1Accumulated, uint256 minInvestValue, uint256 minSwapAmount0, uint256 minSwapAmount1, uint256 totalLp, uint256 totalLpShares, uint256 premiumUtilizationOfReserve0, uint256 debtLimit0, uint256 debtPositionId0, uint256 debtTotalShares0, uint256 premiumUtilizationOfReserve1, uint256 debtLimit1, uint256 debtPositionId1, uint256 debtTotalShares1))"
|
||||
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
const { factory, fromBlock, vaultFactory, positionViewer, } = config[chain]
|
||||
module.exports[chain] = {
|
||||
tvl: async (_, _b, _cb, { api, }) => {
|
||||
const logs = await getLogs({
|
||||
api,
|
||||
target: factory,
|
||||
topics: ['0x857d20297bde4478f678d3aafbfdf7fbfc90a4200b62eb053a32b2c50335676f'],
|
||||
eventAbi: 'event InitReserve (address indexed reserve, address indexed eTokenAddress, address stakingAddress, uint256 id)',
|
||||
onlyArgs: true,
|
||||
fromBlock,
|
||||
})
|
||||
|
||||
const vaultLogs = await getLogs({
|
||||
api,
|
||||
target: vaultFactory,
|
||||
topics: ['0xc0a8c0f282890a3da41a2183a1e9a1988888e8d8a0a39d933d42b0418e626250'],
|
||||
fromBlock,
|
||||
})
|
||||
|
||||
const calls = []
|
||||
for (let i = 1; i <= vaultLogs.length; i++) calls.push(i)
|
||||
|
||||
const data = await api.multiCall({ target: positionViewer, abi: getVaultAbi, calls })
|
||||
data.forEach(({ pair, totalLp }) => api.add(pair, totalLp))
|
||||
|
||||
const tokensAndOwners = logs.map(i => [i.reserve, i.eTokenAddress])
|
||||
|
||||
return sumTokens2({ api, tokensAndOwners, resolveLP: true, })
|
||||
}
|
||||
}
|
||||
})
|
||||
4
projects/fantOHM/api.js
Normal file
4
projects/fantOHM/api.js
Normal file
@@ -0,0 +1,4 @@
|
||||
const index = require('./index')
|
||||
const { ohmStaking } = require('../helper/treasury')
|
||||
|
||||
module.exports = ohmStaking(index)
|
||||
@@ -73,7 +73,7 @@ async function fantomTvl(timestamp, _, {fantom: block}) {
|
||||
await sumTokensAndLPsSharedOwners(balances, [
|
||||
[ADDRESSES.fantom.DAI, false], // DAI
|
||||
[ADDRESSES.fantom.WFTM, false], // wFTM
|
||||
["0x6fc9383486c163fa48becdec79d6058f984f62ca", false], // USDB
|
||||
// ["0x6fc9383486c163fa48becdec79d6058f984f62ca", false], // USDB
|
||||
[ADDRESSES.fantom.USDC, false], // USDC
|
||||
["0xd77fc9c4074b56ecf80009744391942fbfddd88b", true], // DAI/FHM
|
||||
], [fantomTreasuryContract], block, "fantom",
|
||||
@@ -86,7 +86,7 @@ async function fantomTvl(timestamp, _, {fantom: block}) {
|
||||
|
||||
// investments
|
||||
await Promise.all([
|
||||
balanceOf(fantomGnosisContract, "0x6fc9383486c163fa48becdec79d6058f984f62ca", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block), // USDB
|
||||
// balanceOf(fantomGnosisContract, "0x6fc9383486c163fa48becdec79d6058f984f62ca", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block), // USDB
|
||||
balanceOf(fantomGnosisContract, ADDRESSES.fantom.DAI, ADDRESSES.ethereum.DAI, balances, block), // DAI
|
||||
beetsFtm_BeetsLp(fantohmDaoDeployerWallet, balances, block), // beets/wftm LP
|
||||
lqdrFtm_BeetsLp(fantohmDaoDeployerWallet, balances, block), // lqdr/wftm LP
|
||||
@@ -94,8 +94,8 @@ async function fantomTvl(timestamp, _, {fantom: block}) {
|
||||
|
||||
// usdbalance.com
|
||||
await Promise.all([
|
||||
balanceOf(ftmTradfi3mContract, "0x6fc9383486c163fa48becdec79d6058f984f62ca", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block), // USDB
|
||||
balanceOf(ftmTradfi6mContract, "0x6fc9383486c163fa48becdec79d6058f984f62ca", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block), // USDB
|
||||
// balanceOf(ftmTradfi3mContract, "0x6fc9383486c163fa48becdec79d6058f984f62ca", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block), // USDB
|
||||
// balanceOf(ftmTradfi6mContract, "0x6fc9383486c163fa48becdec79d6058f984f62ca", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block), // USDB
|
||||
|
||||
balanceOfStablePool(masterChefContract, "0xD5E946b5619fFf054c40D38c976f1d06C1e2fA82", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", "fantom:" + ADDRESSES.fantom.DAI, balances, block), // USDB-DAI stable pool
|
||||
]);
|
||||
@@ -120,13 +120,13 @@ async function ethTvl(timestamp, block, chainBlocks) {
|
||||
|
||||
// usdbalance.com
|
||||
await Promise.all([
|
||||
balanceOf(ethGnosisContract, "0x02B5453D92B730F29a86A0D5ef6e930c4Cf8860B", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block, "ethereum"), // USDB
|
||||
// balanceOf(ethGnosisContract, "0x02B5453D92B730F29a86A0D5ef6e930c4Cf8860B", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block, "ethereum"), // USDB
|
||||
balanceOf(ethGnosisContract, ADDRESSES.ethereum.DAI, "ethereum:" + ADDRESSES.ethereum.DAI, balances, block, "ethereum"), // DAI
|
||||
|
||||
balanceOf(ethTreasuryContract, "0x02B5453D92B730F29a86A0D5ef6e930c4Cf8860B", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block, "ethereum"), // USDB
|
||||
// balanceOf(ethTreasuryContract, "0x02B5453D92B730F29a86A0D5ef6e930c4Cf8860B", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block, "ethereum"), // USDB
|
||||
|
||||
balanceOf(ethTradfi3mContract, "0x02B5453D92B730F29a86A0D5ef6e930c4Cf8860B", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block, "ethereum"), // USDB
|
||||
balanceOf(ethTradfi6mContract, "0x02B5453D92B730F29a86A0D5ef6e930c4Cf8860B", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block, "ethereum"), // USDB
|
||||
// balanceOf(ethTradfi3mContract, "0x02B5453D92B730F29a86A0D5ef6e930c4Cf8860B", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block, "ethereum"), // USDB
|
||||
// balanceOf(ethTradfi6mContract, "0x02B5453D92B730F29a86A0D5ef6e930c4Cf8860B", "fantom:0x6fc9383486c163fa48becdec79d6058f984f62ca", balances, block, "ethereum"), // USDB
|
||||
]);
|
||||
|
||||
return balances;
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
const ADDRESSES = require('../helper/coreAssets.json')
|
||||
const sdk = require('@defillama/sdk')
|
||||
|
||||
async function tvl(time, ethB, {songbird: block}){
|
||||
return {
|
||||
"songbird": Number(
|
||||
(await sdk.api.erc20.balanceOf({target: ADDRESSES.songbird.WSGB, owner: "0xFa21A4ABD1a58CefAB79CFd597aCcc314403eE9f", block, chain:'songbird'})).output
|
||||
)/1e18
|
||||
}
|
||||
}
|
||||
const { sumTokensExport } = require('../helper/unwrapLPs')
|
||||
|
||||
module.exports={
|
||||
methodology: "We count all WSGB on 0xFa21A4ABD1a58CefAB79CFd597aCcc314403eE9f, which is backing the stablecoin",
|
||||
methodology: "We count all WSGB on 0xFa21A4ABD1a58CefAB79CFd597aCcc314403eE9f and all EXFI on 0x4595fc96262057f9b0d4276ff04de8f2f44e612e, which are backing the stablecoin",
|
||||
songbird: {
|
||||
tvl
|
||||
tvl: sumTokensExport({chain: 'songbird', tokensAndOwners: [
|
||||
['0x02f0826ef6aD107Cfc861152B32B52fD11BaB9ED', '0xFa21A4ABD1a58CefAB79CFd597aCcc314403eE9f'],
|
||||
['0xC348F894d0E939FE72c467156E6d7DcbD6f16e21','0x4595fc96262057f9b0d4276ff04de8f2f44e612e']
|
||||
]})
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
const ADDRESSES = require('../helper/coreAssets.json')
|
||||
const { sumUnknownTokens } = require("../helper/unknownTokens");
|
||||
const { staking } = require('../helper/staking')
|
||||
const WSGB = ADDRESSES.songbird.WSGB
|
||||
const CANARY_DOLLAR = ADDRESSES.songbird.CAND
|
||||
const EXFI = ADDRESSES.songbird.EXFI;
|
||||
@@ -46,13 +47,6 @@ async function pool2(timestamp, ethblock, { [chain]: block }) {
|
||||
]
|
||||
return sumUnknownTokens({ tokensAndOwners: tokens, chain, block, useDefaultCoreAssets: true, })
|
||||
}
|
||||
async function staking(timestamp, ethblock, { [chain]: block }) {
|
||||
const tokens = [
|
||||
[SFIN, '0x554742076743b366504972F86609d64fd18BDC34'],
|
||||
[SFIN,'0xd0dbAFF52224C0882cfaf1765f347Cb5e4364FA1']
|
||||
]
|
||||
return sumUnknownTokens({ tokensAndOwners: tokens, chain, block, useDefaultCoreAssets: true, lps: ['0x48195Ca4D228ce487AE2AE1335B017a95493Ade6'] })
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
misrepresentedTokens: true,
|
||||
@@ -60,6 +54,6 @@ module.exports = {
|
||||
songbird: {
|
||||
tvl: farmTvl,
|
||||
pool2,
|
||||
staking,
|
||||
staking: staking(['0x554742076743b366504972F86609d64fd18BDC34', '0xd0dbAFF52224C0882cfaf1765f347Cb5e4364FA1'], SFIN),
|
||||
}
|
||||
};
|
||||
4
projects/floor-dao/api.js
Normal file
4
projects/floor-dao/api.js
Normal file
@@ -0,0 +1,4 @@
|
||||
const index = require('./index')
|
||||
const { ohmStaking } = require('../helper/treasury')
|
||||
|
||||
module.exports = ohmStaking(index)
|
||||
@@ -1,12 +1,13 @@
|
||||
const ADDRESSES = require('../helper/coreAssets.json')
|
||||
const { sumTokens2, sumTokensExport, } = require('../helper/unwrapLPs')
|
||||
const sdk = require("@defillama/sdk");
|
||||
// https://docs.floor.xyz/fundamentals/treasury
|
||||
|
||||
const WETH = ADDRESSES.ethereum.WETH
|
||||
const WETH = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
|
||||
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
|
||||
|
||||
const NFTX_LP_STAKING = '0x688c3e4658b5367da06fd629e41879beab538e37'
|
||||
const treasury = '0x91E453f442d25523F42063E1695390e325076ca2'
|
||||
const floorTreasury2 = "0xa9d93a5cca9c98512c8c56547866b1db09090326";
|
||||
const stakingAddress = '0x759c6de5bca9ade8a1a2719a31553c4b7de02539'
|
||||
const FLOOR = '0xf59257E961883636290411c11ec5Ae622d19455e'
|
||||
|
||||
@@ -30,7 +31,7 @@ module.exports = {
|
||||
})
|
||||
const balances = {}
|
||||
stakingBalances.forEach((bal,i) => sdk.util.sumSingleBalance(balances,stakingInfo[i][0],bal))
|
||||
return sumTokens2({ balances, block, owner: treasury, tokens: [WETH], resolveLP: true, })
|
||||
return sumTokens2({ balances, block, owners: [treasury, floorTreasury2], tokens: [WETH, USDC], resolveLP: true, })
|
||||
},
|
||||
staking: sumTokensExport({owner: stakingAddress, tokens: [FLOOR]})
|
||||
}
|
||||
|
||||
22
projects/flux-exchange/index.js
Normal file
22
projects/flux-exchange/index.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const { staking } = require("../helper/staking");
|
||||
const { gmxExports } = require("../helper/gmx");
|
||||
|
||||
const FTMVault = "0xc050733A325eEe50E544AcCbD38F6DACEd60ea6D";
|
||||
const FTMStaking = "0x136F1bD4Bb930cD931Ed30310142c2f03a946AC0";
|
||||
const WFTM = "0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83";
|
||||
|
||||
// ZKSYNC
|
||||
const zkSyncVault = "0x09Aa1138dfdfF855Df18DDAf08e92186D213700e";
|
||||
const zkSyncStaking = "0xFae2784FaE4D47316B487Bc0087a7C78D4809753";
|
||||
const WETH = "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91";
|
||||
|
||||
module.exports = {
|
||||
fantom: {
|
||||
staking: staking(FTMStaking, WFTM),
|
||||
tvl: gmxExports({ vault: FTMVault })
|
||||
},
|
||||
era: {
|
||||
staking: staking(zkSyncStaking, WETH),
|
||||
tvl: gmxExports({ vault: zkSyncVault })
|
||||
}
|
||||
};
|
||||
@@ -34,6 +34,21 @@ const pools = [
|
||||
appId: 1044267181,
|
||||
assetId: 287867876,
|
||||
},
|
||||
// Gard
|
||||
{
|
||||
appId: 1060585819,
|
||||
assetId: 684649988,
|
||||
},
|
||||
// WBTC
|
||||
{
|
||||
appId: 1067289273,
|
||||
assetId: 1058926737,
|
||||
},
|
||||
// WETH
|
||||
{
|
||||
appId: 1067289481,
|
||||
assetId: 887406851,
|
||||
},
|
||||
];
|
||||
|
||||
const oracleAppId = 1040271396;
|
||||
|
||||
9
projects/fortress/api.js
Normal file
9
projects/fortress/api.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const index = require('./index')
|
||||
|
||||
module.exports = {
|
||||
avax: {
|
||||
tvl: () => 0,
|
||||
staking: index.avax.staking,
|
||||
}
|
||||
}
|
||||
|
||||
8
projects/fortunedao/api.js
Normal file
8
projects/fortunedao/api.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const index = require('../fortunedao.js')
|
||||
|
||||
module.exports = {
|
||||
cronos: {
|
||||
tvl: () => 0,
|
||||
staking: index.cronos.staking,
|
||||
}
|
||||
}
|
||||
20
projects/fpi/index.js
Normal file
20
projects/fpi/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const frax = "0x853d955acef822db058eb8505911ed77f175b99e"
|
||||
const fxs = "0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0"
|
||||
|
||||
async function tvl(_, _b, _cb, { api, erc20 }){
|
||||
const balances = {}
|
||||
// owner 0x6a7efa964cf6d9ab3bc3c47ebddb853a8853c502
|
||||
const lpOwned = await api.call({ abi: "function totalBalanceOf(address) view returns (uint256)", target:"0x7287488f8df7dddc5f373142d4827aaf92aac845", params: ["0x921852ba77cbceaa29e986e45ef2207f6e664df2"] })
|
||||
const supply = await api.call({ abi: "function totalSupply() view returns (uint256)", target:"0xdb7cbbb1d5d5124f86e92001c9dfdc068c05801d" })
|
||||
const fraxInPool = await api.call({ abi: "function balanceOf(address) view returns (uint256)", params:["0xf861483fa7e511fbc37487d91b6faa803af5d37c"], target: frax })
|
||||
balances[frax] = lpOwned/supply * fraxInPool
|
||||
balances[fxs] = await api.call({ abi: "function balanceOf(address) view returns (uint256)", params:["0x6a7efa964cf6d9ab3bc3c47ebddb853a8853c502"], target: fxs })
|
||||
|
||||
return balances
|
||||
}
|
||||
|
||||
module.exports={
|
||||
ethereum:{
|
||||
tvl
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ module.exports = {
|
||||
...fx("avax", "0x5Ca135cB8527d76e932f34B5145575F9d8cbE08E"),
|
||||
...fx("bsc", "0xa007a9716dba05289df85A90d0Fd9D39BEE808dE"),
|
||||
...fx("dogechain", "0x67b7DA7c0564c6aC080f0A6D9fB4675e52E6bF1d"),
|
||||
...fx("fantom", "0xF55C563148cA0c0F1626834ec1B8651844D76792"),
|
||||
...fx("fantom", "0xF55C563148cA0c0F1626834ec1B8651844D76792","0xDc745E09fC459aDC295E2e7baACe881354dB7F64"),
|
||||
...fx("moonbeam", "0x5Ca135cB8527d76e932f34B5145575F9d8cbE08E"),
|
||||
...fx("polygon", "0xc2544A32872A91F4A553b404C6950e89De901fdb"),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"usdValueInVault": "uint256:usdValueInVault",
|
||||
"collatDollarBalance": "uint256:collatDollarBalance",
|
||||
"borrowed_frax": "uint256:borrowed_frax"
|
||||
}
|
||||
@@ -1,42 +1,15 @@
|
||||
const ADDRESSES = require('../helper/coreAssets.json')
|
||||
const sdk = require("@defillama/sdk");
|
||||
const abi = require("./abi.json");
|
||||
const BigNumber = require("bignumber.js");
|
||||
const { staking, stakings } = require("../helper/staking");
|
||||
const { sumTokens } = require("../helper/unwrapLPs");
|
||||
const { staking, } = require("../helper/staking");
|
||||
const { sumTokens2, nullAddress, } = require("../helper/unwrapLPs");
|
||||
|
||||
const USDC = ADDRESSES.ethereum.USDC;
|
||||
const FXS = "0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0";
|
||||
|
||||
const FEI3CRVs = [
|
||||
"0x70F55767B11c047C8397285E852919F5f6c8DC60",
|
||||
"0xE4BD0461AE7fdc76c61CE286a80c9B55d83B204a",
|
||||
];
|
||||
|
||||
const contractAddresses = [
|
||||
//FRAX3CRV
|
||||
"0x49ee75278820f409ecd67063D8D717B38d66bd71",
|
||||
//CURVE_AMO
|
||||
"0x72170Cdc48C33a6AE6B3E83CD387ca3Fb9105da2",
|
||||
//FRAX_AMO_MINTER
|
||||
"0xcf37B62109b537fa0Cb9A90Af4CA72f6fb85E241",
|
||||
//LENDING_AMO
|
||||
"0x9507189f5B6D820cd93d970d67893006968825ef",
|
||||
//MANUAL_AMO
|
||||
"0x1Be588641Fb28Eb8C2A51f1129707FB1E2683f5a",
|
||||
//USDC_POOL_V1
|
||||
"0x3C2982CA260e870eee70c423818010DfeF212659",
|
||||
//USDC_POOL_V2
|
||||
"0x1864Ca3d47AaB98Ee78D11fc9DCC5E7bADdA1c0d",
|
||||
//USDC_POOL_V3
|
||||
"0x2fE065e6FFEf9ac95ab39E5042744d695F560729",
|
||||
//INVESTOR_COLLATERAL_POOL
|
||||
"0xEE5825d5185a1D512706f9068E69146A54B6e076",
|
||||
//INVESTOR_AMO_V2
|
||||
"0xB8315Af919729c823B2d996B1A6DDE381E7444f1",
|
||||
];
|
||||
const FRAX_3CRV = '0xd632f22692fac7611d2aa1c0d552930d43caed3b'
|
||||
const T_3CRV = '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490'
|
||||
|
||||
const veFXS_StakingContract = "0xc8418aF6358FFddA74e09Ca9CC3Fe03Ca6aDC5b0";
|
||||
const INVESTOR_AMO = '0xb1748c79709f4ba2dd82834b8c82d4a505003f27'
|
||||
|
||||
const POOL_STAKING_CONTRACTS = [
|
||||
"0xD875628B942f8970De3CcEaf6417005F68540d4f",
|
||||
@@ -55,116 +28,163 @@ const LP_ADDRESSES = [
|
||||
"0xecBa967D84fCF0405F6b32Bc45F4d36BfDBB2E81",
|
||||
];
|
||||
|
||||
const treasuryContracts = [
|
||||
"0x63278bF9AcdFC9fA65CFa2940b89A34ADfbCb4A1",
|
||||
"0x8D4392F55bC76A046E443eb3bab99887F4366BB0",
|
||||
"0xa95f86fE0409030136D6b82491822B3D70F890b3",
|
||||
"0x9AA7Db8E488eE3ffCC9CdFD4f2EaECC8ABeDCB48",
|
||||
"0x874a873e4891fB760EdFDae0D26cA2c00922C404",
|
||||
];
|
||||
async function get3CRVRatio(api) {
|
||||
const [
|
||||
frax3crvSupply,
|
||||
bal_3crv,
|
||||
] = await Promise.all([
|
||||
api.call({ abi: 'erc20:totalSupply', target: FRAX_3CRV, }),
|
||||
api.call({ abi: 'erc20:balanceOf', target: T_3CRV, params: FRAX_3CRV, }),
|
||||
])
|
||||
return bal_3crv / frax3crvSupply
|
||||
}
|
||||
|
||||
const ethereumTvl = async (timestamp, block) => {
|
||||
async function addFrax3CRV(api, balances) {
|
||||
const vault = '0x49ee75278820f409ecd67063D8D717B38d66bd71'
|
||||
const [
|
||||
frax3crvBal,
|
||||
ratio3CRV,
|
||||
] = await Promise.all([
|
||||
api.call({ abi: 'uint256:FRAX3CRVInVault', target: vault }),
|
||||
get3CRVRatio(api),
|
||||
])
|
||||
sdk.util.sumSingleBalance(balances, T_3CRV, ratio3CRV * frax3crvBal, api.chain)
|
||||
}
|
||||
|
||||
async function addyFrax3CRV(api, balances) {
|
||||
const vault = '0x72170Cdc48C33a6AE6B3E83CD387ca3Fb9105da2'
|
||||
const yFRAX3CRV = '0xB4AdA607B9d6b2c9Ee07A275e9616B84AC560139'
|
||||
const [
|
||||
yfrax3crvBal,
|
||||
pricePerShare,
|
||||
ratio3CRV,
|
||||
] = await Promise.all([
|
||||
api.call({ abi: 'uint256:yvCurveFRAXBalance', target: vault }),
|
||||
api.call({ abi: 'uint256:pricePerShare', target: yFRAX3CRV }),
|
||||
get3CRVRatio(api),
|
||||
])
|
||||
sdk.util.sumSingleBalance(balances, T_3CRV, yfrax3crvBal * ratio3CRV * (pricePerShare / 1e18), api.chain)
|
||||
return sumTokens2({ balances, api, owner: vault, tokens: [USDC] })
|
||||
}
|
||||
|
||||
|
||||
async function addCvxFRAX_BP(api, balances) {
|
||||
const convexFRAXBP = '0x7e880867363A7e321f5d260Cade2B0Bb2F717B02'
|
||||
const crvFRAX = '0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC'
|
||||
const crvFRAXPool = '0xdcef968d416a41cdac0ed8702fac8128a64241a2'
|
||||
const [
|
||||
cvxFraxBal,
|
||||
usdcBal,
|
||||
poolSupply,
|
||||
] = await Promise.all([
|
||||
|
||||
api.call({ abi: 'erc20:balanceOf', target: convexFRAXBP, params: INVESTOR_AMO }),
|
||||
api.call({ abi: 'erc20:balanceOf', target: USDC, params: crvFRAXPool }),
|
||||
api.call({ abi: 'erc20:totalSupply', target: crvFRAX }),
|
||||
])
|
||||
sdk.util.sumSingleBalance(balances, USDC, usdcBal * cvxFraxBal / poolSupply, api.chain)
|
||||
}
|
||||
|
||||
async function addCvxFXSFRAX_BP(api, balances) {
|
||||
const userAccount = '0x2AA609715488B09EFA93883759e8B089FBa11296'
|
||||
const vault = '0x963f487796d54d2f27ba6f3fbe91154ca103b199'
|
||||
const crvFRAX = '0x3175Df0976dFA876431C2E9eE6Bc45b65d3473CC'
|
||||
const crvFRAXPool = '0xdcef968d416a41cdac0ed8702fac8128a64241a2'
|
||||
const [
|
||||
cvxFraxBal,
|
||||
usdcBal,
|
||||
poolSupply,
|
||||
] = await Promise.all([
|
||||
api.call({ abi: 'function lockedLiquidityOf(address) view returns (uint256)', target: vault, params: userAccount }),
|
||||
api.call({ abi: 'erc20:balanceOf', target: USDC, params: crvFRAXPool }),
|
||||
api.call({ abi: 'erc20:totalSupply', target: crvFRAX }),
|
||||
])
|
||||
sdk.util.sumSingleBalance(balances, USDC, usdcBal * cvxFraxBal / poolSupply, api.chain)
|
||||
}
|
||||
|
||||
|
||||
async function addUSDCPools(api, balances) {
|
||||
return sumTokens2({
|
||||
balances, api, owners: [
|
||||
'0x3C2982CA260e870eee70c423818010DfeF212659',
|
||||
'0x1864Ca3d47AaB98Ee78D11fc9DCC5E7bADdA1c0d',
|
||||
'0x2fE065e6FFEf9ac95ab39E5042744d695F560729',
|
||||
], tokens: [USDC]
|
||||
})
|
||||
}
|
||||
|
||||
async function addAMOMinter(api, balances) {
|
||||
const amoMinter = '0xcf37B62109b537fa0Cb9A90Af4CA72f6fb85E241'
|
||||
let allAMOAddresses = await api.call({ target: amoMinter, abi: 'address[]:allAMOAddresses' })
|
||||
const amos = allAMOAddresses.filter(i => i !== nullAddress)
|
||||
const blacklist = new Set([
|
||||
'0x66635DC1EdEfF19e839f152a67278151Aa6e1B61', // aave AMO
|
||||
INVESTOR_AMO,
|
||||
].map(i => i.toLowerCase()))
|
||||
const dollBallAbi = 'function dollarBalances() view returns (uint256 frax_val_e18, uint256 collat_val_e18)'
|
||||
const res = await api.multiCall({ abi: dollBallAbi, calls: amos.filter(i => blacklist.has(i.toLowerCase())) })
|
||||
const table = []
|
||||
res.forEach((v, i) => {
|
||||
table.push([amos[i], Number(v.collat_val_e18 / 1e24).toFixed(3)])
|
||||
sdk.util.sumSingleBalance(balances, USDC, v.collat_val_e18 / 1e12, api.chain)
|
||||
})
|
||||
table.sort((a, b) => +b[1] - +a[1])
|
||||
console.log(amos.length)
|
||||
console.table(table)
|
||||
|
||||
}
|
||||
|
||||
async function addInvestorAMO(api, balances) {
|
||||
return sumTokens2({
|
||||
balances,
|
||||
api, owner: INVESTOR_AMO,
|
||||
tokens: Object.values({
|
||||
Synapse: '0x0f2d719407fdbeff09d87557abb7232601fd9f29',
|
||||
'Wrapped BTC': '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
||||
'USD Coin': '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
||||
ZigZag: '0xc91a71a1ffa3d8b22ba615ba1b9c01b2bbbf55ad',
|
||||
'Governance OHM': '0x0ab87046fbb341d058f17cbc4c1133f25a20a52f',
|
||||
'Aave interest bearing USDC': '0xbcca60bb61934080951369a648fb03df4f96263c',
|
||||
Perpetual: '0xbc396689893d065f41bc2c6ecbee5e0085233447',
|
||||
Hop: '0xc5102fe9359fd9a28f877a67e36b0f050d81a3cc',
|
||||
'Ethereum Name Service': '0xc18360217d8f7ab5e7c516566761ea12ce7f9d72',
|
||||
'Curve.fi DAI/USDC/USDT': '0x6c3f90f043a72fa612cbac8115ee7e52bde6e490',
|
||||
'Saddle DAO': '0xf1dc500fde233a4055e25e5bbf516372bc4f6871',
|
||||
Ether: nullAddress,
|
||||
TrueUSD: '0x0000000000085d4780b73119b644ae5ecd22b376',
|
||||
'Gelato Network Token': '0x15b7c0c907e4c6b9adaaaabc300c08991d6cea05',
|
||||
'Staked Aave': '0x4da27a545c0c5b758a6ba100e3a049001de870f5',
|
||||
'Convex Token': '0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b',
|
||||
'Curve DAO Token': '0xd533a949740bb3306d119cc777fa900ba034cd52',
|
||||
'Bend Token': '0x0d02755a5700414b26ff040e1de35d337df56218',
|
||||
'Binance USD': '0x4fabb145d64652a948d72533023f6e7a623c7c53',
|
||||
'Alchemix USD': '0xbc6da0fe9ad5f3b0d58160288917aa56653660e9',
|
||||
'Staked CvxCrv': '0xaa0c3f5f7dfd688c6e646f66cd2a6b66acdbe434',
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
const ethereumTvl = async (timestamp, block, _, { api }) => {
|
||||
let balances = {};
|
||||
|
||||
// --- CurveMetapoolLockerAMOs USDC TVL ---
|
||||
const usdValueInVault = (
|
||||
await sdk.api.abi.multiCall({
|
||||
calls: FEI3CRVs.map((addr) => ({ target: addr })),
|
||||
abi: abi.usdValueInVault,
|
||||
block,
|
||||
})
|
||||
).output.map((value) => value.output);
|
||||
|
||||
usdValueInVault.forEach((value) => {
|
||||
sdk.util.sumSingleBalance(
|
||||
balances,
|
||||
USDC,
|
||||
BigNumber(value)
|
||||
.dividedBy(10 ** 12)
|
||||
.toFixed(0)
|
||||
);
|
||||
});
|
||||
|
||||
// --- USDC POOLs + AMOs + FRAX3CRV and FEI3CRVs ---
|
||||
const usdcTvls = (
|
||||
await sdk.api.abi.multiCall({
|
||||
calls: contractAddresses.map((addr) => ({ target: addr })),
|
||||
abi: abi.collatDollarBalance,
|
||||
block,
|
||||
})
|
||||
).output.map((response) => response.output);
|
||||
|
||||
usdcTvls.forEach((usdcTvl) => {
|
||||
sdk.util.sumSingleBalance(
|
||||
balances,
|
||||
USDC,
|
||||
BigNumber(usdcTvl)
|
||||
.dividedBy(10 ** 12)
|
||||
.toFixed(0)
|
||||
);
|
||||
});
|
||||
|
||||
return balances;
|
||||
await Promise.all([
|
||||
addFrax3CRV(api, balances),
|
||||
addyFrax3CRV(api, balances),
|
||||
addUSDCPools(api, balances),
|
||||
addInvestorAMO(api, balances),
|
||||
addCvxFXSFRAX_BP(api, balances),
|
||||
])
|
||||
return balances
|
||||
};
|
||||
|
||||
|
||||
// Fantom
|
||||
const contractAddressesFantom = [
|
||||
//Spirit/Ola Lending AMO Fantom
|
||||
"0x8dbc48743a05A6e615D9C39aEBf8C2b157aa31eA",
|
||||
//Scream Lending AMO Fantom
|
||||
"0x51E6D09d5A1EcF8BE035BBCa82F77BfeC3c7672A",
|
||||
//SpiritSwap Liquidity AMO Fantom
|
||||
"0x48F0856e0E2D06fBCed5FDA10DD69092a500646B",
|
||||
];
|
||||
|
||||
const fantomTvl = async (timestamp, ethBlock, chainBlocks) => {
|
||||
const balances = {};
|
||||
const chain = "fantom"
|
||||
const block = chainBlocks[chain]
|
||||
// --- AMO's ---
|
||||
const usdcTvls = (
|
||||
await sdk.api.abi.multiCall({
|
||||
calls: contractAddressesFantom.map((addr) => ({ target: addr })),
|
||||
abi: abi.borrowed_frax,
|
||||
block,
|
||||
chain,
|
||||
})
|
||||
).output.map((response) => response.output);
|
||||
|
||||
usdcTvls.forEach((usdcTvl) => {
|
||||
sdk.util.sumSingleBalance(
|
||||
balances,
|
||||
USDC,
|
||||
BigNumber(usdcTvl)
|
||||
.dividedBy(10 ** 12) // // Convert to 6 decimal USDC values
|
||||
.toFixed(0)
|
||||
);
|
||||
});
|
||||
|
||||
// --- Liquidity staking ---
|
||||
|
||||
// Curve FRAX2Pool
|
||||
await sumTokens(balances, [
|
||||
["0x8866414733f22295b7563f9c5299715d2d76caf4", "0x7a656b342e14f745e2b164890e88017e27ae7320"],
|
||||
[ADDRESSES.fantom.USDC, "0xbea9f78090bdb9e662d8cb301a00ad09a5b756e9"]
|
||||
], block, chain, addr => addr === "0x8866414733f22295b7563f9c5299715d2d76caf4" ? [ADDRESSES.ethereum.DAI]: `${chain}:${addr}`)
|
||||
|
||||
return balances;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
doublecounted: true,
|
||||
misrepresentedTokens: true,
|
||||
ethereum: {
|
||||
staking: staking(veFXS_StakingContract, FXS),
|
||||
pool2: staking(POOL_STAKING_CONTRACTS, LP_ADDRESSES),
|
||||
tvl: ethereumTvl,
|
||||
},
|
||||
fantom: {
|
||||
tvl: fantomTvl
|
||||
},
|
||||
hallmarks:[
|
||||
hallmarks: [
|
||||
[1651881600, "UST depeg"],
|
||||
],
|
||||
methodology:
|
||||
|
||||
@@ -1,60 +1,18 @@
|
||||
const ADDRESSES = require('../helper/coreAssets.json')
|
||||
const { sumTokensAndLPsSharedOwners } = require("../helper/unwrapLPs");
|
||||
const { staking } = require("../helper/staking");
|
||||
|
||||
const GgStaking = "0xBD79c01140CeE7040f8F5E935B72e13540a801b6"
|
||||
const gg = "0xF2F7CE610a091B94d41D69f4fF1129434a82E2f0"
|
||||
|
||||
// https://app.galaxygoggle.money/#/bonds
|
||||
const treasury = "0xD5F922e23693e552793fE0431F9a95ba67A60A23"
|
||||
const dao = "0xDEEdd1646984F9372Cc9D3d7E13AC1606cC2B548"
|
||||
const mim = "0x130966628846BFd36ff31a822705796e8cb8C18D"
|
||||
const wavax = ADDRESSES.avax.WAVAX
|
||||
const joe = ADDRESSES.avax.JOE
|
||||
|
||||
async function tvl(timestamp, block, chainBlocks) {
|
||||
const balances = {};
|
||||
|
||||
await sumTokensAndLPsSharedOwners(
|
||||
balances,
|
||||
[
|
||||
[mim, false],
|
||||
[wavax, false],
|
||||
[joe, false],
|
||||
["0xe9E8d6b6ce6D94Fc9d724711e80784Ec096949Fc", true], // mim-gg
|
||||
],
|
||||
[treasury, dao],
|
||||
chainBlocks.avax,
|
||||
'avax',
|
||||
addr=>`avax:${addr}`
|
||||
);
|
||||
|
||||
return balances;
|
||||
}
|
||||
|
||||
const bscGG = "0xcAf23964Ca8db16D816eB314a56789F58fE0e10e";
|
||||
const bscTreasury = "0xF76C9753507B3Df0867EB02D86d07C6fFcEecaf1";
|
||||
const bscStaking = "0x97209Cf7a6FccC388eEfF85b35D858756f31690d";
|
||||
const treasuryTokensBSC = [
|
||||
[ADDRESSES.bsc.BUSD, false], // BUSD
|
||||
["0x13Cf29b3F58f777dDeD38278F7d938401f6b260c", true] // GG-BUSD
|
||||
]
|
||||
|
||||
async function bscTvl(timestamp, block, chainBlocks) {
|
||||
let balances = {};
|
||||
await sumTokensAndLPsSharedOwners(balances, treasuryTokensBSC, [bscTreasury], chainBlocks.bsc, "bsc", addr=>`bsc:${addr}`);
|
||||
balances[`avax:${gg}`] = balances["bsc:0xcaf23964ca8db16d816eb314a56789f58fe0e10e"] || 0;
|
||||
delete balances["bsc:0xcaf23964ca8db16d816eb314a56789f58fe0e10e"];
|
||||
return balances;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
avax:{
|
||||
tvl,
|
||||
tvl: () => 0,
|
||||
staking: staking(GgStaking, gg, "avax")
|
||||
},
|
||||
bsc: {
|
||||
tvl: bscTvl,
|
||||
tvl: () => 0,
|
||||
staking: staking(bscStaking, bscGG, "bsc", `avax:${gg}`)
|
||||
},
|
||||
methodology:
|
||||
|
||||
@@ -5,14 +5,23 @@ const {
|
||||
|
||||
async function tvl(_, _1, _2, { api }) {
|
||||
const chain = api.chain
|
||||
const contracts = await queryContracts({ chain, codeId: 106 });
|
||||
const deposited = (await Promise.all(
|
||||
contracts.map(contract => queryContract({ contract, chain, data: { status: {} } }))
|
||||
const vaultContracts = await queryContracts({ chain, codeId: 106 });
|
||||
const vaultDeposited = (await Promise.all(
|
||||
vaultContracts.map(contract => queryContract({ contract, chain, data: { status: {} } }))
|
||||
)).map(i => i.deposited)
|
||||
const tokens = (await Promise.all(
|
||||
contracts.map(contract => queryContract({ contract, chain, data: { config: {} } }))
|
||||
const vaultTokens = (await Promise.all(
|
||||
vaultContracts.map(contract => queryContract({ contract, chain, data: { config: {} } }))
|
||||
)).map(i => i.denom)
|
||||
api.addTokens(tokens, deposited)
|
||||
api.addTokens(vaultTokens, vaultDeposited)
|
||||
|
||||
const marketContracts = await queryContracts({ chain, codeId: 113 });
|
||||
const marketDeposited = (await Promise.all(
|
||||
marketContracts.map(contract => queryContract({ contract, chain, data: { status: {} } }))
|
||||
)).map(i => i.deposited)
|
||||
const marketTokens = (await Promise.all(
|
||||
marketContracts.map(contract => queryContract({ contract, chain, data: { config: {} } }))
|
||||
)).map(i => i.collateral_denom)
|
||||
api.addTokens(marketTokens, marketDeposited)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
16
projects/gnd-protocol/index.js
Normal file
16
projects/gnd-protocol/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
const { staking } = require('../helper/staking')
|
||||
|
||||
async function tvl(_, _b, _cb, { api, }) {
|
||||
const farm = '0xd8769d8826149b137af488b1e9ac0e3afdbc058a'
|
||||
await sumTokens2({ api, owner: farm, resolveUniV3: true, })
|
||||
const tokens = Object.keys(api.getBalances()).map(i => i.replace(/arbitrum:/gi, ''))
|
||||
return sumTokens2({ api, owner: farm, tokens, })
|
||||
|
||||
}
|
||||
module.exports = {
|
||||
arbitrum: {
|
||||
tvl,
|
||||
staking: staking('0x535ec56479892d9C02fe2Bb86CeBF7ed62E81131', '0x40ea7f6d6964413d4a26a0a268542dae9f55768e')
|
||||
}
|
||||
}
|
||||
8
projects/goblinscash/api.js
Normal file
8
projects/goblinscash/api.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const index = require('./index')
|
||||
|
||||
module.exports = {
|
||||
smartbch: {
|
||||
tvl: () => 0,
|
||||
staking: index.smartbch.staking,
|
||||
}
|
||||
}
|
||||
49
projects/goodentry/index.js
Normal file
49
projects/goodentry/index.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const abi = require('../helper/abis/aave.json');
|
||||
|
||||
const addressesProviderRegistry = '0x01b76559D512Fa28aCc03630E8954405BcBB1E02';
|
||||
const balanceOfAbi = "function balanceOf(address account) view returns (uint256)";
|
||||
const getLpAbi = "function getLendingPool() view returns (address)";
|
||||
const getReserveDataAbi = "function getReserveData(address asset) view returns (uint256 reserveConfigurationMap, uint128 liquidityIndex, uint128 variableBorrowIndex, uint128 currentLiquidityRate, uint128 currentVariableBorrowRate, uint128 currentStableBorrowRate, uint40 lastUpdateTimestamp, address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress, address interestRateStrategyAddress, uint8 id)";
|
||||
const getUnderlyingAbi = "function getTokenAmounts(uint amount) external view returns (uint token0Amount, uint token1Amount)";
|
||||
const token0Abi = "function TOKEN0() view returns (address token, uint8 decimals)";
|
||||
const token1Abi = "function TOKEN1() view returns (address token, uint8 decimals)";
|
||||
|
||||
// Aave helper doesnt recognize tokenized Uniswap positions, need to manually
|
||||
|
||||
async function tvl(timestamp, ethBlock, _, { api }) {
|
||||
const addressesProviders = await api.call({ target: addressesProviderRegistry, abi: abi["getAddressesProvidersList"], })
|
||||
const validAddressesProviders = addressesProviders.filter((ap) => ap != "0x0000000000000000000000000000000000000000")
|
||||
const lendingPools = await api.multiCall({ calls: validAddressesProviders, abi: getLpAbi, })
|
||||
const aTokens = await api.multiCall({ calls: lendingPools, abi: abi["getReservesList"], })
|
||||
|
||||
const ge = {}
|
||||
lendingPools.forEach((v, i) => {
|
||||
ge[v] = { aTokens: aTokens[i] }
|
||||
})
|
||||
|
||||
await Promise.all(
|
||||
Object.keys(ge).map(async (pool) => {
|
||||
const aTokens = ge[pool].aTokens;
|
||||
const aTokenAddresses = (await api.multiCall({ abi: getReserveDataAbi, calls: aTokens, target: pool })).map(i => i.aTokenAddress)
|
||||
const bals = (await api.multiCall({ abi: balanceOfAbi, calls: aTokenAddresses.map((v, i) => ({ target: aTokens[i], params: v })) }))
|
||||
const underlyings = await api.multiCall({ abi: getUnderlyingAbi, calls: aTokens.map((v, i) => ({ target: v, params: bals[i] })), permitFailure: true, })
|
||||
const token0s = await api.multiCall({ abi: token0Abi, calls: aTokens, permitFailure: true, })
|
||||
const token1s = await api.multiCall({ abi: token1Abi, calls: aTokens, permitFailure: true, })
|
||||
underlyings.forEach((v, i) => {
|
||||
if (v) {
|
||||
api.add(token0s[i].token, v.token0Amount)
|
||||
api.add(token1s[i].token, v.token1Amount)
|
||||
} else {
|
||||
api.add(aTokens[i], bals[i])
|
||||
}
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
methodology:
|
||||
"Counts the tokens locked in the contracts to be used as collateral to borrow or to earn yield. Borrowed coins are not counted towards the TVL, so only the coins actually locked in the contracts are counted. There's multiple reasons behind this but one of the main ones is to avoid inflating the TVL through cycled lending",
|
||||
arbitrum: { tvl, }
|
||||
};
|
||||
16
projects/groveswap/index.js
Normal file
16
projects/groveswap/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const { getUniTVL } = require('../helper/unknownTokens')
|
||||
const { stakingUnknownPricedLP } = require('../helper/staking')
|
||||
|
||||
module.exports = {
|
||||
misrepresentedTokens: true,
|
||||
bsc: {
|
||||
tvl: getUniTVL({ useDefaultCoreAssets: true, factory: '0x0ed713989f421ff6f702b2e4e1c93b1bb9002119', }),
|
||||
staking: stakingUnknownPricedLP('0x9db65123aa185811e50f8b626a7d4799c39ea4d5', '0xf33893de6eb6ae9a67442e066ae9abd228f5290c', 'bsc', '0xe27f915a8a9ca6c31b193311ae76b8738b926d17'),
|
||||
},
|
||||
ethereum: {
|
||||
tvl: getUniTVL({ useDefaultCoreAssets: true, factory: '0x6c565c5bbdc7f023cae8a2495105a531caac6e54', }),
|
||||
},
|
||||
grove: {
|
||||
tvl: getUniTVL({ useDefaultCoreAssets: true, factory: '0x401e7e28e0C679E1a3242ac6CD93C9c56208A260', }),
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,5 @@ module.exports=ohmTvl("0x8B1522402FECe066d83E0F6C97024248Be3C8c01", [
|
||||
[ADDRESSES.bsc.BUSD, false],
|
||||
["0x5ca063a7e2bebefeb2bdea42158f5b825f0f9ffb", true],
|
||||
["0xa5399084a5f06d308c4527517bbb781c4dce887c", true]
|
||||
], "bsc", "0xe9c178cfdfeb917a46429714e5d51f6d4f296b75", "0x1b239abe619e74232c827fbe5e49a4c072bd869d")
|
||||
], "bsc", "0xe9c178cfdfeb917a46429714e5d51f6d4f296b75", "0x1b239abe619e74232c827fbe5e49a4c072bd869d")
|
||||
module.exports.bsc.tvl = () => 0
|
||||
@@ -1,5 +1,5 @@
|
||||
const { GraphQLClient } = require("graphql-request")
|
||||
const { sumTokens2 } = require('../helper/unwrapLPs')
|
||||
const { cachedGraphQuery } = require("../helper/cache")
|
||||
|
||||
const endpoint = "https://graph-multi-http-hadouken.hadouken.finance/subgraphs/name/balancer-mainnet"
|
||||
|
||||
@@ -8,8 +8,7 @@ const query = `query {
|
||||
}`
|
||||
|
||||
async function tvl(_, _b, _cb, { api, }) {
|
||||
const graphQLClient = new GraphQLClient(endpoint)
|
||||
const { tokens } = await graphQLClient.request(query)
|
||||
const { tokens } = await cachedGraphQuery('haduken-fi-dex', endpoint, query)
|
||||
return sumTokens2({
|
||||
api, owner: '0x4f8bdf24826ebcf649658147756115ee867b7d63', tokens: tokens
|
||||
.filter(i => !i.symbol.startsWith('HDK-'))
|
||||
|
||||
4
projects/hector/api.js
Normal file
4
projects/hector/api.js
Normal file
@@ -0,0 +1,4 @@
|
||||
const index = require('./index')
|
||||
const { ohmStaking } = require('../helper/treasury')
|
||||
|
||||
module.exports = ohmStaking(index)
|
||||
@@ -102,7 +102,7 @@ async function getBorrowed(balances, block, chain, v2ReserveTokens, dataHelper,
|
||||
})
|
||||
}
|
||||
|
||||
function aaveChainTvl(chain, addressesProviderRegistry, transformAddressRaw, dataHelperAddresses, borrowed, v3 = false, { abis = {}, oracle, } = {}) {
|
||||
function aaveChainTvl(chain, addressesProviderRegistry, transformAddressRaw, dataHelperAddresses, borrowed, v3 = false, { abis = {}, oracle, blacklistedTokens = [], } = {}) {
|
||||
return async (timestamp, ethBlock, { [chain]: block }) => {
|
||||
const balances = {}
|
||||
const { transformAddress, fixBalances, v2Atokens, v2ReserveTokens, dataHelper, updateBalances } = await getData({ oracle, chain, block, addressesProviderRegistry, dataHelperAddresses, transformAddressRaw, abis, })
|
||||
@@ -113,13 +113,19 @@ function aaveChainTvl(chain, addressesProviderRegistry, transformAddressRaw, dat
|
||||
}
|
||||
if (updateBalances) updateBalances(balances)
|
||||
fixBalances(balances)
|
||||
Object.keys(balances).forEach((key) => {
|
||||
if (!blacklistedTokens.length) return;
|
||||
if (blacklistedTokens.some(i => new RegExp(i, 'gi').test(key))) {
|
||||
delete balances[key]
|
||||
}
|
||||
})
|
||||
return balances
|
||||
}
|
||||
}
|
||||
function aaveExports(chain, addressesProviderRegistry, transform = undefined, dataHelpers = undefined, { oracle, abis } = {}) {
|
||||
function aaveExports(chain, addressesProviderRegistry, transform = undefined, dataHelpers = undefined, { oracle, abis, v3 = false, blacklistedTokens = [] } = {}) {
|
||||
return {
|
||||
tvl: aaveChainTvl(chain, addressesProviderRegistry, transform, dataHelpers, false, undefined, { oracle, abis, }),
|
||||
borrowed: aaveChainTvl(chain, addressesProviderRegistry, transform, dataHelpers, true, undefined, { oracle, abis })
|
||||
tvl: aaveChainTvl(chain, addressesProviderRegistry, transform, dataHelpers, false, v3, { oracle, abis, blacklistedTokens, }),
|
||||
borrowed: aaveChainTvl(chain, addressesProviderRegistry, transform, dataHelpers, true, v3, { oracle, abis, })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ const aws = require('aws-sdk')
|
||||
const sdk = require('@defillama/sdk')
|
||||
const Bucket = "tvl-adapter-cache";
|
||||
const axios = require('axios')
|
||||
const graphql = require('./utils/graphql')
|
||||
|
||||
function getKey(project, chain) {
|
||||
return `cache/${project}/${chain}.json`
|
||||
@@ -87,6 +88,27 @@ async function configPost(project, endpoint, data) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function cachedGraphQuery(project, endpoint, query, { variables } = {}) {
|
||||
if (!project || !endpoint) throw new Error('Missing parameters')
|
||||
const key = 'config-cache'
|
||||
const cacheKey = getKey(key, project)
|
||||
if (!configCache[cacheKey]) configCache[cacheKey] = _cachedGraphQuery()
|
||||
return configCache[cacheKey]
|
||||
|
||||
async function _cachedGraphQuery() {
|
||||
try {
|
||||
const json = await graphql.request(endpoint, query, { variables })
|
||||
await setCache(key, project, json)
|
||||
return json
|
||||
} catch (e) {
|
||||
// sdk.log(e)
|
||||
sdk.log(project, 'tryng to fetch from cache, failed to fetch data from endpoint:', endpoint)
|
||||
return getCache(key, project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getCache, setCache, getConfig, configPost,
|
||||
getCache, setCache, getConfig, configPost, cachedGraphQuery,
|
||||
}
|
||||
3
projects/helper/cache/uniswap.js
vendored
3
projects/helper/cache/uniswap.js
vendored
@@ -142,7 +142,8 @@ function getUniTVL({ coreAssets, blacklist = [], factory, blacklistedTokens,
|
||||
// if (cache.pairs.includes(null) || cache.token0s.includes(null) || cache.token1s.includes(null))
|
||||
// cache.pairs = undefined
|
||||
}
|
||||
if (!cache.pairs || (hasStablePools && !cache.symbols)) {
|
||||
|
||||
if (!cache.pairs || (hasStablePools && (!cache.symbols || !cache.symbols.length))) {
|
||||
cache = {
|
||||
pairs: [],
|
||||
token0s: [],
|
||||
|
||||
@@ -13,9 +13,9 @@ const assetCache = {}
|
||||
|
||||
const geckoMapping = Object.values(coreAssets.algorand)
|
||||
const axiosObj = axios.create({
|
||||
baseURL: 'https://algoindexer.algoexplorerapi.io',
|
||||
baseURL: "https://mainnet-idx.algonode.cloud",
|
||||
timeout: 300000,
|
||||
})
|
||||
});
|
||||
|
||||
const indexerLimiter = new RateLimiter({ tokensPerInterval: 10, interval: "second" });
|
||||
|
||||
@@ -136,6 +136,8 @@ const tokens = {
|
||||
goUsd: 672913181,
|
||||
usdcGoUsdLp: 885102318,
|
||||
gard: 684649988,
|
||||
gold$: 246516580,
|
||||
silver$: 246519683,
|
||||
}
|
||||
|
||||
// store all asset ids as string
|
||||
|
||||
@@ -10,20 +10,20 @@ const { log } = require("../utils");
|
||||
// https://cosmos-chain.directory/chains/cosmoshub
|
||||
// https://cosmos-chain.directory/chains
|
||||
const endPoints = {
|
||||
|
||||
crescent: "https://mainnet.crescent.network:1317",
|
||||
osmosis: "https://lcd.osmosis.zone",
|
||||
cosmos: "https://cosmoshub-lcd.stakely.io",
|
||||
kujira: "https://lcd.kaiyo.kujira.setten.io",
|
||||
kujira: "https://rest.cosmos.directory/kujira",
|
||||
comdex: "https://rest.comdex.one",
|
||||
terra: "https://terraclassic-lcd-server-01.stakely.io",
|
||||
terra2: "https://phoenix-lcd.terra.dev",
|
||||
umee: "https://umee-api.polkachu.com",
|
||||
orai: "https://lcd.orai.io",
|
||||
juno: "https://lcd-juno.cosmostation.io",
|
||||
cronos: 'https://lcd-crypto-org.cosmostation.io',
|
||||
injective: 'https://lcd-injective.whispernode.com:443',
|
||||
}
|
||||
cronos: "https://lcd-crypto-org.cosmostation.io",
|
||||
injective: "https://lcd-injective.whispernode.com:443",
|
||||
migaloo: "https://migaloo-api.polkachu.com",
|
||||
};
|
||||
|
||||
const chainSubpaths = {
|
||||
crescent: "crescent",
|
||||
@@ -32,7 +32,7 @@ const chainSubpaths = {
|
||||
};
|
||||
|
||||
function getEndpoint(chain) {
|
||||
if (!endPoints[chain]) throw new Error("Chain not found: "+ chain);
|
||||
if (!endPoints[chain]) throw new Error("Chain not found: " + chain);
|
||||
return endPoints[chain];
|
||||
}
|
||||
|
||||
@@ -64,24 +64,27 @@ async function queryV1Beta1({ chain, paginationKey, block, url } = {}) {
|
||||
}
|
||||
|
||||
async function getTokenBalance({ token, owner, block, chain }) {
|
||||
let denom = token.native_token?.denom
|
||||
if (denom) return getDenomBalance({denom, owner, block, chain,})
|
||||
token = token.token.contract_addr
|
||||
return getBalance({ token, owner, block, chain, })
|
||||
let denom = token.native_token?.denom;
|
||||
if (denom) return getDenomBalance({ denom, owner, block, chain });
|
||||
token = token.token.contract_addr;
|
||||
return getBalance({ token, owner, block, chain });
|
||||
}
|
||||
|
||||
function getToken(token) {
|
||||
let denom = token.native_token?.denom
|
||||
return denom ? denom : token.token.contract_addr
|
||||
let denom = token.native_token?.denom;
|
||||
return denom ? denom : token.token.contract_addr;
|
||||
}
|
||||
|
||||
|
||||
async function getBalance({ token, owner, block, chain } = {}) {
|
||||
const data = await queryContract({
|
||||
contract: token,
|
||||
block,
|
||||
chain,
|
||||
data: {
|
||||
balance: { address: owner },
|
||||
},
|
||||
});
|
||||
|
||||
const data = await queryContract({ contract: token, block, chain, data: {
|
||||
balance: { address: owner }
|
||||
}})
|
||||
|
||||
return Number(data.balance);
|
||||
}
|
||||
|
||||
@@ -205,6 +208,7 @@ module.exports = {
|
||||
endPoints,
|
||||
totalSupply,
|
||||
getBalance,
|
||||
getBalance2,
|
||||
getDenomBalance,
|
||||
unwrapLp,
|
||||
query,
|
||||
|
||||
@@ -32,7 +32,7 @@ async function getOrders({ type = TYPES.SPOT, marketIds }) {
|
||||
const chunks = sliceIntoChunks(marketIds, 20)
|
||||
const response = []
|
||||
for (const chunk of chunks)
|
||||
response.push(...await getClient(type).fetchOrderbooks(chunk))
|
||||
response.push(...await getClient(type).fetchOrderbooksV2(chunk))
|
||||
return response
|
||||
}
|
||||
|
||||
@@ -42,4 +42,4 @@ module.exports = {
|
||||
p2j,
|
||||
getMarkets,
|
||||
getOrders,
|
||||
}
|
||||
}
|
||||
|
||||
143
projects/helper/chain/sui.js
Normal file
143
projects/helper/chain/sui.js
Normal file
@@ -0,0 +1,143 @@
|
||||
|
||||
const sdk = require('@defillama/sdk')
|
||||
|
||||
const http = require('../http')
|
||||
const env = require('../env')
|
||||
const { transformDexBalances } = require('../portedTokens')
|
||||
const { sliceIntoChunks } = require('../utils')
|
||||
|
||||
//https://docs.sui.io/sui-jsonrpc
|
||||
|
||||
const endpoint = env.SUI_RPC || "https://fullnode.mainnet.sui.io/"
|
||||
|
||||
async function getObject(objectId) {
|
||||
return (await call('sui_getObject', [objectId, {
|
||||
"showType": true,
|
||||
"showOwner": true,
|
||||
"showContent": true,
|
||||
}])).content
|
||||
}
|
||||
|
||||
async function queryEvents({ eventType, transform = i => i }) {
|
||||
let filter = {}
|
||||
if (eventType) filter.MoveEventType = eventType
|
||||
const items = []
|
||||
let cursor = null
|
||||
do {
|
||||
const { data , nextCursor, hasNextPage } = await call('suix_queryEvents', [filter, cursor], { withMetadata: true, })
|
||||
cursor = hasNextPage ? nextCursor : null
|
||||
items.push(...data)
|
||||
} while (cursor)
|
||||
return items.map(i => i.parsedJson).map(transform)
|
||||
}
|
||||
|
||||
async function getObjects(objectIds) {
|
||||
if (objectIds.length > 49) {
|
||||
const chunks = sliceIntoChunks(objectIds, 49)
|
||||
const res = []
|
||||
for (const chunk of chunks) res.push(...(await getObjects(chunk)))
|
||||
return res
|
||||
}
|
||||
const {
|
||||
result
|
||||
} = await http.post(endpoint, {
|
||||
jsonrpc: "2.0", id: 1, method: 'sui_multiGetObjects', params: [objectIds, {
|
||||
"showType": true,
|
||||
"showOwner": true,
|
||||
"showContent": true,
|
||||
}],
|
||||
})
|
||||
return objectIds.map(i => result.find(j => j.data.objectId === i)?.data?.content)
|
||||
}
|
||||
|
||||
async function getDynamicFieldObject(parent, id) {
|
||||
return (await call('suix_getDynamicFieldObject', [parent, {
|
||||
"type": "0x2::object::ID",
|
||||
"value": id
|
||||
}])).content
|
||||
}
|
||||
|
||||
async function getDynamicFieldObjects({ parent, cursor = null, limit = 48, items = [], idFilter = i => i, addedIds = new Set() }) {
|
||||
const {
|
||||
result: { data, hasNextPage, nextCursor }
|
||||
} = await http.post(endpoint, { jsonrpc: "2.0", id: 1, method: 'suix_getDynamicFields', params: [parent, cursor, limit], })
|
||||
sdk.log('[sui] fetched items length', data.length, hasNextPage, nextCursor)
|
||||
const fetchIds = data.filter(idFilter).map(i => i.objectId).filter(i => !addedIds.has(i))
|
||||
fetchIds.forEach(i => addedIds.add(i))
|
||||
const objects = await getObjects(fetchIds)
|
||||
items.push(...objects)
|
||||
if (!hasNextPage) return items
|
||||
return getDynamicFieldObjects({ parent, cursor: nextCursor, items, limit, idFilter, addedIds })
|
||||
}
|
||||
|
||||
async function call(method, params, { withMetadata = false} = {}) {
|
||||
if (!Array.isArray(params)) params = [params]
|
||||
const {
|
||||
result
|
||||
} = await http.post(endpoint, { jsonrpc: "2.0", id: 1, method, params, })
|
||||
return withMetadata ? result : result.data
|
||||
}
|
||||
|
||||
async function multiCall(calls) {
|
||||
return Promise.all(calls.map(i => call(...i)))
|
||||
}
|
||||
|
||||
|
||||
function dexExport({
|
||||
account,
|
||||
poolStr,
|
||||
token0Reserve = i => i.fields.coin_x_reserve,
|
||||
token1Reserve = i => i.fields.coin_y_reserve,
|
||||
getTokens = i => i.type.split('<')[1].replace('>', '').split(', '),
|
||||
isAMM = true,
|
||||
eventType,
|
||||
eventTransform,
|
||||
}) {
|
||||
return {
|
||||
timetravel: false,
|
||||
misrepresentedTokens: true,
|
||||
sui: {
|
||||
tvl: async (_, _1, _2, { api }) => {
|
||||
const data = []
|
||||
let pools
|
||||
if (!eventType) {
|
||||
pools = await getDynamicFieldObjects({ parent: account, idFilter: i => poolStr ? i.objectType.includes(poolStr) : i })
|
||||
} else {
|
||||
pools = await queryEvents({ eventType, transform: eventTransform })
|
||||
pools = await getObjects(pools)
|
||||
}
|
||||
sdk.log(`[sui] Number of pools: ${pools.length}`)
|
||||
pools.forEach(i => {
|
||||
const [token0, token1] = getTokens(i)
|
||||
if (isAMM) {
|
||||
data.push({
|
||||
token0,
|
||||
token1,
|
||||
token0Bal: token0Reserve(i),
|
||||
token1Bal: token1Reserve(i),
|
||||
})
|
||||
} else {
|
||||
api.add(token0, token0Reserve(i))
|
||||
api.add(token1, token1Reserve(i))
|
||||
}
|
||||
})
|
||||
|
||||
if (!isAMM) return api.getBalances()
|
||||
|
||||
return transformDexBalances({ chain: 'sui', data })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
endpoint,
|
||||
call,
|
||||
multiCall,
|
||||
getObject,
|
||||
getObjects,
|
||||
queryEvents,
|
||||
getDynamicFieldObject,
|
||||
getDynamicFieldObjects,
|
||||
dexExport,
|
||||
};
|
||||
@@ -50,7 +50,9 @@ async function getDenomBalance(denom, owner, block, { isTerra2 = false } = {}) {
|
||||
if (block !== undefined) {
|
||||
endpoint += `?height=${block - (block % 100)}`
|
||||
}
|
||||
const data = (await axios.get(endpoint)).data.result
|
||||
let {data} = (await axios.get(endpoint));
|
||||
if (isTerra2) data = data.balances
|
||||
else data = data.result
|
||||
|
||||
const balance = data.find(balance => balance.denom === denom);
|
||||
return balance ? Number(balance.amount) : 0
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
"godwoken",
|
||||
"godwoken_v1",
|
||||
"goerli",
|
||||
"grove",
|
||||
"harmony",
|
||||
"heco",
|
||||
"hedera",
|
||||
@@ -111,6 +112,7 @@
|
||||
"meta",
|
||||
"meter",
|
||||
"metis",
|
||||
"migaloo",
|
||||
"milkomeda",
|
||||
"milkomeda_a1",
|
||||
"mixin",
|
||||
@@ -172,6 +174,7 @@
|
||||
"stellar",
|
||||
"step",
|
||||
"stride",
|
||||
"sui",
|
||||
"sx",
|
||||
"syscoin",
|
||||
"telos",
|
||||
|
||||
@@ -153,6 +153,7 @@
|
||||
"DOGE": "0x40280e26a572745b1152a54d1d44f365daa51618",
|
||||
"TUSD": "0x5ee41ab6edd38cdfb9f6b4e6cf7f75c87e170d98",
|
||||
"XRP": "0xa2f3c2446a3e20049708838a779ff8782ce6645a",
|
||||
"USDT": "0xa71edc38d189767582c38a3145b5873052c3e47a",
|
||||
"ADA": "0x843af718ef25708765a8e0942f89edeae1d88df0"
|
||||
},
|
||||
"hoo": {
|
||||
@@ -887,6 +888,7 @@
|
||||
"songbird": {
|
||||
"WSGB": "0x02f0826ef6ad107cfc861152b32b52fd11bab9ed",
|
||||
"CAND": "0x70ad7172ef0b131a1428d0c1f66457eb041f2176",
|
||||
"SFIN": "0x0D94e59332732D18CF3a3D457A8886A2AE29eA1B",
|
||||
"EXFI": "0xc348f894d0e939fe72c467156e6d7dcbd6f16e21"
|
||||
},
|
||||
"energi": {
|
||||
@@ -1075,6 +1077,7 @@
|
||||
"WWEMIX": "0x7d72b22a74a216af4a002a1095c8c707d6ec1c5f",
|
||||
"WEMIX_": "0x8e81fcc2d4a3baa0ee9044e0d7e36f59c9bba9c1",
|
||||
"KLAY": "0x461d52769884ca6235b685ef2040f47d30c94eb5",
|
||||
"ETH": "0x765277EebeCA2e31912C9946eAe1021199B39C61",
|
||||
"USDC": "0xe3f5a90f9cb311505cd691a46596599aa1a0ad7d"
|
||||
},
|
||||
"tlchain": {
|
||||
@@ -1240,5 +1243,25 @@
|
||||
},
|
||||
"enuls": {
|
||||
"WNULS": "0x217dffF57E3b855803CE88a1374C90759Ea071bD"
|
||||
},
|
||||
"sui": {
|
||||
"USDC": "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",
|
||||
"CELO": "0xa198f3be41cda8c07b3bf3fee02263526e535d682499806979a111e88a5a8d0f::coin::COIN",
|
||||
"WMATIC": "0xdbe380b13a6d0f5cdedd58de8f04625263f113b3f9db32b3e1983f49e2841676::coin::COIN",
|
||||
"BNB": "0xb848cce11ef3a8f62eccea6eb5b35a12c4c2b1ee1af7755d02d7bd6218e8226f::coin::COIN",
|
||||
"WETH": "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN",
|
||||
"USDT": "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN",
|
||||
"WBTC": "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN",
|
||||
"WAVAX": "0x1e8b532cca6569cab9f9b9ebc73f8c13885012ade714729aa3b450e0339ac766::coin::COIN",
|
||||
"WFTM": "0x6081300950a4f1e2081580e919c210436a1bed49080502834950d31ee55a2396::coin::COIN",
|
||||
"WGLMR": "0x66f87084e49c38f76502d17f87d17f943f183bb94117561eb573e075fdc5ff75::coin::COIN",
|
||||
"SOL": "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8::coin::COIN",
|
||||
"USDC_SOL": "0xb231fcda8bbddb31f2ef02e6161444aec64a514e2c89279584ac9806ce9cf037::coin::COIN",
|
||||
"USDC_ARB": "0xe32d3ebafa42e6011b87ef1087bbc6053b499bf6f095807b9013aff5a6ecd7bb::coin::COIN",
|
||||
"USDC_BNB": "0x909cba62ce96d54de25bec9502de5ca7b4f28901747bbf96b76c2e63ec5f1cba::coin::COIN",
|
||||
"SUI": "0x2::sui::SUI"
|
||||
},
|
||||
"grove": {
|
||||
"WGRV": "0xE85f139488c689038028a3EB8fC38dcC29D4C340"
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ module.exports = {
|
||||
GETBLOCK_KEY: env.GETBLOCK_KEY,
|
||||
SOLANA_RPC: env.SOLANA_RPC,
|
||||
APTOS_RPC: env.APTOS_RPC,
|
||||
SUI_RPC: env.SUI_RPC,
|
||||
TERRA_RPC: env.TERRA_RPC,
|
||||
TERRA2_RPC: env.TERRA2_RPC,
|
||||
LOFTY_API: env.LOFTY_API,
|
||||
|
||||
@@ -17,7 +17,7 @@ coreAssets = JSON.parse(JSON.stringify(coreAssets))
|
||||
// orbit brige: https://bridge.orbitchain.io/open/v1/api/monitor/rawTokenList
|
||||
|
||||
const ibcChains = ['ibc', 'terra', 'terra2', 'crescent', 'osmosis', 'kujira', 'stargaze', 'juno', 'injective', 'cosmos', 'comdex', 'stargaze', 'umee', 'orai', 'persistence', ]
|
||||
const caseSensitiveChains = [...ibcChains, 'solana', 'tezos', 'ton', 'algorand', 'aptos', 'near', 'bitcoin', 'waves', 'tron', 'litecoin', 'polkadot', 'ripple', 'elrond', 'cardano', 'stacks']
|
||||
const caseSensitiveChains = [...ibcChains, 'solana', 'tezos', 'ton', 'algorand', 'aptos', 'near', 'bitcoin', 'waves', 'tron', 'litecoin', 'polkadot', 'ripple', 'elrond', 'cardano', 'stacks', 'sui']
|
||||
|
||||
const distressedAssts = new Set(Object.values({
|
||||
CRK: '0x065de42e28e42d90c2052a1b49e7f83806af0e1f',
|
||||
@@ -27,6 +27,9 @@ const distressedAssts = new Set(Object.values({
|
||||
}).map(i => i.toLowerCase()))
|
||||
|
||||
const transformTokens = {
|
||||
ethereum: {
|
||||
'0xe0b469cb3eda0ece9e425cfeda4df986a55ea9f8': '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
|
||||
}
|
||||
// Sample Code
|
||||
// cronos: {
|
||||
// "0x065de42e28e42d90c2052a1b49e7f83806af0e1f": "0x123", // CRK token is mispriced
|
||||
|
||||
@@ -51,8 +51,37 @@ async function getComplexTreasury(owners){
|
||||
return sum
|
||||
}
|
||||
|
||||
function ohmStaking(exports) {
|
||||
const dummyTvl = () => ({})
|
||||
const newExports = {}
|
||||
Object.entries(exports).forEach(([chain, value]) => {
|
||||
if (typeof value === 'object' && typeof value.tvl === 'function') {
|
||||
newExports[chain] = { ...value, tvl: dummyTvl}
|
||||
} else {
|
||||
newExports[chain] = value
|
||||
}
|
||||
})
|
||||
return newExports
|
||||
}
|
||||
|
||||
function ohmTreasury(exports) {
|
||||
const dummyTvl = () => ({})
|
||||
const newExports = {}
|
||||
Object.entries(exports).forEach(([chain, value]) => {
|
||||
if (typeof value === 'object' && typeof value.staking === 'function') {
|
||||
newExports[chain] = { ...value,}
|
||||
delete newExports[chain].staking
|
||||
} else {
|
||||
newExports[chain] = value
|
||||
}
|
||||
})
|
||||
return newExports
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
nullAddress,
|
||||
treasuryExports,
|
||||
getComplexTreasury
|
||||
getComplexTreasury,
|
||||
ohmTreasury,
|
||||
ohmStaking,
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ function uniV3Export(config) {
|
||||
const exports = {}
|
||||
|
||||
Object.keys(config).forEach(chain => {
|
||||
let { factory: target, fromBlock, topics, eventAbi, isAlgebra } = config[chain]
|
||||
let { factory: target, fromBlock, topics, eventAbi, isAlgebra, blacklistedTokens = [] } = config[chain]
|
||||
if (!topics) topics = isAlgebra ? algebraConfig.topics : uniswapConfig.topics
|
||||
if (!eventAbi) eventAbi = isAlgebra ? algebraConfig.eventAbi : uniswapConfig.eventAbi
|
||||
|
||||
@@ -31,7 +31,7 @@ function uniV3Export(config) {
|
||||
onlyArgs: true,
|
||||
})
|
||||
|
||||
return sumTokens2({ api, ownerTokens: logs.map(i => [[i.token0, i.token1], i.pool]), })
|
||||
return sumTokens2({ api, ownerTokens: logs.map(i => [[i.token0, i.token1], i.pool]), blacklistedTokens, })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -367,7 +367,7 @@ tokensAndOwners [
|
||||
[token, owner] - eg ["0xaaa", "0xbbb"]
|
||||
]
|
||||
*/
|
||||
async function sumTokens(balances = {}, tokensAndOwners, block, chain = "ethereum", transformAddress, { resolveLP = false, unwrapAll = false, blacklistedLPs = [], skipFixBalances = false, abis = {}, ignoreFailed = false } = {}) {
|
||||
async function sumTokens(balances = {}, tokensAndOwners, block, chain = "ethereum", transformAddress, { resolveLP = false, unwrapAll = false, blacklistedLPs = [], skipFixBalances = false, abis = {}, permitFailure = false } = {}) {
|
||||
if (!transformAddress)
|
||||
transformAddress = await getChainTransform(chain)
|
||||
|
||||
@@ -393,6 +393,7 @@ async function sumTokens(balances = {}, tokensAndOwners, block, chain = "ethereu
|
||||
target: t[0],
|
||||
params: t[1]
|
||||
})),
|
||||
permitFailure,
|
||||
abi: 'erc20:balanceOf',
|
||||
block,
|
||||
chain
|
||||
@@ -402,7 +403,7 @@ async function sumTokens(balances = {}, tokensAndOwners, block, chain = "ethereu
|
||||
let balance = BigNumber(result.output)
|
||||
if (result.output === null || isNaN(+result.output)) {
|
||||
sdk.log('failed for', token, balance, balances[token])
|
||||
if (ignoreFailed) balance = BigNumber(0)
|
||||
if (permitFailure) balance = BigNumber(0)
|
||||
else throw new Error('Unable to fetch balance for: ' + result.input.target)
|
||||
}
|
||||
balances[token] = BigNumber(balances[token] || 0).plus(balance).toFixed(0)
|
||||
@@ -499,6 +500,16 @@ async function genericUnwrapCvx(balances, holder, cvx_BaseRewardPool, block, cha
|
||||
return balances
|
||||
}
|
||||
|
||||
async function genericUnwrapCvxDeposit({ api, owner, token, balances }) {
|
||||
if (!balances) balances = await api.getBalances()
|
||||
const [bal, cToken ] = await api.batchCall([
|
||||
{ target: token, params: owner, abi: 'erc20:balanceOf' },
|
||||
{ target: token, abi: 'address:curveToken' },
|
||||
])
|
||||
sdk.util.sumSingleBalance(balances, cToken, bal, api.chain)
|
||||
return balances
|
||||
}
|
||||
|
||||
async function unwrapLPsAuto({ api, balances, block, chain = "ethereum", transformAddress, excludePool2 = false, onlyPool2 = false, pool2Tokens = [], blacklistedLPs = [], abis = {}, }) {
|
||||
if (api) {
|
||||
chain = api.chain ?? chain
|
||||
@@ -627,7 +638,7 @@ async function sumTokens2({
|
||||
resolveUniV3 = false,
|
||||
resolveArtBlocks = false,
|
||||
resolveNFTs = false,
|
||||
ignoreFailed = false,
|
||||
permitFailure = false,
|
||||
}) {
|
||||
if (api) {
|
||||
chain = api.chain ?? chain
|
||||
@@ -675,7 +686,7 @@ async function sumTokens2({
|
||||
tokensAndOwners = getUniqueToA(tokensAndOwners)
|
||||
log(chain, 'summing tokens', tokensAndOwners.length)
|
||||
|
||||
await sumTokens(balances, tokensAndOwners, block, chain, transformAddress, { resolveLP, unwrapAll, blacklistedLPs, skipFixBalances: true, abis, ignoreFailed, })
|
||||
await sumTokens(balances, tokensAndOwners, block, chain, transformAddress, { resolveLP, unwrapAll, blacklistedLPs, skipFixBalances: true, abis, permitFailure, })
|
||||
|
||||
if (!skipFixBalances) {
|
||||
const fixBalances = await getFixBalances(chain)
|
||||
@@ -750,4 +761,5 @@ module.exports = {
|
||||
unwrapBalancerToken,
|
||||
unwrapBalancerPool,
|
||||
sumTokensExport,
|
||||
genericUnwrapCvxDeposit,
|
||||
}
|
||||
|
||||
8
projects/helper/utils/graphql.js
Normal file
8
projects/helper/utils/graphql.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const axios = require("axios");
|
||||
|
||||
async function request(endpoint, query, { variables, withMetadata = false } = {}) {
|
||||
const { data: result } = await axios.post(endpoint, { query, variables })
|
||||
return withMetadata ? result : result.data
|
||||
}
|
||||
|
||||
module.exports = { request }
|
||||
14
projects/holdstation/index.js
Normal file
14
projects/holdstation/index.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const { sumTokens2 } = require("../helper/unwrapLPs");
|
||||
|
||||
const vault = "0xaf08a9d918f16332F22cf8Dc9ABE9D9E14DdcbC2";
|
||||
const usdc = "0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4";
|
||||
|
||||
async function tvl(_, _b, _cb, { api }) {
|
||||
return sumTokens2({ api, tokens: [usdc], owners: [vault] });
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
era: {
|
||||
tvl,
|
||||
},
|
||||
};
|
||||
7
projects/hydradex-v3/api.js
Normal file
7
projects/hydradex-v3/api.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const { getExports } = require('../helper/heroku-api')
|
||||
|
||||
module.exports = {
|
||||
timetravel: false,
|
||||
misrepresentedTokens: true,
|
||||
...getExports("hydradex-v3", ['hydra']),
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user