code.vegaprotocol.io/vega@v0.79.0/core/integration/steps/the_liquidity_sla_params.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 steps 17 18 import ( 19 "code.vegaprotocol.io/vega/core/integration/steps/market" 20 types "code.vegaprotocol.io/vega/protos/vega" 21 22 "github.com/cucumber/godog" 23 ) 24 25 func TheLiquiditySLAPArams(config *market.Config, name string, table *godog.Table) error { 26 row := slaParamRow{row: parseSLAParamsTable(table)[0]} 27 28 return config.LiquiditySLAParams.Add( 29 name, 30 &types.LiquiditySLAParameters{ 31 PriceRange: row.priceRange(), 32 CommitmentMinTimeFraction: row.commitmentMinTimeFraction(), 33 SlaCompetitionFactor: row.slaCompetitionFactor(), 34 PerformanceHysteresisEpochs: uint64(row.performanceHysteresisEpochs()), 35 }) 36 } 37 38 func parseSLAParamsTable(table *godog.Table) []RowWrapper { 39 return StrictParseTable(table, []string{ 40 "price range", 41 "commitment min time fraction", 42 "performance hysteresis epochs", 43 "sla competition factor", 44 }, []string{}) 45 } 46 47 type slaParamRow struct { 48 row RowWrapper 49 } 50 51 func (r slaParamRow) priceRange() string { 52 return r.row.MustStr("price range") 53 } 54 55 func (r slaParamRow) commitmentMinTimeFraction() string { 56 return r.row.MustStr("commitment min time fraction") 57 } 58 59 func (r slaParamRow) performanceHysteresisEpochs() int64 { 60 return r.row.MustI64("performance hysteresis epochs") 61 } 62 63 func (r slaParamRow) slaCompetitionFactor() string { 64 return r.row.MustStr("sla competition factor") 65 }