Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
322 changes: 322 additions & 0 deletions docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
---
sidebar_position: 4
---

# How Intents Are Formed

An _intent_ in CoW Protocol is a signed message that represents a user's wish to trade. It doesn't execute a trade directly — instead, it delegates execution to [solvers](../introduction/solvers) who find the optimal path.

:::caution

This document explains the anatomy of intents and interaction with the API at a low level.
For practical use of the protocol, it is recommended to use high-level tools such as the **[CoW SDK](../../reference/sdks/cow-sdk)**.

:::

Forming an intent follows three stages:

```
Intention → Quote → Intent
```
Comment on lines +16 to +20
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stage count inconsistency between intro and section headers.

Line 16 states "three stages" and the diagram shows Intention → Quote → Intent, but the document has four numbered sections (1. Intention, 2. Quote, 3. Amount Stages, 4. Fees & Slippage). Either update the intro to reflect four stages, or re-label/un-number sections 3 and 4 as subsections of intent formation so they don't look like top-level stages.

🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 18-18: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.md` around
lines 16 - 20, The intro claims "three stages" and shows "Intention → Quote →
Intent" but the document contains four numbered sections ("Intention", "Quote",
"Amount Stages", "Fees & Slippage"); fix by either changing the intro to say
"four stages" and updating the diagram to include "Amount Stages" and "Fees &
Slippage", or keep the diagram as-is and move "Amount Stages" and "Fees &
Slippage" to be subsections under the "Intent" section (remove their top-level
numbering) so the count and headers match; update the heading texts "Amount
Stages" and "Fees & Slippage" accordingly to reflect the chosen approach.

Comment on lines +18 to +20
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

MD040: All plain fenced code blocks are missing a language identifier.

markdownlint-cli2 flags all of these. Add an appropriate language hint (e.g. text for diagrams/formulas, http for the URL block, math where LaTeX-style notation is used).

✏️ Proposed fixes (representative examples)
-```
+```text
 Intention → Quote → Intent

```diff
-```
+```http
 POST https://api.cow.fi/mainnet/api/v1/quote

```diff
-```
+```text
 beforeAllFees.sellAmount = quote.sellAmount + quote.feeAmount
 ...

Apply the same pattern to all remaining unlabelled fenced blocks at lines 243, 257, 265, 275, and 287.
</details>




Also applies to: 26-28, 231-238, 243-247, 257-259, 265-267, 275-277, 287-289

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 markdownlint-cli2 (0.21.0)</summary>

[warning] 18-18: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.md around
lines 18 - 20, Several fenced code blocks in the document are missing language
identifiers; update each unlabelled triple-backtick block to include an
appropriate language hint (e.g., add text for diagrams like the block containing
"Intention → Quote → Intent", add http for the POST example "POST
https://api.cow.fi/mainnet/api/v1/quote", and add text or math for formula-like
snippets such as "beforeAllFees.sellAmount = quote.sellAmount +
quote.feeAmount"); apply the same change to all other unlabelled fenced blocks
in the file so every ... has a language tag.


</details>

<!-- fingerprinting:phantom:triton:churro -->

<!-- This is an auto-generated comment by CodeRabbit -->


## 1. Intention

An intention is the user's raw desire to trade. To obtain a quote, you send this intention to the `/quote` API endpoint:

```
POST https://api.cow.fi/mainnet/api/v1/quote
```

The request body describes what the user wants. Basic fields of the request:

```json
{
"kind": "sell",
"sellToken": "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
"buyToken": "0xbe72E441BF55620febc26715db68d3494213D8Cb",
"sellAmountBeforeFee": "1000000000000000000",
"from": "0xfb3c7eb936cAA12B5A884d612393969A557d4307",
"receiver": "0xfb3c7eb936cAA12B5A884d612393969A557d4307",
"validFor": 1800,
...
}
```

| Field | Description |
|---|---|
| `kind` | `"sell"` or `"buy"` — whether you're fixing the sell or buy amount |
| `sellToken` | Token address you're selling |
| `buyToken` | Token address you're buying |
| `sellAmountBeforeFee` | How much you want to sell (for `sell` orders) |
| `from` | Address of the trader |
| `receiver` | Address that receives the bought tokens (often same as `from`) |
| `validFor` | Order validity period in seconds |

:::note

More details see in [Order Book API](../../reference/apis/orderbook.mdx)

:::
Comment on lines +55 to +59
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Grammar: "More details see in"

✏️ Proposed fix
-More details see in [Order Book API](../../reference/apis/orderbook.mdx)
+For more details, see the [Order Book API](../../reference/apis/orderbook.mdx).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
:::note
More details see in [Order Book API](../../reference/apis/orderbook.mdx)
:::
:::note
For more details, see the [Order Book API](../../reference/apis/orderbook.mdx).
:::
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.md` around
lines 55 - 59, Replace the ungrammatical note text "More details see in [Order
Book API](../../reference/apis/orderbook.mdx)" with a corrected phrase such as
"See the Order Book API for more details" (keeping the existing link target);
update the sentence in the note block so it reads clearly and includes proper
punctuation.



