crossr
Build on crossr

Trading a curve

  • Quote first: quoteBuy(token, quoteAmount, buyer) returns (tokensOut, spent, totalFeeBps) including the snipe tax for that buyer; quoteSell(token, tokenAmount) returns (quoteOut, fees). Or read getCurve once and quote locally with quoteBuy / quoteSell from @crossr/shared/curve, which mirrors the contract exactly.
  • buy(token, quoteAmount, minTokensOut, recipient, deadline). Native quote goes in msg.value and must equal quoteAmount; ERC20 quote needs an approval. A buy that crosses graduation is partially filled and the excess refunded, so treat minTokensOut as a price bound, not an exact output.
  • sell(token, tokenAmount, minQuoteOut, recipient, deadline). Approve the launchpad for the tokens first. A leg only pays out what it took in: tokenAmount ≤ tokensSold, otherwise InsufficientSold.
  • Curve state to track: Trade events carry realQuote and tokensSold after each fill. Progress is realQuote / target; the curve is sold out when tokensSold == supply − reserved.
  • After Graduated, trade the Uniswap v4 pool instead. The pool key is (token, quote, fee 0, tickSpacing 200, hook) sorted by address, which poolKey(token, quote, hook) in the web app builds. Route through the chain's Universal Router with Permit2; quote with the v4 Quoter.