disconnected
docs/trading/sell

How Sells Work

A NAKA sell redeems tokens for ETH from the hook's reserve, at a rate determined by the curve's current state. Sells continue to function even after self-deprecation. Only the buy path closes once issuance ends.

Two-Step Flow (First Time)

The first sell from any wallet is two transactions:

  1. Approve the router to spend NAKA: naka.approve(router, amount).
  2. Sell: router.sellNaka(tokensIn, minEthOut).

Subsequent sells from the same wallet skip step 1 unless the previous approval has been used up. The frontend at naka.exchange detects this automatically and shows approve naka or sell naka accordingly.

What Happens On-Chain

  1. Wallet signs the sell call.
  2. Router transfers tokensIn from the user to the hook (using the prior approval).
  3. Hook computes ETH out by walking the inverse curve from totalMintedFair down by the proportional amount.
  4. 30 bps of tokensIn are sent to 0xdEaD (permanent burn). The user does not pay this fee in ETH; it comes out of the tokens being sold.
  5. The remaining 99.70% of tokens are burned, and the corresponding ETH is transferred from the reserve to the seller.
  6. The hook updates totalMintedFair -= ethOut and the reserve actualEthBalance -= ethOut.
  7. Sell(user, tokensIn, ethOut, tokensLocked) event is emitted.

If minEthOut is not met, the entire transaction reverts.

Slippage

The frontend hardcodes 2% slippage on sells, mirroring the buy path: minEthOut = quotedEthOut · 9800/10000. Same protections apply. Same-block ordering, MEV.

Anti-Flip Cooldown

The hook implements a cooldown to mitigate same-block buy/sell exploits. After a buy from a given account, the same account cannot sell within COOLDOWN_BLOCKS blocks. This prevents specific MEV patterns where an attacker buys, manipulates a downstream price oracle, and sells in the same block.

The cooldown does not affect normal users. Most retail flows are minutes apart, not blocks apart. It only constrains adversarial scripts.

Reserve-Backed Execution

Sells are paid out of the hook's ETH reserve. The reserve is sized by every prior buy's ETH input minus prior sells' ETH output. As long as the reserve is non-zero, sells execute at the curve's prevailing rate.

The reserve cannot be drained outside the sell path. There is no admin withdrawal, no emergency pause, no operator extraction.

Receiving ETH

ETH arrives in the seller's wallet within the same transaction. No claim, no vest. The transferred amount is ethOut from the event log, post-fee.