Bins & price discovery
This page extends DLMM explained with worked examples of price discovery. If you already understand the DLMM mental model, you can read this as a reference.
From bin index to price
Section titled “From bin index to price”The price of any bin is determined by two numbers: the pool’s bin_step (a constant set at pool creation) and the bin’s id (a signed integer that increments by one per bin).
With a bin step of 25 basis points, the progression looks like this:
| Bin ID | Formula | Price |
|---|---|---|
| −2 | 0.99501 | |
| −1 | 0.99751 | |
| 0 | 1.00000 | |
| 1 | 1.00250 | |
| 2 | 1.00501 | |
| 3 | 1.00752 |
Bin 0 is by convention the bin where the initial price of the pool sits. As trades move the active bin, future deposits can still reference any bin id, positive or negative.
The active bin
Section titled “The active bin”The active bin is the only bin that holds reserves of both tokens simultaneously. Bins to the left of active hold only the quote token; bins to the right hold only the base token. When a swap drains the active bin of the token being requested, the active bin shifts by one.
Full worked examples and edge cases are expanding in a future release of this page. For now, see the Daml reference in Developers · SDK for the exact function signatures.