Skip to content

docs: add comprehensive generalized wrappers documentation#595

Open
kaze-cow wants to merge 2 commits intomainfrom
add-wrapper
Open

docs: add comprehensive generalized wrappers documentation#595
kaze-cow wants to merge 2 commits intomainfrom
add-wrapper

Conversation

@kaze-cow
Copy link

@kaze-cow kaze-cow commented Feb 12, 2026

Description

Add complete documentation for CoW Protocol's generalized wrappers feature across three audience-specific files:

Changes

  • concepts/order-types/wrappers.md: High-level overview explaining what wrappers are, use cases (Euler leverage, flash loans, TWAP, protocol hooks), benefits, and considerations
  • integrate/wrappers.mdx: Practical integration guide with three sections:
    • For Order Creators: How to add wrappers to orders via appData
    • For Wrapper Developers: Building custom wrapper contracts with security requirements and implementation examples
    • For Solvers: Encoding wrapper settlements and handling wrapper execution
  • reference/contracts/periphery/wrapper.mdx: Smart contract reference focused on ICowWrapper interface, CowWrapper abstract contract, implementation patterns, and on-chain behavior

Summary by CodeRabbit

  • Documentation
    • Added comprehensive docs for Generalized Wrappers: concepts, architecture, and quick-start examples.
    • New integration guide covering building, encoding, and using wrappers (single & chained), validation, and solver behavior.
    • Details on authentication, execution flow, data encoding, security considerations, gas trade-offs, troubleshooting, and example implementations.

Add complete documentation for CoW Protocol's generalized wrappers feature
across three audience-specific files:

- concepts/order-types/wrappers.md: High-level overview explaining what
  wrappers are, use cases (Euler leverage, flash loans, TWAP, protocol hooks),
  benefits, and considerations

- integrate/wrappers.mdx: Practical integration guide with three sections:
  * For Order Creators: How to add wrappers to orders via appData
  * For Wrapper Developers: Building custom wrapper contracts with security
    requirements and implementation examples
  * For Solvers: Encoding wrapper settlements and handling wrapper execution

- reference/contracts/periphery/wrapper.mdx: Smart contract reference focused
  on ICowWrapper interface, CowWrapper abstract contract, implementation
  patterns, and on-chain behavior

Each file serves a distinct purpose and audience while cross-linking to
provide comprehensive coverage of the wrapper system.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@kaze-cow kaze-cow requested a review from anxolin February 12, 2026 15:58
@kaze-cow kaze-cow self-assigned this Feb 12, 2026
@kaze-cow kaze-cow requested a review from a team as a code owner February 12, 2026 15:58
@vercel
Copy link

vercel bot commented Feb 12, 2026

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Feb 12, 2026 4:09pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

Adds three new documentation pages that introduce Generalized Wrappers for the CoW Protocol, covering concepts, integration steps, and a technical reference for wrapper contract architecture, encoding, execution flow, and security considerations.

Changes

Cohort / File(s) Summary
Wrapper Documentation
docs/cow-protocol/concepts/order-types/wrappers.md, docs/cow-protocol/integrate/wrappers.mdx, docs/cow-protocol/reference/contracts/periphery/wrapper.mdx
Introduces Generalized Wrappers: conceptual overview, integration guide (building, encoding appData.wrappers, omittable vs non-omittable behavior, solver/driver integration), and technical reference (wrappedSettle flow, _wrap/_next/_parseWrapperData, data encoding, examples, security notes).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  rect rgba(200,220,255,0.5)
    participant User
    participant Solver
    participant Authenticator
    participant WrapperA as Wrapper (A)
    participant WrapperB as Wrapper (B)
    participant Settlement as SettlementContract
    participant External as ExternalProtocol
  end

  User->>Solver: submit order + appData.wrappers
  Solver->>Authenticator: validate wrapper allowlist
  Authenticator-->>Solver: allow / deny
  alt allowed
    Solver->>WrapperA: call wrappedSettle(dataA, next=WrapperB)
    WrapperA->>WrapperA: _wrap pre-settlement logic
    WrapperA->>WrapperB: _next(pass remaining data)
    WrapperB->>WrapperB: _wrap pre/post logic
    WrapperB->>Settlement: _next -> call settlement target
    Settlement->>External: execute settlement (swaps, transfers)
    External-->>Settlement: settlement result
    Settlement-->>WrapperB: return
    WrapperB->>WrapperA: return (post-settle)
    WrapperA-->>Solver: final return
  else denied
    Authenticator-->>Solver: revert / reject
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Suggested reviewers

  • pretf00d

Poem

