Skip to content

Improve docs for solver API: limit amounts vs full amounts - #650

Open
tamir-cow wants to merge 4 commits into
mainfrom
update/limit-full-amounts
Open

Improve docs for solver API: limit amounts vs full amounts#650
tamir-cow wants to merge 4 commits into
mainfrom
update/limit-full-amounts

Conversation

@tamir-cow

@tamir-cow tamir-cow commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Clarify that sellAmount/buyAmount reflect an order's remaining (unfilled) amount, while fullSellAmount/fullBuyAmount are the original signed amounts that stay constant across auctions.

Summary by CodeRabbit

  • Documentation
    • Clarified the distinction between remaining executable order amounts and original signed amounts.
    • Documented the new fullSellAmount and fullBuyAmount fields in the order schema.
    • Updated examples and explanations to reflect partial order execution and volume-based fees.

…led) amount, while fullSellAmount/fullBuyAmount are the original signed amounts that stay constant across auctions.
@tamir-cow
tamir-cow requested a review from a team as a code owner August 3, 2026 07:01
@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 10, 2026 6:51am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: aa81078c-1e5d-4929-8fc1-c321c9bc9c44

📥 Commits

Reviewing files that changed from the base of the PR and between 46f7e31 and 3cb6f4d.

📒 Files selected for processing (1)
  • docs/cow-protocol/reference/core/auctions/schema.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/cow-protocol/reference/core/auctions/schema.md

📝 Walkthrough

Walkthrough

The order schema now distinguishes remaining fee-adjusted executable amounts from original signed amounts. The example includes the full amount fields and explains partial fills and volume-based fees.

Changes

Order amount schema

Layer / File(s) Summary
Amount fields and example
docs/cow-protocol/reference/core/auctions/schema.md
The documentation defines sellAmount and buyAmount as remaining executable amounts. It adds fullSellAmount and fullBuyAmount for the original signed amounts. The example reflects partial fills and volume-based fees.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the documentation change about solver API limit amounts and full amounts.
Description check ✅ Passed The description clearly explains the distinction between remaining amounts and original signed amounts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update/limit-full-amounts

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/cow-protocol/reference/core/auctions/schema.md`:
- Line 121: Update the limit sell order explanation in the entry beginning “The
above entry should be interpreted as follows” to state that the example executes
1000 COW atoms and the user transfers that executed amount plus any
solver-computed fee in COW. Remove the claim that the total transfer is exactly
1000000000000000000000 COW atoms, while preserving the guaranteed USDC amount
and surrounding order semantics.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f1a2083d-6d59-41da-bf42-223cc1b7004e

📥 Commits

Reviewing files that changed from the base of the PR and between b5c361d and 11cf6ff.

📒 Files selected for processing (1)
  • docs/cow-protocol/reference/core/auctions/schema.md

```

The above entry should be interpreted as follows. It is a Fill-or-Kill order since the flag `partiallyFillable` is set to `false`. Moreover, it is a sell order since its `kind` is set to `sell`. Finally, this is a `limit` order, meaning that it has a zero-signed fee, which implies that the solver is free to choose an appropriate fee to cover its execution cost. This means that, if executed, the user will send a total of 1000000000000000000000 COW atoms to the settlement contract and, no matter how much fee the solver will charge, the user is guaranteed to receive at least 284138335 USDC atoms.
The above entry should be interpreted as follows. It is a Fill-or-Kill order since the flag `partiallyFillable` is set to `false`. Moreover, it is a sell order since its `kind` is set to `sell`. Finally, this is a `limit` order, meaning that it has a zero-signed fee, which implies that the solver is free to choose an appropriate fee to cover its execution cost. This means that, if executed, the user will send a total of 1000000000000000000000 COW atoms to the settlement contract and, no matter how much fee the solver will charge, the user is guaranteed to receive at least 284138335 USDC atoms. Since this order has not been partially filled yet, `sellAmount`/`buyAmount` and `fullSellAmount`/`fullBuyAmount` coincide here; for a partially fillable order that already has a non-zero `executed` amount from a previous auction, `sellAmount` and `buyAmount` would instead reflect only the remaining, unfilled portion, while `fullSellAmount` and `fullBuyAmount` would still refer to the order's original amounts.

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Correct the fee explanation for limit sell orders.

For a kind: "sell" limit order, the user transfers executedAmount + fee in the sell token. The current text says the user transfers exactly 1000000000000000000000 COW atoms, even though it also says the solver can charge a fee. State that the example executes 1000 COW atoms and that any solver-computed fee is added to the transfer.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/cow-protocol/reference/core/auctions/schema.md` at line 121, Update the
limit sell order explanation in the entry beginning “The above entry should be
interpreted as follows” to state that the example executes 1000 COW atoms and
the user transfers that executed amount plus any solver-computed fee in COW.
Remove the claim that the total transfer is exactly 1000000000000000000000 COW
atoms, while preserving the guaranteed USDC amount and surrounding order
semantics.

Comment thread docs/cow-protocol/reference/core/auctions/schema.md Outdated
…uyAmount: partial fills reduce them to the remaining unfilled amount, and volume-based protocol/partner fees additionally scale them so solvers can route on sellAmount/buyAmount while ignoring fees, and the driver can charge those fees afterwards without violating the user's original signed limit.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/cow-protocol/reference/core/auctions/schema.md`:
- Line 123: The example explanation should not state that the user sends exactly
1000000000000000000000 COW atoms when a solver fee may apply. Update the
sell-fulfillment wording to describe the transfer as 1000 COW atoms plus any
solver-computed fee, while preserving the existing minimum USDC guarantee and
other order details.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c816f04-5735-4455-9471-98dedcac92a0

