Learn
CowSwap

CowSwap

Swap

  • Label: Swap_CowSwap
  • Description: Swap a token to get another in exchange in CowSwap.
  • Actions in execution process:
    1. Swap SELL_TOKEN to get BUY_TOKEN in exchange.

Note: When using the Pilot Extension and the Agile Execution App, all 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.

Note: If SELL_TOKEN or BUY_TOKEN is a native token, it gets wrapped before executing the following functions.

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
    amountequal to the SELL_TOKEN amount to swap

OrderSigner · signOrder

Sign order to swap order.sellAmount of SELL_TOKEN tokens for as much as possible of BUY_TOKEN tokens.

  • 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.sellAmountequal to the SELL_TOKEN amount to swap
    order.buyAmountequal to minimum amount of BUY_TOKEN to receive
    order.validToequal to time_now + validDuration
    order.appData-
    order.feeAmountequal to 0
    order.kindequal to sell
    order.partiallyFillableFalse
    order.sellTokenBalance-
    order.buyTokenBalance-
    validDurationequal to 10 mins
    feeAmountBplower or equal to FEE_AMOUNT_BP: Fee amount basis points (0-10000), where 0 is 0% and 10000 is 100%