## 2. Quote

The `/quote` response provides the price information needed to build the order, including fee breakdowns.

### Sell order response

<img alt="Quote for Sell Order" src="/img/concepts/intents/sell-order-quote.png" width="540"/>

---

```json
{
"protocolFeeBps": "2",
"quote": {
"buyAmount": "191179999",
"feeAmount": "62483346430736",
"sellAmount": "99937516653569264",
"kind": "sell"
},
...
}
```

| Field | Description |
|---|---|
| `protocolFeeBps` | Protocol fee in basis points |
| `quote.sellAmount` | Sell amount **after** network costs have been deducted |
| `quote.feeAmount` | Network costs, in **sell token** units |
| `quote.buyAmount` | Buy amount **after** network costs and protocol fee have been deducted |

### Buy order response

<img alt="Quote for Buy Order" src="/img/concepts/intents/buy-order-quote.png" width="540"/>

---

```json
{
"protocolFeeBps": "2",
"quote": {
"buyAmount": "200000000",
"feeAmount": "42560776189182",
"sellAmount": "104486220751250279",
"kind": "buy"
},
...
}
```

For buy orders, `sellAmount` is **after** the protocol fee, and the `feeAmount` (network costs) is **not yet included** in the sell amount — it must be added separately.

## 3. Amount Stages

The quote response and order construction use a shared vocabulary of amount stages — each representing the token amount at a specific point in the fee pipeline. Understanding these terms is essential for interpreting quote values and building orders correctly.

| Term | Description |
|---|---|
| **`beforeAllFees`** (= `spotPrice`) | The raw exchange rate with no fees applied. This is the theoretical "perfect world" price. It serves as the reference point for calculating partner fees and slippage. |
| **`afterProtocolFees`** | Amount after CoW Protocol's own fee (`protocolFeeBps`) has been applied. |
| **`afterNetworkCosts`** | Amount after gas costs (network costs) have been applied. Network costs are always denominated in the **sell token**, but may be converted to buy token units when applied to the buy side. |
| **`afterPartnerFees`** | Amount after the integrator/partner fee has been deducted. |
| **`afterSlippage`** | The final amount after the user's slippage tolerance has been applied. **This is the value signed into the order** — it is the minimum the user will receive (sell orders) or the maximum they will pay (buy orders). |

### Flow for sell orders

![Quote Amounts Sell Order](/img/concepts/intents/quote-amounts-sell.png)

