Skip to content

Conversation

@kaze-cow
Copy link
Collaborator

@kaze-cow kaze-cow commented Nov 6, 2025

Description

Implements the CowEvcOpenPositionWrapper in order to satisfy a usecase for the Euler integration.

Context

Read up on notion

Considerations

  • While we call this flow "open positoin wrapper", it could also be used to grow an existing position, or take on a position without buying any Euler tokens (by setting collateralAmount to 0)
  • this should be compatible ewith CoW (if two users open opposite positions, for example)

Out of Scope

Every line of code in this PR should be considered in-scope.

Testing Instructions

Follow the test command instructions in the README

We want to make sure:

  • the flow works as expected for the established cases of Euler finance.
  • there are not security opportunities an arbitrary user on the open internet could take advantage of
  • there are not security opportunities that a solver could take advantage that would give access to a significant amount of funds

fixes https://linear.app/cowswap/issue/COW-65/initial-merge-contract-of-cowevcopenpositionwrapper

Kaze and others added 30 commits September 11, 2025 21:44
* check solver on internalSettle function
* check only callable through EVC
* prevent reentrancy
make settlement the gatekeeper

why did I not do this before
This reverts commit e56eac3.
best way to ensure the expected flow is followed exactly
* check solver on internalSettle function
* check only callable through EVC
* prevent reentrancy
they shouldn't have been in the repository
feat: use new wrapper from upstream
we use the settlement contract, so it shouldn't be needed anymore

also soljson.latest is still here
@kaze-cow kaze-cow requested a review from fedgiac December 12, 2025 08:05
/// @dev By default we return the default value (empty array, false)
/// @param location The memory storage position where the parameters needed to encode the batch items have been saved
/// @return items Array of batch items to execute
/// @return needsPermit Whether these items require user signature or prior authorization as an operator
Copy link
Contributor

Choose a reason for hiding this comment

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

Overall the parameter name and explanation is confusing to me. The permission it needs is more specific than the text suggests.
Same comment in _encodeBatchItemsAfter

Suggested change
/// @return needsPermit Whether these items require user signature or prior authorization as an operator
/// @return canUsePermit Whether the returned batch items are intended to be optionally executed in an EVC permit

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The permission it needs is more specific than the text suggests.

Hmm, in a general sense, the flag is intended to indicate whether the things returned require some sort of special permissions. The way that those permissions can be obtained varies (either setAccountOperator or EVC.permit), of course, So I thought needsPermit was an overall good . Would needsPermission be better indication of such a thing? I just want to confirm exactly a label that makes sense to both of us before I go in and rename everything again 😆

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

also I prefer th ecomment as it exists right now. The new comment in your suggestion makes it sound like the authorization from the user is somehow optional, but its not.

@kaze-cow kaze-cow requested a review from fedgiac January 8, 2026 09:00
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.

3 participants