State
The liquidity module x/liquidity keeps track of the Pool and PoolBatch states. The state represents your app at a given moment.
Pool
Pool stores information about the liquidity pool.
Pool type has the following structure.
The parameters of the Pool state are:
-
Pool:
0x11 | Id -> ProtocolBuffer(Pool) -
PoolByReserveAccIndex:
0x12 | ReserveAccLen (1 byte) | ReserveAcc -> ProtocolBuffer(uint64) -
GlobalLiquidityPoolIdKey:
[]byte("globalLiquidityPoolId") -
ModuleName, RouterKey, StoreKey:
liquidity -
PoolCoinDenomPrefix:
pool
PoolBatch
PoolBatch stores information about the liquidity pool batch states.
PoolBatch type has the following structure.
Batch Messages
Deposit, withdrawal, or swap orders are accumulated in a liquidity pool for a pre-defined period, which can be one or more blocks in length. Orders are then added to the pool and executed at the end of the batch. The following messages are executed in batch-style.
DepositMsgState
DepositMsgState defines the state of deposit message as it is processed in the next batch or batches.
When a user sends MsgDepositWithinBatch transaction to the network, it is accumulated in a batch. DepositMsgState contains the state information about the message; if the transaction is executed, successfully matched, and if it is to be deleted in the next block.
WithdrawMsgState
WithdrawMsgState defines the state of the withdraw message as it is processed in the next batch or batches.
When a user sends a MsgWithdrawWithinBatch transaction to the network, it is accumulated in a batch. WithdrawMsgState contains the state information about the message:
- If the transaction is executed
- If the transaction is successfully matched
- If the transaction will be deleted in the next block
SwapMsgState
SwapMsgState defines the state of swap message as it is processed in the next batch or batches.
When a user sends a MsgSwapWithinBatch transaction to the network, it is accumulated in a batch. SwapMsgState contains the state information about the message:
- If the transaction is executed
- If the transaction is successfully matched
- If the transaction will be deleted in the next block
The parameters of the PoolBatch, DepositMsgState, WithdrawMsgState, and SwapMsgState states are:
-
PoolBatch:
0x22 | PoolId -> ProtocolBuffer(PoolBatch) -
PoolBatchDepositMsgStates:
0x31 | PoolId | MsgIndex -> ProtocolBuffer(DepositMsgState) -
PoolBatchWithdrawMsgStates:
0x32 | PoolId | MsgIndex -> ProtocolBuffer(WithdrawMsgState) -
PoolBatchSwapMsgStates:
0x33 | PoolId | MsgIndex -> ProtocolBuffer(SwapMsgState)