Skip to content

How a swap is found and checked

For any coin, the API gathers every way to trade it for ETH right now:

  • Its launchpad curve. A Pons coin trades on its own curve until it graduates; a Flap coin on Flap’s portal. Priced in ETH.
  • Uniswap pools. V2, V3 and V4: the pools listed for it, and the pools Uprally’s charts saw it trade in (so a coin minutes old, in no listing yet, still has its pool). Each is checked on chain: a V2 or V3 pool must come from Uniswap’s own factory, a V4 pool’s key must hash to its id. Pools on other exchanges are not routed.
  • The way from ETH to the pool’s currency. Most Robinhood coins trade against USDG: the route goes ETH → USDG through the deepest ETH/USDG pools (both are tried). A coin priced in another coin or a stock token goes through that currency’s own deepest pool, up to two currencies deep (ETH → USDG → NVDA → the coin, for example).

Each candidate route is run as the exact transaction it would send, against the chain as it is now (an eth_simulateV1 simulation), from your wallet when you send one. What you would end up with is read from the simulation, not worked out from a formula, so a pool’s fee, a V4 hook’s cut, a launchpad’s snipe tax and a coin’s own transfer tax are all already in amountOut. The route that leaves you with the most wins; routesCompared says how many were tried.

  • The minimum is in the calldata. minOut is amountOut less your slippageBps (default 100, 1%). The transaction reverts rather than give you less.
  • Simulated again with that minimum, and refused (SIMULATION_FAILED) if it would fail.
  • A deadline. A router swap reverts after expiresAt (10 minutes).
  • The round trip. A buy is followed, in the same simulation, by selling 99% of what it bought straight back, through the same route or any other. sellBack says what that returns. A coin that cannot be sold back through any route is refused (HONEYPOT).
  • Price impact. A trade that moves the price more than 50% is refused (PRICE_IMPACT_TOO_HIGH) unless you send maxPriceImpactPct.
  • Pool routes: Uniswap’s Universal Router (GET /chain → contracts.universalRouter). The router holds the money between pools and keeps none of it: each step spends everything it holds, and the last sends all of it to you.
  • A Pons coin on its curve: that coin’s curve contract. A Flap coin on its curve: Flap’s portal.

Nothing goes through a contract of Uprally’s.

A sale quote without wallet, or for a wallet holding less than amount, is simulated from a test wallet given the coins in the simulation, or failing that from a real holder (simulatedFrom says which). A build always uses your wallet and your real balance.