Factor Docs
  • 🏭Introduction to Factor
  • Getting Started
    • πŸ•ΉοΈQuickstart
    • πŸ”—Supported Protocols
    • πŸ”Strategy Cheatsheet
      • Swaps Cheatsheet
        • Conditional Market Order
        • Automated Market Order
        • Multi Swap
        • Automated Swap & Earn
        • Automated Scale Order
        • Scale Order Partial Fill Yield
        • Interest On Pending Trades
        • Leverage Trade
        • Leverage DCA
      • Lending Cheatsheet
        • Lending Pool Zap
        • Multi Lend
        • Market Making To Lending Switch
        • Earn Negative Interest
        • Carry Trade
        • Leveraged Staking Yields
        • Leveraged Fixed Yields
      • Borrowing Cheatsheet
        • Collateralized Borrow
        • Collateralized Borrow Zap
        • Multi Borrow
        • Debt Switching
        • Automated Debt Readjustments
        • Debt Refinancing
        • Asset Switching
      • Liquidity Provision Cheatsheet
        • Liquidity Pool Zap
        • Yield Farm Zap
        • Automated LP Adjustments
        • Yield Farm Adjustments
      • Flash Loan Cheatsheet
    • 🧠Strategy Explainers
      • Leverage
        • Leverage Performance Modelling
        • Leverage Long Simulation
        • Leverage Short Simulation
      • Yield
        • Yield Performance Modelling
      • PT Strategies
        • Leverage Long PT Simulation
      • Delta Neutral Yields
        • Levered USD & ETH Carry
    • πŸ“–Glossary
  • Factor Discover
    • πŸ”Factor Discover
      • Public Strategies User Guides
        • Deposit Into User Created Strategies
        • Withdraw From User Created Strategies
      • Leverage User Guides
        • Create A Leveraged Position
        • Adjust Position Leverage
        • Add Collateral To Position
        • Withdraw Collateral From Position
        • Repay Position Debt
      • Yield User Guides
        • Auto-compound Your Yields
      • PT User Guides
        • Redeem Your PT
      • APY Calculations
    • βš™οΈFactor Operated Strategies
      • Yield Type Strategies
        • Additional rETH Yields On USDC Lend
        • Amplified rETH Yields On USDC Lend
        • Additional Liquid Staked ETH Yields On USDC Lend
        • Additional Liquid Restaked ETH Yields On USDC Lend
      • Trading Type Strategies
        • WBTC Base Switch On rETH For ETH & USDC Yields
      • Delta Neutral Type Strategies
        • Delta Neutral ETH With rETH & USDC Yields
  • Factor Studio
    • 🎨Factor Studio
      • Automated Strategies
      • Conditional Strategies
    • 🏠Private Strategies
      • User Guide
        • Private Strategy Creation
    • πŸ‘₯Public Strategies
      • User Guide
        • Public Strategy Creation
        • Create An Exit Strategy
        • Making Your Strategy Public
        • Strategy Execution
      • Security
      • Exit Strategy
    • πŸ—οΈStrategy Builder
      • Building Blocks User Guide
        • Lend
        • Borrow
        • Swap
        • Flash Loan
    • πŸ“œStudio Contracts
      • Leverage
        • FactorLeverageDescriptor.sol
        • FactorLeverageVault.sol
        • WrapperFactorLeverageVault.sol
      • LP Management
        • FactorLPVault.sol
        • FactorLPDescriptor.sol
  • Factor SDK
    • πŸ“¦Factor SDK
    • ↔️REST APIs
      • Utility APIs
        • Pricing
        • Stats
  • Factor Building Blocks
    • 🧱Factor Building Blocks
    • ➑️Lend
    • ⬅️Borrow
    • πŸ”„Leverage
      • Concepts
        • Collateralized Lending & Borrowing
        • Looping
      • Leverage Dev Guides
        • Create Leveraged Position
        • Add Leverage To Position
      • Strategy Contracts
        • AAVEV3LeverageStrategy.sol
        • CompoundLeverageStrategy.sol
        • LodeStarLeverageStrategy.sol
        • RadiantLeverageStrategy.sol
        • SiloLeverageStrategy.sol
        • SiloYieldTokenStrategy.sol
        • TenderLeverageStrategy.sol
      • FAQ - Leverage Building Block
    • πŸ’°Yield
      • Concepts
        • Yield Farming
        • Yield Aggregators
      • ⚑Zap
    • 🌊LP Management
      • Concepts
        • Automated Market Maker
        • Concentrated Liquidity
    • πŸ₯©Stake
    • πŸ”€Swap
      • Concepts
        • Market Orders
        • DEX Aggregators
    • πŸͺ„Flash Loan
      • Concepts
        • Uncollateralized Lending & Borrowing
        • Flash Loan
  • Factor Adapters
    • πŸ”ŒFactor Adapters
    • πŸ“œAdapter Contracts
      • Leverage
      • Yield
      • Swap
      • Flash Loan
  • Governance
    • πŸ›οΈFactorDAO
      • Factor Flywheel
      • Factor Participants
      • Governance Incentive Calculations
        • FactorDAO Incentives Model (LTIPP)
      • User Guides
        • Stake FCTR
        • Governance Migration
      • Contracts
        • FactorDAO Contract Addresses
      • FactorDAO Multisig Addresses
      • Platform Fees
    • πŸͺ™FCTR Token
      • Staking and Governance
      • Tokenomics
      • Contract Addresses
      • FAQ - Tokenomics
    • βš–οΈFactor Scale
      • Arbitrum Foundation LTIPP
      • Emission Multiplier Calculations
        • Emissions Multiplier Model
      • User Guides
        • Stake FCTR
        • Vote On Emissions Distribution
      • Contracts
        • Factor Scale Contract Addresses
      • ❔FAQ - Factor Scale
    • πŸš€Factor Boost
      • Contracts
        • Factor Boost Contract Addresses
    • πŸ’ΌFactor Bribes
      • Contracts
        • Factor Bribes Contracts
  • Security
    • πŸ›‘οΈSecurity
    • πŸ“‹Audits
      • PeckShield
        • Leverage Vault Wrapper
        • Silo Yield
        • Silo Leverage
        • Penpie
        • Factor Boost
      • SourceHat
        • FactorDAO Vaults
        • FCTR & Voting Escrow
  • Reference
    • Discover Pro dApp
    • Studio dApp
    • Discover dApp
    • Official Website
    • Press Kit
    • Partnership Form
    • Media Kit
    • Geo Restrictions
  • Community
    • Factor Contributors
    • X
    • Discord
    • Telegram
    • Medium
    • Email Enquiries
