It's very difficult to determine the execution path of the instantTrade function in the exchange contract, it seems to be responsible for the following functionality:
Buy ether
Sell ether
Buy Corion Tokens
Sell Corion Tokens
while( left > 0 ) in this function seems to be unnecessary, none of the trading code should require a while loop. Even in the case of instantly trading against the order book (ie. a "market order") the instantTradeScanOrders should be able to provide an array of orders that can be used to fill the order.
Another potential risk with while(left >0) is that the contract can enter an infinite loop and run out of gas if trying to instantly trade an order that does not have a large enough order/trade book to fill it.
Lastly the complexity of this statement is very high and it's very difficult to determine what it will do (break or not) in any given case if ( stop || ( jumpTo == 0 || ( _rateLimit > 0 && ( ( _sell && jumpTo > _rateLimit) || ( ! _sell && jumpTo < _rateLimit) ) ) ) ) { break; }
We need a complex function for everything, because we dont have so much "space" while deploy.
Exchange is under development, but thank you for reporting!
It's very difficult to determine the execution path of the
instantTrade
function in theexchange
contract, it seems to be responsible for the following functionality:while( left > 0 )
in this function seems to be unnecessary, none of the trading code should require a while loop. Even in the case of instantly trading against the order book (ie. a "market order") theinstantTradeScanOrders
should be able to provide an array of orders that can be used to fill the order.Another potential risk with
while(left >0)
is that the contract can enter an infinite loop and run out of gas if trying to instantly trade an order that does not have a large enough order/trade book to fill it.Lastly the complexity of this statement is very high and it's very difficult to determine what it will do (break or not) in any given case
if ( stop || ( jumpTo == 0 || ( _rateLimit > 0 && ( ( _sell && jumpTo > _rateLimit) || ( ! _sell && jumpTo < _rateLimit) ) ) ) ) { break; }