Closed dorothy-zbornak closed 4 years ago
@amaurer I think you had some concerns over the removal of marketBuy/SellOrders()
in your usage. Do these new functions meet your needs?
@amaurer I think you had some concerns over the removal of
marketBuy/SellOrders()
in your usage. Do these new functions meet your needs?
I have no issue with removing the generalized market buy/sell functions after reading the proposal. I think it's ideal to have explicit names. We're using the fillOrKillOrder and batchFillOrKillOrders functions. Thanks for checking!
MarketBuy/SellOrdersFillOrKill
Summary
Remove the old
marketBuyOrders()
andmarketSellOrders()
Exchange functions in3.0
in favor of justmarketBuyOrdersNoThrow()
andmarketSellOrdersNoThrow()
. AddmarketBuyOrdersFillOrKill()
andmarketSellOrdersFillOrKill()
which wrap these functions.Motivation
Our reasoning for this decision was that the typical user performing a market buy or sell would likely not care if any individual order in the operation fails.
One feature of
marketBuy/SellOrdersNoThrow()
is that it will not fail even if it buys or sells less than the amount of taker or maker asset requested. Thus, it’s useful when you’re simply trying to purchase or liquidate as much of an asset as possible. However, there are cases when more deterministic behavior is desirable, i.e., where it must fill no less than the amount requested or revert. This is the motivation for introducingmarketSellOrdersFillOrKill()
andmarketBuyOrdersFillOrKill()
.Specification
The behavior of these new functions would be nearly identical to
marketBuyOrdersNoThrow()
andmarketSellOrdersNoThrow()
but with a final check that the combined fill results indicate that the correct amount of assets were sold or bought:marketBuyOrdersNoThrow()
:fillResults.makerAssetFilledAmount >= makerAssetFillAmount
marketSellOrdersNoThrow()
:fillResults.takerAssetFilledAmount >= takerAssetFillAmount
Implementation
The pseudocode for
marketSellOrdersFillOrKill()
would look like:The pseudocode for
marketBuyOrdersFillOrKill()
would look like:Notes/Challenges
In production, we would likely just wrap the existing
marketBuyOrdersNoThrow()
andmarketSellOrdersNoThrow()
then perform the fill check before returning.If you preferred the original versions because they asserted that all orders were valid, you can still detect invalid orders (as an EOA) by examining the
Fill
event logs. If an order hash does not appear in the logs, it was either unfillable or you hit your target without needing to fill that order.