Powered by GitBook
On this page
  • Overview
  • Concepts
  • Price curves
  • Example

Was this helpful?

  1. Factor Building Blocks
  2. LP Management
  3. Concepts

Automated Market Maker

PreviousConceptsNextConcentrated Liquidity

Last updated 1 year ago

Was this helpful?

Overview

Per its namesake, Automated Market Maker (AMM) DEXs maintains a liquidity pool of assets against which trades can be made automatically along a pricing curve. Asset holders are incentivised to provide their tokens to the liquidity pool smart contract in exchange for a portion of the trading fees. In this case, AMM liquidity is generated when token holders lock their tokens in a liquidity pool in exchange for a percentage return on their assets. Generally speaking, the more liquidity locked in a pool, the larger the pool size relative to a trade which results in lesser slippage.

In the pursuit of greater capital efficiency, many AMMs have also implemented their own price curve formulas that enable more fine-grained tuning of liquidity flows. These specialised price curves enable users or the protocol to concentrate liquidity within a particular price interval based on specific use cases. Critically, the price curve is bounded by the pool’s total liquidity and therefore AMM DEX liquidity is heavily reliant on liquidity provider incentives.

Concepts

As this liquidity solution involved the creation of a fundamentally different market, it required multiple concepts to be stacked on top of each other:

  • Create a pool of assets against which trades can be made for a small fee. The composition of this basket of assets will be determined by the trades that are taking place against it. Arbitrageurs will play a key role in rebalancing this pool with the wider market.

  • Create a price curve for the pool which ingests price data from a reliable external source. The exact price for a trade being done against the pool will take into account the external price feed, the current pool composition, as well as resulting effect the trade will have on the pool's liquidity.

  • Incentivize asset holders to provide their assets to the pool via a percentage return on their assets. The majority of the trading fee which the pool charges will be accrued to the pool. This is also to sufficiently compensate the asset holder for locking up their asset with the pool and becoming a liquidity provider (LP).

  • Mint new derivative tokens to the LPs’ wallet which will allow reclaiming of their assets as well as any fees which have accrued to the pool. These LP tokens represent a proportion of the pooled assets and can themselves be traded.

