Documentation Index
Fetch the complete documentation index at: https://cowswap-mintlify-seo-audit-1777280932.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Swap
The swap module provides utilities for encoding Balancer swap requests within CoW Protocol. It enables direct order settlement against Balancer pools via theswap() function on the GPv2Settlement contract.
Interfaces
Swap
Represents a single Balancer pool interaction:BatchSwapStep
The encoded form passed to the settlement contract, using token array indices rather than addresses for gas efficiency:SwapExecution
ProvideslimitAmount for solvers to enforce stricter slippage protection than the original order:
EncodedSwap
A three-element tuple:SwapEncoder Class
Builder class that constructs encoded swap calldata progressively.Methods
encodeSwapStep
Appends one or more swaps to the encoder’s internal state:encodeTrade
Incorporates a pre-signed order into the encoding:signEncodeTrade
Signs an order and encodes it simultaneously:encodedSwap
Returns the finalized tuple:encodeSwap (static)
One-shot utility method with multiple overloads for convenience:Examples
Single-Pool Swap
Multi-Hop Swap
MEV Mitigation
This module specifically handles direct Balancer settlement. For complex scenarios involving multiple orders and contract interactions, use the
SettlementEncoder class instead. Most standard Balancer pools omit the userData field.