CowSwap on Arbitrum
Deployments
Other Deployments
| Name | Address |
|---|---|
ExtensibleFallbackHandler | 0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5 (opens in a new tab) |
CurrentBlockTimestampFactory | 0x23dA9AdE38E4477b23770DeD512fD37b12381FAB (opens in a new tab) |
Action: swap
Parameters
| Name | Type | Description |
|---|---|---|
sell | string[] (required) | ETH | Token address |
buy | string[] (optional) | ETH | Token address |
feeAmountBp | int (optional) | Fee amount basis points (0-10000), where 0 is 0% and 10000 is 100% |
twap | bool (optional) | false = Market Order / true = TWAP Order |
receiver | address (optional) | Address that will receive output tokens when a TWAP Order is executed |
When using the Pilot Extension, all Market Orders (swaps) will be routed
through a delegate call to the
OrderSigner (opens in a new tab) in order to
facilitate parameter scoping and minimize risks.
To allow ETH as sell or buy token, either the "ETH" literal or the
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE address can be used.
If buy is left undefined, there would be no restriction on the buy side of
the swap.
SELL_TOKEN below refers to the ERC-20 token address of each element given in
sell.
BUY_TOKEN below refers to the ERC-20 token address of each element given in
buy.
FEE_AMOUNT_BP below specifies the fee amount in basis points given in
feeAmountBp. It accepts a value between 0 and 10000, where 0 represents 0%
and 10000 represents 100%.
RECEIVER below refers to the address given in the receiver parameter.
This address will receive the output tokens from the TWAP Order.
If twap is set to true, then receiver must be a valid address.
Otherwise, the following error will be thrown: "If twap is true then
receiver must be a valid address".
While not strictly enforced, receiver is expected to be the AVATAR Safe.
Using a different address may result in permission scopes that are not
meaningful or functional.
SELL_TOKEN · approve
Approve GPv2VaultRelayer to spend SELL_TOKEN tokens on behalf of the avatar.
-
Contract:
SELL_TOKEN -
Function:
approve(address,uint256)Parameter Constraint spenderequal to GPv2VaultRelayeramount-
If ETH is SELL_TOKEN:
WETH · approve
Approve GPv2VaultRelayer to spend WETH tokens on behalf of the avatar.
-
Contract:
WETH -
Function:
approve(address,uint256)Parameter Constraint spenderequal to GPv2VaultRelayeramount-
WETH · deposit
Deposit ETH and receive WETH tokens.
-
Contract:
WETH -
Function:
deposit()Ξ allow sending ETHParameter Constraint N/A N/A
If TWAP is true:
RECEIVER · setFallbackHandler
Set the fallback handler on RECEIVER to allow execution of the TWAP Order.
This setup is required once per Safe to enable compatibility with the CoW protocol’s
order settlement logic.
-
Contract:
RECEIVER (Safe contract) -
Function:
setFallbackHandler(address)Parameter Constraint handlerequal to ExtensibleFallbackHandler
Learn more about how the CoW Swap fallback handler works and why it’s needed in this article by CoW Swap (opens in a new tab).
RECEIVER · setDomainVerifier
Configure the domain verifier required to validate signed CoW Orders.
This function is exposed via the ExtensibleFallbackHandler, which must be
previously set using setFallbackHandler.
-
Contract:
RECEIVER (Safe contract) -
Function:
setDomainVerifier(bytes32,address)Parameter Constraint domainSeparatorequal to 0xc078f884a2676e1345748b1feace7b0abee5d00ecadb6e574dcdd109a63e8943newVerifierequal to ComposableCow
ComposableCow · createWithContext
Creates a TWAP Order with predefined parameters and a contextualized factory for time-based execution.
This is the core function used to submit TWAP Orders via the ComposableCow contract.
-
Contract:
ComposableCow -
Function:
createWithContext((address,bytes32,bytes),address,bytes,bool)Parameter Constraint params.handlerequal to TWAPparams.salt- params.staticInputSee breakdown below factoryequal to CurrentBlockTimestampFactorydataequal to 0xdispatch-
The handler contract (TWAP) defines the execution strategy, while factory
provides dynamic inputs such as the current timestamp.
Breakdown of params.staticInput Parameter Scoping
The staticInput structure is defined in the ComposableCow repository (opens in a new tab).
| Field | Scoped | Description |
|---|---|---|
| sellToken | Yes | Address of the token being sold. Scoped using the tokens listed in sell. |
| buyToken | Yes | Address of the token being bought. Scoped using the tokens listed in buy. |
| receiver | Yes | Receiver of the swap proceeds (address(0) = Safe itself). Scoped as AVATAR or ZeroAddress. |
| partSellAmount | No | Amount of sellToken per TWAP chunk. |
| minPartLimit | No | Minimum expected buyToken per chunk. |
| t0 | No | Start time (unix timestamp). |
| n | No | Number of parts in the TWAP. |
| t | No | Interval duration between parts (in seconds). |
| span | No | Optional active span within each interval (in seconds). |
If TWAP is false:
OrderSigner · signOrder
Sign order to swap SELL_TOKEN for BUY_TOKEN.
-
Contract:
OrderSigner -
Function:
signOrder((address,address,address,uint256,uint256,uint32,bytes32,uint256,bytes32,bool,bytes32,bytes32),uint32,uint256)→ delegatecallParameter Constraint order.sellTokenequal to SELL_TOKENorder.buyTokenequal to BUY_TOKENorder.receiverequal to AVATARorder.sellAmount- order.buyAmount- order.validTo- order.appData- order.feeAmount- order.kind- order.partiallyFillable- order.sellTokenBalance- order.buyTokenBalance- validDuration- feeAmountBplower or equal to FEE_AMOUNT_BP
The signOrder function does not allow sending ETH. Therefore, ETH must be
wrapped in order to be sent as a sell token.
OrderSigner · unsignOrder
Unsign and cancel order.
-
Contract:
OrderSigner -
Function:
unsignOrder((address,address,address,uint256,uint256,uint32,bytes32,uint256,bytes32,bool,bytes32,bytes32))→ delegatecallParameter Constraint order.sellTokenequal to SELL_TOKENorder.buyTokenequal to BUY_TOKENorder.receiverequal to AVATARorder.sellAmount- order.buyAmount- order.validTo- order.appData- order.feeAmount- order.kind- order.partiallyFillable- order.sellTokenBalance- order.buyTokenBalance-