code.vegaprotocol.io/vega@v0.79.0/core/integration/steps/the_liquidity_monitoring.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 TheLiquidityMonitoring(config *market.Config, table *godog.Table) error { 26 rows := parseLiquidityMonitoringTable(table) 27 for _, row := range rows { 28 r := liquidityMonitoringRow{row: row} 29 p := &types.LiquidityMonitoringParameters{ 30 TargetStakeParameters: &types.TargetStakeParameters{ 31 TimeWindow: r.timeWindow(), 32 ScalingFactor: r.scalingFactor(), 33 }, 34 } 35 if err := config.LiquidityMonitoring.Add(r.name(), p); err != nil { 36 return err 37 } 38 } 39 return nil 40 } 41 42 func parseLiquidityMonitoringTable(table *godog.Table) []RowWrapper { 43 return StrictParseTable(table, []string{ 44 "name", 45 "time window", 46 "scaling factor", 47 "triggering ratio", 48 }, []string{ 49 "auction extension", 50 }) 51 } 52 53 type liquidityMonitoringRow struct { 54 row RowWrapper 55 } 56 57 func (r liquidityMonitoringRow) name() string { 58 return r.row.MustStr("name") 59 } 60 61 func (r liquidityMonitoringRow) timeWindow() int64 { 62 tw := r.row.MustDurationStr("time window") 63 return int64(tw.Seconds()) 64 } 65 66 func (r liquidityMonitoringRow) scalingFactor() float64 { 67 return r.row.MustF64("scaling factor") 68 }