From 51fbd04d5862355eb420e34535f07bdacca84fa6 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 7 Jan 2025 13:14:59 +0100 Subject: [PATCH] Add details about CoWUidGenerator contract --- .../reference/contracts/periphery/README.mdx | 1 + .../contracts/periphery/cow_uid_generator.md | 66 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 docs/cow-protocol/reference/contracts/periphery/cow_uid_generator.md diff --git a/docs/cow-protocol/reference/contracts/periphery/README.mdx b/docs/cow-protocol/reference/contracts/periphery/README.mdx index 616c1e09..676e844d 100644 --- a/docs/cow-protocol/reference/contracts/periphery/README.mdx +++ b/docs/cow-protocol/reference/contracts/periphery/README.mdx @@ -15,3 +15,4 @@ CoW Protocol contracts are generally deployed to the same addresses on their res | [`EthFlow`](periphery/eth-flow)
Upgradeable: No ❎
[GitHub](https://github.com/cowprotocol/ethflowcontract/blob/main/src/CoWSwapEthFlow.sol) | Production: `0x40A50cf069e992AA4536211B23F286eF88752187`, Staging: `0xD02De8Da0B71E1B59489794F423FaBBa2AdC4d93` on the following networks:
- Ethereum mainnet: [Production](https://etherscan.io/address/0x40A50cf069e992AA4536211B23F286eF88752187), [Staging](https://etherscan.io/address/0xD02De8Da0B71E1B59489794F423FaBBa2AdC4d93)
- Gnosis chain: [Production](https://gnosisscan.io/address/0x40A50cf069e992AA4536211B23F286eF88752187), [Staging](https://gnosisscan.io/address/0xD02De8Da0B71E1B59489794F423FaBBa2AdC4d93)

Production: `0x552fcecc218158fff20e505c8f3ad24f8e1dd33c`, Staging: `0x6dfe75b5ddce1ade279d4fa6bd6aef3cbb6f49db` on the following networks:
- Arbitrum one: [Production](https://arbiscan.io/address/0x552fcecc218158fff20e505c8f3ad24f8e1dd33c), [Staging](https://arbiscan.io/address/0x6dfe75b5ddce1ade279d4fa6bd6aef3cbb6f49db)

Production: `0x3d1b389f1707DB3d4c5344d5669DBda6b5D6Ab51`, Staging: `0x3C3eA1829891BC9bEC3d06A81d5d169e52a415e3` on the following networks:
- Base: [Production](https://basescan.org/address/0x3d1b389f1707DB3d4c5344d5669DBda6b5D6Ab51), [Staging](https://basescan.org/address/0x3C3eA1829891BC9bEC3d06A81d5d169e52a415e3)

Production: `0x0b7795E18767259CC253a2dF471db34c72B49516`, Staging: `0x2671994c7D224ac4799ac2cf6Ef9EF187d42C69f` on the following networks:
- Sepolia: [Production](https://sepolia.etherscan.io/address/0x0b7795E18767259CC253a2dF471db34c72B49516), [Staging](https://sepolia.etherscan.io/address/0x2671994c7D224ac4799ac2cf6Ef9EF187d42C69f)
| | [`HooksTrampoline`](periphery/hooks-trampoline)
Upgradeable: No ❎
[GitHub](https://github.com/cowprotocol/hooks-trampoline/blob/main/src/HooksTrampoline.sol) | `0x01DcB88678aedD0C4cC9552B20F4718550250574`
- [Ethereum mainnet](https://etherscan.io/address/0x01DcB88678aedD0C4cC9552B20F4718550250574)
- [Gnosis chain](https://gnosisscan.io/address/0x01DcB88678aedD0C4cC9552B20F4718550250574)
- [Arbitrum one](https://arbiscan.io/address/0x01DcB88678aedD0C4cC9552B20F4718550250574)
- [Base](https://basescan.org/address/0x01DcB88678aedD0C4cC9552B20F4718550250574)
- [Sepolia](https://sepolia.etherscan.io/address/0x01DcB88678aedD0C4cC9552B20F4718550250574) | | [`ComposableCoW`](periphery/composable-cow)
Upgradeable: No ❎
[GitHub](https://github.com/cowprotocol/composable-cow/blob/main/src/ComposableCoW.sol) | `0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74`
- [Ethereum mainnet](https://etherscan.io/address/0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74)
- [Gnosis chain](https://gnosisscan.io/address/0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74)
- [Arbitrum one](https://arbiscan.io/address/0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74)
- [Base](https://basescan.org/address/0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74)
- [Sepolia](https://sepolia.etherscan.io/address/0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74) | +| [`CoWUidGenerator`](periphery/cow-uid-generator)
Upgradeable: No ❎
| `0xe84dcd8587287b997f51299430a396ad03aaec06` on the following networks:
- [Ethereum mainnet](https://etherscan.io/address/0xe84dcd8587287b997f51299430a396ad03aaec06)

`0xCA51403B524dF7dA6f9D6BFc64895AD833b5d711` on the following networks:
- [Gnosis chain](https://gnosisscan.io/address/0xCA51403B524dF7dA6f9D6BFc64895AD833b5d711)

`0x96ddDAC514d0799e34e3F642c5006852aD24CD68` on the following networks:
- [Base](https://basescan.org/address/0x96dddac514d0799e34e3f642c5006852ad24cd68) | diff --git a/docs/cow-protocol/reference/contracts/periphery/cow_uid_generator.md b/docs/cow-protocol/reference/contracts/periphery/cow_uid_generator.md new file mode 100644 index 00000000..4f69c99b --- /dev/null +++ b/docs/cow-protocol/reference/contracts/periphery/cow_uid_generator.md @@ -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