3. Placing the Limit Order

Order creation is happening via a POST request to the following endpoint:

https://api.cow.fi/mainnet/api/v1/orders

The payload needs to be a json encoded object. Our example order would look like this:

{
"sellToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"buyToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"sellAmount": "10000000000",
"buyAmount": "4959721654652700610",
"receiver": "0x0000000000000000000000000000000000000000",
"validTo": 1628035200,
"appData": "0xf785fae7a7c5abc49f3cd6a61f6df1ff26433392b066ee9ff2240ff1eb7ab6e4",
"feeAmount": "0",
"kind": "sell",
"partiallyFillable": false,
"sellTokenBalance": "erc20",
"buyTokenBalance": "erc20",
"signingScheme": "eip1271",
"signature": <0x encoded signature from step 4>
"from": "0x55fe002aeff02f77364de339a1292923a15844b8"
}

Note that uint256 fields need to be encoded as long decimal strings instead of numbers (validTo however as an integer).

Receiver is optional. If funds are intended to be sent to another account, zero address indicates receiver is same as signer.

The trader address is automatically derived from the signature and thus also optional. **** Since creating a signature can be prone to errors, we advise you specify the address you intended to use for signing nonetheless so that our API can give you a better error message in case the signature doesn't recover to the expected owner.

By default, funds will be taken from your account via the Vault Relayer and proceeds will be sent to your receiving account. For the sell token balance, you can also choose to use your existing Balancer v2 vault's allowance ("external") or internal Balancer v2 balance ("internal"). In this case you don't need to set the VaultRelayer approval from step 1. The buy token can also be transferred into your internal Balancer v2 Vault balance by specifying "buyTokenBalance": "internal".

In case of success, the API should return the order UID, which you can use to track the status of your order either in the Cow Explorer, or the API

Last updated