Skip to content

feat(contracts): Lithoswap V2 DEX for Makalu (item 1 native swap venue)#68

Open
bachal-mb wants to merge 2 commits into
mainfrom
feat/lithoswap-dex-makalu
Open

feat(contracts): Lithoswap V2 DEX for Makalu (item 1 native swap venue)#68
bachal-mb wants to merge 2 commits into
mainfrom
feat/lithoswap-dex-makalu

Conversation

@bachal-mb

Copy link
Copy Markdown
Collaborator

feat(contracts): Lithoswap V2 DEX for Makalu (item 1 — native swap venue)

Adds the on-chain venue for the MultX cross-chain token swap: a Uniswap V2
port on solc 0.8.24 under Makalu/contracts/src/dex/ (Factory, Pair, Router02,
LP ERC20, libraries, interfaces).

Design choices for Makalu:

  • Router resolves pairs via factory.getPair() rather than a hardcoded CREATE2
    init-code hash. Under via_ir/0.8.24 the Pair bytecode hash differs from the
    canonical Uniswap value, so the hardcoded-hash approach silently breaks
    ("router can't find the pair"); getPair avoids that entire class of bug.
  • Router is ERC20<->ERC20 only (no payable/native paths). On Makalu the native
    LITHO is a LEP-100 token that WLITHO already wraps as an ERC20, so every swap
    is token-to-token and the UI handles WLITHO wrap/unwrap explicitly. This drops
    Router02's payable-native handling and its wrap/unwrap edge cases.
  • 0.8 port keeps the intentional overflow of V2 (uint32 timestamp + TWAP price
    accumulators) inside unchecked blocks; SafeMath is dropped (checked math).

Verification: scripts/dex-e2e.ts drives the full flow on the in-process Hardhat
network — pair creation, first-LP mint (200e18 - MINIMUM_LIQUIDITY), getAmountsOut
matching the 0.30%-fee formula to the wei, swap output == quote, slippage revert,
and remove-liquidity returning the correct post-trade constant-product position.
9/9 checks pass. (A mocha/chai test is included too, but this contracts package
has a pre-existing pnpm dep-linking gap — the existing Lep100.test.ts fails the
same way — so the hardhat-run script is the authoritative check.)

Deployment (deployer key held by the operator, read from env, never in-repo):

  • scripts/deploy-dex.ts + a makalu network in hardhat.config.ts -> writes
    deployments/dex-700777.json.
  • scripts/seed-dex-liquidity.ts + dex-pairs.example.json -> idempotent,
    balance/allowance-checked liquidity seeding.

Remaining for item 1 (follow-up): explorer lib/swap.ts + /swap page, and the
cross-chain saga composing this swap with the existing MultX bridge.

…nue)

Adds the on-chain venue for the MultX cross-chain token swap: a Uniswap V2
port on solc 0.8.24 under Makalu/contracts/src/dex/ (Factory, Pair, Router02,
LP ERC20, libraries, interfaces).

Design choices for Makalu:
- Router resolves pairs via factory.getPair() rather than a hardcoded CREATE2
  init-code hash. Under via_ir/0.8.24 the Pair bytecode hash differs from the
  canonical Uniswap value, so the hardcoded-hash approach silently breaks
  ("router can't find the pair"); getPair avoids that entire class of bug.
- Router is ERC20<->ERC20 only (no payable/native paths). On Makalu the native
  LITHO is a LEP-100 token that WLITHO already wraps as an ERC20, so every swap
  is token-to-token and the UI handles WLITHO wrap/unwrap explicitly. This drops
  Router02's payable-native handling and its wrap/unwrap edge cases.
- 0.8 port keeps the intentional overflow of V2 (uint32 timestamp + TWAP price
  accumulators) inside unchecked blocks; SafeMath is dropped (checked math).

Verification: scripts/dex-e2e.ts drives the full flow on the in-process Hardhat
network — pair creation, first-LP mint (200e18 - MINIMUM_LIQUIDITY), getAmountsOut
matching the 0.30%-fee formula to the wei, swap output == quote, slippage revert,
and remove-liquidity returning the correct post-trade constant-product position.
9/9 checks pass. (A mocha/chai test is included too, but this contracts package
has a pre-existing pnpm dep-linking gap — the existing Lep100.test.ts fails the
same way — so the hardhat-run script is the authoritative check.)

Deployment (deployer key held by the operator, read from env, never in-repo):
- scripts/deploy-dex.ts + a `makalu` network in hardhat.config.ts -> writes
  deployments/dex-700777.json.
- scripts/seed-dex-liquidity.ts + dex-pairs.example.json -> idempotent,
  balance/allowance-checked liquidity seeding.

Remaining for item 1 (follow-up): explorer lib/swap.ts + /swap page, and the
cross-chain saga composing this swap with the existing MultX bridge.
@github-actions

github-actions Bot commented Jul 20, 2026

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 ed93d4260d7ddfee50b0f4d60c7ded169d8ccdd3. Test JSON + coverage HTML are uploaded as run artifacts.

Records the Kamet DEX facts (v3 fork, deployed addresses, subgraph) that
answer the integration question, and the decision to ship the verified v2
Lithoswap on Makalu. Kamet's v3 liquidity does not carry to a Makalu-native
swap (fresh Makalu pools needed either way), so v3 buys only cross-chain
codebase parity, not a faster path to a live swap. Liquidity seeding remains
the one open input (LP decision).
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