🐇 I hop through wrappers, layer by layer,
Pre-checks and post-hooks handled with care,
Chains of logic, passing the key,
Settlements tidy, modularly free,
A rabbit's cheer for clean contract fare!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding comprehensive documentation for generalized wrappers across three files.
Description check ✅ Passed The description fully covers required sections with specific file changes, clear organization into three audience-focused files, and detailed scope for each file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-wrapper

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 14

🤖 Fix all issues with AI agents
In `@docs/cow-protocol/concepts/order-types/wrappers.md`:
- Line 44: Fix the spelling in the header "### Progmatic Orders" by changing it
to "### Programmatic Orders" in the docs file; locate the header string
"Progmatic Orders" and replace it with "Programmatic Orders" so the section
title is correct.
- Line 7: Fix the typos and punctuation in the "Generalized wrappers" sentence:
change "progmatic" to "programmatic" and replace the double dash "--" with an em
dash "—" (or a comma) so the sentence reads cleanly (e.g., "...like flash loans,
leveraged positions, and programmatic orders— all while preserving..."). Update
the sentence in the wrappers.md content where "Generalized wrappers is a new
framework..." appears.
- Line 17: Fix typos and minor wording in the paragraph: change "guarenteed" to
"guaranteed", remove the extra space before "wrappers" so it reads "audited and
wrappers" properly as "audited wrappers" (or "audited and wrappers" -> remove
stray "and" if intended), change "solver" to plural "solvers", and lowercase
"Wrapper functionality" to "wrapper functionality" for consistency; update the
sentence in the docs content (the paragraph referencing
GPv2AllowlistAuthenticator and settlement contract) accordingly.
- Line 74: Update the phrase "high quality wrapper implementations" to use a
hyphenated compound adjective: change it to "high-quality wrapper
implementations" in the sentence describing the approval process by the
allowlist authenticator and CoW DAO (the sentence beginning "Wrappers cannot be
deployed..."). Ensure the hyphen is added only when "high-quality" directly
modifies "wrapper implementations."
- Line 92: Update the broken link pointing to
../../reference/contracts/periphery/wrapper.md by changing its extension to .mdx
(../../reference/contracts/periphery/wrapper.mdx) in the text "**For technical
specs**" inside the wrapper documentation; locate the markdown link string
"../../reference/contracts/periphery/wrapper.md" and replace ".md" with ".mdx"
so it points to the correct Technical Reference file (wrapper.mdx).

In `@docs/cow-protocol/integrate/wrappers.mdx`:
- Line 131: Replace the placeholder link in the sentence "Wrappers are specified
in the order's [`appData`](TODO) under the `wrappers` field" with the actual
documentation path for appData: locate the appData docs by searching the repo
for the "appData" heading or file (the page that documents order.appData), then
update the TODO to that MDX/URL (use a relative docs path or absolute docs URL
consistent with other links in docs/cow-protocol/integrate/wrappers.mdx) so the
link points directly to the appData section.
- Line 320: Replace the misspelled word "simpulate" with "simulate" in the
sentence that reads "Account for wrapper gas overhead in your bids. The easiest
way to do this is to simpulate the wrapper transaction against an empty
settlement." so it reads "...simulate the wrapper transaction against an empty
settlement."; locate that exact sentence to make the single-word correction.
- Line 164: Update the incorrect documentation link: change the path string in
the sentence referencing GPv2AllowlistAuthenticator from
../references/contracts/core/allowlist.md to
../reference/contracts/core/allowlist.md so the link points to the existing
reference directory and continues to mention GPv2AllowlistAuthenticator for
context.
- Line 343: Update the broken link in docs/cow-protocol/integrate/wrappers.mdx
by changing the reference from "../reference/contracts/periphery/wrapper.md" to
"../reference/contracts/periphery/wrapper.mdx" so it points to the actual
wrapper.mdx file; locate the link text "**[Contracts
Reference](../reference/contracts/periphery/wrapper.md)**" and replace the .md
extension with .mdx.
- Line 8: The navigation link in docs/cow-protocol/integrate/wrappers.mdx has
mismatched bold markers around the link text ("Executing Wrappers as a Solver"
with anchor "#for-solvers") causing formatting issues; fix it by making the bold
markers balanced — either wrap the entire link and trailing description in
**...** or remove the leading ** so the link uses normal markdown; update the
line containing the "[Executing Wrappers as a Solver](`#for-solvers`) - Everything
solvers need to know to execute wrapper orders" text to have correct opening and
closing bold markers.
- Around line 254-257: The docs use two different names for the same
value—chainedWrapperData vs wrapperData—causing confusion in the call to
wrapperContract.interface.encodeFunctionData("wrappedSettle"); make the names
consistent by either (A) changing the second parameter in the encodeFunctionData
call from chainedWrapperData to wrapperData, or (B) updating the earlier
function that returns wrapperData to return/mention chainedWrapperData instead;
ensure the comment "From step 3" and the variable name used in wrappedSettle's
argument list (wrapperData/chainedWrapperData) match exactly.

