[feat] LilSwap - Add aggregators and fees adapters#6375
[feat] LilSwap - Add aggregators and fees adapters#6375bheluga merged 14 commits intoDefiLlama:masterfrom
Conversation
|
Caution Review failedPull request was closed or merged during review Summary by CodeRabbit
WalkthroughA new LilSwap adapter module is introduced that fetches daily protocol metrics including volume, fees, revenue, and supply-side revenue. The adapter targets specific blockchain chains via a chain aliases map and requests data from LilSwap's public endpoint, then populates standardized balance containers with the retrieved USD values. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (2 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
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 |
|
The lilswap adapter exports: |
|
The lilswap adapter exports: |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@fees/lilswap/index.ts`:
- Around line 21-30: Add a breakdownMethodology object and convert unlabeled
aggregate returns into label-keyed breakdowns: update the adapter's methodology
to include a breakdownMethodology entry that documents every label you will use
(e.g., "explicitFees", "revenueRetained", "supplySide"), then change the value
construction (the place that calls getLilSwapFees and/or where results are
returned in fetch) to populate labeled breakdowns for Fees, Revenue,
ProtocolRevenue, and SupplySideRevenue (use .add() style labels in your internal
construction or equivalent return shape) and ensure fetch still calls
fetchLilSwapDailyMetrics(options) and maps that row through getLilSwapFees to
produce the labeled structure; include descriptions in breakdownMethodology for
each label (even single-source labels) to satisfy repo standards.
In `@helpers/lilswap.ts`:
- Around line 52-75: Add concise JSDoc comments to the three exported helper
functions: fetchLilSwapDailyMetrics, getLilSwapVolume, and getLilSwapFees; for
fetchLilSwapDailyMetrics document the options parameter (type FetchOptions),
explain it may return a LilSwapMetricsRow or null when chain is invalid or data
missing and describe start/end timestamps and chain behavior; for
getLilSwapVolume and getLilSwapFees document that they accept a
LilSwapMetricsRow | null, explain null-safe behavior (returns parsed numeric
metrics, defaulting to 0 or parsed result when row is null/fields missing), and
specify return types (number for getLilSwapVolume and an object with dailyFees,
dailyUserFees, dailyRevenue, dailyProtocolRevenue, dailySupplySideRevenue for
getLilSwapFees).
- Around line 58-60: Remove the cross-chain fallback in the row lookup: change
the assignment that currently uses response.data?.find((entry) =>
entry.chain.toLowerCase() === chain) ?? response.data?.[0] so it only returns
the exact match (e.g., response.data?.find((entry) => entry.chain.toLowerCase()
=== chain) ?? null) and ensure the function returns null when no matching chain
row is found; update the use of the variable row and the final return to reflect
this (no fallback to response.data?.[0]) so metrics are not misattributed.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: fa0a0761-ba1c-4f82-a377-193705fba43c
📒 Files selected for processing (3)
aggregators/lilswap/index.tsfees/lilswap/index.tshelpers/lilswap.ts
|
The lilswap adapter exports: |
|
The lilswap adapter exports: |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@fees/lilswap/index.ts`:
- Around line 17-21: Update the destination-explicit labels in the LABELS
constant and corresponding entries in breakdownMethodology: change the "REVENUE"
value from "LilSwap Retained Fees" to "Explicit Swap Fees To Protocol" and the
"SUPPLY_SIDE" value from "External Fee Share" to "Explicit Swap Fees To External
Partners", and mirror those exact strings wherever breakdownMethodology refers
to the retained-fees / external-fee-share labels so the dailyRevenue and
dailySupplySideRevenue dimensions use source→destination wording; locate and
update the LABELS constant and the breakdownMethodology object to apply these
new strings.
In `@helpers/lilswap.ts`:
- Around line 87-95: The getLilSwapFees function currently returns dailyFees,
dailyRevenue, and dailySupplySideRevenue independently which can produce
inconsistent totals; update getLilSwapFees to compute one value from the others
(e.g., compute dailyRevenue = parseMetric(row?.feesUsd) -
parseMetric(row?.supplySideRevenueUsd)) and set dailyFees =
parseMetric(row?.feesUsd) and dailySupplySideRevenue =
parseMetric(row?.supplySideRevenueUsd), keep dailyUserFees consistent (e.g.,
equal to dailyFees or derived per spec), and add validation that the derived
dailyRevenue is non-negative (throw or return null/error if validation fails) so
the adapter always satisfies the fees mapping contract; use the existing
parseMetric helper and reference getLilSwapFees, parseMetric, and the
LilSwapMetricsRow fields feesUsd and supplySideRevenueUsd when making the
change.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 99eca0c5-c584-487f-881f-67f60efdae13
📒 Files selected for processing (2)
fees/lilswap/index.tshelpers/lilswap.ts
|
The lilswap adapter exports: |
|
The lilswap adapter exports: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@helpers/lilswap.ts`:
- Around line 65-67: The code calls entry.chain.toLowerCase() on external data;
add a defensive type guard before that call in the logic that computes row (the
response from fetchURL as LilSwapMetricsResponse). Ensure you verify entry.chain
is a string (e.g., typeof entry.chain === "string") before calling toLowerCase,
and skip or treat non-strings as non-matching rows so you don't throw; update
the matching expression that compares to the local chain variable (and/or
normalize the local chain once) in the same block to use the guarded,
lower-cased value.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: e86dde44-2945-4337-bec4-098920b59753
📒 Files selected for processing (2)
fees/lilswap/index.tshelpers/lilswap.ts
|
The lilswap adapter exports: |
|
The lilswap adapter exports: |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
The lilswap adapter exports: |
|
The lilswap adapter exports: |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@helpers/lilswap.ts`:
- Around line 42-47: parseMetric currently treats an empty string as numeric
because Number("") === 0; add an explicit blank-string guard so that if value is
a string and value.trim() === "" the function throws the same Error as
non-finite values. Update parseMetric to check for typeof value === "string" &&
value.trim() === "" before Number(value) and throw new Error(`LilSwap metric
field=${fieldName} is not numeric: ${String(value)}`), and apply the same
blank-string guard pattern to the analogous parsing helper in neony to keep
behavior consistent.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6a19559b-6224-4d53-b5fe-20beb7c60aff
📒 Files selected for processing (2)
helpers/lilswap.tshelpers/lilswapConfig.ts
…terns - Added defensive check in parseMetric to throw on empty/whitespace strings, preventing silent coercion to 0. - Removed process.env override for BASE_URL to align with standard repository helper patterns. - Simplified return logic in fetchLilSwapDailyMetrics.
|
The lilswap adapter exports: |
|
The lilswap adapter exports: |
|
@InkCrypto thanks for the PR. |
Hi @bheluga. LilSwap is non-custodial and does not have a LilSwap-specific smart contract. The app coordinates user-triggered collateral swap and debt swap flows by interacting directly with Aave contracts. Because of that, providing only the Aave contract addresses would not be enough to attribute volume or fees to LilSwap. Those contracts are public and can be used by anyone, so onchain activity from those addresses alone would include transactions unrelated to our app. Our attribution source is the transaction set generated through LilSwap itself. Since day 1, we have persisted the transaction hashes for every transaction routed through the app, and our metrics endpoint is derived from that execution history. If helpful, we can share sample transaction hashes or more detail about how we attribute volume and fees from that dataset. |
Yes , plz provide an example transaction hash, we can then decide what to be done |
Here is a small sample of confirmed transactions routed through LilSwap across multiple chains. These are persisted in our execution history and are part of the dataset used by our metrics endpoint.
These are examples of transactions attributed through the execution history recorded by LilSwap itself. If another format would be easier for validation, please let me know. |
|
The lilswap adapter exports: |
Summary
Adds LilSwap dimension adapters for:
Links
Methodology
Volume
Counts the USD notional of all confirmed LilSwap swaps from LilSwap's public daily metrics endpoint, including zero-fee swaps.
Fees
Counts explicit LilSwap fees from confirmed swaps. Zero-fee swaps remain in volume but do not contribute to fees.
Revenue
LilSwap retained explicit swap fees, sourced from LilSwap's public daily metrics and computed as total explicit fees minus the external partner fee share.
ProtocolRevenue
Same as daily revenue, computed from the explicit fee split as dailyFees minus dailySupplySideRevenue.
SupplySideRevenue
External partner fee share sourced from LilSwap's public daily metrics endpoint.
Name (to be shown on DefiLlama):
LilSwap
Twitter Link:
https://x.com/LilSwap_
List of audit links if any:
N/A
Website Link:
https://lilswap.xyz
Logo (High resolution, will be shown with rounded borders):
https://app.lilswap.xyz/favicon.png
Current TVL:
N/A (non-custodial; this PR adds dimensions only)
Treasury Addresses (if the protocol has treasury)
N/A
Chain:
Ethereum, BNB Chain, Polygon, Base, Arbitrum, Avalanche, Optimism, Gnosis, Sonic
Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed):
Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed):
Short Description (to be shown on DefiLlama):
Non-custodial swap automation for Aave-related position management and token swaps.
Token address and ticker if any:
N/A
Category (full list at https://defillama.com/categories) *Please choose only one:
Aggregator
Oracle Provider(s): Specify the oracle(s) used (e.g., Chainlink, Band, API3, TWAP, etc.):
N/A for this PR
Implementation Details: Briefly describe how the oracle is integrated into your project:
This PR does not add a TVL adapter. It adds aggregator volume and fees adapters sourced from LilSwap's public daily metrics endpoint.
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
https://docs.llama.fi/list-your-project/other-dashboards
forkedFrom (Does your project originate from another project):
No
methodology (what is being counted as tvl, how is tvl being calculated):
N/A for this PR. LilSwap is non-custodial and this PR adds dimensions only.
Github org/user (Optional, if your code is open source, we can track activity):
InkCrypto
Does this project have a referral program?
No