Protocol
JoseonSwap
A V2-style AMM, with launch pools reserved and fees booked separately.
A V2-shaped AMM, with two additions#
JoseonSwap is a constant-product AMM in the Uniswap V2 shape: a factory that deploys one pair per token pair, pairs that hold reserves and mint LP tokens, and a router that handles paths, deadlines, and ETH wrapping. If you have integrated with V2 before, everything you know transfers.
Two things are different here:
- A launch's pool is reserved for it. It is claimed when the token is created and can only be opened by the migration, so a graduation cannot be front-run or blocked.
- Fees are booked, not compounded. The 0.30% fee is set aside and claimed by whoever earned it, rather than all of it flowing into LP share value.
Pricing#
amountInWithFee = amountIn × 997
amountOut = (amountInWithFee × reserveOut) / (reserveIn × 1000 + amountInWithFee)That 997/1000 is the same 0.30% V2 charges. Splitting the fee three ways changed who receives it, not what a trader
gets — an AMM prices a swap against the input net of the whole fee no matter where the fee lands. A test runs the same
swap through both pair versions and asserts identical output.
How fees are held#
On each swap the pair takes the fee from the input side and records the creator and protocol shares separately from the reserves. The rest stays in the reserves, which is the LP share.
Claiming is pull-based and permissionless: anyone can trigger a claim, and the funds go to the address whose balance is being settled rather than to whoever called. That means a creator never depends on us running a job for them. The ledger is per address, so a wallet replaced by a takeover still claims the fees it earned earlier.
A graduated pool credits the creator share to whoever holds the fee position at the time of each swap, so handing a token over to someone new moves future earnings without touching what the previous recipient has already earned.
See fees for the split by pool type and the reasoning behind it.
A launch's pool is reserved for it#
When a token is created, its pool is claimed in the same transaction. Until the graduation opens it, that pool cannot be
traded, drained, or synced, and only the migration can put the first liquidity in. Ordinary pool creation for a known
launch token is refused outright, and createPair also requires both tokens to already hold code — so a predicted
future launch-token address cannot have its pair slot taken before the launch runs.
Together that means the pool a curve graduates into is always the one the protocol reserved, always empty when it is funded, and always priced by the curve rather than by someone who got there first.
Authorisation is additive, so bringing a new launch factory online does not revoke an older one. Curves still in flight on a previous version can graduate normally.
Routes#
ETH → WETH → Token
Token → WETH → ETH
Token A → Token B
Token A → WETH → Token BPaths are capped at two hops. That keeps gas predictable and quoting simple, at the cost of not finding exotic routes.
ETH is wrapped and unwrapped by the router; pairs only ever hold WETH.
Each stack ships its own WETH and its own factory. A token that graduated here has no pool on an older router, and routing through the wrong one fails quietly rather than reverting. Use the addresses on network.
Liquidity#
Adding and removing liquidity works the way it does on V2: deposit both sides in ratio, receive LP tokens, burn them to withdraw. A tiny amount of the first mint is retained permanently, as in V2, so the share price stays well-defined.
The only position that behaves differently is the one a graduation creates. It sits in a locker with no withdraw function and stays there. Everything you add on top of it is yours.