Skip to content

Commit af9ef6f

Browse files
committed
making perpetual safety factor per pool
1 parent 94891e4 commit af9ef6f

File tree

4 files changed

+3
-10
lines changed

4 files changed

+3
-10
lines changed

x/perpetual/keeper/mtp_trigger.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ func (k Keeper) MTPTriggerChecksAndUpdates(ctx sdk.Context, mtp *types.MTP, pool
7373

7474
k.SetPool(ctx, *pool)
7575

76-
safetyFactor := k.GetSafetyFactor(ctx)
7776
// Position is unhealthy, close the position
78-
if mtp.MtpHealth.LTE(safetyFactor) {
77+
if mtp.MtpHealth.LTE(pool.MtpSafetyFactor) {
7978
forceClosed = true
8079
repayAmt, returnAmt, perpetualFeesCoins, closingPrice, err = k.ForceClose(ctx, mtp, pool, ammPool)
8180
if err != nil {

x/perpetual/keeper/open_consolidate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ func (k Keeper) OpenConsolidate(ctx sdk.Context, existingMtp *types.MTP, newMtp
6767
}
6868

6969
// Check if the MTP is unhealthy
70-
safetyFactor := k.GetSafetyFactor(ctx)
71-
if existingMtp.MtpHealth.LTE(safetyFactor) {
70+
if existingMtp.MtpHealth.LTE(pool.MtpSafetyFactor) {
7271
return nil, errorsmod.Wrapf(types.ErrMTPUnhealthy, "(MtpHealth: %s)", existingMtp.MtpHealth.String())
7372
}
7473

x/perpetual/keeper/params.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ func (k Keeper) GetBorrowInterestPaymentEnabled(ctx sdk.Context) bool {
9494
return k.GetParams(ctx).BorrowInterestPaymentEnabled
9595
}
9696

97-
func (k Keeper) GetSafetyFactor(ctx sdk.Context) sdkmath.LegacyDec {
98-
return k.GetParams(ctx).SafetyFactor
99-
}
100-
10197
func (k Keeper) IsWhitelistingEnabled(ctx sdk.Context) bool {
10298
return k.GetParams(ctx).WhitelistingEnabled
10399
}

x/perpetual/keeper/process_open.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ func (k Keeper) ProcessOpen(ctx sdk.Context, pool *types.Pool, ammPool *ammtypes
100100
}
101101

102102
// Check if the MTP is unhealthy
103-
safetyFactor := k.GetSafetyFactor(ctx)
104-
if mtp.MtpHealth.LTE(safetyFactor) {
103+
if mtp.MtpHealth.LTE(pool.MtpSafetyFactor) {
105104
return types.PerpetualFees{}, errorsmod.Wrapf(types.ErrMTPUnhealthy, "(MtpHealth: %s)", mtp.MtpHealth.String())
106105
}
107106

0 commit comments

Comments
 (0)