In `@docs/cow-protocol/reference/contracts/periphery/wrapper.mdx`:
- Line 477: Replace the misspelled word "reccomended" with "recommended" in the
sentence that reads "It is reccomended to use
[Cannon](https://usecannon.com/learn) to make it easy to redeploy your
wrappers." (search for the exact string "reccomended" in the wrapper.mdx content
to locate the spot).
- Line 283: Fix the spelling mistake in the documentation: change "reccomended"
to "recommended" in the sentence mentioning ICowWrapper and CowWrapper so it
reads "It is strongly recommended to **NOT** implement `ICowWrapper` directly.
The `CowWrapper` abstract contract provides:". Update the phrase near the
references to ICowWrapper and CowWrapper accordingly.
- Around line 129-134: Fix the malformed Markdown code block under the
"Example:" section by converting the loose fenced text into a proper fenced code
block: ensure the "Example:" label is followed by a fenced block using ```text,
include the two lines "[0x0005][0xAABBCCDDEE][0x1234...ABCD][0x0003][0x112233]"
and "↑len    ↑data         ↑next wrapper  ↑len   ↑data" exactly as shown, and
close the block with ``` so the snippet displays correctly in the docs reference
for wrapper.mdx.
🧹 Nitpick comments (1)
docs/cow-protocol/reference/contracts/periphery/wrapper.mdx (1)

43-43: Clarify incomplete phrase.

"allowing CoW orders" appears incomplete. Perhaps it should be "allowing multiple CoW orders to use different wrappers in the same batch" or similar?

📝 Suggested clarification
-3. **Nested Support**: Multiple wrappers chain by encoding addresses sequentially, allowing CoW orders
+3. **Nested Support**: Multiple wrappers chain by encoding addresses sequentially, allowing multiple orders with different wrappers in the same settlement batch


# Generalized Wrappers

Generalized wrappers is a new framework to allow custom logic to execute before and/or after order settlement on CoW Protocol. They enable complex DeFi workflows—like flash loans, leveraged positions, and progmatic orders--all while preserving the security and assurances granted by CoW Protocol.
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

Fix spelling errors.

"progmatic" should be "programmatic" and the sentence has punctuation issues (double dash should be em dash or comma).

✍️ Proposed fix
-Generalized wrappers is a new framework to allow custom logic to execute before and/or after order settlement on CoW Protocol. They enable complex DeFi workflows—like flash loans, leveraged positions, and progmatic orders--all while preserving the security and assurances granted by CoW Protocol.
+Generalized wrappers is a new framework to allow custom logic to execute before and/or after order settlement on CoW Protocol. They enable complex DeFi workflows—like flash loans, leveraged positions, and programmatic orders—all while preserving the security and assurances granted by CoW Protocol.
📝 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
Generalized wrappers is a new framework to allow custom logic to execute before and/or after order settlement on CoW Protocol. They enable complex DeFi workflows—like flash loans, leveraged positions, and progmatic orders--all while preserving the security and assurances granted by CoW Protocol.
Generalized wrappers is a new framework to allow custom logic to execute before and/or after order settlement on CoW Protocol. They enable complex DeFi workflows—like flash loans, leveraged positions, and programmatic ordersall while preserving the security and assurances granted by CoW Protocol.
🧰 Tools
🪛 LanguageTool

