LayerHopDocsLaunch app (opens in a new tab)

Receive an exact amount

Quote by the amount the recipient must receive instead of the amount the sender pays. Send dstAmount; each quote says what it costs, the most it can take and the guaranteed output.

Most quotes fix the input: the sender pays amount and the output floats with the price. An exact-output quote fixes the output instead: send dstAmount (what the recipient must receive) and each quote tells you what it costs. Use it to pay an invoice, top up a wallet to a known balance, or buy a set number of tokens.

Request it#

Send dstAmount instead of amount to GET /v1/quote. It is an integer string in base units of dstToken, like every amount.

Terminal
curl "https://api.layerhop.com/v1/quote?srcChain=base&srcToken=USDC\
&dstChain=arbitrum&dstToken=USDC&dstAmount=10000000\
&sender=0xYou&recipient=0xYou"
Parameter Meaning
dstAmount The amount of dstToken the recipient receives, in base units (10000000 = 10 USDC).
amount Leave it out. Sending both, or neither, is INVALID_PARAMS.

POST /v1/quote takes dstAmount the same way in a JSON body. With the TypeScript SDK:

TypeScript
const { best } = await lh.quote({
  srcChain: "base", srcToken: "USDC",
  dstChain: "arbitrum", dstToken: "USDC",
  dstAmount: "10000000",            // exactly 10 USDC arrives
  sender: address, recipient: address,
});

Read the quote#

Every exact-output quote carries the amount to pay next to the output:

JSON
{
  "provider": "lifi",
  "srcAmount": "10048745",
  "srcAmountMax": "10048745",
  "dstAmount": "10000000",
  "dstAmountMin": "10000000",
  "fees": { "ourFeeBps": 25 }
}
Field Meaning
srcAmount What sender pays, base units of srcToken, fees included.
srcAmountMax The most the transaction can take from sender, slippage included. Check the balance and the approval against it.
dstAmountMin The guaranteed output: never less than dstAmount you asked for. A provider quote below it is dropped.
dstAmount The expected output. It can be a little above what you asked for on routes with a swap.

Quotes rank by the lowest srcAmount: they all deliver the same amount, so the cheapest wins, after a waiting penalty of 0.1% per minute of estimatedSeconds beyond the first (at most 1.5%). Someone paying a checkout is watching the page, so a route that takes 18 minutes only wins if it's more than about 1.5% cheaper than one that takes seconds. Then build and send the order with POST /v1/orders as usual. The transaction (and its token approval) is sized for srcAmountMax.

Which routes support it?#

Only providers that quote a fixed output are asked. The others are skipped, never approximated:

Provider Exact output
LI.FI Yes
deBridge Yes, cross-chain (not from Tron)
Relay Yes, from EVM chains (to EVM chains and Solana, same-chain included)
Jupiter, 0x, KyberSwap, Mayan No: these routes quote by input only

When no provider supports the route, the answer is NO_ROUTE. Exact output can't be combined with gasless or gas on arrival (INVALID_PARAMS). Route minimums and no-route suggestions are computed for input amounts only, so they are not added to exact-output errors.

Fees#

LayerHop's fee (and a partner's fee) is the same number of basis points as on any quote, reported in fees.ourFeeBps. LI.FI and deBridge size it on the input. Relay sizes it on the output value, so on a Relay route it comes to slightly less than that share of the input (for example 24.9 instead of 25 bps).

Last updated