Skip to content

Commit

Permalink
chore: review fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Van Ootegem <[email protected]>
  • Loading branch information
EVODelavega committed Apr 18, 2024
1 parent 279afcc commit cf3a644
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions core/execution/liquidation/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,19 @@ func (e *Engine) Update(cfg *types.LiquidationStrategy) {
}

func (e *Engine) OnTick(ctx context.Context, now time.Time, midPrice *num.Uint) (*types.Order, error) {
if e.pos.open == 0 || e.as.InAuction() || e.nextStep.After(now) {
if e.pos.open == 0 || e.as.InAuction() || e.nextStep.After(now) || midPrice.IsZero() {
return nil, nil
}

one := num.DecimalOne()
// get the min/max price from the range based on slippage parameter
mpDec := num.DecimalFromUint(midPrice)
minP := num.UintZero()
if e.cfg.DisposalSlippage.LessThan(num.DecimalZero()) {
minD := mpDec.Mul(num.DecimalZero().Sub(e.cfg.DisposalSlippage))
if e.cfg.DisposalSlippage.LessThan(one) {
minD := mpDec.Mul(one.Sub(e.cfg.DisposalSlippage))
minP, _ = num.UintFromDecimal(minD)
}
maxD := mpDec.Mul(num.DecimalZero().Add(e.cfg.DisposalSlippage))
maxD := mpDec.Mul(one.Add(e.cfg.DisposalSlippage))
maxP, _ := num.UintFromDecimal(maxD)

minB, maxB := e.pmon.GetValidPriceRange()
Expand Down
2 changes: 1 addition & 1 deletion protos/sources/vega/markets.proto
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ message LiquidationStrategy {
// Max fraction of the total volume of the orderbook, within liquidity bounds, that the network can use to close its position; range 0 through 1.
string max_fraction_consumed = 4;
// Decimal > 0 defining the price range within which the network will trade to dispose of its position. Retroactively defaults to 0.1 (10%).
// The value can be > 1, if set to 1.5, the minimum price will be 0 (min(0, mid_price * (1 - 1.))), the maximum price will be mid_price * (1 + 1.5).
// The value can be > 1, if set to 1.5, the minimum price will be 0 (max(0, mid_price * (1 - 1.5))), the maximum price will be mid_price * (1 + 1.5).
string disposal_slippage_range = 5;
}

Expand Down
2 changes: 1 addition & 1 deletion protos/vega/markets.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cf3a644

Please sign in to comment.