Skip to content

Commit bd0aada

Browse files
authored
feat: cow.finance (#614)
# Description Move to cow.finance domain
1 parent 110bab6 commit bd0aada

339 files changed

Lines changed: 13303 additions & 60 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Before contributing, make sure you have the following installed:
1515
You can help other users in the community to solve their issues in the [CoW Protocol Discord].
1616

1717
[CoW Protocol Discord]: https://discord.gg/cowprotocol
18-
[CoW Protocol Forums]: https://forum.cow.fi
18+
[CoW Protocol Forums]: https://forum.cow.finance
1919

2020
## Opening an issue
2121

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3+
};

docs/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Welcome
3+
sidebar_position: 1
4+
---
5+
6+
# CoW DAO
7+
8+
CoW DAO is on a mission to innovate the most user-protective products in Ethereum. 
9+
10+
Currently, CoW DAO's two main products are [**CoW Protocol**](cow-protocol) and [CoW AMM](https://cow.finance/cow-amm), which it supports with development and marketing resources – including the [CoW Grants Program](https://grants.cow.finance), the [CoW Protocol Explorer](cow-protocol/tutorials/cow-explorer), and the [CoW Swap frontend](cow-protocol/tutorials/cow-swap).
11+
12+
## What is [CoW Protocol](cow-protocol)
13+
14+
CoW Protocol is a fully permissionless trading protocol that leverages [fair combinatorial batch auctions](cow-protocol/concepts/introduction/fair-combinatorial-auction) as its price finding mechanism. CoW Protocol uses fair combinatorial auctions to maximize liquidity via Coincidence of Wants (CoWs) in addition to tapping all available on-chain liquidity whenever needed.
15+
16+
## What is [CoW AMM](https://cow.finance/cow-amm)?
17+
18+
CoW AMM is a new type of AMM built from the ground up to protect LPs from price exploitation in the form of [LVR](https://cow.finance/learn/what-is-loss-versus-rebalancing-lvr). Liquidity providers expect their tokens to earn yield, but most liquidity pools are actually not profitable after accounting for stale prices. Arbitrageurs exploit these stale prices at the expense of LPs. CoW AMM fixes LVR once and for all, with liquidity pools proven to outperform reference Balancer and Uniswap pools.
19+
20+
## [Governance](governance)
21+
22+
CoW DAO is of its community, by its community, and for its community. CoW DAO uses a [decentralized governance model](governance) to ensure that the community has full control over the direction of the protocol.
23+
24+
## How to use CoW DAO's documentation
25+
26+
CoW DAO's documentation follows a "Concepts", "Tutorials", "Technical Reference" methodology. For example when a user wants to learn:
27+
28+
- **_What_** something is (example: batch auctions) → see [Concepts](/category/concepts)
29+
- **_How_** to do something (example: create an order) → see [Tutorials](/category/tutorials)
30+
- **_Technical_** information (example: such as SDKs, APIs) - see [Technical Reference](/category/technical-reference)

docs/cow-amm/README.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# CoW AMM: The First MEV-capturing AMM
2+
3+
CoW AMM protects LPs from LVR so they can provide liquidity with less risk and more return. CoW AMM achieves close to 5% more in TVL compared to reference pools, protects millions from LVR, and has captured over $100,000 in surplus for LPs to date.
4+
5+
## AMMs don't want you to know about LVR
6+
7+
Liquidity providers expect their tokens to earn yield, but the dirty little secret of AMMs is that most liquidity pools lose money. In fact, hundreds of millions of dollars of LP funds are stolen by arbitrageurs every year. These losses are known as loss-versus-rebalancing (LVR). LVR is a bigger source of MEV than frontrunning and sandwich attacks combined.
8+
9+
## An AMM designed with LPs in mind
10+
11+
CoW AMM eliminates LVR once and for all by using batch auctions to send surplus to LPs
12+
13+
1. Liquidity providers deposit tokens into protected CoW AMM liquidity pools, where traders can access the liquidity
14+
2. Solvers bid to rebalance CoW AMM pools whenever there is an arbitrage opportunity
15+
3. The solver that offers the most surplus to the pool wins the right to rebalance the pool
16+
4. CoW AMM eliminates LVR by capturing arbitrage value for LPs and shielding it from MEV bots
17+
18+
## Deploy liquidity on CoW AMM
19+
20+
Thanks to CoW AMM's integration with Balancer, LPs can now [deploy their liquidity or create a brand new pool in just a few clicks](https://balancer.fi/pools/cow).

docs/cow-amm/_category_.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"position": 3,
3+
"label": "🌊 CoW AMM",
4+
"collapsible": true,
5+
"collapsed": true
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"position": 1,
3+
"label": "Concepts",
4+
"collapsible": true,
5+
"collapsed": true,
6+
"link": {
7+
"type": "generated-index"
8+
}
9+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# How CoW AMMs Work
6+
7+
## FM-AMMs
8+
9+
The [“Function-Maximizing” AMM](https://arxiv.org/abs/2307.02074) is a novel AMM mechanism that tackles the shortcomings of the CF-AMM design and eliminates LVR. The FM-AMM batches trades together, executing all the orders in a batch at the same uniform clearing price. This price is such that the AMM “moves up the curve” with each trade. Since anyone can submit trades to the FM-AMM while its batch is open, competition between arbitrageurs guarantees that FM-AMM always trades at the correct, equilibrium price.
10+
11+
## CoW AMM
12+
13+
CoW AMM is a production-ready implementation of an FM-AMM that supplies liquidity for trades made on CoW Protocol. Solvers compete with each other for the right to trade against the AMM. The winning solver is the one that moves the AMM curve higher.
14+
15+
CoW AMM pools are optimal for every token pair that is not stable-to-stable. Since volatility dictates the amount of LVR that takes place in any given liquidity pool, CoW AMM pools are most effective for volatile token pairs where arbitrage outweighs LP fees.
16+
17+
## Getting Started with CoW AMM
18+
19+
To facilitate easy liquidity providing, CoW DAO has partnered with Balancer to implement CoW AMMs into the Balancer ecosystem. LPs can [use the Balancer app](https://balancer.fi/pools/cow) to LP direclty on one of over a dozen liquidity pools.
20+
21+
In the next section, LPs can learn how to create their own CoW AMM pools for brand new assets either on Balancer or outside the platform.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# The Problem of LVR (Loss-versus-rebalancing)
6+
7+
First coined by a team of researchers from [Columbia University,](https://arxiv.org/abs/2208.06046) LVR is a form of arbitrage that occurs whenever an AMM has an outdated (stale) price in comparison to some other trading venue.
8+
9+
Arbitrageurs exploit this difference by trading from the AMM to the more liquid exchange (usually a centralized exchange like Binance), correcting the arbitrage and extracting value from LPs in the process.
10+
11+
# How LVR Works
12+
13+
Most AMMs (such as Uniswap) are examples of constant function automated market makers—CF-AMMs. These AMMs take in two assets and automatically re-calculate prices after each trade to ensure ample liquidity at all times. This means the AMMs experience asset price discovery as they are being traded against.
14+
15+
However, since crypto assets trade on various platforms including centralized exchanges, the prices on a CF-AMM may be outdated compared to the more liquid prices on a centralized exchange. This discrepancy allows arbitrageurs to trade between the liquid exchange and the outdated AMM, correcting prices and capturing arbitrage in the process.
16+
17+
"Loss-versus-rebalancing" is the scenario where an LP provides liquidity to a CF-AMM whose prices are stale compared to a more liquid venue like a centralized exchange. By leaving their funds in the liquidity pool, they are not making as much money as they could be if they were to constantly "rebalance" between the AMM and the exchange. Thus, they incur a "loss" compared to what they would have in a "rebalancing" strategy.
18+
19+
# The Impact of LVR on LPs
20+
21+
Many liquidity providers haven’t even heard of LVR, but it costs them 5–7% of their liquidity, resulting in hundreds of millions lost each year. In fact, when accounting for LVR, many of the largest liquidity pools are not profitable for LPs at all.
22+
23+
Due to these losses, LVR is a type of MEV (maximal extractable value) that accounts for more price exploitation than frontrunning and sandwich attacks combined.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"position": 2,
3+
"label": "Tutorials",
4+
"collapsible": true,
5+
"collapsed": true,
6+
"link": {
7+
"type": "generated-index"
8+
}
9+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Deploying a CoW AMM Using Balancer
6+
7+
In this short tutorial, we describe how you can create and deploy their own Balancer CoW AMM.
8+
9+
**You may also deploy a CoW AMM through the Balancer UI using [this guide.](https://cow.finance/learn/how-to-create-a-lvr-protected-liquidity-pool-on-cowamm)**
10+
11+
The proposed transactions and interactions can be executed through any smart contract or EOA transaction builder, Etherscan "Write Contract," from other UI mechanisms, or directly from the console.
12+
13+
The current factory contract addresses are the following:
14+
15+
- Ethereum Mainnet: [`0xf76c421bAb7df8548604E60deCCcE50477C10462`](https://etherscan.io/address/0xf76c421bAb7df8548604E60deCCcE50477C10462#code)
16+
- Gnosis Chain: [`0x703Bd8115E6F21a37BB5Df97f78614ca72Ad7624`](https://gnosisscan.io/address/0x703Bd8115E6F21a37BB5Df97f78614ca72Ad7624#code)
17+
- Arbitrum One: [`0xE0e2Ba143EE5268DA87D529949a2521115987302`](https://arbiscan.io/address/0xe0e2ba143ee5268da87d529949a2521115987302#code)
18+
- Base: [`0x03362f847B4fAbC12e1Ce98b6b59F94401E4588e`](https://basescan.org/address/0x03362f847b4fabc12e1ce98b6b59f94401e4588e#code)
19+
- Avalanche: N/A
20+
- Polygon: N/A
21+
- BNB: N/A
22+
- Linea: N/A
23+
- Plasma: N/A
24+
- Sepolia Testnet: [`0x1E3D76AC2BB67a2D7e8395d3A624b30AA9056DF9`](https://sepolia.etherscan.io/address/0x1E3D76AC2BB67a2D7e8395d3A624b30AA9056DF9#code)
25+
26+
These contracts can be verified through [this](https://github.com/balancer/cow-amm) repository.
27+
28+
1. In order to create a new pool, one first needs to call the `newBPool` function of the factory contract. An example transaction that creates a new pool can be found [here](https://etherscan.io/tx/0x7543a97853827e267ecd3c1309509ac7704e4f85a53fbfacd6060f461d85bad8#eventlog). The relevant `LOG_NEW_POOL` log also reveals the address of the newly created pool; in our example transaction, it is `0x81530e9B069c69F6671A0A9d7Ee337cafEF419F6`.
29+
30+
:::note
31+
32+
In case ABI of the factory contract is not fetched, the ABI from the Sepolia network can be used.
33+
:::
34+
35+
1. The next step is to approve the tokens we want to add to the pool; this can be done by calling the `approve()` function on the contract of the relevant ERC-20 token that is being added to the pool, where the "spender" needs to be set to the newly created BPool address from (1).
36+
37+
:::caution
38+
39+
One needs to take the token's decimals into account in order to set the correct approval.
40+
:::
41+
42+
1. The next step is to bind the approved tokens to the pool, by using the `bind()` function of the newly created pool contract. We need to do one bind per token that will be added to the pool. Note that the `denorm` parameter should always be set to 1000000000000000000 (i.e., 10^18).
43+
44+
2. We can then set the swap fee; this is the fee trades will pay if they trade permissionlessly (i.e., outside of the batch), and this is done by calling the `setSwapFee()` function of the pool contract. The fee parameter needs to be specified in wei, hence, a 10% fee would be 100000000000000000 (i.e., 10^17)
45+
46+
:::note
47+
48+
In order to guarantee full LVR protection, the fee should be set to 100%.
49+
:::
50+
51+
:::caution
52+
53+
The fee parameter is an unsigned integer where 10^18 corresponds to 100% of fee. Note that 100% is actually not a valid value though, but one can set up to 99.99%.
54+
:::
55+
56+
1. The final step is to finalize the pool by calling the `finalize()` function of the newly created pool contract.

0 commit comments

Comments
 (0)