@@ -1001,18 +1001,18 @@ func (fes *APIServer) GetQuoteCurrencyPriceInUsd(
10011001}
10021002
10031003func (fes * APIServer ) GetHighestBidAndLowestAskPriceFromPKIDs (
1004- coin1PKID * lib.PKID ,
1005- coin2PKID * lib.PKID ,
1004+ basePkid * lib.PKID ,
1005+ quotePkid * lib.PKID ,
10061006 utxoView * lib.UtxoView ,
10071007 initialHighestBidPrice float64 ,
10081008) (float64 , float64 , float64 , error ) {
10091009 ordersBuyingCoin1 , err := utxoView .GetAllDAOCoinLimitOrdersForThisDAOCoinPair (
1010- coin1PKID , coin2PKID )
1010+ basePkid , quotePkid )
10111011 if err != nil {
10121012 return 0 , 0 , 0 , fmt .Errorf ("GetDAOCoinLimitOrders: Error getting limit orders: %v" , err )
10131013 }
10141014 ordersBuyingCoin2 , err := utxoView .GetAllDAOCoinLimitOrdersForThisDAOCoinPair (
1015- coin2PKID , coin1PKID )
1015+ quotePkid , basePkid )
10161016 if err != nil {
10171017 return 0 , 0 , 0 , fmt .Errorf ("GetDAOCoinLimitOrders: Error getting limit orders: %v" , err )
10181018 }
@@ -1033,12 +1033,26 @@ func (fes *APIServer) GetHighestBidAndLowestAskPriceFromPKIDs(
10331033 if err != nil {
10341034 return 0 , 0 , 0 , fmt .Errorf ("GetQuoteCurrencyPriceInUsd: Error parsing price: %v" , err )
10351035 }
1036+
1037+ // Flip orders as needed.
1038+ appliedOperationType := order .OperationType
10361039 if order .OperationType == lib .DAOCoinLimitOrderOperationTypeBID &&
1040+ order .BuyingDAOCoinCreatorPKID .Eq (quotePkid ) {
1041+ priceFloat = 1.0 / priceFloat
1042+ appliedOperationType = lib .DAOCoinLimitOrderOperationTypeASK
1043+ }
1044+ if order .OperationType == lib .DAOCoinLimitOrderOperationTypeASK &&
1045+ order .SellingDAOCoinCreatorPKID .Eq (quotePkid ) {
1046+ priceFloat = 1.0 / priceFloat
1047+ appliedOperationType = lib .DAOCoinLimitOrderOperationTypeBID
1048+ }
1049+
1050+ if appliedOperationType == lib .DAOCoinLimitOrderOperationTypeBID &&
10371051 priceFloat > highestBidPrice {
10381052
10391053 highestBidPrice = priceFloat
10401054 }
1041- if order . OperationType == lib .DAOCoinLimitOrderOperationTypeASK &&
1055+ if appliedOperationType == lib .DAOCoinLimitOrderOperationTypeASK &&
10421056 priceFloat < lowestAskPrice {
10431057
10441058 lowestAskPrice = priceFloat
0 commit comments