GPv2VaultRelayer Contract
TheGPv2VaultRelayer contract serves as an intermediary between the settlement contract and Balancer Vault, enabling secure token transfers and batch swaps while maintaining strict access controls.
Overview
The relayer acts as an intermediary between the settlement contract and Balancer Vault with specialized functions for handling user fund interactions safely. Only the settlement contract can initiate transfers.State Variables
| Variable | Type | Description |
|---|---|---|
creator | address (immutable) | The settlement contract address with exclusive privileges |
vault | IVault (immutable) | The Balancer Vault instance |
Access Control
All external functions use theonlyCreator modifier, restricting operations to the settlement contract that deployed the relayer:
Main Functions
transferFromAccounts()
Moves sell token amounts from user accounts to the settlement contract, supporting three balance types:- ERC20 - Standard ERC20 token transfers
- External - Balancer Vault external balances
- Internal - Balancer Vault internal balances
batchSwapWithFee()
Executes Balancer batch swaps on behalf of users while simultaneously collecting protocol fees:Security Architecture
The contract implements layered protection:- Creator-only access prevents unauthorized vault interactions
- Immutable references prevent state tampering post-deployment
- User approvals remain isolated since only the settlement contract can trigger transfers
- No direct user interaction pathway exists — users never call this contract directly
Integration Point
The vault relayer operates within the settlement workflow, handling token transfers before and after batch swaps. It is automatically instantiated by the settlement contract during deployment.Users approve the Balancer Vault, not the VaultRelayer directly. The relayer leverages existing vault approvals to move tokens.