Quote and Swap
Discover the engine
The pool cannot enumerate pairs. Seed token pairs, then keep those with getEngine(a, b) != address(0) and engine.rfqPool() == pool. See Address References for deployed engines and the live directSwapEnabled check.
Quote — PropAMMEngine.getQuote
function getQuote(
address sellerToken,
address buyerToken,
uint256 sellerTokenAmount
) external view returns (uint256 amountOut);Amounts are raw token units (respect decimals).
Output is after engine fees. The call does not consume depth.
For native gas token (ETH/BNB), pass the wrapped address to
getQuote. Never passaddress(0)on the engine.Reverts when price is expired, depth is insufficient, size is below
minBaseInputRaw/minQuoteInputRaw, or the direction is not this engine'sbaseAsset()/quoteAsset()pair (UnsupportedPair).A successful quote is necessary but not sufficient.
getQuotealso enforces the pair's position limit and treasury cash, and it works even whendirectSwapEnabledis false. It does not guarantee the swap will execute.
const base = await engine.baseAsset();
const quote = await engine.quoteAsset();
// Sell 1 wrapped base → how much quote out?
const amountOut = await engine.getQuote(base, quote, 10n ** 18n);Refresh the quote close to send. Engine price is short-TTL; a stale quote often becomes PriceExpired or PriceOutsideAllowedRange onchain.
Suggested slippage: start at 50 bps (amountOutMinimum = amountOut * 9950 / 10000). Tighten once you see fill quality.
Approve, then swap — NativeRouter.tradePAMM
Do not call Engine.swap(); only the bound pool may call it. Users always go through the router.
Rules:
Single hop only. No multi-hop routing.
Pair must have an engine and
directSwapEnabled == true.Sell ERC-20:
msg.value = 0. Sell native:sellerToken = address(0)andmsg.value = sellerTokenAmount.Buy native:
buyerToken = address(0); pool unwraps WETH/WBNB torecipient.tradePAMMreturns nothing. Read actual out from the poolPAMMTradeevent. See Events.No WidgetFee on this path today.
Failure reverts. There is no RFQ fallback if you swap directly with pAMM. Use FirmQuote Swap APIs for hybrid RFQ fallback and a higher swap success rate.
Last updated