Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions dexs/hikari.ts
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);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

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_CONTRACT will 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logs.forEach((log) => {
if (log.recipient === BASELINE_CONTRACT)
dailyFees.add(AUSD_TOKEN, log.amount0);
});
logs.forEach((log) => {
if (log.recipient.toLowerCase() === BASELINE_CONTRACT.toLowerCase())
dailyFees.add(AUSD_TOKEN, log.amount0);
});
🤖 Prompt for AI Agents
In `@dexs/hikari.ts` around lines 28 - 31, The equality check in logs.forEach
comparing log.recipient to BASELINE_CONTRACT is case-sensitive and can miss
matches; update the comparison to normalize both sides (e.g., toLowerCase())
before comparing so that log.recipient.toLowerCase() ===
BASELINE_CONTRACT.toLowerCase() is used, ensuring dailyFees.add(AUSD_TOKEN,
log.amount0) runs for matching addresses; adjust any related references to
BASELINE_CONTRACT or log.recipient comparisons in this block to use the same
normalization.


swapLogs.forEach((swapLog) => {
const amount0 = Number(swapLog.amount0) / 1e6;
if (amount0 > 0) dailyVolume.addUSDValue(amount0);
else dailyVolume.addUSDValue(-amount0);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check how other DEX adapters handle swap volume calculations
rg -n -A5 'addUSDValue' --glob 'dexs/*.ts' | head -100

Repository: DefiLlama/dimension-adapters

Length of output: 5165


🏁 Script executed:

# Check for similar swap patterns with amount0/amount1
rg -n -B2 -A5 'Swap.*amount0.*amount1' --glob 'dexs/*.ts' | head -100

Repository: DefiLlama/dimension-adapters

Length of output: 7132


🏁 Script executed:

# Look at the full hikari.ts file to understand AUSD token configuration
cat dexs/hikari.ts

Repository: DefiLlama/dimension-adapters

Length of output: 1850


🏁 Script executed:

# Check if there are any token configurations or decimal references for AUSD
rg -n 'AUSD\|amount0\|1e6' dexs/hikari.ts

Repository: DefiLlama/dimension-adapters

Length of output: 54


Fix volume calculation to match fee handling and use the framework's token mechanism.

The code divides amount0 by 1e6 and passes it to addUSDValue, but this is inconsistent with how fees are correctly handled using dailyFees.add(AUSD_TOKEN, log.amount0). The swap event's amount0 is a raw contract value, not a USD value—dividing by an arbitrary decimal count does not convert it to USD. This bypasses the framework's pricing mechanism.

Use dailyVolume.add(AUSD_TOKEN, Math.abs(swapLog.amount0)) to match the fee calculation pattern and let the framework handle token decimals and USD conversion properly.

🤖 Prompt for AI Agents
In `@dexs/hikari.ts` around lines 33 - 37, The volume calculation currently
divides swapLog.amount0 by 1e6 and calls dailyVolume.addUSDValue, which bypasses
the framework pricing; instead update the swapLogs.forEach handler to call
dailyVolume.add with AUSD_TOKEN and the absolute raw amount (use Math.abs on
swapLog.amount0) so it matches the fee pattern (dailyFees.add(AUSD_TOKEN, ...))
and lets the framework handle token decimals and USD conversion; locate the
swapLogs.forEach block and replace the addUSDValue/division logic with
dailyVolume.add(AUSD_TOKEN, Math.abs(swapLog.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;
29 changes: 24 additions & 5 deletions package-lock.json

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

Loading