Base-first builder starter template for LI.FI Earn discovery, Composer quote generation, and wallet execution.
This repo is intentionally narrow:
- wallet-connected browser flow
- Base vault discovery through the public Earn Data API
- same-chain deposit quote generation through Composer
- route anatomy, stage-stack, and execution-checklist debugging for the built quote
- a copyable proof/debug snapshot for teammate handoff
- a downloadable JSON debug bundle for teammate handoff
- a local reusable workspace package under
packages/earn-toolkit - an in-app integration doctor and toolkit page at
/toolkit - wallet transaction handoff
- portfolio verification against
GET /v1/portfolio/:address/positions
It is not a full yield dashboard. It is a builder-facing template that gets another participant to a real faucet-backed test loop quickly.
- Copy
.env.exampleto.env.local - Fill in:
NEXT_PUBLIC_LIFI_INTEGRATORLIFI_COMPOSER_API_KEYif you want trusted local/dev requests to use authenticated Composer
- Start the app:
pnpm devOpen http://localhost:3000.
Open http://localhost:3000/toolkit only after the starter path is already running and you want diagnostics or export artifacts.
NEXT_PUBLIC_LIFI_INTEGRATOR- Explicit string identifier used by LI.FI for API requests
LIFI_COMPOSER_API_KEY- Get it from
https://portal.li.fi/ - Required for both Earn data requests and authenticated Composer requests
- In trusted local/dev mode, the starter quote route uses this authenticated Composer path
- If it is missing, Earn data requests now fail and the starter can no longer rely on public Earn access
- Get it from
- Injected wallet with Base support
- Base faucet funds if you want to run a real deposit test
https://lifi-faucet.vercel.app/
ENABLE_AUTHENTICATED_COMPOSER- Default is enabled
- Set to
falseonly if you deliberately want to force public fallback mode
STARTER_ALLOWED_QUOTE_ORIGINS- Comma-separated allowlist for authenticated Composer in production
- Development defaults already include localhost on ports
3000and3001
- Connect an injected wallet
- Open a Base transactional vault
- Enter an amount for the first underlying token
- Build a Composer quote through the starter quote route
- trusted local/dev mode + key: authenticated Composer
- untrusted/public mode: public Composer fallback
- Inspect the route debugger if you need to explain or validate the route
- Copy the proof/debug snapshot if you need to hand the route state to a teammate
- Download the JSON debug bundle if you need a structured route artifact
- Approve the source token when the quote requires allowance
- Send the returned transaction request to the wallet
- Verify the portfolio output panel
- Copy
.env.exampleto.env.local - Set
NEXT_PUBLIC_LIFI_INTEGRATOR - Set
LIFI_COMPOSER_API_KEYif you want authenticated Composer during local development - Start the app with
pnpm dev - Connect a Base wallet with small Base ETH and Base USDC
- Open the first vault row and run the standard deposit loop
This repo now has two layers:
app/- runnable Next.js starter surface for the live demo path
packages/earn-toolkit/- reusable local toolkit primitives for:
- shared types
- flow presets
- route-debug helpers
- proof/debug bundle builders
- integration-doctor checks
- reusable local toolkit primitives for:
The starter page is the working loop. The toolkit page explains the reusable builder-facing parts behind it.
The toolkit package now exposes a clearer external API instead of only acting as an internal helper folder:
earnToolkitClient- flow preset builders
- typed quote-input builders
- doctor reports
- debug bundle builders
- a minimal fixture-driven CLI
The repo now ships a narrow toolkit CLI over the local package API.
Use it from the repo root:
pnpm earn --help
pnpm earn doctor --server packages/earn-toolkit/fixtures/server-doctor.json --wallet packages/earn-toolkit/fixtures/wallet-doctor.json
pnpm earn quote --vault packages/earn-toolkit/fixtures/vault.base.json --from-address 0x9D58f474D6c29Dcc2703b9b432F7eE2Fe1415C5e --from-amount 20000
pnpm earn debug-bundle --quote packages/earn-toolkit/fixtures/quote.base.json --context packages/earn-toolkit/fixtures/debug-context.base.json --format snapshotThis CLI is intentionally narrow:
- no network calls
- no wallet control
- no deployment auth surface
- deterministic fixture-driven outputs for builder debugging and demos
The fastest way to understand the repo is:
- Run
/ - Prove the Base flow works
- Open
/toolkit - Use the doctor, route debugger, and debug bundle only when you need them
- Base only
- Same-chain Base path only
- First underlying token only
- No backend persistence
- No general multi-chain orchestration UI yet
- Composer quote is
GET /v1/quote, not POST - Earn data routes now use
/v1/...paths such asGET /v1/vaultsandGET /v1/portfolio/:address/positions - Vault
addressis the ComposertoToken - APY fields can be
null - TVL comes back as a string
- Portfolio
protocolNameis context-sensitive - Empty
positions: []is a valid response shape - This starter does not expose an open unauthenticated partner-key relay
The starter currently filters to Base plus isTransactional === true.
If you want to widen or narrow the scope, start in:
lib/earn-api.tsapp/page.tsx
pnpm dev
pnpm lint
pnpm typecheck
pnpm build
pnpm test:toolkit
pnpm earn --help