code.vegaprotocol.io/vega@v0.79.0/core/execution/future/liquidity_provision.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 future 17 18 import ( 19 "context" 20 "errors" 21 22 "code.vegaprotocol.io/vega/core/types" 23 ) 24 25 var ErrCommitmentAmountTooLow = errors.New("commitment amount is too low") 26 27 // SubmitLiquidityProvision forwards a LiquidityProvisionSubmission to the Liquidity Engine. 28 func (m *Market) SubmitLiquidityProvision( 29 ctx context.Context, 30 sub *types.LiquidityProvisionSubmission, 31 party, deterministicID string, 32 ) error { 33 defer m.onTxProcessed() 34 35 // add the party to the list of all parties involved with 36 // this market 37 if m.addParty(party) { 38 // First time seeing the party, we report his margin mode. 39 m.emitPartyMarginModeUpdated(ctx, party, m.getMarginMode(party), m.getMarginFactor(party)) 40 } 41 42 _, err := m.collateral.CreatePartyMarginAccount(ctx, party, m.GetID(), m.settlementAsset) 43 if err != nil { 44 return err 45 } 46 47 return m.liquidity.SubmitLiquidityProvision(ctx, sub, party, deterministicID, m.GetMarketState()) 48 } 49 50 // AmendLiquidityProvision forwards a LiquidityProvisionAmendment to the Liquidity Engine. 51 func (m *Market) AmendLiquidityProvision(ctx context.Context, lpa *types.LiquidityProvisionAmendment, party string, deterministicID string) (err error) { 52 defer m.onTxProcessed() 53 54 return m.liquidity.AmendLiquidityProvision(ctx, lpa, party, deterministicID, m.GetMarketState()) 55 } 56 57 // CancelLiquidityProvision forwards a LiquidityProvisionCancel to the Liquidity Engine. 58 func (m *Market) CancelLiquidityProvision(ctx context.Context, cancel *types.LiquidityProvisionCancellation, party string) (err error) { 59 defer m.onTxProcessed() 60 61 return m.liquidity.CancelLiquidityProvision(ctx, party) 62 }