Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present. |
factory/aaveLiquidations.ts
Outdated
|
|
||
| type Config = Record<string, { pools: string[]; start: string }>; | ||
|
|
||
| const configs: Record<string, Config> = { |
There was a problem hiding this comment.
hmm, why not export aaveProtocolConfigs from helper/aave and use it here instead of duplicating the same config, this way, when a new pool/protocol gets added there, you automatically get support
|
|
||
| type LiquidationConfig = Record<string, { comptroller: string; start: string }>; | ||
|
|
||
| const liquidationConfigs: Record<string, LiquidationConfig> = { |
There was a problem hiding this comment.
same comment as aave, can keep only the missing protocols here
liquidations/compound-v3/index.ts
Outdated
| const AbsorbCollateralEvent = 'event AbsorbCollateral(address indexed absorber, address indexed borrower, address indexed asset, uint256 collateralAbsorbed, uint256 usdValue)' | ||
| const AbsorbDebtEvent = 'event AbsorbDebt(address indexed absorber, address indexed borrower, uint256 basePaidOut, uint256 usdValue)' | ||
|
|
||
| const config: { [chain: string]: { comets: string[]; start: string } } = { |
There was a problem hiding this comment.
can be pulled from compound v3 fees adapter, this way, any change there is reflected here
g1nt0ki
left a comment
There was a problem hiding this comment.
can you also track liquidations in perp dexes, I think gmx forks emit liquidation event, and might need to look for events/rely on their api in some cases
| const collateralUnderlying = underlyingMap[collateralCToken] | ||
| const exchangeRate = exchangeRateMap[collateralCToken] | ||
| if (collateralUnderlying && exchangeRate) { | ||
| const underlyingAmount = (BigInt(event.seizeTokens) * exchangeRate) / BigInt(1e18) |
There was a problem hiding this comment.
Need to update the conversion here, this is from Compound docs:
oneCTokenInUnderlying = exchangeRateCurrent / (1 * 10 ^ (18 + underlyingDecimals - cTokenDecimals))
There was a problem hiding this comment.
I think the current formula is also correct since we add to balances in raw units, we keep the extra decimals (like adding 1e18 to ETH bal instead of 1 wei). Using this tx hash as an example, if we use the current formula we get 63.4 LINK seized (cLINK underlying), if we add underlyingDecimals - cTokenDecimals, it would show 0.000000006 LINK seized, and if we follow the docs and calculate underlyingAmount in two steps then we get 63.4 LINK seized (same output):
const txHash = '0x14f738e13b596d61bb66adfe86f6a1250948c0983111a460976546ba2bb281b7'
const seizeTokensRaw = 315071765737n
const exchangeRateStored = 201264676862259987086714351n
const cTokenDecimals = 8n
const underlyingDecimals = 18n
// current method
const oneStepUnderlyingRaw = (seizeTokensRaw * exchangeRateStored) / (10n ** 18n)
// compound docs: https://docs.compound.finance/v2/#protocol-math
const oneCTokenInUnderlyingScaled = (exchangeRateStored * (10n ** 18n)) / (10n ** (18n + underlyingDecimals - cTokenDecimals))
const twoStepUnderlyingRaw = (seizeTokensRaw * oneCTokenInUnderlyingScaled * (10n ** underlyingDecimals)) / ((10n ** cTokenDecimals) * (10n ** 18n))
console.log('oneStepUnderlyingRaw:', oneStepUnderlyingRaw.toString()) // 63412817119478982867
console.log('twoStepUnderlyingRaw:', twoStepUnderlyingRaw.toString()) // 63412817119478980634
console.log('underlyingHuman:', Number(oneStepUnderlyingRaw) / 1e18) // 63.41281711947898There was a problem hiding this comment.
can you check cases of liquidated USDC, USDT? they have 6 decimals and make sure the calculation is correct to them
adapters/types.ts
Outdated
| // LIQUIDATIONS | ||
| export type FetchResultLiquidations = FetchResultBase & { | ||
| dailyLiquidations?: FetchResponseValue | ||
| dailyLiquidatedDebt?: FetchResponseValue |
There was a problem hiding this comment.
personally, I would prefer dailyLiquidationRepaidDebt, because debt is repaid, not liquidated
our HL indexer is tracking liquidation volume on Hyperliquid too |
|
The aave-v3.ts adapter exports: |
No description provided.