Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
SportPositionalMarketMastercopy
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Inheritance import "./SportPositionalMarket.sol"; contract SportPositionalMarketMastercopy is SportPositionalMarket { constructor() OwnedWithInit() { // Freeze mastercopy on deployment so it can never be initialized with real arguments initialized = true; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Inheritance import "../../OwnedWithInit.sol"; import "../../interfaces/ISportPositionalMarket.sol"; import "../../interfaces/ITherundownConsumer.sol"; import "../../interfaces/ISportsAMM.sol"; import "../../interfaces/ISportPositionalMarketFactory.sol"; // Libraries import "@openzeppelin/contracts-4.4.1/utils/math/SafeMath.sol"; // Internal references import "./SportPositionalMarketManager.sol"; import "./SportPosition.sol"; import "@openzeppelin/contracts-4.4.1/token/ERC20/IERC20.sol"; contract SportPositionalMarket is OwnedWithInit, ISportPositionalMarket { /* ========== LIBRARIES ========== */ using SafeMath for uint; /* ========== TYPES ========== */ struct Options { SportPosition home; SportPosition away; SportPosition draw; } struct Times { uint maturity; uint expiry; } struct GameDetails { bytes32 gameId; string gameLabel; } struct SportPositionalMarketParameters { address owner; address creator; bytes32 gameId; string gameLabel; uint[2] times; // [maturity, expiry] uint positionCount; address[] positions; uint[] tags; bool isChild; address parentMarket; bool isDoubleChance; address factory; } /* ========== STATE VARIABLES ========== */ Options public options; uint public override optionsCount; Times public parentTimes; GameDetails private gameDetails; string private childGameLabel; uint[] public override tags; uint public finalResult; // `deposited` tracks the sum of all deposits. // This must explicitly be kept, in case tokens are transferred to the contract directly. uint public override deposited; address public override creator; bool public override resolved; bool public override cancelled; uint public cancelTimestamp; uint public homeOddsOnCancellation; uint public awayOddsOnCancellation; uint public drawOddsOnCancellation; bool public invalidOdds; bool public initialized = false; bool public override paused; bool public override isChild; ISportPositionalMarket public override parentMarket; bool public override isDoubleChance; bool public override optionsInitialized; address public factory; /* ========== CONSTRUCTOR ========== */ function initialize(SportPositionalMarketParameters calldata _parameters) external { require(!initialized, "Positional Market already initialized"); initialized = true; initOwner(_parameters.owner); optionsCount = _parameters.positionCount; require(optionsCount == _parameters.positions.length, "Position count mismatch"); creator = _parameters.creator; if (_parameters.isChild || _parameters.isDoubleChance) { isChild = _parameters.isChild; isDoubleChance = _parameters.isDoubleChance; parentMarket = ISportPositionalMarket(_parameters.parentMarket); childGameLabel = _parameters.gameLabel; } else { parentTimes = Times(_parameters.times[0], _parameters.times[1]); gameDetails = GameDetails(_parameters.gameId, _parameters.gameLabel); } tags = _parameters.tags; factory = _parameters.factory; } /* ---------- External Contracts ---------- */ function _manager() internal view returns (SportPositionalMarketManager) { return SportPositionalMarketManager(owner); } /* ---------- Phases ---------- */ function _times() internal view returns (Times memory) { if (isChild || isDoubleChance) { (uint maturity, uint expiry) = parentMarket.times(); return Times(maturity, expiry); } return parentTimes; } function _matured() internal view returns (bool) { return _times().maturity < block.timestamp; } function _expired() internal view returns (bool) { return resolved && (_times().expiry < block.timestamp || deposited == 0); } function _isPaused() internal view returns (bool) { return isDoubleChance ? parentMarket.paused() : paused; } function getTags() external view override returns (uint tag1, uint tag2) { if (tags.length > 1) { tag1 = tags[0]; tag2 = tags[1]; } else { tag1 = tags[0]; } } function getTagsLength() external view override returns (uint tagsLength) { return tags.length; } function times() external view override returns (uint maturity, uint destruction) { Times memory time = _times(); return (time.maturity, time.expiry); } function phase() external view override returns (Phase) { if (!_matured()) { return Phase.Trading; } if (!_expired()) { return Phase.Maturity; } return Phase.Expiry; } function setPaused(bool _paused) external override onlyOwner managerNotPaused { require(paused != _paused, "State not changed"); paused = _paused; emit PauseUpdated(_paused); } function updateDates(uint256 _maturity, uint256 _expiry) external override onlyOwner managerNotPaused noDoubleChance { require(_maturity > block.timestamp, "Maturity must be in a future"); if (!isChild) { parentTimes = Times(_maturity, _expiry); } emit DatesUpdated(_maturity, _expiry); } /* ---------- Market Resolution ---------- */ function canResolve() public view override returns (bool) { return !resolved && _matured() && !paused; } function getGameDetails() external view override returns (bytes32 gameId, string memory gameLabel) { return (_getDetails().gameId, _getDetails().gameLabel); } function getParentMarketPositionsUint() public view override returns (uint position1, uint position2) { if (isDoubleChance) { (IPosition home, , ) = parentMarket.getOptions(); if (_hasNotBeenInitialized(home)) { if ( keccak256(abi.encodePacked(_getDetails().gameLabel)) == keccak256(abi.encodePacked("HomeTeamNotToLose")) ) { (position1, position2) = (0, 2); } else if ( keccak256(abi.encodePacked(_getDetails().gameLabel)) == keccak256(abi.encodePacked("AwayTeamNotToLose")) ) { (position1, position2) = (1, 2); } else { (position1, position2) = (0, 1); } } } } function getParentMarketPositions() public view override returns (IPosition position1, IPosition position2) { if (isDoubleChance) { (IPosition home, IPosition away, IPosition draw) = parentMarket.getOptions(); if (keccak256(abi.encodePacked(_getDetails().gameLabel)) == keccak256(abi.encodePacked("HomeTeamNotToLose"))) { (position1, position2) = (home, draw); } else if ( keccak256(abi.encodePacked(_getDetails().gameLabel)) == keccak256(abi.encodePacked("AwayTeamNotToLose")) ) { (position1, position2) = (away, draw); } else { (position1, position2) = (home, away); } } } function _result() internal view returns (Side) { if (!resolved || cancelled) { return Side.Cancelled; } else if (finalResult == 3 && optionsCount > 2) { return Side.Draw; } else { return finalResult == 1 ? Side.Home : Side.Away; } } function result() external view override returns (Side) { return _result(); } /* ---------- Option Balances and Mints ---------- */ function getGameId() external view override returns (bytes32) { return _getDetails().gameId; } function getStampedOdds() public view override returns ( uint, uint, uint ) { if (cancelled) { if (isDoubleChance) { (uint position1Odds, uint position2Odds) = _getParentPositionOdds(); return (position1Odds + position2Odds, 0, 0); } return (homeOddsOnCancellation, awayOddsOnCancellation, drawOddsOnCancellation); } else { return (0, 0, 0); } } function _getParentPositionOdds() internal view returns (uint odds1, uint odds2) { (uint homeOddsParent, uint awayOddsParent, uint drawOddsParent) = parentMarket.getStampedOdds(); (IPosition position1, IPosition position2) = getParentMarketPositions(); (IPosition home, IPosition away, ) = parentMarket.getOptions(); if (_hasNotBeenInitialized(home)) { return (0, 0); } odds1 = position1 == home ? homeOddsParent : position1 == away ? awayOddsParent : drawOddsParent; odds2 = position2 == home ? homeOddsParent : position2 == away ? awayOddsParent : drawOddsParent; } function _balancesOf(address account) internal view returns ( uint home, uint away, uint draw ) { if (!optionsInitialized) { return (0, 0, 0); } if (optionsCount > 2) { return ( options.home.getBalanceOf(account), options.away.getBalanceOf(account), options.draw.getBalanceOf(account) ); } return (options.home.getBalanceOf(account), options.away.getBalanceOf(account), 0); } function balancesOf(address account) external view override returns ( uint home, uint away, uint draw ) { return _balancesOf(account); } function totalSupplies() external view override returns ( uint home, uint away, uint draw ) { if (optionsCount > 2) { return (options.home.totalSupply(), options.away.totalSupply(), options.draw.totalSupply()); } return (options.home.totalSupply(), options.away.totalSupply(), 0); } function getOptions() external view override returns ( IPosition home, IPosition away, IPosition draw ) { home = options.home; away = options.away; draw = options.draw; } function _getMaximumBurnable(address account) internal view returns (uint amount) { (uint homeBalance, uint awayBalance, uint drawBalance) = _balancesOf(account); uint min = homeBalance; if (min > awayBalance) { min = awayBalance; if (optionsCount > 2 && drawBalance < min) { min = drawBalance; } } else { if (optionsCount > 2 && drawBalance < min) { min = drawBalance; } } return min; } function _getDetails() internal view returns (GameDetails memory) { if (isChild || isDoubleChance) { (bytes32 gameId, ) = parentMarket.getGameDetails(); return GameDetails(gameId, childGameLabel); } return gameDetails; } /* ---------- Utilities ---------- */ function _incrementDeposited(uint value) internal returns (uint _deposited) { _deposited = deposited.add(value); deposited = _deposited; _manager().incrementTotalDeposited(value); } function _decrementDeposited(uint value) internal returns (uint _deposited) { _deposited = deposited.sub(value); deposited = _deposited; _manager().decrementTotalDeposited(value); } function _requireManagerNotPaused() internal view { require(!_manager().paused(), "This action cannot be performed while the contract is paused"); } function requireUnpaused() external view { _requireManagerNotPaused(); } /* ========== MUTATIVE FUNCTIONS ========== */ /* ---------- Minting ---------- */ function mint(uint value) external override { require(!_matured() && !_isPaused(), "Minting inactive"); require(msg.sender == ISportPositionalMarketFactory(factory).sportsAMM(), "Invalid minter"); if (value == 0) { return; } _mint(msg.sender, value); if (!isDoubleChance) { _incrementDeposited(value); _manager().transferSusdTo(msg.sender, address(this), value); } } function _mint(address minter, uint amount) internal { if (!optionsInitialized) { _initializeOptions(); } if (isDoubleChance) { options.home.mint(minter, amount); emit Mint(Side.Home, minter, amount); } else { options.home.mint(minter, amount); options.away.mint(minter, amount); emit Mint(Side.Home, minter, amount); emit Mint(Side.Away, minter, amount); if (optionsCount > 2) { options.draw.mint(minter, amount); emit Mint(Side.Draw, minter, amount); } } } function initializeOptions() external override { _initializeOptions(); } function _initializeOptions() internal { require(!optionsInitialized, "already initialized"); address[] memory positions = new address[](optionsCount); for (uint i = 0; i < optionsCount; i++) { positions[i] = address(SportPosition(Clones.clone(ISportPositionalMarketFactory(factory).positionMastercopy()))); } // Instantiate the options themselves options.home = SportPosition(positions[0]); options.away = SportPosition(positions[1]); if (isChild) { require(tags.length > 1, "Child markets must have more then one tag"); if (tags[1] == 10001) { options.home.initialize(_getDetails().gameLabel, "HOME", ISportPositionalMarketFactory(factory).sportsAMM()); options.away.initialize(_getDetails().gameLabel, "AWAY", ISportPositionalMarketFactory(factory).sportsAMM()); } else if (tags[1] == 10002 || tags[1] == 10010) { options.home.initialize(_getDetails().gameLabel, "OVER", ISportPositionalMarketFactory(factory).sportsAMM()); options.away.initialize( _getDetails().gameLabel, "UNDER", ISportPositionalMarketFactory(factory).sportsAMM() ); } } else { options.home.initialize(_getDetails().gameLabel, "HOME", ISportPositionalMarketFactory(factory).sportsAMM()); options.away.initialize(_getDetails().gameLabel, "AWAY", ISportPositionalMarketFactory(factory).sportsAMM()); } if (optionsCount > 2) { options.draw = SportPosition(positions[2]); options.draw.initialize(_getDetails().gameLabel, "DRAW", ISportPositionalMarketFactory(factory).sportsAMM()); } optionsInitialized = true; emit PositionsInitialized( address(this), address(options.home), address(options.away), optionsCount > 2 ? address(options.draw) : address(0) ); } function _hasNotBeenInitialized(IPosition home) internal view returns (bool) { return address(home) == address(0); } /* ---------- Market Resolution ---------- */ function resolve(uint _outcome) external onlyOwner managerNotPaused { require(_outcome <= optionsCount, "Invalid outcome"); if (_outcome == 0) { cancelled = true; cancelTimestamp = block.timestamp; if (!isDoubleChance) { stampOdds(); } } else { require(canResolve(), "Can not resolve market"); } finalResult = _outcome; resolved = true; emit MarketResolved(_result(), deposited, 0, 0); } function stampOdds() internal { uint[] memory odds = new uint[](optionsCount); odds = ITherundownConsumer(creator).getNormalizedOddsForMarket(address(this)); if (odds[0] == 0 || odds[1] == 0) { invalidOdds = true; } homeOddsOnCancellation = odds[0]; awayOddsOnCancellation = odds[1]; drawOddsOnCancellation = optionsCount > 2 ? odds[2] : 0; emit StoredOddsOnCancellation(homeOddsOnCancellation, awayOddsOnCancellation, drawOddsOnCancellation); } /* ---------- Claiming and Exercising Options ---------- */ function exerciseOptions() external override { // The market must be resolved if it has not been. require(resolved, "Unresolved"); require(!_isPaused(), "Paused"); // If the account holds no options, revert. (uint homeBalance, uint awayBalance, uint drawBalance) = _balancesOf(msg.sender); require(homeBalance != 0 || awayBalance != 0 || drawBalance != 0, "Nothing to exercise"); if (isDoubleChance && _canExerciseParentOptions()) { parentMarket.exerciseOptions(); } // Each option only needs to be exercised if the account holds any of it. if (homeBalance != 0) { options.home.exercise(msg.sender); } if (awayBalance != 0) { options.away.exercise(msg.sender); } if (drawBalance != 0) { options.draw.exercise(msg.sender); } uint payout = _getPayout(homeBalance, awayBalance, drawBalance); if (cancelled) { require( block.timestamp > cancelTimestamp.add(_manager().cancelTimeout()) && !invalidOdds, "Unexpired timeout/ invalid odds" ); payout = calculatePayoutOnCancellation(homeBalance, awayBalance, drawBalance); } emit OptionsExercised(msg.sender, payout); if (payout != 0) { if (!isDoubleChance) { _decrementDeposited(payout); } payout = _manager().transformCollateral(payout); ISportsAMM(ISportPositionalMarketFactory(factory).sportsAMM()).sUSD().transfer(msg.sender, payout); } } function _canExerciseParentOptions() internal view returns (bool) { if (!parentMarket.resolved() && !parentMarket.canResolve()) { return false; } (uint homeBalance, uint awayBalance, uint drawBalance) = parentMarket.balancesOf(address(this)); if (homeBalance == 0 && awayBalance == 0 && drawBalance == 0) { return false; } return true; } function _getPayout( uint homeBalance, uint awayBalance, uint drawBalance ) internal view returns (uint payout) { if (isDoubleChance) { if (_result() == Side.Home) { payout = homeBalance; } } else { payout = (_result() == Side.Home) ? homeBalance : awayBalance; if (optionsCount > 2 && _result() != Side.Home) { payout = _result() == Side.Away ? awayBalance : drawBalance; } } } function restoreInvalidOdds( uint _homeOdds, uint _awayOdds, uint _drawOdds ) external override onlyOwner { require(_homeOdds > 0 && _awayOdds > 0, "Invalid odd"); homeOddsOnCancellation = _homeOdds; awayOddsOnCancellation = _awayOdds; drawOddsOnCancellation = optionsCount > 2 ? _drawOdds : 0; invalidOdds = false; emit StoredOddsOnCancellation(homeOddsOnCancellation, awayOddsOnCancellation, drawOddsOnCancellation); } function calculatePayoutOnCancellation( uint _homeBalance, uint _awayBalance, uint _drawBalance ) public view returns (uint payout) { if (!cancelled) { return 0; } else { if (isDoubleChance) { (uint position1Odds, uint position2Odds) = _getParentPositionOdds(); payout = _homeBalance.mul(position1Odds).div(1e18); payout = payout.add(_homeBalance.mul(position2Odds).div(1e18)); } else { payout = _homeBalance.mul(homeOddsOnCancellation).div(1e18); payout = payout.add(_awayBalance.mul(awayOddsOnCancellation).div(1e18)); payout = payout.add(_drawBalance.mul(drawOddsOnCancellation).div(1e18)); } } } /* ---------- Market Expiry ---------- */ function _selfDestruct(address payable beneficiary) internal { uint _deposited = deposited; if (_deposited != 0) { _decrementDeposited(_deposited); } // Transfer the balance rather than the deposit value in case there are any synths left over // from direct transfers. uint balance = ISportsAMM(ISportPositionalMarketFactory(factory).sportsAMM()).sUSD().balanceOf(address(this)); if (balance != 0) { ISportsAMM(ISportPositionalMarketFactory(factory).sportsAMM()).sUSD().transfer(beneficiary, balance); } // Destroy the option tokens before destroying the market itself. options.home.expire(beneficiary); options.away.expire(beneficiary); selfdestruct(beneficiary); } function expire(address payable beneficiary) external onlyOwner { require(_expired(), "Unexpired options remaining"); emit Expired(beneficiary); _selfDestruct(beneficiary); } /* ========== MODIFIERS ========== */ modifier managerNotPaused() { _requireManagerNotPaused(); _; } modifier noDoubleChance() { require(!isDoubleChance, "Not supported for double chance markets"); _; } /* ========== EVENTS ========== */ event Mint(Side side, address indexed account, uint value); event MarketResolved(Side result, uint deposited, uint poolFees, uint creatorFees); event OptionsExercised(address indexed account, uint value); event OptionsBurned(address indexed account, uint value); event Expired(address beneficiary); event StoredOddsOnCancellation(uint homeOdds, uint awayOdds, uint drawOdds); event PauseUpdated(bool _paused); event DatesUpdated(uint256 _maturity, uint256 _expiry); event PositionsInitialized(address _market, address _home, address _away, address _draw); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract OwnedWithInit { address public owner; address public nominatedOwner; constructor() {} function initOwner(address _owner) internal { require(owner == address(0), "Init can only be called when owner is 0"); owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } modifier onlyOwner { _onlyOwner(); _; } function _onlyOwner() private view { require(msg.sender == owner, "Only the contract owner may perform this action"); } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "../interfaces/IPositionalMarketManager.sol"; import "../interfaces/IPosition.sol"; import "../interfaces/IPriceFeed.sol"; interface ISportPositionalMarket { /* ========== TYPES ========== */ enum Phase { Trading, Maturity, Expiry } enum Side { Cancelled, Home, Away, Draw } /* ========== VIEWS / VARIABLES ========== */ function getOptions() external view returns ( IPosition home, IPosition away, IPosition draw ); function times() external view returns (uint maturity, uint destruction); function getGameDetails() external view returns (bytes32 gameId, string memory gameLabel); function getGameId() external view returns (bytes32); function deposited() external view returns (uint); function optionsCount() external view returns (uint); function creator() external view returns (address); function resolved() external view returns (bool); function cancelled() external view returns (bool); function paused() external view returns (bool); function phase() external view returns (Phase); function canResolve() external view returns (bool); function result() external view returns (Side); function isChild() external view returns (bool); function optionsInitialized() external view returns (bool); function tags(uint idx) external view returns (uint); function getTags() external view returns (uint tag1, uint tag2); function getTagsLength() external view returns (uint tagsLength); function getParentMarketPositions() external view returns (IPosition position1, IPosition position2); function getParentMarketPositionsUint() external view returns (uint position1, uint position2); function getStampedOdds() external view returns ( uint, uint, uint ); function balancesOf(address account) external view returns ( uint home, uint away, uint draw ); function totalSupplies() external view returns ( uint home, uint away, uint draw ); function isDoubleChance() external view returns (bool); function parentMarket() external view returns (ISportPositionalMarket); /* ========== MUTATIVE FUNCTIONS ========== */ function setPaused(bool _paused) external; function updateDates(uint256 _maturity, uint256 _expiry) external; function mint(uint value) external; function exerciseOptions() external; function restoreInvalidOdds( uint _homeOdds, uint _awayOdds, uint _drawOdds ) external; function initializeOptions() external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ITherundownConsumer { struct GameCreate { bytes32 gameId; uint256 startTime; int24 homeOdds; int24 awayOdds; int24 drawOdds; string homeTeam; string awayTeam; } // view functions function supportedSport(uint _sportId) external view returns (bool); function gameOnADate(bytes32 _gameId) external view returns (uint); function isGameResolvedOrCanceled(bytes32 _gameId) external view returns (bool); function getNormalizedOddsForMarket(address _market) external view returns (uint[] memory); function getGamesPerDatePerSport(uint _sportId, uint _date) external view returns (bytes32[] memory); function getGamePropsForOdds(address _market) external view returns ( uint, uint, bytes32 ); function gameIdPerMarket(address _market) external view returns (bytes32); function getGameCreatedById(bytes32 _gameId) external view returns (GameCreate memory); function isChildMarket(address _market) external view returns (bool); function gameFulfilledCreated(bytes32 _gameId) external view returns (bool); function playerProps() external view returns (address); function oddsObtainer() external view returns (address); // write functions function fulfillGamesCreated( bytes32 _requestId, bytes[] memory _games, uint _sportsId, uint _date ) external; function fulfillGamesResolved( bytes32 _requestId, bytes[] memory _games, uint _sportsId ) external; function fulfillGamesOdds(bytes32 _requestId, bytes[] memory _games) external; function setPausedByCanceledStatus(address _market, bool _flag) external; function setGameIdPerChildMarket(bytes32 _gameId, address _child) external; function pauseOrUnpauseMarket(address _market, bool _pause) external; function pauseOrUnpauseMarketForPlayerProps( address _market, bool _pause, bool _invalidOdds, bool _circuitBreakerMain ) external; function setChildMarkets( bytes32 _gameId, address _main, address _child, bool _isSpread, int16 _spreadHome, uint24 _totalOver ) external; function resolveMarketManually( address _market, uint _outcome, uint8 _homeScore, uint8 _awayScore, bool _usebackupOdds ) external; function getOddsForGame(bytes32 _gameId) external view returns ( int24, int24, int24 ); function sportsIdPerGame(bytes32 _gameId) external view returns (uint); function getGameStartTime(bytes32 _gameId) external view returns (uint256); function getLastUpdatedFromGameResolve(bytes32 _gameId) external view returns (uint40); function marketPerGameId(bytes32 _gameId) external view returns (address); function marketResolved(address _market) external view returns (bool); function marketCanceled(address _market) external view returns (bool); function invalidOdds(address _market) external view returns (bool); function isPausedByCanceledStatus(address _market) external view returns (bool); function isSportOnADate(uint _date, uint _sportId) external view returns (bool); function isSportTwoPositionsSport(uint _sportsId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../interfaces/ISportAMMRiskManager.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; interface ISportsAMM { /* ========== VIEWS / VARIABLES ========== */ enum Position { Home, Away, Draw } struct SellRequirements { address user; address market; Position position; uint amount; uint expectedPayout; uint additionalSlippage; } function theRundownConsumer() external view returns (address); function riskManager() external view returns (ISportAMMRiskManager riskManager); function getMarketDefaultOdds(address _market, bool isSell) external view returns (uint[] memory); function isMarketInAMMTrading(address _market) external view returns (bool); function isMarketForSportOnePositional(uint _tag) external view returns (bool); function availableToBuyFromAMM(address market, Position position) external view returns (uint _available); function parlayAMM() external view returns (address); function minSupportedOdds() external view returns (uint); function maxSupportedOdds() external view returns (uint); function minSupportedOddsPerSport(uint) external view returns (uint); function min_spread() external view returns (uint); function max_spread() external view returns (uint); function minimalTimeLeftToMaturity() external view returns (uint); function getSpentOnGame(address market) external view returns (uint); function safeBoxImpact() external view returns (uint); function manager() external view returns (address); function getLiquidityPool() external view returns (address); function sUSD() external view returns (IERC20Upgradeable); function buyFromAMM( address market, Position position, uint amount, uint expectedPayout, uint additionalSlippage ) external; function buyFromAmmQuote( address market, Position position, uint amount ) external view returns (uint); function buyFromAmmQuoteForParlayAMM( address market, Position position, uint amount ) external view returns (uint); function updateParlayVolume(address _account, uint _amount) external; function buyPriceImpact( address market, ISportsAMM.Position position, uint amount ) external view returns (int impact); function obtainOdds(address _market, ISportsAMM.Position _position) external view returns (uint oddsToReturn); function buyFromAmmQuoteWithDifferentCollateral( address market, ISportsAMM.Position position, uint amount, address collateral ) external view returns (uint collateralQuote, uint sUSDToPay); function availableToBuyFromAMMWithBaseOdds( address market, ISportsAMM.Position position, uint baseOdds, uint balance, bool useBalance ) external view returns (uint availableAmount); function floorBaseOdds(uint baseOdds, address market) external view returns (uint); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ISportPositionalMarketFactory { function sportsAMM() external view returns (address); function positionMastercopy() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Inheritance import "../../utils/proxy/solidity-0.8.0/ProxyOwned.sol"; import "../../utils/proxy/solidity-0.8.0/ProxyPausable.sol"; // Libraries import "../../utils/libraries/AddressSetLib.sol"; import "@openzeppelin/contracts-4.4.1/utils/math/SafeMath.sol"; // Internal references import "./SportPositionalMarketFactory.sol"; import "./SportPositionalMarket.sol"; import "./SportPosition.sol"; import "../../interfaces/ISportPositionalMarketManager.sol"; import "../../interfaces/ISportPositionalMarket.sol"; import "../../interfaces/ITherundownConsumer.sol"; import "@openzeppelin/contracts-4.4.1/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "../../interfaces/IGamesOddsObtainer.sol"; import "../../interfaces/IGamesPlayerProps.sol"; import "../../interfaces/IGameChildMarket.sol"; contract SportPositionalMarketManager is Initializable, ProxyOwned, ProxyPausable, ISportPositionalMarketManager { /* ========== LIBRARIES ========== */ using SafeMath for uint; using AddressSetLib for AddressSetLib.AddressSet; /* ========== STATE VARIABLES ========== */ uint public override expiryDuration; bool public override marketCreationEnabled; bool public customMarketCreationEnabled; uint public override totalDeposited; AddressSetLib.AddressSet internal _activeMarkets; AddressSetLib.AddressSet internal _maturedMarkets; SportPositionalMarketManager internal _migratingManager; IERC20 public sUSD; address public theRundownConsumer; address public sportPositionalMarketFactory; bool public needsTransformingCollateral; mapping(address => bool) public whitelistedAddresses; address private apexConsumer; // deprecated uint public cancelTimeout; mapping(address => bool) public whitelistedCancelAddresses; address public oddsObtainer; mapping(address => bool) public isDoubleChance; bool public override isDoubleChanceSupported; mapping(address => address[]) public doubleChanceMarketsByParent; mapping(uint => bool) public override doesSportSupportDoubleChance; address public playerProps; /* ========== CONSTRUCTOR ========== */ function initialize(address _owner, IERC20 _sUSD) external initializer { setOwner(_owner); sUSD = _sUSD; // Temporarily change the owner so that the setters don't revert. owner = msg.sender; marketCreationEnabled = true; customMarketCreationEnabled = false; } /* ========== SETTERS ========== */ function setSportPositionalMarketFactory(address _sportPositionalMarketFactory) external onlyOwner { sportPositionalMarketFactory = _sportPositionalMarketFactory; emit SetSportPositionalMarketFactory(_sportPositionalMarketFactory); } function setTherundownConsumer(address _theRundownConsumer) external onlyOwner { theRundownConsumer = _theRundownConsumer; emit SetTherundownConsumer(_theRundownConsumer); } function setOddsObtainer(address _oddsObtainer) external onlyOwner { oddsObtainer = _oddsObtainer; emit SetObtainerAddress(_oddsObtainer); } function setPlayerProps(address _playerProps) external onlyOwner { playerProps = _playerProps; emit SetPlayerPropsAddress(_playerProps); } function getOddsObtainer() external view override returns (address obtainer) { obtainer = oddsObtainer; } /// @notice setNeedsTransformingCollateral sets needsTransformingCollateral value /// @param _needsTransformingCollateral boolen value to be set function setNeedsTransformingCollateral(bool _needsTransformingCollateral) external onlyOwner { needsTransformingCollateral = _needsTransformingCollateral; } /// @notice setWhitelistedAddresses enables whitelist addresses of given array /// @param _whitelistedAddresses array of whitelisted addresses /// @param _flag adding or removing from whitelist (true: add, false: remove) function setWhitelistedAddresses( address[] calldata _whitelistedAddresses, bool _flag, uint8 _group ) external onlyOwner { require(_whitelistedAddresses.length > 0, "Whitelisted addresses cannot be empty"); for (uint256 index = 0; index < _whitelistedAddresses.length; index++) { // only if current flag is different, if same skip it if (_group == 1) { if (whitelistedAddresses[_whitelistedAddresses[index]] != _flag) { whitelistedAddresses[_whitelistedAddresses[index]] = _flag; emit AddedIntoWhitelist(_whitelistedAddresses[index], _flag); } } if (_group == 2) { if (whitelistedCancelAddresses[_whitelistedAddresses[index]] != _flag) { whitelistedCancelAddresses[_whitelistedAddresses[index]] = _flag; emit AddedIntoWhitelist(_whitelistedAddresses[index], _flag); } } } } /* ========== VIEWS ========== */ /* ---------- Market Information ---------- */ function isKnownMarket(address candidate) public view override returns (bool) { return _activeMarkets.contains(candidate) || _maturedMarkets.contains(candidate); } function isActiveMarket(address candidate) public view override returns (bool) { return _activeMarkets.contains(candidate) && !ISportPositionalMarket(candidate).paused(); } function isDoubleChanceMarket(address candidate) public view override returns (bool) { return isDoubleChance[candidate]; } function numActiveMarkets() external view override returns (uint) { return _activeMarkets.elements.length; } function activeMarkets(uint index, uint pageSize) external view override returns (address[] memory) { return _activeMarkets.getPage(index, pageSize); } function numMaturedMarkets() external view override returns (uint) { return _maturedMarkets.elements.length; } function getActiveMarketAddress(uint _index) external view override returns (address) { if (_index < _activeMarkets.elements.length) { return _activeMarkets.elements[_index]; } else { return address(0); } } function getDoubleChanceMarketsByParentMarket(address market) external view returns (address[] memory) { if (doubleChanceMarketsByParent[market].length > 0) { address[] memory markets = new address[](3); for (uint i = 0; i < doubleChanceMarketsByParent[market].length; i++) { markets[i] = doubleChanceMarketsByParent[market][i]; } return markets; } } function maturedMarkets(uint index, uint pageSize) external view override returns (address[] memory) { return _maturedMarkets.getPage(index, pageSize); } function setMarketPaused(address _market, bool _paused) external override { require( msg.sender == owner || msg.sender == theRundownConsumer || msg.sender == oddsObtainer || msg.sender == playerProps || whitelistedAddresses[msg.sender], "Invalid caller" ); require(ISportPositionalMarket(_market).paused() != _paused, "No state change"); ISportPositionalMarket(_market).setPaused(_paused); } function updateDatesForMarket(address _market, uint256 _newStartTime) external override { require(msg.sender == owner || msg.sender == theRundownConsumer, "Invalid caller"); uint expiry = _newStartTime.add(expiryDuration); // Update main market _updateDatesForMarket(_market, _newStartTime, expiry); // Update child markets _updateDatesForChildMarkets(_market, _newStartTime, expiry, oddsObtainer); _updateDatesForChildMarkets(_market, _newStartTime, expiry, playerProps); } function _updateDatesForChildMarkets( address _market, uint256 _newStartTime, uint256 _expiry, address _childMarketContract ) internal { uint numberOfChildMarkets = IGameChildMarket(_childMarketContract).numberOfChildMarkets(_market); for (uint i = 0; i < numberOfChildMarkets; i++) { address child = IGameChildMarket(_childMarketContract).mainMarketChildMarketIndex(_market, i); _updateDatesForMarket(child, _newStartTime, _expiry); } } function isMarketPaused(address _market) external view override returns (bool) { return ISportPositionalMarket(_market).paused(); } function queryMintsAndMaturityStatusForParents(address[] memory _parents) external view returns ( bool[] memory _hasAnyMintsArray, bool[] memory _isMaturedArray, bool[] memory _isResolvedArray ) { _hasAnyMintsArray = new bool[](_parents.length); _isMaturedArray = new bool[](_parents.length); _isResolvedArray = new bool[](_parents.length); for (uint i = 0; i < _parents.length; i++) { (bool _hasAnyMints, uint _maturity) = _hasAnyMintsAndMaturityDatesForMarket(_parents[i]); _isResolvedArray[i] = _isResolvedMarket(_parents[i]); _hasAnyMintsArray[i] = _hasAnyMints; _isMaturedArray[i] = _maturity <= block.timestamp; } } function queryMintsAndMaturityStatusForPlayerProps(address[] memory _playerPropsMarkets) external view override returns ( bool[] memory _hasAnyMintsArray, bool[] memory _isMaturedArray, bool[] memory _isResolvedArray, uint[] memory _maturities ) { _hasAnyMintsArray = new bool[](_playerPropsMarkets.length); _isMaturedArray = new bool[](_playerPropsMarkets.length); _isResolvedArray = new bool[](_playerPropsMarkets.length); _maturities = new uint[](_playerPropsMarkets.length); for (uint i = 0; i < _playerPropsMarkets.length; i++) { (bool _hasAnyMints, uint _maturity) = _hasAnyMintsAndMaturityDatesForPP(_playerPropsMarkets[i]); _isResolvedArray[i] = _isResolvedMarket(_playerPropsMarkets[i]); _hasAnyMintsArray[i] = _hasAnyMints; _isMaturedArray[i] = _maturity <= block.timestamp; _maturities[i] = _maturity; } } function _hasAnyMintsAndMaturityDatesForMarket(address _parent) internal view returns (bool _hasAnyMints, uint _maturity) { ISportPositionalMarket marketContract = ISportPositionalMarket(_parent); (uint maturity, ) = marketContract.times(); _hasAnyMints = marketContract.deposited() > 0 || _hasAnyMintsForChildren(_parent); _maturity = maturity; } function _hasAnyMintsAndMaturityDatesForPP(address _market) internal view returns (bool _hasAnyMints, uint _maturity) { ISportPositionalMarket marketContract = ISportPositionalMarket(_market); (uint maturity, ) = marketContract.times(); _hasAnyMints = marketContract.deposited() > 0; _maturity = maturity; } function _isResolvedMarket(address _market) internal view returns (bool _flag) { return ISportPositionalMarket(_market).resolved(); } /* ========== MUTATIVE FUNCTIONS ========== */ /* ---------- Setters ---------- */ function setExpiryDuration(uint _expiryDuration) public onlyOwner { expiryDuration = _expiryDuration; emit ExpiryDurationUpdated(_expiryDuration); } function setsUSD(address _address) external onlyOwner { sUSD = IERC20(_address); emit SetsUSD(_address); } /* ---------- Deposit Management ---------- */ function incrementTotalDeposited(uint delta) external onlyActiveMarkets notPaused { totalDeposited = totalDeposited.add(delta); } function decrementTotalDeposited(uint delta) external onlyKnownMarkets notPaused { // NOTE: As individual market debt is not tracked here, the underlying markets // need to be careful never to subtract more debt than they added. // This can't be enforced without additional state/communication overhead. totalDeposited = totalDeposited.sub(delta); } /* ---------- Market Lifecycle ---------- */ function createMarket( bytes32 gameId, string memory gameLabel, uint maturity, uint initialMint, // initial sUSD to mint options for, uint positionCount, uint[] memory tags, bool isChild, address parentMarket ) external override notPaused returns ( ISportPositionalMarket // no support for returning PositionalMarket polymorphically given the interface ) { require(marketCreationEnabled, "Market creation is disabled"); require( msg.sender == theRundownConsumer || msg.sender == oddsObtainer || msg.sender == playerProps, "Invalid creator" ); uint expiry = maturity.add(expiryDuration); require(block.timestamp < maturity, "Maturity has to be in the future"); // We also require maturity < expiry. But there is no need to check this. // The market itself validates the capital and skew requirements. ISportPositionalMarket market = _createMarket( SportPositionalMarketFactory.SportPositionCreationMarketParameters( msg.sender, gameId, gameLabel, [maturity, expiry], positionCount, tags, isChild, parentMarket, false ) ); if (positionCount > 2 && isDoubleChanceSupported) { _createDoubleChanceMarkets(msg.sender, gameId, maturity, expiry, address(market), tags[0]); } return market; } function createDoubleChanceMarketsForParent(address market) external notPaused onlyOwner { require(marketCreationEnabled, "Market creation is disabled"); require(isDoubleChanceSupported, "Double chance not supported"); ISportPositionalMarket marketContract = ISportPositionalMarket(market); require(marketContract.optionsCount() > 2, "Not supported for 2 options market"); (uint maturity, uint expiry) = marketContract.times(); _createDoubleChanceMarkets( marketContract.creator(), marketContract.getGameId(), maturity, expiry, market, marketContract.tags(0) ); } function _createMarket(SportPositionalMarketFactory.SportPositionCreationMarketParameters memory parameters) internal returns (ISportPositionalMarket) { SportPositionalMarket market = SportPositionalMarketFactory(sportPositionalMarketFactory).createMarket(parameters); _activeMarkets.add(address(market)); (IPosition up, IPosition down, IPosition draw) = market.getOptions(); emit MarketCreated( address(market), parameters.creator, parameters.gameId, parameters.times[0], parameters.times[1], address(up), address(down), address(draw) ); emit MarketLabel(address(market), parameters.gameLabel); return market; } function _createDoubleChanceMarkets( address creator, bytes32 gameId, uint maturity, uint expiry, address market, uint tag ) internal onlySupportedGameId(gameId) { string[3] memory labels = ["HomeTeamNotToLose", "AwayTeamNotToLose", "NoDraw"]; uint[] memory tagsDoubleChance = new uint[](2); tagsDoubleChance[0] = tag; tagsDoubleChance[1] = 10003; for (uint i = 0; i < 3; i++) { ISportPositionalMarket doubleChanceMarket = _createMarket( SportPositionalMarketFactory.SportPositionCreationMarketParameters( creator, gameId, labels[i], [maturity, expiry], 2, tagsDoubleChance, false, address(market), true ) ); _activeMarkets.add(address(doubleChanceMarket)); doubleChanceMarketsByParent[address(market)].push(address(doubleChanceMarket)); isDoubleChance[address(doubleChanceMarket)] = true; IGamesOddsObtainer(oddsObtainer).setChildMarketGameId(gameId, address(doubleChanceMarket)); emit DoubleChanceMarketCreated(address(market), address(doubleChanceMarket), tagsDoubleChance[1], labels[i]); } } function transferSusdTo( address sender, address receiver, uint amount ) external override { //only to be called by markets themselves require(isKnownMarket(address(msg.sender)), "Market unknown."); amount = _transformCollateral(amount); amount = needsTransformingCollateral ? amount + 1 : amount; bool success = sUSD.transferFrom(sender, receiver, amount); if (!success) { revert("TransferFrom function failed"); } } function resolveMarket(address market, uint _outcome) external override { require( msg.sender == theRundownConsumer || msg.sender == owner || msg.sender == oddsObtainer || msg.sender == playerProps || whitelistedCancelAddresses[msg.sender], "Invalid resolver" ); require(_activeMarkets.contains(market), "Not an active market"); require(!isDoubleChance[market], "Not supported for double chance markets"); // unpause if paused if (ISportPositionalMarket(market).paused()) { ISportPositionalMarket(market).setPaused(false); } SportPositionalMarket(market).resolve(_outcome); _activeMarkets.remove(market); _maturedMarkets.add(market); if (doubleChanceMarketsByParent[market].length > 0) { if (_outcome == 1) { // HomeTeamNotLose, NoDraw SportPositionalMarket(doubleChanceMarketsByParent[market][0]).resolve(1); SportPositionalMarket(doubleChanceMarketsByParent[market][1]).resolve(2); SportPositionalMarket(doubleChanceMarketsByParent[market][2]).resolve(1); } else if (_outcome == 2) { // AwayTeamNotLose, NoDraw SportPositionalMarket(doubleChanceMarketsByParent[market][0]).resolve(2); SportPositionalMarket(doubleChanceMarketsByParent[market][1]).resolve(1); SportPositionalMarket(doubleChanceMarketsByParent[market][2]).resolve(1); } else if (_outcome == 3) { // HomeTeamNotLose, AwayTeamNotLose SportPositionalMarket(doubleChanceMarketsByParent[market][0]).resolve(1); SportPositionalMarket(doubleChanceMarketsByParent[market][1]).resolve(1); SportPositionalMarket(doubleChanceMarketsByParent[market][2]).resolve(2); } else { // cancelled SportPositionalMarket(doubleChanceMarketsByParent[market][0]).resolve(0); SportPositionalMarket(doubleChanceMarketsByParent[market][1]).resolve(0); SportPositionalMarket(doubleChanceMarketsByParent[market][2]).resolve(0); } for (uint i = 0; i < doubleChanceMarketsByParent[market].length; i++) { _activeMarkets.remove(doubleChanceMarketsByParent[market][i]); _maturedMarkets.add(doubleChanceMarketsByParent[market][i]); } } } function resolveMarketWithResult( address _market, uint _outcome, uint8 _homeScore, uint8 _awayScore, address _consumer, bool _useBackupOdds ) external { require(msg.sender == owner || whitelistedCancelAddresses[msg.sender], "Invalid resolver"); require(!isDoubleChance[_market], "Not supported for double chance markets"); if (_outcome != 0) { require(!_useBackupOdds, "Only use backup odds on cancelation, if needed!"); } if (_consumer == theRundownConsumer) { ITherundownConsumer(theRundownConsumer).resolveMarketManually( _market, _outcome, _homeScore, _awayScore, _useBackupOdds ); } } function cancelMarketsForParents(address[] memory _parents) external { for (uint i = 0; i < _parents.length; i++) { require(!isDoubleChance[_parents[i]], "Not supported for double chance markets"); (bool _hasAnyMints, uint _maturity) = _hasAnyMintsAndMaturityDatesForMarket(_parents[i]); if (!_hasAnyMints && _maturity <= block.timestamp && !_isResolvedMarket(_parents[i])) { ITherundownConsumer(theRundownConsumer).resolveMarketManually(_parents[i], 0, 0, 0, false); } } } function cancelMarketsForPlayerProps(address[] memory _playerPropsMarkets) external { for (uint i = 0; i < _playerPropsMarkets.length; i++) { require(!isDoubleChance[_playerPropsMarkets[i]], "Not supported for double chance markets"); (bool _hasAnyMints, uint _maturity) = _hasAnyMintsAndMaturityDatesForPP(_playerPropsMarkets[i]); if (!_hasAnyMints && _maturity <= block.timestamp && !_isResolvedMarket(_playerPropsMarkets[i])) { IGamesPlayerProps(playerProps).cancelMarketFromManager(_playerPropsMarkets[i]); } } } function overrideResolveWithCancel(address market, uint _outcome) external { require(msg.sender == owner || whitelistedCancelAddresses[msg.sender], "Invalid resolver"); require(_outcome == 0, "Can only set 0 outcome"); require(SportPositionalMarket(market).resolved(), "Market not resolved"); require(!_activeMarkets.contains(market), "Active market"); require(!isDoubleChance[market], "Not supported for double chance markets"); // unpause if paused if (ISportPositionalMarket(market).paused()) { ISportPositionalMarket(market).setPaused(false); } SportPositionalMarket(market).resolve(_outcome); if (doubleChanceMarketsByParent[market].length > 0) { SportPositionalMarket(doubleChanceMarketsByParent[market][0]).resolve(0); SportPositionalMarket(doubleChanceMarketsByParent[market][1]).resolve(0); SportPositionalMarket(doubleChanceMarketsByParent[market][2]).resolve(0); } } function expireMarkets(address[] calldata markets) external override notPaused onlyOwner { for (uint i = 0; i < markets.length; i++) { address market = markets[i]; require(isKnownMarket(address(market)), "Market unknown."); // The market itself handles decrementing the total deposits. SportPositionalMarket(market).expire(payable(msg.sender)); // Note that we required that the market is known, which guarantees // its index is defined and that the list of markets is not empty. _maturedMarkets.remove(market); emit MarketExpired(market); } } function restoreInvalidOddsForMarket( address _market, uint _homeOdds, uint _awayOdds, uint _drawOdds ) external onlyOwner { require(isKnownMarket(address(_market)), "Market unknown."); require(SportPositionalMarket(_market).cancelled(), "Market not cancelled."); SportPositionalMarket(_market).restoreInvalidOdds(_homeOdds, _awayOdds, _drawOdds); emit OddsForMarketRestored(_market, _homeOdds, _awayOdds, _drawOdds); } function setMarketCreationEnabled(bool enabled) external onlyOwner { if (enabled != marketCreationEnabled) { marketCreationEnabled = enabled; emit MarketCreationEnabledUpdated(enabled); } } function setCancelTimeout(uint _cancelTimeout) external onlyOwner { cancelTimeout = _cancelTimeout; } function setIsDoubleChanceSupported(bool _isDoubleChanceSupported) external onlyOwner { isDoubleChanceSupported = _isDoubleChanceSupported; emit DoubleChanceSupportChanged(_isDoubleChanceSupported); } function setSupportedSportForDoubleChance(uint[] memory _sportIds, bool _isSupported) external onlyOwner { for (uint256 index = 0; index < _sportIds.length; index++) { // only if current flag is different, if same skip it if (doesSportSupportDoubleChance[_sportIds[index]] != _isSupported) { doesSportSupportDoubleChance[_sportIds[index]] = _isSupported; emit SupportedSportForDoubleChanceAdded(_sportIds[index], _isSupported); } } } // support USDC with 6 decimals function transformCollateral(uint value) external view override returns (uint) { return _transformCollateral(value); } function _transformCollateral(uint value) internal view returns (uint) { if (needsTransformingCollateral) { return value / 1e12; } else { return value; } } function _updateDatesForMarket( address _market, uint256 _newStartTime, uint256 _expiry ) internal { ISportPositionalMarket(_market).updateDates(_newStartTime, _expiry); emit DatesUpdatedForMarket(_market, _newStartTime, _expiry); } function _hasAnyMintsForChildren(address _market) internal view returns (bool) { return _hasAnyMints(_market, true) || _hasAnyMints(_market, false); } function _hasAnyMints(address _market, bool checkPlayerProps) internal view returns (bool) { uint numberOfChildMarkets; address childMarketContract; if (checkPlayerProps) { numberOfChildMarkets = IGameChildMarket(playerProps).numberOfChildMarkets(_market); childMarketContract = playerProps; } else { numberOfChildMarkets = IGameChildMarket(oddsObtainer).numberOfChildMarkets(_market); childMarketContract = oddsObtainer; } for (uint i = 0; i < numberOfChildMarkets; i++) { address child = IGameChildMarket(childMarketContract).mainMarketChildMarketIndex(_market, i); if (ISportPositionalMarket(child).deposited() > 0) { return true; } } return false; } function reverseTransformCollateral(uint value) external view override returns (uint) { if (needsTransformingCollateral) { return value * 1e12; } else { return value; } } function isWhitelistedAddress(address _address) external view override returns (bool) { return whitelistedAddresses[_address]; } /* ========== MODIFIERS ========== */ modifier onlyActiveMarkets() { require(_activeMarkets.contains(msg.sender), "Permitted only for active markets."); _; } modifier onlyKnownMarkets() { require(isKnownMarket(msg.sender), "Permitted only for known markets."); _; } modifier onlySupportedGameId(bytes32 gameId) { uint sportId = ITherundownConsumer(theRundownConsumer).sportsIdPerGame(gameId); if (doesSportSupportDoubleChance[sportId] && isDoubleChanceSupported) { _; } } /* ========== EVENTS ========== */ event MarketCreated( address market, address indexed creator, bytes32 indexed gameId, uint maturityDate, uint expiryDate, address up, address down, address draw ); event MarketLabel(address market, string gameLabel); event MarketExpired(address market); event MarketCreationEnabledUpdated(bool enabled); event MarketsMigrated(SportPositionalMarketManager receivingManager, SportPositionalMarket[] markets); event MarketsReceived(SportPositionalMarketManager migratingManager, SportPositionalMarket[] markets); event SetMigratingManager(address migratingManager); event ExpiryDurationUpdated(uint duration); event MaxTimeToMaturityUpdated(uint duration); event CreatorCapitalRequirementUpdated(uint value); event SetSportPositionalMarketFactory(address _sportPositionalMarketFactory); event SetsUSD(address _address); event SetTherundownConsumer(address theRundownConsumer); event SetObtainerAddress(address _obratiner); event SetPlayerPropsAddress(address _playerProps); event OddsForMarketRestored(address _market, uint _homeOdds, uint _awayOdds, uint _drawOdds); event AddedIntoWhitelist(address _whitelistAddress, bool _flag); event DatesUpdatedForMarket(address _market, uint256 _newStartTime, uint256 _expiry); event DoubleChanceMarketCreated(address _parentMarket, address _doubleChanceMarket, uint tag, string label); event DoubleChanceSupportChanged(bool _isDoubleChanceSupported); event SupportedSportForDoubleChanceAdded(uint _sportId, bool _isSupported); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Inheritance import "@openzeppelin/contracts-4.4.1/token/ERC20/IERC20.sol"; import "../../interfaces/IPosition.sol"; // Libraries import "@openzeppelin/contracts-4.4.1/utils/math/SafeMath.sol"; // Internal references import "./SportPositionalMarket.sol"; contract SportPosition is IERC20, IPosition { /* ========== LIBRARIES ========== */ using SafeMath for uint; /* ========== STATE VARIABLES ========== */ string public name; string public symbol; uint8 public constant decimals = 18; SportPositionalMarket public market; mapping(address => uint) public override balanceOf; uint public override totalSupply; // The argument order is allowance[owner][spender] mapping(address => mapping(address => uint)) private allowances; // Enforce a 1 cent minimum amount uint internal constant _MINIMUM_AMOUNT = 1e16; address public sportsAMM; /* ========== CONSTRUCTOR ========== */ bool public initialized = false; function initialize( string calldata _name, string calldata _symbol, address _sportsAMM ) external { require(!initialized, "Positional Market already initialized"); initialized = true; name = _name; symbol = _symbol; market = SportPositionalMarket(msg.sender); // add through constructor sportsAMM = _sportsAMM; } function allowance(address owner, address spender) external view override returns (uint256) { if (spender == sportsAMM) { return 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; } else { return allowances[owner][spender]; } } function _requireMinimumAmount(uint amount) internal pure returns (uint) { require(amount >= _MINIMUM_AMOUNT || amount == 0, "Balance < $0.01"); return amount; } function mint(address minter, uint amount) external onlyMarket { _requireMinimumAmount(amount); totalSupply = totalSupply.add(amount); balanceOf[minter] = balanceOf[minter].add(amount); // Increment rather than assigning since a transfer may have occurred. emit Transfer(address(0), minter, amount); emit Issued(minter, amount); } // This must only be invoked after maturity. function exercise(address claimant) external onlyMarket { uint balance = balanceOf[claimant]; if (balance == 0) { return; } balanceOf[claimant] = 0; totalSupply = totalSupply.sub(balance); emit Transfer(claimant, address(0), balance); emit Burned(claimant, balance); } // This must only be invoked after maturity. function exerciseWithAmount(address claimant, uint amount) external override onlyMarket { require(amount > 0, "Can not exercise zero amount!"); require(balanceOf[claimant] >= amount, "Balance must be greather or equal amount that is burned"); balanceOf[claimant] = balanceOf[claimant] - amount; totalSupply = totalSupply.sub(amount); emit Transfer(claimant, address(0), amount); emit Burned(claimant, amount); } // This must only be invoked after the exercise window is complete. // Note that any options which have not been exercised will linger. function expire(address payable beneficiary) external onlyMarket { selfdestruct(beneficiary); } /* ---------- ERC20 Functions ---------- */ function _transfer( address _from, address _to, uint _value ) internal returns (bool success) { market.requireUnpaused(); require(_to != address(0) && _to != address(this), "Invalid address"); uint fromBalance = balanceOf[_from]; require(_value <= fromBalance, "Insufficient balance"); balanceOf[_from] = fromBalance.sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); return true; } function transfer(address _to, uint _value) external override returns (bool success) { return _transfer(msg.sender, _to, _value); } function transferFrom( address _from, address _to, uint _value ) external override returns (bool success) { if (msg.sender != sportsAMM) { uint fromAllowance = allowances[_from][msg.sender]; require(_value <= fromAllowance, "Insufficient allowance"); allowances[_from][msg.sender] = fromAllowance.sub(_value); } return _transfer(_from, _to, _value); } function approve(address _spender, uint _value) external override returns (bool success) { require(_spender != address(0)); allowances[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function getBalanceOf(address account) external view override returns (uint) { return balanceOf[account]; } function getTotalSupply() external view override returns (uint) { return totalSupply; } /* ========== MODIFIERS ========== */ modifier onlyMarket() { require(msg.sender == address(market), "Only market allowed"); _; } /* ========== EVENTS ========== */ event Issued(address indexed account, uint value); event Burned(address indexed account, uint value); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "../interfaces/IPositionalMarket.sol"; interface IPositionalMarketManager { /* ========== VIEWS / VARIABLES ========== */ function durations() external view returns (uint expiryDuration, uint maxTimeToMaturity); function capitalRequirement() external view returns (uint); function marketCreationEnabled() external view returns (bool); function onlyAMMMintingAndBurning() external view returns (bool); function transformCollateral(uint value) external view returns (uint); function reverseTransformCollateral(uint value) external view returns (uint); function totalDeposited() external view returns (uint); function numActiveMarkets() external view returns (uint); function activeMarkets(uint index, uint pageSize) external view returns (address[] memory); function numMaturedMarkets() external view returns (uint); function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory); function isActiveMarket(address candidate) external view returns (bool); function isKnownMarket(address candidate) external view returns (bool); function getThalesAMM() external view returns (address); /* ========== MUTATIVE FUNCTIONS ========== */ function createMarket( bytes32 oracleKey, uint strikePrice, uint maturity, uint initialMint // initial sUSD to mint options for, ) external returns (IPositionalMarket); function resolveMarket(address market) external; function expireMarkets(address[] calldata market) external; function transferSusdTo( address sender, address receiver, uint amount ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "./IPositionalMarket.sol"; interface IPosition { /* ========== VIEWS / VARIABLES ========== */ function getBalanceOf(address account) external view returns (uint); function getTotalSupply() external view returns (uint); function exerciseWithAmount(address claimant, uint amount) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; interface IPriceFeed { // Structs struct RateAndUpdatedTime { uint216 rate; uint40 time; } // Mutative functions function addAggregator(bytes32 currencyKey, address aggregatorAddress) external; function removeAggregator(bytes32 currencyKey) external; // Views function rateForCurrency(bytes32 currencyKey) external view returns (uint); function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time); function getRates() external view returns (uint[] memory); function getCurrencies() external view returns (bytes32[] memory); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "../interfaces/IPositionalMarketManager.sol"; import "../interfaces/IPosition.sol"; import "../interfaces/IPriceFeed.sol"; interface IPositionalMarket { /* ========== TYPES ========== */ enum Phase { Trading, Maturity, Expiry } enum Side { Up, Down } /* ========== VIEWS / VARIABLES ========== */ function getOptions() external view returns (IPosition up, IPosition down); function times() external view returns (uint maturity, uint destructino); function getOracleDetails() external view returns ( bytes32 key, uint strikePrice, uint finalPrice ); function fees() external view returns (uint poolFee, uint creatorFee); function deposited() external view returns (uint); function creator() external view returns (address); function resolved() external view returns (bool); function phase() external view returns (Phase); function oraclePrice() external view returns (uint); function oraclePriceAndTimestamp() external view returns (uint price, uint updatedAt); function canResolve() external view returns (bool); function result() external view returns (Side); function balancesOf(address account) external view returns (uint up, uint down); function totalSupplies() external view returns (uint up, uint down); function getMaximumBurnable(address account) external view returns (uint amount); /* ========== MUTATIVE FUNCTIONS ========== */ function mint(uint value) external; function exerciseOptions() external returns (uint); function burnOptions(uint amount) external; function burnOptionsMaximum() external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ISportAMMRiskManager { function calculateCapToBeUsed(address _market) external view returns (uint toReturn); function isTotalSpendingLessThanTotalRisk(uint _totalSpent, address _market) external view returns (bool _isNotRisky); function isMarketForSportOnePositional(uint _tag) external view returns (bool); function isMarketForPlayerPropsOnePositional(uint _tag) external view returns (bool); function minSupportedOddsPerSport(uint tag) external view returns (uint); function minSpreadPerSport(uint tag1, uint tag2) external view returns (uint); function maxSpreadPerSport(uint tag) external view returns (uint); function getMinSpreadToUse( bool useDefaultMinSpread, address market, uint min_spread, uint min_spreadPerAddress ) external view returns (uint); function getMaxSpreadForMarket(address _market, uint max_spread) external view returns (uint); function getMinOddsForMarket(address _market, uint minSupportedOdds) external view returns (uint minOdds); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Clone of syntetix contract without constructor contract ProxyOwned { address public owner; address public nominatedOwner; bool private _initialized; bool private _transferredAtInit; function setOwner(address _owner) public { require(_owner != address(0), "Owner address cannot be 0"); require(!_initialized, "Already initialized, use nominateNewOwner"); _initialized = true; owner = _owner; emit OwnerChanged(address(0), _owner); } function nominateNewOwner(address _owner) external onlyOwner { nominatedOwner = _owner; emit OwnerNominated(_owner); } function acceptOwnership() external { require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); emit OwnerChanged(owner, nominatedOwner); owner = nominatedOwner; nominatedOwner = address(0); } function transferOwnershipAtInit(address proxyAddress) external onlyOwner { require(proxyAddress != address(0), "Invalid address"); require(!_transferredAtInit, "Already transferred"); owner = proxyAddress; _transferredAtInit = true; emit OwnerChanged(owner, proxyAddress); } modifier onlyOwner { _onlyOwner(); _; } function _onlyOwner() private view { require(msg.sender == owner, "Only the contract owner may perform this action"); } event OwnerNominated(address newOwner); event OwnerChanged(address oldOwner, address newOwner); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Inheritance import "./ProxyOwned.sol"; // Clone of syntetix contract without constructor contract ProxyPausable is ProxyOwned { uint public lastPauseTime; bool public paused; /** * @notice Change the paused state of the contract * @dev Only the contract owner may call this. */ function setPaused(bool _paused) external onlyOwner { // Ensure we're actually changing the state before we do anything if (_paused == paused) { return; } // Set our paused state. paused = _paused; // If applicable, set the last pause time. if (paused) { lastPauseTime = block.timestamp; } // Let everyone know that our pause state has changed. emit PauseChanged(paused); } event PauseChanged(bool isPaused); modifier notPaused { require(!paused, "This action cannot be performed while the contract is paused"); _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library AddressSetLib { struct AddressSet { address[] elements; mapping(address => uint) indices; } function contains(AddressSet storage set, address candidate) internal view returns (bool) { if (set.elements.length == 0) { return false; } uint index = set.indices[candidate]; return index != 0 || set.elements[0] == candidate; } function getPage( AddressSet storage set, uint index, uint pageSize ) internal view returns (address[] memory) { // NOTE: This implementation should be converted to slice operators if the compiler is updated to v0.6.0+ uint endIndex = index + pageSize; // The check below that endIndex <= index handles overflow. // If the page extends past the end of the list, truncate it. if (endIndex > set.elements.length) { endIndex = set.elements.length; } if (endIndex <= index) { return new address[](0); } uint n = endIndex - index; // We already checked for negative overflow. address[] memory page = new address[](n); for (uint i; i < n; i++) { page[i] = set.elements[i + index]; } return page; } function add(AddressSet storage set, address element) internal { // Adding to a set is an idempotent operation. if (!contains(set, element)) { set.indices[element] = set.elements.length; set.elements.push(element); } } function remove(AddressSet storage set, address element) internal { require(contains(set, element), "Element not in set."); // Replace the removed element with the last element of the list. uint index = set.indices[element]; uint lastIndex = set.elements.length - 1; // We required that element is in the list, so it is not empty. if (index != lastIndex) { // No need to shift the last element if it is the one we want to delete. address shiftedElement = set.elements[lastIndex]; set.elements[index] = shiftedElement; set.indices[shiftedElement] = index; } set.elements.pop(); delete set.indices[element]; } }
pragma solidity ^0.8.0; // Inheritance import "../../utils/proxy/solidity-0.8.0/ProxyOwned.sol"; // Internal references import "./SportPosition.sol"; import "./SportPositionalMarket.sol"; import "./SportPositionalMarketFactory.sol"; import "@openzeppelin/contracts-4.4.1/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-4.4.1/proxy/Clones.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; contract SportPositionalMarketFactory is Initializable, ProxyOwned { /* ========== STATE VARIABLES ========== */ address public positionalMarketManager; address public positionalMarketMastercopy; address public positionMastercopy; address public sportsAMM; struct SportPositionCreationMarketParameters { address creator; bytes32 gameId; string gameLabel; uint[2] times; // [maturity, expiry] uint positionCount; uint[] tags; bool isChild; address parentMarket; bool isDoubleChance; } /* ========== INITIALIZER ========== */ function initialize(address _owner) external initializer { setOwner(_owner); } /* ========== MUTATIVE FUNCTIONS ========== */ function createMarket(SportPositionCreationMarketParameters calldata _parameters) external returns (SportPositionalMarket) { require(positionalMarketManager == msg.sender, "Only permitted by the manager."); SportPositionalMarket pom = SportPositionalMarket(Clones.clone(positionalMarketMastercopy)); address[] memory positions = new address[](_parameters.positionCount); pom.initialize( SportPositionalMarket.SportPositionalMarketParameters( positionalMarketManager, _parameters.creator, _parameters.gameId, _parameters.gameLabel, _parameters.times, _parameters.positionCount, positions, _parameters.tags, _parameters.isChild, _parameters.parentMarket, _parameters.isDoubleChance, address(this) ) ); emit MarketCreated( address(pom), _parameters.gameId, _parameters.gameLabel, _parameters.times[0], _parameters.times[1], 0, _parameters.positionCount, _parameters.tags, _parameters.isChild, _parameters.parentMarket ); return pom; } /* ========== SETTERS ========== */ function setSportPositionalMarketManager(address _positionalMarketManager) external onlyOwner { positionalMarketManager = _positionalMarketManager; emit SportPositionalMarketManagerChanged(_positionalMarketManager); } function setSportPositionalMarketMastercopy(address _positionalMarketMastercopy) external onlyOwner { positionalMarketMastercopy = _positionalMarketMastercopy; emit SportPositionalMarketMastercopyChanged(_positionalMarketMastercopy); } function setSportPositionMastercopy(address _positionMastercopy) external onlyOwner { positionMastercopy = _positionMastercopy; emit SportPositionMastercopyChanged(_positionMastercopy); } function setSportsAMM(address _sportsAMM) external onlyOwner { sportsAMM = _sportsAMM; emit SetSportsAMM(_sportsAMM); } event SportPositionalMarketManagerChanged(address _positionalMarketManager); event SportPositionalMarketMastercopyChanged(address _positionalMarketMastercopy); event SportPositionMastercopyChanged(address _positionMastercopy); event SetSportsAMM(address _sportsAMM); event SetLimitOrderProvider(address _limitOrderProvider); event MarketCreated( address market, bytes32 indexed gameId, string gameLabel, uint maturityDate, uint expiryDate, uint initialMint, uint positionCount, uint[] tags, bool isChild, address parent ); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../interfaces/ISportPositionalMarket.sol"; interface ISportPositionalMarketManager { /* ========== VIEWS / VARIABLES ========== */ function marketCreationEnabled() external view returns (bool); function totalDeposited() external view returns (uint); function numActiveMarkets() external view returns (uint); function activeMarkets(uint index, uint pageSize) external view returns (address[] memory); function numMaturedMarkets() external view returns (uint); function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory); function isActiveMarket(address candidate) external view returns (bool); function isDoubleChanceMarket(address candidate) external view returns (bool); function doesSportSupportDoubleChance(uint _sport) external view returns (bool); function isDoubleChanceSupported() external view returns (bool); function isKnownMarket(address candidate) external view returns (bool); function getActiveMarketAddress(uint _index) external view returns (address); function transformCollateral(uint value) external view returns (uint); function reverseTransformCollateral(uint value) external view returns (uint); function isMarketPaused(address _market) external view returns (bool); function expiryDuration() external view returns (uint); function isWhitelistedAddress(address _address) external view returns (bool); function getOddsObtainer() external view returns (address obtainer); /* ========== MUTATIVE FUNCTIONS ========== */ function createMarket( bytes32 gameId, string memory gameLabel, uint maturity, uint initialMint, // initial sUSD to mint options for, uint positionCount, uint[] memory tags, bool isChild, address parentMarket ) external returns (ISportPositionalMarket); function setMarketPaused(address _market, bool _paused) external; function updateDatesForMarket(address _market, uint256 _newStartTime) external; function resolveMarket(address market, uint outcome) external; function expireMarkets(address[] calldata market) external; function transferSusdTo( address sender, address receiver, uint amount ) external; function queryMintsAndMaturityStatusForPlayerProps(address[] memory _playerPropsMarkets) external view returns ( bool[] memory _hasAnyMintsArray, bool[] memory _isMaturedArray, bool[] memory _isResolvedArray, uint[] memory _maturities ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IGamesOddsObtainer { struct GameOdds { bytes32 gameId; int24 homeOdds; int24 awayOdds; int24 drawOdds; int16 spreadHome; int24 spreadHomeOdds; int16 spreadAway; int24 spreadAwayOdds; uint24 totalOver; int24 totalOverOdds; uint24 totalUnder; int24 totalUnderOdds; } // view function getActiveChildMarketsFromParent(address _parent) external view returns (address, address); function getSpreadTotalsChildMarketsFromParent(address _parent) external view returns ( uint numOfSpreadMarkets, address[] memory spreadMarkets, uint numOfTotalsMarkets, address[] memory totalMarkets ); function areOddsValid(bytes32 _gameId, bool _useBackup) external view returns (bool); function invalidOdds(address _market) external view returns (bool); function getNormalizedOdds(bytes32 _gameId) external view returns (uint[] memory); function getNormalizedOddsForMarket(address _market) external view returns (uint[] memory); function getOddsForGames(bytes32[] memory _gameIds) external view returns (int24[] memory odds); function mainMarketChildMarketIndex(address _main, uint _index) external view returns (address); function numberOfChildMarkets(address _main) external view returns (uint); function mainMarketSpreadChildMarket(address _main, int16 _spread) external view returns (address); function mainMarketTotalChildMarket(address _main, uint24 _total) external view returns (address); function childMarketMainMarket(address _market) external view returns (address); function childMarketTotal(address _market) external view returns (uint24); function currentActiveTotalChildMarket(address _main) external view returns (address); function currentActiveSpreadChildMarket(address _main) external view returns (address); function isSpreadChildMarket(address _child) external view returns (bool); function childMarketCreated(address _child) external view returns (bool); function getOddsForGame(bytes32 _gameId) external view returns ( int24, int24, int24, int24, int24, int24, int24 ); function getLinesForGame(bytes32 _gameId) external view returns ( int16, int16, uint24, uint24 ); // executable function obtainOdds( bytes32 requestId, GameOdds memory _game, uint _sportId ) external; function setFirstOdds( bytes32 _gameId, int24 _homeOdds, int24 _awayOdds, int24 _drawOdds ) external; function setFirstNormalizedOdds(bytes32 _gameId, address _market) external; function setBackupOddsAsMainOddsForGame(bytes32 _gameId) external; function pauseUnpauseChildMarkets(address _main, bool _flag) external; function pauseUnpauseCurrentActiveChildMarket( bytes32 _gameId, address _main, bool _flag ) external; function resolveChildMarkets( address _market, uint _outcome, uint8 _homeScore, uint8 _awayScore ) external; function setChildMarketGameId(bytes32 gameId, address market) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IGamesPlayerProps { struct PlayerProps { bytes32 gameId; bytes32 playerId; uint8 option; string playerName; uint16 line; int24 overOdds; int24 underOdds; } struct PlayerPropsResolver { bytes32 gameId; bytes32 playerId; uint8 option; uint16 score; uint8 statusId; } function obtainPlayerProps(PlayerProps memory _player, uint _sportId) external; function resolvePlayerProps(PlayerPropsResolver memory _result) external; function cancelMarketFromManager(address _market) external; function pauseAllPlayerPropsMarketForMain( address _main, bool _flag, bool _invalidOddsOnMain, bool _circuitBreakerMain ) external; function createFulfilledForPlayerProps( bytes32 gameId, bytes32 playerId, uint8 option ) external view returns (bool); function cancelPlayerPropsMarketForMain(address _main) external; function getNormalizedOddsForMarket(address _market) external view returns (uint[] memory); function mainMarketChildMarketIndex(address _main, uint _index) external view returns (address); function numberOfChildMarkets(address _main) external view returns (uint); function doesSportSupportPlayerProps(uint _sportId) external view returns (bool); function pausedByInvalidOddsOnMain(address _main) external view returns (bool); function pausedByCircuitBreakerOnMain(address _main) external view returns (bool); function playerIdPerChildMarket(address _market) external view returns (bytes32); function optionIdPerChildMarket(address _market) external view returns (uint8); function getAllOptionsWithPlayersForGameId(bytes32 _gameId) external view returns ( bytes32[] memory _playerIds, uint8[] memory _options, bool[] memory _isResolved, address[][] memory _childMarketsPerOption ); function getPlayerPropsDataForMarket(address _market) external view returns ( address, bytes32, bytes32, uint8 ); function getPlayerPropForOption( bytes32 gameId, bytes32 playerId, uint8 option ) external view returns ( uint16, int24, int24, bool ); function fulfillPlayerPropsCLResolved(bytes[] memory _playerProps) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IGameChildMarket { function mainMarketChildMarketIndex(address _main, uint _index) external view returns (address); function numberOfChildMarkets(address _main) external view returns (uint); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/Clones.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library Clones { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create2(0, ptr, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, implementation)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000) mstore(add(ptr, 0x38), shl(0x60, deployer)) mstore(add(ptr, 0x4c), salt) mstore(add(ptr, 0x6c), keccak256(ptr, 0x37)) predicted := keccak256(add(ptr, 0x37), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address implementation, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maturity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_expiry","type":"uint256"}],"name":"DatesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"beneficiary","type":"address"}],"name":"Expired","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum ISportPositionalMarket.Side","name":"result","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"deposited","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"poolFees","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"creatorFees","type":"uint256"}],"name":"MarketResolved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"enum ISportPositionalMarket.Side","name":"side","type":"uint8"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"OptionsBurned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"OptionsExercised","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_paused","type":"bool"}],"name":"PauseUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_market","type":"address"},{"indexed":false,"internalType":"address","name":"_home","type":"address"},{"indexed":false,"internalType":"address","name":"_away","type":"address"},{"indexed":false,"internalType":"address","name":"_draw","type":"address"}],"name":"PositionsInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"homeOdds","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"awayOdds","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"drawOdds","type":"uint256"}],"name":"StoredOddsOnCancellation","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"awayOddsOnCancellation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balancesOf","outputs":[{"internalType":"uint256","name":"home","type":"uint256"},{"internalType":"uint256","name":"away","type":"uint256"},{"internalType":"uint256","name":"draw","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_homeBalance","type":"uint256"},{"internalType":"uint256","name":"_awayBalance","type":"uint256"},{"internalType":"uint256","name":"_drawBalance","type":"uint256"}],"name":"calculatePayoutOnCancellation","outputs":[{"internalType":"uint256","name":"payout","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"canResolve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deposited","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawOddsOnCancellation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exerciseOptions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"beneficiary","type":"address"}],"name":"expire","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"finalResult","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGameDetails","outputs":[{"internalType":"bytes32","name":"gameId","type":"bytes32"},{"internalType":"string","name":"gameLabel","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGameId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOptions","outputs":[{"internalType":"contract IPosition","name":"home","type":"address"},{"internalType":"contract IPosition","name":"away","type":"address"},{"internalType":"contract IPosition","name":"draw","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getParentMarketPositions","outputs":[{"internalType":"contract IPosition","name":"position1","type":"address"},{"internalType":"contract IPosition","name":"position2","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getParentMarketPositionsUint","outputs":[{"internalType":"uint256","name":"position1","type":"uint256"},{"internalType":"uint256","name":"position2","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStampedOdds","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTags","outputs":[{"internalType":"uint256","name":"tag1","type":"uint256"},{"internalType":"uint256","name":"tag2","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTagsLength","outputs":[{"internalType":"uint256","name":"tagsLength","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"homeOddsOnCancellation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"bytes32","name":"gameId","type":"bytes32"},{"internalType":"string","name":"gameLabel","type":"string"},{"internalType":"uint256[2]","name":"times","type":"uint256[2]"},{"internalType":"uint256","name":"positionCount","type":"uint256"},{"internalType":"address[]","name":"positions","type":"address[]"},{"internalType":"uint256[]","name":"tags","type":"uint256[]"},{"internalType":"bool","name":"isChild","type":"bool"},{"internalType":"address","name":"parentMarket","type":"address"},{"internalType":"bool","name":"isDoubleChance","type":"bool"},{"internalType":"address","name":"factory","type":"address"}],"internalType":"struct SportPositionalMarket.SportPositionalMarketParameters","name":"_parameters","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initializeOptions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"invalidOdds","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isChild","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isDoubleChance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"options","outputs":[{"internalType":"contract SportPosition","name":"home","type":"address"},{"internalType":"contract SportPosition","name":"away","type":"address"},{"internalType":"contract SportPosition","name":"draw","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"optionsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"optionsInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"parentMarket","outputs":[{"internalType":"contract ISportPositionalMarket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"parentTimes","outputs":[{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"phase","outputs":[{"internalType":"enum ISportPositionalMarket.Phase","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"requireUnpaused","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_outcome","type":"uint256"}],"name":"resolve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resolved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_homeOdds","type":"uint256"},{"internalType":"uint256","name":"_awayOdds","type":"uint256"},{"internalType":"uint256","name":"_drawOdds","type":"uint256"}],"name":"restoreInvalidOdds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"result","outputs":[{"internalType":"enum ISportPositionalMarket.Side","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tags","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"times","outputs":[{"internalType":"uint256","name":"maturity","type":"uint256"},{"internalType":"uint256","name":"destruction","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupplies","outputs":[{"internalType":"uint256","name":"home","type":"uint256"},{"internalType":"uint256","name":"away","type":"uint256"},{"internalType":"uint256","name":"draw","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maturity","type":"uint256"},{"internalType":"uint256","name":"_expiry","type":"uint256"}],"name":"updateDates","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040526013805461ff001916905534801561001b57600080fd5b506013805461ff001916610100179055614c638061003a6000396000f3fe608060405234801561001057600080fd5b50600436106102d65760003560e01c80638514925811610182578063c45a0155116100e9578063d068cdc5116100a2578063eef49ee31161007c578063eef49ee31461065a578063ef83f72414610663578063f3a8286f14610677578063fa20d6681461068057600080fd5b8063d068cdc514610631578063d63700bc14610639578063e6b2c87c1461064757600080fd5b8063c45a0155146105ab578063c8db233e146105be578063c9dd0e92146105d1578063cb2ff199146105e4578063cc2ee196146105f7578063d03ecc641461061657600080fd5b8063a0712d681161013b578063a0712d681461055e578063a14f582314610571578063ac3791e314610579578063b1c9fe6e14610581578063c0b303f514610596578063c0bd8351146105a357600080fd5b8063851492581461051757806388c886201461051f5780638da5cb5b14610527578063995d9ab71461053a5780639a82a09a146105425780639e3b34bf1461055657600080fd5b806341682b061161024157806353a47bb7116101fa578063647b65df116101d4578063647b65df146104c957806365372147146104f15780637684c8cb1461050657806379ba50971461050f57600080fd5b806353a47bb7146104905780635c975abb146104a35780636392a51f146104b657600080fd5b806341682b061461042057806344f2723f146104295780634641057d146104315780634f896d4f1461044457806350e947ab1461045757806350fc2c611461047a57600080fd5b806316c38b3c1161029357806316c38b3c146103bd5780631a1dbabb146103d057806320822abc146103e75780632584ccbb146103fa57806337df572e146104035780633f6fa6551461040c57600080fd5b806302d05d3f146102db57806308a0106c1461030b5780631069143a1461032857806311f2d49414610372578063158ef93e146103965780631627540c146103a8575b600080fd5b600e546102ee906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610313610694565b60408051928352602083019190915201610302565b600254600354600454610348926001600160a01b03908116928116911683565b604080516001600160a01b0394851681529284166020840152921691810191909152606001610302565b601354610386906301000000900460ff1681565b6040519015158152602001610302565b60135461038690610100900460ff1681565b6103bb6103b63660046144a4565b610852565b005b6103bb6103cb366004614584565b6108af565b6103d960055481565b604051908152602001610302565b6103d96103f53660046146dd565b610963565b6103d960105481565b6103d960115481565b600e5461038690600160a01b900460ff1681565b6103d9600f5481565b600b546103d9565b6103bb61043f3660046146a4565b610984565b6103bb6104523660046146dd565b610c78565b61045f610daa565b60408051938452602084019290925290820152606001610302565b610482610e1c565b604051610302929190614805565b6001546102ee906001600160a01b031681565b6013546103869062010000900460ff1681565b61045f6104c43660046144a4565b610e3d565b6104d1610e59565b604080516001600160a01b03938416815292909116602083015201610302565b6104f961100f565b6040516103029190614838565b6103d960125481565b6103bb61101e565b6103bb611108565b6103bb611722565b6000546102ee906001600160a01b031681565b61031361172c565b600e5461038690600160a81b900460ff1681565b6103136117d2565b6103bb61056c3660046146dd565b6117f1565b6103bb6119c1565b6103866119c9565b610589611a01565b604051610302919061481e565b6013546103869060ff1681565b6103d9611a2d565b6014546102ee906001600160a01b031681565b6103bb6105cc3660046144a4565b611a3d565b6103bb6105df366004614751565b611ade565b6103d96105f2366004614751565b611ba9565b6002546003546004546001600160a01b03928316929182169116610348565b6013546102ee9064010000000090046001600160a01b031681565b61045f611cac565b600654600754610313919082565b6103bb61065536600461470d565b611f42565b6103d9600d5481565b60135461038690600160c81b900460ff1681565b6103d9600c5481565b60135461038690600160c01b900460ff1681565b6013546000908190600160c01b900460ff161561084e576000601360049054906101000a90046001600160a01b03166001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b1580156106fb57600080fd5b505afa15801561070f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107339190614658565b50509050610748816001600160a01b03161590565b1561084c5760405170486f6d655465616d4e6f74546f4c6f736560781b60208201526031016040516020818303038152906040528051906020012061078b612077565b6020015160405160200161079f91906147e9565b6040516020818303038152906040528051906020012014156107c857600092506002915061084c565b60405170417761795465616d4e6f74546f4c6f736560781b602082015260310160405160208183030381529060405280519060200120610806612077565b6020015160405160200161081a91906147e9565b60405160208183030381529060405280519060200120141561084357600192506002915061084c565b60009250600191505b505b9091565b61085a612290565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906020015b60405180910390a150565b6108b7612290565b6108bf612302565b60135460ff6201000090910416151581151514156109185760405162461bcd60e51b815260206004820152601160248201527014dd185d19481b9bdd0818da185b99d959607a1b60448201526064015b60405180910390fd5b60138054821515620100000262ff0000199091161790556040517f77860e247ab9186dbe64e5bd0e0b93273cc4273e01818420e788f500078886f5906108a490831515815260200190565b600b818154811061097357600080fd5b600091825260209091200154905081565b601354610100900460ff16156109ea5760405162461bcd60e51b815260206004820152602560248201527f506f736974696f6e616c204d61726b657420616c726561647920696e697469616044820152641b1a5e995960da1b606482015260840161090f565b6013805461ff001916610100179055610a0e610a0960208301836144a4565b6123f1565b60c0810135600555610a2360e08201826149f3565b905060055414610a755760405162461bcd60e51b815260206004820152601760248201527f506f736974696f6e20636f756e74206d69736d61746368000000000000000000604482015260640161090f565b610a8560408201602083016144a4565b600e80546001600160a01b0319166001600160a01b0392909216919091179055610ab761014082016101208301614584565b80610acf5750610acf61018082016101608301614584565b15610b8e57610ae661014082016101208301614584565b6013805491151563010000000263ff00000019909216919091179055610b1461018082016101608301614584565b60138054911515600160c01b0260ff60c01b19909216919091179055610b42610160820161014083016144a4565b601380546001600160a01b039290921664010000000002640100000000600160c01b0319909216919091179055610b7c6060820182614a42565b610b8891600a9161435d565b50610c28565b604080518082018252608083013580825260a08401356020928301819052600691909155600755815180830183529183013582528101610bd16060840184614a42565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250805160089081556020808301518051610c249260099201906143e1565b5050505b610c366101008201826149f3565b610c4291600b91614455565b50610c556101a0820161018083016144a4565b601480546001600160a01b0319166001600160a01b039290921691909117905550565b610c80612290565b610c88612302565b600554811115610ccc5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206f7574636f6d6560881b604482015260640161090f565b80610d0657600e805460ff60a81b1916600160a81b17905542600f55601354600160c01b900460ff16610d0157610d016124ae565b610d53565b610d0e6119c9565b610d535760405162461bcd60e51b815260206004820152601660248201527510d85b881b9bdd081c995cdbdb1d99481b585c9ad95d60521b604482015260640161090f565b600c819055600e805460ff60a01b1916600160a01b1790557ff8cc2e475dd35323f81093a72f447ae02bcccdc3f7b49783e5b0f940e88d942c610d946126da565b600d546000806040516108a49493929190614861565b6000806000600e60159054906101000a900460ff1615610e1057601354600160c01b900460ff1615610dfe57600080610de161273f565b9092509050610df08183614ab8565b956000955085945092505050565b50506010546011546012549193909250565b50600092839250829150565b60006060610e28612077565b51610e31612077565b60200151915091509091565b6000806000610e4b84612926565b9250925092505b9193909250565b6013546000908190600160c01b900460ff161561084e576000806000601360049054906101000a90046001600160a01b03166001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b158015610ec357600080fd5b505afa158015610ed7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efb9190614658565b925092509250604051602001610f289070486f6d655465616d4e6f74546f4c6f736560781b815260110190565b60405160208183030381529060405280519060200120610f46612077565b60200151604051602001610f5a91906147e9565b604051602081830303815290604052805190602001201415610f8457919350909150829082611008565b60405170417761795465616d4e6f74546f4c6f736560781b602082015260310160405160208183030381529060405280519060200120610fc2612077565b60200151604051602001610fd691906147e9565b604051602081830303815290604052805190602001201415610ffe5790935091508282611008565b9193509150829082905b5050509091565b60006110196126da565b905090565b6001546001600160a01b031633146110965760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b606482015260840161090f565b600054600154604080516001600160a01b0393841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b600e54600160a01b900460ff1661114e5760405162461bcd60e51b815260206004820152600a602482015269155b9c995cdbdb1d995960b21b604482015260640161090f565b611156612be4565b1561118c5760405162461bcd60e51b815260206004820152600660248201526514185d5cd95960d21b604482015260640161090f565b600080600061119a33612926565b9250925092508260001415806111af57508115155b806111b957508015155b6111fb5760405162461bcd60e51b81526020600482015260136024820152724e6f7468696e6720746f20657865726369736560681b604482015260640161090f565b601354600160c01b900460ff1680156112175750611217612c8e565b1561128557601360049054906101000a90046001600160a01b03166001600160a01b031663851492586040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561126c57600080fd5b505af1158015611280573d6000803e3d6000fd5b505050505b82156112e957600254604051630d8acc1560e11b81523360048201526001600160a01b0390911690631b15982a90602401600060405180830381600087803b1580156112d057600080fd5b505af11580156112e4573d6000803e3d6000fd5b505050505b811561134d57600354604051630d8acc1560e11b81523360048201526001600160a01b0390911690631b15982a90602401600060405180830381600087803b15801561133457600080fd5b505af1158015611348573d6000803e3d6000fd5b505050505b80156113b25760048054604051630d8acc1560e11b815233928101929092526001600160a01b031690631b15982a90602401600060405180830381600087803b15801561139957600080fd5b505af11580156113ad573d6000803e3d6000fd5b505050505b60006113bf848484612e70565b600e54909150600160a81b900460ff16156114cd576114626113e96000546001600160a01b031690565b6001600160a01b0316633744734d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561142157600080fd5b505afa158015611435573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145991906146f5565b600f5490612f6e565b42118015611473575060135460ff16155b6114bf5760405162461bcd60e51b815260206004820152601f60248201527f556e657870697265642074696d656f75742f20696e76616c6964206f64647300604482015260640161090f565b6114ca848484611ba9565b90505b60405181815233907fd82b6f69d7477fb41cd83d936de94990cee2fa1a309feeee90101fc0513b6a439060200160405180910390a2801561171c57601354600160c01b900460ff166115245761152281612f83565b505b60005460405163edc892e160e01b8152600481018390526001600160a01b039091169063edc892e19060240160206040518083038186803b15801561156857600080fd5b505afa15801561157c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a091906146f5565b9050601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b1580156115f057600080fd5b505afa158015611604573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162891906144c0565b6001600160a01b0316639324cac76040518163ffffffff1660e01b815260040160206040518083038186803b15801561166057600080fd5b505afa158015611674573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169891906144c0565b60405163a9059cbb60e01b8152336004820152602481018390526001600160a01b03919091169063a9059cbb90604401602060405180830381600087803b1580156116e257600080fd5b505af11580156116f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171a91906145a0565b505b50505050565b61172a613010565b565b6000806001600b80549050111561179f57600b60008154811061175f57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549150600b60018154811061178e57634e487b7160e01b600052603260045260246000fd5b906000526020600020015490509091565b600b6000815481106117c157634e487b7160e01b600052603260045260246000fd5b906000526020600020015491509091565b60008060006117df613aab565b80516020909101519094909350915050565b6117f9613ba1565b15801561180b5750611809612be4565b155b61184a5760405162461bcd60e51b815260206004820152601060248201526f4d696e74696e6720696e61637469766560801b604482015260640161090f565b601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561189857600080fd5b505afa1580156118ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d091906144c0565b6001600160a01b0316336001600160a01b0316146119215760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21036b4b73a32b960911b604482015260640161090f565b806119295750565b6119333382613bb3565b601354600160c01b900460ff166119be5761194d81613e4b565b506000546001600160a01b0316604051635c847f5960e11b8152336004820152306024820152604481018390526001600160a01b03919091169063b908feb290606401600060405180830381600087803b1580156119aa57600080fd5b505af115801561171a573d6000803e3d6000fd5b50565b61172a612302565b600e54600090600160a01b900460ff161580156119e957506119e9613ba1565b801561101957505060135462010000900460ff161590565b6000611a0b613ba1565b611a155750600090565b611a1d613ea1565b611a275750600190565b50600290565b6000611a37612077565b51919050565b611a45612290565b611a4d613ea1565b611a995760405162461bcd60e51b815260206004820152601b60248201527f556e65787069726564206f7074696f6e732072656d61696e696e670000000000604482015260640161090f565b6040516001600160a01b03821681527fd5669ebe8b90ed693033f1915dcea031e7a16a6f146a8326c02eec10eed77edd9060200160405180910390a16119be81613ed4565b611ae6612290565b600083118015611af65750600082115b611b305760405162461bcd60e51b815260206004820152600b60248201526a125b9d985b1a59081bd91960aa1b604482015260640161090f565b60108390556011829055600554600210611b4b576000611b4d565b805b60128190556013805460ff191690556010546011546040805192835260208301919091528101919091527fff554c9505df49513bbfe3d3b79c4e8c93d7ea27e843facef592e4d94af60ced9060600160405180910390a1505050565b600e54600090600160a81b900460ff16611bc557506000611ca5565b601354600160c01b900460ff1615611c2e57600080611be261273f565b9092509050611c03670de0b6b3a7640000611bfd888561429c565b906142a8565b9250611c25611c1e670de0b6b3a7640000611bfd898561429c565b8490612f6e565b92505050611ca5565b611c4f670de0b6b3a7640000611bfd6010548761429c90919063ffffffff16565b9050611c7c611c75670de0b6b3a7640000611bfd6011548761429c90919063ffffffff16565b8290612f6e565b9050611ca2611c75670de0b6b3a7640000611bfd6012548661429c90919063ffffffff16565b90505b9392505050565b600080600060026005541115611e3b57600254604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b158015611d0157600080fd5b505afa158015611d15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3991906146f5565b600354604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b158015611d7e57600080fd5b505afa158015611d92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db691906146f5565b60048054604080516318160ddd60e01b815290516001600160a01b03909216926318160ddd928282019260209290829003018186803b158015611df857600080fd5b505afa158015611e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3091906146f5565b925092509250909192565b600254604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b158015611e8057600080fd5b505afa158015611e94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eb891906146f5565b600354604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b158015611efd57600080fd5b505afa158015611f11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f3591906146f5565b6000925092509250909192565b611f4a612290565b611f52612302565b601354600160c01b900460ff1615611fbc5760405162461bcd60e51b815260206004820152602760248201527f4e6f7420737570706f7274656420666f7220646f75626c65206368616e6365206044820152666d61726b65747360c81b606482015260840161090f565b42821161200b5760405162461bcd60e51b815260206004820152601c60248201527f4d61747572697479206d75737420626520696e20612066757475726500000000604482015260640161090f565b6013546301000000900460ff1661203a5760408051808201909152828152602001819052600682905560078190555b60408051838152602081018390527f070aa07a2e5f94bbac2e0a5c78100b2c0e686f6f43d555537f89133916d4f316910160405180910390a15050565b6040805180820190915260008152606060208201526013546301000000900460ff16806120ad5750601354600160c01b900460ff165b156121e6576000601360049054906101000a90046001600160a01b03166001600160a01b03166350fc2c616040518163ffffffff1660e01b815260040160006040518083038186803b15801561210257600080fd5b505afa158015612116573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261213e91908101906145bc565b5090506040518060400160405280828152602001600a805461215f90614b52565b80601f016020809104026020016040519081016040528092919081815260200182805461218b90614b52565b80156121d85780601f106121ad576101008083540402835291602001916121d8565b820191906000526020600020905b8154815290600101906020018083116121bb57829003601f168201915b505050505081525091505090565b604080518082019091526008805482526009805460208401919061220990614b52565b80601f016020809104026020016040519081016040528092919081815260200182805461223590614b52565b80156122825780601f1061225757610100808354040283529160200191612282565b820191906000526020600020905b81548152906001019060200180831161226557829003601f168201915b505050505081525050905090565b6000546001600160a01b0316331461172a5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b606482015260840161090f565b6000546001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561234657600080fd5b505afa15801561235a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061237e91906145a0565b1561172a5760405162461bcd60e51b815260206004820152603c60248201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060448201527f7768696c652074686520636f6e74726163742069732070617573656400000000606482015260840161090f565b6000546001600160a01b03161561245a5760405162461bcd60e51b815260206004820152602760248201527f496e69742063616e206f6e6c792062652063616c6c6564207768656e206f776e6044820152660657220697320360cc1b606482015260840161090f565b600080546001600160a01b0319166001600160a01b03831690811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91016108a4565b600060055467ffffffffffffffff8111156124d957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612502578160200160208202803683370190505b50600e5460405163db0d457960e01b81523060048201529192506001600160a01b03169063db0d45799060240160006040518083038186803b15801561254757600080fd5b505afa15801561255b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261258391908101906144dc565b9050806000815181106125a657634e487b7160e01b600052603260045260246000fd5b6020026020010151600014806125e45750806001815181106125d857634e487b7160e01b600052603260045260246000fd5b60200260200101516000145b156125f7576013805460ff191660011790555b8060008151811061261857634e487b7160e01b600052603260045260246000fd5b60200260200101516010819055508060018151811061264757634e487b7160e01b600052603260045260246000fd5b6020026020010151601181905550600260055411612666576000612690565b8060028151811061268757634e487b7160e01b600052603260045260246000fd5b60200260200101515b60128190556010546011546040805192835260208301919091528101919091527fff554c9505df49513bbfe3d3b79c4e8c93d7ea27e843facef592e4d94af60ced906060016108a4565b600e54600090600160a01b900460ff1615806126ff5750600e54600160a81b900460ff165b1561270a5750600090565b600c54600314801561271e57506002600554115b156127295750600390565b600c546001146127395750600290565b50600190565b6000806000806000601360049054906101000a90046001600160a01b03166001600160a01b03166350e947ab6040518163ffffffff1660e01b815260040160606040518083038186803b15801561279557600080fd5b505afa1580156127a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127cd919061477c565b9250925092506000806127de610e59565b91509150600080601360049054906101000a90046001600160a01b03166001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b15801561283357600080fd5b505afa158015612847573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061286b9190614658565b5091509150612881826001600160a01b03161590565b1561289757506000988998509650505050505050565b816001600160a01b0316846001600160a01b0316146128d557806001600160a01b0316846001600160a01b0316146128cf57846128d7565b856128d7565b865b9850816001600160a01b0316836001600160a01b03161461291757806001600160a01b0316836001600160a01b0316146129115784612919565b85612919565b865b9750505050505050509091565b6000806000601360199054906101000a900460ff1661294d57506000915081905080610e52565b60026005541115612adc57600254604051634dcb776760e11b81526001600160a01b03868116600483015290911690639b96eece9060240160206040518083038186803b15801561299d57600080fd5b505afa1580156129b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129d591906146f5565b600354604051634dcb776760e11b81526001600160a01b03878116600483015290911690639b96eece9060240160206040518083038186803b158015612a1a57600080fd5b505afa158015612a2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a5291906146f5565b60048054604051634dcb776760e11b81526001600160a01b0389811693820193909352911690639b96eece9060240160206040518083038186803b158015612a9957600080fd5b505afa158015612aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad191906146f5565b925092509250610e52565b600254604051634dcb776760e11b81526001600160a01b03868116600483015290911690639b96eece9060240160206040518083038186803b158015612b2157600080fd5b505afa158015612b35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b5991906146f5565b600354604051634dcb776760e11b81526001600160a01b03878116600483015290911690639b96eece9060240160206040518083038186803b158015612b9e57600080fd5b505afa158015612bb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bd691906146f5565b909590945060009350915050565b601354600090600160c01b900460ff16612c08575060135462010000900460ff1690565b601360049054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c5657600080fd5b505afa158015612c6a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101991906145a0565b6000601360049054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015612cde57600080fd5b505afa158015612cf2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1691906145a0565b158015612da65750601360049054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b158015612d6c57600080fd5b505afa158015612d80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612da491906145a0565b155b15612db15750600090565b601354604051636392a51f60e01b81523060048201526000918291829164010000000090046001600160a01b031690636392a51f9060240160606040518083038186803b158015612e0157600080fd5b505afa158015612e15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e39919061477c565b925092509250826000148015612e4d575081155b8015612e57575080155b15612e66576000935050505090565b6001935050505090565b601354600090600160c01b900460ff1615612ebc576001612e8f6126da565b6003811115612eae57634e487b7160e01b600052602160045260246000fd5b1415612eb75750825b611ca5565b6001612ec66126da565b6003811115612ee557634e487b7160e01b600052602160045260246000fd5b14612ef05782612ef2565b835b90506002600554118015612f2d57506001612f0b6126da565b6003811115612f2a57634e487b7160e01b600052602160045260246000fd5b14155b15611ca5576002612f3c6126da565b6003811115612f5b57634e487b7160e01b600052602160045260246000fd5b14612f665781611ca2565b509092915050565b6000612f7a8284614ab8565b90505b92915050565b600d54600090612f9390836142b4565b600d8190559050612fac6000546001600160a01b031690565b6001600160a01b0316636b3a0984836040518263ffffffff1660e01b8152600401612fd991815260200190565b600060405180830381600087803b158015612ff357600080fd5b505af1158015613007573d6000803e3d6000fd5b50505050919050565b601354600160c81b900460ff16156130605760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b604482015260640161090f565b600060055467ffffffffffffffff81111561308b57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156130b4578160200160208202803683370190505b50905060005b600554811015613191576014546040805163015d74c560e51b81529051613147926001600160a01b031691632bae98a0916004808301926020929190829003018186803b15801561310a57600080fd5b505afa15801561311e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061314291906144c0565b6142c0565b82828151811061316757634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101528061318981614b8d565b9150506130ba565b50806000815181106131b357634e487b7160e01b600052603260045260246000fd5b6020026020010151600260000160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508060018151811061320557634e487b7160e01b600052603260045260246000fd5b6020908102919091010151600380546001600160a01b0319166001600160a01b039092169190911790556013546301000000900460ff16156136ed57600b546001106132a55760405162461bcd60e51b815260206004820152602960248201527f4368696c64206d61726b657473206d7573742068617665206d6f7265207468656044820152686e206f6e652074616760b81b606482015260840161090f565b600b6001815481106132c757634e487b7160e01b600052603260045260246000fd5b906000526020600020015461271114156134c6576002546001600160a01b031663077f224a6132f4612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561334657600080fd5b505afa15801561335a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061337e91906144c0565b6040518363ffffffff1660e01b815260040161339b9291906148d2565b600060405180830381600087803b1580156133b557600080fd5b505af11580156133c9573d6000803e3d6000fd5b50506003546001600160a01b0316915063077f224a90506133e8612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561343a57600080fd5b505afa15801561344e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061347291906144c0565b6040518363ffffffff1660e01b815260040161348f929190614963565b600060405180830381600087803b1580156134a957600080fd5b505af11580156134bd573d6000803e3d6000fd5b505050506138d4565b600b6001815481106134e857634e487b7160e01b600052603260045260246000fd5b9060005260206000200154612712148061352f5750600b60018154811061351f57634e487b7160e01b600052603260045260246000fd5b906000526020600020015461271a145b156136e8576002546001600160a01b031663077f224a61354d612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561359f57600080fd5b505afa1580156135b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135d791906144c0565b6040518363ffffffff1660e01b81526004016135f49291906149ab565b600060405180830381600087803b15801561360e57600080fd5b505af1158015613622573d6000803e3d6000fd5b50506003546001600160a01b0316915063077f224a9050613641612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561369357600080fd5b505afa1580156136a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136cb91906144c0565b6040518363ffffffff1660e01b815260040161348f92919061491a565b6138d4565b6002546001600160a01b031663077f224a613706612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561375857600080fd5b505afa15801561376c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379091906144c0565b6040518363ffffffff1660e01b81526004016137ad9291906148d2565b600060405180830381600087803b1580156137c757600080fd5b505af11580156137db573d6000803e3d6000fd5b50506003546001600160a01b0316915063077f224a90506137fa612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561384c57600080fd5b505afa158015613860573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061388491906144c0565b6040518363ffffffff1660e01b81526004016138a1929190614963565b600060405180830381600087803b1580156138bb57600080fd5b505af11580156138cf573d6000803e3d6000fd5b505050505b60026005541115613a10578060028151811061390057634e487b7160e01b600052603260045260246000fd5b6020908102919091010151600480546001600160a01b0319166001600160a01b03909216918217905563077f224a613936612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561398857600080fd5b505afa15801561399c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139c091906144c0565b6040518363ffffffff1660e01b81526004016139dd92919061488a565b600060405180830381600087803b1580156139f757600080fd5b505af1158015613a0b573d6000803e3d6000fd5b505050505b6013805460ff60c81b1916600160c81b179055600280546003546005547f2d010965ba615ce04b2caa89ec260d016efa5b5eb0e6ad0690c5c507bfe924689330936001600160a01b0390811693169111613a6b576000613a78565b6004546001600160a01b03165b604080516001600160a01b03958616815293851660208501529184169183019190915290911660608201526080016108a4565b60408051808201909152600080825260208201526013546301000000900460ff1680613ae05750601354600160c01b900460ff165b15613b8657600080601360049054906101000a90046001600160a01b03166001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b158015613b3557600080fd5b505afa158015613b49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b6d919061472e565b6040805180820190915291825260208201529392505050565b50604080518082019091526006548152600754602082015290565b600042613bac613aab565b5110919050565b601354600160c81b900460ff16613bcc57613bcc613010565b601354600160c01b900460ff1615613c7a576002546040516340c10f1960e01b81526001600160a01b03848116600483015260248201849052909116906340c10f1990604401600060405180830381600087803b158015613c2c57600080fd5b505af1158015613c40573d6000803e3d6000fd5b50505050816001600160a01b0316600080516020614c0e833981519152600183604051613c6e929190614846565b60405180910390a25050565b6002546040516340c10f1960e01b81526001600160a01b03848116600483015260248201849052909116906340c10f1990604401600060405180830381600087803b158015613cc857600080fd5b505af1158015613cdc573d6000803e3d6000fd5b50506003546040516340c10f1960e01b81526001600160a01b0386811660048301526024820186905290911692506340c10f199150604401600060405180830381600087803b158015613d2e57600080fd5b505af1158015613d42573d6000803e3d6000fd5b50505050816001600160a01b0316600080516020614c0e833981519152600183604051613d70929190614846565b60405180910390a2816001600160a01b0316600080516020614c0e833981519152600283604051613da2929190614846565b60405180910390a260026005541115613e4757600480546040516340c10f1960e01b81526001600160a01b0385811693820193909352602481018490529116906340c10f1990604401600060405180830381600087803b158015613e0557600080fd5b505af1158015613e19573d6000803e3d6000fd5b50505050816001600160a01b0316600080516020614c0e833981519152600383604051613c6e929190614846565b5050565b600d54600090613e5b9083612f6e565b600d8190559050613e746000546001600160a01b031690565b6001600160a01b031663aeab5849836040518263ffffffff1660e01b8152600401612fd991815260200190565b600e54600090600160a01b900460ff168015611019575042613ec1613aab565b602001511080611019575050600d541590565b600d548015613ee857613ee681612f83565b505b601454604080516319324a5160e31b815290516000926001600160a01b03169163c9925288916004808301926020929190829003018186803b158015613f2d57600080fd5b505afa158015613f41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f6591906144c0565b6001600160a01b0316639324cac76040518163ffffffff1660e01b815260040160206040518083038186803b158015613f9d57600080fd5b505afa158015613fb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fd591906144c0565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b15801561401657600080fd5b505afa15801561402a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061404e91906146f5565b905080156141d257601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b1580156140a457600080fd5b505afa1580156140b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140dc91906144c0565b6001600160a01b0316639324cac76040518163ffffffff1660e01b815260040160206040518083038186803b15801561411457600080fd5b505afa158015614128573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061414c91906144c0565b60405163a9059cbb60e01b81526001600160a01b03858116600483015260248201849052919091169063a9059cbb90604401602060405180830381600087803b15801561419857600080fd5b505af11580156141ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141d091906145a0565b505b60025460405163646d919f60e11b81526001600160a01b0385811660048301529091169063c8db233e90602401600060405180830381600087803b15801561421957600080fd5b505af115801561422d573d6000803e3d6000fd5b505060035460405163646d919f60e11b81526001600160a01b038781166004830152909116925063c8db233e9150602401600060405180830381600087803b15801561427857600080fd5b505af115801561428c573d6000803e3d6000fd5b50505050826001600160a01b0316ff5b6000612f7a8284614af0565b6000612f7a8284614ad0565b6000612f7a8284614b0f565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b0381166143585760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b604482015260640161090f565b919050565b82805461436990614b52565b90600052602060002090601f01602090048101928261438b57600085556143d1565b82601f106143a45782800160ff198235161785556143d1565b828001600101855582156143d1579182015b828111156143d15782358255916020019190600101906143b6565b506143dd92915061448f565b5090565b8280546143ed90614b52565b90600052602060002090601f01602090048101928261440f57600085556143d1565b82601f1061442857805160ff19168380011785556143d1565b828001600101855582156143d1579182015b828111156143d157825182559160200191906001019061443a565b8280548282559060005260206000209081019282156143d157916020028201828111156143d15782358255916020019190600101906143b6565b5b808211156143dd5760008155600101614490565b6000602082840312156144b5578081fd5b8135611ca581614bea565b6000602082840312156144d1578081fd5b8151611ca581614bea565b600060208083850312156144ee578182fd5b825167ffffffffffffffff80821115614505578384fd5b818501915085601f830112614518578384fd5b81518181111561452a5761452a614bd4565b8060051b915061453b848301614a87565b8181528481019084860184860187018a1015614555578788fd5b8795505b83861015614577578051835260019590950194918601918601614559565b5098975050505050505050565b600060208284031215614595578081fd5b8135611ca581614bff565b6000602082840312156145b1578081fd5b8151611ca581614bff565b600080604083850312156145ce578081fd5b82519150602083015167ffffffffffffffff808211156145ec578283fd5b818501915085601f8301126145ff578283fd5b81518181111561461157614611614bd4565b614624601f8201601f1916602001614a87565b915080825286602082850101111561463a578384fd5b61464b816020840160208601614b26565b5080925050509250929050565b60008060006060848603121561466c578081fd5b835161467781614bea565b602085015190935061468881614bea565b604085015190925061469981614bea565b809150509250925092565b6000602082840312156146b5578081fd5b813567ffffffffffffffff8111156146cb578182fd5b82016101a08185031215611ca5578182fd5b6000602082840312156146ee578081fd5b5035919050565b600060208284031215614706578081fd5b5051919050565b6000806040838503121561471f578182fd5b50508035926020909101359150565b60008060408385031215614740578182fd5b505080516020909101519092909150565b600080600060608486031215614765578081fd5b505081359360208301359350604090920135919050565b600080600060608486031215614790578081fd5b8351925060208401519150604084015190509250925092565b600481106147b9576147b9614bbe565b9052565b600081518084526147d5816020860160208601614b26565b601f01601f19169290920160200192915050565b600082516147fb818460208701614b26565b9190910192915050565b828152604060208201526000611ca260408301846147bd565b602081016003831061483257614832614bbe565b91905290565b60208101612f7d82846147a9565b6040810161485482856147a9565b8260208301529392505050565b6080810161486f82876147a9565b84602083015283604083015282606083015295945050505050565b60608152600061489d60608301856147bd565b82810360208085019190915260048252634452415760e01b908201526001600160a01b03939093166040928301525001919050565b6060815260006148e560608301856147bd565b8281036020808501919091526004825263484f4d4560e01b908201526001600160a01b03939093166040928301525001919050565b60608152600061492d60608301856147bd565b82810360208085019190915260058252642aa72222a960d91b908201526001600160a01b03939093166040928301525001919050565b60608152600061497660608301856147bd565b82810360208085019190915260048252634157415960e01b908201526001600160a01b03939093166040928301525001919050565b6060815260006149be60608301856147bd565b828103602080850191909152600482526327ab22a960e11b908201526001600160a01b03939093166040928301525001919050565b6000808335601e19843603018112614a09578283fd5b83018035915067ffffffffffffffff821115614a23578283fd5b6020019150600581901b3603821315614a3b57600080fd5b9250929050565b6000808335601e19843603018112614a58578283fd5b83018035915067ffffffffffffffff821115614a72578283fd5b602001915036819003821315614a3b57600080fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715614ab057614ab0614bd4565b604052919050565b60008219821115614acb57614acb614ba8565b500190565b600082614aeb57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615614b0a57614b0a614ba8565b500290565b600082821015614b2157614b21614ba8565b500390565b60005b83811015614b41578181015183820152602001614b29565b8381111561171c5750506000910152565b600181811c90821680614b6657607f821691505b60208210811415614b8757634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415614ba157614ba1614ba8565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146119be57600080fd5b80151581146119be57600080fdfe377111a2ead9c89151d782f261f5cfbfff7958bed8335f97dd6356765ad5c155a264697066735822122046fc03787899dc369452c4c31db690ab3bba3beb2cff75af99d4bfb5549b195364736f6c63430008040033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102d65760003560e01c80638514925811610182578063c45a0155116100e9578063d068cdc5116100a2578063eef49ee31161007c578063eef49ee31461065a578063ef83f72414610663578063f3a8286f14610677578063fa20d6681461068057600080fd5b8063d068cdc514610631578063d63700bc14610639578063e6b2c87c1461064757600080fd5b8063c45a0155146105ab578063c8db233e146105be578063c9dd0e92146105d1578063cb2ff199146105e4578063cc2ee196146105f7578063d03ecc641461061657600080fd5b8063a0712d681161013b578063a0712d681461055e578063a14f582314610571578063ac3791e314610579578063b1c9fe6e14610581578063c0b303f514610596578063c0bd8351146105a357600080fd5b8063851492581461051757806388c886201461051f5780638da5cb5b14610527578063995d9ab71461053a5780639a82a09a146105425780639e3b34bf1461055657600080fd5b806341682b061161024157806353a47bb7116101fa578063647b65df116101d4578063647b65df146104c957806365372147146104f15780637684c8cb1461050657806379ba50971461050f57600080fd5b806353a47bb7146104905780635c975abb146104a35780636392a51f146104b657600080fd5b806341682b061461042057806344f2723f146104295780634641057d146104315780634f896d4f1461044457806350e947ab1461045757806350fc2c611461047a57600080fd5b806316c38b3c1161029357806316c38b3c146103bd5780631a1dbabb146103d057806320822abc146103e75780632584ccbb146103fa57806337df572e146104035780633f6fa6551461040c57600080fd5b806302d05d3f146102db57806308a0106c1461030b5780631069143a1461032857806311f2d49414610372578063158ef93e146103965780631627540c146103a8575b600080fd5b600e546102ee906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610313610694565b60408051928352602083019190915201610302565b600254600354600454610348926001600160a01b03908116928116911683565b604080516001600160a01b0394851681529284166020840152921691810191909152606001610302565b601354610386906301000000900460ff1681565b6040519015158152602001610302565b60135461038690610100900460ff1681565b6103bb6103b63660046144a4565b610852565b005b6103bb6103cb366004614584565b6108af565b6103d960055481565b604051908152602001610302565b6103d96103f53660046146dd565b610963565b6103d960105481565b6103d960115481565b600e5461038690600160a01b900460ff1681565b6103d9600f5481565b600b546103d9565b6103bb61043f3660046146a4565b610984565b6103bb6104523660046146dd565b610c78565b61045f610daa565b60408051938452602084019290925290820152606001610302565b610482610e1c565b604051610302929190614805565b6001546102ee906001600160a01b031681565b6013546103869062010000900460ff1681565b61045f6104c43660046144a4565b610e3d565b6104d1610e59565b604080516001600160a01b03938416815292909116602083015201610302565b6104f961100f565b6040516103029190614838565b6103d960125481565b6103bb61101e565b6103bb611108565b6103bb611722565b6000546102ee906001600160a01b031681565b61031361172c565b600e5461038690600160a81b900460ff1681565b6103136117d2565b6103bb61056c3660046146dd565b6117f1565b6103bb6119c1565b6103866119c9565b610589611a01565b604051610302919061481e565b6013546103869060ff1681565b6103d9611a2d565b6014546102ee906001600160a01b031681565b6103bb6105cc3660046144a4565b611a3d565b6103bb6105df366004614751565b611ade565b6103d96105f2366004614751565b611ba9565b6002546003546004546001600160a01b03928316929182169116610348565b6013546102ee9064010000000090046001600160a01b031681565b61045f611cac565b600654600754610313919082565b6103bb61065536600461470d565b611f42565b6103d9600d5481565b60135461038690600160c81b900460ff1681565b6103d9600c5481565b60135461038690600160c01b900460ff1681565b6013546000908190600160c01b900460ff161561084e576000601360049054906101000a90046001600160a01b03166001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b1580156106fb57600080fd5b505afa15801561070f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107339190614658565b50509050610748816001600160a01b03161590565b1561084c5760405170486f6d655465616d4e6f74546f4c6f736560781b60208201526031016040516020818303038152906040528051906020012061078b612077565b6020015160405160200161079f91906147e9565b6040516020818303038152906040528051906020012014156107c857600092506002915061084c565b60405170417761795465616d4e6f74546f4c6f736560781b602082015260310160405160208183030381529060405280519060200120610806612077565b6020015160405160200161081a91906147e9565b60405160208183030381529060405280519060200120141561084357600192506002915061084c565b60009250600191505b505b9091565b61085a612290565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906020015b60405180910390a150565b6108b7612290565b6108bf612302565b60135460ff6201000090910416151581151514156109185760405162461bcd60e51b815260206004820152601160248201527014dd185d19481b9bdd0818da185b99d959607a1b60448201526064015b60405180910390fd5b60138054821515620100000262ff0000199091161790556040517f77860e247ab9186dbe64e5bd0e0b93273cc4273e01818420e788f500078886f5906108a490831515815260200190565b600b818154811061097357600080fd5b600091825260209091200154905081565b601354610100900460ff16156109ea5760405162461bcd60e51b815260206004820152602560248201527f506f736974696f6e616c204d61726b657420616c726561647920696e697469616044820152641b1a5e995960da1b606482015260840161090f565b6013805461ff001916610100179055610a0e610a0960208301836144a4565b6123f1565b60c0810135600555610a2360e08201826149f3565b905060055414610a755760405162461bcd60e51b815260206004820152601760248201527f506f736974696f6e20636f756e74206d69736d61746368000000000000000000604482015260640161090f565b610a8560408201602083016144a4565b600e80546001600160a01b0319166001600160a01b0392909216919091179055610ab761014082016101208301614584565b80610acf5750610acf61018082016101608301614584565b15610b8e57610ae661014082016101208301614584565b6013805491151563010000000263ff00000019909216919091179055610b1461018082016101608301614584565b60138054911515600160c01b0260ff60c01b19909216919091179055610b42610160820161014083016144a4565b601380546001600160a01b039290921664010000000002640100000000600160c01b0319909216919091179055610b7c6060820182614a42565b610b8891600a9161435d565b50610c28565b604080518082018252608083013580825260a08401356020928301819052600691909155600755815180830183529183013582528101610bd16060840184614a42565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050915250805160089081556020808301518051610c249260099201906143e1565b5050505b610c366101008201826149f3565b610c4291600b91614455565b50610c556101a0820161018083016144a4565b601480546001600160a01b0319166001600160a01b039290921691909117905550565b610c80612290565b610c88612302565b600554811115610ccc5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206f7574636f6d6560881b604482015260640161090f565b80610d0657600e805460ff60a81b1916600160a81b17905542600f55601354600160c01b900460ff16610d0157610d016124ae565b610d53565b610d0e6119c9565b610d535760405162461bcd60e51b815260206004820152601660248201527510d85b881b9bdd081c995cdbdb1d99481b585c9ad95d60521b604482015260640161090f565b600c819055600e805460ff60a01b1916600160a01b1790557ff8cc2e475dd35323f81093a72f447ae02bcccdc3f7b49783e5b0f940e88d942c610d946126da565b600d546000806040516108a49493929190614861565b6000806000600e60159054906101000a900460ff1615610e1057601354600160c01b900460ff1615610dfe57600080610de161273f565b9092509050610df08183614ab8565b956000955085945092505050565b50506010546011546012549193909250565b50600092839250829150565b60006060610e28612077565b51610e31612077565b60200151915091509091565b6000806000610e4b84612926565b9250925092505b9193909250565b6013546000908190600160c01b900460ff161561084e576000806000601360049054906101000a90046001600160a01b03166001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b158015610ec357600080fd5b505afa158015610ed7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610efb9190614658565b925092509250604051602001610f289070486f6d655465616d4e6f74546f4c6f736560781b815260110190565b60405160208183030381529060405280519060200120610f46612077565b60200151604051602001610f5a91906147e9565b604051602081830303815290604052805190602001201415610f8457919350909150829082611008565b60405170417761795465616d4e6f74546f4c6f736560781b602082015260310160405160208183030381529060405280519060200120610fc2612077565b60200151604051602001610fd691906147e9565b604051602081830303815290604052805190602001201415610ffe5790935091508282611008565b9193509150829082905b5050509091565b60006110196126da565b905090565b6001546001600160a01b031633146110965760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b606482015260840161090f565b600054600154604080516001600160a01b0393841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b600e54600160a01b900460ff1661114e5760405162461bcd60e51b815260206004820152600a602482015269155b9c995cdbdb1d995960b21b604482015260640161090f565b611156612be4565b1561118c5760405162461bcd60e51b815260206004820152600660248201526514185d5cd95960d21b604482015260640161090f565b600080600061119a33612926565b9250925092508260001415806111af57508115155b806111b957508015155b6111fb5760405162461bcd60e51b81526020600482015260136024820152724e6f7468696e6720746f20657865726369736560681b604482015260640161090f565b601354600160c01b900460ff1680156112175750611217612c8e565b1561128557601360049054906101000a90046001600160a01b03166001600160a01b031663851492586040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561126c57600080fd5b505af1158015611280573d6000803e3d6000fd5b505050505b82156112e957600254604051630d8acc1560e11b81523360048201526001600160a01b0390911690631b15982a90602401600060405180830381600087803b1580156112d057600080fd5b505af11580156112e4573d6000803e3d6000fd5b505050505b811561134d57600354604051630d8acc1560e11b81523360048201526001600160a01b0390911690631b15982a90602401600060405180830381600087803b15801561133457600080fd5b505af1158015611348573d6000803e3d6000fd5b505050505b80156113b25760048054604051630d8acc1560e11b815233928101929092526001600160a01b031690631b15982a90602401600060405180830381600087803b15801561139957600080fd5b505af11580156113ad573d6000803e3d6000fd5b505050505b60006113bf848484612e70565b600e54909150600160a81b900460ff16156114cd576114626113e96000546001600160a01b031690565b6001600160a01b0316633744734d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561142157600080fd5b505afa158015611435573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145991906146f5565b600f5490612f6e565b42118015611473575060135460ff16155b6114bf5760405162461bcd60e51b815260206004820152601f60248201527f556e657870697265642074696d656f75742f20696e76616c6964206f64647300604482015260640161090f565b6114ca848484611ba9565b90505b60405181815233907fd82b6f69d7477fb41cd83d936de94990cee2fa1a309feeee90101fc0513b6a439060200160405180910390a2801561171c57601354600160c01b900460ff166115245761152281612f83565b505b60005460405163edc892e160e01b8152600481018390526001600160a01b039091169063edc892e19060240160206040518083038186803b15801561156857600080fd5b505afa15801561157c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a091906146f5565b9050601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b1580156115f057600080fd5b505afa158015611604573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162891906144c0565b6001600160a01b0316639324cac76040518163ffffffff1660e01b815260040160206040518083038186803b15801561166057600080fd5b505afa158015611674573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169891906144c0565b60405163a9059cbb60e01b8152336004820152602481018390526001600160a01b03919091169063a9059cbb90604401602060405180830381600087803b1580156116e257600080fd5b505af11580156116f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171a91906145a0565b505b50505050565b61172a613010565b565b6000806001600b80549050111561179f57600b60008154811061175f57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549150600b60018154811061178e57634e487b7160e01b600052603260045260246000fd5b906000526020600020015490509091565b600b6000815481106117c157634e487b7160e01b600052603260045260246000fd5b906000526020600020015491509091565b60008060006117df613aab565b80516020909101519094909350915050565b6117f9613ba1565b15801561180b5750611809612be4565b155b61184a5760405162461bcd60e51b815260206004820152601060248201526f4d696e74696e6720696e61637469766560801b604482015260640161090f565b601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561189857600080fd5b505afa1580156118ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118d091906144c0565b6001600160a01b0316336001600160a01b0316146119215760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21036b4b73a32b960911b604482015260640161090f565b806119295750565b6119333382613bb3565b601354600160c01b900460ff166119be5761194d81613e4b565b506000546001600160a01b0316604051635c847f5960e11b8152336004820152306024820152604481018390526001600160a01b03919091169063b908feb290606401600060405180830381600087803b1580156119aa57600080fd5b505af115801561171a573d6000803e3d6000fd5b50565b61172a612302565b600e54600090600160a01b900460ff161580156119e957506119e9613ba1565b801561101957505060135462010000900460ff161590565b6000611a0b613ba1565b611a155750600090565b611a1d613ea1565b611a275750600190565b50600290565b6000611a37612077565b51919050565b611a45612290565b611a4d613ea1565b611a995760405162461bcd60e51b815260206004820152601b60248201527f556e65787069726564206f7074696f6e732072656d61696e696e670000000000604482015260640161090f565b6040516001600160a01b03821681527fd5669ebe8b90ed693033f1915dcea031e7a16a6f146a8326c02eec10eed77edd9060200160405180910390a16119be81613ed4565b611ae6612290565b600083118015611af65750600082115b611b305760405162461bcd60e51b815260206004820152600b60248201526a125b9d985b1a59081bd91960aa1b604482015260640161090f565b60108390556011829055600554600210611b4b576000611b4d565b805b60128190556013805460ff191690556010546011546040805192835260208301919091528101919091527fff554c9505df49513bbfe3d3b79c4e8c93d7ea27e843facef592e4d94af60ced9060600160405180910390a1505050565b600e54600090600160a81b900460ff16611bc557506000611ca5565b601354600160c01b900460ff1615611c2e57600080611be261273f565b9092509050611c03670de0b6b3a7640000611bfd888561429c565b906142a8565b9250611c25611c1e670de0b6b3a7640000611bfd898561429c565b8490612f6e565b92505050611ca5565b611c4f670de0b6b3a7640000611bfd6010548761429c90919063ffffffff16565b9050611c7c611c75670de0b6b3a7640000611bfd6011548761429c90919063ffffffff16565b8290612f6e565b9050611ca2611c75670de0b6b3a7640000611bfd6012548661429c90919063ffffffff16565b90505b9392505050565b600080600060026005541115611e3b57600254604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b158015611d0157600080fd5b505afa158015611d15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d3991906146f5565b600354604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b158015611d7e57600080fd5b505afa158015611d92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db691906146f5565b60048054604080516318160ddd60e01b815290516001600160a01b03909216926318160ddd928282019260209290829003018186803b158015611df857600080fd5b505afa158015611e0c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3091906146f5565b925092509250909192565b600254604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b158015611e8057600080fd5b505afa158015611e94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eb891906146f5565b600354604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b158015611efd57600080fd5b505afa158015611f11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f3591906146f5565b6000925092509250909192565b611f4a612290565b611f52612302565b601354600160c01b900460ff1615611fbc5760405162461bcd60e51b815260206004820152602760248201527f4e6f7420737570706f7274656420666f7220646f75626c65206368616e6365206044820152666d61726b65747360c81b606482015260840161090f565b42821161200b5760405162461bcd60e51b815260206004820152601c60248201527f4d61747572697479206d75737420626520696e20612066757475726500000000604482015260640161090f565b6013546301000000900460ff1661203a5760408051808201909152828152602001819052600682905560078190555b60408051838152602081018390527f070aa07a2e5f94bbac2e0a5c78100b2c0e686f6f43d555537f89133916d4f316910160405180910390a15050565b6040805180820190915260008152606060208201526013546301000000900460ff16806120ad5750601354600160c01b900460ff165b156121e6576000601360049054906101000a90046001600160a01b03166001600160a01b03166350fc2c616040518163ffffffff1660e01b815260040160006040518083038186803b15801561210257600080fd5b505afa158015612116573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261213e91908101906145bc565b5090506040518060400160405280828152602001600a805461215f90614b52565b80601f016020809104026020016040519081016040528092919081815260200182805461218b90614b52565b80156121d85780601f106121ad576101008083540402835291602001916121d8565b820191906000526020600020905b8154815290600101906020018083116121bb57829003601f168201915b505050505081525091505090565b604080518082019091526008805482526009805460208401919061220990614b52565b80601f016020809104026020016040519081016040528092919081815260200182805461223590614b52565b80156122825780601f1061225757610100808354040283529160200191612282565b820191906000526020600020905b81548152906001019060200180831161226557829003601f168201915b505050505081525050905090565b6000546001600160a01b0316331461172a5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b606482015260840161090f565b6000546001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561234657600080fd5b505afa15801561235a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061237e91906145a0565b1561172a5760405162461bcd60e51b815260206004820152603c60248201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060448201527f7768696c652074686520636f6e74726163742069732070617573656400000000606482015260840161090f565b6000546001600160a01b03161561245a5760405162461bcd60e51b815260206004820152602760248201527f496e69742063616e206f6e6c792062652063616c6c6564207768656e206f776e6044820152660657220697320360cc1b606482015260840161090f565b600080546001600160a01b0319166001600160a01b03831690811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91016108a4565b600060055467ffffffffffffffff8111156124d957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612502578160200160208202803683370190505b50600e5460405163db0d457960e01b81523060048201529192506001600160a01b03169063db0d45799060240160006040518083038186803b15801561254757600080fd5b505afa15801561255b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261258391908101906144dc565b9050806000815181106125a657634e487b7160e01b600052603260045260246000fd5b6020026020010151600014806125e45750806001815181106125d857634e487b7160e01b600052603260045260246000fd5b60200260200101516000145b156125f7576013805460ff191660011790555b8060008151811061261857634e487b7160e01b600052603260045260246000fd5b60200260200101516010819055508060018151811061264757634e487b7160e01b600052603260045260246000fd5b6020026020010151601181905550600260055411612666576000612690565b8060028151811061268757634e487b7160e01b600052603260045260246000fd5b60200260200101515b60128190556010546011546040805192835260208301919091528101919091527fff554c9505df49513bbfe3d3b79c4e8c93d7ea27e843facef592e4d94af60ced906060016108a4565b600e54600090600160a01b900460ff1615806126ff5750600e54600160a81b900460ff165b1561270a5750600090565b600c54600314801561271e57506002600554115b156127295750600390565b600c546001146127395750600290565b50600190565b6000806000806000601360049054906101000a90046001600160a01b03166001600160a01b03166350e947ab6040518163ffffffff1660e01b815260040160606040518083038186803b15801561279557600080fd5b505afa1580156127a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127cd919061477c565b9250925092506000806127de610e59565b91509150600080601360049054906101000a90046001600160a01b03166001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b15801561283357600080fd5b505afa158015612847573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061286b9190614658565b5091509150612881826001600160a01b03161590565b1561289757506000988998509650505050505050565b816001600160a01b0316846001600160a01b0316146128d557806001600160a01b0316846001600160a01b0316146128cf57846128d7565b856128d7565b865b9850816001600160a01b0316836001600160a01b03161461291757806001600160a01b0316836001600160a01b0316146129115784612919565b85612919565b865b9750505050505050509091565b6000806000601360199054906101000a900460ff1661294d57506000915081905080610e52565b60026005541115612adc57600254604051634dcb776760e11b81526001600160a01b03868116600483015290911690639b96eece9060240160206040518083038186803b15801561299d57600080fd5b505afa1580156129b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129d591906146f5565b600354604051634dcb776760e11b81526001600160a01b03878116600483015290911690639b96eece9060240160206040518083038186803b158015612a1a57600080fd5b505afa158015612a2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a5291906146f5565b60048054604051634dcb776760e11b81526001600160a01b0389811693820193909352911690639b96eece9060240160206040518083038186803b158015612a9957600080fd5b505afa158015612aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad191906146f5565b925092509250610e52565b600254604051634dcb776760e11b81526001600160a01b03868116600483015290911690639b96eece9060240160206040518083038186803b158015612b2157600080fd5b505afa158015612b35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b5991906146f5565b600354604051634dcb776760e11b81526001600160a01b03878116600483015290911690639b96eece9060240160206040518083038186803b158015612b9e57600080fd5b505afa158015612bb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bd691906146f5565b909590945060009350915050565b601354600090600160c01b900460ff16612c08575060135462010000900460ff1690565b601360049054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c5657600080fd5b505afa158015612c6a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101991906145a0565b6000601360049054906101000a90046001600160a01b03166001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b158015612cde57600080fd5b505afa158015612cf2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1691906145a0565b158015612da65750601360049054906101000a90046001600160a01b03166001600160a01b031663ac3791e36040518163ffffffff1660e01b815260040160206040518083038186803b158015612d6c57600080fd5b505afa158015612d80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612da491906145a0565b155b15612db15750600090565b601354604051636392a51f60e01b81523060048201526000918291829164010000000090046001600160a01b031690636392a51f9060240160606040518083038186803b158015612e0157600080fd5b505afa158015612e15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e39919061477c565b925092509250826000148015612e4d575081155b8015612e57575080155b15612e66576000935050505090565b6001935050505090565b601354600090600160c01b900460ff1615612ebc576001612e8f6126da565b6003811115612eae57634e487b7160e01b600052602160045260246000fd5b1415612eb75750825b611ca5565b6001612ec66126da565b6003811115612ee557634e487b7160e01b600052602160045260246000fd5b14612ef05782612ef2565b835b90506002600554118015612f2d57506001612f0b6126da565b6003811115612f2a57634e487b7160e01b600052602160045260246000fd5b14155b15611ca5576002612f3c6126da565b6003811115612f5b57634e487b7160e01b600052602160045260246000fd5b14612f665781611ca2565b509092915050565b6000612f7a8284614ab8565b90505b92915050565b600d54600090612f9390836142b4565b600d8190559050612fac6000546001600160a01b031690565b6001600160a01b0316636b3a0984836040518263ffffffff1660e01b8152600401612fd991815260200190565b600060405180830381600087803b158015612ff357600080fd5b505af1158015613007573d6000803e3d6000fd5b50505050919050565b601354600160c81b900460ff16156130605760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b604482015260640161090f565b600060055467ffffffffffffffff81111561308b57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156130b4578160200160208202803683370190505b50905060005b600554811015613191576014546040805163015d74c560e51b81529051613147926001600160a01b031691632bae98a0916004808301926020929190829003018186803b15801561310a57600080fd5b505afa15801561311e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061314291906144c0565b6142c0565b82828151811061316757634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101528061318981614b8d565b9150506130ba565b50806000815181106131b357634e487b7160e01b600052603260045260246000fd5b6020026020010151600260000160006101000a8154816001600160a01b0302191690836001600160a01b031602179055508060018151811061320557634e487b7160e01b600052603260045260246000fd5b6020908102919091010151600380546001600160a01b0319166001600160a01b039092169190911790556013546301000000900460ff16156136ed57600b546001106132a55760405162461bcd60e51b815260206004820152602960248201527f4368696c64206d61726b657473206d7573742068617665206d6f7265207468656044820152686e206f6e652074616760b81b606482015260840161090f565b600b6001815481106132c757634e487b7160e01b600052603260045260246000fd5b906000526020600020015461271114156134c6576002546001600160a01b031663077f224a6132f4612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561334657600080fd5b505afa15801561335a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061337e91906144c0565b6040518363ffffffff1660e01b815260040161339b9291906148d2565b600060405180830381600087803b1580156133b557600080fd5b505af11580156133c9573d6000803e3d6000fd5b50506003546001600160a01b0316915063077f224a90506133e8612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561343a57600080fd5b505afa15801561344e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061347291906144c0565b6040518363ffffffff1660e01b815260040161348f929190614963565b600060405180830381600087803b1580156134a957600080fd5b505af11580156134bd573d6000803e3d6000fd5b505050506138d4565b600b6001815481106134e857634e487b7160e01b600052603260045260246000fd5b9060005260206000200154612712148061352f5750600b60018154811061351f57634e487b7160e01b600052603260045260246000fd5b906000526020600020015461271a145b156136e8576002546001600160a01b031663077f224a61354d612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561359f57600080fd5b505afa1580156135b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135d791906144c0565b6040518363ffffffff1660e01b81526004016135f49291906149ab565b600060405180830381600087803b15801561360e57600080fd5b505af1158015613622573d6000803e3d6000fd5b50506003546001600160a01b0316915063077f224a9050613641612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561369357600080fd5b505afa1580156136a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136cb91906144c0565b6040518363ffffffff1660e01b815260040161348f92919061491a565b6138d4565b6002546001600160a01b031663077f224a613706612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561375857600080fd5b505afa15801561376c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061379091906144c0565b6040518363ffffffff1660e01b81526004016137ad9291906148d2565b600060405180830381600087803b1580156137c757600080fd5b505af11580156137db573d6000803e3d6000fd5b50506003546001600160a01b0316915063077f224a90506137fa612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561384c57600080fd5b505afa158015613860573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061388491906144c0565b6040518363ffffffff1660e01b81526004016138a1929190614963565b600060405180830381600087803b1580156138bb57600080fd5b505af11580156138cf573d6000803e3d6000fd5b505050505b60026005541115613a10578060028151811061390057634e487b7160e01b600052603260045260246000fd5b6020908102919091010151600480546001600160a01b0319166001600160a01b03909216918217905563077f224a613936612077565b60200151601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b15801561398857600080fd5b505afa15801561399c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139c091906144c0565b6040518363ffffffff1660e01b81526004016139dd92919061488a565b600060405180830381600087803b1580156139f757600080fd5b505af1158015613a0b573d6000803e3d6000fd5b505050505b6013805460ff60c81b1916600160c81b179055600280546003546005547f2d010965ba615ce04b2caa89ec260d016efa5b5eb0e6ad0690c5c507bfe924689330936001600160a01b0390811693169111613a6b576000613a78565b6004546001600160a01b03165b604080516001600160a01b03958616815293851660208501529184169183019190915290911660608201526080016108a4565b60408051808201909152600080825260208201526013546301000000900460ff1680613ae05750601354600160c01b900460ff165b15613b8657600080601360049054906101000a90046001600160a01b03166001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b158015613b3557600080fd5b505afa158015613b49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b6d919061472e565b6040805180820190915291825260208201529392505050565b50604080518082019091526006548152600754602082015290565b600042613bac613aab565b5110919050565b601354600160c81b900460ff16613bcc57613bcc613010565b601354600160c01b900460ff1615613c7a576002546040516340c10f1960e01b81526001600160a01b03848116600483015260248201849052909116906340c10f1990604401600060405180830381600087803b158015613c2c57600080fd5b505af1158015613c40573d6000803e3d6000fd5b50505050816001600160a01b0316600080516020614c0e833981519152600183604051613c6e929190614846565b60405180910390a25050565b6002546040516340c10f1960e01b81526001600160a01b03848116600483015260248201849052909116906340c10f1990604401600060405180830381600087803b158015613cc857600080fd5b505af1158015613cdc573d6000803e3d6000fd5b50506003546040516340c10f1960e01b81526001600160a01b0386811660048301526024820186905290911692506340c10f199150604401600060405180830381600087803b158015613d2e57600080fd5b505af1158015613d42573d6000803e3d6000fd5b50505050816001600160a01b0316600080516020614c0e833981519152600183604051613d70929190614846565b60405180910390a2816001600160a01b0316600080516020614c0e833981519152600283604051613da2929190614846565b60405180910390a260026005541115613e4757600480546040516340c10f1960e01b81526001600160a01b0385811693820193909352602481018490529116906340c10f1990604401600060405180830381600087803b158015613e0557600080fd5b505af1158015613e19573d6000803e3d6000fd5b50505050816001600160a01b0316600080516020614c0e833981519152600383604051613c6e929190614846565b5050565b600d54600090613e5b9083612f6e565b600d8190559050613e746000546001600160a01b031690565b6001600160a01b031663aeab5849836040518263ffffffff1660e01b8152600401612fd991815260200190565b600e54600090600160a01b900460ff168015611019575042613ec1613aab565b602001511080611019575050600d541590565b600d548015613ee857613ee681612f83565b505b601454604080516319324a5160e31b815290516000926001600160a01b03169163c9925288916004808301926020929190829003018186803b158015613f2d57600080fd5b505afa158015613f41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f6591906144c0565b6001600160a01b0316639324cac76040518163ffffffff1660e01b815260040160206040518083038186803b158015613f9d57600080fd5b505afa158015613fb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fd591906144c0565b6040516370a0823160e01b81523060048201526001600160a01b0391909116906370a082319060240160206040518083038186803b15801561401657600080fd5b505afa15801561402a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061404e91906146f5565b905080156141d257601460009054906101000a90046001600160a01b03166001600160a01b031663c99252886040518163ffffffff1660e01b815260040160206040518083038186803b1580156140a457600080fd5b505afa1580156140b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140dc91906144c0565b6001600160a01b0316639324cac76040518163ffffffff1660e01b815260040160206040518083038186803b15801561411457600080fd5b505afa158015614128573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061414c91906144c0565b60405163a9059cbb60e01b81526001600160a01b03858116600483015260248201849052919091169063a9059cbb90604401602060405180830381600087803b15801561419857600080fd5b505af11580156141ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141d091906145a0565b505b60025460405163646d919f60e11b81526001600160a01b0385811660048301529091169063c8db233e90602401600060405180830381600087803b15801561421957600080fd5b505af115801561422d573d6000803e3d6000fd5b505060035460405163646d919f60e11b81526001600160a01b038781166004830152909116925063c8db233e9150602401600060405180830381600087803b15801561427857600080fd5b505af115801561428c573d6000803e3d6000fd5b50505050826001600160a01b0316ff5b6000612f7a8284614af0565b6000612f7a8284614ad0565b6000612f7a8284614b0f565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b0381166143585760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b604482015260640161090f565b919050565b82805461436990614b52565b90600052602060002090601f01602090048101928261438b57600085556143d1565b82601f106143a45782800160ff198235161785556143d1565b828001600101855582156143d1579182015b828111156143d15782358255916020019190600101906143b6565b506143dd92915061448f565b5090565b8280546143ed90614b52565b90600052602060002090601f01602090048101928261440f57600085556143d1565b82601f1061442857805160ff19168380011785556143d1565b828001600101855582156143d1579182015b828111156143d157825182559160200191906001019061443a565b8280548282559060005260206000209081019282156143d157916020028201828111156143d15782358255916020019190600101906143b6565b5b808211156143dd5760008155600101614490565b6000602082840312156144b5578081fd5b8135611ca581614bea565b6000602082840312156144d1578081fd5b8151611ca581614bea565b600060208083850312156144ee578182fd5b825167ffffffffffffffff80821115614505578384fd5b818501915085601f830112614518578384fd5b81518181111561452a5761452a614bd4565b8060051b915061453b848301614a87565b8181528481019084860184860187018a1015614555578788fd5b8795505b83861015614577578051835260019590950194918601918601614559565b5098975050505050505050565b600060208284031215614595578081fd5b8135611ca581614bff565b6000602082840312156145b1578081fd5b8151611ca581614bff565b600080604083850312156145ce578081fd5b82519150602083015167ffffffffffffffff808211156145ec578283fd5b818501915085601f8301126145ff578283fd5b81518181111561461157614611614bd4565b614624601f8201601f1916602001614a87565b915080825286602082850101111561463a578384fd5b61464b816020840160208601614b26565b5080925050509250929050565b60008060006060848603121561466c578081fd5b835161467781614bea565b602085015190935061468881614bea565b604085015190925061469981614bea565b809150509250925092565b6000602082840312156146b5578081fd5b813567ffffffffffffffff8111156146cb578182fd5b82016101a08185031215611ca5578182fd5b6000602082840312156146ee578081fd5b5035919050565b600060208284031215614706578081fd5b5051919050565b6000806040838503121561471f578182fd5b50508035926020909101359150565b60008060408385031215614740578182fd5b505080516020909101519092909150565b600080600060608486031215614765578081fd5b505081359360208301359350604090920135919050565b600080600060608486031215614790578081fd5b8351925060208401519150604084015190509250925092565b600481106147b9576147b9614bbe565b9052565b600081518084526147d5816020860160208601614b26565b601f01601f19169290920160200192915050565b600082516147fb818460208701614b26565b9190910192915050565b828152604060208201526000611ca260408301846147bd565b602081016003831061483257614832614bbe565b91905290565b60208101612f7d82846147a9565b6040810161485482856147a9565b8260208301529392505050565b6080810161486f82876147a9565b84602083015283604083015282606083015295945050505050565b60608152600061489d60608301856147bd565b82810360208085019190915260048252634452415760e01b908201526001600160a01b03939093166040928301525001919050565b6060815260006148e560608301856147bd565b8281036020808501919091526004825263484f4d4560e01b908201526001600160a01b03939093166040928301525001919050565b60608152600061492d60608301856147bd565b82810360208085019190915260058252642aa72222a960d91b908201526001600160a01b03939093166040928301525001919050565b60608152600061497660608301856147bd565b82810360208085019190915260048252634157415960e01b908201526001600160a01b03939093166040928301525001919050565b6060815260006149be60608301856147bd565b828103602080850191909152600482526327ab22a960e11b908201526001600160a01b03939093166040928301525001919050565b6000808335601e19843603018112614a09578283fd5b83018035915067ffffffffffffffff821115614a23578283fd5b6020019150600581901b3603821315614a3b57600080fd5b9250929050565b6000808335601e19843603018112614a58578283fd5b83018035915067ffffffffffffffff821115614a72578283fd5b602001915036819003821315614a3b57600080fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715614ab057614ab0614bd4565b604052919050565b60008219821115614acb57614acb614ba8565b500190565b600082614aeb57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615614b0a57614b0a614ba8565b500290565b600082821015614b2157614b21614ba8565b500390565b60005b83811015614b41578181015183820152602001614b29565b8381111561171c5750506000910152565b600181811c90821680614b6657607f821691505b60208210811415614b8757634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415614ba157614ba1614ba8565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146119be57600080fd5b80151581146119be57600080fdfe377111a2ead9c89151d782f261f5cfbfff7958bed8335f97dd6356765ad5c155a264697066735822122046fc03787899dc369452c4c31db690ab3bba3beb2cff75af99d4bfb5549b195364736f6c63430008040033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 29 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.