Skip to content

Commit

Permalink
Add surplus details
Browse files Browse the repository at this point in the history
  • Loading branch information
fedgiac committed Feb 19, 2024
1 parent 944152e commit 655ec31
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/amm.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ However, CoW AMMs allow solvers to specify custom buy and sell amounts, as long
CoW AMMs can be treated as a liquidity source akin to Uniswap or Balancer weighted pools with uniform weights.
Each CoW AMM is a pair that trades two tokens.

Surplus for a CoW AMM counts as a normal order for the rewards payout.
Importantly, surplus for a CoW AMM order is measured differently when computing the solver reward payout.

### Indexing CoW AMMs

Expand Down Expand Up @@ -156,6 +156,19 @@ The last step (clearing the commit) is technically not required for the batch to
However, leaving the commit set means that no AMM orders will appear in the orderbook until the commit is reset.
Not clearing the commit at the end of the batch is considered slashable behavior.

### Surplus

The surplus for a CoW AMM order is measured differently depending on which AMM order is executed.

If picking the default CoW AMM order (that is, it's settled with the empty commitment), then the surplus is computed exactly like any other CoW Swap order.

Otherwise, if we call `X` (resp. `Y`) the reserves of sell (resp. buy) token, and `x` (resp. `y`) the sell (resp. buy) amount, then the order surplus is computed as:
```
x (Y + y)
surplus = y - --------- .
X
```

## Risk profile

The risks for the funds on the AMM are comparable to the risks of depositing the same reserves on a constant-product curve like Uniswap v2.
Expand Down

0 comments on commit 655ec31

Please sign in to comment.