github.com/gravity-devs/liquidity@v1.5.3/x/liquidity/spec/06_end_block.md (about)

     1  <!-- order: 6 -->
     2  
     3   # Before-End-Block
     4  
     5  These operations occur before the end-block operations for the liquidity module.
     6  
     7  ## Append messages to LiquidityPoolBatch
     8  
     9  After successful message verification and coin `escrow` process, the incoming `MsgDepositWithinBatch`, `MsgWithdrawWithinBatch`, and `MsgSwapWithinBatch` messages are appended to the current `PoolBatch` of the corresponding `Pool`.
    10  
    11  # End-Block
    12  
    13  End-block operations for the Liquidity Module.
    14  
    15  ## Execute LiquidityPoolBatch upon execution heights
    16  
    17  If there are `{*action}MsgState` messages that have not yet executed in the `PoolBatch` for each `Pool`, the `PoolBatch` is executed. This batch contains one or more `DepositLiquidityPool`, `WithdrawLiquidityPool`, and `SwapExecution` processes.
    18  
    19  ### Transact and refund for each message
    20  
    21  A liquidity module escrow account holds coins temporarily and releases them when state changes. Refunds from the escrow account are made for cancellations, partial cancellations, expiration, and failed messages.
    22  
    23  ### Set states for each message according to the results
    24  
    25  After transact and refund transactions occur for each message, update the state of each `{*action}MsgState` message according to the results.
    26  
    27  Even if the message is completed or expired:
    28  
    29  1. Set the `ToBeDeleted` state value as true instead of deleting the message directly from the `end-block`
    30  2. Delete the messages that have `ToBeDeleted` state from the begin-block in the next block so that each message with result state in the block can be stored to kvstore.
    31  
    32  This process allows searching for the past messages that have this result state. Searching is supported when the kvstore is not pruning.