Skip to content

feat(explorer): Lithoswap swap UI (/swap) — item 1 frontend - #69

Open
bachal-mb wants to merge 1 commit into
mainfrom
feat/lithoswap-swap-ui
Open

feat(explorer): Lithoswap swap UI (/swap) — item 1 frontend#69
bachal-mb wants to merge 1 commit into
mainfrom
feat/lithoswap-swap-ui

Conversation

@bachal-mb

Copy link
Copy Markdown
Collaborator

feat(explorer): Lithoswap swap UI (/swap) — item 1 frontend

Adds the same-chain swap front-end for the Lithoswap V2 DEX (PR for the
contracts is separate):

  • lib/swap.ts — ethers v6 client for the Lithoswap router: read-only quotes
    via getAmountsOut against rpc.litho.ai, WLITHO-based path routing
    (token→WLITHO→token when there's no direct pair), slippage/min-out,
    approve + swapExactTokensForTokens through the connected wallet, and an
    actionable error decoder. Reuses the bridge's token list and approveIfNeeded.
  • pages/swap.tsx — the /swap page: token in/out selectors, debounced live
    quote, slippage tolerance, minimum-received + route display, and a Makalu
    chain-switch gate (same pattern as /bridge).
  • Header: adds "Swap" to the nav and points the wallet-menu Swap entry at
    /swap (it was a stopgap link to /bridge).

The router address is injected as NEXT_PUBLIC_SWAP_ROUTER at build time once
the DEX is deployed; until then isSwapConfigured() is false and the page shows
a clear "not live yet" state instead of calling a zero address — so this is
safe to ship ahead of the on-chain deploy.

Verified: tsc clean (aside from the pre-existing build-info.test.ts errors)
and next build compiles /swap as a static route.

Adds the same-chain swap front-end for the Lithoswap V2 DEX (PR for the
contracts is separate):

- lib/swap.ts — ethers v6 client for the Lithoswap router: read-only quotes
  via getAmountsOut against rpc.litho.ai, WLITHO-based path routing
  (token→WLITHO→token when there's no direct pair), slippage/min-out,
  approve + swapExactTokensForTokens through the connected wallet, and an
  actionable error decoder. Reuses the bridge's token list and approveIfNeeded.
- pages/swap.tsx — the /swap page: token in/out selectors, debounced live
  quote, slippage tolerance, minimum-received + route display, and a Makalu
  chain-switch gate (same pattern as /bridge).
- Header: adds "Swap" to the nav and points the wallet-menu Swap entry at
  /swap (it was a stopgap link to /bridge).

The router address is injected as NEXT_PUBLIC_SWAP_ROUTER at build time once
the DEX is deployed; until then isSwapConfigured() is false and the page shows
a clear "not live yet" state instead of calling a zero address — so this is
safe to ship ahead of the on-chain deploy.

Verified: tsc clean (aside from the pre-existing build-info.test.ts errors)
and `next build` compiles /swap as a static route.
@github-actions

Copy link
Copy Markdown

Test Results

Package Passed Failed Skipped Total Duration
api no results
indexer no results
explorer no results

Coverage

Package Stmts % Branch % Funcs % Lines %
api no coverage
indexer no coverage
explorer no coverage

Generated by ci.yaml for 95be95c010c346d8216bcbc5b23a7a97be1f5b0b. Test JSON + coverage HTML are uploaded as run artifacts.

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.

1 participant