Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add details about CoWUidGenerator contract #444

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ CoW Protocol contracts are generally deployed to the same addresses on their res
| [`EthFlow`](periphery/eth-flow)<br />Upgradeable: No ❎<br />[GitHub](https://github.com/cowprotocol/ethflowcontract/blob/main/src/CoWSwapEthFlow.sol) | Production: `0x40A50cf069e992AA4536211B23F286eF88752187`, Staging: `0xD02De8Da0B71E1B59489794F423FaBBa2AdC4d93` on the following networks:<br />- Ethereum mainnet: [Production](https://etherscan.io/address/0x40A50cf069e992AA4536211B23F286eF88752187), [Staging](https://etherscan.io/address/0xD02De8Da0B71E1B59489794F423FaBBa2AdC4d93)<br />- Gnosis chain: [Production](https://gnosisscan.io/address/0x40A50cf069e992AA4536211B23F286eF88752187), [Staging](https://gnosisscan.io/address/0xD02De8Da0B71E1B59489794F423FaBBa2AdC4d93)<br /><br />Production: `0x552fcecc218158fff20e505c8f3ad24f8e1dd33c`, Staging: `0x6dfe75b5ddce1ade279d4fa6bd6aef3cbb6f49db` on the following networks:<br />- Arbitrum one: [Production](https://arbiscan.io/address/0x552fcecc218158fff20e505c8f3ad24f8e1dd33c), [Staging](https://arbiscan.io/address/0x6dfe75b5ddce1ade279d4fa6bd6aef3cbb6f49db)<br /><br />Production: `0x3d1b389f1707DB3d4c5344d5669DBda6b5D6Ab51`, Staging: `0x3C3eA1829891BC9bEC3d06A81d5d169e52a415e3` on the following networks:<br />- Base: [Production](https://basescan.org/address/0x3d1b389f1707DB3d4c5344d5669DBda6b5D6Ab51), [Staging](https://basescan.org/address/0x3C3eA1829891BC9bEC3d06A81d5d169e52a415e3)<br /><br />Production: `0x0b7795E18767259CC253a2dF471db34c72B49516`, Staging: `0x2671994c7D224ac4799ac2cf6Ef9EF187d42C69f` on the following networks:<br />- Sepolia: [Production](https://sepolia.etherscan.io/address/0x0b7795E18767259CC253a2dF471db34c72B49516), [Staging](https://sepolia.etherscan.io/address/0x2671994c7D224ac4799ac2cf6Ef9EF187d42C69f)<br /> |
| [`HooksTrampoline`](periphery/hooks-trampoline)<br />Upgradeable: No ❎<br />[GitHub](https://github.com/cowprotocol/hooks-trampoline/blob/main/src/HooksTrampoline.sol) | `0x01DcB88678aedD0C4cC9552B20F4718550250574`<br />- [Ethereum mainnet](https://etherscan.io/address/0x01DcB88678aedD0C4cC9552B20F4718550250574)<br />- [Gnosis chain](https://gnosisscan.io/address/0x01DcB88678aedD0C4cC9552B20F4718550250574)<br/>- [Arbitrum one](https://arbiscan.io/address/0x01DcB88678aedD0C4cC9552B20F4718550250574)<br/>- [Base](https://basescan.org/address/0x01DcB88678aedD0C4cC9552B20F4718550250574)<br/>- [Sepolia](https://sepolia.etherscan.io/address/0x01DcB88678aedD0C4cC9552B20F4718550250574) |
| [`ComposableCoW`](periphery/composable-cow)<br />Upgradeable: No ❎<br />[GitHub](https://github.com/cowprotocol/composable-cow/blob/main/src/ComposableCoW.sol) | `0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74`<br />- [Ethereum mainnet](https://etherscan.io/address/0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74)<br />- [Gnosis chain](https://gnosisscan.io/address/0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74)<br/>- [Arbitrum one](https://arbiscan.io/address/0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74)<br/>- [Base](https://basescan.org/address/0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74)<br/>- [Sepolia](https://sepolia.etherscan.io/address/0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74) |
| [`CoWUidGenerator`](periphery/cow-uid-generator)<br />Upgradeable: No ❎<br /> | `0xe84dcd8587287b997f51299430a396ad03aaec06` on the following networks:<br />- [Ethereum mainnet](https://etherscan.io/address/0xe84dcd8587287b997f51299430a396ad03aaec06)<br /><br />`0xCA51403B524dF7dA6f9D6BFc64895AD833b5d711` on the following networks:<br />- [Gnosis chain](https://gnosisscan.io/address/0xCA51403B524dF7dA6f9D6BFc64895AD833b5d711)<br/><br />`0x96ddDAC514d0799e34e3F642c5006852aD24CD68` on the following networks:<br />- [Base](https://basescan.org/address/0x96dddac514d0799e34e3f642c5006852ad24cd68) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
id: cow-uid-generator
sidebar_position: 4
---

# CoWUidGenerator

A helper contract for calculating the same EIP-712 signature hash for a given user order that the GPv2SettlementContract expects.

## Architecture
This contract is a simple helper contract that:

- References the CoW Protocol settlement contract’s `domainSeparator`.
- Constructs a Gnosis Protocol v2 (CoW) order data struct on-chain.
- Determines whether the order is a sell or buy order based on `isSell`.
- Computes the EIP-712 hash that matches what the CoW Protocol uses to verify user signatures off-chain.

## Data Types and Storage

### `GPv2SettlementContract`
An interface for the [CoW Protocol settlement contract](../core/settlement.md).

```solidity
interface GPv2SettlementContract {
function domainSeparator() external view returns (bytes32);
}
```

## Functions

### `getUid`
Constructs an order, determines if it is a sell or buy order, then computes the same EIP-712 hash used by CoW Protocol for verifying signatures. Returns both the EIP-712 digest and the ABI-encoded order.
bram-vdberg marked this conversation as resolved.
Show resolved Hide resolved

:::tip

Note: The digest being returned is only the order digest, not the actual order uid. In order to get the order uid this must be concatenated with the address of the order owner and the timestamp until which the order is valid ([reference](../settlement.md#orderuid)).

:::

```solidity
getUid(
address sellToken,
address buyToken,
address receiver,
uint256 sellAmount,
uint256 buyAmount,
uint32 validTo,
bytes32 appData,
uint256 feeAmount,
bool isSell,
bool partiallyFillable)
public view returns (bytes32 hash, bytes memory encoded)
```

| **Parameter** | **Description** |
| --- | --- |
| `sellToken` | The token address being sold if the order is a sell order, or the token that the user owes if the order is a buy order |
| `buyToken` | The token the user will receive if the order is a sell order, or the token the user wants to buy if if the order is a buy order |
| `receiver` | The address to receive the bought tokens |
| `sellAmount` | The amount of `sellToken` being transferred (cannot be 0) |
| `buyAmount` | The amount of `buyToken` being transferred (cannot be 0) |
| `validTo` | Timestamp after which the order expires |
| `appData` | Optional field used by users/dapps/wallets to attach meta-information to orders |
| `feeAmount` | Amount of fee to be charged (currently hardcoded to 0) |
| `isSell` | Indicates whether the order is a buy or sell |
| `partiallyFillable` | Indicates whether the order is partially fillable or fill-or-kill |

## Indexing
Nil

## Off-chain
Nil
Loading