Bunicorn
Launch Testnet App
  • What is Bunicorn?
  • Introduction
    • AMM DEX
    • Liquidity Mining
    • NFT Collectibles
  • Getting Started
    • Wallets that Bunicorn supports
    • Get BEP20 Tokens
    • Connect your wallet
    • Bunicorn testnet 101
  • Bunicorn Exchange TUTORIAL
    • Tutorial for Trader
    • Tutorial for Liquidity Provider
      • Setup Proxy
      • Swap native BNB to WBNB to farm
      • How to Add Liquidity on Bunicorn
        • How to add liquidity to a Flexible pool?
        • How to add liquidity to a Stable Pool?
      • How to create a new Flexible pool?
        • How to Create a New Smart Pool
        • How to Create a New Shared Pool
      • How to Remove Liquidity
    • How to Join Token Play Farms
      • Stake LPs to Token Play Farm
      • Stake Single Asset $TOP
    • How to Join Ancient Buni NFT Farms
      • NFT Farm Ends. What should I do?
      • Stake LPs to Join the Ancient Buni Farm
      • Stake Single Asset
      • Harvest NFTs (Ancient Buni)
      • How to transfer Ancient BUNI NFTs to another address?
    • How to Join Bunicorn NFT Farms
      • Prestaking Farm Ends. What's next?
      • Stake LP to Join NFT Farms
      • Stake Single Asset
      • Harvest NFTs (Chest/Egg)
      • How to unlock ingame items from Chest/Egg NFTs
      • How to Transfer Egg/Chest NFTs to another address
    • Fee Structure
  • FAQ
    • What is a Flexible Pool?
    • What is a Stable Pool?
    • Can users create Stable pools themselves?
    • Are there any constraints for setting up a Bunicorn Flexible pool?
    • What are the advantages of a Stable Pool?
  • Glossary
  • SMART CONTRACTS
    • Flexible Pools
      • Exchange Proxy
      • Smart Order Router
      • On Chain Registry
      • Smart Pools
        • Overview
        • Configurable Rights Pool
        • Component Libraries
          • Rights Manager
      • Interfaces
      • Addresses
      • Events
      • API Index
    • Stable Pools
      • Pool Addresses
      • Swap Execution
      • Providing Liquidity
      • Flash Swaps
      • Contract Addresses
      • BuniCornRouter02
      • Pool
      • Pool (ERC-20)
      • Library
  • Subgraph API
    • Stable Pools
      • Entities
      • Sample queries
    • Flexible Pools
      • Entities
      • Sample queries
Powered by GitBook
On this page
  • Summary
  • API
  • Batch Swap Functions
  • View Split Functions
  • Smart Swap Functions

Was this helpful?

  1. SMART CONTRACTS
  2. Flexible Pools

Exchange Proxy

PreviousFlexible PoolsNextSmart Order Router

Last updated 3 years ago

Was this helpful?

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 optimized 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.

off-chain SOR
On Chain Registry