From 5ad6cb2fe8401d00887657e93252cae6a809ec94 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Tue, 31 Oct 2023 18:52:35 +0530 Subject: [PATCH] add new params values to upgrade handler --- app/upgrades.go | 16 ++++++++++++++++ x/uibc/quota/keeper/quota.go | 2 +- x/uibc/quota/keeper/quota_test.go | 4 ++-- x/uibc/quota/keeper/unit_test.go | 6 +++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index d6a49f0513..57f657f627 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -126,6 +126,22 @@ func (app *UmeeApp) registerUpgrade6_2(upgradeInfo upgradetypes.Plan) { govParams := app.GovKeeper.GetParams(ctx) govParams.MinInitialDepositRatio = sdk.NewDecWithPrec(1, 2).String() err = app.GovKeeper.SetParams(ctx, govParams) + if err != nil { + return fromVM, err + } + + // uibc params + uibcParams := app.UIbcQuotaKeeperB.Keeper(&ctx).GetParams() + uibcParams.TotalQuota = sdk.NewDec(1_600_000) + uibcParams.TokenQuota = sdk.NewDec(900_000) + uibcParams.InflowOutflowQuotaBase = sdk.NewDec(1_000_000) + // TODO: needs to finalize quota rate + uibcParams.InflowOutflowQuotaRate = sdk.MustNewDecFromStr("0.1") + + err = app.UIbcQuotaKeeperB.Keeper(&ctx).SetParams(uibcParams) + if err != nil { + return fromVM, err + } return fromVM, err }, ) diff --git a/x/uibc/quota/keeper/quota.go b/x/uibc/quota/keeper/quota.go index 3c2061abf0..66a1d32106 100644 --- a/x/uibc/quota/keeper/quota.go +++ b/x/uibc/quota/keeper/quota.go @@ -253,7 +253,7 @@ func (k Keeper) UndoUpdateQuota(denom string, amount sdkmath.Int) error { return nil } -// RecordIBCInflow validates if inflow token is registered in x/leverage +// RecordIBCInflow will save the inflow amount if token is registered otherwise it will skip func (k Keeper) RecordIBCInflow(ctx sdk.Context, packet channeltypes.Packet, dataDenom, dataAmount string, isSourceChain bool, ) exported.Acknowledgement { diff --git a/x/uibc/quota/keeper/quota_test.go b/x/uibc/quota/keeper/quota_test.go index 18115608d6..2a48f22456 100644 --- a/x/uibc/quota/keeper/quota_test.go +++ b/x/uibc/quota/keeper/quota_test.go @@ -73,8 +73,8 @@ func TestUnitCheckAndUpdateQuota(t *testing.T) { k.checkOutflows(umee, 50, 94) // transferring additional 5 umee => 10USD, will fail total quota check but it will pass inflow quota check - // sum of outflows <= $1M + params.InflowOutflowQuota * sum of all inflows = (10_000_000) * 50 + (0) = 500000000 - // 104 <= 500000000 + // sum of outflows <= $1M + params.InflowOutflowQuotaRate * sum of all inflows = (10_000_000)+ (50*0) = 10_000_000 + // 104 <= 10_000_000 err = k.CheckAndUpdateQuota(umee, sdk.NewInt(5)) require.NoError(t, err) k.checkOutflows(umee, 60, 104) diff --git a/x/uibc/quota/keeper/unit_test.go b/x/uibc/quota/keeper/unit_test.go index ede6259918..7cb820892d 100644 --- a/x/uibc/quota/keeper/unit_test.go +++ b/x/uibc/quota/keeper/unit_test.go @@ -54,6 +54,10 @@ func (k TestKeeper) checkOutflows(denom string, perToken, total int64) { } func (k TestKeeper) setQuotaParams(perToken, total int64) { - err := k.SetParams(uibc.Params{TokenQuota: sdk.NewDec(perToken), TotalQuota: sdk.NewDec(total)}) + err := k.SetParams(uibc.Params{ + TokenQuota: sdk.NewDec(perToken), + TotalQuota: sdk.NewDec(total), + InflowOutflowQuotaBase: sdk.NewDec(1_000_000), + }) require.NoError(k.t, err) }