Balancer V1
Discord
  • Home
  • Getting Started
    • Use Cases
    • FAQ
  • Core Concepts
    • Protocol
      • Background
      • Glossary
      • Pool Lifecycle
      • Limitations
      • Math
        • Exponentiation
    • BAL Governance Token
      • BAL for Gas
    • Liquidity Mining
      • Exchange and BAL Mining Listing
      • Liquidity Mining Estimates API
    • Security
      • Audits
      • Bug Bounty
  • Smart Contracts
    • Exchange Proxy
    • Smart Order Router
      • Development & Examples
    • Smart Pools
      • Overview
      • Configurable Rights Pool
      • Component Libraries
        • Rights Manager
      • Smart Pool Templates
      • Liquidity Bootstrapping FAQ
    • On Chain Registry
    • Interfaces
    • Addresses
  • API
    • Migration to Version 1.0
    • Events
    • API Index
    • UML Docs
  • Guides
    • Interact via Etherscan
    • Using the SOR
    • Creating a Shared Pool
    • Creating a Smart Pool
    • CRP Tutorial
      • Liquidity Bootstrapping Example
    • Smart Pool Use Cases
      • Liquidity Bootstrapping Pool
      • Swing Trading Pool
      • Smart Treasury
      • Perpetual Synthetic Pool
      • Investors' Club
      • Experimental
    • Testing on Kovan
    • Hackathons
      • Hacking & Testing
      • Judging
      • Ideas
Powered by GitBook
On this page
  • This page has been deprecated. V1 documentation is partially maintained here
  • Exchange Proxy
  • Summary
  • API
  1. Smart Contracts

Exchange Proxy

PreviousBug BountyNextSmart Order Router

Last updated 3 years ago

This page has been deprecated. V1 documentation is partially maintained

Exchange Proxy

Summary

This contract includes swap forwarding proxy logic and on-chain smart order routing functionality.

batchSwap functions allows users to batch execute swaps recommended by .

viewSplit functions query the to provide best swap information using on-chain data.

smartSwap functions combine view and batch functionality to provide complete optimised on-chain swaps.

API

Batch Swap Functions

multihopBatchSwapExactIn

multihopBatchSwapExactIn(Swap[][] memory swapSequences, TokenInterface tokenIn, TokenInterface tokenOut, uint totalAmountIn, uint minTotalAmountOut) public payable

Execute multi-hop swaps returned from off-chain SOR for swapExactIn trade type.

multihopBatchSwapExactOut

multihopBatchSwapExactOut(Swap[][] memory swapSequences, TokenInterface tokenIn, TokenInterface tokenOut, uint maxTotalAmountIn) public payable

Execute multi-hop swaps returned from off-chain SOR for swapExactOut trade type.

batchSwapExactIn

batchSwapExactIn(Swap[] memory swaps, TokenInterface tokenIn, TokenInterface tokenOut, uint totalAmountIn, uint minTotalAmountOut) public payable

Execute single-hop swaps for swapExactIn trade type. Used for swaps returned from viewSplit function and legacy off-chain SOR.

batchSwapExactOut

batchSwapExactOut(Swap[] memory swaps, TokenInterface tokenIn, TokenInterface tokenOut, uint maxTotalAmountIn) public payable

Execute single-hop swaps for swapExactOut trade type. Used for swaps returned from viewSplit function and legacy off-chain SOR.

View Split Functions

viewSplitExactIn

viewSplitExactIn(address tokenIn, address tokenOut, uint swapAmount, uint nPools)

View function that calculates most optimal swaps (exactIn swap type) across a max of nPools. Returns an array of Swaps and the total amount out for swap.

viewSplitExactOut

viewSplitExactOut(address tokenIn, address tokenOut, uint swapAmount, uint nPools)

View function that calculates most optimal swaps (exactOut swap type) across a max of nPools. Returns an array of Swaps and the total amount in for swap. (! Please be aware the return parameter "totalOutput" in the contract is a misnomer and actually represents totalInput !)

Smart Swap Functions

smartSwapExactIn

smartSwapExactIn(TokenInterface tokenIn, TokenInterface tokenOut, uint totalAmountIn, uint minTotalAmountOut, uint nPools) public payable

Calculates and executes most optimal swaps across a max of nPools for tokenIn > tokenOut swap with an input token amount = totalAmountIn.

smartSwapExactOut

smartSwapExactOut(TokenInterface tokenIn, TokenInterface tokenOut, uint totalAmountOut, uint maxTotalAmountIn, uint nPools) public payable

Calculates and executes most optimal swaps across a max of nPools for tokenIn > tokenOut swap with a desired output token amount = totalAmountOut.

here
off-chain SOR
On Chain Registry