Add KYO AG volume indexing adapter#6272
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughA new KYO AG aggregator was added to index inbound volume across Hyperliquid, Monad, and Soneium by combining SwapExecuted events with ERC-20 Changes
Sequence DiagramsequenceDiagram
participant Adapter as KYO AG Adapter
participant EventRouter as Event Routers
participant Contracts as ERC-20 / Native Contracts
participant Store as Volume Store
Adapter->>EventRouter: Query `SwapExecuted` events (per chain)
EventRouter-->>Adapter: Return swap logs (tx hashes, srcToken, amountIn)
Adapter->>Adapter: Build swap tx hash set (mark swap txs)
Adapter->>Contracts: Query `Transfer` logs to router/logic targets
Adapter->>Contracts: Query native `Deposit` logs to targets
Contracts-->>Adapter: Return transfer/deposit logs
Adapter->>Adapter: Filter logs (positive value, exclude router-origin, not swap txs)
Adapter->>Adapter: Aggregate candidates and dedupe by earliest log (logIndex/index)
Adapter->>Store: Update `dailyVolume` (wrapped-native as gas inflow, others as ERC-20 inflow)
Store-->>Adapter: Confirm volume update
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
aggregators/kyoag/index.ts (1)
16-42: Add a guardrail for the manual allowlists.These hard-coded router/logic lists will silently miss volume whenever Kyo deploys a new executor. A lightweight config test or registry-driven source would make the adapter safer to keep current.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@aggregators/kyoag/index.ts` around lines 16 - 42, Add a guardrail to ensure the hard-coded LOGICS allowlist stays current by verifying it at startup (or in a scheduled test) against the on-chain router/logic registry: implement a small check (e.g., validateLogicsAgainstRegistry or initAndValidateLogics) that iterates LOGICS for each CHAIN entry, queries the router or registry contract for active logic/executor addresses, and logs or throws if any active logic is missing from LOGICS (or optionally auto-merge new addresses into a safe dynamic config); ensure the check uses CHAIN and LOGICS identifiers so it runs before indexing begins and surfaces mismatches as warnings/errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@aggregators/kyoag/index.ts`:
- Around line 94-99: The current getLogs call (getLogs({... topics:
[DEPOSIT_TOPIC, padded], noTarget: true ...})) will match any contract emitting
Deposit(address,uint256); after collecting depositLogs, add a post-filter that
restricts logs to only those emitted by the chain’s wrapped-native token
addresses using a per-chain allowlist (e.g., compare log.address against a
WrappedNativeAllowlist map keyed by chainId). Update the code paths that build
depositLogs (including the similar block at the other occurrence) to reject logs
whose log.address is not in the allowlist before they are counted as
swap/deposit volume.
- Around line 102-115: The loops over transferLogs and depositLogs currently
only skip empty payloads (log.data === "0x") but still include zero-value
events; update both loops (the transferLogs and depositLogs iterations) to also
skip logs where the decoded amount is zero by checking BigInt(log.data) === 0n
(after handling the '0x' case) so zero-amount Transfer/Deposit events are
ignored before selecting the first inflow.
---
Nitpick comments:
In `@aggregators/kyoag/index.ts`:
- Around line 16-42: Add a guardrail to ensure the hard-coded LOGICS allowlist
stays current by verifying it at startup (or in a scheduled test) against the
on-chain router/logic registry: implement a small check (e.g.,
validateLogicsAgainstRegistry or initAndValidateLogics) that iterates LOGICS for
each CHAIN entry, queries the router or registry contract for active
logic/executor addresses, and logs or throws if any active logic is missing from
LOGICS (or optionally auto-merge new addresses into a safe dynamic config);
ensure the check uses CHAIN and LOGICS identifiers so it runs before indexing
begins and surfaces mismatches as warnings/errors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9dc34975-78a1-468a-9868-b10ee1f84202
📒 Files selected for processing (1)
aggregators/kyoag/index.ts
|
The kyoag adapter exports: |
|
The kyoag adapter exports: |
|
The kyoag adapter exports: |
NOTE
Please enable "Allow edits by maintainers" while putting up the PR.
package.json/package-lock.jsonfile as part of your changesName (to be shown on DefiLlama):
Kyo Ag
Twitter Link:
https://x.com/kyo_ag
List of audit links if any:
https://docs.kyo.finance/resources/security
Website Link:
https://kyo.ag
Logo (High resolution, will be shown with rounded borders):
SVG : https://raw.githubusercontent.com/kyo-ag/brandkit/055a4cde0d48d02b849b3629e23bc58e1581c020/Kyoag_Symbol.svg
PNG : https://raw.githubusercontent.com/kyo-ag/brandkit/refs/heads/main/Kyoag_Symbol.png
Current TVL:
Dex aggregator
Chain:
Multi-chain dex aggregator (19+ chains will be supported)
Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed): (https://api.coingecko.com/api/v3/coins/list)
Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed): (https://api.coinmarketcap.com/data-api/v3/map/all?listing_status=active,inactive,untracked&start=1&limit=10000)
Short Description (to be shown on DefiLlama):
KYO AG is a cross-chain bridge, meta aggregator, and DEX aggregator for optimal token swaps and bridge routing across multiple networks. KyoAg's multi-chain DEX aggregator is built in Rust for speed, with mathematically optimal routing.
Token address and ticker if any:
Category (full list at https://defillama.com/categories) *Please choose only one:
DEX Aggregator
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
https://docs.kyo.ag
forkedFrom (Does your project originate from another project):
methodology (what is being counted as tvl, how is tvl being calculated):
Github org/user (Optional, if your code is open source, we can track activity):
https://github.com/kyo-ag
Does this project have a referral program?
Not yet, but going to.
Summary by CodeRabbit