Balancer
Balancer V2
Balancer V2
  • Protocol Overview
  • Developer Docs
  • Products
    • The Vault
      • Flash Loans
    • Balancer Pools
      • Weighted Pools
      • Composable Stable Pools
      • Liquidity Bootstrapping Pools (LBPs)
      • Managed Pools
        • Asset Managers
      • Boosted Pools
      • Custom Pools
    • Smart Order Router
    • Balancer CoW Protocol
    • Oracles (deprecated)
  • Concepts
    • Math
      • Weighted Math
      • Stable Math
    • Fees
  • Ecosystem
    • Governance
      • Governance Process
        • RFC/Proposal Forum Post Template
      • BAL Governance Token
      • Snapshot
      • Multisig
        • Other DAO Multisigs
      • Governable Protocol Fees
      • Emergency subDAO
    • Community
      • Ballers
      • Delegation
      • Grants
    • veBAL and Gauges
      • veBAL
        • How veBAL Works
        • How To Use veBAL
        • How veBAL Boosting Works
          • Working Supply
          • Calculating My Boost
          • Minimum veBAL for Max Boost
        • BIP19 and Yield Bearing Tokens
      • Gauges
        • How Gauges Work
        • How To Use Gauges
  • Security
    • Audits
    • Bug Bounties
    • Emergency Pause
    • Token Compatibility
    • Balancer x Certora Accelerator
  • Getting Started
    • FAQs
      • Swapping
      • Liquidity
      • Liquidity Mining with the veBAL and Gauge System
      • Liquidity Mining (Legacy)
      • Fees
      • Governance
      • The Vault
      • Pools and LBPs
      • Asset Managers
      • Oracles
      • About Balancer Protocol and Labs
      • V2 in a Nutshell
      • V1 ➝ V2 Migration
    • Walkthroughs
      • Trade
      • Invest
    • Contribution Guide
  • Community
    • Discord
    • Forums
    • Medium
    • Dune Analytics
  • Developers (Deprecated)
    • !!! DEPRECATED !!! ⛔
    • Guides
      • Pool Verification
    • Smart Order Router V2
    • GitHub
Powered by GitBook
On this page
  • Overview
  • Utilize All the Liquidity!
  • Taking Gas Into Account
  • How It Works
  • Multiple Pools, Same Spot Price

Was this helpful?

  1. Products

Smart Order Router

PreviousCustom PoolsNextBalancer CoW Protocol

Last updated 3 years ago

Was this helpful?

Overview

The Smart Order Router (SOR) finds the best prices for Balancer traders. For given input and output tokens, the SOR finds the optimal trades whether that is a direct swap in one pool, or a combination of trades hopping through multiple pools.

Utilize All the Liquidity!

As the variety of Balancer Pools grows, the SOR grows too! The SOR keeps expanding as new pool types that use different math under the hood are added. This ensures that all pools in the Balancer ecosystem can support trades. By integrating with the SOR, any custom pool built on Balancer can benefit from all the other Balancer liquidity. All you need to integrate a pool is first and second order differentiable spotPriceAfterSwap functions (differentiable either numerically or analytically).

Taking Gas Into Account

In an ideal world in which gas costs are negligible, a trade between two tokens would involve each Balancer pool that contains that pair. This would utilize all the available liquidity for the trader and maintain equal prices across all pools. Such a scenario would be an arbitrage-free state, in which no value could be extracted from the pools' price differences.

Since there are incremental gas costs for each swap added to a batch, additional pools are added to the path only when they provide enough of a price difference to make up for the gas. Since only a subset of pools are considered, this can create arbitrage opportunities across Balancer pools.

How It Works

The optimization mechanism finds the path through a set of Balancer Pools with the greatest output (after gas costs).

Multiple Pools, Same Spot Price

In order to get the best price for a trader, the SOR is designed to create an arbitrage-free state between the paths it's using. In order to achieve this, each path the SOR routes through needs to provide the same spot price after the swap has completed.

Page cover image