OasisDEX / oasis

Oasis - Decentralized Token Market
http://oasisdex.com/
Apache License 2.0
170 stars 56 forks source link

New order type with price determined by (a function of) an external feed #318

Open livnev opened 7 years ago

livnev commented 7 years ago

Create a new order type, whose price will be determined by (some function of) an external price feed

The idea is that a user may either supply their own price feed for this, allowing for the price of an order to be changed (possibly) cheaper and faster, or the user can choose to piggyback on (and trust) someone else's feed (or medianizer, etc.), in which case they could potentially avoid spending any gas at all in updating the price.

For simplicity, we could restrict to functions of the form λx. x + spread, which may cover the majority of use cases for this.

To protect the order taker, to take such an order, the taker passes in the "expected" value of the function, to make sure that the taker has consented to the order price. If the "expectation" argument and the function, feed don't match, then the take fails. This prevents surprises, including a malicious bait-and-switch.

As @dbrock suggested, the order could just use the value resulting from calling an arbitrary maker-specified contract, presumably meaning that the maker would have to deploy such a contract to go with the order (could be helped in UI). Thus we would abstract away the "arbitrary function" part. Or, to keep things simple, just restrict to affine functions of the form λx. x + spread, which may cover the majority of use cases for this.

livnev commented 7 years ago

While manageable on the non-order matching version of Oasis, this is probably not feasible for the Oasis with on-chain order matching. :|

bamos01 commented 7 years ago

Definitely support this- when you are trading a stablecoin that is related to a fiat value - orders need to be tied to pricefeeds if you want people to leave large orders on the books. Its too risky to make a large order unless you have a bot or can monitor directly, which isn't really realistic. Bots also would require high gas costs

jpritikin commented 7 years ago

I don't see how to implement this with a new ordertype, but what if the whole orderbook was represented as the current price plus or minus some spread?

bamos01 commented 7 years ago

Yes - that would be great

On Sun, Aug 6, 2017 at 5:42 AM, Joshua Pritikin notifications@github.com wrote:

I don't see how to implement this with a new ordertype, but what if the whole orderbook was represented as the current price plus or minus some spread?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/OasisDEX/oasis","title":"OasisDEX/oasis","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/OasisDEX/oasis"}},"updates":{"snippets":[{"icon":"PERSON","message":"@jpritikin in #318: I don't see how to implement this with a new ordertype, but what if the whole orderbook was represented as the current price plus or minus some spread?"}],"action":{"name":"View Issue","url":"https://github.com/OasisDEX/oasis/issues/318#issuecomment-320496400"}}}

peculiarity commented 6 years ago

@pimato

livnev commented 6 years ago

@peculiarity with order matching, this idea can't really work.

peculiarity commented 6 years ago

@livnev I guess we can implement it in the oasis-direct though