The quoting equation
For an input ofamount_in, the program computes:
- A final
spreadof0.999means 10 bps of spread around your oracle price, on both the bid and the ask. - Oracle price is quote atoms per base atom in Q32.32, as are factors (
1.0 = 2^32). - The clamp caps the spread factor at
1.0by default, so you never quote better than your oracle price. See Risk controls. - The fee, and any token transfer fee, comes off the input first. See Fees.
Your curves
Each side of the pool (bid and ask) has two curves you define:price_curve(input_amount)sets the factor by trade size, so larger trades can be priced wider.inventory_curve(your_inventory)sets the factor by your inventory, so your price skews as your position moves without you sending an update.
- Stateless (the default). Every trade reads the price curve from the start, so identical trades get identical prices.
- Stateful (integrated). Trades use up the curve like a book and pay the average across the depth they take, so a burst of orders walks down it. It refills at a rate you set, or when your crank refills it.
- % mode. The inventory axis is your share of value in base, as a %. This way you can set how your quotes skew at, for instance, an 80/20 imbalance.
- Integrated. The inventory axis is your token balance, and the factor is averaged over the inventory move the trade causes.