Skip to content

Commit

Permalink
Merge pull request #563 from AugurProject/integer_types
Browse files Browse the repository at this point in the history
uint8 -> uint256
  • Loading branch information
nuevoalex committed Feb 27, 2018
2 parents 1dbaa43 + 1780f26 commit 3dc92ef
Show file tree
Hide file tree
Showing 37 changed files with 381 additions and 345 deletions.
2 changes: 1 addition & 1 deletion source/contracts/factories/MarketFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'IController.sol';


contract MarketFactory {
function createMarket(IController _controller, IUniverse _universe, uint256 _endTime, uint256 _feePerEthInWei, ICash _denominationToken, address _designatedReporterAddress, address _sender, uint8 _numOutcomes, uint256 _numTicks) public payable returns (IMarket _market) {
function createMarket(IController _controller, IUniverse _universe, uint256 _endTime, uint256 _feePerEthInWei, ICash _denominationToken, address _designatedReporterAddress, address _sender, uint256 _numOutcomes, uint256 _numTicks) public payable returns (IMarket _market) {
Delegator _delegator = new Delegator(_controller, "Market");
_market = IMarket(_delegator);
IReputationToken _reputationToken = _universe.getReputationToken();
Expand Down
2 changes: 1 addition & 1 deletion source/contracts/factories/ShareTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'IController.sol';


contract ShareTokenFactory {
function createShareToken(IController _controller, IMarket _market, uint8 _outcome) public returns (IShareToken) {
function createShareToken(IController _controller, IMarket _market, uint256 _outcome) public returns (IShareToken) {
Delegator _delegator = new Delegator(_controller, "ShareToken");
IShareToken _shareToken = IShareToken(_delegator);
_shareToken.initialize(_market, _outcome);
Expand Down
2 changes: 1 addition & 1 deletion source/contracts/libraries/Extractable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract Extractable is Controlled {

function mayExtract(ERC20Basic _token) private returns (bool) {
address[] memory _protectedTokens = getProtectedTokens();
for (uint8 i = 0; i < _protectedTokens.length; i++) {
for (uint256 i = 0; i < _protectedTokens.length; i++) {
if (_protectedTokens[i] == address(_token)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion source/contracts/reporting/BaseReportingParticipant.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ contract BaseReportingParticipant is Controlled, IReportingParticipant {
return market == IMarket(0) || !market.isContainerForReportingParticipant(this);
}

function getPayoutNumerator(uint8 _outcome) public view returns (uint256) {
function getPayoutNumerator(uint256 _outcome) public view returns (uint256) {
return payoutNumerators[_outcome];
}
}
8 changes: 4 additions & 4 deletions source/contracts/reporting/IMarket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ contract IMarket is ITyped, IOwnable {
SCALAR
}

function initialize(IUniverse _universe, uint256 _endTime, uint256 _feePerEthInAttoeth, ICash _cash, address _designatedReporterAddress, address _creator, uint8 _numOutcomes, uint256 _numTicks) public payable returns (bool _success);
function initialize(IUniverse _universe, uint256 _endTime, uint256 _feePerEthInAttoeth, ICash _cash, address _designatedReporterAddress, address _creator, uint256 _numOutcomes, uint256 _numTicks) public payable returns (bool _success);
function derivePayoutDistributionHash(uint256[] _payoutNumerators, bool _invalid) public view returns (bytes32);
function getUniverse() public view returns (IUniverse);
function getFeeWindow() public view returns (IFeeWindow);
function getNumberOfOutcomes() public view returns (uint8);
function getNumberOfOutcomes() public view returns (uint256);
function getNumTicks() public view returns (uint256);
function getDenominationToken() public view returns (ICash);
function getShareToken(uint8 _outcome) public view returns (IShareToken);
function getShareToken(uint256 _outcome) public view returns (IShareToken);
function getMarketCreatorSettlementFeeDivisor() public view returns (uint256);
function getForkingMarket() public view returns (IMarket _market);
function getEndTime() public view returns (uint256);
function getMarketCreatorMailbox() public view returns (IMailbox);
function getWinningPayoutDistributionHash() public view returns (bytes32);
function getWinningPayoutNumerator(uint8 _outcome) public view returns (uint256);
function getWinningPayoutNumerator(uint256 _outcome) public view returns (uint256);
function getReputationToken() public view returns (IReputationToken);
function getFinalizationTime() public view returns (uint256);
function isContainerForShareToken(IShareToken _shadyTarget) public view returns (bool);
Expand Down
2 changes: 1 addition & 1 deletion source/contracts/reporting/IReportingParticipant.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract IReportingParticipant {
function isInvalid() public view returns (bool);
function isDisavowed() public view returns (bool);
function migrate() public returns (bool);
function getPayoutNumerator(uint8 _outcome) public view returns (uint256);
function getPayoutNumerator(uint256 _outcome) public view returns (uint256);
function getMarket() public view returns (IMarket);
function getSize() public view returns (uint256);
}
42 changes: 21 additions & 21 deletions source/contracts/reporting/Market.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
uint256 private constant MAX_FEE_PER_ETH_IN_ATTOETH = 1 ether / 2;
uint256 private constant APPROVAL_AMOUNT = 2 ** 256 - 1;
address private constant NULL_ADDRESS = address(0);
uint8 private constant MIN_OUTCOMES = 2;
uint8 private constant MAX_OUTCOMES = 8;
uint256 private constant MIN_OUTCOMES = 2;
uint256 private constant MAX_OUTCOMES = 8;

// Contract Refs
IUniverse private universe;
Expand All @@ -46,7 +46,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
uint256 private numTicks;
uint256 private feeDivisor;
uint256 private endTime;
uint8 private numOutcomes;
uint256 private numOutcomes;
bytes32 private winningPayoutDistributionHash;
uint256 private validityBondAttoeth;
uint256 private reporterGasCostsFeeAttoeth;
Expand All @@ -58,7 +58,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
Map public crowdsourcers;
IShareToken[] private shareTokens;

function initialize(IUniverse _universe, uint256 _endTime, uint256 _feePerEthInAttoeth, ICash _cash, address _designatedReporterAddress, address _creator, uint8 _numOutcomes, uint256 _numTicks) public onlyInGoodTimes payable beforeInitialized returns (bool _success) {
function initialize(IUniverse _universe, uint256 _endTime, uint256 _feePerEthInAttoeth, ICash _cash, address _designatedReporterAddress, address _creator, uint256 _numOutcomes, uint256 _numTicks) public onlyInGoodTimes payable beforeInitialized returns (bool _success) {
endInitialization();
require(MIN_OUTCOMES <= _numOutcomes && _numOutcomes <= MAX_OUTCOMES);
require(_numTicks > 0);
Expand All @@ -80,7 +80,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
participants.push(_initialReporterFactory.createInitialReporter(controller, this, _designatedReporterAddress));
marketCreatorMailbox = MailboxFactory(controller.lookup("MailboxFactory")).createMailbox(controller, owner);
crowdsourcers = MapFactory(controller.lookup("MapFactory")).createMap(controller, this);
for (uint8 _outcome = 0; _outcome < numOutcomes; _outcome++) {
for (uint256 _outcome = 0; _outcome < numOutcomes; _outcome++) {
shareTokens.push(createShareToken(_outcome));
}
approveSpenders();
Expand All @@ -99,17 +99,17 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
return true;
}

function createShareToken(uint8 _outcome) private onlyInGoodTimes returns (IShareToken) {
function createShareToken(uint256 _outcome) private onlyInGoodTimes returns (IShareToken) {
return ShareTokenFactory(controller.lookup("ShareTokenFactory")).createShareToken(controller, this, _outcome);
}

// This will need to be called manually for each open market if a spender contract is updated
function approveSpenders() public onlyInGoodTimes returns (bool) {
bytes32[5] memory _names = [bytes32("CancelOrder"), bytes32("CompleteSets"), bytes32("FillOrder"), bytes32("TradingEscapeHatch"), bytes32("ClaimTradingProceeds")];
for (uint8 i = 0; i < _names.length; i++) {
for (uint256 i = 0; i < _names.length; i++) {
cash.approve(controller.lookup(_names[i]), APPROVAL_AMOUNT);
}
for (uint8 j = 0; j < numOutcomes; j++) {
for (uint256 j = 0; j < numOutcomes; j++) {
shareTokens[j].approve(controller.lookup("FillOrder"), APPROVAL_AMOUNT);
}
return true;
Expand Down Expand Up @@ -157,7 +157,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
universe.fork();
} else {
feeWindow = universe.getOrCreateNextFeeWindow();
for (uint8 i = 0; i < participants.length; i++) {
for (uint256 i = 0; i < participants.length; i++) {
participants[i].migrate();
}
}
Expand Down Expand Up @@ -201,7 +201,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
IReportingParticipant _reportingParticipant;

// Initial pass is to liquidate losers so we have sufficient REP to pay the winners
for (uint8 i = 0; i < participants.length; i++) {
for (uint256 i = 0; i < participants.length; i++) {
_reportingParticipant = participants[i];
if (_reportingParticipant.getPayoutDistributionHash() != winningPayoutDistributionHash) {
_reportingParticipant.liquidateLosing();
Expand All @@ -211,7 +211,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
IReputationToken _reputationToken = getReputationToken();

// Now redistribute REP
for (uint8 j = 0; j < participants.length; j++) {
for (uint256 j = 0; j < participants.length; j++) {
_reportingParticipant = participants[j];
if (_reportingParticipant.getPayoutDistributionHash() == winningPayoutDistributionHash) {
_reputationToken.transfer(_reportingParticipant, _reportingParticipant.getSize().div(2));
Expand Down Expand Up @@ -322,15 +322,15 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable

function getTotalStake() public view returns (uint256) {
uint256 _sum;
for (uint8 i = 0; i < participants.length; ++i) {
for (uint256 i = 0; i < participants.length; ++i) {
_sum += participants[i].getStake();
}
return _sum;
}

function getStakeInOutcome(bytes32 _payoutDistributionHash) public view returns (uint256) {
uint256 _sum;
for (uint8 i = 0; i < participants.length; ++i) {
for (uint256 i = 0; i < participants.length; ++i) {
if (participants[i].getPayoutDistributionHash() != _payoutDistributionHash) {
continue;
}
Expand Down Expand Up @@ -384,7 +384,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
return IInitialReporter(participants[0]);
}

function getReportingParticipant(uint8 _index) public view returns (IReportingParticipant) {
function getReportingParticipant(uint256 _index) public view returns (IReportingParticipant) {
return participants[_index];
}

Expand All @@ -396,7 +396,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
return participants[participants.length-1];
}

function getWinningPayoutNumerator(uint8 _outcome) public view returns (uint256) {
function getWinningPayoutNumerator(uint256 _outcome) public view returns (uint256) {
require(isFinalized());
return getWinningReportingParticipant().getPayoutNumerator(_outcome);
}
Expand All @@ -417,7 +417,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
return universe.getReputationToken();
}

function getNumberOfOutcomes() public view returns (uint8) {
function getNumberOfOutcomes() public view returns (uint256) {
return numOutcomes;
}

Expand All @@ -429,7 +429,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
return cash;
}

function getShareToken(uint8 _outcome) public view returns (IShareToken) {
function getShareToken(uint256 _outcome) public view returns (IShareToken) {
return shareTokens[_outcome];
}

Expand All @@ -445,7 +445,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
uint256 _sum = 0;
uint256 _previousValue = _payoutNumerators[0];
require(_payoutNumerators.length == numOutcomes);
for (uint8 i = 0; i < _payoutNumerators.length; i++) {
for (uint256 i = 0; i < _payoutNumerators.length; i++) {
uint256 _value = _payoutNumerators[i];
_sum = _sum.add(_value);
require(!_invalid || _value == _previousValue);
Expand All @@ -463,7 +463,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
if (crowdsourcers.getAsAddressOrZero(_shadyReportingParticipant.getPayoutDistributionHash()) == address(_shadyReportingParticipant)) {
return true;
}
for (uint8 i = 0; i < participants.length; i++) {
for (uint256 i = 0; i < participants.length; i++) {
if (_shadyReportingParticipant == participants[i]) {
return true;
}
Expand All @@ -477,7 +477,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
// Market Open Interest. If we're finalized we need actually calculate the value
if (isFinalized()) {
IReportingParticipant _winningReportingPartcipant = getWinningReportingParticipant();
for (uint8 i = 0; i < numOutcomes; i++) {
for (uint256 i = 0; i < numOutcomes; i++) {
_expectedBalance = _expectedBalance.add(shareTokens[i].totalSupply().mul(_winningReportingPartcipant.getPayoutNumerator(i)));
}
} else {
Expand All @@ -491,7 +491,7 @@ contract Market is DelegationTarget, Extractable, ITyped, Initializable, Ownable
// Markets hold the initial fees paid by the creator in ETH and REP, so we dissallow ETH and REP extraction by the controller
function getProtectedTokens() internal returns (address[] memory) {
address[] memory _protectedTokens = new address[](numOutcomes + 3);
for (uint8 i = 0; i < numOutcomes; i++) {
for (uint256 i = 0; i < numOutcomes; i++) {
_protectedTokens[i] = shareTokens[i];
}
// address(1) is the sentinel value for Ether extraction
Expand Down
2 changes: 1 addition & 1 deletion source/contracts/reporting/Reporting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ library Reporting {
function getDefaultReportingFeeDivisor() internal pure returns (uint256) { return DEFAULT_REPORTING_FEE_DIVISOR; }
function getInitialREPSupply() internal pure returns (uint256) { return INITIAL_REP_SUPPLY; }

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

if (_numOutcomes == 2) {return 10000;}
Expand Down
8 changes: 4 additions & 4 deletions source/contracts/reporting/Universe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv

function createCategoricalMarket(uint256 _endTime, uint256 _feePerEthInWei, ICash _denominationToken, address _designatedReporterAddress, bytes32[] _outcomes, bytes32 _topic, string _description, string _extraInfo) public onlyInGoodTimes afterInitialized payable returns (IMarket _newMarket) {
require(bytes(_description).length > 0);
_newMarket = createMarketInternal(_endTime, _feePerEthInWei, _denominationToken, _designatedReporterAddress, msg.sender, uint8(_outcomes.length), Reporting.getCategoricalMarketNumTicks(uint8(_outcomes.length)));
_newMarket = createMarketInternal(_endTime, _feePerEthInWei, _denominationToken, _designatedReporterAddress, msg.sender, uint256(_outcomes.length), Reporting.getCategoricalMarketNumTicks(uint256(_outcomes.length)));
controller.getAugur().logMarketCreated(_topic, _description, _extraInfo, this, _newMarket, msg.sender, _outcomes, 0, 1 ether, IMarket.MarketType.CATEGORICAL);
return _newMarket;
}
Expand All @@ -457,7 +457,7 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv
return _newMarket;
}

function createMarketInternal(uint256 _endTime, uint256 _feePerEthInWei, ICash _denominationToken, address _designatedReporterAddress, address _sender, uint8 _numOutcomes, uint256 _numTicks) private onlyInGoodTimes afterInitialized returns (IMarket _newMarket) {
function createMarketInternal(uint256 _endTime, uint256 _feePerEthInWei, ICash _denominationToken, address _designatedReporterAddress, address _sender, uint256 _numOutcomes, uint256 _numTicks) private onlyInGoodTimes afterInitialized returns (IMarket _newMarket) {
MarketFactory _marketFactory = MarketFactory(controller.lookup("MarketFactory"));
getReputationToken().trustedUniverseTransfer(_sender, _marketFactory, getOrCacheDesignatedReportNoShowBond());
_newMarket = _marketFactory.createMarket.value(msg.value)(controller, this, _endTime, _feePerEthInWei, _denominationToken, _designatedReporterAddress, _sender, _numOutcomes, _numTicks);
Expand All @@ -466,11 +466,11 @@ contract Universe is DelegationTarget, Extractable, ITyped, Initializable, IUniv
}

function redeemStake(IReportingParticipant[] _reportingParticipants, IFeeWindow[] _feeWindows) public onlyInGoodTimes returns (bool) {
for (uint8 i=0; i < _reportingParticipants.length; i++) {
for (uint256 i=0; i < _reportingParticipants.length; i++) {
_reportingParticipants[i].redeem(msg.sender);
}

for (uint8 k=0; k < _feeWindows.length; k++) {
for (uint256 k=0; k < _feeWindows.length; k++) {
_feeWindows[k].redeem(msg.sender);
}

Expand Down
6 changes: 3 additions & 3 deletions source/contracts/trading/CancelOrder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract CancelOrder is CashAutoConverter, Extractable, ReentrancyGuard, MarketV
uint256 _sharesEscrowed = _orders.getOrderSharesEscrowed(_orderId);
Order.Types _type = _orders.getOrderType(_orderId);
IMarket _market = _orders.getMarket(_orderId);
uint8 _outcome = _orders.getOutcome(_orderId);
uint256 _outcome = _orders.getOutcome(_orderId);

// Check that the order ID is correct and that the sender owns the order
require(msg.sender == _orders.getOrderCreator(_orderId));
Expand All @@ -55,11 +55,11 @@ contract CancelOrder is CashAutoConverter, Extractable, ReentrancyGuard, MarketV
/**
* @dev Issue refunds
*/
function refundOrder(address _sender, Order.Types _type, uint256 _sharesEscrowed, uint256 _moneyEscrowed, IMarket _market, uint8 _outcome) private returns (bool) {
function refundOrder(address _sender, Order.Types _type, uint256 _sharesEscrowed, uint256 _moneyEscrowed, IMarket _market, uint256 _outcome) private returns (bool) {
if (_sharesEscrowed > 0) {
// Return to user sharesEscrowed that weren't filled yet for all outcomes except the order outcome
if (_type == Order.Types.Bid) {
for (uint8 _i = 0; _i < _market.getNumberOfOutcomes(); ++_i) {
for (uint256 _i = 0; _i < _market.getNumberOfOutcomes(); ++_i) {
if (_i != _outcome) {
_market.getShareToken(_i).trustedCancelOrderTransfer(_market, _sender, _sharesEscrowed);
}
Expand Down
Loading

0 comments on commit 3dc92ef

Please sign in to comment.