[grammar] ~7-~7: Ensure spelling is correct
Context: ...e flash loans, leveraged positions, and progmatic orders--all while preserving the securi...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
In `@docs/cow-protocol/concepts/order-types/wrappers.md` at line 7, Fix the typos
and punctuation in the "Generalized wrappers" sentence: change "progmatic" to
"programmatic" and replace the double dash "--" with an em dash "—" (or a comma)
so the sentence reads cleanly (e.g., "...like flash loans, leveraged positions,
and programmatic orders— all while preserving..."). Update the sentence in the
wrappers.md content where "Generalized wrappers is a new framework..." appears.


### Wrapper Authentication

For security, all wrappers must be approved through CoW Protocol's `GPv2AllowlistAuthenticator` before they can be used. This ensures that only audited and wrappers can interact with the settlement contract, protecting users, solver, and the protocol from malicious contracts. Unlike [hooks](./cow-hooks.mdx), Wrapper functionality can revert the execution of a transaction, ensuring sensitive user operations such as cross-chain operations can be guarenteed to be completed.
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

Fix spelling error.

"guarenteed" should be "guaranteed".

✍️ Proposed fix
-For security, all wrappers must be approved through CoW Protocol's `GPv2AllowlistAuthenticator` before they can be used. This ensures that only audited and  wrappers can interact with the settlement contract, protecting users, solver, and the protocol from malicious contracts. Unlike [hooks](./cow-hooks.mdx), Wrapper functionality can revert the execution of a transaction, ensuring sensitive user operations such as cross-chain operations can be guarenteed to be completed.
+For security, all wrappers must be approved through CoW Protocol's `GPv2AllowlistAuthenticator` before they can be used. This ensures that only audited wrappers can interact with the settlement contract, protecting users, solvers, and the protocol from malicious contracts. Unlike [hooks](./cow-hooks.mdx), wrapper functionality can revert the execution of a transaction, ensuring sensitive user operations such as cross-chain operations can be guaranteed to be completed.

Note: Also fixed "solver" → "solvers", removed extra space before "wrappers", and capitalization of "Wrapper functionality" → "wrapper functionality" for consistency.

📝 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
For security, all wrappers must be approved through CoW Protocol's `GPv2AllowlistAuthenticator` before they can be used. This ensures that only audited and wrappers can interact with the settlement contract, protecting users, solver, and the protocol from malicious contracts. Unlike [hooks](./cow-hooks.mdx), Wrapper functionality can revert the execution of a transaction, ensuring sensitive user operations such as cross-chain operations can be guarenteed to be completed.
For security, all wrappers must be approved through CoW Protocol's `GPv2AllowlistAuthenticator` before they can be used. This ensures that only audited wrappers can interact with the settlement contract, protecting users, solvers, and the protocol from malicious contracts. Unlike [hooks](./cow-hooks.mdx), wrapper functionality can revert the execution of a transaction, ensuring sensitive user operations such as cross-chain operations can be guaranteed to be completed.
🧰 Tools
🪛 LanguageTool

[grammar] ~17-~17: Ensure spelling is correct
Context: ...s such as cross-chain operations can be guarenteed to be completed. ### Wrapper Nesting ...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
In `@docs/cow-protocol/concepts/order-types/wrappers.md` at line 17, Fix typos and
minor wording in the paragraph: change "guarenteed" to "guaranteed", remove the
extra space before "wrappers" so it reads "audited and wrappers" properly as
"audited wrappers" (or "audited and wrappers" -> remove stray "and" if
intended), change "solver" to plural "solvers", and lowercase "Wrapper
functionality" to "wrapper functionality" for consistency; update the sentence
in the docs content (the paragraph referencing GPv2AllowlistAuthenticator and
settlement contract) accordingly.


Currently, CoW Protocol uses a dedicated `FlashLoanRouter` contract for flash loan functionality. However, this implementation comes with additional implementation effort from both the solvers and the CoW Protocol backend infrastructure. With generalized wrappers, flash loan integration becomes simpler and more flexible.

### Progmatic Orders
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

Fix spelling error.

"Progmatic" should be "Programmatic".

✍️ Proposed fix
-### Progmatic Orders
+### Programmatic Orders
📝 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
### Progmatic Orders
### Programmatic Orders
🧰 Tools
🪛 LanguageTool

[grammar] ~44-~44: Ensure spelling is correct
Context: ...becomes simpler and more flexible. ### Progmatic Orders By introducing a wrapped order ...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
In `@docs/cow-protocol/concepts/order-types/wrappers.md` at line 44, Fix the
spelling in the header "### Progmatic Orders" by changing it to "###
Programmatic Orders" in the docs file; locate the header string "Progmatic
Orders" and replace it with "Programmatic Orders" so the section title is
correct.


### Requires Protocol Approval

Wrappers cannot be deployed and used immediately—they must be approved by the CoW DAO through the allowlist authenticator. This approval process ensures high quality wrapper implementations and safety for solvers, but means there's a roadblock for developers looking to extend CoW Protocol. Developers should plan for this approval process when building wrapper-based integrations.
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

Add hyphen to compound adjective.

"high quality" should be hyphenated when used as a compound adjective before a noun.

✍️ Proposed fix
-Wrappers cannot be deployed and used immediately—they must be approved by the CoW DAO through the allowlist authenticator. This approval process ensures high quality wrapper implementations and safety for solvers, but means there's a roadblock for developers looking to extend CoW Protocol. Developers should plan for this approval process when building wrapper-based integrations.
+Wrappers cannot be deployed and used immediately—they must be approved by the CoW DAO through the allowlist authenticator. This approval process ensures high-quality wrapper implementations and safety for solvers, but means there's a roadblock for developers looking to extend CoW Protocol. Developers should plan for this approval process when building wrapper-based integrations.
📝 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
Wrappers cannot be deployed and used immediately—they must be approved by the CoW DAO through the allowlist authenticator. This approval process ensures high quality wrapper implementations and safety for solvers, but means there's a roadblock for developers looking to extend CoW Protocol. Developers should plan for this approval process when building wrapper-based integrations.
Wrappers cannot be deployed and used immediately—they must be approved by the CoW DAO through the allowlist authenticator. This approval process ensures high-quality wrapper implementations and safety for solvers, but means there's a roadblock for developers looking to extend CoW Protocol. Developers should plan for this approval process when building wrapper-based integrations.
🧰 Tools
🪛 LanguageTool

[grammar] ~74-~74: Use a hyphen to join words.
Context: ...ator. This approval process ensures high quality wrapper implementations and safe...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
In `@docs/cow-protocol/concepts/order-types/wrappers.md` at line 74, Update the
phrase "high quality wrapper implementations" to use a hyphenated compound
adjective: change it to "high-quality wrapper implementations" in the sentence
describing the approval process by the allowlist authenticator and CoW DAO (the
sentence beginning "Wrappers cannot be deployed..."). Ensure the hyphen is added
only when "high-quality" directly modifies "wrapper implementations."


### Gas Estimation

Account for wrapper gas overhead in your bids. The easiest way to do this is to simpulate the wrapper transaction against an empty settlement.
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

Fix spelling error.

"simpulate" should be "simulate".

✍️ Proposed fix
-Account for wrapper gas overhead in your bids. The easiest way to do this is to simpulate the wrapper transaction against an empty settlement.
+Account for wrapper gas overhead in your bids. The easiest way to do this is to simulate the wrapper transaction against an empty settlement.
📝 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
Account for wrapper gas overhead in your bids. The easiest way to do this is to simpulate the wrapper transaction against an empty settlement.
Account for wrapper gas overhead in your bids. The easiest way to do this is to simulate the wrapper transaction against an empty settlement.
🧰 Tools
🪛 LanguageTool

[grammar] ~320-~320: Ensure spelling is correct
Context: ... bids. The easiest way to do this is to simpulate the wrapper transaction against an empt...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
In `@docs/cow-protocol/integrate/wrappers.mdx` at line 320, Replace the misspelled
word "simpulate" with "simulate" in the sentence that reads "Account for wrapper
gas overhead in your bids. The easiest way to do this is to simpulate the
wrapper transaction against an empty settlement." so it reads "...simulate the
wrapper transaction against an empty settlement."; locate that exact sentence to
make the single-word correction.

Comment on lines +129 to +134
```
Example:
```
[0x0005][0xAABBCCDDEE][0x1234...ABCD][0x0003][0x112233]
↑len ↑data ↑next wrapper ↑len ↑data
```
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

Fix markdown formatting for code example.

The "Example:" line and subsequent code block have inconsistent formatting. The code block isn't properly closed and formatted.

🔧 Proposed fix
-Example: 
-```
+**Example:**
+```text
 [0x0005][0xAABBCCDDEE][0x1234...ABCD][0x0003][0x112233]
 ↑len    ↑data         ↑next wrapper  ↑len   ↑data
</details>

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

In @docs/cow-protocol/reference/contracts/periphery/wrapper.mdx around lines 129

  • 134, Fix the malformed Markdown code block under the "Example:" section by
    converting the loose fenced text into a proper fenced code block: ensure the
    "Example:" label is followed by a fenced block using text, include the two lines "[0x0005][0xAABBCCDDEE][0x1234...ABCD][0x0003][0x112233]" and "↑len ↑data ↑next wrapper ↑len ↑data" exactly as shown, and close the block with so the snippet displays correctly in the docs reference for
    wrapper.mdx.

</details>

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

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


#### 1. Use CowWrapper Abstract Contract

It is strongly reccomended to **NOT** implement `ICowWrapper` directly. The `CowWrapper` abstract contract provides:
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

Fix spelling error.

"reccomended" should be "recommended".

✍️ Proposed fix
-It is strongly reccomended to **NOT** implement `ICowWrapper` directly. The `CowWrapper` abstract contract provides:
+It is strongly recommended to **NOT** implement `ICowWrapper` directly. The `CowWrapper` abstract contract provides:
📝 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
It is strongly reccomended to **NOT** implement `ICowWrapper` directly. The `CowWrapper` abstract contract provides:
It is strongly recommended to **NOT** implement `ICowWrapper` directly. The `CowWrapper` abstract contract provides:
🧰 Tools
🪛 LanguageTool

[grammar] ~283-~283: Ensure spelling is correct
Context: ...apper Abstract Contract It is strongly reccomended to NOT implement ICowWrapper dire...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
In `@docs/cow-protocol/reference/contracts/periphery/wrapper.mdx` at line 283, Fix
the spelling mistake in the documentation: change "reccomended" to "recommended"
in the sentence mentioning ICowWrapper and CowWrapper so it reads "It is
strongly recommended to **NOT** implement `ICowWrapper` directly. The
`CowWrapper` abstract contract provides:". Update the phrase near the references
to ICowWrapper and CowWrapper accordingly.


### Settlement Upgrades

When settlement contract upgrades, all wrappers must be redeployed. It is reccomended to use [Cannon](https://usecannon.com/learn) to make it easy to redeploy your wrappers.
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

Fix spelling error.

"reccomended" should be "recommended".

✍️ Proposed fix
-When settlement contract upgrades, all wrappers must be redeployed. It is reccomended to use [Cannon](https://usecannon.com/learn) to make it easy to redeploy your wrappers.
+When settlement contract upgrades, all wrappers must be redeployed. It is recommended to use [Cannon](https://usecannon.com/learn) to make it easy to redeploy your wrappers.
🧰 Tools
🪛 LanguageTool

[grammar] ~477-~477: Ensure spelling is correct
Context: ... all wrappers must be redeployed. It is reccomended to use [Cannon](https://usecannon.com/l...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
In `@docs/cow-protocol/reference/contracts/periphery/wrapper.mdx` at line 477,
Replace the misspelled word "reccomended" with "recommended" in the sentence
that reads "It is reccomended to use [Cannon](https://usecannon.com/learn) to
make it easy to redeploy your wrappers." (search for the exact string
"reccomended" in the wrapper.mdx content to locate the spot).

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@docs/cow-protocol/concepts/order-types/wrappers.md`:
- Line 11: In the sentence starting "Wrappers are smart contracts that 'wrap'
the settlement process..." replace "surrounding settlement contract" with
"surrounding the settlement contract" so the phrase reads "executing custom
logic surrounding the settlement contract" to correct the missing article;
locate the phrase in wrappers.md and update that sentence accordingly.
- Around line 52-54: Replace the inconsistent "Cross chain transfers (pre- or
post- transfer)" phrase with a hyphenated form: "Cross-chain transfers (pre- or
post-transfer)" so it matches the existing "cross-chain" usage and also
hyphenates "post-transfer"; update the exact line containing the phrase "Cross
chain transfers" in the document.

