Learn
Arbitrum

CowSwap on Arbitrum

Deployments

NameAddress
GPv2VaultRelayer0xC92E8bdf79f0507f65a392b0ab4667716BFE0110 (opens in a new tab)
OrderSigner0x23dA9AdE38E4477b23770DeD512fD37b12381FAB (opens in a new tab)
ComposableCow0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74 (opens in a new tab)
TWAP0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5 (opens in a new tab)

Other Deployments

NameAddress
ExtensibleFallbackHandler0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5 (opens in a new tab)
CurrentBlockTimestampFactory0x23dA9AdE38E4477b23770DeD512fD37b12381FAB (opens in a new tab)

Action: swap

Parameters

NameTypeDescription
sellstring[] (required)ETH | Token address
buystring[] (optional)ETH | Token address
feeAmountBpint (optional)Fee amount basis points (0-10000), where 0 is 0% and 10000 is 100%
twapbool (optional)false = Market Order / true = TWAP Order
receiveraddress (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)

    ParameterConstraint
    spenderequal to GPv2VaultRelayer
    amount-

If ETH is SELL_TOKEN:

WETH · approve

Approve GPv2VaultRelayer to spend WETH tokens on behalf of the avatar.

  • Contract: WETH

  • Function: approve(address,uint256)

    ParameterConstraint
    spenderequal to GPv2VaultRelayer
    amount-

WETH · deposit

Deposit ETH and receive WETH tokens.

  • Contract: WETH

  • Function: deposit() Ξ allow sending ETH

    ParameterConstraint
    N/AN/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)

    ParameterConstraint
    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)

    ParameterConstraint
    domainSeparatorequal to 0xc078f884a2676e1345748b1feace7b0abee5d00ecadb6e574dcdd109a63e8943
    newVerifierequal 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)

    ParameterConstraint
    params.handlerequal to TWAP
    params.salt-
    params.staticInputSee breakdown below
    factoryequal to CurrentBlockTimestampFactory
    dataequal to 0x
    dispatch-

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).

FieldScopedDescription
sellTokenYesAddress of the token being sold. Scoped using the tokens listed in sell.
buyTokenYesAddress of the token being bought. Scoped using the tokens listed in buy.
receiverYesReceiver of the swap proceeds (address(0) = Safe itself). Scoped as AVATAR or ZeroAddress.
partSellAmountNoAmount of sellToken per TWAP chunk.
minPartLimitNoMinimum expected buyToken per chunk.
t0NoStart time (unix timestamp).
nNoNumber of parts in the TWAP.
tNoInterval duration between parts (in seconds).
spanNoOptional 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) → delegatecall

    ParameterConstraint
    order.sellTokenequal to SELL_TOKEN
    order.buyTokenequal to BUY_TOKEN
    order.receiverequal to AVATAR
    order.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)) → delegatecall

    ParameterConstraint
    order.sellTokenequal to SELL_TOKEN
    order.buyTokenequal to BUY_TOKEN
    order.receiverequal to AVATAR
    order.sellAmount-
    order.buyAmount-
    order.validTo-
    order.appData-
    order.feeAmount-
    order.kind-
    order.partiallyFillable-
    order.sellTokenBalance-
    order.buyTokenBalance-