Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 268 lines (219 sloc) 8.51 KB
# This software (Augur) allows buying && selling event outcomes in ethereum
# Copyright (C) 2015 Forecast Foundation OU
# This program is free software; you can redistribute it &&/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is free software: you can redistribute it &&/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Any questions please contact joey@augur.net
inset('refund.se')
# Keeps track of data about events in augur
# Events' index is the eventID
# so max-min/numOutcomes is interval between outcomes (useful for ui for categoricals, e.g. 1 is >50, 2 is >100, etc.)
# markets keeps track of the markets associated with an event
# threshold is the min "random" sha threshold for reporting on an event used in the scenario where no one reports on an event
# mode is the mode reported value for a given event [only on categorical / scalar events]
# uncaughtOutcome is the average reported value for a binary event
# ethical is the ethicality for a given event
# originalExp is original expiry date in the case an event was pushed back and the expiration date gets changed - both are in epoch time
# pushedUp states that an event was pushed forward to attempt early resolution
# rejected states that a pushed forward market's event [so one that attempted to resolve before it was expired] got rejected and shouldn't have actually been pushed forward
# rejectedPeriod is the period such an event was pushed forward to and failed to be resolved in
# bond is the indeterminate bond that's taken away if an event is reported on as indeterminate
# forked is whether an event was the event a branch was forked over
# forkOver is whether the event that was forked over is resolved
# forkOutcome is the outcome of an event that was forked over
# forkEthicality is the ethicality of an event that was forked over
# resolutionSource is a string with the recommended source for resolving a market
data Events[](branch, expirationDate, outcome, minValue, maxValue, numOutcomes, markets[], numMarkets, threshold, mode, uncaughtOutcome, ethical, originalExp, rejected, rejectedPeriod, bond, forked, forkOver, forkOutcome, forkEthicality, resolutionSource[], resolutionSourceLength, pushedUp)
# Keeps track of number of events created in the past 24 hours
data past24Hours[]
def getEventPushedUp(event):
return(self.Events[event].pushedUp)
def setEventPushedUp(event, val):
self.Events[event].pushedUp = val
return(1)
def getForkOutcome(event):
return(self.Events[event].forkOutcome)
def setForkOutcome(event, value):
self.Events[event].forkOutcome = value
return(1)
def getForkEthicality(event):
return(self.Events[event].forkEthicality)
def setForkEthicality(event, value):
self.Events[event].forkEthicality = value
return(1)
def getForked(event):
return(self.Events[event].forked)
def setForked(event):
self.Events[event].forked = 1
return(1)
def setForkDone(event):
self.Events[event].forkOver = 1
return(1)
def getForkedDone(event):
return(self.Events[event].forkOver)
def getEventInfo(event):
refund()
eventinfo = array(7)
eventinfo[0] = self.Events[event].branch
eventinfo[1] = self.Events[event].expirationDate
eventinfo[2] = self.Events[event].outcome
eventinfo[3] = self.Events[event].minValue
eventinfo[4] = self.Events[event].maxValue
eventinfo[5] = self.Events[event].numOutcomes
eventinfo[6] = self.Events[event].bond
return(eventinfo: arr)
def getResolutionLength(event):
return(self.Events[event].resolutionSourceLength)
def getResolution(event):
refund()
length=self.Events[event].resolutionSourceLength
return(load(self.Events[event].resolutionSource[0], chars=length): str)
def getPast24(period):
refund()
return(self.past24Hours[period])
def addPast24(period):
refund()
self.past24Hours[period] += 1
return(1)
def getEventBranch(event):
refund()
return(self.Events[event].branch)
def getExpiration(event):
refund()
return(self.Events[event].expirationDate)
def getOriginalExpiration(event):
refund()
return(self.Events[event].originalExp)
def setOriginalExpiration(event, date):
self.Events[event].originalExp = date
return(1)
def setExpiration(event, date):
refund()
self.Events[event].expirationDate = date
return(1)
def setBranch(event, branch):
self.Events[event].branch = branch
return(1)
def getOutcome(event):
refund()
# do whitelist, if oracle system branch, always return outcome, if in whitelist it's good
return(self.Events[event].outcome)
def getEthics(event):
refund()
return(self.Events[event].ethical)
def setEthics(event, ethicality):
refund()
self.Events[event].ethical = ethicality
return(ethicality)
def getEthical(event):
refund()
return(self.Events[event].ethical)
def getMinValue(event):
refund()
return(self.Events[event].minValue)
def getMaxValue(event):
refund()
return(self.Events[event].maxValue)
def getNumOutcomes(event):
refund()
return(self.Events[event].numOutcomes)
def setUncaughtOutcome(event, outcome):
refund()
self.Events[event].uncaughtOutcome = outcome
return(1)
def getUncaughtOutcome(event):
refund()
# do whitelist, if oracle system branch, always return outcome, if in whitelist it's good
return(self.Events[event].uncaughtOutcome)
def initializeEvent(ID, branch, expirationDate, minValue, maxValue, numOutcomes, resolution: str):
refund()
# check that msg.sender is one of our function contracts
#if(!self.whitelist.check(msg.sender)):
# return(-1)
if(self.Events[ID].expirationDate==0):
self.Events[ID].branch = branch
self.Events[ID].expirationDate = expirationDate
self.Events[ID].originalExp = expirationDate
self.Events[ID].minValue = minValue
self.Events[ID].maxValue = maxValue
self.Events[ID].numOutcomes = numOutcomes
resolutionSourceLength = len(resolution)
self.Events[ID].resolutionSourceLength = resolutionSourceLength
save(self.Events[ID].resolutionSource[0], resolution, chars=resolutionSourceLength)
return(1)
else:
return(0)
def setBond(event, bond):
refund()
self.Events[event].bond = bond
return(1)
def addMarket(event, marketID):
refund()
self.Events[event].markets[self.Events[event].numMarkets] = marketID
self.Events[event].numMarkets += 1
return(1)
def getBranch(event):
return(self.Events[event].branch)
def getBond(event):
refund()
return(self.Events[event].bond)
def getMarkets(event):
refund()
i = 0
markets = array(self.Events[event].numMarkets)
while i < self.Events[event].numMarkets:
markets[i] = self.Events[event].markets[i]
i += 1
return(markets: arr)
def getMarket(event, marketIndex):
refund()
return(self.Events[event].markets[marketIndex])
def getNumMarkets(event):
refund()
return(self.Events[event].numMarkets)
def setOutcome(ID, outcome):
refund()
#if(!self.whitelist.check(msg.sender)):
# return(-1)
self.Events[ID].outcome = outcome
return(1)
def getReportingThreshold(event):
refund()
return(self.Events[event].threshold)
def setThreshold(event, threshold):
# do whitelist
self.Events[event].threshold = threshold
return(1)
def getmode(event):
refund()
# do whitelist, if oracle system branch, always return outcome, if in whitelist it's good
return(self.Events[event].mode)
def setmode(event, mode):
refund()
self.Events[event].mode = mode
return(1)
def setRejected(event, period):
refund()
self.Events[event].rejected = 1
self.Events[event].rejectedPeriod = period
return(1)
def getRejected(event):
refund()
return(self.Events[event].rejected)
def getRejectedPeriod(event):
refund()
return(self.Events[event].rejectedPeriod)