Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hoomp3/DefiLlama-Adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
hoomp3 committed May 13, 2024
2 parents 094756a + c8ae1d8 commit 72f1364
Show file tree
Hide file tree
Showing 57 changed files with 901 additions and 301 deletions.
47 changes: 23 additions & 24 deletions package-lock.json

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

163 changes: 46 additions & 117 deletions projects/a51-finance-v3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,133 +9,62 @@ const A51 = "0xe9e7c09e82328c3107d367f6c617cf9977e63ed0";
const getStrategiesDetails = "function strategies(bytes32) view returns ( tuple(address pool, int24 tickLower, int24 tickUpper) key, address owner, bytes actions, bytes actionStatus, bool isCompound, bool isPrivate, uint256 managementFee, uint256 performanceFee, tuple(uint256 fee0, uint256 fee1, uint256 balance0, uint256 balance1, uint256 totalShares, uint128 uniswapLiquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128) account)"
const getStrategyReserves = "function getStrategyReserves(address, int24, int24, uint128) returns (uint256 reserves0, uint256 reserves1)"

const ADDRESSES = {
arbitrum: {
CLTBASE: "0x3e0aa2e17fe3e5e319f388c794fdbc3c64ef9da6",
HELPER: "0x9d80597d9403bdb35b3d7d9f400377e790b01053",
},
blast: {
CLTBASE: "0x5a8e82c4b3Dbd7579fD198A3276cF75CEA2Df63D",
HELPER: "0xbA13be69628d12963b28de8E7Ba04C3C4c1eaceA",
},
base: {
CLTBASE: "0x3e0AA2e17FE3E5e319f388C794FdBC3c64Ef9da6",
HELPER: "0xA1d8180F4482359CEb7Eb7437FCf4a2616830F81",
},
optimism: {
CLTBASE: "0x525c80e91efe9222de3eae86af69a480fbced416",
HELPER: "0x965356eb2c208ce4130e267342ca720042cce7b2",
},
polygon: {
CLTBASE: "0xD4798F142FDb87738eF4eBE82Bd56Eccde19A88C",
HELPER: "0x9c225a02426e3229C073A6132E083561e95000b5",
},
bsc: {
CLTBASE: "0x6F2b186e9392042B1edE2D1D1706a3DC4a4725d8",
HELPER: "0x9c225a02426e3229C073A6132E083561e95000b5",
},
scroll: {
CLTBASE: "0xA8Dc31c8C9F93dB2e42A5472F580689794639576",
HELPER: "0x965356eb2C208Ce4130E267342cA720042Cce7b2",
},
manta: {
CLTBASE: "0x69317029384c3305fC04670c68a2b434e2D8C44C",
HELPER: "0xa1d8180f4482359ceb7eb7437fcf4a2616830f81",
},
}

const DEFAULT_STRATEGY_CREATION_TOPIC = "StrategyCreated(bytes32)"

const START_BLOCKS = {
arbitrum: {
CLTBASE: 190945156,
},
blast: {
CLTBASE: 1709947,
},
base: {
CLTBASE: 12765695,
},
optimism: {
CLTBASE: 118360616,
},
polygon: {
CLTBASE: 55506149,
},
bsc: {
CLTBASE: 37623104,
},
scroll: {
CLTBASE: 4846051,
},
manta: {
CLTBASE: 1834975,
},
const config = {
arbitrum: [{ target: "0x3e0aa2e17fe3e5e319f388c794fdbc3c64ef9da6", helper: "0x9d80597d9403bdb35b3d7d9f400377e790b01053", startBlock: 190945156 },],
blast: [{ target: "0x5a8e82c4b3Dbd7579fD198A3276cF75CEA2Df63D", helper: "0xbA13be69628d12963b28de8E7Ba04C3C4c1eaceA", startBlock: 1709947 },],
base: [
{ target: "0x3e0AA2e17FE3E5e319f388C794FdBC3c64Ef9da6", helper: "0xA1d8180F4482359CEb7Eb7437FCf4a2616830F81", startBlock: 12765695 },
{ target: "0xDFb179526ae303Eea49AC99DD360159C39105828", helper: "0x6e7e838E20ED6657Aaf1166f9B7a845565956F51", startBlock: 13890566 },
],
optimism: [{ target: "0x525c80e91efe9222de3eae86af69a480fbced416", helper: "0x965356eb2c208ce4130e267342ca720042cce7b2", startBlock: 118360616 },],
polygon: [{ target: "0xD4798F142FDb87738eF4eBE82Bd56Eccde19A88C", helper: "0x9c225a02426e3229C073A6132E083561e95000b5", startBlock: 55506149 },],
bsc: [{ target: "0x6F2b186e9392042B1edE2D1D1706a3DC4a4725d8", helper: "0x9c225a02426e3229C073A6132E083561e95000b5", startBlock: 37623104 },],
scroll: [{ target: "0xA8Dc31c8C9F93dB2e42A5472F580689794639576", helper: "0x965356eb2C208Ce4130E267342cA720042Cce7b2", startBlock: 4846051 },],
manta: [{ target: "0x69317029384c3305fC04670c68a2b434e2D8C44C", helper: "0xa1d8180f4482359ceb7eb7437fcf4a2616830f81", startBlock: 1834975 },],
}

async function getStrategiesLogs(strategies, factoryType, api) {
const chain = api.chain
let topic = DEFAULT_STRATEGY_CREATION_TOPIC
module.exports = {
doublecounted: true,
}

const strategyLogs = await getLogs({
target: ADDRESSES[chain][factoryType],
topic,
fromBlock: START_BLOCKS[chain][factoryType],
api,
})
Object.keys(config).forEach(chain => {
const configs = config[chain]
module.exports[chain] = {
tvl: async (api) => {
await Promise.all(configs.map(addConfigTvl))

for (let log of strategyLogs)
strategies.push(log.topics[1])
async function addConfigTvl({ target, helper, startBlock, topic = DEFAULT_STRATEGY_CREATION_TOPIC }) {
const strategyLogs = await getLogs({ target, topic, fromBlock: startBlock, api, })
const strategies = strategyLogs.map(log => log.topics[1])

return strategies
}
const pools = []
const reservesCalls = []

async function tvl(api) {
const chain = api.chain
const strategies = []
const pools = []
const reservesCalls = []

for (const label of Object.keys(START_BLOCKS[api.chain]))
await getStrategiesLogs(strategies, label, api)

const strategyDetails = await api.multiCall({
abi: getStrategiesDetails,
target: ADDRESSES[chain].CLTBASE,
calls: strategies,
})

strategyDetails.forEach(({ key: { pool, tickLower, tickUpper }, account }) => {
pools.push(pool)

reservesCalls.push({
target: ADDRESSES[chain].HELPER,
params: [pool, Number(tickLower), Number(tickUpper), account.uniswapLiquidity,],
})
})

const [token0s, token1s, reserves] = await Promise.all([
api.multiCall({ abi: 'address:token0', calls: pools, }),
api.multiCall({ abi: 'address:token1', calls: pools, }),
api.multiCall({ abi: getStrategyReserves, calls: reservesCalls, target: ADDRESSES[chain].HELPER, }),
])

reserves.forEach((reserve, index) => {
api.add(token0s[index], reserve.reserves0)
api.add(token1s[index], reserve.reserves1)
})

return sumTokens2({ owner: ADDRESSES[chain].CLTBASE, tokens: token0s.concat(token1s), api, })
}
const strategyDetails = await api.multiCall({ abi: getStrategiesDetails, target, calls: strategies, })

module.exports = {
doublecounted: true,
}
strategyDetails.forEach(({ key: { pool, tickLower, tickUpper }, account }) => {
pools.push(pool)

Object.keys(ADDRESSES).forEach((chain) => {
module.exports[chain] = { tvl }
})
reservesCalls.push({ params: [pool, Number(tickLower), Number(tickUpper), account.uniswapLiquidity,], })
})

if (!module.exports.polygon) module.exports.polygon = {}
const [token0s, token1s, reserves] = await Promise.all([
api.multiCall({ abi: 'address:token0', calls: pools, }),
api.multiCall({ abi: 'address:token1', calls: pools, }),
api.multiCall({ abi: getStrategyReserves, calls: reservesCalls, target: helper, }),
])

reserves.forEach((reserve, index) => {
api.add(token0s[index], reserve.reserves0)
api.add(token1s[index], reserve.reserves1)
})

return sumTokens2({ owner: target, tokens: token0s.concat(token1s), api, })
}
}
}
})

module.exports.polygon.staking = staking(A51_STAKING_CONTRACT, A51)
1 change: 1 addition & 0 deletions projects/abstraDex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const config = {
zkfair: '0x174c4C03DfeA09682728A5959A253bf1F7C7766F',
zeta: '0x174c4C03DfeA09682728A5959A253bf1F7C7766F',
blast: '0xA7afB6163c331DDb0845843889D6f9544328846F',
cyeth: '0x174c4c03dfea09682728a5959a253bf1f7c7766f',
}

module.exports = {
Expand Down
16 changes: 16 additions & 0 deletions projects/apestore/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { sumTokensExport } = require("../helper/unwrapLPs");
const coreAssets = require("../helper/coreAssets.json");

const routers = [
"0xF6Af6C034E92694A4c79569B03543d580df402D7",
"0x992D40d9ED8937Bb0Ad3c0Ba99713072Ae0a05b3",
"0x135De7F9223C76b7d0278FFe854eC480D37FE906"
];

const tokens = [coreAssets.null];

module.exports = {
base: {
tvl: sumTokensExport({ owners: routers, tokens })
},
};
3 changes: 2 additions & 1 deletion projects/avalon-finance/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

const { aaveExports } = require('../helper/aave')
const { aaveExports } = require('../helper/aave')
const methodologies = require('../helper/methodologies')
const { mergeExports } = require('../helper/utils')

Expand All @@ -8,6 +8,7 @@ const mainMarket = {
}
const innovativeMarket = {
merlin: aaveExports('', '0x91b212e9FaF20117Eae59d6289CB38749DDFc070', undefined, ['0x883cb2E2d9c5D4D9aF5b0d37fc39Fa2284405682'], { v3: true }),
btr: aaveExports('', '0x6aB5d5E96aC59f66baB57450275cc16961219796', undefined, ['0x5F314b36412765f3E1016632fD1Ad528929536CA'], { v3: true }),
}

module.exports = mergeExports(mainMarket, innovativeMarket)
Expand Down
1 change: 1 addition & 0 deletions projects/becoswap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
tvl: getUniTVL({
useDefaultCoreAssets: true,
factory: '0x58b54BCDF2aF8a70dD6433EB39b308148261bB49',
blacklistedTokens: ['0x551a5dcac57c66aa010940c2dcff5da9c53aa53b']
})
},
};
27 changes: 27 additions & 0 deletions projects/bitcow/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { sumTokens2 } = require('../helper/unwrapLPs')

