-
Notifications
You must be signed in to change notification settings - Fork 1.8k
hikari reapplication for defi Llama #5789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
8126d16
96f7d61
e721857
8b99953
0f120c8
fadb92f
c738554
c0d6b3f
074420b
d66e363
4ea28d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { FetchOptions, SimpleAdapter } from "../adapters/types"; | ||
| import { CHAIN } from "../helpers/chains"; | ||
|
|
||
| const AUSD_TOKEN = "0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a"; | ||
| const BASELINE_CONTRACT = "0xE788dfA236CC9973750239593Db189ac78Afb2C6"; | ||
| const hikariPool = "0x2ac7673C3a0370dE512A20464a800fa7C53235C3"; | ||
|
|
||
| const FEE_EVENT = | ||
| "event Collect(address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1)"; | ||
|
|
||
| const SWAP_EVENT = | ||
| "event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick)"; | ||
|
|
||
| const fetch = async (options: FetchOptions) => { | ||
| const dailyFees = options.createBalances(); | ||
| const dailyVolume = options.createBalances(); | ||
|
|
||
| const logs = await options.getLogs({ | ||
| target: hikariPool, | ||
| eventAbi: FEE_EVENT, | ||
| }); | ||
|
|
||
| const swapLogs = await options.getLogs({ | ||
| target: hikariPool, | ||
| eventAbi: SWAP_EVENT, | ||
| }); | ||
|
|
||
| logs.forEach((log) => { | ||
| if (log.recipient === BASELINE_CONTRACT) | ||
| dailyFees.add(AUSD_TOKEN, log.amount0); | ||
| }); | ||
|
|
||
| swapLogs.forEach((swapLog) => { | ||
| const amount0 = Number(swapLog.amount0) / 1e6; | ||
| if (amount0 > 0) dailyVolume.addUSDValue(amount0); | ||
| else dailyVolume.addUSDValue(-amount0); | ||
| }); | ||
|
||
|
|
||
| return { | ||
| dailyFees, | ||
| dailyRevenue: dailyFees, | ||
| dailyVolume: dailyVolume, | ||
| }; | ||
| }; | ||
|
|
||
| const adapter: SimpleAdapter = { | ||
| methodology: { | ||
| Fees: "Fees collected from the Hikari pool's Concentrated Liquidity.", | ||
| Revenue: "Revenue collected from the Hikari pool.", | ||
| Volume: "Volume collected from the Hikari pool.", | ||
| }, | ||
| version: 2, | ||
| adapter: { | ||
| [CHAIN.KATANA]: { | ||
| fetch: fetch as any, | ||
| start: "2025-07-08", | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default adapter; | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Case-sensitive address comparison will likely fail.
Ethereum addresses returned from event logs may be in different case formats (lowercase or checksummed). The strict equality check
log.recipient === BASELINE_CONTRACTwill fail if the cases don't match, causing fees to be silently ignored.🐛 Proposed fix: normalize addresses to lowercase
logs.forEach((log) => { - if (log.recipient === BASELINE_CONTRACT) + if (log.recipient.toLowerCase() === BASELINE_CONTRACT.toLowerCase()) dailyFees.add(AUSD_TOKEN, log.amount0); });📝 Committable suggestion
🤖 Prompt for AI Agents