Skip to content

Commit 920ec41

Browse files
committed
making first liqudiation closing ratio as param
1 parent f10d2ef commit 920ec41

File tree

7 files changed

+215
-74
lines changed

7 files changed

+215
-74
lines changed

api/elys/perpetual/params.pulsar.go

Lines changed: 97 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/elys/perpetual/params.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,9 @@ message Params {
135135
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
136136
(gogoproto.nullable) = false
137137
];
138+
string first_liquidation_closing_ratio = 27 [
139+
(cosmos_proto.scalar) = "cosmos.Dec",
140+
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
141+
(gogoproto.nullable) = false
142+
];
138143
}

x/perpetual/keeper/force_close.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ func (k Keeper) ForceClose(ctx sdk.Context, mtp *types.MTP, pool *types.Pool, am
1515
closingRatio := math.LegacyOneDec()
1616
addCollateral := false
1717
if isLiquidation && !mtp.PartialLiquidationDone {
18-
closingRatio = math.LegacyOneDec().QuoInt64(2)
18+
params := k.GetParams(ctx)
19+
closingRatio = params.FirstLiquidationClosingRatio
1920
addCollateral = true
2021
}
2122
repayAmt, returnAmount, perpetualFeesCoins, closingPrice, collateralToAdd, err := k.EstimateAndRepay(ctx, mtp, pool, ammPool, closingRatio, isLiquidation)

x/perpetual/migrations/v22_migration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ func (m Migrator) V22Migration(ctx sdk.Context) error {
99
params := m.keeper.GetParams(ctx)
1010
params.MinimumFundingRate = math.LegacyMustNewDecFromStr("0.1")
1111
params.SecondLiquidationTriggerRatio = math.LegacyMustNewDecFromStr("0.67")
12+
params.FirstLiquidationClosingRatio = math.LegacyMustNewDecFromStr("0.5")
1213
err := m.keeper.SetParams(ctx, &params)
1314
if err != nil {
1415
return err

x/perpetual/migrations/v23_migration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
func (m Migrator) V23Migration(ctx sdk.Context) error {
99
params := m.keeper.GetParams(ctx)
1010
params.SecondLiquidationTriggerRatio = math.LegacyMustNewDecFromStr("0.67")
11+
params.FirstLiquidationClosingRatio = math.LegacyMustNewDecFromStr("0.5")
1112
err := m.keeper.SetParams(ctx, &params)
1213
if err != nil {
1314
return err

x/perpetual/types/params.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func NewParams() Params {
3737
TakerFee: math.LegacyMustNewDecFromStr("0.00075"),
3838
MinimumFundingRate: math.LegacyMustNewDecFromStr("0.1"),
3939
SecondLiquidationTriggerRatio: math.LegacyMustNewDecFromStr("0.67"),
40+
FirstLiquidationClosingRatio: math.LegacyMustNewDecFromStr("0.5"),
4041
}
4142
}
4243

0 commit comments

Comments
 (0)