@@ -250,6 +250,33 @@ func TestAMMSmallBounds(t *testing.T) {
250
250
assert .Equal (t , 0 , int (mds .service .GetVolumeAtPrice (marketID , types .SideSell , 2002 )))
251
251
}
252
252
253
+ func TestEstimatedStepOverAMMBound (t * testing.T ) {
254
+ ctx := context .Background ()
255
+ mds := getServiceWithConfig (t ,
256
+ service.MarketDepthConfig {
257
+ AmmFullExpansionPercentage : 5 ,
258
+ AmmEstimatedStepPercentage : 7.6 , // make this a werid number so our estimated steps are not nice multiplies of 10
259
+ AmmMaxEstimatedSteps : 5 ,
260
+ },
261
+ )
262
+ defer mds .ctrl .Finish ()
263
+
264
+ marketID := vgcrypto .RandomHash ()
265
+ ensureLiveOrders (t , mds , marketID )
266
+ ensureDecimalPlaces (t , mds )
267
+ mds .pos .EXPECT ().GetByMarketAndParty (gomock .Any (), gomock .Any (), gomock .Any ()).Return (entities.Position {OpenVolume : 0 }, nil )
268
+ mds .marketData .EXPECT ().GetMarketDataByID (gomock .Any (), gomock .Any ()).Times (1 ).Return (entities.MarketData {MidPrice : num .DecimalFromInt64 (2000 )}, nil )
269
+
270
+ // data node is starting from network history, initialise market-depth based on whats aleady there
271
+ ensureAMMs (t , mds , marketID )
272
+ mds .service .Initialise (ctx )
273
+
274
+ assert .Equal (t , "1999" , mds .service .GetBestBidPrice (marketID ).String ())
275
+ assert .Equal (t , "2001" , mds .service .GetBestAskPrice (marketID ).String ())
276
+ assert .Equal (t , 3 , int (mds .service .GetVolumeAtPrice (marketID , types .SideBuy , 1999 )))
277
+ assert .Equal (t , 3 , int (mds .service .GetVolumeAtPrice (marketID , types .SideSell , 2001 )))
278
+ }
279
+
253
280
func ensureLiveOrders (t * testing.T , mds * MDS , marketID string ) {
254
281
t .Helper ()
255
282
mds .orders .EXPECT ().GetLiveOrders (gomock .Any ()).Return ([]entities.Order {
0 commit comments