-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
158 changed files
with
2,851 additions
and
585 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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], }), } | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.