Skip to content

Commit

Permalink
add new params values to upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
gsk967 committed Oct 31, 2023
1 parent b1382bf commit 5ad6cb2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
16 changes: 16 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
)
Expand Down
2 changes: 1 addition & 1 deletion x/uibc/quota/keeper/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions x/uibc/quota/keeper/quota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion x/uibc/quota/keeper/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 5ad6cb2

Please sign in to comment.