Skip to content

Instantly share code, notes, and snippets.

@tinybike
Created September 2, 2015 17:28
Show Gist options
  • Select an option

  • Save tinybike/c5c1d72bcaa4af1aff17 to your computer and use it in GitHub Desktop.

Select an option

Save tinybike/c5c1d72bcaa4af1aff17 to your computer and use it in GitHub Desktop.
compiling /home/jack/src/augur-core/src/consensus/center.se
compiling /home/jack/src/augur-core/src/consensus/resolve.se
compiling /home/jack/src/augur-core/src/consensus/payout.se
compiling /home/jack/src/augur-core/src/consensus/redeem_interpolate.se
compiling /home/jack/src/augur-core/src/consensus/redeem_payout.se
compiling /home/jack/src/augur-core/src/consensus/redeem_score.se
compiling /home/jack/src/augur-core/src/consensus/redeem_adjust.se
compiling /home/jack/src/augur-core/src/consensus/score.se
compiling /home/jack/src/augur-core/src/consensus/redeem_resolve.se
compiling /home/jack/src/augur-core/src/consensus/statistics.se
compiling /home/jack/src/augur-core/src/consensus/adjust.se
compiling /home/jack/src/augur-core/src/consensus/redeem_center.se
compiling /home/jack/src/augur-core/src/data and api/fxpFunctions.se
compiling /home/jack/src/augur-core/src/data and api/markets.se
Warning (file "main", line 41, char 8): Warning: function return type inconsistent!
Warning (file "main", line 56, char 8): Warning: function return type inconsistent!
Warning (file "main", line 41, char 8): Warning: function return type inconsistent!
Warning (file "main", line 56, char 8): Warning: function return type inconsistent!
Warning (file "main", line 41, char 8): Warning: function return type inconsistent!
Warning (file "main", line 56, char 8): Warning: function return type inconsistent!
compiling /home/jack/src/augur-core/src/data and api/cash.se
compiling /home/jack/src/augur-core/src/data and api/events.se
compiling /home/jack/src/augur-core/src/data and api/info.se
compiling /home/jack/src/augur-core/src/data and api/reporting.se
compiling /home/jack/src/augur-core/src/data and api/branches.se
compiling /home/jack/src/augur-core/src/data and api/expiringEvents.se
compiling /home/jack/src/augur-core/src/functions/faucets.se
Error (file "main", line 34, char 34): Invalid call: setCash
Traceback (most recent call last):
File "/home/jack/src/augur-core/load_contracts.py", line 483, in compile
evm = '0x' + serpent.compile(code).encode('hex')
File "build/bdist.linux-x86_64/egg/serpent.py", line 78, in <lambda>
compile = lambda x: pyext.compile(strtobytes(x))
Exception: Error (file "main", line 34, char 34): Invalid call: setCash
Code that broke everything:
# This software (Augur) allows buying and selling event options in Ethereum.
#
# Copyright (c) 2015 Forecast Foundation
#
# This program is free software; you can redistribute it and/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 and/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/>.
#
# If you have questions, please contact [email protected] or [email protected].
extern cash: [addCash:[int256,int256]:int256, balance:[int256]:int256, faucet:[]:int256, send:[int256,int256]:int256, sendFrom:[int256,int256,int256]:int256, subtractCash:[int256,int256]:int256]
CASH = 0x09dfcb6be0b8927518ab930e93518044c71c5a4f
extern reporting: [addRep:[int256,int256,int256]:int256, addReporter:[int256,int256]:int256, faucet:[int256]:int256, getNumberReporters:[int256]:int256, getRepBalance:[int256,int256]:int256, getRepByIndex:[int256,int256]:int256, getReporterID:[int256,int256]:int256, getReputation:[int256]:int256[], getTotalRep:[int256]:int256, hashReport:[int256[],int256]:int256, repIDToIndex:[int256,int256]:int256, setInitialReporters:[int256,int256]:int256, setRep:[int256,int256,int256]:int256, subtractRep:[int256,int256,int256]:int256]
REPORTING = 0x08606bc6f0aa9c41bed0ea1747dd567739751102
# Error -1: Hey, you're not broke!
def cashFaucet():
if CASH.balance(tx.origin) > fix(5):
return(-1)
CASH.setCash(tx.origin, fix(10000))
return(1)
def reputationFaucet(branch):
if REPORTING.repIDToIndex(branch, tx.origin) != 0 or REPORTING.getReporterID(branch, 0) == tx.origin:
index = REPORTING.repIDToIndex(branch, tx.origin)
else:
index = REPORTING.getNumberReporters(branch)
REPORTING.addReporter(branch, tx.origin)
REPORTING.setRep(branch, index, fix(47))
return(1)
inset("../../macros/fixed.sm")
DB dump:
{
"adjust": {
"address": "0x5069d883e31429c6dd1325d961f443007747c7a2",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Jack Peterson ([email protected]).",
"",
"# Minimum value of array",
"macro minimum($a):",
" with $min = $a[0]:",
" with $i = 1:",
" with $len = len($a):",
" while $i < $len:",
" if $a[$i] < $min:",
" $min = $a[$i]",
" $i += 1",
" $min",
"",
"def reputation_delta(scores:arr, num_reports, num_events):",
" # Which of the two possible 'new' reputation vectors had more in common",
" # with the original 'old' reputation?",
" # set1: [0, num_reports - 1]",
" # set2: [num_reports, 2*num_reports - 1]",
" with two_num_reports = 2*num_reports:",
" with sets = array(two_num_reports):",
" with set1_compare = abs(minimum(scores)):",
" with set2_compare = maximum(scores):",
" with i = 0:",
" while i < num_reports:",
" sets[i] = scores[i] + set1_compare",
" i += 1",
" while i < two_num_reports:",
" sets[i] = scores[i - num_reports] - set2_compare",
" i += 1",
" return(sets: arr)",
"",
"def weighted_delta(set1:arr, set2:arr, reputation:arr, reports:arr, num_reports, num_events):",
" with i = 0:",
" while i < num_reports:",
" reputation[i] = fixed_divide(reputation[i], TOTAL_REPUTATION)",
" i += 1",
" with three_num_events = 3*num_events:",
" with wsets = array(three_num_events):",
" with wset1 = normalize(set1):",
" with wset2 = normalize(set2):",
" with i = 0:",
" with two_num_events = 2*num_events:",
" while i < num_events:",
" with k = 0:",
" while k < num_reports:",
" with pos = k*num_events + i:",
" wsets[i] += fixed_multiply(reputation[k], reports[pos])",
" wsets[i + num_events] += fixed_multiply(wset1[k], reports[pos])",
" wsets[i + two_num_events] += fixed_multiply(wset2[k], reports[pos])",
" k += 1",
" i += 1",
" return(wsets: arr)",
"",
"def select_scores(old:arr, new1:arr, new2:arr, set1:arr, set2:arr, scores:arr, num_reports, num_events):",
" # Difference in sum of squared errors. If > 0, then new1 had higher",
" # errors (use new2); conversely if < 0, then use new1.",
" with sse1 = 0:",
" with sse2 = 0:",
" with i = 0:",
" while i < num_events:",
" sse1 += fixed_multiply(new1[i] - old[i], new1[i] - old[i])",
" sse2 += fixed_multiply(new2[i] - old[i], new2[i] - old[i])",
" i += 1",
" with ref_ind = sse1 - sse2:",
" with adjusted_scores = array(num_reports):",
" if ref_ind <= 0:",
" adjusted_scores = set1",
" else:",
" adjusted_scores = set2",
" return(adjusted_scores: arr)",
"",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')",
"inset('../../macros/arrays.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "scores",
"type": "int256[]"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "reputation_delta(int256[],int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "old",
"type": "int256[]"
},
{
"name": "new1",
"type": "int256[]"
},
{
"name": "new2",
"type": "int256[]"
},
{
"name": "set1",
"type": "int256[]"
},
{
"name": "set2",
"type": "int256[]"
},
{
"name": "scores",
"type": "int256[]"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "select_scores(int256[],int256[],int256[],int256[],int256[],int256[],int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "set1",
"type": "int256[]"
},
{
"name": "set2",
"type": "int256[]"
},
{
"name": "reputation",
"type": "int256[]"
},
{
"name": "reports",
"type": "int256[]"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "weighted_delta(int256[],int256[],int256[],int256[],int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
}
],
"sig": "extern adjust: [reputation_delta:[int256[],int256,int256]:int256[], select_scores:[int256[],int256[],int256[],int256[],int256[],int256[],int256,int256]:int256[], weighted_delta:[int256[],int256[],int256[],int256[],int256,int256]:int256[]]"
},
"branches": {
"address": "0x60cb05deb51f92ee25ce99f67181ecaeb0b743ea",
"code": [
"# This software (Augur) allows buying && selling event outcomes in ethereum",
"# Copyright (C) 2015 Forecast Foundation",
"# 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 [email protected]",
"",
"# CurrentVotePeriod is the current index in eventsExpDates",
"# Branches' index is the hash of the branch (aka branchID)",
"# currentVotePeriod is a nonce that tells us which bucket of events up to be",
"# voted on in the current vote period (should always be 1 behind block.number/periodlength or current EventsExpDates index)",
"# period parameter for reporting",
"# currentExpPeriod = (block.number / self.Branches[branch].periodLength)",
"# currentExpPeriod - 1 is what's up for reporting at any given time",
"extern reporting: [addRep:[int256,int256,int256]:int256, addReporter:[int256,int256]:int256, faucet:[int256]:int256, getNumberReporters:[int256]:int256, getRepBalance:[int256,int256]:int256, getRepByIndex:[int256,int256]:int256, getReporterID:[int256,int256]:int256, getReputation:[int256]:int256[], getTotalRep:[int256]:int256, hashReport:[int256[],int256]:int256, repIDToIndex:[int256,int256]:int256, setInitialReporters:[int256,int256]:int256, setRep:[int256,int256,int256]:int256, subtractRep:[int256,int256,int256]:int256]",
"REP = 0x08606bc6f0aa9c41bed0ea1747dd567739751102",
"",
"data Branches[](currentVotePeriod, periodLength, step, substep, markets[], numMarkets, minTradingFee)",
"",
"data branchList[]",
"",
"data branchListCount",
"",
"def init():",
" self.Branches[1010101].currentVotePeriod = (block.number / 1800) - 1",
" self.Branches[1010101].periodLength = 1800",
" self.Branches[1010101].minTradingFee = 2^57",
" self.branchListCount = 1",
" self.branchList[0] = 1010101",
"",
"def getVotePeriod(branch):",
"\treturn(self.Branches[branch].currentVotePeriod)",
"",
"def getPeriodLength(branch):",
"\treturn(self.Branches[branch].periodLength)",
"",
"def getStep(branch):",
"\treturn(self.Branches[branch].step)",
"",
"# @return all markets in a branch",
"def getMarkets(branch):",
" numMarkets = self.Branches[branch].numMarkets",
" markets = array(numMarkets)",
" i = 0",
" while i < numMarkets:",
" markets[i] = self.Branches[branch].markets[i]",
" i += 1",
" return(markets: arr)",
"",
"def getNumMarkets(branch):",
"\treturn(self.Branches[branch].numMarkets)",
"",
"def getMinTradingFee(branch):",
"\treturn(self.Branches[branch].minTradingFee)",
"",
"# @return all branches",
"def getBranches():",
" b = 0",
" numBranches = self.branchListCount",
" branches = array(numBranches)",
" while b < numBranches:",
" branches[b] = self.branchList[b]",
" b += 1",
" return(branches: arr)",
"",
"def getNumBranches():",
"\treturn(self.branchListCount)",
"",
"def getBranch(branchNumber):",
"\treturn(self.branchList[branchNumber])",
"",
"# will return 0s for array values after it's looped through all the ones you",
"# have an actual balance in",
"def getReputation(address):",
" branchListCount = self.branchListCount",
" if(address):",
" branches = array(2*branchListCount)",
" branchList = array(branchListCount)",
" branchList = self.getBranches(outitems=branchListCount)",
" i = 0",
" b = 0",
" while i < branchListCount:",
" branch = branchList[i]",
" balance = REP.getRepBalance(branch, address)",
" if(balance!=0):",
" branches[b] = branch",
" branches[b+1] = balance",
" b += 2",
" i += 1",
" else:",
" address = tx.origin",
" branches = array(2*branchListCount)",
" branchList = array(branchListCount)",
" branchList = self.getBranches(outitems=branchListCount)",
" i = 0",
" b = 0",
" while i < branchListCount:",
" branch = branchList[i]",
" balance = REP.getRepBalance(branch, address)",
" if(balance!=0):",
" branches[b] = branch",
" branches[b+1] = balance",
" b += 2",
" i += 1",
" return(branches: arr)",
"",
"",
"# check that msg.sender is one of our function contracts",
"def initializeBranch(ID, currentVotePeriod, periodLength, minTradingFee):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tif(self.Branches[ID].periodLength==0):",
"\t\tself.Branches[ID].currentVotePeriod = currentVotePeriod",
"\t\tself.Branches[ID].periodLength = periodLength",
"\t\tself.Branches[ID].minTradingFee = minTradingFee",
"\t\tself.branchList[self.branchListCount] = ID",
"\t\tself.branchListCount += 1",
"\t\treturn(1)",
"\telse:",
"\t\treturn(0)",
"",
"# check that msg.sender is one of our function contracts",
"def incrementStep(branch):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tself.Branches[branch].step += 1",
"\treturn(1)",
"",
"def setStep(branch, step):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tself.Branches[branch].step = step",
"\treturn(1)",
"",
"def incrementPeriod(branch):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tself.Branches[branch].currentVotePeriod += 1",
"\treturn(1)",
"",
"# check that msg.sender is one of our function contracts",
"def addMarket(branch, market):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tnumMarkets = self.Branches[branch].numMarkets",
"\tself.Branches[branch].markets[numMarkets] = market",
"\tself.Branches[branch].numMarkets += 1",
"\treturn(1)",
"",
"def getSubstep(branch):",
"\treturn(self.Branches[branch].substep)",
"",
"def incrementSubstep(branch):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" self.Branches[branch].substep += 1",
" return(1)",
"",
"def setSubstep(branch, substep):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" self.Branches[branch].substep = substep",
" return(1)"
],
"fullsig": [
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "market",
"type": "int256"
}
],
"name": "addMarket(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branchNumber",
"type": "int256"
}
],
"name": "getBranch(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [],
"name": "getBranches()",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "getMarkets(int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "getMinTradingFee(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [],
"name": "getNumBranches()",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "getNumMarkets(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "getPeriodLength(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "address",
"type": "int256"
}
],
"name": "getReputation(int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "getStep(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "getSubstep(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "getVotePeriod(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "incrementPeriod(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "incrementStep(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "incrementSubstep(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "ID",
"type": "int256"
},
{
"name": "currentVotePeriod",
"type": "int256"
},
{
"name": "periodLength",
"type": "int256"
},
{
"name": "minTradingFee",
"type": "int256"
}
],
"name": "initializeBranch(int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "step",
"type": "int256"
}
],
"name": "setStep(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "substep",
"type": "int256"
}
],
"name": "setSubstep(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern branches: [addMarket:[int256,int256]:int256, getBranch:[int256]:int256, getBranches:[]:int256[], getMarkets:[int256]:int256[], getMinTradingFee:[int256]:int256, getNumBranches:[]:int256, getNumMarkets:[int256]:int256, getPeriodLength:[int256]:int256, getReputation:[int256]:int256[], getStep:[int256]:int256, getSubstep:[int256]:int256, getVotePeriod:[int256]:int256, incrementPeriod:[int256]:int256, incrementStep:[int256]:int256, incrementSubstep:[int256]:int256, initializeBranch:[int256,int256,int256,int256]:int256, setStep:[int256,int256]:int256, setSubstep:[int256,int256]:int256]"
},
"cash": {
"address": "0xd15a6cfc462ae76b9ec590cab8b34bfa8e1302d7",
"code": [
"# This software (Augur) allows buying && selling event outcomes in ethereum",
"# Copyright (C) 2015 Forecast Foundation",
"# 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 [email protected]",
"",
"data cashcoinBalances[]",
"",
"def init():",
" # test initial funds",
" self.cashcoinBalances[tx.origin] = 100000*2^64",
"",
"# @return: cash balance of address",
"def balance(address):",
" return(self.cashcoinBalances[address])",
"",
"# should send values as fixed point in UI (1 is 2^64, 4 is 4*2^64, .5 is 2^63, etc.)",
"# so cashcoin fees could just go to root branch, or we could not have fees besides",
"# gas fee to do a send transaction",
"# @return: value sent, 0 if fails",
"def send(recver, value):",
" sender = tx.origin",
" senderBalance = self.cashcoinBalances[sender]",
" if(senderBalance >= value):",
" self.cashcoinBalances[sender] -= value",
" self.cashcoinBalances[recver] += value",
" return(value)",
" else:",
" return(0)",
"",
"# @return value of cash sent; fail is 0",
"def sendFrom(recver, value, from):",
" if(from!=tx.origin):",
" return(0)",
" senderBalance = self.cashcoinBalances[from]",
" if(senderBalance >= value):",
" self.cashcoinBalances[from] -= value",
" self.cashcoinBalances[recver] += value",
" return(value)",
" else:",
" return(0)",
"",
"# make sure only coming from specific contracts",
"def subtractCash(ID, amount):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" self.cashcoinBalances[ID] -= amount",
" return(1)",
"",
"def addCash(ID, amount):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" self.cashcoinBalances[ID] += amount",
" return(1)",
"",
"def setCash(address, balance):",
" #if !self.whitelist.check(msg.sender):",
" # return(-1)",
" self.cashcoinBalances[address] = balance",
" return(1)"
],
"fullsig": [
{
"inputs": [
{
"name": "ID",
"type": "int256"
},
{
"name": "amount",
"type": "int256"
}
],
"name": "addCash(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "address",
"type": "int256"
}
],
"name": "balance(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "recver",
"type": "int256"
},
{
"name": "value",
"type": "int256"
}
],
"name": "send(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "recver",
"type": "int256"
},
{
"name": "value",
"type": "int256"
},
{
"name": "from",
"type": "int256"
}
],
"name": "sendFrom(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "address",
"type": "int256"
},
{
"name": "balance",
"type": "int256"
}
],
"name": "setCash(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "ID",
"type": "int256"
},
{
"name": "amount",
"type": "int256"
}
],
"name": "subtractCash(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern cash: [addCash:[int256,int256]:int256, balance:[int256]:int256, send:[int256,int256]:int256, sendFrom:[int256,int256,int256]:int256, setCash:[int256,int256]:int256, subtractCash:[int256,int256]:int256]"
},
"center": {
"address": "0xa34c9f6fc047cea795f69b34a063d32e6cb6288c",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Jack Peterson ([email protected]).",
"",
"def center(reports_filled:arr, reputation:arr, scaled:arr, scaled_max:arr, scaled_min:arr, max_iterations, max_components):",
" with num_reports = len(reputation):",
" with flatsize = len(reports_filled):",
" with num_events = flatsize / num_reports:",
" # calculate weighted centered data matrix",
" with weighted_means = array(num_events):",
" with total_weight = 0:",
" with i = 0:",
" while i < num_reports:",
" with j = 0:",
" while j < num_events:",
" weighted_means[j] += reputation[i] * reports_filled[i * num_events + j]",
" j += 1",
" total_weight += reputation[i]",
" i += 1",
" with j = 0:",
" while j < num_events:",
" weighted_means[j] /= total_weight",
" j += 1",
" # weighted centered data (wcd): [0, flatsize-1]",
" # loading_vector [1 0 0 . . . 0]: [flatsize, flatsize + num_events]",
" with lflatsize = flatsize + num_events + 2:",
" with wcd = array(lflatsize):",
" with i = 0:",
" while i < flatsize:",
" # 0 if num_reports = 1",
" wcd[i] = reports_filled[i] - weighted_means[i % num_events]",
" i += 1",
" wcd[i] = ONE",
" wcd[lflatsize - 2] = max_iterations",
" if max_components < num_events:",
" wcd[lflatsize - 1] = max_components",
" else:",
" wcd[lflatsize - 1] = num_events",
" return(wcd: arr)",
"",
"def tokenize(reputation:arr, num_reports):",
" with tokens = array(num_reports):",
" with i = 0:",
" while i < num_reports:",
" tokens[i] = reputation[i] * COINS",
" i += 1",
" return(tokens: arr)",
"",
"# First row of the covariance matrix",
"def covariance(wcd:arr, tokens:arr, num_reports, num_events):",
" with cov = array(num_events):",
" with wcd_x_tokens = array(num_reports):",
" with i = 0:",
" while i < num_reports:",
" wcd_x_tokens[i] = fixed_multiply(wcd[i*num_events], tokens[i])",
" i += 1",
" with alltokens = sum(tokens):",
" with i = 0:",
" while i < num_events:",
" with j = 0:",
" while j < num_reports:",
" cov[i] += fixed_multiply(wcd_x_tokens[j], wcd[j*num_events + i])",
" j += 1",
" cov[i] = fixed_divide(cov[i], alltokens - ONE)",
" i += 1",
" return(cov: arr)",
"",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')",
"inset('../../macros/arrays.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "reports_filled",
"type": "int256[]"
},
{
"name": "reputation",
"type": "int256[]"
},
{
"name": "scaled",
"type": "int256[]"
},
{
"name": "scaled_max",
"type": "int256[]"
},
{
"name": "scaled_min",
"type": "int256[]"
},
{
"name": "max_iterations",
"type": "int256"
},
{
"name": "max_components",
"type": "int256"
}
],
"name": "center(int256[],int256[],int256[],int256[],int256[],int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "wcd",
"type": "int256[]"
},
{
"name": "tokens",
"type": "int256[]"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "covariance(int256[],int256[],int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "reputation",
"type": "int256[]"
},
{
"name": "num_reports",
"type": "int256"
}
],
"name": "tokenize(int256[],int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
}
],
"sig": "extern center: [center:[int256[],int256[],int256[],int256[],int256[],int256,int256]:int256[], covariance:[int256[],int256[],int256,int256]:int256[], tokenize:[int256[],int256]:int256[]]"
},
"events": {
"address": "0x9fe69262bbaa47f013b7dbd6ca5f01e17446c645",
"code": [
"# This software (Augur) allows buying && selling event outcomes in ethereum",
"# Copyright (C) 2015 Forecast Foundation",
"# 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 [email protected]",
"",
"# Events' index is the eventID",
"# a binary outcome has 0 for min && 1 for max value, but consensus will return 2^64 and 2^65 respectively",
"# so for voting 1 and 2 in fxp. need to be given for binaries, not 0 & 1",
"# S&P 500 scalar would be say 0 && 4700, respectively",
"# categorical markets have fixed point min and max",
" # so max-min/numOutcomes is interval between outcomes (useful for ui, e.g. 1 is >50, 2 is >100, etc.)",
"# need outcomes returned as 1*2^64, 2*2^64, etc... indeterminate as 3*2^63",
"data Events[](branch, expirationDate, outcome, minValue, maxValue, numOutcomes)",
"",
"def getEventInfo(event):",
" info = array(6)",
" info[0] = self.Events[event].branch",
" info[1] = self.Events[event].expirationDate",
" info[2] = self.Events[event].outcome",
" info[3] = self.Events[event].minValue",
" info[4] = self.Events[event].maxValue",
" info[5] = self.Events[event].numOutcomes",
" return(info: arr)",
"",
"def getEventBranch(event):",
"\treturn(self.Events[event].branch)",
"",
"def getExpiration(event):",
"\treturn(self.Events[event].expirationDate)",
"",
"def getOutcome(event):",
"\treturn(self.Events[event].outcome)",
"",
"def getMinValue(event):",
"\treturn(self.Events[event].minValue)",
"",
"def getMaxValue(event):",
"\treturn(self.Events[event].maxValue)",
"",
"def getNumOutcomes(event):",
"\treturn(self.Events[event].numOutcomes)",
"",
"def initializeEvent(ID, branch, expirationDate, minValue, maxValue, numOutcomes):",
"\t# check that msg.sender is one of our function contracts",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tif(self.Events[ID].expirationDate==0):",
"\t\tself.Events[ID].branch = branch",
"\t\tself.Events[ID].expirationDate = expirationDate",
"\t\tself.Events[ID].minValue = minValue",
"\t\tself.Events[ID].maxValue = maxValue",
"\t\tself.Events[ID].numOutcomes = numOutcomes",
"\t\treturn(1)",
"\telse:",
"\t\treturn(0)",
"",
"def setOutcome(ID, outcome):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tself.Events[ID].outcome = outcome",
"\treturn(1)"
],
"fullsig": [
{
"inputs": [
{
"name": "event",
"type": "int256"
}
],
"name": "getEventBranch(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "event",
"type": "int256"
}
],
"name": "getEventInfo(int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "event",
"type": "int256"
}
],
"name": "getExpiration(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "event",
"type": "int256"
}
],
"name": "getMaxValue(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "event",
"type": "int256"
}
],
"name": "getMinValue(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "event",
"type": "int256"
}
],
"name": "getNumOutcomes(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "event",
"type": "int256"
}
],
"name": "getOutcome(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "ID",
"type": "int256"
},
{
"name": "branch",
"type": "int256"
},
{
"name": "expirationDate",
"type": "int256"
},
{
"name": "minValue",
"type": "int256"
},
{
"name": "maxValue",
"type": "int256"
},
{
"name": "numOutcomes",
"type": "int256"
}
],
"name": "initializeEvent(int256,int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "ID",
"type": "int256"
},
{
"name": "outcome",
"type": "int256"
}
],
"name": "setOutcome(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern events: [getEventBranch:[int256]:int256, getEventInfo:[int256]:int256[], getExpiration:[int256]:int256, getMaxValue:[int256]:int256, getMinValue:[int256]:int256, getNumOutcomes:[int256]:int256, getOutcome:[int256]:int256, initializeEvent:[int256,int256,int256,int256,int256,int256]:int256, setOutcome:[int256,int256]:int256]"
},
"expiringEvents": {
"address": "0x52ccb0490bc81a2ae363fccbb2b367bca546cec7",
"code": [
"# This software (Augur) allows buying && selling event outcomes in ethereum",
"# Copyright (C) 2015 Forecast Foundation",
"# 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 [email protected]",
"",
"extern branches: [addMarket:[int256,int256]:int256, getBranch:[int256]:int256, getBranches:[]:int256[], getMarkets:[int256]:int256[], getMinTradingFee:[int256]:int256, getNumBranches:[]:int256, getNumMarkets:[int256]:int256, getPeriodLength:[int256]:int256, getStep:[int256]:int256, getSubstep:[int256]:int256, getVotePeriod:[int256]:int256, incrementPeriod:[int256]:int256, incrementStep:[int256]:int256, incrementSubstep:[int256]:int256, initializeBranch:[int256,int256,int256,int256]:int256, setStep:[int256,int256]:int256, setSubstep:[int256,int256]:int256]",
"BRANCHES = 0x552454582fe259c644c191448c66e4fce4306437",
"",
"# [branchID][votingPeriod]",
"# v_size = numReports * numEvents",
"# reportsFilled, reportsMask, weightedCenteredData, loadingVector, scores, set1, set2, old,",
"# new1, new2, adjPrinComp, smoothRep, outcomesFinal, consensusReward is all consensus data",
"# reporters is [reporterID][eventNum]",
"# reporthash is [reporterID] = hash",
"data EventsExpDates[][](numberEvents, events[], totalRepReported, totalReputation, reporters[][], reportHash[], vSize, reportsFilled[], reportsMask[], weightedCenteredData[], covarianceMatrixRow[], deflated[], loadingVector[], latent, scores[], set1[], set2[], old[], new1[], new2[], adjPrinComp[], smoothRep[], outcomesFinal[], reporterPayouts[])",
"",
"# atm voters who do vote are req. to vote on all things in their respective ballots (even if just a 0 / no vote)",
"# ballot should be all votes for events in order of the events from self.Reporting[branch].eventsExpDates[w/eVotingPeriodShouldBe].numberEvents",
"# w/ this function you can get the eventIDs and report on outcomes",
" # make sure in this function to check that the report value is not >maxvalue or <minvalue for the event",
"# ui will want to alert users of any hey we're behind but atm you should really be voting on this voting period situation (anything meeting the req. of vote if we were caught up)",
"# @returns a ballot of events (UI needs to vote w/ a ballot of reports in this order per corresponding event)",
"# @return all events in a branch and expiration period",
"def getEvents(branch, expDateIndex):",
" numEvents = self.EventsExpDates[branch][expDateIndex].numberEvents",
" events = array(numEvents)",
" i = 0",
" while i < numEvents:",
" events[i] = self.EventsExpDates[branch][expDateIndex].events[i]",
" i += 1",
" return(events: arr)",
"",
"def getNumberEvents(branch, expDateIndex):",
"\treturn(self.EventsExpDates[branch][expDateIndex].numberEvents)",
"",
"def getEvent(branch, expDateIndex, eventIndex):",
"\treturn(self.EventsExpDates[branch][expDateIndex].events[eventIndex])",
"",
"def getTotalReputation(branch, expDateIndex):",
" return(self.EventsExpDates[branch][expDateIndex].totalReputation)",
"",
"def getTotalRepReported(branch, expDateIndex):",
"\treturn(self.EventsExpDates[branch][expDateIndex].totalRepReported)",
"",
"def getReporterBallot(branch, expDateIndex, reporterID):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].reporters[reporterID][0], chars=32*self.EventsExpDates[branch][expDateIndex].numberEvents): arr)",
"",
"def getReport(branch, expDateIndex, reporter, reportNum):",
"\treturn(self.EventsExpDates[branch][expDateIndex].reporters[reporter][reportNum])",
"",
"def getReportHash(branch, expDateIndex, reporter):",
"\treturn(self.EventsExpDates[branch][expDateIndex].reportHash[reporter])",
"",
"def getVSize(branch, expDateIndex):",
" return(self.EventsExpDates[branch][expDateIndex].vSize)",
"",
"def getReportsFilled(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].reportsFilled[0], chars=32*self.EventsExpDates[branch][expDateIndex].vSize): arr)",
"",
"def getReportsMask(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].reportsMask[0], chars=32*self.EventsExpDates[branch][expDateIndex].vSize): arr)",
"",
"def getWeightedCenteredData(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].weightedCenteredData[0], chars=32*self.EventsExpDates[branch][expDateIndex].vSize): arr)",
"",
"def getCovarianceMatrixRow(branch, expDateIndex):",
" return(load(self.EventsExpDates[branch][expDateIndex].covarianceMatrixRow[0], chars=32*self.EventsExpDates[branch][expDateIndex].numberEvents): arr)",
"",
"def getDeflated(branch, expDateIndex):",
" return(load(self.EventsExpDates[branch][expDateIndex].deflated[0], chars=32*self.EventsExpDates[branch][expDateIndex].vSize): arr)",
"",
"def getLoadingVector(branch, expDateIndex):",
" return(load(self.EventsExpDates[branch][expDateIndex].loadingVector[0], chars=32*(self.EventsExpDates[branch][expDateIndex].numberEvents+2)): arr)",
"",
"def getLatent(branch, expDateIndex):",
" return(self.EventsExpDates[branch][expDateIndex].latent)",
"",
"def getScores(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].scores[0], chars=32*(self.EventsExpDates[branch][expDateIndex].vSize/self.EventsExpDates[branch][expDateIndex].numberEvents)): arr)",
"",
"def getSetOne(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].set1[0], chars=32*(self.EventsExpDates[branch][expDateIndex].vSize/self.EventsExpDates[branch][expDateIndex].numberEvents)): arr)",
"",
"def getSetTwo(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].set2[0], chars=32*(self.EventsExpDates[branch][expDateIndex].vSize/self.EventsExpDates[branch][expDateIndex].numberEvents)): arr)",
"",
"def returnOld(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].old[0], chars=32*self.EventsExpDates[branch][expDateIndex].numberEvents): arr)",
"",
"def getNewOne(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].new1[0], chars=32*self.EventsExpDates[branch][expDateIndex].numberEvents): arr)",
"",
"def getNewTwo(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].new2[0], chars=32*self.EventsExpDates[branch][expDateIndex].numberEvents): arr)",
"",
"def getAdjPrinComp(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].adjPrinComp[0], chars=32*(self.EventsExpDates[branch][expDateIndex].vSize/self.EventsExpDates[branch][expDateIndex].numberEvents)): arr)",
"",
"def getSmoothRep(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].smoothRep[0], chars=32*(self.EventsExpDates[branch][expDateIndex].vSize/self.EventsExpDates[branch][expDateIndex].numberEvents)): arr)",
"",
"def getOutcomesFinal(branch, expDateIndex):",
"\treturn(load(self.EventsExpDates[branch][expDateIndex].outcomesFinal[0], chars=32*self.EventsExpDates[branch][expDateIndex].numberEvents): arr)",
"",
"def getReporterPayouts(branch, expDateIndex):",
" return(load(self.EventsExpDates[branch][expDateIndex].reporterPayouts[0], chars=32*self.EventsExpDates[branch][expDateIndex].numberEvents): arr)",
"",
"# check that msg.sender is one of our function contracts",
"def addEvent(branch, futurePeriod, eventID):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tself.EventsExpDates[branch][futurePeriod].events[self.EventsExpDates[branch][futurePeriod].numberEvents] = eventID",
"\tself.EventsExpDates[branch][futurePeriod].numberEvents += 1",
"\treturn(1)",
"",
"def setTotalRepReported(branch, expDateIndex, repReported):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tself.EventsExpDates[branch][expDateIndex].totalRepReported = repReported",
"\treturn(1)",
"",
"def setTotalReputation(branch, expDateIndex, totalReputation):",
" self.EventsExpDates[branch][expDateIndex].totalReputation = totalReputation",
" return(1)",
"",
"def setReporterBallot(branch, expDateIndex, reporterID, report: arr, reputation):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].reporters[reporterID][0], report, chars=32*len(report))",
"\tself.EventsExpDates[branch][expDateIndex].totalRepReported += reputation",
"\treturn(1)",
"",
"def setVSize(branch, expDateIndex, vSize):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tself.EventsExpDates[branch][expDateIndex].vSize = vSize",
"\treturn(1)",
"",
"def setReportsFilled(branch, expDateIndex, reportsFilled: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].reportsFilled[0], reportsFilled, chars=32*len(reportsFilled))",
"\treturn(1)",
"",
"def setReportsMask(branch, expDateIndex, reportsMask: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].reportsMask[0], reportsMask, chars=32*len(reportsMask))",
"\treturn(1)",
"",
"def setWeightedCenteredData(branch, expDateIndex, weightedCenteredData: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].weightedCenteredData[0], weightedCenteredData, chars=32*len(weightedCenteredData))",
"\treturn(1)",
"",
"def setCovarianceMatrixRow(branch, expDateIndex, covarianceMatrixRow: arr):",
" #if !self.whitelist.check(msg.sender):",
" # return(-1)",
" save(self.EventsExpDates[branch][expDateIndex].covarianceMatrixRow[0], covarianceMatrixRow, chars=32*len(covarianceMatrixRow))",
" return(1)",
"",
"def setDeflated(branch, expDateIndex, deflated: arr):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" save(self.EventsExpDates[branch][expDateIndex].deflated[0], deflated, chars=32*len(deflated))",
" return(1)",
"",
"def setLoadingVector(branch, expDateIndex, loadingVector: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].loadingVector[0], loadingVector, chars=32*len(loadingVector))",
"\treturn(1)",
"",
"def setLatent(branch, expDateIndex, latent):",
" #if !self.whitelist.check(msg.sender):",
" # return(-1)",
" self.EventsExpDates[branch][expDateIndex].latent = latent",
" return(1)",
"",
"def setScores(branch, expDateIndex, scores: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].scores[0], scores, chars=32*len(scores))",
"\treturn(1)",
"",
"def setSetOne(branch, expDateIndex, setOne: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].set1[0], setOne, chars=32*len(setOne))",
"\treturn(1)",
"",
"def setSetTwo(branch, expDateIndex, setTwo: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].set2[0], setTwo, chars=32*len(setTwo))",
"\treturn(1)",
"",
"def setOld(branch, expDateIndex, setOld: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].old[0], setOld, chars=32*len(setOld))",
"\treturn(1)",
"",
"def setNewOne(branch, expDateIndex, newOne: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].new1[0], newOne, chars=32*len(newOne))",
"\treturn(1)",
"",
"def setNewTwo(branch, expDateIndex, newTwo: arr):",
"\t# if(!self.whitelist.check(msg.sender)):",
"\t# \treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].new2[0], newTwo, chars=32*len(newTwo))",
"\treturn(1)",
"",
"def setAdjPrinComp(branch, expDateIndex, adjPrinComp: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].adjPrinComp[0], adjPrinComp, chars=32*len(adjPrinComp))",
"\treturn(1)",
"",
"def setSmoothRep(branch, expDateIndex, smoothRep: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].smoothRep[0], smoothRep, chars=32*len(smoothRep))",
"\treturn(1)",
"",
"def setOutcomesFinal(branch, expDateIndex, outcomesFinal: arr):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tsave(self.EventsExpDates[branch][expDateIndex].outcomesFinal[0], outcomesFinal, chars=32*len(outcomesFinal))",
"\treturn(1)",
"",
"def setReporterPayouts(branch, expDateIndex, reporterPayouts: arr):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" save(self.EventsExpDates[branch][expDateIndex].reporterPayouts[0], reporterPayouts, chars=32*len(reporterPayouts))",
" return(1)",
"",
"def setReportHash(branch, expDateIndex, reporter, reportHash):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\tself.EventsExpDates[branch][expDateIndex].reportHash[reporter] = reportHash",
"\treturn(1)",
"",
"def moveEventsToCurrentPeriod(branch, currentVotePeriod, currentPeriod):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" x = 0",
" while(x < self.EventsExpDates[branch][currentVotePeriod-1].numberEvents):",
" self.EventsExpDates[branch][currentPeriod].events[self.EventsExpDates[branch][currentPeriod].numberEvents] = self.EventsExpDates[branch][currentVotePeriod-1].events[x]",
" self.EventsExpDates[branch][currentPeriod].numberEvents += 1",
" # sub and set old period event to 0 poss.?",
" x += 1",
" return(1)"
],
"fullsig": [
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "futurePeriod",
"type": "int256"
},
{
"name": "eventID",
"type": "int256"
}
],
"name": "addEvent(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getAdjPrinComp(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getCovarianceMatrixRow(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getDeflated(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "eventIndex",
"type": "int256"
}
],
"name": "getEvent(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getEvents(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getLatent(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getLoadingVector(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getNewOne(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getNewTwo(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getNumberEvents(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getOutcomesFinal(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "reporter",
"type": "int256"
},
{
"name": "reportNum",
"type": "int256"
}
],
"name": "getReport(int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "reporter",
"type": "int256"
}
],
"name": "getReportHash(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "reporterID",
"type": "int256"
}
],
"name": "getReporterBallot(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getReporterPayouts(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getReportsFilled(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getReportsMask(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getScores(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getSetOne(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getSetTwo(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getSmoothRep(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getTotalRepReported(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getTotalReputation(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getVSize(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "getWeightedCenteredData(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "currentVotePeriod",
"type": "int256"
},
{
"name": "currentPeriod",
"type": "int256"
}
],
"name": "moveEventsToCurrentPeriod(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
}
],
"name": "returnOld(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "adjPrinComp",
"type": "int256[]"
}
],
"name": "setAdjPrinComp(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "covarianceMatrixRow",
"type": "int256[]"
}
],
"name": "setCovarianceMatrixRow(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "deflated",
"type": "int256[]"
}
],
"name": "setDeflated(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "latent",
"type": "int256"
}
],
"name": "setLatent(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "loadingVector",
"type": "int256[]"
}
],
"name": "setLoadingVector(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "newOne",
"type": "int256[]"
}
],
"name": "setNewOne(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "newTwo",
"type": "int256[]"
}
],
"name": "setNewTwo(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "setOld",
"type": "int256[]"
}
],
"name": "setOld(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "outcomesFinal",
"type": "int256[]"
}
],
"name": "setOutcomesFinal(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "reporter",
"type": "int256"
},
{
"name": "reportHash",
"type": "int256"
}
],
"name": "setReportHash(int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "reporterID",
"type": "int256"
},
{
"name": "report",
"type": "int256[]"
},
{
"name": "reputation",
"type": "int256"
}
],
"name": "setReporterBallot(int256,int256,int256,int256[],int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "reporterPayouts",
"type": "int256[]"
}
],
"name": "setReporterPayouts(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "reportsFilled",
"type": "int256[]"
}
],
"name": "setReportsFilled(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "reportsMask",
"type": "int256[]"
}
],
"name": "setReportsMask(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "scores",
"type": "int256[]"
}
],
"name": "setScores(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "setOne",
"type": "int256[]"
}
],
"name": "setSetOne(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "setTwo",
"type": "int256[]"
}
],
"name": "setSetTwo(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "smoothRep",
"type": "int256[]"
}
],
"name": "setSmoothRep(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "repReported",
"type": "int256"
}
],
"name": "setTotalRepReported(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "totalReputation",
"type": "int256"
}
],
"name": "setTotalReputation(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "vSize",
"type": "int256"
}
],
"name": "setVSize(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "expDateIndex",
"type": "int256"
},
{
"name": "weightedCenteredData",
"type": "int256[]"
}
],
"name": "setWeightedCenteredData(int256,int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern expiringEvents: [addEvent:[int256,int256,int256]:int256, getAdjPrinComp:[int256,int256]:int256[], getCovarianceMatrixRow:[int256,int256]:int256[], getDeflated:[int256,int256]:int256[], getEvent:[int256,int256,int256]:int256, getEvents:[int256,int256]:int256[], getLatent:[int256,int256]:int256, getLoadingVector:[int256,int256]:int256[], getNewOne:[int256,int256]:int256[], getNewTwo:[int256,int256]:int256[], getNumberEvents:[int256,int256]:int256, getOutcomesFinal:[int256,int256]:int256[], getReport:[int256,int256,int256,int256]:int256, getReportHash:[int256,int256,int256]:int256, getReporterBallot:[int256,int256,int256]:int256[], getReporterPayouts:[int256,int256]:int256[], getReportsFilled:[int256,int256]:int256[], getReportsMask:[int256,int256]:int256[], getScores:[int256,int256]:int256[], getSetOne:[int256,int256]:int256[], getSetTwo:[int256,int256]:int256[], getSmoothRep:[int256,int256]:int256[], getTotalRepReported:[int256,int256]:int256, getTotalReputation:[int256,int256]:int256, getVSize:[int256,int256]:int256, getWeightedCenteredData:[int256,int256]:int256[], moveEventsToCurrentPeriod:[int256,int256,int256]:int256, returnOld:[int256,int256]:int256[], setAdjPrinComp:[int256,int256,int256[]]:int256, setCovarianceMatrixRow:[int256,int256,int256[]]:int256, setDeflated:[int256,int256,int256[]]:int256, setLatent:[int256,int256,int256]:int256, setLoadingVector:[int256,int256,int256[]]:int256, setNewOne:[int256,int256,int256[]]:int256, setNewTwo:[int256,int256,int256[]]:int256, setOld:[int256,int256,int256[]]:int256, setOutcomesFinal:[int256,int256,int256[]]:int256, setReportHash:[int256,int256,int256,int256]:int256, setReporterBallot:[int256,int256,int256,int256[],int256]:int256, setReporterPayouts:[int256,int256,int256[]]:int256, setReportsFilled:[int256,int256,int256[]]:int256, setReportsMask:[int256,int256,int256[]]:int256, setScores:[int256,int256,int256[]]:int256, setSetOne:[int256,int256,int256[]]:int256, setSetTwo:[int256,int256,int256[]]:int256, setSmoothRep:[int256,int256,int256[]]:int256, setTotalRepReported:[int256,int256,int256]:int256, setTotalReputation:[int256,int256,int256]:int256, setVSize:[int256,int256,int256]:int256, setWeightedCenteredData:[int256,int256,int256[]]:int256]"
},
"fxpFunctions": {
"address": "0x81a7621e9a286d061b3dea040888a51c96693b1c",
"code": [
"macro fx_floor_log2($x):",
" with $y = $x / 0x10000000000000000:",
" with $lo = 0:",
" with $hi = 191:",
" with $mid = ($hi + $lo)/2:",
" while (($lo + 1) != $hi):",
" if $y < 2**$mid:",
" $hi = $mid",
" else:",
" $lo = $mid",
" $mid = ($hi + $lo)/2",
" $lo",
"",
"macro fx_log2_small($x):",
" with $result = -0x48A49EAD9B2CD16BE:",
" with $temp = $x:",
" $result += 0x124DC64B2741E5F083*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result -= 0x36A569D528A96FF419*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x880785B1DE09970584*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result -= 0x10AF33C52EB996E92A6*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x19FD6E8AC1305DD6D3F*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result -= 0x2086485A91622AE7378*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x210382DF5A3175686B4*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result -= 0x1B58D71F02D9DA4F7B6*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x1288E14C2FB8C4C1595*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result -= 0xA44C5BBEB599D5AB38*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x4A0E619C630B69BC17*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result -= 0x1AE8CAEA63CF2593A9*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x7C3EF5A5BFC21BA1F*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result -= 0x1BD202FA82B683802*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x4A90858A0731AD74*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result -= 0x8CB3CD4376E76EF*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0xA6B8F8E68CD877*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result - 0x5D5316875D9E3*$temp / 0x10000000000000000",
"",
"macro fx_log2($x):",
" with $y = fx_floor_log2($x):",
" with $z = $x / 2**$y:",
" $y * 0x10000000000000000 + fx_log2_small($z)",
"",
"macro fx_log($x):",
" fx_log2($x) * 0x10000000000000000 / 0x171547652B82FE177",
"",
"macro fx_exp2_small($x):",
" with $result = 0x10000000000000000:",
" with $temp = $x:",
" $result += 0xB17217F7D1CF79AC*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x3D7F7BFF058B1D56*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0xE35846B82505F32*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x276556DF749D7C6*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x5761FF9E294A6F*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0xA184897C5558D*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0xFFE5FE24386C*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x162C023B2A1D*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x1B5250C02BF*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x1E4D3F1A83*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x1E87B8E21*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x1C768AA3*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result += 0x164F0A9*$temp / 0x10000000000000000",
" $temp = $temp*$x / 0x10000000000000000",
" $result + 0x1B08D3*$temp / 0x10000000000000000",
"",
"macro fx_exp2($x):",
" with $y = $x / 0x10000000000000000:",
" with $z = $x % 0x10000000000000000:",
" fx_exp2_small($z) * 2**$y",
"",
"macro fx_exp($x):",
" fx_exp2($x * 0x10000000000000000 / 0xB17217F7D1CF79AC)",
"",
"def fx_exp(x):",
"\treturn(fx_exp(x))",
"",
"def fx_log(x):",
"\treturn(fx_log(x))"
],
"fullsig": [
{
"inputs": [
{
"name": "x",
"type": "int256"
}
],
"name": "fx_exp(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "x",
"type": "int256"
}
],
"name": "fx_log(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern fxpFunctions: [fx_exp:[int256]:int256, fx_log:[int256]:int256]"
},
"info": {
"address": "0xe5b327630cfa7f4b2324f9066c897dceecfd88a3",
"code": [
"# This software (Augur) allows buying && selling event outcomes in ethereum",
"# Copyright (C) 2015 Forecast Foundation",
"# 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 [email protected]",
"",
"",
"# Every entity in our contract has similar metadata.",
"# Instead of putting it in each entity, we put all the",
"# metadata here.",
"# Info's index is the hash of the item we're getting info on",
"data Info[](description[2048], descriptionLength, creator, creationFee)",
"",
"def init():",
" description = text(\"Root branch\")",
" save(self.Info[1010101].description[0], description, chars=len(description))",
" self.Info[1010101].creator = 0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826",
" self.Info[1010101].creationFee = 10",
" self.Info[1010101].descriptionLength = len(description)",
"",
"def getDescription(ID):",
"\tlength=self.Info[ID].descriptionLength",
"\treturn(load(self.Info[ID].description[0], chars=length): str)",
"",
"def getDescriptionLength(ID):",
"\treturn(self.Info[ID].descriptionLength)",
"",
"def getCreator(ID):",
"\treturn(self.Info[ID].creator)",
"",
"def getCreationFee(ID):",
"\treturn(self.Info[ID].creationFee)",
"",
"# @return 1 if success, 0 if creator already exists",
"def setInfo(ID, description: str, creator, fee):",
"\t#if(!self.whitelist.check(msg.sender)):",
"\t#\treturn(-1)",
"\t# check that msg.sender is one of our function contracts",
"\tif(self.Info[ID].creator == 0):",
"\t\tsave(self.Info[ID].description[0], description, chars=len(description))",
"\t\tself.Info[ID].descriptionLength = len(description)",
"\t\tself.Info[ID].creationFee = fee",
"\t\tself.Info[ID].creator = creator",
"\t\treturn(1)",
"\telse:",
"\t\treturn(0)"
],
"fullsig": [
{
"inputs": [
{
"name": "ID",
"type": "int256"
}
],
"name": "getCreationFee(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "ID",
"type": "int256"
}
],
"name": "getCreator(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "ID",
"type": "int256"
}
],
"name": "getDescription(int256)",
"outputs": [
{
"name": "out",
"type": "bytes"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "ID",
"type": "int256"
}
],
"name": "getDescriptionLength(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "ID",
"type": "int256"
},
{
"name": "description",
"type": "bytes"
},
{
"name": "creator",
"type": "int256"
},
{
"name": "fee",
"type": "int256"
}
],
"name": "setInfo(int256,bytes,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern info: [getCreationFee:[int256]:int256, getCreator:[int256]:int256, getDescription:[int256]:bytes, getDescriptionLength:[int256]:int256, setInfo:[int256,bytes,int256,int256]:int256]"
},
"markets": {
"address": "0xabe47f122a496a732d6c4b38b3ca376d597d75dd",
"code": [
"# This software (Augur) allows buying && selling event outcomes in ethereum",
"# Copyright (C) 2015 Forecast Foundation",
"# 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 [email protected]",
"",
"extern fxpFunctions: [fx_exp:[int256]:int256, fx_log:[int256]:int256]",
"FXP = 0x3db6079d2f73f840ca4764c87d16dcca7ddaf1de",
"",
"# Markets' index is the marketID",
"# Events is a 0 indexed array of events in the market in the format of",
" # [1, event, event, 2, event, 3, event, event, event]",
" # 1 means dimension 1, 2 is events in dimension 2, 3 is the dimension 3 events",
"# Sharespurchased keeps track of the number of shares purchased for each outcome",
" # sharesPurchased states starts at 1 - (same for participants[].shares[] array)",
"# Participants is a 0 indexed array of participants, their cashIDs, && the shares in each outcome they've purchased of an event",
"# a binary outcome state 1 is no, 2 is true, 0 if not determined",
"# tradingFee is a percent in fixedPoint",
"# tradingPeriod is which eventexpperiod market expires in",
"data Markets[](events[], sharesPurchased[], addr2participant[], participants[](participantID, shares[]), lenEvents, currentParticipant, winningOutcomes[], alpha, cumulativeScale, numOutcomes, tradingPeriod, tradingFee, branch)",
"",
"# @return cost - how much it costs you to buy",
"# price - current share price of that outcome after buy",
"def getSimulatedBuy(market, outcome, amount):",
" # lmsr cost calcs",
" oldCost = lsLmsr(market)",
" sharesPurchased(market)[outcome] += amount",
" newCost = lsLmsr(market)",
" if newCost <= oldCost:",
" sharesPurchased(market)[outcome] -= amount",
" return(-2)",
" cost = (newCost - oldCost)",
" price = self.price(market, outcome)",
" sharesPurchased(market)[outcome] -= amount",
" return([cost, price], chars=64)",
"",
"# @return cost - how much you get paid to sell",
"# price - current share price of that outcome after sell",
"def getSimulatedSell(market, outcome, amount):",
" # lmsr cost calcs",
" oldCost = lsLmsr(market)",
" sharesPurchased(market)[outcome] -= amount",
" newCost = lsLmsr(market)",
" if oldCost <= newCost:",
" sharesPurchased(market)[outcome] += amount",
" return(-2)",
" # these prices are in fixed point",
" cost = oldCost - newCost",
" price = self.price(market, outcome)",
" sharesPurchased(market)[outcome] += amount",
" return([cost, price], chars=64)",
"",
"def getMarketInfo(market):",
" lenEvents = self.Markets[market].lenEvents",
" info = array(14+lenEvents)",
" info[0] = self.Markets[market].currentParticipant",
" info[1] = self.Markets[market].alpha",
" #info[2] = self.Markets[market].cumulativeScale",
" info[2] = self.Markets[market].addr2participant[tx.origin]",
" info[3] = self.Markets[market].numOutcomes",
" info[4] = self.Markets[market].tradingPeriod",
" info[5] = self.Markets[market].tradingFee",
" i = 0",
" while i < lenEvents:",
" info[6+i] = self.Markets[market].events[i]",
" i += 1",
" info[6+i] = self.Markets[market].winningOutcomes[0]",
" info[7+i] = self.Markets[market].winningOutcomes[1]",
" info[8+i] = self.Markets[market].winningOutcomes[2]",
" info[9+i] = self.Markets[market].winningOutcomes[3]",
" info[10+i] = self.Markets[market].winningOutcomes[4]",
" info[11+i] = self.Markets[market].winningOutcomes[5]",
" info[12+i] = self.Markets[market].winningOutcomes[6]",
" info[13+i] = self.Markets[market].winningOutcomes[7]",
" return(info: arr)",
"",
"def getMarketEvents(market):",
" i = 0",
" lenEvents = self.Markets[market].lenEvents",
" events = array(lenEvents)",
" while i < lenEvents:",
" events[i] = self.Markets[market].events[i]",
" i += 1",
" return(events: arr)",
"",
"def getSharesPurchased(market, outcome):",
" return(self.Markets[market].sharesPurchased[outcome])",
"",
"def getParticipantNumber(market, address):",
" participantNumber = self.Markets[market].addr2participant[address]",
" if(self.Markets[market].participants[participantNumber].participantID != tx.origin):",
" return(-1)",
" else:",
" return(participantNumber)",
"",
"def getParticipantID(market, participantNumber):",
" return(self.Markets[market].participants[participantNumber].participantID)",
"",
"def getParticipantSharesPurchased(market, participantNumber, outcome):",
" return(self.Markets[market].participants[participantNumber].shares[outcome])",
"",
"def getNumEvents(market):",
" return(self.Markets[market].lenEvents)",
"",
"def getCurrentParticipantNumber(market):",
" return(self.Markets[market].currentParticipant)",
"",
"def getAlpha(market):",
" return(self.Markets[market].alpha)",
"",
"def getCumScale(market):",
" return(self.Markets[market].cumulativeScale)",
"",
"def getMarketNumOutcomes(market):",
" return(self.Markets[market].numOutcomes)",
"",
"def getTradingPeriod(market):",
" return(self.Markets[market].tradingPeriod)",
"",
"def getTradingFee(market):",
" return(self.Markets[market].tradingFee)",
"",
"def getBranchID(market):",
" return(self.Markets[market].branch)",
"",
"# alpha is equal to v/(n*log(n)) where v is the max percent commission",
"# && n is the number of outcomes people can trade. Alpha is set when",
"# a market is created.",
"macro lsLmsr($marketID):",
" with $bq = Bq($marketID):",
" with $i = 1:",
" with $sumExp = 0:",
" while $i <= numOutcomes($marketID):",
" $sumExp += FXP.fx_exp(sharesPurchased($marketID)[$i] * 2**64 / $bq)",
" $i += 1",
" $bq*FXP.fx_log($sumExp)/2**64",
"",
"macro sumList($q, $a, $b):",
" $i = $a + 1",
" $result = $q[$a]",
" while $i <= $b:",
" $result += $q[$i]",
" $i += 1",
" $result",
"",
"macro market($marketID):",
" self.Markets[$marketID]",
"",
"macro alpha($marketID):",
" market($marketID).alpha",
"",
"macro cumScale($marketID):",
" market($marketID).cumulativeScale",
"",
"macro numOutcomes($marketID):",
" market($marketID).numOutcomes",
"",
"macro sharesPurchased($marketID):",
" market($marketID).sharesPurchased",
"",
"macro particpant($marketID, $addr):",
" market($marketID).participants[$addr]",
"",
"macro Bq($marketID):",
" alpha($marketID) * cumScale($marketID) * sumList(sharesPurchased($marketID), 1, numOutcomes($marketID)) / 2**64",
"",
"def lsLmsr(marketID):",
" return(lsLmsr(marketID))",
"",
"def price(market, outcome):",
" a = lsLmsr(market)",
" sharesPurchased(market)[outcome] += 2**60",
" b = lsLmsr(market)",
" sharesPurchased(market)[outcome] -= 2**60",
" return(((b - a) * 2**64)/2**60)",
"",
"# check that msg.sender is one of our function contracts",
"def initializeMarket(marketID, events: arr, tradingPeriod, tradingFee, branch):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" # add event list to the market",
" save(self.Markets[marketID].events[0], events, chars=32*len(events))",
" self.Markets[marketID].lenEvents = len(events)",
" self.Markets[marketID].tradingPeriod = tradingPeriod",
" self.Markets[marketID].tradingFee = tradingFee",
" self.Markets[marketID].branch = branch",
" return(1)",
"",
"def addParticipant(market, address):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" participantNumber = self.Markets[market].currentParticipant",
" self.Markets[market].participants[participantNumber].participantID = address",
" self.Markets[market].addr2participant[address] = participantNumber",
" self.Markets[market].currentParticipant += 1",
" return(participantNumber)",
"",
"def modifyShares(marketID, outcome, amount):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" sharesPurchased(marketID)[outcome] += amount",
" return(1)",
"",
"def modifyParticipantShares(marketID, participantNumber, outcome, amount):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" self.Markets[marketID].participants[participantNumber].shares[outcome] += amount",
" return(1)",
"",
"def setWinningOutcomes(market, outcomes: arr):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" # largest # of winning outcomes is 8",
" i = 0",
" while outcomes[i] != 0:",
" self.Markets[market].winningOutcomes[i] = outcomes[i]",
" i += 1",
" return(1)",
"",
"def getWinningOutcomes(market):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" # largest # of winning outcomes is 8",
" return(load(self.Markets[market].winningOutcomes[0], chars=32*8): arr)",
"",
"def initialLiquiditySetup(marketID, alpha, cumScale, numOutcomes):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" self.Markets[marketID].alpha = alpha",
" self.Markets[marketID].cumulativeScale = cumScale",
" self.Markets[marketID].numOutcomes = numOutcomes",
" return(1)",
"",
"def getMarketOutcomeInfo(market, outcome):",
" info = array(13)",
" participantNumber = self.Markets[market].addr2participant[tx.origin]",
" info[0] = self.getSharesPurchased(market, outcome)",
" info[1] = self.getParticipantSharesPurchased(market, participantNumber, outcome)",
" info[2] = self.price(market, outcome)",
" info[3] = participantNumber",
" info[4] = self.getCurrentParticipantNumber(market)",
" info[5] = self.Markets[market].winningOutcomes[0]",
" info[6] = self.Markets[market].winningOutcomes[1]",
" info[7] = self.Markets[market].winningOutcomes[2]",
" info[8] = self.Markets[market].winningOutcomes[3]",
" info[9] = self.Markets[market].winningOutcomes[4]",
" info[10] = self.Markets[market].winningOutcomes[5]",
" info[11] = self.Markets[market].winningOutcomes[6]",
" info[12] = self.Markets[market].winningOutcomes[7]",
" return(info: arr)"
],
"fullsig": [
{
"inputs": [
{
"name": "market",
"type": "int256"
},
{
"name": "address",
"type": "int256"
}
],
"name": "addParticipant(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getAlpha(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getBranchID(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getCumScale(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getCurrentParticipantNumber(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getMarketEvents(int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getMarketInfo(int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getMarketNumOutcomes(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
},
{
"name": "outcome",
"type": "int256"
}
],
"name": "getMarketOutcomeInfo(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getNumEvents(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
},
{
"name": "participantNumber",
"type": "int256"
}
],
"name": "getParticipantID(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
},
{
"name": "address",
"type": "int256"
}
],
"name": "getParticipantNumber(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
},
{
"name": "participantNumber",
"type": "int256"
},
{
"name": "outcome",
"type": "int256"
}
],
"name": "getParticipantSharesPurchased(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
},
{
"name": "outcome",
"type": "int256"
}
],
"name": "getSharesPurchased(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
},
{
"name": "outcome",
"type": "int256"
},
{
"name": "amount",
"type": "int256"
}
],
"name": "getSimulatedBuy(int256,int256,int256)",
"outputs": [
{
"name": "unknown_out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
},
{
"name": "outcome",
"type": "int256"
},
{
"name": "amount",
"type": "int256"
}
],
"name": "getSimulatedSell(int256,int256,int256)",
"outputs": [
{
"name": "unknown_out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getTradingFee(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getTradingPeriod(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
}
],
"name": "getWinningOutcomes(int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "marketID",
"type": "int256"
},
{
"name": "alpha",
"type": "int256"
},
{
"name": "cumScale",
"type": "int256"
},
{
"name": "numOutcomes",
"type": "int256"
}
],
"name": "initialLiquiditySetup(int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "marketID",
"type": "int256"
},
{
"name": "events",
"type": "int256[]"
},
{
"name": "tradingPeriod",
"type": "int256"
},
{
"name": "tradingFee",
"type": "int256"
},
{
"name": "branch",
"type": "int256"
}
],
"name": "initializeMarket(int256,int256[],int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "marketID",
"type": "int256"
}
],
"name": "lsLmsr(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "marketID",
"type": "int256"
},
{
"name": "participantNumber",
"type": "int256"
},
{
"name": "outcome",
"type": "int256"
},
{
"name": "amount",
"type": "int256"
}
],
"name": "modifyParticipantShares(int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "marketID",
"type": "int256"
},
{
"name": "outcome",
"type": "int256"
},
{
"name": "amount",
"type": "int256"
}
],
"name": "modifyShares(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
},
{
"name": "outcome",
"type": "int256"
}
],
"name": "price(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "market",
"type": "int256"
},
{
"name": "outcomes",
"type": "int256[]"
}
],
"name": "setWinningOutcomes(int256,int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern markets: [addParticipant:[int256,int256]:int256, getAlpha:[int256]:int256, getBranchID:[int256]:int256, getCumScale:[int256]:int256, getCurrentParticipantNumber:[int256]:int256, getMarketEvents:[int256]:int256[], getMarketInfo:[int256]:int256[], getMarketNumOutcomes:[int256]:int256, getMarketOutcomeInfo:[int256,int256]:int256[], getNumEvents:[int256]:int256, getParticipantID:[int256,int256]:int256, getParticipantNumber:[int256,int256]:int256, getParticipantSharesPurchased:[int256,int256,int256]:int256, getSharesPurchased:[int256,int256]:int256, getSimulatedBuy:[int256,int256,int256]:_, getSimulatedSell:[int256,int256,int256]:_, getTradingFee:[int256]:int256, getTradingPeriod:[int256]:int256, getWinningOutcomes:[int256]:int256[], initialLiquiditySetup:[int256,int256,int256,int256]:int256, initializeMarket:[int256,int256[],int256,int256,int256]:int256, lsLmsr:[int256]:int256, modifyParticipantShares:[int256,int256,int256,int256]:int256, modifyShares:[int256,int256,int256]:int256, price:[int256,int256]:int256, setWinningOutcomes:[int256,int256[]]:int256]"
},
"payout": {
"address": "0x708fdfe18bf28afe861a69e95419d183ace003eb",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Jack Peterson ([email protected]).",
"",
"def payout(outcomes_final:arr, smooth_rep:arr, reports_mask:arr, num_reports, num_events):",
"",
" # Event participation (within columns):",
" # proportion of reputation that answered each event",
" with participation_events = array(num_events):",
" with i = 0:",
" while i < num_events:",
" with k = 0:",
" while k < num_reports:",
" participation_events[i] += smooth_rep[k] * reports_mask[k*num_events + i]",
" k += 1",
" participation_events[i] = ONE - participation_events[i]",
" i += 1",
"",
" # Voter participation (within rows): all events treated equally",
" with participation_reports = array(num_reports):",
" with i = 0:",
" while i < num_reports:",
" with total = 0:",
" with j = 0:",
" while j < num_events:",
" total += reports_mask[i*num_events + j]",
" j += 1",
" participation_reports[i] = ONE - fix(total) / num_events",
" i += 1",
"",
" # General participation",
" with total = 0:",
" with i = 0:",
" while i < num_events:",
" total += participation_events[i]",
" i += 1",
" with participation = ONE - total / num_events:",
" with reporter_bonus = array(num_reports):",
" with na_bonus_reports = normalize(participation_reports):",
" with i = 0:",
" while i < num_reports:",
" reporter_bonus[i] = fixed_multiply(na_bonus_reports[i], participation) + fixed_multiply(smooth_rep[i], ONE - participation)",
" i += 1",
" return(reporter_bonus: arr)",
"",
"# inset('macros/constants.se')",
"# inset('macros/fixed.se')",
"# inset('macros/arrays.se')",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')",
"inset('../../macros/arrays.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "outcomes_final",
"type": "int256[]"
},
{
"name": "smooth_rep",
"type": "int256[]"
},
{
"name": "reports_mask",
"type": "int256[]"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "payout(int256[],int256[],int256[],int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
}
],
"sig": "extern payout: [payout:[int256[],int256[],int256[],int256,int256]:int256[]]"
},
"redeem_adjust": {
"address": "0x482c57abdce592b39434e3f619ffc3db62ab6d01",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Joey Krug ([email protected]) or",
"# Jack Peterson ([email protected]).",
"",
"extern reporting: [addRep:[int256,int256,int256]:int256, addReporter:[int256,int256]:int256, faucet:[int256]:int256, getNumberReporters:[int256]:int256, getRepBalance:[int256,int256]:int256, getRepByIndex:[int256,int256]:int256, getReporterID:[int256,int256]:int256, getReputation:[int256]:int256[], getTotalRep:[int256]:int256, hashReport:[int256[],int256]:int256, repIDToIndex:[int256,int256]:int256, setInitialReporters:[int256,int256]:int256, setRep:[int256,int256,int256]:int256, subtractRep:[int256,int256,int256]:int256]",
"REPORTING = 0x08606bc6f0aa9c41bed0ea1747dd567739751102",
"extern expiringEvents: [addEvent:[int256,int256,int256]:int256, getAdjPrinComp:[int256,int256]:int256[], getCovarianceMatrixRow:[int256,int256]:int256[], getDeflated:[int256,int256]:int256[], getEvent:[int256,int256,int256]:int256, getEvents:[int256,int256]:int256[], getLatent:[int256,int256]:int256, getLoadingVector:[int256,int256]:int256[], getNewOne:[int256,int256]:int256[], getNewTwo:[int256,int256]:int256[], getNumberEvents:[int256,int256]:int256, getOutcomesFinal:[int256,int256]:int256[], getReport:[int256,int256,int256,int256]:int256, getReportHash:[int256,int256,int256]:int256, getReporterBallot:[int256,int256,int256]:int256[], getReporterPayouts:[int256,int256]:int256[], getReportsFilled:[int256,int256]:int256[], getReportsMask:[int256,int256]:int256[], getScores:[int256,int256]:int256[], getSetOne:[int256,int256]:int256[], getSetTwo:[int256,int256]:int256[], getSmoothRep:[int256,int256]:int256[], getTotalRepReported:[int256,int256]:int256, getTotalReputation:[int256,int256]:int256, getVSize:[int256,int256]:int256, getWeightedCenteredData:[int256,int256]:int256[], moveEventsToCurrentPeriod:[int256,int256,int256]:int256, returnOld:[int256,int256]:int256[], setAdjPrinComp:[int256,int256,int256[]]:int256, setCovarianceMatrixRow:[int256,int256,int256[]]:int256, setDeflated:[int256,int256,int256[]]:int256, setLatent:[int256,int256,int256]:int256, setLoadingVector:[int256,int256,int256[]]:int256, setNewOne:[int256,int256,int256[]]:int256, setNewTwo:[int256,int256,int256[]]:int256, setOld:[int256,int256,int256[]]:int256, setOutcomesFinal:[int256,int256,int256[]]:int256, setReportHash:[int256,int256,int256,int256]:int256, setReporterBallot:[int256,int256,int256,int256[],int256]:int256, setReporterPayouts:[int256,int256,int256[]]:int256, setReportsFilled:[int256,int256,int256[]]:int256, setReportsMask:[int256,int256,int256[]]:int256, setScores:[int256,int256,int256[]]:int256, setSetOne:[int256,int256,int256[]]:int256, setSetTwo:[int256,int256,int256[]]:int256, setSmoothRep:[int256,int256,int256[]]:int256, setTotalRepReported:[int256,int256,int256]:int256, setTotalReputation:[int256,int256,int256]:int256, setVSize:[int256,int256,int256]:int256, setWeightedCenteredData:[int256,int256,int256[]]:int256]",
"EXPIRING = 0x915f35711d96b400908737bb82129580991f6021",
"extern adjust: [reputation_delta:[int256[],int256,int256]:int256[], select_scores:[int256[],int256[],int256[],int256[],int256[],int256[],int256,int256]:int256[], weighted_delta:[int256[],int256[],int256[],int256[],int256,int256]:int256[]]",
"ADJUST = 0xa70f5e35b9d4891a36bdb13f1de37a3ecefd4feb",
"",
"def reputation_delta(branch, period, num_events, num_reports, flatsize):",
" with scores = array(num_reports):",
" scores = slice(EXPIRING.getScores(branch, period, outitems=num_reports), items=0, items=num_reports)",
" with nr_x_2 = num_reports * 2:",
" with sets = array(nr_x_2):",
" sets = slice(ADJUST.reputation_delta(scores, num_reports, num_events, outitems=nr_x_2), items=0, items=nr_x_2)",
" EXPIRING.setSetOne(branch, period, slice(sets, items=0, items=num_reports))",
" EXPIRING.setSetTwo(branch, period, slice(sets, items=num_reports, items=nr_x_2))",
" return(1)",
"",
"def weighted_delta(branch, period, num_events, num_reports, flatsize):",
" with reports_filled = array(flatsize):",
" reports_filled = slice(EXPIRING.getReportsFilled(branch, period, outitems=flatsize), items=0, items=flatsize)",
" with reputation = array(num_reports):",
" with i = 0:",
" while i < num_reports:",
" reputation[i] = REPORTING.getRepByIndex(branch, i)",
" i += 1",
" with set1 = array(num_reports):",
" set1 = slice(EXPIRING.getSetOne(branch, period, outitems=num_reports), items=0, items=num_reports)",
" with set2 = array(num_reports):",
" set2 = slice(EXPIRING.getSetTwo(branch, period, outitems=num_reports), items=0, items=num_reports)",
" with ne_x_3 = num_events * 3:",
" with ne_x_2 = num_events * 2:",
" with wsets = array(ne_x_3):",
" wsets = slice(ADJUST.weighted_delta(set1, set2, reputation, reports_filled, num_reports, num_events, outitems=ne_x_3), items=0, items=ne_x_3)",
" EXPIRING.setOld(branch, period, slice(wsets, items=0, items=num_events))",
" EXPIRING.setNewOne(branch, period, slice(wsets, items=num_events, items=ne_x_2))",
" EXPIRING.setNewTwo(branch, period, slice(wsets, items=ne_x_2, items=ne_x_3))",
" return(1)",
"",
"def select_scores(branch, period, num_events, num_reports, flatsize):",
" with old = array(num_events):",
" old = slice(EXPIRING.returnOld(branch, period, outitems=num_events), items=0, items=num_events)",
" with new1 = array(num_events):",
" new1 = slice(EXPIRING.getNewOne(branch, period, outitems=num_events), items=0, items=num_events)",
" with new2 = array(num_events):",
" new2 = slice(EXPIRING.getNewTwo(branch, period, outitems=num_events), items=0, items=num_events)",
" with set1 = array(num_reports):",
" set1 = slice(EXPIRING.getSetOne(branch, period, outitems=num_reports), items=0, items=num_reports)",
" with set2 = array(num_reports):",
" set2 = slice(EXPIRING.getSetTwo(branch, period, outitems=num_reports), items=0, items=num_reports)",
" with scores = array(num_reports):",
" scores = slice(EXPIRING.getScores(branch, period, outitems=num_reports), items=0, items=num_reports)",
" with adjusted_scores = array(num_reports):",
" adjusted_scores = slice(ADJUST.select_scores(old, new1, new2, set1, set2, scores, num_reports, num_events, outitems=num_reports), items=0, items=num_reports)",
" EXPIRING.setAdjPrinComp(branch, period, adjusted_scores)",
" return(1)",
"",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "reputation_delta(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "select_scores(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "weighted_delta(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern redeem_adjust: [reputation_delta:[int256,int256,int256,int256,int256]:int256, select_scores:[int256,int256,int256,int256,int256]:int256, weighted_delta:[int256,int256,int256,int256,int256]:int256]"
},
"redeem_center": {
"address": "0xc21cfa6688dbfd2eca2548d894aa55fd0bbf1c7e",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Joey Krug ([email protected]) or",
"# Jack Peterson ([email protected]).",
"",
"extern events: [getEventBranch:[int256]:int256, getEventInfo:[int256]:int256[], getExpiration:[int256]:int256, getMaxValue:[int256]:int256, getMinValue:[int256]:int256, getNumOutcomes:[int256]:int256, getOutcome:[int256]:int256, initializeEvent:[int256,int256,int256,int256,int256,int256]:int256, setOutcome:[int256,int256]:int256]",
"EVENTS = 0xb48e92dfcae19d6962c6dd000f67a7a26ee7e8e6",
"extern expiringEvents: [addEvent:[int256,int256,int256]:int256, getAdjPrinComp:[int256,int256]:int256[], getCovarianceMatrixRow:[int256,int256]:int256[], getDeflated:[int256,int256]:int256[], getEvent:[int256,int256,int256]:int256, getEvents:[int256,int256]:int256[], getLatent:[int256,int256]:int256, getLoadingVector:[int256,int256]:int256[], getNewOne:[int256,int256]:int256[], getNewTwo:[int256,int256]:int256[], getNumberEvents:[int256,int256]:int256, getOutcomesFinal:[int256,int256]:int256[], getReport:[int256,int256,int256,int256]:int256, getReportHash:[int256,int256,int256]:int256, getReporterBallot:[int256,int256,int256]:int256[], getReporterPayouts:[int256,int256]:int256[], getReportsFilled:[int256,int256]:int256[], getReportsMask:[int256,int256]:int256[], getScores:[int256,int256]:int256[], getSetOne:[int256,int256]:int256[], getSetTwo:[int256,int256]:int256[], getSmoothRep:[int256,int256]:int256[], getTotalRepReported:[int256,int256]:int256, getTotalReputation:[int256,int256]:int256, getVSize:[int256,int256]:int256, getWeightedCenteredData:[int256,int256]:int256[], moveEventsToCurrentPeriod:[int256,int256,int256]:int256, returnOld:[int256,int256]:int256[], setAdjPrinComp:[int256,int256,int256[]]:int256, setCovarianceMatrixRow:[int256,int256,int256[]]:int256, setDeflated:[int256,int256,int256[]]:int256, setLatent:[int256,int256,int256]:int256, setLoadingVector:[int256,int256,int256[]]:int256, setNewOne:[int256,int256,int256[]]:int256, setNewTwo:[int256,int256,int256[]]:int256, setOld:[int256,int256,int256[]]:int256, setOutcomesFinal:[int256,int256,int256[]]:int256, setReportHash:[int256,int256,int256,int256]:int256, setReporterBallot:[int256,int256,int256,int256[],int256]:int256, setReporterPayouts:[int256,int256,int256[]]:int256, setReportsFilled:[int256,int256,int256[]]:int256, setReportsMask:[int256,int256,int256[]]:int256, setScores:[int256,int256,int256[]]:int256, setSetOne:[int256,int256,int256[]]:int256, setSetTwo:[int256,int256,int256[]]:int256, setSmoothRep:[int256,int256,int256[]]:int256, setTotalRepReported:[int256,int256,int256]:int256, setTotalReputation:[int256,int256,int256]:int256, setVSize:[int256,int256,int256]:int256, setWeightedCenteredData:[int256,int256,int256[]]:int256]",
"EXPIRING = 0x915f35711d96b400908737bb82129580991f6021",
"extern reporting: [addRep:[int256,int256,int256]:int256, addReporter:[int256,int256]:int256, faucet:[int256]:int256, getNumberReporters:[int256]:int256, getRepBalance:[int256,int256]:int256, getRepByIndex:[int256,int256]:int256, getReporterID:[int256,int256]:int256, getReputation:[int256]:int256[], getTotalRep:[int256]:int256, hashReport:[int256[],int256]:int256, repIDToIndex:[int256,int256]:int256, setInitialReporters:[int256,int256]:int256, setRep:[int256,int256,int256]:int256, subtractRep:[int256,int256,int256]:int256]",
"REPORTING = 0x08606bc6f0aa9c41bed0ea1747dd567739751102",
"extern center: [center:[int256[],int256[],int256[],int256[],int256[],int256,int256]:int256[], covariance:[int256[],int256[],int256,int256]:int256[], tokenize:[int256[],int256]:int256[]]",
"CENTER = 0x483fafce5e476792f726428b76a80abbb46522b9",
"",
"def center(branch, period, num_events, num_reports, flatsize):",
" with reputation = array(num_reports):",
" with i = 0:",
" while i < num_reports:",
" reputation[i] = REPORTING.getRepByIndex(branch, i)",
" i += 1",
" with scaled = array(num_events):",
" with scaled_max = array(num_events):",
" with scaled_min = array(num_events):",
" with j = 0:",
" while j < num_events:",
" with event = EXPIRING.getEvent(branch, period, j):",
" if fix(EVENTS.getMaxValue(event)) != YES and EVENTS.getNumOutcomes(event) == 2:",
" scaled[j] = 1",
" scaled_min[j] = fix(EVENTS.getMinValue(event))",
" scaled_max[j] = fix(EVENTS.getMaxValue(event))",
" else:",
" scaled[j] = 0",
" scaled_min[j] = NO",
" scaled_max[j] = YES",
" j += 1",
" with reports_filled = array(flatsize):",
" reports_filled = slice(EXPIRING.getReportsFilled(branch, period, outitems=flatsize), items=0, items=flatsize)",
" with lflatsize = flatsize + num_events + 2:",
" with result = array(lflatsize):",
" result = slice(CENTER.center(reports_filled, reputation, scaled, scaled_max, scaled_min, MAX_ITERATIONS, MAX_COMPONENTS, outitems=lflatsize), items=0, items=lflatsize)",
" with wcd = array(flatsize):",
" wcd = slice(result, items=0, items=flatsize)",
" EXPIRING.setWeightedCenteredData(branch, period, wcd)",
" with loading_vector = array(num_events + 2):",
" loading_vector = slice(result, items=flatsize, items=lflatsize)",
" EXPIRING.setLoadingVector(branch, period, loading_vector)",
" return(1)",
"",
"def covariance(branch, period, num_events, num_reports, flatsize):",
" with reputation = array(num_reports):",
" with i = 0:",
" while i < num_reports:",
" reputation[i] = REPORTING.getRepByIndex(branch, i)",
" i += 1",
" with reptokens = array(num_reports):",
" reptokens = slice(CENTER.tokenize(reputation, num_reports, outitems=num_reports), items=0, items=num_reports)",
" with wcd = array(flatsize):",
" wcd = slice(EXPIRING.getWeightedCenteredData(branch, period, outitems=flatsize), items=0, items=flatsize)",
" EXPIRING.setDeflated(branch, period, wcd)",
" with covrow = array(num_events):",
" covrow = slice(CENTER.covariance(wcd, reptokens, num_reports, num_events, outitems=num_events), items=0, items=num_events)",
" EXPIRING.setCovarianceMatrixRow(branch, period, covrow)",
" return(1)",
"",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "center(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "covariance(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern redeem_center: [center:[int256,int256,int256,int256,int256]:int256, covariance:[int256,int256,int256,int256,int256]:int256]"
},
"redeem_interpolate": {
"address": "0x8f2c2267687cb0f047b28a1b6f945da6e101a0d7",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Joey Krug ([email protected]) or",
"# Jack Peterson ([email protected]).",
"",
"# import events as EVENTS",
"extern expiringEvents: [addEvent:[int256,int256,int256]:int256, getAdjPrinComp:[int256,int256]:int256[], getCovarianceMatrixRow:[int256,int256]:int256[], getDeflated:[int256,int256]:int256[], getEvent:[int256,int256,int256]:int256, getEvents:[int256,int256]:int256[], getLatent:[int256,int256]:int256, getLoadingVector:[int256,int256]:int256[], getNewOne:[int256,int256]:int256[], getNewTwo:[int256,int256]:int256[], getNumberEvents:[int256,int256]:int256, getOutcomesFinal:[int256,int256]:int256[], getReport:[int256,int256,int256,int256]:int256, getReportHash:[int256,int256,int256]:int256, getReporterBallot:[int256,int256,int256]:int256[], getReporterPayouts:[int256,int256]:int256[], getReportsFilled:[int256,int256]:int256[], getReportsMask:[int256,int256]:int256[], getScores:[int256,int256]:int256[], getSetOne:[int256,int256]:int256[], getSetTwo:[int256,int256]:int256[], getSmoothRep:[int256,int256]:int256[], getTotalRepReported:[int256,int256]:int256, getTotalReputation:[int256,int256]:int256, getVSize:[int256,int256]:int256, getWeightedCenteredData:[int256,int256]:int256[], moveEventsToCurrentPeriod:[int256,int256,int256]:int256, returnOld:[int256,int256]:int256[], setAdjPrinComp:[int256,int256,int256[]]:int256, setCovarianceMatrixRow:[int256,int256,int256[]]:int256, setDeflated:[int256,int256,int256[]]:int256, setLatent:[int256,int256,int256]:int256, setLoadingVector:[int256,int256,int256[]]:int256, setNewOne:[int256,int256,int256[]]:int256, setNewTwo:[int256,int256,int256[]]:int256, setOld:[int256,int256,int256[]]:int256, setOutcomesFinal:[int256,int256,int256[]]:int256, setReportHash:[int256,int256,int256,int256]:int256, setReporterBallot:[int256,int256,int256,int256[],int256]:int256, setReporterPayouts:[int256,int256,int256[]]:int256, setReportsFilled:[int256,int256,int256[]]:int256, setReportsMask:[int256,int256,int256[]]:int256, setScores:[int256,int256,int256[]]:int256, setSetOne:[int256,int256,int256[]]:int256, setSetTwo:[int256,int256,int256[]]:int256, setSmoothRep:[int256,int256,int256[]]:int256, setTotalRepReported:[int256,int256,int256]:int256, setTotalReputation:[int256,int256,int256]:int256, setVSize:[int256,int256,int256]:int256, setWeightedCenteredData:[int256,int256,int256[]]:int256]",
"EXPIRING = 0x915f35711d96b400908737bb82129580991f6021",
"extern reporting: [addRep:[int256,int256,int256]:int256, addReporter:[int256,int256]:int256, faucet:[int256]:int256, getNumberReporters:[int256]:int256, getRepBalance:[int256,int256]:int256, getRepByIndex:[int256,int256]:int256, getReporterID:[int256,int256]:int256, getReputation:[int256]:int256[], getTotalRep:[int256]:int256, hashReport:[int256[],int256]:int256, repIDToIndex:[int256,int256]:int256, setInitialReporters:[int256,int256]:int256, setRep:[int256,int256,int256]:int256, subtractRep:[int256,int256,int256]:int256]",
"REPORTING = 0x08606bc6f0aa9c41bed0ea1747dd567739751102",
"# import interpolate as INTERPOLATE",
"",
"data Interpolate[][](reputation[], reports[])",
"",
"# - loop through reputation && check if in reporters, if so use their",
"# report, if not use the fillin / not reported report (all zeroes)",
"# - use this to make a giant array of reports to pass to self.consensus",
"# - want to pass reports for each 0 indexed event in order (so we get",
"# reports from an actual reporter)",
"# (if they didn't vote we set their array for each event to 0,0,0,0,0,0, etc...)",
"def read_ballots(branch, period, num_events, num_reports, flatsize):",
" with reputation = array(num_reports):",
" with reports = array(flatsize):",
" with i = 0:",
" while i < num_reports:",
" with reporterID = REPORTING.getReporterID(branch, i):",
" reputation[i] = REPORTING.getRepBalance(branch, reporterID)",
" # - checks to see if each reporter actually voted on events",
" # - if they didn't vote (simply check if they voted on first event)",
" # do nothing (these values will be 0 by default due to Serpent array styles)",
" # else if the reporter did report on events put their ballot into the reports array",
" # reports[i*num_events] = slice(EXPIRING.getReporterBallot(branch, period, reporterID, outitems=num_events), items=0, items=1)",
" reports[i*num_events] = EXPIRING.getReport(branch, period, reporterID, 0)",
" if reports[i*num_events] != 0:",
" with ballot = array(num_events - 1):",
" ballot = slice(EXPIRING.getReporterBallot(branch, period, reporterID, outitems=num_events), items=1, items=num_events)",
" with j = 1:",
" while j < num_events:",
" reports[i*num_events + j] = ballot[j - 1]",
" j += 1",
" i += 1",
" reputation = normalize(reputation)",
" save(self.Interpolate[branch][period].reports[0], reports, chars=32*flatsize)",
" save(self.Interpolate[branch][period].reputation[0], reputation, chars=32*num_reports)",
" return(1)",
"",
"def interpolate(branch, period, num_events, num_reports, flatsize):",
" with reputation = array(num_reports):",
" reputation = slice(load(self.Interpolate[branch][period].reputation[0], chars=32*num_reports), items=0, items=num_reports)",
" with reports = array(flatsize):",
" reports = slice(load(self.Interpolate[branch][period].reports[0], chars=32*flatsize), items=0, items=num_reports)",
" with reports_mask = array(flatsize):",
" with reports_filled = array(flatsize):",
" with missing_values = 0:",
" with i = 0:",
" while i < flatsize:",
" if reports[i] == 0:",
" reports_filled[i] = 0",
" reports_mask[i] = 1",
" missing_values = 1",
" else:",
" reports_filled[i] = reports[i]",
" i += 1",
"",
" # every event must be calculated, if any missing values",
" # b/c can only be missing ALL values",
" if missing_values:",
" active_rep = 0",
" j = 0",
" while j < num_reports:",
" if reports[j*num_events] != 0:",
" active_rep += reputation[j]",
" j += 1",
" replacements = array(num_events)",
" i = 0",
" while i < num_events:",
"",
" # weighted average of other reports",
" j = 0",
" while j < num_reports:",
" replacements[i] += reputation[j] * reports[i + j*num_events] / active_rep",
" j += 1",
" replacements[i] = catch(replacements[i])",
" i += 1",
" j = 0",
" while j < num_reports:",
" idx = j * num_events",
" if reports[idx] == 0:",
" i = 0",
" while i < num_events:",
" reports_filled[i + idx] = replacements[i]",
" i += 1",
" j += 1",
" EXPIRING.setVSize(branch, period, flatsize)",
" EXPIRING.setReportsFilled(branch, period, reports_filled)",
" EXPIRING.setReportsMask(branch, period, reports_mask)",
" return(1)",
"",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')",
"inset('../../macros/arrays.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "interpolate(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "read_ballots(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern redeem_interpolate: [interpolate:[int256,int256,int256,int256,int256]:int256, read_ballots:[int256,int256,int256,int256,int256]:int256]"
},
"redeem_payout": {
"address": "0x0fbddb6bfb81c8d0965a894567cf4061446072c2",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Joey Krug ([email protected]) or",
"# Jack Peterson ([email protected]).",
"",
"extern events: [getEventBranch:[int256]:int256, getEventInfo:[int256]:int256[], getExpiration:[int256]:int256, getMaxValue:[int256]:int256, getMinValue:[int256]:int256, getNumOutcomes:[int256]:int256, getOutcome:[int256]:int256, initializeEvent:[int256,int256,int256,int256,int256,int256]:int256, setOutcome:[int256,int256]:int256]",
"EVENTS = 0xb48e92dfcae19d6962c6dd000f67a7a26ee7e8e6",
"extern expiringEvents: [addEvent:[int256,int256,int256]:int256, getAdjPrinComp:[int256,int256]:int256[], getCovarianceMatrixRow:[int256,int256]:int256[], getDeflated:[int256,int256]:int256[], getEvent:[int256,int256,int256]:int256, getEvents:[int256,int256]:int256[], getLatent:[int256,int256]:int256, getLoadingVector:[int256,int256]:int256[], getNewOne:[int256,int256]:int256[], getNewTwo:[int256,int256]:int256[], getNumberEvents:[int256,int256]:int256, getOutcomesFinal:[int256,int256]:int256[], getReport:[int256,int256,int256,int256]:int256, getReportHash:[int256,int256,int256]:int256, getReporterBallot:[int256,int256,int256]:int256[], getReporterPayouts:[int256,int256]:int256[], getReportsFilled:[int256,int256]:int256[], getReportsMask:[int256,int256]:int256[], getScores:[int256,int256]:int256[], getSetOne:[int256,int256]:int256[], getSetTwo:[int256,int256]:int256[], getSmoothRep:[int256,int256]:int256[], getTotalRepReported:[int256,int256]:int256, getTotalReputation:[int256,int256]:int256, getVSize:[int256,int256]:int256, getWeightedCenteredData:[int256,int256]:int256[], moveEventsToCurrentPeriod:[int256,int256,int256]:int256, returnOld:[int256,int256]:int256[], setAdjPrinComp:[int256,int256,int256[]]:int256, setCovarianceMatrixRow:[int256,int256,int256[]]:int256, setDeflated:[int256,int256,int256[]]:int256, setLatent:[int256,int256,int256]:int256, setLoadingVector:[int256,int256,int256[]]:int256, setNewOne:[int256,int256,int256[]]:int256, setNewTwo:[int256,int256,int256[]]:int256, setOld:[int256,int256,int256[]]:int256, setOutcomesFinal:[int256,int256,int256[]]:int256, setReportHash:[int256,int256,int256,int256]:int256, setReporterBallot:[int256,int256,int256,int256[],int256]:int256, setReporterPayouts:[int256,int256,int256[]]:int256, setReportsFilled:[int256,int256,int256[]]:int256, setReportsMask:[int256,int256,int256[]]:int256, setScores:[int256,int256,int256[]]:int256, setSetOne:[int256,int256,int256[]]:int256, setSetTwo:[int256,int256,int256[]]:int256, setSmoothRep:[int256,int256,int256[]]:int256, setTotalRepReported:[int256,int256,int256]:int256, setTotalReputation:[int256,int256,int256]:int256, setVSize:[int256,int256,int256]:int256, setWeightedCenteredData:[int256,int256,int256[]]:int256]",
"EXPIRING = 0x915f35711d96b400908737bb82129580991f6021",
"extern reporting: [addRep:[int256,int256,int256]:int256, addReporter:[int256,int256]:int256, faucet:[int256]:int256, getNumberReporters:[int256]:int256, getRepBalance:[int256,int256]:int256, getRepByIndex:[int256,int256]:int256, getReporterID:[int256,int256]:int256, getReputation:[int256]:int256[], getTotalRep:[int256]:int256, hashReport:[int256[],int256]:int256, repIDToIndex:[int256,int256]:int256, setInitialReporters:[int256,int256]:int256, setRep:[int256,int256,int256]:int256, subtractRep:[int256,int256,int256]:int256]",
"REPORTING = 0x08606bc6f0aa9c41bed0ea1747dd567739751102",
"extern cash: [addCash:[int256,int256]:int256, balance:[int256]:int256, faucet:[]:int256, send:[int256,int256]:int256, sendFrom:[int256,int256,int256]:int256, subtractCash:[int256,int256]:int256]",
"CASH = 0x09dfcb6be0b8927518ab930e93518044c71c5a4f",
"extern info: [getCreationFee:[int256]:int256, getCreator:[int256]:int256, getDescription:[int256]:bytes, getDescriptionLength:[int256]:int256, setInfo:[int256,bytes,int256,int256]:int256]",
"INFO = 0x21607adae6f054274a5b7a3970692a31d4bfb896",
"extern payout: [payout:[int256[],int256[],int256[],int256,int256]:int256[]]",
"PAYOUT = 0x0d80452ef8f2a4322d0971447cdf6971b803a5b8",
"",
"def payout(branch, period, num_events, num_reports, flatsize):",
" with smooth_rep = array(num_reports):",
" smooth_rep = slice(EXPIRING.getSmoothRep(branch, period, outitems=num_reports), items=0, items=num_reports)",
" with reports_mask = array(flatsize):",
" reports_mask = slice(EXPIRING.getReportsMask(branch, period, outitems=flatsize), items=0, items=flatsize)",
" with outcomes = array(num_events):",
" outcomes = slice(EXPIRING.getOutcomesFinal(branch, period, outitems=num_events), items=0, items=num_events)",
" with reporter_payouts = array(num_reports):",
" reporter_payouts = slice(PAYOUT.payout(outcomes, smooth_rep, reports_mask, num_reports, num_events, outitems=num_reports), items=0, items=num_reports)",
"",
" # get event ID for each event by taking the x index in the reports arrays",
" # - shoving it in reporting.events[] and getting the corresponding ID",
" with j = 0:",
" while j < num_events:",
" with event = EXPIRING.getEvent(branch, period, j):",
"",
" # then take outcomes_final and set each event outcome",
" # (BAD and BOND macros defined in consensus/constants.se)",
" EVENTS.setOutcome(event, outcomes[j])",
" if outcomes[j] != BAD:",
"",
" # return bond",
" CASH.subtractCash(event, BOND)",
" CASH.addCash(INFO.getCreator(event), BOND)",
" else:",
"",
" # give event bond money to reporters",
" CASH.subtractCash(event, BOND)",
" CASH.addCash(branch, BOND)",
" j += 1",
" # - need to loop through rep holders and distribute 50% of branch fees to",
" # reporters' cashcoin addresses",
" # - also need to take reporter_payouts and redistribute reputation in the",
" # Reporting structure accordingly",
" EXPIRING.setReporterPayouts(branch, period, reporter_payouts)",
" with i = 0:",
" while i < num_reports:",
" REPORTING.setRep(branch, i, fixed_multiply(reporter_payouts[i], EXPIRING.getTotalReputation(branch, period)))",
" CASH.addCash(REPORTING.getReporterID(branch, i), fixed_multiply(CASH.balance(branch), reporter_payouts[i]))",
" i += 1",
" CASH.subtractCash(branch, CASH.balance(branch))",
" return(1)",
"",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')",
"inset('../../macros/arrays.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "payout(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern redeem_payout: [payout:[int256,int256,int256,int256,int256]:int256]"
},
"redeem_resolve": {
"address": "0x4a61f3db785f1e2a23ffefeafaceeef2df551667",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Joey Krug ([email protected]) or",
"# Jack Peterson ([email protected]).",
"",
"extern events: [getEventBranch:[int256]:int256, getEventInfo:[int256]:int256[], getExpiration:[int256]:int256, getMaxValue:[int256]:int256, getMinValue:[int256]:int256, getNumOutcomes:[int256]:int256, getOutcome:[int256]:int256, initializeEvent:[int256,int256,int256,int256,int256,int256]:int256, setOutcome:[int256,int256]:int256]",
"EVENTS = 0xb48e92dfcae19d6962c6dd000f67a7a26ee7e8e6",
"extern expiringEvents: [addEvent:[int256,int256,int256]:int256, getAdjPrinComp:[int256,int256]:int256[], getCovarianceMatrixRow:[int256,int256]:int256[], getDeflated:[int256,int256]:int256[], getEvent:[int256,int256,int256]:int256, getEvents:[int256,int256]:int256[], getLatent:[int256,int256]:int256, getLoadingVector:[int256,int256]:int256[], getNewOne:[int256,int256]:int256[], getNewTwo:[int256,int256]:int256[], getNumberEvents:[int256,int256]:int256, getOutcomesFinal:[int256,int256]:int256[], getReport:[int256,int256,int256,int256]:int256, getReportHash:[int256,int256,int256]:int256, getReporterBallot:[int256,int256,int256]:int256[], getReporterPayouts:[int256,int256]:int256[], getReportsFilled:[int256,int256]:int256[], getReportsMask:[int256,int256]:int256[], getScores:[int256,int256]:int256[], getSetOne:[int256,int256]:int256[], getSetTwo:[int256,int256]:int256[], getSmoothRep:[int256,int256]:int256[], getTotalRepReported:[int256,int256]:int256, getTotalReputation:[int256,int256]:int256, getVSize:[int256,int256]:int256, getWeightedCenteredData:[int256,int256]:int256[], moveEventsToCurrentPeriod:[int256,int256,int256]:int256, returnOld:[int256,int256]:int256[], setAdjPrinComp:[int256,int256,int256[]]:int256, setCovarianceMatrixRow:[int256,int256,int256[]]:int256, setDeflated:[int256,int256,int256[]]:int256, setLatent:[int256,int256,int256]:int256, setLoadingVector:[int256,int256,int256[]]:int256, setNewOne:[int256,int256,int256[]]:int256, setNewTwo:[int256,int256,int256[]]:int256, setOld:[int256,int256,int256[]]:int256, setOutcomesFinal:[int256,int256,int256[]]:int256, setReportHash:[int256,int256,int256,int256]:int256, setReporterBallot:[int256,int256,int256,int256[],int256]:int256, setReporterPayouts:[int256,int256,int256[]]:int256, setReportsFilled:[int256,int256,int256[]]:int256, setReportsMask:[int256,int256,int256[]]:int256, setScores:[int256,int256,int256[]]:int256, setSetOne:[int256,int256,int256[]]:int256, setSetTwo:[int256,int256,int256[]]:int256, setSmoothRep:[int256,int256,int256[]]:int256, setTotalRepReported:[int256,int256,int256]:int256, setTotalReputation:[int256,int256,int256]:int256, setVSize:[int256,int256,int256]:int256, setWeightedCenteredData:[int256,int256,int256[]]:int256]",
"EXPIRING = 0x915f35711d96b400908737bb82129580991f6021",
"extern reporting: [addRep:[int256,int256,int256]:int256, addReporter:[int256,int256]:int256, faucet:[int256]:int256, getNumberReporters:[int256]:int256, getRepBalance:[int256,int256]:int256, getRepByIndex:[int256,int256]:int256, getReporterID:[int256,int256]:int256, getReputation:[int256]:int256[], getTotalRep:[int256]:int256, hashReport:[int256[],int256]:int256, repIDToIndex:[int256,int256]:int256, setInitialReporters:[int256,int256]:int256, setRep:[int256,int256,int256]:int256, subtractRep:[int256,int256,int256]:int256]",
"REPORTING = 0x08606bc6f0aa9c41bed0ea1747dd567739751102",
"extern resolve: [resolve:[int256[],int256[],int256[],int256[],int256[],int256,int256]:int256[], smooth:[int256[],int256[],int256,int256]:int256[]]",
"RESOLVE = 0xbdb19659d24194af3b6cdf4737bf65bd60e0b69a",
"",
"def smooth(branch, period, num_events, num_reports, flatsize):",
" with reputation = array(num_reports):",
" with i = 0:",
" while i < num_reports:",
" reputation[i] = REPORTING.getRepByIndex(branch, i)",
" i += 1",
" with adjusted_scores = array(num_reports):",
" adjusted_scores = slice(EXPIRING.getAdjPrinComp(branch, period, outitems=num_reports), items=0, items=num_reports)",
" with smooth_rep = array(num_reports):",
" smooth_rep = slice(RESOLVE.smooth(adjusted_scores, reputation, num_reports, num_events, outitems=num_reports), items=0, items=num_reports)",
" EXPIRING.setSmoothRep(branch, period, smooth_rep)",
" return(1)",
"",
"def resolve(branch, period, num_events, num_reports, flatsize):",
" with reports_filled = array(flatsize):",
" reports_filled = slice(EXPIRING.getReportsFilled(branch, period, outitems=flatsize), items=0, items=flatsize)",
" with smooth_rep = array(num_reports):",
" smooth_rep = slice(EXPIRING.getSmoothRep(branch, period, outitems=num_reports), items=0, items=num_reports)",
" with scaled = array(num_events):",
" with scaled_max = array(num_events):",
" with scaled_min = array(num_events):",
" with j = 0:",
" while j < num_events:",
" with event = EXPIRING.getEvent(branch, period, j):",
" if fix(EVENTS.getMaxValue(event)) != YES and EVENTS.getNumOutcomes(event) == 2:",
" scaled[j] = 1",
" scaled_min[j] = fix(EVENTS.getMinValue(event))",
" scaled_max[j] = fix(EVENTS.getMaxValue(event))",
" else:",
" scaled[j] = 0",
" scaled_min[j] = NO",
" scaled_max[j] = YES",
" j += 1",
" with outcomes = array(num_events):",
" outcomes = slice(RESOLVE.resolve(smooth_rep, reports_filled, scaled, scaled_max, scaled_min, num_reports, num_events, outitems=num_events), items=0, items=num_events)",
" EXPIRING.setOutcomesFinal(branch, period, outcomes)",
" return(1)",
"",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "resolve(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "smooth(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern redeem_resolve: [resolve:[int256,int256,int256,int256,int256]:int256, smooth:[int256,int256,int256,int256,int256]:int256]"
},
"redeem_score": {
"address": "0xbd19195b9e8a2d8ed14fc3a2823856b5c16f7f55",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Joey Krug ([email protected]) or",
"# Jack Peterson ([email protected]).",
"",
"extern expiringEvents: [addEvent:[int256,int256,int256]:int256, getAdjPrinComp:[int256,int256]:int256[], getCovarianceMatrixRow:[int256,int256]:int256[], getDeflated:[int256,int256]:int256[], getEvent:[int256,int256,int256]:int256, getEvents:[int256,int256]:int256[], getLatent:[int256,int256]:int256, getLoadingVector:[int256,int256]:int256[], getNewOne:[int256,int256]:int256[], getNewTwo:[int256,int256]:int256[], getNumberEvents:[int256,int256]:int256, getOutcomesFinal:[int256,int256]:int256[], getReport:[int256,int256,int256,int256]:int256, getReportHash:[int256,int256,int256]:int256, getReporterBallot:[int256,int256,int256]:int256[], getReporterPayouts:[int256,int256]:int256[], getReportsFilled:[int256,int256]:int256[], getReportsMask:[int256,int256]:int256[], getScores:[int256,int256]:int256[], getSetOne:[int256,int256]:int256[], getSetTwo:[int256,int256]:int256[], getSmoothRep:[int256,int256]:int256[], getTotalRepReported:[int256,int256]:int256, getTotalReputation:[int256,int256]:int256, getVSize:[int256,int256]:int256, getWeightedCenteredData:[int256,int256]:int256[], moveEventsToCurrentPeriod:[int256,int256,int256]:int256, returnOld:[int256,int256]:int256[], setAdjPrinComp:[int256,int256,int256[]]:int256, setCovarianceMatrixRow:[int256,int256,int256[]]:int256, setDeflated:[int256,int256,int256[]]:int256, setLatent:[int256,int256,int256]:int256, setLoadingVector:[int256,int256,int256[]]:int256, setNewOne:[int256,int256,int256[]]:int256, setNewTwo:[int256,int256,int256[]]:int256, setOld:[int256,int256,int256[]]:int256, setOutcomesFinal:[int256,int256,int256[]]:int256, setReportHash:[int256,int256,int256,int256]:int256, setReporterBallot:[int256,int256,int256,int256[],int256]:int256, setReporterPayouts:[int256,int256,int256[]]:int256, setReportsFilled:[int256,int256,int256[]]:int256, setReportsMask:[int256,int256,int256[]]:int256, setScores:[int256,int256,int256[]]:int256, setSetOne:[int256,int256,int256[]]:int256, setSetTwo:[int256,int256,int256[]]:int256, setSmoothRep:[int256,int256,int256[]]:int256, setTotalRepReported:[int256,int256,int256]:int256, setTotalReputation:[int256,int256,int256]:int256, setVSize:[int256,int256,int256]:int256, setWeightedCenteredData:[int256,int256,int256[]]:int256]",
"EXPIRING = 0x915f35711d96b400908737bb82129580991f6021",
"extern reporting: [addRep:[int256,int256,int256]:int256, addReporter:[int256,int256]:int256, faucet:[int256]:int256, getNumberReporters:[int256]:int256, getRepBalance:[int256,int256]:int256, getRepByIndex:[int256,int256]:int256, getReporterID:[int256,int256]:int256, getReputation:[int256]:int256[], getTotalRep:[int256]:int256, hashReport:[int256[],int256]:int256, repIDToIndex:[int256,int256]:int256, setInitialReporters:[int256,int256]:int256, setRep:[int256,int256,int256]:int256, subtractRep:[int256,int256,int256]:int256]",
"REPORTING = 0x08606bc6f0aa9c41bed0ea1747dd567739751102",
"extern branches: [addMarket:[int256,int256]:int256, getBranch:[int256]:int256, getBranches:[]:int256[], getMarkets:[int256]:int256[], getMinTradingFee:[int256]:int256, getNumBranches:[]:int256, getNumMarkets:[int256]:int256, getPeriodLength:[int256]:int256, getStep:[int256]:int256, getSubstep:[int256]:int256, getVotePeriod:[int256]:int256, incrementPeriod:[int256]:int256, incrementStep:[int256]:int256, incrementSubstep:[int256]:int256, initializeBranch:[int256,int256,int256,int256]:int256, setStep:[int256,int256]:int256, setSubstep:[int256,int256]:int256]",
"BRANCHES = 0x552454582fe259c644c191448c66e4fce4306437",
"extern score: [blank:[int256,int256,int256]:int256[], deflate:[int256[],int256[],int256,int256]:int256[], latent:[int256[],int256[],int256]:int256, loadings:[int256[],int256[],int256[],int256,int256]:int256[], score:[int256[],int256[],int256[],int256,int256,int256]:int256[]]",
"SCORE = 0xbbd95558ff1dd01ba9e2f014da65c9394ef0ddea",
"",
"def blank(branch, period, num_events, num_reports, flatsize):",
" # blank",
" # loading vector (eigenvector) has num_events + 2 elements:",
" # - second-to-last element: number of iterations remaining",
" # - last element: number of components (eigenvectors) remaining",
" with ne_plus_2 = num_events + 2:",
" # - if element ne_plus_2 is zero, we're on the first component, so set the last",
" # element equal to MAX_COMPONENTS",
" # - otherwise, decrement the last element",
" with loading_vector = array(ne_plus_2):",
" loading_vector = slice(EXPIRING.getLoadingVector(branch, period, outitems=ne_plus_2), items=0, items=ne_plus_2)",
" if loading_vector[num_events+1] == 0:",
" if num_events >= MAX_COMPONENTS:",
" loading_vector = slice(SCORE.blank(MAX_COMPONENTS-1, MAX_ITERATIONS, num_events, outitems=ne_plus_2), items=0, items=ne_plus_2)",
" else:",
" loading_vector = slice(SCORE.blank(num_events-1, MAX_ITERATIONS, num_events, outitems=ne_plus_2), items=0, items=ne_plus_2)",
" else:",
" loading_vector = slice(SCORE.blank(loading_vector[num_events+1]-1, MAX_ITERATIONS, num_events, outitems=ne_plus_2), items=0, items=ne_plus_2)",
" EXPIRING.setLoadingVector(branch, period, loading_vector)",
" return(1)",
"",
"def loadings(branch, period, num_events, num_reports, flatsize):",
" with ne_plus_2 = num_events + 2:",
" with loading_vector = array(ne_plus_2):",
" loading_vector = slice(EXPIRING.getLoadingVector(branch, period, outitems=ne_plus_2), items=0, items=ne_plus_2)",
" with deflated = array(flatsize):",
" deflated = slice(EXPIRING.getDeflated(branch, period, outitems=flatsize), items=0, items=flatsize)",
" with reputation = array(num_reports):",
" with i = 0:",
" while i < num_reports:",
" reputation[i] = REPORTING.getRepByIndex(branch, i)",
" i += 1",
" # Iteratively diagonalize the weighted centered data matrix,",
" # deflating (subtracting out the eigenvectors) the matrix after each",
" # eigenvector is found",
" loading_vector = slice(SCORE.loadings(loading_vector, deflated, reputation, num_reports, num_events, outitems=ne_plus_2), items=0, items=ne_plus_2)",
" EXPIRING.setLoadingVector(branch, period, loading_vector)",
" if loading_vector[num_events] == 0:",
" return(0)",
" else:",
" return(1)",
"",
"def latent(branch, period, num_events, num_reports, flatsize):",
" with ne_plus_2 = num_events + 2:",
" with loading_vector = array(ne_plus_2):",
" loading_vector = slice(EXPIRING.getLoadingVector(branch, period, outitems=ne_plus_2), items=0, items=ne_plus_2)",
" with covrow = array(num_events):",
" covrow = slice(EXPIRING.getCovarianceMatrixRow(branch, period, outitems=num_events), items=0, items=num_events)",
" with latent = SCORE.latent(covrow, loading_vector, num_events):",
" EXPIRING.setLatent(branch, period, latent)",
" return(1)",
"",
"def deflate(branch, period, num_events, num_reports, flatsize):",
" with ne_plus_2 = num_events + 2:",
" with loading_vector = array(ne_plus_2):",
" loading_vector = slice(EXPIRING.getLoadingVector(branch, period, outitems=ne_plus_2), items=0, items=ne_plus_2)",
" with deflated = array(flatsize):",
" deflated = slice(EXPIRING.getDeflated(branch, period, outitems=flatsize), items=0, items=flatsize)",
" deflated = slice(SCORE.deflate(loading_vector, deflated, num_reports, num_events, outitems=flatsize), items=0, items=flatsize)",
" EXPIRING.setDeflated(branch, period, deflated)",
" return(1)",
"",
"def score(branch, period, num_events, num_reports, flatsize):",
" with ne_plus_2 = num_events + 2:",
" with loading_vector = array(ne_plus_2):",
" loading_vector = slice(EXPIRING.getLoadingVector(branch, period, outitems=ne_plus_2), items=0, items=ne_plus_2)",
" with wcd = array(flatsize):",
" wcd = slice(EXPIRING.getWeightedCenteredData(branch, period, outitems=flatsize), items=0, items=flatsize)",
" with latent = EXPIRING.getLatent(branch, period):",
" with scores = array(num_reports):",
" scores = slice(EXPIRING.getScores(branch, period, outitems=num_reports), items=0, items=num_reports)",
" scores = slice(SCORE.score(scores, loading_vector, wcd, latent, num_reports, num_events, outitems=num_reports), items=0, items=num_reports)",
" EXPIRING.setScores(branch, period, scores)",
" if loading_vector[num_events+1] == 0:",
" return(0)",
" else:",
" return(1)",
"",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "blank(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "deflate(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "latent(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "loadings(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "period",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "flatsize",
"type": "int256"
}
],
"name": "score(int256,int256,int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern redeem_score: [blank:[int256,int256,int256,int256,int256]:int256, deflate:[int256,int256,int256,int256,int256]:int256, latent:[int256,int256,int256,int256,int256]:int256, loadings:[int256,int256,int256,int256,int256]:int256, score:[int256,int256,int256,int256,int256]:int256]"
},
"reporting": {
"address": "0x8caf2c0ce7cdc2e81b58f74322cefdef440b3f8d",
"code": [
"# This software (Augur) allows buying && selling event outcomes in ethereum",
"# Copyright (C) 2015 Forecast Foundation",
"# 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 [email protected]",
"",
"# Reporting index is the branchID",
"# Reporters index is the rep. address",
"# We 0 index reputation so can walk thru for consensus",
"# EventsExpDates index is the currentVotePeriod or in the future if an event expires in the future",
"# RepIDtoIndex returns a reporter's reporters[] index given their reputationID as the key",
"# Events is 0 indexed as well",
"data Reporting[](reputation[](repValue, reporterID), numberReporters, repIDtoIndex[], totalRep)",
"data whitelists[](taken, addresses[])",
"",
"",
"def init():",
" self.Reporting[1010101].repIDtoIndex[tx.origin] = 0",
" self.Reporting[1010101].reputation[0].repValue = 47*2^64",
" self.Reporting[1010101].reputation[0].reporterID = tx.origin",
" self.Reporting[1010101].numberReporters = 1",
" self.Reporting[1010101].totalRep += 47*2^64",
"",
"def checkWhitelist(address):",
" return(self.whitelists[msg.sender].addresses[address])",
"",
"def checkContractWhitelist(contract, address):",
" return(self.whitelists[contract].addresses[address])",
"",
"def setWhitelist(contract, addresses:arr):",
" if self.whitelists[contract].taken:",
" return(text(\"ERROR: you have to vote to change a whitelist\"):str)",
" else:",
" self.whitelists[contract].taken = 1",
" i = 0",
" l = len(addresses)",
" while i <l:",
" address = addresses[i]",
" self.whitelists[contract].addresses[addresses] = 1",
" i += 1",
" return(text(\"SUCCESS\"):str)",
"",
"# @return reputation value",
"def getRepByIndex(branch, repIndex):",
" return(self.Reporting[branch].reputation[repIndex].repValue)",
"",
"# @return reputation value",
"def getRepBalance(branch, address):",
" repIndex = self.Reporting[branch].repIDtoIndex[address]",
" if(repIndex==0 && self.Reporting[branch].reputation[repIndex].reporterID!=address):",
" return(0)",
" return(self.Reporting[branch].reputation[repIndex].repValue)",
"",
"def getReporterID(branch, index):",
" return(self.Reporting[branch].reputation[index].reporterID)",
"",
"def getTotalRep(branch):",
" return(self.Reporting[branch].totalRep)",
"",
"def getNumberReporters(branch):",
" return(self.Reporting[branch].numberReporters)",
"",
"def repIDToIndex(branch, repID):",
" return(self.Reporting[branch].repIDtoIndex[repID])",
"",
"def hashReport(report: arr, salt):",
" hashInfo = array(len(report) + 2)",
" hashInfo[0] = tx.origin",
" hashInfo[1] = salt",
" i = 2",
" while i < (len(report) + 2):",
" hashInfo[i] = report[i-2]",
" i += 1",
" reportHash = sha256(hashInfo, chars=32*len(hashInfo))",
" return(reportHash)",
"",
"# check that msg.sender is one of our function contracts",
"def setInitialReporters(parent, branchID):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" # first vote period won't be until after the current (in this case first) basket of things has expired",
" # if floor(blockNum / periodLength) is say 5 and eventsExpDates[5]",
" # the current vote period should be on things from eventsExpDates 4 (when making a new branch this vote period will just fail quorem, and current vote period will be incrememented)",
" # then once blockNum / periodLength is say 6 and eventsExpDates[6]",
" # votePeriod 4 should close and the currentVotePeriod should be from",
" # eventsExpDates 5 (anyone can call the consensus function for voteperiod 4 at this point)",
" i = 0",
" while i < self.Reporting[parent].numberReporters:",
" reporterID = self.Reporting[parent].reputation[i].reporterID",
" self.Reporting[branchID].reputation[i].reporterID = reporterID",
" self.Reporting[branchID].reputation[i].repValue = self.Reporting[parent].reputation[i].repValue",
" self.Reporting[branchID].repIDtoIndex[reporterID] = i",
" i+=1",
" self.Reporting[branchID].numberReporters = i",
" return(1)",
"",
"def addReporter(branch, sender):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" reporterIndex = self.Reporting[branch].numberReporters",
" self.Reporting[branch].repIDtoIndex[sender] = reporterIndex",
" self.Reporting[branch].reputation[reporterIndex].repValue = 0",
" self.Reporting[branch].reputation[reporterIndex].reporterID = sender",
" self.Reporting[branch].numberReporters += 1",
" return(1)",
"",
"def addRep(branch, index, value):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" self.Reporting[branch].reputation[index].repValue += value",
" return(1)",
"",
"def subtractRep(branch, index, value):",
" #if(!self.whitelist.check(msg.sender)):",
" # return(-1)",
" self.Reporting[branch].reputation[index].repValue -= value",
" return(1)",
"",
"def setRep(branch, index, newRep):",
" #if !self.whitelist.check(msg.sender):",
" # return(-1)",
" oldRep = self.Reporting[branch].reputation[index].repValue",
" self.Reporting[branch].reputation[index].repValue = newRep",
" self.Reporting[branch].totalRep += newRep - oldRep",
" return(1)"
],
"fullsig": [
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "index",
"type": "int256"
},
{
"name": "value",
"type": "int256"
}
],
"name": "addRep(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "sender",
"type": "int256"
}
],
"name": "addReporter(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "contract",
"type": "int256"
},
{
"name": "address",
"type": "int256"
}
],
"name": "checkContractWhitelist(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "address",
"type": "int256"
}
],
"name": "checkWhitelist(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "getNumberReporters(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "address",
"type": "int256"
}
],
"name": "getRepBalance(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "repIndex",
"type": "int256"
}
],
"name": "getRepByIndex(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "index",
"type": "int256"
}
],
"name": "getReporterID(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
}
],
"name": "getTotalRep(int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "report",
"type": "int256[]"
},
{
"name": "salt",
"type": "int256"
}
],
"name": "hashReport(int256[],int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "repID",
"type": "int256"
}
],
"name": "repIDToIndex(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "parent",
"type": "int256"
},
{
"name": "branchID",
"type": "int256"
}
],
"name": "setInitialReporters(int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "index",
"type": "int256"
},
{
"name": "newRep",
"type": "int256"
}
],
"name": "setRep(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "contract",
"type": "int256"
},
{
"name": "addresses",
"type": "int256[]"
}
],
"name": "setWhitelist(int256,int256[])",
"outputs": [
{
"name": "out",
"type": "bytes"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "branch",
"type": "int256"
},
{
"name": "index",
"type": "int256"
},
{
"name": "value",
"type": "int256"
}
],
"name": "subtractRep(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern reporting: [addRep:[int256,int256,int256]:int256, addReporter:[int256,int256]:int256, checkContractWhitelist:[int256,int256]:int256, checkWhitelist:[int256]:int256, getNumberReporters:[int256]:int256, getRepBalance:[int256,int256]:int256, getRepByIndex:[int256,int256]:int256, getReporterID:[int256,int256]:int256, getTotalRep:[int256]:int256, hashReport:[int256[],int256]:int256, repIDToIndex:[int256,int256]:int256, setInitialReporters:[int256,int256]:int256, setRep:[int256,int256,int256]:int256, setWhitelist:[int256,int256[]]:bytes, subtractRep:[int256,int256,int256]:int256]"
},
"resolve": {
"address": "0x8a4e2993a9972ee035453bb5674816fc3a698718",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Jack Peterson ([email protected]).",
"",
"extern statistics: [weighted_median:[int256[],int256[]]:int256]",
"STATISTICS = 0xc9e4983d90f2cd9a83391c19e01f1a37551a4ae8",
"",
"# Absolute value of all array elements",
"macro array_abs($a):",
" with $len = len($a):",
" with $absval = array($len):",
" with $i = 0:",
" while $i < $len:",
" $absval[$i] = abs($a[$i])",
" $i += 1",
" $absval",
"",
"def smooth(adjusted_scores:arr, reputation:arr, num_reports, num_events):",
" # Weighted sum of old and new reputation vectors.",
" # New: row_reward_weighted",
" # Old: reputation",
" reputation = normalize(reputation)",
" with row_reward_weighted = array(num_reports):",
" with i = 0:",
" while i < num_reports:",
" row_reward_weighted[i] = reputation[i]",
" i += 1",
"",
" # Overwrite the inital declaration IFF there wasn't perfect consensus.",
" if maximum(array_abs(adjusted_scores)) != 0:",
" with mean_weight = mean(row_reward_weighted):",
" with i = 0:",
" while i < num_reports:",
" row_reward_weighted[i] = adjusted_scores[i] * row_reward_weighted[i] / mean_weight",
" i += 1",
" row_reward_weighted = normalize(row_reward_weighted)",
" # Freshly-calculated reward (in reputation)",
" # (0.1 is the adjustable parameter \"alpha\", hard-coding it for now)",
" with smooth_rep = array(num_reports):",
" with i = 0:",
" while i < num_reports:",
" smooth_rep[i] = row_reward_weighted[i]/10 + reputation[i]*9/10",
" i += 1",
" smooth_rep = normalize(smooth_rep)",
" return(smooth_rep, items=num_reports)",
"",
"def resolve(smooth_rep:arr, reports:arr, scaled:arr, scaled_max:arr, scaled_min:arr, num_reports, num_events):",
" with two_num_events = 2*num_events:",
" with outcomes_final = array(num_events):",
" # discriminate based on contract type",
" with outcomes_raw = array(num_events):",
" with i = 0:",
" while i < num_events:",
" if scaled[i] == 1:",
" with active_reports = array(num_reports):",
" with j = 0:",
" while j < num_reports:",
" active_reports[j] = reports[i + j*num_events]",
" j += 1",
" outcomes_raw[i] = STATISTICS.weighted_median(active_reports, smooth_rep)",
" else:",
" with j = 0:",
" while j < num_reports:",
" outcomes_raw[i] += fixed_multiply(smooth_rep[j], reports[j*num_events + i])",
" j += 1",
" i += 1",
" with outcomes_adj = array(num_events):",
" with i = 0:",
" while i < num_events:",
" if scaled[i] == 1:",
" outcomes_adj[i] = outcomes_raw[i]",
" else:",
" outcomes_adj[i] = catch(outcomes_raw[i])",
" i += 1",
" with i = 0:",
" while i < num_events:",
" if scaled[i] == 1:",
" outcomes_final[i] = fixed_multiply(outcomes_adj[i], scaled_max[i] - scaled_min[i]) + scaled_min[i]",
" else:",
" outcomes_final[i] = outcomes_adj[i]",
" i += 1",
"",
" with certainty = array(num_events):",
" with i = 0:",
" while i < num_events:",
" with j = 0:",
" while j < num_reports:",
" if abs(reports[i + j*num_events] - outcomes_adj[i]) < 0x1197998:",
" certainty[i] += smooth_rep[j]",
" j += 1",
" i += 1",
" with total = 0:",
" with i = 0:",
" while i < num_events:",
" certainty[i] = abs(certainty[i])",
" total += certainty[i]",
" i += 1",
" return(outcomes_final, items=num_events)",
"",
"#inset('macros/constants.se')",
"#inset('macros/fixed.se')",
"#inset('macros/arrays.se')",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')",
"inset('../../macros/arrays.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "smooth_rep",
"type": "int256[]"
},
{
"name": "reports",
"type": "int256[]"
},
{
"name": "scaled",
"type": "int256[]"
},
{
"name": "scaled_max",
"type": "int256[]"
},
{
"name": "scaled_min",
"type": "int256[]"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "resolve(int256[],int256[],int256[],int256[],int256[],int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "adjusted_scores",
"type": "int256[]"
},
{
"name": "reputation",
"type": "int256[]"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "smooth(int256[],int256[],int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
}
],
"sig": "extern resolve: [resolve:[int256[],int256[],int256[],int256[],int256[],int256,int256]:int256[], smooth:[int256[],int256[],int256,int256]:int256[]]"
},
"score": {
"address": "0xe4714fcbdcdba49629bc408183ef40d120700b8d",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Jack Peterson ([email protected]).",
"",
"# Outer product of vectors",
"macro outer_product($u, $v, $n):",
" with $p = array($n^2):",
" with $i = 0:",
" while $i < $n:",
" with $j = 0:",
" while $j < $n:",
" $p[$i*$n + $j] += fixed_multiply($u[$i], $v[$j])",
" $j += 1",
" $i += 1",
" $p",
"",
"# Flattened fixed-point matrix multiplication",
"macro matrix_multiply($a, $arows, $acols, $b, $brows, $bcols):",
" with $c = array($arows*$bcols):",
" with $i = 0:",
" while $i < $arows:",
" with $j = 0:",
" while $j < $bcols:",
" with $k = 0:",
" while $k < $acols:",
" $c[$i*$bcols + $j] += fixed_multiply($a[$i*$acols + $k], $b[$k*$bcols + $j])",
" $k += 1",
" $j += 1",
" $i += 1",
" $c",
"",
"def blank(components_remaining, max_iterations, num_events):",
" with ne_plus_2 = num_events + 2:",
" with iv = array(ne_plus_2):",
" iv[0] = ONE",
" iv[num_events] = max_iterations",
" iv[num_events + 1] = components_remaining",
" return(iv, items=ne_plus_2)",
"",
"def loadings(iv:arr, X:arr, reputation:arr, num_reports, num_events):",
" # R.dot(wcd).dot(lv).dot(wcd)",
" with lvsize = len(iv):",
" with lv = array(lvsize):",
" with j = 0:",
" while j < num_reports:",
" with d_dot_lv = 0:",
" with k = 0:",
" while k < num_events:",
" d_dot_lv += X[j*num_events + k] * iv[k]",
" k += 1",
" d_dot_lv /= ONE",
" with k = 0:",
" while k < num_events:",
" lv[k] -= d_dot_lv * X[j*num_events + k] * reputation[j] / ONE^2",
" k += 1",
" j += 1",
" # Normalize by length",
" with lv_dot_lv = 0:",
" with j = 0:",
" while j < num_events:",
" lv_dot_lv += lv[j] * lv[j]",
" j += 1",
" lv_dot_lv /= ONE",
" with norm_lv = lv_dot_lv / 2:",
" with j = 0:",
" while j < 11:",
" norm_lv = (norm_lv + fixed_divide(lv_dot_lv, norm_lv)) / 2",
" j += 1",
" with j = 0:",
" while j < num_events:",
" lv[j] = fixed_divide(lv[j], norm_lv)",
" j += 1",
" lv[num_events] = iv[num_events] - 1",
" lv[num_events + 1] = iv[num_events + 1]",
" return(lv, items=lvsize)",
"",
"def latent(covrow:arr, loadings:arr, num_events):",
" with lf = 0:",
" with i = 0:",
" while i < num_events:",
" lf += fixed_multiply(covrow[i], loadings[i])",
" i += 1",
" if loadings[0] != 0:",
" lf = fixed_divide(lf, loadings[0])",
" else:",
" lf = 0",
" return(lf)",
"",
"def deflate(ev:arr, wcd:arr, num_reports, num_events):",
" with dsz = len(wcd):",
" with evop = outer_product(ev, ev, num_events):",
" with ddata = array(dsz):",
" with data_x_evop = matrix_multiply(wcd, num_reports, num_events, evop, num_events, num_events):",
" with i = 0:",
" while i < dsz:",
" ddata[i] = wcd[i] - data_x_evop[i]",
" i += 1",
" return(ddata, items=dsz)",
"",
"def score(scores:arr, lv:arr, wcd:arr, latent, num_reports, num_events):",
" if lv[0] < 0:",
" with j = 0:",
" while j < num_events:",
" lv[j] = -lv[j]",
" j += 1",
" with i = 0:",
" while i < num_reports:",
" with k = 0:",
" while k < num_events:",
" scores[i] += fixed_multiply(wcd[i*num_events + k], latent * lv[k] / ONE)",
" k += 1",
" i += 1",
" return(scores, items=num_reports)",
"",
"inset('../../macros/constants.sm')",
"inset('../../macros/fixed.sm')",
"inset('../../macros/arrays.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "components_remaining",
"type": "int256"
},
{
"name": "max_iterations",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "blank(int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "ev",
"type": "int256[]"
},
{
"name": "wcd",
"type": "int256[]"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "deflate(int256[],int256[],int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "covrow",
"type": "int256[]"
},
{
"name": "loadings",
"type": "int256[]"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "latent(int256[],int256[],int256)",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "iv",
"type": "int256[]"
},
{
"name": "X",
"type": "int256[]"
},
{
"name": "reputation",
"type": "int256[]"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "loadings(int256[],int256[],int256[],int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
},
{
"inputs": [
{
"name": "scores",
"type": "int256[]"
},
{
"name": "lv",
"type": "int256[]"
},
{
"name": "wcd",
"type": "int256[]"
},
{
"name": "latent",
"type": "int256"
},
{
"name": "num_reports",
"type": "int256"
},
{
"name": "num_events",
"type": "int256"
}
],
"name": "score(int256[],int256[],int256[],int256,int256,int256)",
"outputs": [
{
"name": "out",
"type": "int256[]"
}
],
"type": "function"
}
],
"sig": "extern score: [blank:[int256,int256,int256]:int256[], deflate:[int256[],int256[],int256,int256]:int256[], latent:[int256[],int256[],int256]:int256, loadings:[int256[],int256[],int256[],int256,int256]:int256[], score:[int256[],int256[],int256[],int256,int256,int256]:int256[]]"
},
"statistics": {
"address": "0x77c424f86a1b80f1e303d1c2651acd6aba653cb6",
"code": [
"# This software (Augur) allows buying and selling event options in Ethereum.",
"#",
"# Copyright (c) 2015 Forecast Foundation",
"#",
"# This program is free software; you can redistribute it and/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 and/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/>.",
"#",
"# If you have questions, please contact Jack Peterson ([email protected]).",
"",
"macro concat($a, $b):",
" with $c = array(len($a)+len($b)):",
" mcopy($c, $a, chars=32*len($a))",
" mcopy($c+(chars=32*len($a)), $b, chars=32*len($b))",
" $c",
"",
"macro swap($a, $i, $j):",
" with $t = $a[$i]:",
" $a[$i] = $a[$j]",
" $a[$j] = $t",
"",
"# Find index corresponding to the maximum value of an array",
"macro findmax($a):",
" with $len = len($a):",
" with $max = $a[0]:",
" with $maxidx = 0:",
" with $i = 1:",
" while $i < $len:",
" if $a[$i] > $max:",
" $maxval = $a[$i]",
" $maxidx = $i",
" $i += 1",
" $maxidx",
"",
"macro paired_qsort($a, $b):",
" with $len = len($a):",
" with $c = concat($a, $b):",
" with $stack = array($len):",
" with $top = 0:",
" with $h = 0:",
" with $l = 0:",
" with $x = 0:",
" with $i = 0:",
" with $j = 0:",
" $stack[0] = 0",
" $stack[1] = $len - 1",
" $top = 1",
" while $top >= 0:",
" $h = $stack[$top]",
" $l = $stack[$top - 1]",
" $top -= 2",
" $x = $c[$h]",
" $i = $l - 1",
" $j = $l",
"",
" while $j <= $h - 1:",
" if $c[$j] <= $x:",
" $i += 1",
" swap($c, $i, $j)",
" swap($c, $i + $len, $j + $len)",
" $j += 1",
"",
" swap($c, $i+1, $h)",
" swap($c, $i + $len + 1, $h + $len)",
" if $i > $l:",
" $stack[$top + 1] = $l",
" $stack[$top + 2] = $i",
" $top += 2",
" if $i + 2 < $h:",
" $stack[$top + 1] = $i + 2",
" $stack[$top + 2] = $h",
" $top += 2",
" $c",
"",
"# Weighted median of an array",
"macro weighted_median($data, $weights):",
" with n = len($data):",
" with done = 0:",
" with midpoint = sum($weights) / 2:",
" with j = 0:",
" while j < num_present[i]:",
" if $weights[j] > midpoint:",
" with maxidx = findmax($weights):",
" wmedian = $data[maxidx]",
" done = 1",
" j += 1",
" if done == 0:",
" with sorted = paired_qsort($data, $weights):",
" with sorted_data = array(n):",
" with sorted_weights = array(n):",
" with j = 0:",
" while j < n:",
" sorted_data[j] = sorted[j]",
" sorted_weights[j] = sorted[j + n]",
" j += 1",
" with cumulative_weight = 0:",
" with idx = 0:",
" while cumulative_weight <= midpoint:",
" idx += 1",
" cumulative_weight += sorted_weights[idx-1]",
" cumulative_weight -= sorted_weights[idx-1]",
" # conservative machine epsilon:",
" # 0x1197998 = 18446744 = ONE / 10^12",
" if abs(cumulative_weight - midpoint) < 0x1197998:",
" wmedian = (sorted_data[idx-2] + sorted_data[idx-1]) / 2",
" else:",
" wmedian = sorted_data[idx-1]",
" wmedian",
"",
"# Weighted median of an array",
"def weighted_median(data:arr, weights:arr):",
" return(weighted_median(data, weights))",
"",
"inset('../../macros/arrays.sm')"
],
"fullsig": [
{
"inputs": [
{
"name": "data",
"type": "int256[]"
},
{
"name": "weights",
"type": "int256[]"
}
],
"name": "weighted_median(int256[],int256[])",
"outputs": [
{
"name": "out",
"type": "int256"
}
],
"type": "function"
}
],
"sig": "extern statistics: [weighted_median:[int256[],int256[]]:int256]"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment