Skip to content

Commit

Permalink
Typos and style changes from code review
Browse files Browse the repository at this point in the history
Co-authored-by: mfw78 <[email protected]>
  • Loading branch information
fedgiac and mfw78 authored Feb 5, 2024
1 parent 5187b14 commit 3e58cf9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ You can find detailed documentation on the building blocks of this repo in the f

Details on the theory behind CoW AMM can be found on the paper [Arbitrageurs' profits, LVR, and sandwich attacks: batch trading as an AMM design response](https://arxiv.org/pdf/2307.02074.pdf).

## Development4
## Development

### Build

Expand Down
16 changes: 8 additions & 8 deletions docs/amm.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ CoW AMM is an automated market maker running on top of CoW Protocol.
The AMM contract itself is a dedicated Safe multisig.
It stores reserves of two tokens and allows anyone to create orders between these two tokens on CoW Protocol as long as the trade doesn't decrease the product of the reserves stored on the contract.

The order is based on the composable CoW framework: this repository only specified the code needed for the dedicated handler and the related price oracles.
All the code of the composable cow framework is [here](https://github.com/cowprotocol/composable-cow).
The order is based on the `ComposableCoW` framework: this repository only specifies the code needed for the dedicated handler and the related price oracles.
All the code for the `ComposableCoW` framework is [here](https://github.com/cowprotocol/composable-cow).

The AMM also provides a view function (`getTradeableOrder`): this function doesn't impact which order is valid or not, but returns an order that can be traded in a way that tries to rebalance the AMM to align with the reference price of a price oracle.

This order is intended to be picked up automatically by the [watchtower](https://github.com/cowprotocol/watch-tower/) without any necessity for the AMM to interact with the CoW Protocol API.
This order is intended to be picked up automatically by the [watchtower](https://github.com/cowprotocol/watch-tower) without any necessity for the AMM to interact with the CoW Protocol API.
For now, most solvers rely on the order that's automatically generated by the watchtower to balance the AMM.
Eventually, we expect solvers to be aware of the peculiar dynamics of the CoW AMM and create their own orders when settling a CoW Protocol batch.

CoW AMM orders are executed in batches by CoW Protocol solvers.
Only one order per AMM is intended to be executed per batch.
This is currently not enforced onchain but it's a planned feature of a future version of the CoW AMM.
This is currently not enforced on-chain but it's a planned feature of a future version of the CoW AMM.

Further information on the theoretical research work that serves as the base of CoW AMM can be found in the paper [Arbitrageurs' profits, LVR, and sandwich attacks: batch trading as an AMM design response](https://arxiv.org/pdf/2307.02074.pdf).

Expand All @@ -28,20 +28,20 @@ Batch trading guarantees that despite the minimum viable order follows the const

- The CoW AMM funds will be stored in a safe. Every pair of tokens requires its dedicated safe. The owners of the safe have full access to the funds.
- The CoW AMM safe needs to use the safe's `ExtensibleFallbackHandler` fallback handler (needed to validate a Composable CoW order).
- The CoW AMM safe needs to create a new [Composable CoW](https://github.com/cowprotocol/composable-cow) that uses the standard deployment of `ConstantProduct` as its handler.
- The CoW AMM safe needs to create a new [`ComposableCoW`](https://github.com/cowprotocol/composable-cow) order that uses the standard deployment of `ConstantProduct` as its handler.

## Order setup

### Composable CoW order
### `ComposableCoW` order

A composable cow order is created by calling the function `create(ConditionalOrderParams params, bool dispatch)` on the Composable CoW main contract.
A `ComposableCoW` order is created by calling the function `create(ConditionalOrderParams params, bool dispatch)` on the `ComposableCoW` main contract.

The conditional order parameters should be set as follows:
- `IConditionalOrder handler`: the address of the standard deployment of `ConstantProduct` for the desired chain. See file `networks.json` for a list of official deployments by chain id.
- `bytes32 salt`: this value is used to make the order unique. It's recommended to use a value that hasn't been used before for an order on the same safe. Note that it's discouraged to use the CoW AMM safe for other orders outside of setting up the AMM, in which case conflicts are not a concern.
- `bytes staticInput`: The configuration values for the CoW AMM. See next section for more details.

If `dispatch` is set to true, then the order will be automatically picked up on CoW Protocol's orderbook by the [watchtower service](https://github.com/cowprotocol/watch-tower/).
If `dispatch` is set to true, then the order will be automatically picked up on CoW Protocol's orderbook by the [watchtower service](https://github.com/cowprotocol/watch-tower).

### ConstantProduct static input

Expand Down

0 comments on commit 3e58cf9

Please sign in to comment.