Skip to content

Explain /quote amounts and how to compare them in the API guide - #667

Open
raq0x wants to merge 4 commits into
mainfrom
claude/youthful-noether-1ad774
Open

raq0x wants to merge 4 commits into
mainfrom
claude/youthful-noether-1ad774

Conversation

@raq0x

@raq0x raq0x commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • Added a Displaying and Comparing Quotes section to the API integration guide:
    • Explains sellAmount, feeAmount, and buyAmount for sell quotes.
    • Provides plain JavaScript calculations using the API response for total input, before-gas output, and after-gas ranking.
    • Includes an illustrative 10 USDT → USDC comparison with another aggregator.
    • Covers partner fees, token decimals, buy orders, and why execution can improve on a quote.
    • Distinguishes display amounts from amounts used when signing an order.
  • Added prominent gas-cost warnings after the first quote example and above the embedded Swagger reference.
  • Fixed the quickstart to build from quoteResponse.quote, sign sellAmount + feeAmount with feeAmount: "0", apply slippage, handle appData, and submit quoteId and from.
  • Corrected the USDC address in the quote request.
  • Linked to the detailed amount formulas and an optional SDK helper; the API calculations require no SDK.

Why

Direct API integrators can mistake quote.buyAmount for a before-gas output. For sell orders, it already reflects network costs and the applicable protocol fee. Comparing it with another provider’s before-gas output makes CoW look worse even when its net price is better.

Ambire recently encountered this (AmbireTech/ambire-common#2779). These changes explain the returned amounts where API integrators first encounter them and show how to compare quotes on the same basis.

Integrators keep using quote.buyAmount (after network costs) as a generic
toAmount next to other aggregators' before-gas amounts, so CoW ranks last
even at an equal price. Add a "Displaying and Comparing Quotes" section,
fix the quickstart to build the order from quoteResponse.quote, and link
the amount-stage math on the concepts page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raq0x
raq0x requested a review from a team as a code owner October 8, 2026 21:27
@vercel

vercel Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Nov 10, 2026 2:51pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1eb7f4ff-003f-4ebd-b7b0-c80994e8faeb
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@raq0x
raq0x marked this pull request as ready for review October 13, 2026 14:22
Comment thread docs/cow-protocol/integrate/api.mdx Outdated

Settlement network costs are already reflected in `quote.buyAmount`; `quote.feeAmount` describes those costs in the sell token, not an additional amount to deduct from the output.
Other aggregators usually return their output **before** gas, which the user pays on top.
Shown side by side as-is, CoW Protocol ranks lower even at the same price.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to: When quotes are shown side by side as-is, CoW Protocol ranks lower even at the same price.”

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. It now reads "When quotes are shown side by side as-is, …".


### Example

Selling 10 USDT for USDC at a 1:1 price, with 0.40 USDT of network costs and no protocol or partner fee (illustrative numbers).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we say USDT here but USD in other places. Confirm if they're the same thing and correct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They weren't the same thing. USDT is the sell token, and CoW's feeAmount is in sell-token units, so "0.40 USDT of network costs" was right. "0.40 USD" was the dollar value of the gas the user pays in ETH with the other aggregator. The example now says that gas is "worth 0.40 USDC", and the table headers show the amounts are in USDC.

@pretf00d pretf00d left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few tweaks.

…er-1ad774

# Conflicts:
#	docs/cow-protocol/integrate/api.mdx

This branch was successfully deployed

1 active deployment
Preview — 31984f5f Deployed Nov 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants