Skip to content

Commit

Permalink
Add details about CoWUidGenerator contract
Browse files Browse the repository at this point in the history
  • Loading branch information
bram-vdberg committed Jan 7, 2025
1 parent 32aa8dc commit 51fbd04
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/cow-protocol/reference/contracts/periphery/README.mdx
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,66 @@
---
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.

```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 |
| `buyAmount` | The amount of `buyToken` being transferred |
| `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. For sell orders the |
| `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

0 comments on commit 51fbd04

Please sign in to comment.