feat(contracts): Lithoswap V2 DEX for Makalu (item 1 native swap venue)#68
Open
bachal-mb wants to merge 2 commits into
Open
feat(contracts): Lithoswap V2 DEX for Makalu (item 1 native swap venue)#68bachal-mb wants to merge 2 commits into
bachal-mb wants to merge 2 commits into
Conversation
…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.
Test Results
Coverage
Generated by |
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.
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.
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):
makalunetwork in hardhat.config.ts -> writesdeployments/dex-700777.json.
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.