Tracking Pool Balances
The LBPair contract emits DepositedToBins and WithdrawnFromBins events when users add or remove liquidity from the market.
We track the user balances in LBPairs by parsing these events.
Liquidity is deposited/withdrawn into multiple
Bins, for which theBin Idsare returned in arrayuint256[] ids.Token amounts deposited/withdrawn are tracked by
amounts, which is a of tuple[amountX, amountY]encoded intobyte32.The arrays
amounts[]andids[]correspond to the token amounts andBin Idsof each correspondingBin.See Byte32 Decoding for more details.
DepositedToBins
// ILBPair.sol
event DepositedToBins(
address indexed sender,
address indexed to,
uint256[] ids,
bytes32[] amounts
);WithdrawnFromBins
// ILBPair.sol
event WithdrawnFromBins(
address indexed sender,
address indexed to,
uint256[] ids,
bytes32[] amounts
);Example Handler
Last updated