Bin

Each bin is a small market. In this case, the exchange rate of the two assets in the market is constant, meaning that the market can be viewed as a small Constant Sum Market Makers pool. A bin is similar to a quote in an order book. Each bin represents one price, and many make up the entire pool to exchange a pair of tokens.

The active trading market is called the active bin, meaning that the price across the entire market equals the price of the token currently being exchanged in the active bin. The trade starts from the active bin when a taker order is placed. The liquidity of the current active bin is used to fulfill the taker order, and when the active bin is exhausted, it moves to the next bin to finish the trade.

For example, there is a market that exchanges token X for USDC. Suppose the current price is 10 USDC, the next price is 11 USDC, the following price is 12 USDC, 13 USDC... and so on for an integer range, and there are 5 tokens of X at each price due to maker orders.

At this point, a taker has created a taker order worth 100 USDC.

To calculate the amount of tokens X the taker can receive, we need to traverse each bin and calculate the amount of tokens that can be exchanged.

First, a trade must be initiated on the active bin. Currently, the exchange rate in the active bin is 1:10, and there are 5 tokens X in existence. Therefore, the taker order of 100 USDC cannot be fulfilled, and you must accept all of the tokens X that exist in this bin before moving on to the next bin.

Amount of taker orders left after using the first bin = 100 - 10 * 5 = 50

In the second bin, the exchange rate is 1:11, and the trade can be completed in the second bin because the amount of remaining taker orders is lower than the value of tokens X deposited in the second bin. In this case, the amount of tokens X that can be received in this bin is 50 / 11.

Therefore, the total amount of tokens this taker can receive is 5 + 50 / 11, and the active bin changes accordingly, with the current price of token X being 11 USDC.

Each bin has a fixed exchange rate for its tokens, meaning that the formula for determining the price in a bin follows the constant sum price formula. Therefore, it is possible to trade with zero slippage as long as trades do not leave the bin.

Slippage only occurs when the liquidity in the active bin is exhausted, meaning that zero slippage is possible if a trader trades enough never to use up the active bin. This is a significant difference from CPMMs, where every trade has some slippage.

ION names each market a Bin.

Last updated