[//]: # (TODO: add a link to SDK)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Unresolved TODO comments in published documentation.

Both lines contain [//]: # (TODO: add a link to SDK) placeholders. In MDX, this Markdown comment syntax may not be suppressed by the JSX renderer and could either render literally or emit warnings. These TODOs should be resolved — replace each with the actual SDK link — before merging.

Also applies to: 170-170

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.mdx` at line
129, Replace the literal Markdown comment placeholder "[//]: # (TODO: add a link
to SDK)" with a proper MDX link to the SDK in both occurrences; edit the MDX
content so the placeholder string is removed and replaced by an inline link
using standard Markdown/MDX link syntax, e.g. [SDK](<SDK_URL>), ensuring the
actual SDK_URL is provided and the link renders correctly (no raw comment left
behind).


The `/quote` response maps directly to `afterNetworkCosts`. `beforeAllFees` is reconstructed from it for partner fee calculations:

```ts
// /quote response maps to afterNetworkCosts
const afterNetworkCosts = {
sellAmount: quote.sellAmount,
buyAmount: quote.buyAmount,
}

// reconstruct beforeAllFees (spot price) — used as the base for partner fee calculation
const networkCostAmountInBuyCurrency = (quote.buyAmount * quote.feeAmount) / quote.sellAmount
const beforeAllFees = {
sellAmount: quote.sellAmount + quote.feeAmount,
buyAmount: quote.buyAmount + networkCostAmountInBuyCurrency + protocolFeeAmount,
}

// partner fee is deducted from buy amount, relative to spot price
const afterPartnerFees = {
sellAmount: afterNetworkCosts.sellAmount,
buyAmount: afterNetworkCosts.buyAmount - partnerFeeAmount,
}
// partnerFeeAmount = beforeAllFees.buyAmount * partnerFeeBps / 10000

// slippage reduces buy amount (user accepts receiving less)
const afterSlippage = {
sellAmount: afterPartnerFees.sellAmount,
buyAmount: afterPartnerFees.buyAmount - slippageAmount,
}
// slippageAmount = afterPartnerFees.buyAmount * slippageBps / 10000

// sell is set to spot price — settlement contract deducts network costs itself
const amountsToSign = {
sellAmount: beforeAllFees.sellAmount, // = quote.sellAmount + quote.feeAmount
buyAmount: afterSlippage.buyAmount, // minimum to receive
}
```

### Flow for buy orders

[//]: # (TODO: add a link to SDK)

![Quote Amounts Buy Order](/img/concepts/intents/quote-amounts-buy.png)

The `/quote` sell amount maps to `afterProtocolFees`. The buy amount is fixed and maps to `beforeAllFees`:

```ts
// /quote response: sell maps to afterProtocolFees, buy is fixed (= beforeAllFees)
const afterProtocolFees = {
sellAmount: quote.sellAmount,
buyAmount: quote.buyAmount,
}

// reconstruct beforeAllFees (spot price) — used as the base for partner fee calculation
const beforeAllFees = {
sellAmount: quote.sellAmount - protocolFeeAmount,
buyAmount: quote.buyAmount,
}

// add network costs to sell amount
const afterNetworkCosts = {
sellAmount: quote.sellAmount + quote.feeAmount,
buyAmount: quote.buyAmount,
}

// partner fee is added to sell amount, relative to spot price
const afterPartnerFees = {
sellAmount: afterNetworkCosts.sellAmount + partnerFeeAmount,
buyAmount: afterNetworkCosts.buyAmount,
// partnerFeeAmount = beforeAllFees.sellAmount * partnerFeeBps / 10000
}

// slippage increases sell amount (user accepts paying more)
const afterSlippage = {
sellAmount: afterPartnerFees.sellAmount + slippageAmount,
buyAmount: afterPartnerFees.buyAmount,
// slippageAmount = afterPartnerFees.sellAmount * slippageBps / 10000
}

// buy is fixed (exact amount to receive), sell includes all fees and slippage
const amountsToSign = {
sellAmount: afterSlippage.sellAmount, // maximum to pay
buyAmount: beforeAllFees.buyAmount, // = quote.buyAmount
}
```

## 4. Fees & Slippage

Several layers of fees transform the raw spot price into the final amounts signed in the order.

### Fee types

| Fee | Description | Token |
|---|---|---|
| **Network costs** | Gas fees for on-chain execution, estimated by the protocol | Sell token |
| **Protocol fee** | CoW Protocol's fee, expressed in basis points (`protocolFeeBps`) | Buy token (sell orders) / Sell token (buy orders) |
| **Partner fee** | Optional fee added by integrators (e.g. widget providers) | Buy token (sell orders) / Sell token (buy orders) |
| **Slippage** | Tolerance buffer to account for price movements | Buy token (sell orders) / Sell token (buy orders) |

## Spot Price (beforeAllFees)

The spot price is the exchange rate before any fees are applied. It serves as the reference for partner fee and slippage calculations.

### Sell order

```
beforeAllFees.sellAmount = quote.sellAmount + quote.feeAmount

Network Costs (buy token) = (quote.buyAmount × quote.feeAmount) / quote.sellAmount

beforeAllFees.buyAmount = quote.buyAmount + protocolFeeAmount + Network Costs (buy token)

```


### Buy order

```
beforeAllFees.sellAmount = quote.sellAmount - protocolFeeAmount

beforeAllFees.buyAmount = quote.buyAmount\
```
Comment on lines +247 to +251
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stray trailing backslash on beforeAllFees.buyAmount line.

✏️ Proposed fix
-beforeAllFees.buyAmount = quote.buyAmount\
+beforeAllFees.buyAmount = quote.buyAmount
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
beforeAllFees.sellAmount = quote.sellAmount - protocolFeeAmount
beforeAllFees.buyAmount = quote.buyAmount\
```
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 243-243: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.md` around
lines 243 - 247, Remove the stray trailing backslash on the
beforeAllFees.buyAmount assignment so the line correctly assigns quote.buyAmount
(matching the pattern used for beforeAllFees.sellAmount); update the assignment
expression for beforeAllFees.buyAmount to be a normal equals assignment
referencing quote.buyAmount to fix the syntax error.


## Protocol Fee

The protocol fee is expressed as basis points (`protocolFeeBps`) in the quote response.

### Sell orders (buy token units)

For sell orders, `quote.buyAmount` is already **after** the protocol fee has been deducted:

```
protocolFeeAmount = quote.buyAmount × protocolFeeBps / (1 − protocolFeeBps)
```

### Buy orders (sell token units)

For buy orders, the protocol fee is applied to the sum of sell amount and network costs:

```
protocolFeeAmount = (quote.sellAmount + quote.feeAmount) × protocolFeeBps / (1 + protocolFeeBps)
```
Comment on lines +261 to +271
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Protocol fee formulas are mathematically wrong — protocolFeeBps is used raw instead of normalized.

protocolFeeBps is in basis points (e.g. 2 means 0.02%), so it must be divided by 10000 before being used in the fee formula. As written, with protocolFeeBps = 2:

  • Sell order (line 258): quote.buyAmount × 2 / (1 − 2) → negative number.
  • Buy order (line 266): (sellAmount + feeAmount) × 2 / (1 + 2) → ~67% of volume, not ~0.02%.
🐛 Proposed fix
-protocolFeeAmount = quote.buyAmount × protocolFeeBps / (1 − protocolFeeBps)
+protocolFeeAmount = quote.buyAmount × (protocolFeeBps / 10000) / (1 − protocolFeeBps / 10000)
-protocolFeeAmount = (quote.sellAmount + quote.feeAmount) × protocolFeeBps / (1 + protocolFeeBps)
+protocolFeeAmount = (quote.sellAmount + quote.feeAmount) × (protocolFeeBps / 10000) / (1 + protocolFeeBps / 10000)
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 257-257: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


[warning] 265-265: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.md` around
lines 257 - 267, The formulas for protocolFeeAmount use protocolFeeBps raw;
convert it to a decimal rate first (e.g., protocolFeeRate = protocolFeeBps /
10000) and then apply that rate in the formulas: for sell orders compute
protocolFeeAmount = quote.buyAmount × protocolFeeRate / (1 − protocolFeeRate)
and for buy orders compute protocolFeeAmount = (quote.sellAmount +
quote.feeAmount) × protocolFeeRate / (1 + protocolFeeRate); update any
occurrences of protocolFeeBps in the doc to reference protocolFeeRate (or
explicitly show division by 10000) so the examples and formulas use the
normalized basis-point value.


## Partner Fee

The partner (integrator) fee is calculated as a percentage of the **spot price** (`beforeAllFees`), not the post-fee amounts.

### Sell orders (buy token units)

```
partnerFeeAmount = beforeAllFees × partnerFeePercent / 100
```

### Buy orders (sell token units)

The same formula applies, but the result is in sell token units.

Comment on lines +279 to +286
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Partner fee formulas reference beforeAllFees as a scalar — missing property specifier and buy-order formula.

beforeAllFees is an object ({ sellAmount, buyAmount }). Using it bare in a formula is ambiguous. The sell-order formula needs .buyAmount, and the buy-order section omits the formula entirely instead of showing it explicitly.

✏️ Proposed fix
 ### Sell orders (buy token units)
 

-partnerFeeAmount = beforeAllFees × partnerFeePercent / 100
+partnerFeeAmount = beforeAllFees.buyAmount × partnerFeePercent / 100


### Buy orders (sell token units)

-The same formula applies, but the result is in sell token units.
+```
+partnerFeeAmount = beforeAllFees.sellAmount × partnerFeePercent / 100
+```
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.mdx` around
lines 279 - 286, The formulas currently treat beforeAllFees as a scalar; update
the sell-order formula to reference beforeAllFees.buyAmount when computing
partnerFeeAmount (partnerFeeAmount = beforeAllFees.buyAmount × partnerFeePercent
/ 100) and add an explicit buy-order formula that uses beforeAllFees.sellAmount
(partnerFeeAmount = beforeAllFees.sellAmount × partnerFeePercent / 100) so both
sections reference the correct object properties (symbols: beforeAllFees,
partnerFeeAmount, partnerFeePercent).

## Slippage

Slippage tolerance uses the same calculation as the partner fee, but it is applied to the **`afterPartnerFees`** amount rather than the spot price:

```
slippageAmount = afterPartnerFees × slippagePercent / 100
```
Comment on lines +279 to +293
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Inconsistent units between formula sections and inline code — bps vs percent.

The ## Partner Fee and ## Slippage sections express amounts as partnerFeePercent / 100 and slippagePercent / 100, while the TypeScript code blocks in Section 3 consistently use partnerFeeBps / 10000 and slippageBps / 10000. These are numerically equivalent but use different variable names and units without any cross-reference.

Either align the formula notation to use bps consistently, or add a brief inline note making the equivalence explicit (e.g., partnerFeePercent / 100 = partnerFeeBps / 10000).

🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 275-275: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


[warning] 287-287: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.md` around
lines 275 - 289, The formulas use percent variables (partnerFeePercent,
slippagePercent) while the TS examples use basis points (partnerFeeBps,
slippageBps), causing inconsistent units; update the markdown so units are
consistent by either (A) changing the formulas to use bps (e.g., partnerFeeBps /
10000, slippageBps / 10000) or (B) adding a single inline clarifying sentence
near partnerFeeAmount and slippageAmount stating the equivalence
(partnerFeePercent / 100 = partnerFeeBps / 10000 and slippagePercent / 100 =
slippageBps / 10000) and reference afterPartnerFees to show slippage applies to
that amount—pick one approach and apply it to both Partner Fee and Slippage
sections for consistency.

Comment on lines +287 to +293
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Slippage formula uses afterPartnerFees as a scalar — needs property specifier.

Same ambiguity as the partner fee formula: afterPartnerFees is an object. For sell orders the basis is .buyAmount; for buy orders it's .sellAmount.

✏️ Proposed fix
 ### Sell orders
-slippageAmount = afterPartnerFees × slippagePercent / 100
+slippageAmount = afterPartnerFees.buyAmount × slippagePercent / 100

 ### Buy orders
+slippageAmount = afterPartnerFees.sellAmount × slippagePercent / 100
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.mdx` around
lines 287 - 293, Clarify that afterPartnerFees is an object and use the correct
property based on order side: for sell orders use afterPartnerFees.buyAmount and
for buy orders use afterPartnerFees.sellAmount; update the slippage formula
description to read "slippageAmount = afterPartnerFees.buyAmount ×
slippagePercent / 100 (for sell orders)" and "slippageAmount =
afterPartnerFees.sellAmount × slippagePercent / 100 (for buy orders)" and ensure
the surrounding text references afterPartnerFees, slippageAmount,
slippagePercent, and the order side (sell/buy) so readers know which property to
use.


## Forming the Final Order

The signed order combines the quote API response with UI/integrator settings:

| Source | Fields |
|---|---|
| `/quote` API response | `sellAmount`, `buyAmount`, `feeAmount`, `protocolFeeBps` |
| UI / integrator settings | `partnerFee`, `slippage` |

The resulting order contains the **`afterSlippage`** buy amount (for sell orders) or sell amount (for buy orders), which the protocol guarantees as the minimum the user will receive (or maximum they'll pay). Fixed amount is the spot price amount.
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Unclear closing sentence in "Forming the Final Order" intro.

"Fixed amount is the spot price amount." is incomplete — it doesn't identify which amount is fixed, for which order type, or why. Suggest replacing with a clearer summary:

✏️ Proposed fix
-The resulting order contains the **`afterSlippage`** buy amount (for sell orders) or sell amount (for buy orders), which the protocol guarantees as the minimum the user will receive (or maximum they'll pay). Fixed amount is the spot price amount.
+The resulting order contains the **`afterSlippage`** buy amount (for sell orders) or sell amount (for buy orders), which the protocol guarantees as the minimum the user will receive (or maximum they'll pay). The complementary amount (sell for sell-orders, buy for buy-orders) is set to the **spot price** (`beforeAllFees`), allowing solvers to capture any surplus above the guaranteed amount.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cow-protocol/concepts/how-it-works/how-intents-are-formed.mdx` at line
304, Replace the ambiguous sentence "Fixed amount is the spot price amount."
with a clear summary that identifies which amount is fixed and why: state that
for fixed-amount intents (rather than flexible ones) the protocol uses the
spot-price amount as the fixed value, clarifying whether that refers to the buy
or sell side and that it does not change with slippage; reference the term
afterSlippage and the phrase "fixed amount" so readers understand that
afterSlippage is the guaranteed minimum/maximum while the "fixed amount" equals
the spot price used in fixed-amount orders.


### Sell order

```typescript
const orderToSign = {
sellAmount: beforeAllFees.sellAmount,
buyAmount: afterSlippage.buyAmount
}
```

### Buy order

```typescript
const orderToSign = {
sellAmount: afterSlippage.sellAmount,
buyAmount: beforeAllFees.buyAmount
}
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.