code.vegaprotocol.io/vega@v0.79.0/core/execution/spot/market_callbacks.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package spot
    17  
    18  import (
    19  	"context"
    20  	"time"
    21  
    22  	"code.vegaprotocol.io/vega/core/events"
    23  	"code.vegaprotocol.io/vega/core/types"
    24  	"code.vegaprotocol.io/vega/libs/num"
    25  )
    26  
    27  func (m *Market) OnMarketAMMMaxCalculationLevels(ctx context.Context, c *num.Uint) {}
    28  
    29  func (m *Market) OnAMMMinCommitmentQuantumUpdate(ctx context.Context, c *num.Uint) {}
    30  
    31  func (m *Market) OnMinimalHoldingQuantumMultipleUpdate(multiplier num.Decimal) error {
    32  	m.minHoldingQuantumMultiplier = multiplier
    33  	return nil
    34  }
    35  
    36  func (m *Market) OnMarketMinLpStakeQuantumMultipleUpdate(_ context.Context, d num.Decimal) {
    37  	m.minLPStakeQuantumMultiple = d
    38  	m.liquidity.OnMinLPStakeQuantumMultiple((d))
    39  }
    40  
    41  func (m *Market) OnMarketMinProbabilityOfTradingLPOrdersUpdate(_ context.Context, d num.Decimal) {
    42  	m.liquidity.OnMinProbabilityOfTradingLPOrdersUpdate(d)
    43  }
    44  
    45  func (m *Market) OnMarketProbabilityOfTradingTauScalingUpdate(_ context.Context, d num.Decimal) {
    46  	m.liquidity.OnProbabilityOfTradingTauScalingUpdate(d)
    47  }
    48  
    49  func (m *Market) OnFeeFactorsTreasuryFeeUpdate(ctx context.Context, d num.Decimal) {
    50  	m.fee.OnFeeFactorsTreasuryFeeUpdate(d)
    51  	m.mkt.Fees.Factors.TreasuryFee = d
    52  	m.broker.Send(events.NewMarketUpdatedEvent(ctx, *m.mkt))
    53  }
    54  
    55  func (m *Market) OnFeeFactorsBuyBackFeeUpdate(ctx context.Context, d num.Decimal) {
    56  	m.fee.OnFeeFactorsBuyBackFeeUpdate(d)
    57  	m.mkt.Fees.Factors.BuyBackFee = d
    58  	m.broker.Send(events.NewMarketUpdatedEvent(ctx, *m.mkt))
    59  }
    60  
    61  func (m *Market) OnFeeFactorsMakerFeeUpdate(ctx context.Context, d num.Decimal) {
    62  	m.fee.OnFeeFactorsMakerFeeUpdate(d)
    63  	m.mkt.Fees.Factors.MakerFee = d
    64  	m.broker.Send(events.NewMarketUpdatedEvent(ctx, *m.mkt))
    65  }
    66  
    67  func (m *Market) OnFeeFactorsInfrastructureFeeUpdate(ctx context.Context, d num.Decimal) {
    68  	m.fee.OnFeeFactorsInfrastructureFeeUpdate(d)
    69  	m.mkt.Fees.Factors.InfrastructureFee = d
    70  	m.broker.Send(events.NewMarketUpdatedEvent(ctx, *m.mkt))
    71  }
    72  
    73  func (m *Market) OnMarketValueWindowLengthUpdate(d time.Duration) {
    74  	m.marketValueWindowLength = d
    75  }
    76  
    77  func (m *Market) OnMarketTargetStakeTimeWindowUpdate(d time.Duration) {
    78  	m.tsCalc.UpdateTimeWindow(d)
    79  }
    80  
    81  func (m *Market) OnMarketTargetStakeScalingFactorUpdate(d num.Decimal) error {
    82  	return m.tsCalc.UpdateScalingFactor(d)
    83  }
    84  
    85  func (m *Market) OnMarketAuctionMinimumDurationUpdate(ctx context.Context, d time.Duration) {
    86  	m.minDuration = d
    87  	m.pMonitor.SetMinDuration(d)
    88  	evt := m.as.UpdateMinDuration(ctx, d)
    89  	// we were in an auction, and the duration of the auction was updated
    90  	if evt != nil {
    91  		m.broker.Send(evt)
    92  	}
    93  }
    94  
    95  func (m *Market) OnMarketAuctionMaximumDurationUpdate(ctx context.Context, d time.Duration) {
    96  	if m.mkt.State == types.MarketStatePending || m.mkt.State == types.MarketStateProposed {
    97  		m.as.UpdateMaxDuration(ctx, d)
    98  	}
    99  }
   100  
   101  func (m *Market) OnMarkPriceUpdateMaximumFrequency(ctx context.Context, d time.Duration) {
   102  	if !m.nextMTM.IsZero() {
   103  		m.nextMTM = m.nextMTM.Add(-m.mtmDelta)
   104  	}
   105  	m.nextMTM = m.nextMTM.Add(d)
   106  	m.mtmDelta = d
   107  }
   108  
   109  func (m *Market) OnMarketPartiesMaximumStopOrdersUpdate(ctx context.Context, u *num.Uint) {
   110  	m.maxStopOrdersPerParties = u.Clone()
   111  }
   112  
   113  func (m *Market) OnMarketLiquidityV2EarlyExitPenaltyUpdate(d num.Decimal) {
   114  	m.liquidity.OnEarlyExitPenalty(d)
   115  }
   116  
   117  func (m *Market) OnMarketLiquidityV2MaximumLiquidityFeeFactorLevelUpdate(d num.Decimal) {
   118  	m.liquidity.OnMaximumLiquidityFeeFactorLevelUpdate(d)
   119  }
   120  
   121  func (m *Market) OnMarketLiquidityV2SLANonPerformanceBondPenaltySlopeUpdate(d num.Decimal) {
   122  	m.liquidity.OnNonPerformanceBondPenaltySlopeUpdate(d)
   123  }
   124  
   125  func (m *Market) OnMarketLiquidityV2SLANonPerformanceBondPenaltyMaxUpdate(d num.Decimal) {
   126  	m.liquidity.OnNonPerformanceBondPenaltyMaxUpdate(d)
   127  }
   128  
   129  func (m *Market) OnMarketLiquidityV2StakeToCCYVolume(d num.Decimal) {
   130  	m.liquidity.OnStakeToCcyVolumeUpdate(d)
   131  }
   132  
   133  func (m *Market) OnMarketLiquidityV2ProvidersFeeCalculationTimeStep(d time.Duration) {
   134  	m.liquidity.OnProvidersFeeCalculationTimeStep(d)
   135  }
   136  
   137  func (m *Market) OnMarketLiquidityV2BondPenaltyFactorUpdate(d num.Decimal) {
   138  	m.liquidity.OnBondPenaltyFactorUpdate(d)
   139  }
   140  
   141  func (m *Market) OnMarketLiquidityEquityLikeShareFeeFractionUpdate(d num.Decimal) {
   142  	m.liquidity.SetELSFeeFraction(d)
   143  }