Skip to content

Commit 44b757f

Browse files
authored
Merge pull request #512 from AugurProject/universe_changes
Universe changes
2 parents b58d960 + e91537c commit 44b757f

File tree

13 files changed

+210
-81
lines changed

13 files changed

+210
-81
lines changed

source/contracts/reporting/BaseReportingParticipant.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ contract BaseReportingParticipant is Controlled, IReportingParticipant {
3434

3535
function fork() public onlyInGoodTimes returns (bool) {
3636
require(market == market.getUniverse().getForkingMarket());
37-
IUniverse _newUniverse = market.getUniverse().createChildUniverse(payoutDistributionHash);
37+
IUniverse _newUniverse = market.getUniverse().createChildUniverse(payoutNumerators, invalid);
3838
IReputationToken _newReputationToken = _newUniverse.getReputationToken();
3939
redeemForAllFeeWindows();
4040
uint256 _balance = reputationToken.balanceOf(this);

source/contracts/reporting/IReputationToken.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ contract IReputationToken is ITyped, ERC20 {
1414
function trustedFeeWindowTransfer(address _source, address _destination, uint256 _attotokens) public returns (bool);
1515
function trustedUniverseTransfer(address _source, address _destination, uint256 _attotokens) public returns (bool);
1616
function getUniverse() public view returns (IUniverse);
17+
function getTotalMigrated() public view returns (uint256);
18+
function getTotalTheoreticalSupply() public view returns (uint256);
1719
function mintForReportingParticipant(uint256 _amountMigrated) public returns (bool);
1820
}

source/contracts/reporting/IUniverse.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ contract IUniverse is ITyped {
1515
function initialize(IUniverse _parentUniverse, bytes32 _parentPayoutDistributionHash) external returns (bool);
1616
function fork() public returns (bool);
1717
function getParentUniverse() public view returns (IUniverse);
18-
function createChildUniverse(bytes32 _parentPayoutDistributionHash) public returns (IUniverse);
18+
function createChildUniverse(uint256[] _parentPayoutNumerators, bool _invalid) public returns (IUniverse);
1919
function getChildUniverse(bytes32 _parentPayoutDistributionHash) public view returns (IUniverse);
2020
function getReputationToken() public view returns (IReputationToken);
2121
function getForkingMarket() public view returns (IMarket);
@@ -34,12 +34,15 @@ contract IUniverse is ITyped {
3434
function getOrCacheDesignatedReportStake() public returns (uint256);
3535
function getOrCacheDesignatedReportNoShowBond() public returns (uint256);
3636
function getOrCacheReportingFeeDivisor() public returns (uint256);
37+
function getDisputeThresholdForFork() public view returns (uint256);
38+
function getInitialReportMinValue() public view returns (uint256);
3739
function calculateFloatingValue(uint256 _badMarkets, uint256 _totalMarkets, uint256 _targetDivisor, uint256 _previousValue, uint256 _defaultValue, uint256 _floor) public pure returns (uint256 _newValue);
3840
function getOrCacheTargetReporterGasCosts() public returns (uint256);
3941
function getOrCacheMarketCreationCost() public returns (uint256);
4042
function getCurrentFeeWindow() public view returns (IFeeWindow);
4143
function getOrCreateFeeWindowBefore(IFeeWindow _feeWindow) public returns (IFeeWindow);
4244
function isParentOf(IUniverse _shadyChild) public view returns (bool);
45+
function updateTentativeWinningChildUniverse(bytes32 _parentPayoutDistributionHash) public returns (bool);
4346
function isContainerForFeeWindow(IFeeWindow _shadyTarget) public view returns (bool);
4447
function isContainerForMarket(IMarket _shadyTarget) public view returns (bool);
4548
function isContainerForReportingParticipant(IReportingParticipant _reportingParticipant) public view returns (bool);

source/contracts/reporting/Market.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
154154
participants.push(_reportingParticipant);
155155
crowdsourcers = MapFactory(controller.lookup("MapFactory")).createMap(controller, this); // disavow other crowdsourcers
156156
controller.getAugur().logDisputeCrowdsourcerCompleted(universe, this, _reportingParticipant);
157-
if (IDisputeCrowdsourcer(msg.sender).getSize() >= Reporting.getDisputeThresholdForFork()) {
157+
if (IDisputeCrowdsourcer(msg.sender).getSize() >= universe.getDisputeThresholdForFork()) {
158158
universe.fork();
159159
} else {
160160
feeWindow = universe.getOrCreateNextFeeWindow();

source/contracts/reporting/Reporting.sol

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ library Reporting {
88
uint256 private constant FORK_DURATION_SECONDS = 60 days;
99

1010
uint256 private constant INITIAL_REP_SUPPLY = 11 * 10 ** 6 * 10 ** 18; // 11 Million REP
11-
// CONSIDER: Should this be a constant?
12-
uint256 private constant DISPUTE_THRESHOLD_FOR_FORK = INITIAL_REP_SUPPLY / 80; // 1.25% of the REP total supply
13-
uint256 private constant INITIAL_REPORT_MIN_VALUE = 175 * 10**15; // This value will result in a maximum 20 round dispute sequence
14-
uint256 private constant DEFAULT_DESIGNATED_REPORT_STAKE = INITIAL_REPORT_MIN_VALUE;
15-
uint256 private constant DESIGNATED_REPORT_STAKE_FLOOR = INITIAL_REPORT_MIN_VALUE;
16-
uint256 private constant DEFAULT_DESIGNATED_REPORT_NO_SHOW_BOND = INITIAL_REPORT_MIN_VALUE;
17-
uint256 private constant DESIGNATED_REPORT_NO_SHOW_BOND_FLOOR = INITIAL_REPORT_MIN_VALUE;
11+
1812
uint256 private constant DEFAULT_VALIDITY_BOND = 1 ether / 100;
1913
uint256 private constant VALIDITY_BOND_FLOOR = 1 ether / 100;
2014
uint256 private constant DEFAULT_REPORTING_FEE_DIVISOR = 100; // 1% fees
@@ -31,7 +25,6 @@ library Reporting {
3125
uint256 private constant TARGET_REP_MARKET_CAP_MULTIPLIER = 5;
3226

3327
uint256 private constant FORK_MIGRATION_PERCENTAGE_BONUS_DIVISOR = 20; // 5% bonus to any REP migrated during a fork
34-
uint256 private constant FORK_REP_MIGRATION_VICTORY_DIVISOR = 2; // 50% of the REP supply in the forking universe has to migrate for a victory
3528

3629
function getDesignatedReportingDurationSeconds() internal pure returns (uint256) { return DESIGNATED_REPORTING_DURATION_SECONDS; }
3730
function getDisputeRoundDurationSeconds() internal pure returns (uint256) { return DISPUTE_ROUND_DURATION_SECONDS; }
@@ -40,22 +33,16 @@ library Reporting {
4033
function getGasToReport() internal pure returns (uint256) { return GAS_TO_REPORT; }
4134
function getDefaultReportingGasPrice() internal pure returns (uint256) { return DEFAULT_REPORTING_GAS_PRICE; }
4235
function getDefaultValidityBond() internal pure returns (uint256) { return DEFAULT_VALIDITY_BOND; }
43-
function getDefaultDesignatedReportStake() internal pure returns (uint256) { return DEFAULT_DESIGNATED_REPORT_STAKE; }
44-
function getDefaultDesignatedReportNoShowBond() internal pure returns (uint256) { return DEFAULT_DESIGNATED_REPORT_NO_SHOW_BOND; }
4536
function getValidityBondFloor() internal pure returns (uint256) { return VALIDITY_BOND_FLOOR; }
46-
function getDesignatedReportStakeFloor() internal pure returns (uint256) { return DESIGNATED_REPORT_STAKE_FLOOR; }
47-
function getDesignatedReportNoShowBondFloor() internal pure returns (uint256) { return DESIGNATED_REPORT_NO_SHOW_BOND_FLOOR; }
4837
function getTargetInvalidMarketsDivisor() internal pure returns (uint256) { return TARGET_INVALID_MARKETS_DIVISOR; }
4938
function getTargetIncorrectDesignatedReportMarketsDivisor() internal pure returns (uint256) { return TARGET_INCORRECT_DESIGNATED_REPORT_MARKETS_DIVISOR; }
5039
function getTargetDesignatedReportNoShowsDivisor() internal pure returns (uint256) { return TARGET_DESIGNATED_REPORT_NO_SHOWS_DIVISOR; }
5140
function getTargetRepMarketCapMultiplier() internal pure returns (uint256) { return TARGET_REP_MARKET_CAP_MULTIPLIER; }
5241
function getForkMigrationPercentageBonusDivisor() internal pure returns (uint256) { return FORK_MIGRATION_PERCENTAGE_BONUS_DIVISOR; }
53-
function getForkRepMigrationVictoryDivisor() internal pure returns (uint256) { return FORK_REP_MIGRATION_VICTORY_DIVISOR; }
5442
function getMaximumReportingFeeDivisor() internal pure returns (uint256) { return MAXIMUM_REPORTING_FEE_DIVISOR; }
5543
function getMinimumReportingFeeDivisor() internal pure returns (uint256) { return MINIMUM_REPORTING_FEE_DIVISOR; }
5644
function getDefaultReportingFeeDivisor() internal pure returns (uint256) { return DEFAULT_REPORTING_FEE_DIVISOR; }
5745
function getInitialREPSupply() internal pure returns (uint256) { return INITIAL_REP_SUPPLY; }
58-
function getDisputeThresholdForFork() internal pure returns (uint256) { return DISPUTE_THRESHOLD_FOR_FORK; }
5946

6047
function getCategoricalMarketNumTicks(uint8 _numOutcomes) internal pure returns (uint256) {
6148
require(_numOutcomes >= 2 && _numOutcomes <= 8);

source/contracts/reporting/ReputationToken.sol

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ contract ReputationToken is DelegationTarget, Extractable, ITyped, Initializable
2222
string constant public symbol = "REP";
2323
uint256 constant public decimals = 18;
2424
IUniverse private universe;
25+
uint256 private totalMigrated;
26+
mapping(address => uint256) migratedToSibling;
27+
uint256 private parentTotalTheoreticalSupply;
28+
uint256 private totalTheoreticalSupply;
2529

2630
function initialize(IUniverse _universe) public onlyInGoodTimes beforeInitialized returns (bool) {
2731
endInitialization();
2832
require(_universe != address(0));
2933
universe = _universe;
34+
updateParentTotalTheoreticalSupply();
3035
return true;
3136
}
3237

@@ -42,12 +47,13 @@ contract ReputationToken is DelegationTarget, Extractable, ITyped, Initializable
4247
IUniverse _parentUniverse = universe.getParentUniverse();
4348
require(ReputationToken(msg.sender) == _parentUniverse.getReputationToken());
4449
mint(_reporter, _attotokens);
45-
// Award a bonus if migration is done before the fork has resolved and check if the fork can be resolved early
50+
totalMigrated += _attotokens;
51+
// Award a bonus if migration is done before the fork has resolved and update the universe tentative winner tracking
4652
if (!_parentUniverse.getForkingMarket().isFinalized()) {
47-
mint(_reporter, _attotokens.div(Reporting.getForkMigrationPercentageBonusDivisor()));
48-
if (supply > _parentUniverse.getForkReputationGoal()) {
49-
_parentUniverse.getForkingMarket().finalizeFork();
50-
}
53+
uint256 _bonus = _attotokens.div(Reporting.getForkMigrationPercentageBonusDivisor());
54+
mint(_reporter, _bonus);
55+
totalTheoreticalSupply += _bonus;
56+
_parentUniverse.updateTentativeWinningChildUniverse(universe.getParentPayoutDistributionHash());
5157
}
5258
return true;
5359
}
@@ -64,7 +70,9 @@ contract ReputationToken is DelegationTarget, Extractable, ITyped, Initializable
6470
IUniverse _parentUniverse = universe.getParentUniverse();
6571
IReportingParticipant _reportingParticipant = IReportingParticipant(msg.sender);
6672
require(_parentUniverse.isContainerForReportingParticipant(_reportingParticipant));
67-
mint(_reportingParticipant, _amountMigrated / 2);
73+
uint256 _bonus = _amountMigrated / 2;
74+
mint(_reportingParticipant, _bonus);
75+
totalTheoreticalSupply += _bonus;
6876
return true;
6977
}
7078

@@ -108,6 +116,36 @@ contract ReputationToken is DelegationTarget, Extractable, ITyped, Initializable
108116
return universe;
109117
}
110118

119+
function getTotalMigrated() public view returns (uint256) {
120+
return totalMigrated;
121+
}
122+
123+
function updateSiblingMigrationTotal(IReputationToken _token) public returns (bool) {
124+
require(_token != this);
125+
IUniverse _supposedUniverse = _token.getUniverse();
126+
require(_token == universe.getParentUniverse().getChildUniverse(_supposedUniverse.getParentPayoutDistributionHash()).getReputationToken());
127+
totalTheoreticalSupply += migratedToSibling[_token];
128+
migratedToSibling[_token] = _token.getTotalMigrated();
129+
totalTheoreticalSupply -= migratedToSibling[_token];
130+
return true;
131+
}
132+
133+
function updateParentTotalTheoreticalSupply() public returns (bool) {
134+
IUniverse _parentUniverse = universe.getParentUniverse();
135+
totalTheoreticalSupply -= parentTotalTheoreticalSupply;
136+
if (_parentUniverse == IUniverse(0)) {
137+
parentTotalTheoreticalSupply = Reporting.getInitialREPSupply();
138+
} else {
139+
parentTotalTheoreticalSupply = _parentUniverse.getReputationToken().getTotalTheoreticalSupply();
140+
}
141+
totalTheoreticalSupply += parentTotalTheoreticalSupply;
142+
return true;
143+
}
144+
145+
function getTotalTheoreticalSupply() public view returns (uint256) {
146+
return totalTheoreticalSupply;
147+
}
148+
111149
function onTokenTransfer(address _from, address _to, uint256 _value) internal returns (bool) {
112150
controller.getAugur().logReputationTokensTransferred(universe, _from, _to, _value);
113151
return true;

0 commit comments

Comments
 (0)