Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDanr authored Jun 28, 2024
2 parents 2ae9d7c + 4a5ae79 commit ddfbcc6
Show file tree
Hide file tree
Showing 158 changed files with 2,851 additions and 585 deletions.
36 changes: 18 additions & 18 deletions package-lock.json

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

1 change: 1 addition & 0 deletions projects/SecuredFinance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const config = {
tokenVault: '0x0896AC8B9e2DC3545392ff65061E5a8a3eD68824',
currencyController: '0x9E1254292195F241FA2DF1aA51af23796627A74B',
},
filecoin: {}
};

Object.keys(config).forEach(chain => {
Expand Down
5 changes: 4 additions & 1 deletion projects/agentfi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ const { getTvlForLooperWithOrbit } = require('./strategies/looper')
const { getTvlForDexBalancer } = require('./strategies/dex-balancer')
const { sumTokens2, nullAddress } = require("../helper/unwrapLPs");
const { getAllAgent } = require("./utils");
const { getTvlForBladeSwapCLM } = require("./strategies/bladeswap");


async function tvl(api) {
const allAgents = await getAllAgent(api)
const allAgentsAddress = allAgents.map(i => i.agentAddress)
const dexBalancerAgents = allAgents.filter(i => i.moduleType === "DexBalancer")
const concentratedLiquidityAgents = allAgents.filter(i => i.moduleType === "ConcentratedLiquidity")
const bladeSwapConcentratedLiquidityAgentAddresses = allAgents.filter(i => i.moduleType === "BladeSwapLiquidityManager").map(i => i.agentAddress)
const looperAgentsAddresses = allAgents.filter(i => i.moduleType === "Looper").map(i => i.agentAddress)


Expand All @@ -23,7 +25,8 @@ async function tvl(api) {


await getTvlForDexBalancer(dexBalancerAgents.map(i => i.agentAddress), api)
await getTvlForLooperWithOrbit(looperAgentsAddresses, api)
await getTvlForLooperWithOrbit(looperAgentsAddresses, api)
await getTvlForBladeSwapCLM(bladeSwapConcentratedLiquidityAgentAddresses, api)
await sumTokens2({
tokensAndOwners: [
...thrusterv2,
Expand Down
56 changes: 56 additions & 0 deletions projects/agentfi/strategies/bladeswap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
async function getTvlForBladeSwapCLM(agentAddresses, api) {
const calls = agentAddresses.map(agent => ({
target: agent, params: []
}))

const safelyGetStateOfAMMPromise = api.multiCall({
abi: 'function safelyGetStateOfAMM() view returns (uint160 sqrtPrice, int24 tick, uint16 lastFee, uint8 pluginConfig, uint128 activeLiquidity, int24 nextTick, int24 previousTick)',
calls: calls,
withMetadata: true,
permitFailure: true,
})
const positionPromise = api.multiCall({
abi: 'function position() view returns (uint96 nonce, address operator, address token0, address token1, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)',
calls: calls,
withMetadata: true,
permitFailure: true,
})
const [positionData, safelyGetStateOfAMMData] = await Promise.all([positionPromise, safelyGetStateOfAMMPromise])
agentAddresses.forEach((address) => {
const positionResult = positionData.find(b => b.input.target === address)
const safelyGetStateOfAMMResult = safelyGetStateOfAMMData.find(b => b.input.target === address)
if (safelyGetStateOfAMMResult.success && positionResult.success) {
const position = positionResult.output
const safelyGetStateOfAMM = safelyGetStateOfAMMResult.output
const tickToPrice = (tick) => 1.0001 ** tick
const token0 = position.token0
const token1 = position.token1
const liquidity = position.liquidity
const bottomTick = +position.tickLower
const topTick = +position.tickUpper
const tick = safelyGetStateOfAMM.tick
const sa = tickToPrice(bottomTick / 2)
const sb = tickToPrice(topTick / 2)
let amount0 = 0
let amount1 = 0
if (tick < bottomTick) {
amount0 = liquidity * (sb - sa) / (sa * sb)
} else if (tick < topTick) {
const price = tickToPrice(tick)
const sp = price ** 0.5

amount0 = liquidity * (sb - sp) / (sp * sb)
amount1 = liquidity * (sp - sa)
} else {
amount1 = liquidity * (sb - sa)
}

api.add(token0, amount0)
api.add(token1, amount1)
}
})
}

module.exports = {
getTvlForBladeSwapCLM
}
4 changes: 2 additions & 2 deletions projects/agentfi/strategies/dex-balancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ async function getTvlForDexBalancer(agentAddresses, api) {
const reserve1BigN = BigNumber(reserve1)
const token0Balance = lpBalanceBigN.times(reserve0BigN).div(totalBigN)
const token1Balance = lpBalanceBigN.times(reserve1BigN).div(totalBigN)
api.add(RingTokenMappings[address0], token0Balance.toFixed(0))
api.add(RingTokenMappings[address1], token1Balance.toFixed(0))
api.add(RingTokenMappings[address0.toLowerCase()], token0Balance.toFixed(0))
api.add(RingTokenMappings[address1.toLowerCase()], token1Balance.toFixed(0))
}
const hyperlocklpBalance = hyperlocklpBalances.find(b => b.input.params[0] === address)
if (hyperlocklpBalance.success) {
Expand Down
13 changes: 12 additions & 1 deletion projects/agentfi/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ async function getAllAgent(api) {
const DexBalancerModules = ["0x7e8280f5Ee5137f89d09FA61B356fa322a93415a", "0x35a4B9B95bc1D93Bf8e3CA9c030fc15726b83E6F", "0x067299A9C3F7E8d4A9d9dD06E2C1Fe3240144389"]
const MultioliooorModule = ["0x54D588243976F7fA4eaf68d77122Da4e6C811167"]
const ConcentratedLiquidityModule = ["0x10C02a975a748Db5B749Dc420154dD945e2e8657", "0x41D68d86545D6b931c1232f1E0aBB5844Ada4967", "0xa11D4dcD5a9ad75c609E1786cf1FD88b53C83A5E"]
const Looper = ["0x6A9D21A09A76808C444a89fE5fCc0a5f38dc0523", "0xe5fe6f280CEadc5c4DDE69eF2DF6234dd7Bd82E2"]
const BladeSwapConcentratedLiquidityModule = [
"0x5dBC01F3F1310E36454C43cA1d2c84F44b8094F2",
"0xa28299bfbf44450CbA73a1eAdcE461AF62181a02",
"0xD18eD95286316a359291b21d02e8d46C59986302",
]
const pacLooperModule = '0x5E38765FF50D9b8932441Cd668c1fDA365D358b5'
const Looper = ["0x6A9D21A09A76808C444a89fE5fCc0a5f38dc0523", "0xe5fe6f280CEadc5c4DDE69eF2DF6234dd7Bd82E2", "0x8220512520db5D3295EA41308601FD0974405975", pacLooperModule]
if (modules.some(i => DexBalancerModules.includes(i))) {
return {
...i,
Expand All @@ -78,6 +84,11 @@ async function getAllAgent(api) {
...i,
moduleType: "ConcentratedLiquidity"
}
} else if (modules.some(i => BladeSwapConcentratedLiquidityModule.includes(i))) {
return {
...i,
moduleType: "BladeSwapLiquidityManager"
}
} else if (modules.some(i => Looper.includes(i))) {
return {
...i,
Expand Down
10 changes: 10 additions & 0 deletions projects/ainnswap/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { iziswapExport } = require('../helper/iziswap')

const poolHelpers = {
'ailayer': ['0x19b683A2F45012318d9B2aE1280d68d3eC54D663'],
} // iziswap liquidityManager contracts


Object.keys(poolHelpers).forEach(chain => {
module.exports[chain] = { tvl: iziswapExport({ poolHelpers: poolHelpers[chain], }), }
})
11 changes: 11 additions & 0 deletions projects/airdao-hera-pool/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
async function tvl(api) {
const totalStake = await api.call({abi: 'uint256:totalStake', target: '0x0E051C8C1cd519d918DB9b631Af303aeC85266BF'})
api.addCGToken('amber', totalStake/1e18)
}

module.exports = {
methodology: `TVL counts deposits made to Hera pool on AirDAO.`,
airdao: {
tvl
}
}
31 changes: 27 additions & 4 deletions projects/airpuff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,54 @@ const contractAbis = {
getUnderlyingPrice: "function getUnderlyingPrice(address cToken) view returns (uint256)",
getUniswapPrice:
"function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 observationCardinalityNext, uint8 observationCardinalityNext)",
getMantleBalance: "function balances(address) view returns (uint256)",
};

module.exports = {
misrepresentedTokens: true,

mantle: {
tvl: async (api) => {
const mantle = {
vault: "0xf9B484901BCA34A8615c90E8C4933f1Bd553B639",
lending: "0x08ccF72358B44D9d45438Fc703962A0a2FD5c978",
staking: "0x9f39dC8eA0a73ab462d23104699AFAE9c30d1E4f",
};

const stakedBalance = await api.call({
abi: contractAbis.getMantleBalance,
target: mantle.staking,
params: [mantle.vault],
});

api.add(ADDRESSES.mantle.WMNT, stakedBalance);

await api.sumTokens({
tokensAndOwners: [[ADDRESSES.mantle.WMNT, mantle.lending]],
});
},
},

karak: {
tvl: async (api) => {
const KUSDC = {
vault: "0x4c18E80b801AA24066D8B1C6E65ee245497Cb741",
token: ADDRESSES.karak.USDC,
token: "0xa415021bC5c4C3b5B989116DC35Ae95D9C962c8D",
};

const KWETH = {
vault: "0x9a9631F7BEcE5C6E0aBA1f73f0e5796c534dc4db",
token: ADDRESSES.optimism.WETH_1,
token: "0x4200000000000000000000000000000000000006",
};

const wethLending = {
vault: "0xd6034F9147CF7528e857403Dea93bc45743295eb",
token: ADDRESSES.optimism.WETH_1,
token: "0x4200000000000000000000000000000000000006",
};

const usdcLending = {
vault: "0x475820E4bCE0E3d233Ad7f6A8c9DD1f66974c5d6",
token: ADDRESSES.karak.USDC,
token: "0xa415021bC5c4C3b5B989116DC35Ae95D9C962c8D",
};

const KarakUSDCBal = await api.call({ target: KUSDC.vault, abi: contractAbis.getTotalSupply });
Expand Down
3 changes: 2 additions & 1 deletion projects/aktionariat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { cachedGraphQuery } = require('../helper/cache')
const graphs = {
ethereum: sdk.graph.modifyEndpoint('2ZoJCp4S7YP7gbYN2ndsYNjPeZBV1PMti7BBoPRRscNq'),
optimism: sdk.graph.modifyEndpoint('3QfEXbPfP23o3AUzcmjTfRtUUd4bfrFj3cJ4jET57CTX'),
polygon: sdk.graph.modifyEndpoint('7camBLZckE5TLKha372tqawpDs8Lkez6yYiri7PykRak'),
}

function tvlPaged(chain) {
Expand All @@ -29,7 +30,7 @@ module.exports = {
timetravel: false,
hallmarks: []
}
const chains = ['ethereum', 'optimism']
const chains = ['ethereum', 'optimism', 'polygon']

chains.forEach(chain => {
module.exports[chain] = {
Expand Down
Loading

0 comments on commit ddfbcc6

Please sign in to comment.