Last active
April 18, 2019 20:45
-
-
Save ryanberckmans/e32e00e153a5a1b7b310b4d7daf11e95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Augur's oracle can be used to bring information on-chain, | |
// allowing money to move automatically based on real-world facts. | |
// Augur's oracle is secure so long as money that depends on Augur | |
// is properly tracked in the Augur system. | |
// Money that depends on Augur's oracle, but isn't tracked in Augur, | |
// is said to be "parasitic" and is at risk of attack and a threat | |
// to Augur itself. | |
// Happily, any project that uses Augur's oracle can write a thin | |
// wrapper around Augur to properly track money and avoid being | |
// parasitic. | |
// Here is an example algorithm for an Ethereum smart contract | |
// showing how to wrap Augur and properly track money: | |
// (Augur's Forecast Foundation may one day provide a standardized | |
// wrapper as a platform component. If you want this please get in | |
// touch @AugurProject.) | |
function useOracle( | |
money, // money whose destination depends on Augur | |
marketId, // the Augur market question whose answer will route the money, eg. "Will the Patriots win the 2019 Super Bowl?" | |
moneyDestinationIfYes, // money transferred to this address if Patriots win the Super Bowl | |
moneyDestinationIfNo, // money transferred to this address if Patriots lose the Super Bowl | |
moneyDestinationIfInvalid) { // money transferred to this address if Augur market deemed invalid | |
const { yesShare, noShare, invalidShare } = marketId.makeCompleteSets(money) | |
// After market resolves: | |
switch(marketId resolution) { | |
case yes => send(marketId.redeem(yesShare), moneyDestinationIfYes) | |
case no => send(marketId.redeem(noShare), moneyDestinationIfNo) | |
case invalid => send(marketId.redeem(invalidShare), moneyDestinationIfInvalid) | |
} | |
} | |
// We can think of wrapper as a bit like a javascript Promise, | |
// it can route money even if the underlying Augur market | |
// resolved a long time ago. In javascript we can do | |
// `anonymousPromise.then(onSuccess, onFailure)` and in fact | |
// the Promise might already be resolved but caller doesn't have | |
// to worry about that. | |
// See the Augur whitepaper for further reading: https://www.augur.net/whitepaper.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment