github.com/gravity-devs/liquidity@v1.5.3/x/liquidity/abci.go (about)

     1  package liquidity
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/cosmos/cosmos-sdk/telemetry"
     7  	sdk "github.com/cosmos/cosmos-sdk/types"
     8  
     9  	"github.com/gravity-devs/liquidity/x/liquidity/keeper"
    10  	"github.com/gravity-devs/liquidity/x/liquidity/types"
    11  )
    12  
    13  // In the Begin blocker of the liquidity module,
    14  // Reinitialize batch messages that were not executed in the previous batch and delete batch messages that were executed or ready to delete.
    15  func BeginBlocker(ctx sdk.Context, k keeper.Keeper) {
    16  	defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker)
    17  	k.DeleteAndInitPoolBatches(ctx)
    18  }
    19  
    20  // In case of deposit, withdraw, and swap msgs, unlike other normal tx msgs,
    21  // collect them in the liquidity pool batch and perform an execution once at the endblock to calculate and use the universal price.
    22  func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
    23  	defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker)
    24  	k.ExecutePoolBatches(ctx)
    25  }