📥 Commits

Reviewing files that changed from the base of the PR and between 11cf6ff and 46f7e31.

📒 Files selected for processing (1)
  • docs/cow-protocol/reference/core/auctions/schema.md

Comment thread docs/cow-protocol/reference/core/auctions/schema.md Outdated
…uyAmount: partial fills reduce them to the remaining unfilled amount, and volume-based protocol/partner fees additionally scale them so solvers can route on sellAmount/buyAmount while ignoring fees, and the driver can charge those fees afterwards without violating the user's original signed limit.
```

The above entry should be interpreted as follows. It is a Fill-or-Kill order since the flag `partiallyFillable` is set to `false`. Moreover, it is a sell order since its `kind` is set to `sell`. Finally, this is a `limit` order, meaning that it has a zero-signed fee, which implies that the solver is free to choose an appropriate fee to cover its execution cost. This means that, if executed, the user will send a total of 1000000000000000000000 COW atoms to the settlement contract and, no matter how much fee the solver will charge, the user is guaranteed to receive at least 284138335 USDC atoms.
The above entry should be interpreted as follows. It is a Fill-or-Kill order since the flag `partiallyFillable` is set to `false`. Moreover, it is a sell order since its `kind` is set to `sell`. Finally, this is a `limit` order, meaning that it has a zero-signed fee, which implies that the solver is free to choose an appropriate fee to cover its execution cost. This means that, if executed, the user will send a total of 1000000000000000000000 COW atoms to the settlement contract and, no matter how much fee the solver will charge, the user is guaranteed to receive at least 284138335 USDC atoms. Here, `sellAmount`/`buyAmount` equal `fullSellAmount`/`fullBuyAmount` because the order has not been partially filled and has no `protocolFees` applied. In general they can differ: partial fills reduce `sellAmount`/`buyAmount` to the remaining unfilled amount, and volume-based fees scale them down further, so the driver can charge those fees afterwards without violating the user's original limit.

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.

This case of buyAmount = fullBuyAmount does not happen in practice on most chains. This example should cover the usual case, I think, of a 2bps volume fee. The given signed amount of 284138335 would be consistent with a buyAmount of 284138335 / (1 - 0.0002) = 284195174.03... rounded to 284195174.

@fhenneke fhenneke 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.

I would remove the info on the fee policy entry. Otherwise looks good now.

Comment on lines -113 to +123
"class": "limit"
"class": "limit",
"protocolFees": [
{
"kind": "volume",
"factor": 0.0002
}
]

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.

I would revert this change. Fee policies are not always forwarded to solvers. (This is also not documented cleanly anywhere, I had to ask Claude to give some pointers on this.)
As an example, this auction instance does have the modified amounts but not any fee policies.

```

The above entry should be interpreted as follows. It is a Fill-or-Kill order since the flag `partiallyFillable` is set to `false`. Moreover, it is a sell order since its `kind` is set to `sell`. Finally, this is a `limit` order, meaning that it has a zero-signed fee, which implies that the solver is free to choose an appropriate fee to cover its execution cost. This means that, if executed, the user will send a total of 1000000000000000000000 COW atoms to the settlement contract and, no matter how much fee the solver will charge, the user is guaranteed to receive at least 284138335 USDC atoms.
The above entry should be interpreted as follows. It is a Fill-or-Kill order since the flag `partiallyFillable` is set to `false`. Moreover, it is a sell order since its `kind` is set to `sell`. Finally, this is a `limit` order, meaning that it has a zero-signed fee, which implies that the solver is free to choose an appropriate fee to cover its execution cost. This means that, if executed, the user will send a total of 1000000000000000000000 COW atoms to the settlement contract, and the user has signed for a minimum of 284138335 USDC atoms (`fullBuyAmount`). The order also carries a `protocolFees` entry for a 2 bps volume fee, which the driver will deduct from the buy side once the trade settles. Since the order has not been partially filled, `sellAmount` still equals `fullSellAmount`, but `buyAmount` is scaled up from `fullBuyAmount` to net out that fee: `buyAmount` = `fullBuyAmount` / (1 - 0.0002) = 284138335 / 0.9998 ≈ 284195174.03, rounded down to 284195174. Solvers can then route on `sellAmount`/`buyAmount` while ignoring fees entirely, and once the driver charges its 2 bps cut of the 284195174 USDC bought (≈56839 USDC atoms), the user is left with exactly the signed minimum of 284138335 USDC atoms — so the original limit is never violated. This is the usual case in practice: on most chains essentially every order carries some volume-based protocol or partner fee, so `buyAmount`/`sellAmount` differ from `fullBuyAmount`/`fullSellAmount` even without any partial fill; the two only coincide when there is no such fee, which is rare.

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.

Probably rephrase this then from

The order also carries a protocolFees entry for a 2 bps volume fee, which the driver will deduct from the buy side once the trade settles.

to

The order also carries a 2 bps volume fee, which the driver will deduct from the buy side once the trade settles.

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