4
4
"context"
5
5
"encoding/json"
6
6
"fmt"
7
+ "sort"
7
8
8
9
"github.com/CosmWasm/wasmd/x/wasm"
9
10
"github.com/gorilla/mux"
@@ -346,6 +347,12 @@ func (am AppModule) endBlockForContract(ctx sdk.Context, contract types.Contract
346
347
assetDenomStr := pair .AssetDenom
347
348
allExistingBuys := am .keeper .GetAllLongBookForPair (ctx , contractAddr , priceDenomStr , assetDenomStr )
348
349
allExistingSells := am .keeper .GetAllShortBookForPair (ctx , contractAddr , priceDenomStr , assetDenomStr )
350
+ sort .Slice (allExistingBuys , func (i , j int ) bool {
351
+ return allExistingBuys [i ].GetPrice ().LT (allExistingBuys [j ].GetPrice ())
352
+ })
353
+ sort .Slice (allExistingSells , func (i , j int ) bool {
354
+ return allExistingSells [i ].GetPrice ().LT (allExistingSells [j ].GetPrice ())
355
+ })
349
356
350
357
longDirtyPrices , shortDirtyPrices := exchange .NewDirtyPrices (), exchange .NewDirtyPrices ()
351
358
@@ -473,6 +480,7 @@ func (am AppModule) endBlockForContract(ctx sdk.Context, contract types.Contract
473
480
Id : marketOrder .Id ,
474
481
Initiator : types .CancellationInitiator_USER ,
475
482
})
483
+ am .keeper .UpdateOrderStatus (ctx , contractAddr , marketOrder .Id , types .OrderStatus_CANCELLED )
476
484
}
477
485
}
478
486
for _ , marketOrder := range marketSells {
@@ -481,6 +489,7 @@ func (am AppModule) endBlockForContract(ctx sdk.Context, contract types.Contract
481
489
Id : marketOrder .Id ,
482
490
Initiator : types .CancellationInitiator_USER ,
483
491
})
492
+ am .keeper .UpdateOrderStatus (ctx , contractAddr , marketOrder .Id , types .OrderStatus_CANCELLED )
484
493
}
485
494
}
486
495
}
0 commit comments