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
  • Workflow
  • 1. Take out a loan
  • 2. Do something
  • 3. Repay the loan
  • Flash Swaps

Was this helpful?

  1. Products
  2. The Vault

Flash Loans

PreviousThe VaultNextBalancer Pools

Last updated 2 years ago

Was this helpful?

Overview

While the consolidated liquidity in the Vault does not improve price impact on a per-pool basis, but it does enable Balancer Protocol to leverage that combined liquidity by offering Flash Loans. Flash Loans, , are uncollateralized loans that must be repaid (plus interest) in the same transaction as they is borrowed. If a strategy is unable to repay the loan, the entire transaction is reverted, returning all borrowed tokens to the Vault.

Workflow

What does a sample Flash Loan transaction look like?

1. Take out a loan

Borrow X amount of DAI, up to the total amount of DAI available in the Vault.

2. Do something

Any maneuver that can be profitable within the span of a single transaction is worth performing with a flash loan. Two of the most common flash loan use cases are arbitrage and collateral swap:

Arbitrage Trade

  • Trade DAI for TokenA on one DEX

  • Trade TokenA for DAI on another DEX

Collateral Swap

  • Pay off DAI loan for collateral

  • Trade collateral for TokenA

  • Take out another DAI loan with TokenA as collateral

3. Repay the loan

Check if final_amount >= X * (1 + interest_rate)

  • If successful, repay X * (1 + interest_rate) of DAI and keep profit (if any)

  • If unsuccessful, revert transaction and lose gas fee

Flash Swaps

Further, anyone who identifies a price discrepancy in two Balancer Pools can execute a Flash Swap. An arbitrageur who makes a flash swap does not need to hold any of the input tokens that one would normally need to make a trade. Instead, the trader identifies the imbalance, tells the Vault to make the swap, and is rewarded with the profit.

originally created by Aave