diff --git a/x/uibc/quota/keeper/genesis.go b/x/uibc/quota/keeper/genesis.go index f8814d2797..da55d7f231 100644 --- a/x/uibc/quota/keeper/genesis.go +++ b/x/uibc/quota/keeper/genesis.go @@ -35,7 +35,7 @@ func (kb Builder) ExportGenesis(ctx sdk.Context) *uibc.GenesisState { return &uibc.GenesisState{ Params: k.GetParams(), Outflows: outflows, - OutflowSum: k.GetTotalOutflow(), + OutflowSum: k.GetOutflowSum(), QuotaExpires: *quotaExpires, Inflows: inflows, InflowSum: k.GetInflowSum(), diff --git a/x/uibc/quota/keeper/grpc_query.go b/x/uibc/quota/keeper/grpc_query.go index ba0f3a216f..bcc5e891b6 100644 --- a/x/uibc/quota/keeper/grpc_query.go +++ b/x/uibc/quota/keeper/grpc_query.go @@ -37,7 +37,7 @@ func (q Querier) Outflows(goCtx context.Context, req *uibc.QueryOutflows) ( k := q.Keeper(&ctx) var o sdk.Dec if len(req.Denom) == 0 { - o = k.GetTotalOutflow() + o = k.GetOutflowSum() } else { d := k.GetTokenOutflows(req.Denom) o = d.Amount diff --git a/x/uibc/quota/keeper/quota.go b/x/uibc/quota/keeper/quota.go index 031da8275d..f2b26edea8 100644 --- a/x/uibc/quota/keeper/quota.go +++ b/x/uibc/quota/keeper/quota.go @@ -46,8 +46,8 @@ func (k Keeper) SetOutflowSum(amount sdk.Dec) { util.Panic(err) } -// GetTotalOutflow returns the total outflow of ibc-transfer amount. -func (k Keeper) GetTotalOutflow() sdk.Dec { +// GetOutflowSum returns the total outflow of ibc-transfer amount. +func (k Keeper) GetOutflowSum() sdk.Dec { // When total outflow is not stored in store it will return 0 amount, _ := store.GetDec(k.store, keyTotalOutflows, "total_outflow") return amount @@ -158,7 +158,7 @@ func (k Keeper) CheckAndUpdateQuota(denom string, newOutflow sdkmath.Int) error // Allow outflow either of two conditions // 1. Outflow Sum <= Total Outflow Quota // 2. OR Outflow Sum <= params.InflowOutflowQuotaBase + (params.InflowOutflowQuotaRate * sum of all inflows) - outflowSum := k.GetTotalOutflow().Add(exchangePrice) + outflowSum := k.GetOutflowSum().Add(exchangePrice) inflowSum := k.GetInflowSum() if !params.TotalQuota.IsZero() { if outflowSum.GT(params.TotalQuota) || @@ -223,7 +223,7 @@ func (k Keeper) UndoUpdateQuota(denom string, amount sdkmath.Int) error { } k.SetTokenOutflow(o) - totalOutflowSum := k.GetTotalOutflow() + totalOutflowSum := k.GetOutflowSum() k.SetOutflowSum(totalOutflowSum.Sub(exchangePrice)) return nil } diff --git a/x/uibc/quota/keeper/unit_test.go b/x/uibc/quota/keeper/unit_test.go index d31d6e398e..7f766bbc1c 100644 --- a/x/uibc/quota/keeper/unit_test.go +++ b/x/uibc/quota/keeper/unit_test.go @@ -48,7 +48,7 @@ func (k TestKeeper) checkOutflows(denom string, perToken, total int64) { o := k.GetTokenOutflows(denom) require.Equal(k.t, sdk.NewDec(perToken), o.Amount) - d := k.GetTotalOutflow() + d := k.GetOutflowSum() require.Equal(k.t, sdk.NewDec(total), d) }