CoW Swap is the first trading interface built on top of CoW Protocol.
It allows you to buy and sell tokens using gasless orders that are settled peer-to-peer among its users or into any on-chain liquidity source while providing MEV protection.
-
🐮Official Website🐮: https://swap.cow.fi/
- The website can also be run locally, or from IPFS. Every release will have an IPFS hash associated, available in the Releases section.
-
Protocol: https://cow.fi
-
Docs: https://docs.cow.fi
-
Twitter: @CoWSwap
Please see the:
You can block an entire list of tokens by passing in a tokenlist like here or you can block specific tokens by adding them to unsupported.tokenlist.json.
yarn
yarn start
yarn test
Make sure you add the required environment varianbles to your
.env.local
file with:
INTEGRATION_TEST_PRIVATE_KEY=<your-private-key>
: Private keyINTEGRATION_TESTS_INFURA_KEY=<your-infura-key>
: Infura key
To launch it with our development server (so you have live-reloading):
yarn start
yarn cypress
Alternativelly, you can build the project and launch the integration test.
yarn build
yarn integration-test
If we want to use the Cypress UI:
yarn build
yarn serve
yarn cypress
This will start a server on the http://localhost:5000/
yarn run cosmos
The app has some default configuration, but it's highly encouraged to define your own.
Make a copy of .env
named .env.local
, this will allow you to set your own configuration only in your local environment.
Your environment MUST have the following variables defined:
REACT_APP_INFURA_KEY
=YOUR_INFURA_KEY
REACT_APP_NETWORK_URL_1
=https://mainnet.infura.io/v3/{YOUR_INFURA_KEY}
REACT_APP_NETWORK_URL_5
=https://goerli.infura.io/v3/{YOUR_INFURA_KEY}
Additionally, to successfully run E2E / Integration tests locally you must have;
INTEGRATION_TESTS_INFURA_KEY
=YOUR_INFURA_KEY
INTEGRATION_TESTS_PRIVATE_KEY
=YOUR_TEST_WALLET_PRIVATE_KEY
Modify the environment variables in .env.production
, or override them in build time.
CoW Swap tries to find the best price available on-chain using some price feeds.
All price feeds are enabled by default, but they can be individually disabled by using an environment variable:
Name | Environment variable | Type | Description |
---|---|---|---|
CoW Protocol | REACT_APP_PRICE_FEED_GP_ENABLED |
boolean (default = true ) |
CoW Protocol price estimation. Used for all price estimation. |
Paraswap | REACT_APP_PRICE_FEED_PARASWAP_ENABLED |
boolean (default = true ) |
Paraswap price estimation. Used for all price estimations. |
1inch | REACT_APP_PRICE_FEED_1INCH_ENABLED |
boolean (default = true ) |
Paraswap price estimation. Used for all price estimations. |
0x | REACT_APP_PRICE_FEED_0X_ENABLED |
boolean (default = true ) |
0x price estimation. Used for all price estimation. |
Coingecko | REACT_APP_PRICE_FEED_COINGECKO_ENABLED |
boolean (default = true ) |
Coingecko price estimation. Used only for USD estimations to calculate the slippage on the trade. |
The app will attach some metadata to all orders.
This metadata will be sent to the smart contract as a hexadecimal value in an order field called AppData
. This value comes from hashing the content of a metadata JSON containing some information about the trade.
Any web app or client using CoW Protocol can upload to IPFS a metadata JSON and use the digest hex to attach that information to the order.
For example, CoW Swap uploaded the file https://cloudflare-ipfs.com/ipfs/QmTDarZ47oek1miuRd8uuNCy5AFfjzQbWJ7348izx9N8wQ
which has the hexadecimal digest 0x487B02C558D729ABAF3ECF17881A4181E5BC2446429A0995142297E897B6EB37
(See
CID Explorer for more details).
The format of the JSON follows this typescript format: <src/utils/metadata.ts>
To set your own AppData
, change REACT_APP_DOMAIN_REGEX_<environment>
environment variable. Ask for yours at CoW Swap's Discord channel. For more details, check out the environment file (<.env>)
You can change the supported networks and their RPC endpoint.
To have the interface default to a different network when a wallet is not connected:
- Change
REACT_APP_NETWORK_ID
to"{YOUR_NETWORK_ID}"
. This will be your default network id - Define your own list of supported networks:
REACT_APP_SUPPORTED_CHAIN_IDS="1,100,5"
REACT_APP_NETWORK_URL_1=https://mainnet.infura.io/v3/{YOUR_INFURA_KEY}
REACT_APP_NETWORK_URL_5=https://goerli.infura.io/v3/{YOUR_INFURA_KEY}
REACT_APP_NETWORK_URL_100=https://rpc.gnosischain.com
Fee quote requests and posting orders are sent to an API. This API has the responsibility of collecting orders and handing them to the solvers.
The reference implementation of the API is gp-v2-services.
The API endpoint is configured using the environment variable {XDAI|GOERLI|MAINNET}
to e.g. "http://localhost:8080/api"
when running the services locally.
Wallet Connect allows to connect the app to any Wallet Connect supported wallet.
In order to do so, it uses a Websocket, that can be configured using: the env var WALLET_CONNECT_BRIDGE
.
The sitemap can be found in <./public/sitemap.xml>
To update its content:
- Edit the list of pages in <./src/sitemap.js>
- Run
yarn sitemap
- Commit the changes to git
In case of problems with the service worker cache you force a reset using emergency.js The plan:
const resetCacheInCaseOfEmergency = false
- changefalse
totrue
- Deploy a new version to production
emergency.js
is not cached by browser and loaded before all.