In `@docs/cow-protocol/integrate/wrappers.mdx`:
- Around line 12-16: Multiple subsection headings (e.g., "Overview", "Adding
Wrappers to Orders", "Detecting Wrapper Orders" and other similar entries) are
incorrectly using "##" and therefore sit at the same level as the three main
audience headings ("For Wrapper Developers", "For Order Creators…", "For
Solvers"); change these subsection headings from "##" to "###" so they become
children of their respective audience sections (update every occurrence
referenced in the comment such as the "Overview", "Adding Wrappers to Orders",
"Detecting Wrapper Orders" headings and the other instances mentioned) to
restore proper heading hierarchy and TOC nesting.
- Around line 217-237: The encodeWrapperData function assumes wrapper.data
always exists and uses wrapper.data.length and slice, which breaks when
WrapperCall.data is optional; update encodeWrapperData to normalize data per
wrapper (e.g., const data = wrapper.data ?? '0x'; if (data === '') data = '0x'),
compute dataLength safely as Math.max(0, (data.length - 2) / 2), generate
lengthHex from that number, and only append data.slice(2) when dataLength > 0;
apply these changes in the encodeWrapperData function so it handles undefined or
empty wrapper.data without throwing.
🧹 Nitpick comments (1)
docs/cow-protocol/integrate/wrappers.mdx (1)

298-314: Wrapper accumulation example blindly collects duplicates.

The conceptual example pushes all wrappers from all orders without deduplication. If two orders reference the same wrapper, it would appear twice. Consider adding a comment or dedup logic to clarify expected behavior for readers.


## What are Wrappers?

Wrappers are smart contracts that "wrap" the settlement process, executing custom logic surrounding settlement contract. When a solver executes a settlement that includes a wrapper, they call the wrapper contract instead of the settlement contract directly. The wrapper calls the settlement contract on behalf of the solver.
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

Missing article: "surrounding settlement contract" → "surrounding the settlement contract".

-Wrappers are smart contracts that "wrap" the settlement process, executing custom logic surrounding settlement contract.
+Wrappers are smart contracts that "wrap" the settlement process, executing custom logic surrounding the settlement contract.
📝 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
Wrappers are smart contracts that "wrap" the settlement process, executing custom logic surrounding settlement contract. When a solver executes a settlement that includes a wrapper, they call the wrapper contract instead of the settlement contract directly. The wrapper calls the settlement contract on behalf of the solver.
Wrappers are smart contracts that "wrap" the settlement process, executing custom logic surrounding the settlement contract. When a solver executes a settlement that includes a wrapper, they call the wrapper contract instead of the settlement contract directly. The wrapper calls the settlement contract on behalf of the solver.
🤖 Prompt for AI Agents
In `@docs/cow-protocol/concepts/order-types/wrappers.md` at line 11, In the
sentence starting "Wrappers are smart contracts that 'wrap' the settlement
process..." replace "surrounding settlement contract" with "surrounding the
settlement contract" so the phrase reads "executing custom logic surrounding the
settlement contract" to correct the missing article; locate the phrase in
wrappers.md and update that sentence accordingly.

Comment on lines +52 to +54
- Compliance checks (e.g., OFAC screening)
- Cross chain transfers (pre- or post- transfer)
- Deposit in a vault or other wrapper contract (swap and stake)
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 hyphenation: "Cross chain" should be "Cross-chain".

Line 17 already uses "cross-chain" correctly. Line 53 should match:

-- Cross chain transfers (pre- or post- transfer)
+- Cross-chain transfers (pre- or post-transfer)
📝 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
- Compliance checks (e.g., OFAC screening)
- Cross chain transfers (pre- or post- transfer)
- Deposit in a vault or other wrapper contract (swap and stake)
- Compliance checks (e.g., OFAC screening)
- Cross-chain transfers (pre- or post-transfer)
- Deposit in a vault or other wrapper contract (swap and stake)
🤖 Prompt for AI Agents
In `@docs/cow-protocol/concepts/order-types/wrappers.md` around lines 52 - 54,
Replace the inconsistent "Cross chain transfers (pre- or post- transfer)" phrase
with a hyphenated form: "Cross-chain transfers (pre- or post-transfer)" so it
matches the existing "cross-chain" usage and also hyphenates "post-transfer";
update the exact line containing the phrase "Cross chain transfers" in the
document.

Comment on lines +12 to +16
## For Wrapper Developers

This section covers building new wrapper contracts from scratch.

## Overview
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

Heading hierarchy is broken — subsections use the same ## level as their parent sections.

All subsections (e.g., "Overview", "Adding Wrappers to Orders", "Detecting Wrapper Orders", etc.) use ##, the same level as the three audience sections ("For Wrapper Developers", "For Order Creators…", "For Solvers"). This will flatten the document outline/TOC and make it unclear which content belongs to which audience.

Subsections under each audience heading should be ###:

Proposed fix (representative diff)
 ## For Wrapper Developers
 
 This section covers building new wrapper contracts from scratch.
 
-## Overview
+### Overview

 ...

 ## For Order Creators and Frontend Developers
 
 This section shows you how to use existing wrappers...
 
-## Adding Wrappers to Orders
+### Adding Wrappers to Orders

 ...

-## Validating Wrapper Configuration
+### Validating Wrapper Configuration

 ...

 ## For Solvers
 
 This section explains how to execute settlements...
 
-## Detecting Wrapper Orders
+### Detecting Wrapper Orders

-## Solver Requirements
+### Solver Requirements

-## Encoding Wrapper Settlements
+### Encoding Wrapper Settlements

-## Accumulating Wrappers in Solutions
+### Accumulating Wrappers in Solutions

-## Testing and Validation
+### Testing and Validation

-## Common Issues
+### Common Issues

Also applies to: 30-34, 103-103, 125-129, 154-154, 170-170, 281-281, 316-316, 322-322

🤖 Prompt for AI Agents
In `@docs/cow-protocol/integrate/wrappers.mdx` around lines 12 - 16, Multiple
subsection headings (e.g., "Overview", "Adding Wrappers to Orders", "Detecting
Wrapper Orders" and other similar entries) are incorrectly using "##" and
therefore sit at the same level as the three main audience headings ("For
Wrapper Developers", "For Order Creators…", "For Solvers"); change these
subsection headings from "##" to "###" so they become children of their
respective audience sections (update every occurrence referenced in the comment
such as the "Overview", "Adding Wrappers to Orders", "Detecting Wrapper Orders"
headings and the other instances mentioned) to restore proper heading hierarchy
and TOC nesting.

Comment on lines +217 to +237
function encodeWrapperData(wrappers: WrapperCall[]): string {
let wrapperData = '0x';

for (const [index, wrapper] of wrappers.entries()) {
// Skip first wrapper's address (it's the transaction target)
if (index !== 0) {
// Add wrapper address (20 bytes, without 0x prefix)
wrapperData += wrapper.target.slice(2);
}

// Encode data length as u16 big-endian (2 bytes)
const dataLength = (wrapper.data.length - 2) / 2; // Remove '0x' and convert to byte length
const lengthHex = dataLength.toString(16).padStart(4, '0');
wrapperData += lengthHex;

// Add wrapper data (without 0x prefix)
wrapperData += wrapper.data.slice(2);
}

return wrapperData;
}
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

Encoding function doesn't handle optional/empty data field.

The WrapperCall interface (line 43) declares data as optional (data?: string), but this encoding function unconditionally accesses wrapper.data.length and wrapper.data.slice(2). If data is undefined or an empty string, this will throw at runtime.

Proposed fix
 function encodeWrapperData(wrappers: WrapperCall[]): string {
     let wrapperData = '0x';
 
     for (const [index, wrapper] of wrappers.entries()) {
         // Skip first wrapper's address (it's the transaction target)
         if (index !== 0) {
             // Add wrapper address (20 bytes, without 0x prefix)
             wrapperData += wrapper.target.slice(2);
         }
 
+        const rawData = wrapper.data ?? '0x';
         // Encode data length as u16 big-endian (2 bytes)
-        const dataLength = (wrapper.data.length - 2) / 2; // Remove '0x' and convert to byte length
+        const dataLength = (rawData.length - 2) / 2; // Remove '0x' and convert to byte length
         const lengthHex = dataLength.toString(16).padStart(4, '0');
         wrapperData += lengthHex;
 
         // Add wrapper data (without 0x prefix)
-        wrapperData += wrapper.data.slice(2);
+        wrapperData += rawData.slice(2);
     }
 
     return wrapperData;
 }
📝 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
function encodeWrapperData(wrappers: WrapperCall[]): string {
let wrapperData = '0x';
for (const [index, wrapper] of wrappers.entries()) {
// Skip first wrapper's address (it's the transaction target)
if (index !== 0) {
// Add wrapper address (20 bytes, without 0x prefix)
wrapperData += wrapper.target.slice(2);
}
// Encode data length as u16 big-endian (2 bytes)
const dataLength = (wrapper.data.length - 2) / 2; // Remove '0x' and convert to byte length
const lengthHex = dataLength.toString(16).padStart(4, '0');
wrapperData += lengthHex;
// Add wrapper data (without 0x prefix)
wrapperData += wrapper.data.slice(2);
}
return wrapperData;
}
function encodeWrapperData(wrappers: WrapperCall[]): string {
let wrapperData = '0x';
for (const [index, wrapper] of wrappers.entries()) {
// Skip first wrapper's address (it's the transaction target)
if (index !== 0) {
// Add wrapper address (20 bytes, without 0x prefix)
wrapperData += wrapper.target.slice(2);
}
const rawData = wrapper.data ?? '0x';
// Encode data length as u16 big-endian (2 bytes)
const dataLength = (rawData.length - 2) / 2; // Remove '0x' and convert to byte length
const lengthHex = dataLength.toString(16).padStart(4, '0');
wrapperData += lengthHex;
// Add wrapper data (without 0x prefix)
wrapperData += rawData.slice(2);
}
return wrapperData;
}
🤖 Prompt for AI Agents
In `@docs/cow-protocol/integrate/wrappers.mdx` around lines 217 - 237, The
encodeWrapperData function assumes wrapper.data always exists and uses
wrapper.data.length and slice, which breaks when WrapperCall.data is optional;
update encodeWrapperData to normalize data per wrapper (e.g., const data =
wrapper.data ?? '0x'; if (data === '') data = '0x'), compute dataLength safely
as Math.max(0, (data.length - 2) / 2), generate lengthHex from that number, and
only append data.slice(2) when dataLength > 0; apply these changes in the
encodeWrapperData function so it handles undefined or empty wrapper.data without
throwing.

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.

1 participant