Taken as a whole, this solution came to be known as the Automated Market Maker (AMM). β€œAutomated” because it is always available for trading and does not depend on the traditional interaction between buyers and sellers where orders must first be submitted (i.e. orderbook model).

Price curves

Price curves are key to ensuring the stability of the pool as well as the capital efficiency of the assets within a pool. Price curves are essentially constant product curves whose most basic form, xβˆ—y=kx * y =kxβˆ—y=k, ensures that the price for each additional token purchased from the pool scales according to the relative ratio of tokens in the pool.

Example

The example below assumes an existing ETH/USDT pool which has an exact 50:50 value ratio of tokens (1 ETH = 2000 USDT).

Liquidity Pool
ETH amount
USDT amount
Constant

ETH/USDT

100

200,000

20,000,000

Swap

For a 1 ETH swap, the trader will receive 3,921.57 USDT. In effect, the average price per ETH is effectively 1,960.79 USDT. Notice that the final price differs from the initial pool price before the swap (i.e. 1 ETH = 2,000 USDT). This exponential price scaling ensures that the 20,000,000 constant is maintained as the supply of each token in the pool changes.

Liquidity Pool
ETH amount
USDT amount
Constant

ETH/USDT

102

196,078

20,000,000

Based on the above, the price for the next ETH unit in the pool after the trade is 196,078/102 = 1,922.33.

Critically, the changes in pool ratios have to be taken within the wider context of the overall ETH/USDT market. In this case, assuming that the market price of ETH on external markets remains at 1 ETH to 2,000 USDT, a profit opportunity presents itself for arbitrageurs who will buy ETH from the pool and sell it on external exchanges to pocket the price differential (i.e. buy 2 ETH at an average price of 1,960.79 and resell it for 2,000 hence making a profit of 78.42). This arbitrage action will bring the pool back in line with the market rate. Arbitrageurs play a crucial role in rebalancing the pool with the external market.

Adding and removing liquidity

For liquidity contributions and withdrawals, the ratio of the tokens in the pool must be maintained. Assuming we have the same ETH/USDT pool above:

Liquidity Pool
ETH amount
USDT amount
Constant

ETH/USDT

102

196,078

20,000,000

Any liquidity additions or removals, will require a ratio of 1ETH:1,922USDT. This ensures that the price of the pool is unaffected by liquidity additions or removals. Consequently, note that the ratio will be dependent upon the exact ratio in the pool at the point of adding/removing liquidity.

Assuming that a liquidity provider wants to remove exactly 2 ETH from the pool, the withdrawal will also result in 3,844 USDT being removed from the pool. Notice that the constant has also been updated but the price ratio remains the same (192,234/100=1,922).

Liquidity Pool
ETH amount
USDT amount
Constant

ETH/USDT

100

192,234

19,223,400

For AMM implementations, xxx is the quantity of TokenA while yyy is the quantity of TokenB. This means that the pool's token ratio always shifts according to the constant product, kkk, of the token quantities. Any action against the pool (trades, deposits, or withdrawals), will always be executed based on the price curve.

For ease of understanding, the example below showcases how prices change according to a standard constant product curve (i.e. xβˆ—y=kx * y =kxβˆ—y=k). Newer AMM iterations implement more complex price curves but the underlying principals remains the same.

A trader decides to trade 2 ETH for USDT using the pool. We can calculate the equivalent USDT amount for the trade by using the constant product 20,000,000 calculated above. Note that xxx refers to ETH amount and yyy refers to USDT amount.

(x+Ξ”x)(y+Ξ”y)=k(x +\Delta{x})(y+\Delta{y})=k(x+Ξ”x)(y+Ξ”y)=k
(100+2)(200,000+Ξ”y)=20,000,000(100+2)(200,000+\Delta{y})=20,000,000(100+2)(200,000+Ξ”y)=20,000,000
Ξ”y=20,000,000102βˆ’200,000\Delta{y}=\frac{20,000,000}{102} - 200,000Ξ”y=10220,000,000β€‹βˆ’200,000
Ξ”y=βˆ’3,921.57\Delta{y}=-3,921.57Ξ”y=βˆ’3,921.57
🌊
A constant price curve