docs: add comprehensive generalized wrappers documentation#595
docs: add comprehensive generalized wrappers documentation#595
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAdds 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
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
| 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. |
🧰 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. |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| ### 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. |
There was a problem hiding this comment.
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.
| 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. |
There was a problem hiding this comment.
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.
| 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.
| ``` | ||
| Example: | ||
| ``` | ||
| [0x0005][0xAABBCCDDEE][0x1234...ABCD][0x0003][0x112233] | ||
| ↑len ↑data ↑next wrapper ↑len ↑data | ||
| ``` |
There was a problem hiding this comment.
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 usingtext, include the two lines "[0x0005][0xAABBCCDDEE][0x1234...ABCD][0x0003][0x112233]" and "↑len ↑data ↑next wrapper ↑len ↑data" exactly as shown, and close the block withso 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: |
There was a problem hiding this comment.
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.
| 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. |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
| 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.
| - Compliance checks (e.g., OFAC screening) | ||
| - Cross chain transfers (pre- or post- transfer) | ||
| - Deposit in a vault or other wrapper contract (swap and stake) |
There was a problem hiding this comment.
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.
| - 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.
| ## For Wrapper Developers | ||
|
|
||
| This section covers building new wrapper contracts from scratch. | ||
|
|
||
| ## Overview |
There was a problem hiding this comment.
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 IssuesAlso 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.
| 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; | ||
| } |
There was a problem hiding this comment.
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.
| 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.
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 considerationsintegrate/wrappers.mdx: Practical integration guide with three sections:reference/contracts/periphery/wrapper.mdx: Smart contract reference focused on ICowWrapper interface, CowWrapper abstract contract, implementation patterns, and on-chain behaviorSummary by CodeRabbit