Let's trace a simplified example of a user adding liquidity to a single bin.
- Bin 100 (Price = 1.00 USDC per SOL)
- User wants to add: 100 USDC and 100 SOL
- Initial State: Bin is empty (
total_shares = 0)
User specifies:
delta_id = 0(Active Bin)dist_x = 5000(50% of X)dist_y = 5000(50% of Y)
Calculated from input amounts (e.g., total input 200 USDC, 200 SOL):
When total_shares == 0, we use the geometric mean:
User receives 100 shares.
Bin State After Case A:
reserve_x = 100reserve_y = 100total_shares = 100
Now User 2 comes along.
- Wants to add 50 USDC and 50 SOL.
- Bin already has liquidity (from Case A).
We calculate the share ratio for both X and Y and take the minimum:
User 2 receives 50 shares.
Bin State After Case B:
reserve_x = 100 + 50 = 150reserve_y = 100 + 50 = 150total_shares = 100 + 50 = 150
Imagine User 3 tries to cheat. They add 1000 USDC but only 1 SOL.
- The bin ratio is 1:1 (150 X : 150 Y).
- User 3 adds 10:1 ratio.
They only get 1 share.
- Their extra 999 USDC is effectively "donated" to the pool (captured by existing LPs).
- This forces LPs to add liquidity matching the current bin ratio.