const config = {
btr: { pairInfo: '0xb6d73e9a9cf70ddf396afcd677fdafe7073aa026' },
}

Object.keys(config).forEach(chain => {
const { pairInfo } = config[chain]
module.exports[chain] = {
tvl: async (api) => {
let pairs = []
let hasMore = true
let length = 999
let offset = 0
do {
const { pagePairs, } = await api.call({ abi: 'function fetchPairsAddressListPaginate(uint256 start, uint256 end) view returns (address[] pagePairs, uint256 pairCount)', target: pairInfo, params: [offset, length] })
pairs = pairs.concat(pagePairs)
offset += length
hasMore = pagePairs.length === length
} while (hasMore)
const tokenXs = await api.multiCall({ abi: 'address:xToken', calls: pairs })
const tokenYs = await api.multiCall({ abi: 'address:yToken', calls: pairs })
const tokensAndOwners2 = [tokenXs.concat(tokenYs), pairs.concat(pairs)]
return sumTokens2({ tokensAndOwners2, api })
}
}
})
30 changes: 30 additions & 0 deletions projects/bitsmiley-io/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { sumTokens2, } = require('../helper/unwrapLPs')

async function tvl(api) {

return sumTokens2({ owners: [
'0x37fc73b4dda9f7263926590838e32e05e4e051e9',
], tokens: ['0xff204e2681a6fa0e2c3fade68a1b28fb90e4fc5f'], api, })
}

module.exports = {
btr: { tvl, }
}
/*
const config = {
btr: { query: '0x3622a84D5861d25aA064512E3F244Dd8e67Dc22B', },
}
const abis = {
"listCollaterals": "function listCollaterals() view returns ((string name, uint256 maxLTV, uint256 liquidationFeeRate, uint256 stabilityFeeRate, bytes32 collateralId, (address tokenAddress, uint256 safetyFactor, uint256 totalDebt, uint256 totalLocked, uint256 vaultMaxDebt, uint256 vaultMinDebt, uint256 maxDebt) collateral)[] collateralInfos)",
}
Object.keys(config).forEach(chain => {
const { query,} = config[chain]
module.exports[chain] = {
tvl: async (api) => {
const res = await api.call({ abi: abis.listCollaterals, target: query})
res.forEach(({ collateral}) => api.add(collateral.tokenAddress, collateral.totalLocked))
}
}
}) */
Loading

0 comments on commit 72f1364

Please sign in to comment.