Skip to content

feat: add LunarBase PMM volume adapter#6286

Open
NebulaNomadPixel wants to merge 1 commit intoDefiLlama:masterfrom
NebulaNomadPixel:lunarbase-pmm-volume
Open

feat: add LunarBase PMM volume adapter#6286
NebulaNomadPixel wants to merge 1 commit intoDefiLlama:masterfrom
NebulaNomadPixel:lunarbase-pmm-volume

Conversation

@NebulaNomadPixel
Copy link
Copy Markdown

@NebulaNomadPixel NebulaNomadPixel commented Mar 28, 2026

NOTE

Please enable "Allow edits by maintainers" while putting up the PR.


  1. If you would like to add a volume/fees/revenue adapter please submit the PR here.

  2. Once your adapter has been merged, it takes time to show on the UI. If more than 24 hours have passed, please let us know in Discord.

  3. Sorry, We no longer accept fetch adapter for new projects, we prefer the tvl to computed from blockchain data, if you have trouble with creating a the adapter, please hop onto our discord, we are happy to assist you.

  4. For updating listing info It is a different repo, you can find your listing in this file, you can edit it there and put up a PR

  5. Please do not add new npm dependencies, do not edit/push pnpm-lock.yaml file as part of your changes


(Needs to be filled only for new listings)

Name (to be shown on DefiLlama): Lunarbase
Twitter Link: x.com/lunarbaseX
List of audit links if any:
Website Link: https://lunarbase.gg/
Logo (High resolution, will be shown with rounded borders):
Group 77
Current TVL: 9.59 k
Treasury Addresses (if the protocol has treasury):
Chain: Base
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): Proactive Market Maker (PMM) with concentrated liquidity on Base.
Token address and ticker if any:
Category (full list at https://defillama.com/categories) *Please choose only one: Dex
Oracle Provider(s): Specify the oracle(s) used (e.g., Chainlink, Band, API3, TWAP, etc.):
Implementation Details: Briefly describe how the oracle is integrated into your project: Price is set by authorized operators through the upd() function on the CurvePMM contract. No on-chain oracle is used — the operator submits a price (pX96) and fee parameter directly.
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
forkedFrom (Does your project originate from another project):
methodology (what is being counted as tvl, how is tvl being calculated): TVL is calculated as the total value of tokens (ETH and USDC) held in the LunarBase CurvePMM pool contract on Base. Token addresses are read dynamically from the pool contract via X() and Y() view functions, and balances are summed using standard ERC-20 balanceOf calls.
Github org/user (Optional, if your code is open source, we can track activity): https://github.com/Lunarbase-Lab
Does this project have a referral program?

Summary by CodeRabbit

  • New Features
    • Added support for Lunarbase DEX on the BASE chain. The adapter now tracks daily trading volumes and fees starting from March 19, 2026.

Track daily swap volume and fees for LunarBase CurvePMM pool on Base (ETH/USDC).
Reads SwapExecuted events from the pool contract.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 28, 2026

📝 Walkthrough

Walkthrough

A new Curve-based DEX adapter for LunarBase is introduced with a SimpleAdapter that fetches swap execution events from Base chain starting March 19, 2026. The adapter extracts token addresses from the CURVE_PMM contract, processes SwapExecuted logs to record daily trading volumes and fees by token.

Changes

Cohort / File(s) Summary
LunarBase DEX Adapter
dexs/lunarbase/index.ts
New adapter module implementing Curve-based swap tracking for Base chain. Initializes daily volume and fee accumulators, retrieves token addresses via contract calls, processes SwapExecuted event logs to track traded volumes (dx/dy mapped to tokenX/Y) and fees (recorded on output side).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A lunar base adapter hops into sight,
Tracking swaps with curves shining bright,
Volumes and fees dance in the blockchain light,
Base chain harvests its data just right,
Code rabbits celebrate this new height! 🌙✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add LunarBase PMM volume adapter' clearly and specifically describes the main change—adding a volume adapter for LunarBase's PMM, matching the core content of the changeset.
Description check ✅ Passed The PR description is well-populated with all critical metadata for a new listing including protocol name, website, chain, category, logo, description, and implementation details. All required sections are adequately filled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@llamabutler
Copy link
Copy Markdown

The lunarbase adapter exports:

> adapters@1.0.0 test
> ts-node --transpile-only cli/testAdapter.ts dexs lunarbase

🦙 Running LUNARBASE adapter 🦙
---------------------------------------------------
Start Date:	Fri, 27 Mar 2026 14:25:49 GMT
End Date:	Sat, 28 Mar 2026 14:25:49 GMT
---------------------------------------------------

BASE 👇
Backfill start time: 19/3/2026
Daily volume: 103.66 k
Daily fees: 20.00
End timestamp: 1774707948 (2026-03-28T14:25:48.000Z)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 `@dexs/lunarbase/index.ts`:
- Line 3: The dailyVolume is undercounted because addOneToken only records one
side of a swap; update the handling in dexs/lunarbase/index.ts so both legs are
recorded: either call addOneToken twice (once for dx and once for dy) where
dailyVolume is updated, or modify/add a helper that accepts both token/amount
pairs and increments both tokens' volumes; ensure you reference the dx and dy
variables and the addOneToken function so both token-level swap volumes are
incremented for each event.
🪄 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: bd817596-40c2-4e65-92d9-5734d3a728e6

📥 Commits

Reviewing files that changed from the base of the PR and between 39fcc87 and 0649234.

📒 Files selected for processing (1)
  • dexs/lunarbase/index.ts

@@ -0,0 +1,44 @@
import { FetchOptions, SimpleAdapter } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import { addOneToken } from "../../helpers/prices";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

dailyVolume is undercounted here because addOneToken records only one side.

addOneToken does not add both dx and dy; it selects one token by core-asset heuristic. For token-level swap volume, this drops one leg on every event.

Proposed fix
-import { addOneToken } from "../../helpers/prices";
@@
-    addOneToken({ chain: options.chain, balances: dailyVolume, token0: tokenX, token1: tokenY, amount0: dx, amount1: dy });
+    dailyVolume.add(tokenX, dx);
+    dailyVolume.add(tokenY, dy);

Also applies to: 26-26

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dexs/lunarbase/index.ts` at line 3, The dailyVolume is undercounted because
addOneToken only records one side of a swap; update the handling in
dexs/lunarbase/index.ts so both legs are recorded: either call addOneToken twice
(once for dx and once for dy) where dailyVolume is updated, or modify/add a
helper that accepts both token/amount pairs and increments both tokens' volumes;
ensure you reference the dx and dy variables and the addOneToken function so
both token-level swap volumes are incremented for each event.

@bheluga bheluga self-assigned this Mar 29, 2026
Copy link
Copy Markdown
Member

@bheluga bheluga left a comment

Choose a reason for hiding this comment

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

@NebulaNomadPixel thanks for the PR.
Is there a way we get the fees going to Supplyside (LP's), Protocol, holders etc?
If yes please track them as dailySupplySideRevenue, dailyRevenue (dailyProtocolRevenue + dailyHoldersRevenue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants