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 readgetCurveonce and quote locally withquoteBuy/quoteSellfrom@crossr/shared/curve, which mirrors the contract exactly. buy(token, quoteAmount, minTokensOut, recipient, deadline). Native quote goes inmsg.valueand must equalquoteAmount; ERC20 quote needs an approval. A buy that crosses graduation is partially filled and the excess refunded, so treatminTokensOutas 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, otherwiseInsufficientSold.- Curve state to track:
Tradeevents carryrealQuoteandtokensSoldafter each fill. Progress isrealQuote / target; the curve is sold out whentokensSold == supply − reserved. - After
Graduated, trade the Uniswap v4 pool instead. The pool key is(token, quote, fee 0, tickSpacing 200, hook)sorted by address, whichpoolKey(token, quote, hook)in the web app builds. Route through the chain's Universal Router with Permit2; quote with the v4 Quoter.