Exact input and exact output
This page is also Markdown, for agents: /dex-aggregator/guides/amounts.md, and /llms.txt lists every page.
Pass exactly one of amount_in or amount_out. Both are raw integers in the token’s smallest unit (use the token’s decimals from ft_metadata).
Exact input: amount_in
Section titled “Exact input: amount_in”“I pay exactly this much, how much do I get?” This is the most common mode, and every DEX supports it.
amount_in=1000000000000000000000000Quotes come back with output amounts:
"estimated_amount": { "amount_out": "4880007" },"worst_case_amount": { "amount_out": "4831206" }worst_case_amount is the minimum output the transactions accept. If the pools move so that the output would be lower, the swap fails and the input is refunded.
Exact output: amount_out
Section titled “Exact output: amount_out”“I want to receive exactly this much, how much do I pay?”
amount_out=1000000Quotes come back with input amounts:
"estimated_amount": { "amount_in": "205495745391126196067546" },"worst_case_amount": { "amount_in": "210222147535122098577099" }worst_case_amount is the most the trader can pay. The transactions send up to this much and return whatever isn’t used, so the trader needs to hold the worst-case amount, not just the estimate.
Not every DEX supports exact output:
| DEX | Exact output |
|---|---|
| Rhea | ❌ No |
| Rhea DCL | ✅ Yes |
| IntearDex | ✅ Yes, through one DEX on Intear DEX. Routes through more than one, like Plach and then Qoq, are exact input only |
| Plach | ✅ Yes |
| Qoq | ✅ Yes |
| Wrap | ✅ Yes |
DEXs that don’t support it just don’t return a quote, so you may get fewer quotes than with amount_in.
Fee discounts
Section titled “Fee discounts”Traders who stake TEAR (token.intear.near) get a discount on the pool and protocol fees of their swaps on Intear DEX, in IntearDex, Plach and Qoq quotes:
| TEAR staked | Fee discount |
|---|---|
| 10 | 10% |
| 1,000 | 25% |
| 100,000 | 75% |
Pass trader_account_id to get it: the aggregator signs the discount into the route for that trader. Referral fees aren’t discounted. The discount expires after about 10 minutes (1000 blocks), and the swap fails after that, so don’t execute old quotes.
The quote’s discount says how much it saves, in the same direction as estimated_amount:
"estimated_amount": { "amount_out": "4880007" },"worst_case_amount": { "amount_out": "4831206" },"discount": { "amount_out": "1952" }With amount_in, discount is the extra output the trader gets, so you can show it as a bonus. With amount_out, it’s {"amount_in": "..."}, how much less the trader pays.
estimated_amount and worst_case_amount already include the discount, so don’t add it again. It can be 0 when the discount doesn’t change the result, for example on very small amounts. Quotes without a fee discount have no discount field.
To take a trader’s discount in your own calls to Intear DEX, get it signed from GET /fee-discount.