Build an AMM with Proteus

A brief summary of how to construct an AMM using Proteus

Derive a Bonding Curve for Proteus

Constructing an AMM using Proteus is much simpler than building one from scratch. Here is a brief summary of how to derive a Proteus bonding curve with concentrated liquidity.
  1. 1.
    Gather price data by looking at the historical prices for the pair over the last year. One resource you can use for this is Nomics.
  2. 2.
    Use the historical prices to decide where to concentrate liquidity. Stable-to-stable pools are designed so that when the pool's liquidity is split 50-50 across both tokens, the swap rate is the median rate over the last year. Volatile-to-stable pools (like USD+ETH) are designed so that when the pool's liquidity is split 50-50 across both tokens, the swap rate uses the median dollar value of the volatile token over the last year (note, this creates visually unusual bonding curves—basically it looks like a vertical line).
  3. 3.
    Assign price buckets to fit the historical price distribution. You can use as many as you like. The first deployed pools used 8-12 for stable-to-stable pairs and fewer (~4) for volatile-to-stable pairs. In this case, fewer buckets means larger buckets. This is necessary because their prices (of ETH or BTC, for example) are so variable. Therefore these volatile-to-stable curves are less concentrated than the stable-to-stable pools, although they are still significantly more concentrated than constant product curves.
  4. 4.
    Next, you assign approximate liquidity concentration values to each price bucket. The concentration of liquidity determines how much to magnify that portion of the curve (as detailed in the section "Deriving segment parameters"). In other words, assign multipliers to each price bucket so a higher proportion of the pool's liquidity will always be allocated to the more popular price buckets.
  5. 5.
    Finally, you plug all this information into a gigantic system of equations to help create a composite function that takes each magnified curve section and stitches it together, resulting in one big curve.