Overview
ETH Balance
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Buy From AMM | 115025689 | 454 days ago | IN | 0 ETH | 0.000052391289 |
View more zero value Internal Transactions in Advanced View mode
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; // internal import "../utils/proxy/solidity-0.8.0/ProxyReentrancyGuard.sol"; import "../utils/proxy/solidity-0.8.0/ProxyOwned.sol"; // interface import "../interfaces/ISportPositionalMarket.sol"; import "../interfaces/ISportPositionalMarketManager.sol"; import "../interfaces/IPosition.sol"; import "../interfaces/IStakingThales.sol"; import "../interfaces/ITherundownConsumer.sol"; import "../interfaces/ICurveSUSD.sol"; import "../interfaces/IReferrals.sol"; import "../interfaces/ISportsAMM.sol"; import "../interfaces/ITherundownConsumerWrapper.sol"; import "../interfaces/ISportAMMRiskManager.sol"; import "./SportsAMMUtils.sol"; import "./LiquidityPool/SportAMMLiquidityPool.sol"; import "../interfaces/IMultiCollateralOnOffRamp.sol"; /// @title Sports AMM contract /// @author kirilaa contract SportsAMM is Initializable, ProxyOwned, PausableUpgradeable, ProxyReentrancyGuard { using SafeERC20Upgradeable for IERC20Upgradeable; uint private constant ONE = 1e18; uint private constant ZERO_POINT_ONE = 1e17; uint private constant ONE_PERCENT = 1e16; uint private constant MAX_APPROVAL = type(uint256).max; uint public constant TAG_NUMBER_PLAYERS = 10010; /// @return The sUSD contract used for payment IERC20Upgradeable public sUSD; /// @return The address of the SportsPositionalManager contract address public manager; uint private defaultCapPerGame; //deprecated see SportAMMRiskManager.sol /// @return The minimal spread/skrew percentage uint public min_spread; /// @return The maximum spread/skrew percentage uint public max_spread; /// @notice Each game will be restricted for AMM trading `minimalTimeLeftToMaturity` seconds before is mature /// @return The period of time before a game is matured and begins to be restricted for AMM trading uint public minimalTimeLeftToMaturity; enum Position { Home, Away, Draw } /// @return The sUSD amount bought from AMM by users for the market mapping(address => uint) public spentOnGame; /// @return The SafeBox address address public safeBox; /// @return The address of Therundown Consumer address public theRundownConsumer; /// @return The percentage that goes to SafeBox uint public safeBoxImpact; /// @return The address of the Staking contract IStakingThales public stakingThales; /// @return The minimum supported odd uint public minSupportedOdds; /// @return The maximum supported odd uint public maxSupportedOdds; ICurveSUSD private curveSUSD; // deprecated see MultiCollateralOnOffRamp.sol address private usdc; // deprecated see MultiCollateralOnOffRamp.sol address private usdt; // deprecated see MultiCollateralOnOffRamp.sol address private dai; // deprecated see MultiCollateralOnOffRamp.sol bool private curveOnrampEnabled; // deprecated see MultiCollateralOnOffRamp.sol /// @return Referrals contract address address public referrals; uint private referrerFee; // deprecated, moved to Referrals.sol /// @return The address of Parlay AMM address public parlayAMM; address private apexConsumer; // deprecated uint private maxAllowedPegSlippagePercentage; // deprecated see MultiCollateralOnOffRamp.sol mapping(uint => uint) private capPerSport; //deprecated see SportAMMRiskManager.sol SportsAMMUtils public sportAmmUtils; mapping(address => uint) private capPerMarket; //deprecated see SportAMMRiskManager.sol /// @notice odds threshold which will trigger odds update /// @return The threshold. uint public thresholdForOddsUpdate; /// @return The address of wrapper contract ITherundownConsumerWrapper public wrapper; // @return specific SafeBoxFee per address mapping(address => uint) public safeBoxFeePerAddress; // @return specific min_spread per address mapping(address => uint) public min_spreadPerAddress; mapping(uint => mapping(uint => uint)) private capPerSportAndChild; //deprecated see SportAMMRiskManager.sol struct BuyFromAMMParams { address market; ISportsAMM.Position position; uint amount; uint expectedPayout; uint additionalSlippage; bool sendSUSD; uint sUSDPaid; } struct DoubleChanceStruct { bool isDoubleChance; ISportsAMM.Position position1; ISportsAMM.Position position2; address parentMarket; } /// @return the adddress of the AMMLP contract SportAMMLiquidityPool public liquidityPool; mapping(uint => mapping(uint => uint)) private minSpreadPerSport; //deprecated see SportAMMRiskManager.sol mapping(uint => bool) private isMarketForSportOnePositional; //deprecated see SportAMMRiskManager.sol mapping(uint => uint) private minSupportedOddsPerSport; //deprecated see SportAMMRiskManager.sol mapping(uint => uint) private maxSpreadPerSport; //deprecated see SportAMMRiskManager.sol ISportAMMRiskManager public riskManager; mapping(address => uint) private spentOnParent; /// @return The sUSD amount bought from AMM by users for the parent IMultiCollateralOnOffRamp public multiCollateralOnOffRamp; bool public multicollateralEnabled; receive() external payable {} /// @notice Initialize the storage in the proxy contract with the parameters. /// @param _owner Owner for using the ownerOnly functions /// @param _sUSD The payment token (sUSD) /// @param _min_spread Minimal spread (percentage) /// @param _max_spread Maximum spread (percentage) /// @param _minimalTimeLeftToMaturity Period to close AMM trading befor maturity function initialize( address _owner, IERC20Upgradeable _sUSD, uint _min_spread, uint _max_spread, uint _minimalTimeLeftToMaturity ) public initializer { setOwner(_owner); initNonReentrant(); sUSD = _sUSD; min_spread = _min_spread; max_spread = _max_spread; minimalTimeLeftToMaturity = _minimalTimeLeftToMaturity; } /// @notice Returns the available position options to buy from AMM for specific market/game /// @param market The address of the SportPositional market created for a game /// @param position The position (home/away/draw) to check availability /// @return _available The amount of position options (tokens) available to buy from AMM. function availableToBuyFromAMM(address market, ISportsAMM.Position position) public view returns (uint _available) { if (isMarketInAMMTrading(market)) { uint baseOdds = _obtainOdds(market, position); if (baseOdds > 0) { _available = _availableToBuyFromAMMInternal( market, position, baseOdds, 0, false, _getDoubleChanceStruct(market) ); } } } /// @notice Calculate the sUSD cost to buy an amount of available position options from AMM for specific market/game /// @param market The address of the SportPositional market of a game /// @param position The position (home/away/draw) quoted to buy from AMM /// @param amount The position amount quoted to buy from AMM /// @return _quote The sUSD cost for buying the `amount` of `position` options (tokens) from AMM for `market`. function buyFromAmmQuote( address market, ISportsAMM.Position position, uint amount ) public view returns (uint _quote) { if (isMarketInAMMTrading(market)) { uint baseOdds = _obtainOdds(market, position); if (baseOdds > 0) { baseOdds = floorBaseOdds(baseOdds, market); _quote = _buyFromAmmQuoteWithBaseOdds( market, position, amount, baseOdds, safeBoxImpact, 0, false, true, _getDoubleChanceStruct(market) ); } } } function _buyFromAmmQuoteWithBaseOdds( address market, ISportsAMM.Position position, uint amount, uint baseOdds, uint useSafeBoxSkewImpact, uint available, bool useAvailable, bool useDefaultMinSpread, DoubleChanceStruct memory dcs ) internal view returns (uint returnQuote) { if (dcs.isDoubleChance) { returnQuote = _buyFromAMMQuoteDoubleChance( market, position, amount, useSafeBoxSkewImpact, useDefaultMinSpread, dcs ); } else { returnQuote = _buyFromAmmQuoteWithBaseOddsInternal( market, position, amount, baseOdds, useSafeBoxSkewImpact, available, useAvailable, useDefaultMinSpread ); } } function _buyFromAmmQuoteWithBaseOddsInternal( address market, ISportsAMM.Position position, uint amount, uint baseOdds, uint useSafeBoxSkewImpact, uint available, bool useAvailable, bool useDefaultMinSpread ) internal view returns (uint returnQuote) { if (!useAvailable) { available = availableToBuyFromAMMWithBaseOdds(market, position, baseOdds, 0, false); } if (amount <= available) { uint _availableOtherSide = _getAvailableOtherSide(market, position); int skewImpact = _buyPriceImpact(market, position, amount, available, _availableOtherSide); baseOdds = (baseOdds * (ONE + _getMinSpreadToUse(useDefaultMinSpread, market))) / ONE; int tempQuote = sportAmmUtils.calculateTempQuote(skewImpact, baseOdds, useSafeBoxSkewImpact, amount); returnQuote = ISportPositionalMarketManager(manager).transformCollateral(uint(tempQuote)); } } function _buyFromAMMQuoteDoubleChance( address market, ISportsAMM.Position position, uint amount, uint useSafeBoxSkewImpact, bool useDefaultMinSpread, DoubleChanceStruct memory dcs ) internal view returns (uint returnQuote) { if (position == ISportsAMM.Position.Home) { (uint baseOdds1, uint baseOdds2) = sportAmmUtils.getBaseOddsForDoubleChance(market, _minOddsForMarket(market)); if (baseOdds1 > 0 && baseOdds2 > 0) { uint firstQuote = _buyFromAmmQuoteWithBaseOddsInternal( dcs.parentMarket, dcs.position1, amount, baseOdds1, useSafeBoxSkewImpact, 0, false, useDefaultMinSpread ); uint secondQuote = _buyFromAmmQuoteWithBaseOddsInternal( dcs.parentMarket, dcs.position2, amount, baseOdds2, useSafeBoxSkewImpact, 0, false, useDefaultMinSpread ); if (firstQuote > 0 && secondQuote > 0) { returnQuote = firstQuote + secondQuote; } } } } function _getAvailableOtherSide(address market, ISportsAMM.Position position) internal view returns (uint _availableOtherSide) { ISportsAMM.Position positionFirst = ISportsAMM.Position((uint(position) + 1) % 3); ISportsAMM.Position positionSecond = ISportsAMM.Position((uint(position) + 2) % 3); _availableOtherSide = _getAvailableHigherForPositions(market, positionFirst, positionSecond, false); } function floorBaseOdds(uint baseOdds, address market) public view returns (uint) { uint minOdds = _minOddsForMarket(market); return baseOdds < minOdds ? minOdds : baseOdds; } function _getAvailableHigherForPositions( address market, ISportsAMM.Position positionFirst, ISportsAMM.Position positionSecond, bool inverse ) internal view returns (uint) { (uint cap, uint maxSpreadForMarket, uint minOddsForMarket) = riskManager.getCapMaxSpreadAndMinOddsForMarket( market, max_spread, minSupportedOdds ); return sportAmmUtils.getAvailableHigherForPositions( SportsAMMUtils.AvailableHigher( market, positionFirst, positionSecond, inverse, liquidityPool.getMarketPool(market), minOddsForMarket, cap, maxSpreadForMarket, spentOnGame[market] ) ); } /// @notice Calculate the sUSD cost to buy an amount of available position options from AMM for specific market/game /// @param market The address of the SportPositional market of a game /// @param position The position (home/away/draw) quoted to buy from AMM /// @param amount The position amount quoted to buy from AMM /// @return _quote The sUSD cost for buying the `amount` of `position` options (tokens) from AMM for `market`. function buyFromAmmQuoteForParlayAMM( address market, ISportsAMM.Position position, uint amount ) external view returns (uint _quote) { uint baseOdds = _obtainOdds(market, position); baseOdds = floorBaseOdds(baseOdds, market); _quote = _buyFromAmmQuoteWithBaseOdds( market, position, amount, baseOdds, 0, 0, false, true, _getDoubleChanceStruct(market) ); } /// @notice Calculate the sUSD cost to buy an amount of available position options from AMM for specific market/game /// @param market The address of the SportPositional market of a game /// @param position The position (home/away/draw) quoted to buy from AMM /// @param amount The position amount quoted to buy from AMM /// @param collateral The position amount quoted to buy from AMM /// @return collateralQuote The sUSD cost for buying the `amount` of `position` options (tokens) from AMM for `market`. /// @return sUSDToPay The sUSD cost for buying the `amount` of `position` options (tokens) from AMM for `market`. function buyFromAmmQuoteWithDifferentCollateral( address market, ISportsAMM.Position position, uint amount, address collateral ) public view returns (uint collateralQuote, uint sUSDToPay) { sUSDToPay = buyFromAmmQuote(market, position, amount); collateralQuote = multiCollateralOnOffRamp.getMinimumNeeded(collateral, sUSDToPay); } /// @notice Calculates the buy price impact for given position amount. Changes with every new purchase. /// @param market The address of the SportPositional market of a game /// @param position The position (home/away/draw) for which the buy price impact is calculated /// @param amount The position amount to calculate the buy price impact /// @return impact The buy price impact after the buy of the amount of positions for market function buyPriceImpact( address market, ISportsAMM.Position position, uint amount ) public view returns (int impact) { if (ISportPositionalMarketManager(manager).isDoubleChanceMarket(market)) { if (position == ISportsAMM.Position.Home) { impact = sportAmmUtils.getParentMarketPositionsImpactDoubleChance(market, amount); } } else { uint _availableToBuyFromAMM = availableToBuyFromAMM(market, position); uint _availableOtherSide = _getAvailableOtherSide(market, position); if (amount > 0 && amount <= _availableToBuyFromAMM) { impact = _buyPriceImpact(market, position, amount, _availableToBuyFromAMM, _availableOtherSide); } } } /// @notice Obtains the oracle odds for `_position` of a given `_market` game. Odds do not contain price impact /// @param _market The address of the SportPositional market of a game /// @param _position The position (home/away/draw) to get the odds /// @return oddsToReturn The oracle odds for `_position` of a `_market` function obtainOdds(address _market, ISportsAMM.Position _position) external view returns (uint oddsToReturn) { oddsToReturn = _obtainOdds(_market, _position); } /// @notice Checks if a `market` is active for AMM trading /// @param market The address of the SportPositional market of a game /// @return isTrading Returns true if market is active, returns false if not active. function isMarketInAMMTrading(address market) public view returns (bool isTrading) { if (ISportPositionalMarketManager(manager).isActiveMarket(market)) { (uint maturity, ) = ISportPositionalMarket(market).times(); if (maturity >= block.timestamp) { isTrading = (maturity - block.timestamp) > minimalTimeLeftToMaturity; } } } /// @notice Checks the default odds for a `_market`. These odds take into account the price impact. /// @param _market The address of the SportPositional market of a game /// @return odds Returns the default odds for the `_market` including the price impact. function getMarketDefaultOdds(address _market, bool isSell) public view returns (uint[] memory odds) { odds = new uint[](ISportPositionalMarket(_market).optionsCount()); for (uint i = 0; i < odds.length; i++) { odds[i] = buyFromAmmQuote(_market, ISportsAMM.Position(i), ONE); } } // write methods /// @notice Buy amount of position for market/game from AMM using different collateral /// @param market The address of the SportPositional market of a game /// @param position The position (home/away/draw) to buy from AMM /// @param amount The position amount to buy from AMM /// @param expectedPayout The amount expected to pay in sUSD for the amount of position. Obtained by buyAMMQuote. /// @param additionalSlippage The slippage percentage for the payout /// @param collateral The address of the collateral used /// @param _referrer who referred the buyer to SportsAMM function buyFromAMMWithDifferentCollateralAndReferrer( address market, ISportsAMM.Position position, uint amount, uint expectedPayout, uint additionalSlippage, address collateral, address _referrer ) public nonReentrant whenNotPaused { if (_referrer != address(0)) { IReferrals(referrals).setReferrer(_referrer, msg.sender); } _buyFromAMMWithDifferentCollateral(market, position, amount, expectedPayout, additionalSlippage, collateral, false); } /// @notice Buy amount of position for market/game from AMM using different collateral /// @param market The address of the SportPositional market of a game /// @param position The position (home/away/draw) to buy from AMM /// @param amount The position amount to buy from AMM /// @param expectedPayout The amount expected to pay in sUSD for the amount of position. Obtained by buyAMMQuote. /// @param additionalSlippage The slippage percentage for the payout /// @param collateral The address of the collateral used function buyFromAMMWithDifferentCollateral( address market, ISportsAMM.Position position, uint amount, uint expectedPayout, uint additionalSlippage, address collateral ) public nonReentrant whenNotPaused { _buyFromAMMWithDifferentCollateral(market, position, amount, expectedPayout, additionalSlippage, collateral, false); } /// @notice Buy amount of position for market/game from AMM using ETH /// @param market The address of the SportPositional market of a game /// @param position The position (home/away/draw) to buy from AMM /// @param amount The position amount to buy from AMM /// @param expectedPayout The amount expected to pay in sUSD for the amount of position. Obtained by buyAMMQuote. /// @param additionalSlippage The slippage percentage for the payout /// @param collateral The address of the collateral used /// @param _referrer who referred the buyer to SportsAMM function buyFromAMMWithEthAndReferrer( address market, ISportsAMM.Position position, uint amount, uint expectedPayout, uint additionalSlippage, address collateral, address _referrer ) external payable nonReentrant whenNotPaused { if (_referrer != address(0)) { IReferrals(referrals).setReferrer(_referrer, msg.sender); } _buyFromAMMWithDifferentCollateral(market, position, amount, expectedPayout, additionalSlippage, collateral, true); } /// @notice Buy amount of position for market/game from AMM using sUSD /// @param market The address of the SportPositional market of a game /// @param position The position (home/away/draw) to buy from AMM /// @param amount The position amount to buy from AMM /// @param expectedPayout The sUSD amount expected to pay for buyuing the position amount. Obtained by buyAMMQuote. /// @param additionalSlippage The slippage percentage for the payout function buyFromAMM( address market, ISportsAMM.Position position, uint amount, uint expectedPayout, uint additionalSlippage ) public nonReentrant whenNotPaused { _buyFromAMM(BuyFromAMMParams(market, position, amount, expectedPayout, additionalSlippage, true, 0)); } /// @notice Buy amount of position for market/game from AMM using sUSD /// @param market The address of the SportPositional market of a game /// @param position The position (home/away/draw) to buy from AMM /// @param amount The position amount to buy from AMM /// @param expectedPayout The sUSD amount expected to pay for buying the position amount. Obtained by buyAMMQuote. /// @param additionalSlippage The slippage percentage for the payout function buyFromAMMWithReferrer( address market, ISportsAMM.Position position, uint amount, uint expectedPayout, uint additionalSlippage, address _referrer ) public nonReentrant whenNotPaused { if (_referrer != address(0)) { IReferrals(referrals).setReferrer(_referrer, msg.sender); } _buyFromAMM(BuyFromAMMParams(market, position, amount, expectedPayout, additionalSlippage, true, 0)); } function exerciseWithOfframp( address market, address collateral, bool toEth ) external nonReentrant whenNotPaused { require(ISportPositionalMarketManager(manager).isKnownMarket(market), "unknown market"); (IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(market).getOptions(); require(address(home) != address(0), "0A"); (uint homeBalance, uint awayBalance, uint drawBalance) = ISportPositionalMarket(market).balancesOf(msg.sender); _sendFromIfNotZero(msg.sender, address(home), address(this), homeBalance); _sendFromIfNotZero(msg.sender, address(away), address(this), awayBalance); _sendFromIfNotZero(msg.sender, address(draw), address(this), drawBalance); uint amountBefore = sUSD.balanceOf(address(this)); ISportPositionalMarket(market).exerciseOptions(); uint amountDiff = sUSD.balanceOf(address(this)) - amountBefore; uint offramped; if (amountDiff > 0) { if (toEth) { offramped = multiCollateralOnOffRamp.offrampIntoEth(amountDiff); bool sent = payable(msg.sender).send(offramped); require(sent, "Failed to send Ether"); } else { offramped = multiCollateralOnOffRamp.offramp(collateral, amountDiff); IERC20Upgradeable(collateral).safeTransfer(msg.sender, offramped); } } emit ExercisedWithOfframp(msg.sender, market, collateral, toEth, amountDiff, offramped); } // setters /// @notice Setting all key parameters for AMM /// @param _minimalTimeLeftToMaturity The time period in seconds. /// @param _minSpread Minimum spread percentage expressed in ether unit (uses 18 decimals -> 1% = 0.01*1e18) /// @param _maxSpread Maximum spread percentage expressed in ether unit (uses 18 decimals -> 1% = 0.01*1e18) /// @param _minSupportedOdds Minimal oracle odd in ether unit (18 decimals) /// @param _maxSupportedOdds Maximum oracle odds in ether unit (18 decimals) /// @param _safeBoxImpact Percentage expressed in ether unit (uses 18 decimals -> 1% = 0.01*1e18) /// @param _referrerFee how much of a fee to pay to referrers function setParameters( uint _minimalTimeLeftToMaturity, uint _minSpread, uint _maxSpread, uint _minSupportedOdds, uint _maxSupportedOdds, uint _safeBoxImpact, uint _referrerFee, uint _threshold ) external onlyOwner { minimalTimeLeftToMaturity = _minimalTimeLeftToMaturity; min_spread = _minSpread; max_spread = _maxSpread; minSupportedOdds = _minSupportedOdds; maxSupportedOdds = _maxSupportedOdds; safeBoxImpact = _safeBoxImpact; thresholdForOddsUpdate = _threshold; emit ParametersUpdated( _minimalTimeLeftToMaturity, _minSpread, _maxSpread, _minSupportedOdds, _maxSupportedOdds, _safeBoxImpact, _referrerFee, _threshold ); } /// @notice Setting the main addresses for SportsAMM /// @param _safeBox Address of the Safe Box /// @param _sUSD Address of the sUSD /// @param _theRundownConsumer Address of Therundown consumer /// @param _stakingThales Address of Staking contract /// @param _referrals contract for referrals storage /// @param _wrapper contract for calling wrapper contract /// @param _lp contract for managing liquidity pools function setAddresses( address _safeBox, IERC20Upgradeable _sUSD, address _theRundownConsumer, IStakingThales _stakingThales, address _referrals, address _parlayAMM, address _wrapper, address _lp, address _riskManager ) external onlyOwner { safeBox = _safeBox; sUSD = _sUSD; theRundownConsumer = _theRundownConsumer; stakingThales = _stakingThales; referrals = _referrals; parlayAMM = _parlayAMM; wrapper = ITherundownConsumerWrapper(_wrapper); liquidityPool = SportAMMLiquidityPool(_lp); riskManager = ISportAMMRiskManager(_riskManager); emit AddressesUpdated( _safeBox, _sUSD, _theRundownConsumer, _stakingThales, _referrals, _parlayAMM, _wrapper, _lp, _riskManager ); } /// @notice Setting the Sport Positional Manager contract address /// @param _manager Address of Staking contract function setSportsPositionalMarketManager(address _manager) external onlyOwner { if (address(_manager) != address(0)) { sUSD.approve(address(_manager), 0); } manager = _manager; sUSD.approve(manager, MAX_APPROVAL); emit SetSportsPositionalMarketManager(_manager); } /// @notice Updates contract parametars /// @param _address which has a specific safe box fee /// @param newSBFee the SafeBox fee for address /// @param newMSFee the min_spread fee for address function setSafeBoxFeeAndMinSpreadPerAddress( address _address, uint newSBFee, uint newMSFee ) external onlyOwner { safeBoxFeePerAddress[_address] = newSBFee; min_spreadPerAddress[_address] = newMSFee; } function setPaused(bool _setPausing) external onlyOwner { _setPausing ? _pause() : _unpause(); } /// @notice used to update gamified Staking bonuses from Parlay contract /// @param _account Address to update volume for /// @param _amount of the volume function updateParlayVolume(address _account, uint _amount) external { require(msg.sender == parlayAMM, "Invalid caller"); if (address(stakingThales) != address(0)) { stakingThales.updateVolume(_account, _amount); } } /// @notice Updates contract parametars /// @param _ammUtils address of AMMUtils function setAmmUtils(SportsAMMUtils _ammUtils) external onlyOwner { sportAmmUtils = _ammUtils; } /// @notice set multicollateral onramp contract function setMultiCollateralOnOffRamp(address _onramper, bool enabled) external onlyOwner { if (address(multiCollateralOnOffRamp) != address(0)) { sUSD.approve(address(multiCollateralOnOffRamp), 0); } multiCollateralOnOffRamp = IMultiCollateralOnOffRamp(_onramper); multicollateralEnabled = enabled; sUSD.approve(_onramper, MAX_APPROVAL); emit SetMultiCollateralOnOffRamp(_onramper, enabled); } // Internal function _buyFromAMMWithDifferentCollateral( address market, ISportsAMM.Position position, uint amount, uint expectedPayout, uint additionalSlippage, address collateral, bool isEth ) internal { (uint collateralQuote, uint susdQuote) = buyFromAmmQuoteWithDifferentCollateral( market, position, amount, collateral ); require((collateralQuote * ONE) / (expectedPayout) <= (ONE + additionalSlippage), "Slippage too high!"); uint exactReceived; if (isEth) { require(collateral == multiCollateralOnOffRamp.WETH9(), "Wrong collateral sent"); exactReceived = multiCollateralOnOffRamp.onrampWithEth{value: collateralQuote}(collateralQuote); } else { IERC20Upgradeable(collateral).safeTransferFrom(msg.sender, address(this), collateralQuote); IERC20Upgradeable(collateral).approve(address(multiCollateralOnOffRamp), collateralQuote); exactReceived = multiCollateralOnOffRamp.onramp(collateral, collateralQuote); } require(exactReceived >= susdQuote, "Not enough sUSD received"); //send the surplus to SB if (exactReceived > susdQuote) { sUSD.safeTransfer(safeBox, exactReceived - susdQuote); } return _buyFromAMM(BuyFromAMMParams(market, position, amount, susdQuote, additionalSlippage, false, susdQuote)); } function _buyFromAMM(BuyFromAMMParams memory params) internal { _checkMarketValidityAndOptionsCount(params.market, params.position); DoubleChanceStruct memory dcs = _getDoubleChanceStruct(params.market); require(!dcs.isDoubleChance || params.position == ISportsAMM.Position.Home, "Invalid pos"); uint baseOdds = _obtainOdds(params.market, params.position); require(baseOdds > 0, "No base odds"); baseOdds = floorBaseOdds(baseOdds, params.market); uint availableInContract = sportAmmUtils.balanceOfPositionOnMarket( params.market, params.position, liquidityPool.getMarketPool(params.market) ); uint availableToBuyFromAMMatm = _availableToBuyFromAMMInternal( params.market, params.position, baseOdds, availableInContract, true, dcs ); require(params.amount > ZERO_POINT_ONE && params.amount <= availableToBuyFromAMMatm, "Low liquidity || 0"); if (params.sendSUSD) { params.sUSDPaid = _buyFromAmmQuoteWithBaseOdds( params.market, params.position, params.amount, baseOdds, _getSafeBoxFeePerAddress(msg.sender), availableToBuyFromAMMatm, true, false, dcs ); require((params.sUSDPaid * ONE) / params.expectedPayout <= (ONE + params.additionalSlippage), "High slippage"); sUSD.safeTransferFrom(msg.sender, address(this), params.sUSDPaid); } address parent = dcs.isDoubleChance || ISportPositionalMarket(params.market).isChild() ? address(ISportPositionalMarket(params.market).parentMarket()) : params.market; if (dcs.isDoubleChance) { ISportPositionalMarket(params.market).mint(params.amount); _mintParentPositions(params.market, params.amount, dcs); (address parentMarketPosition1, address parentMarketPosition2) = sportAmmUtils.getParentMarketPositionAddresses( params.market ); _getDoubleChanceOptions(params.amount, parentMarketPosition1, params.market); _getDoubleChanceOptions(params.amount, parentMarketPosition2, params.market); IERC20Upgradeable(parentMarketPosition1).safeTransfer(params.market, params.amount); IERC20Upgradeable(parentMarketPosition2).safeTransfer(params.market, params.amount); } else { uint toMint = availableInContract < params.amount ? params.amount - availableInContract : 0; if (toMint > 0) { liquidityPool.commitTrade(params.market, toMint); ISportPositionalMarket(params.market).mint(toMint); spentOnGame[params.market] += toMint; spentOnParent[parent] += toMint; } liquidityPool.getOptionsForBuy(params.market, params.amount - toMint, params.position); } (IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(params.market).getOptions(); IPosition target = params.position == ISportsAMM.Position.Home ? home : params.position == ISportsAMM.Position.Away ? away : draw; IERC20Upgradeable(address(target)).safeTransfer(msg.sender, params.amount); if ( !dcs.isDoubleChance && thresholdForOddsUpdate > 0 && (params.amount - params.sUSDPaid) >= thresholdForOddsUpdate ) { ISportPositionalMarket sportMarket = ISportPositionalMarket(params.market); uint tag2 = sportMarket.isChild() ? sportMarket.tags(1) : 0; if (tag2 == TAG_NUMBER_PLAYERS) { wrapper.callUpdateOddsForSpecificPlayerProps(params.market); } else { wrapper.callUpdateOddsForSpecificGame(params.market); } } _updateSpentOnMarketOnBuy(dcs.isDoubleChance ? parent : params.market, parent, params.sUSDPaid, msg.sender); require(riskManager.isTotalSpendingLessThanTotalRisk(spentOnParent[parent], parent), "Risk is to high!"); _sendMintedPositionsAndUSDToLiquidityPool(dcs.isDoubleChance ? parent : params.market); if (address(stakingThales) != address(0)) { stakingThales.updateVolume(msg.sender, params.sUSDPaid); } emit BoughtFromAmm( msg.sender, params.market, params.position, params.amount, params.sUSDPaid, address(sUSD), address(target) ); } function _getDoubleChanceOptions( uint amount, address position, address market ) internal { uint balanceHeld = IERC20Upgradeable(position).balanceOf(address(this)); if (amount > balanceHeld) { liquidityPool.getOptionsForBuyByAddress( address(ISportPositionalMarket(market).parentMarket()), amount - balanceHeld, position ); } } function _availableToBuyFromAMMInternal( address market, ISportsAMM.Position position, uint baseOdds, uint balance, bool useBalance, DoubleChanceStruct memory dcs ) internal view returns (uint _available) { if (dcs.isDoubleChance) { if (position == ISportsAMM.Position.Home && (baseOdds > 0 && baseOdds < maxSupportedOdds)) { _available = _getAvailableHigherForPositions(dcs.parentMarket, dcs.position1, dcs.position2, true); } } else { baseOdds = floorBaseOdds(baseOdds, market); _available = availableToBuyFromAMMWithBaseOdds(market, position, baseOdds, balance, useBalance); } } function availableToBuyFromAMMWithBaseOdds( address market, ISportsAMM.Position position, uint baseOdds, uint balance, bool useBalance ) public view returns (uint availableAmount) { if (baseOdds > 0 && baseOdds < maxSupportedOdds) { baseOdds = (baseOdds * (ONE + min_spread)) / ONE; balance = useBalance ? balance : sportAmmUtils.balanceOfPositionOnMarket(market, position, liquidityPool.getMarketPool(market)); (uint cap, uint maxSpreadForMarket) = riskManager.getCapAndMaxSpreadForMarket(market, max_spread); availableAmount = sportAmmUtils.calculateAvailableToBuy( cap, spentOnGame[market], baseOdds, balance, maxSpreadForMarket ); } } function _obtainOdds(address _market, ISportsAMM.Position _position) internal view returns (uint) { if (ISportPositionalMarketManager(manager).isDoubleChanceMarket(_market)) { if (_position == ISportsAMM.Position.Home) { return sportAmmUtils.getBaseOddsForDoubleChanceSum(_market, _minOddsForMarket(_market)); } } return sportAmmUtils.obtainOdds(_market, _position); } function _checkMarketValidityAndOptionsCount(address market, ISportsAMM.Position position) internal view { require(isMarketInAMMTrading(market), "Not trading"); uint optionsCount = ISportPositionalMarket(market).optionsCount(); require(optionsCount > uint(position), "Invalid pos"); } function _getMinSpreadToUse(bool useDefaultMinSpread, address market) internal view returns (uint) { return riskManager.getMinSpreadToUse(useDefaultMinSpread, market, min_spread, min_spreadPerAddress[msg.sender]); } function _getSafeBoxFeePerAddress(address toCheck) internal view returns (uint toReturn) { if (toCheck != parlayAMM) { return safeBoxFeePerAddress[toCheck] > 0 ? safeBoxFeePerAddress[toCheck] : safeBoxImpact; } } function _minOddsForMarket(address _market) internal view returns (uint minOdds) { minOdds = riskManager.getMinOddsForMarket(_market, minSupportedOdds); } function _maxSpreadForMarket(address _market) internal view returns (uint maxSpread) { maxSpread = riskManager.getMaxSpreadForMarket(_market, max_spread); } function _sendMintedPositionsAndUSDToLiquidityPool(address market) internal { address _liquidityPool = liquidityPool.getOrCreateMarketPool(market); _sendIfNotZero(address(sUSD), _liquidityPool, sUSD.balanceOf(address(this))); (IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(market).getOptions(); require(address(home) != address(0), "0A"); (uint homeBalance, uint awayBalance, uint drawBalance) = ISportPositionalMarket(market).balancesOf(address(this)); _sendIfNotZero(address(home), _liquidityPool, homeBalance); _sendIfNotZero(address(away), _liquidityPool, awayBalance); _sendIfNotZero(address(draw), _liquidityPool, drawBalance); } function _sendIfNotZero( address source, address target, uint balance ) internal { if (balance > 0) { IERC20Upgradeable(source).safeTransfer(target, balance); } } function _sendFromIfNotZero( address from, address source, address target, uint balance ) internal { if (balance > 0) { IERC20Upgradeable(source).safeTransferFrom(from, target, balance); } } function _updateSpentOnMarketOnBuy( address market, address parent, uint sUSDPaid, address buyer ) internal { address referrer = IReferrals(referrals).sportReferrals(buyer); uint referrerShare; if (referrer != address(0)) { uint referrerFeeByTier = IReferrals(referrals).getReferrerFee(referrer); if (referrerFeeByTier > 0) { referrerShare = (sUSDPaid * referrerFeeByTier) / ONE; sUSD.safeTransfer(referrer, referrerShare); emit ReferrerPaid(referrer, msg.sender, referrerShare, sUSDPaid); } } uint safeBoxShare; uint sbimpact = _getSafeBoxFeePerAddress(buyer); if (sbimpact > 0) { safeBoxShare = sUSDPaid - (sUSDPaid * ONE) / (ONE + sbimpact); sUSD.safeTransfer(safeBox, safeBoxShare - referrerShare); } uint toSubtract = ISportPositionalMarketManager(manager).reverseTransformCollateral(sUSDPaid - safeBoxShare); spentOnGame[market] = spentOnGame[market] <= toSubtract ? 0 : (spentOnGame[market] -= toSubtract); spentOnParent[parent] = spentOnParent[parent] <= toSubtract ? 0 : (spentOnParent[parent] -= toSubtract); } function _buyPriceImpact( address market, ISportsAMM.Position position, uint amount, uint _availableToBuyFromAMM, uint _availableToBuyFromAMMOtherSide ) internal view returns (int priceImpact) { return sportAmmUtils.getBuyPriceImpact( SportsAMMUtils.PriceImpactParams( market, position, amount, _availableToBuyFromAMM, _availableToBuyFromAMMOtherSide, liquidityPool, _maxSpreadForMarket(market), _minOddsForMarket(market) ) ); } function _mintParentPositions( address market, uint amount, DoubleChanceStruct memory dcs ) internal { (uint availableInContract1, uint availableInContract2) = sportAmmUtils.getBalanceOfPositionsOnMarketByPositions( dcs.parentMarket, liquidityPool.getMarketPool(market), dcs.position1, dcs.position2 ); uint toMintPosition1 = availableInContract1 < amount ? amount - availableInContract1 : 0; uint toMintPosition2 = availableInContract2 < amount ? amount - availableInContract2 : 0; uint toMint = toMintPosition1 < toMintPosition2 ? toMintPosition2 : toMintPosition1; if (toMint > 0) { liquidityPool.commitTrade(dcs.parentMarket, toMint); ISportPositionalMarket(dcs.parentMarket).mint(toMint); spentOnGame[dcs.parentMarket] += toMint; spentOnParent[dcs.parentMarket] += toMint; } } function _getDoubleChanceStruct(address market) internal view returns (DoubleChanceStruct memory) { if (!ISportPositionalMarketManager(manager).isDoubleChanceMarket(market)) { return DoubleChanceStruct(false, ISportsAMM.Position.Home, ISportsAMM.Position.Away, address(0)); } else { (ISportsAMM.Position position1, ISportsAMM.Position position2, address parentMarket) = sportAmmUtils .getParentMarketPositions(market); return DoubleChanceStruct(true, position1, position2, parentMarket); } } // events event BoughtFromAmm( address buyer, address market, ISportsAMM.Position position, uint amount, uint sUSDPaid, address susd, address asset ); event ParametersUpdated( uint _minimalTimeLeftToMaturity, uint _minSpread, uint _maxSpread, uint _minSupportedOdds, uint _maxSupportedOdds, uint _safeBoxImpact, uint _referrerFee, uint threshold ); event AddressesUpdated( address _safeBox, IERC20Upgradeable _sUSD, address _theRundownConsumer, IStakingThales _stakingThales, address _referrals, address _parlayAMM, address _wrapper, address _lp, address _riskManager ); event SetSportsPositionalMarketManager(address _manager); event ReferrerPaid(address refferer, address trader, uint amount, uint volume); event SetMultiCollateralOnOffRamp(address _onramper, bool enabled); event ExercisedWithOfframp( address user, address market, address collateral, bool toEth, uint payout, uint payoutInCollateral ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } uint256[49] private __gap; }
// 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 // 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 // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier * available, which can be aplied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. */ contract ProxyReentrancyGuard { /// @dev counter to allow mutex lock with only one SSTORE operation uint256 private _guardCounter; bool private _initialized; function initNonReentrant() public { require(!_initialized, "Already initialized"); _initialized = true; _guardCounter = 1; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { _guardCounter += 1; uint256 localCounter = _guardCounter; _; require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); } }
// 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.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; 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 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 IStakingThales { function updateVolume(address account, uint amount) external; /* ========== VIEWS / VARIABLES ========== */ function totalStakedAmount() external view returns (uint); function stakedBalanceOf(address account) external view returns (uint); function currentPeriodRewards() external view returns (uint); function currentPeriodFees() external view returns (uint); function getLastPeriodOfClaimedRewards(address account) external view returns (uint); function getRewardsAvailable(address account) external view returns (uint); function getRewardFeesAvailable(address account) external view returns (uint); function getAlreadyClaimedRewards(address account) external view returns (uint); function getContractRewardFunds() external view returns (uint); function getContractFeeFunds() external view returns (uint); function getAMMVolume(address account) external view returns (uint); }
// 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); function marketForTeamName(string memory _teamName) external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; interface ICurveSUSD { function exchange_underlying( int128 i, int128 j, uint256 _dx, uint256 _min_dy ) external returns (uint256); function get_dy_underlying( int128 i, int128 j, uint256 _dx ) external view returns (uint256); // @notice Perform an exchange between two underlying coins // @param i Index value for the underlying coin to send // @param j Index valie of the underlying coin to receive // @param _dx Amount of `i` being exchanged // @param _min_dy Minimum amount of `j` to receive // @param _receiver Address that receives `j` // @return Actual amount of `j` received // indexes: // 0 = sUSD 18 dec 0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9 // 1= DAI 18 dec 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1 // 2= USDC 6 dec 0x7F5c764cBc14f9669B88837ca1490cCa17c31607 // 3= USDT 6 dec 0x94b008aA00579c1307B0EF2c499aD98a8ce58e58 }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; interface IReferrals { function referrals(address) external view returns (address); function getReferrerFee(address) external view returns (uint); function sportReferrals(address) external view returns (address); function setReferrer(address, address) external; }
// 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 ITherundownConsumerWrapper { function callUpdateOddsForSpecificGame(address _marketAddress) external; function callUpdateOddsForSpecificPlayerProps(address _marketAddress) 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); function getCapAndMaxSpreadForMarket(address _market, uint max_spread) external view returns (uint, uint); function getCapMaxSpreadAndMinOddsForMarket( address _market, uint max_spread, uint minSupportedOdds ) external view returns ( uint cap, uint maxSpread, uint minOddsForMarket ); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-4.4.1/token/ERC20/IERC20.sol"; import "../interfaces/ISportPositionalMarket.sol"; import "../interfaces/ISportPositionalMarketManager.sol"; import "../interfaces/IPosition.sol"; import "../interfaces/ITherundownConsumer.sol"; import "../interfaces/ISportsAMM.sol"; import "../interfaces/ISportAMMRiskManager.sol"; import "./LiquidityPool/SportAMMLiquidityPool.sol"; /// @title Sports AMM utils contract SportsAMMUtils { uint private constant ONE = 1e18; uint private constant ZERO_POINT_ONE = 1e17; uint private constant ONE_PERCENT = 1e16; uint private constant MAX_APPROVAL = type(uint256).max; int private constant ONE_INT = 1e18; int private constant ONE_PERCENT_INT = 1e16; uint public constant TAG_NUMBER_PLAYERS = 10010; ISportsAMM public sportsAMM; constructor(address _sportsAMM) { sportsAMM = ISportsAMM(_sportsAMM); } struct DiscountParams { uint balancePosition; uint balanceOtherSide; uint amount; uint availableToBuyFromAMM; uint max_spread; } struct NegativeDiscountsParams { uint amount; uint balancePosition; uint balanceOtherSide; uint _availableToBuyFromAMMOtherSide; uint _availableToBuyFromAMM; uint pricePosition; uint priceOtherPosition; uint max_spread; } struct PriceImpactParams { address market; ISportsAMM.Position position; uint amount; uint _availableToBuyFromAMM; uint _availableToBuyFromAMMOtherSide; SportAMMLiquidityPool liquidityPool; uint max_spread; uint minSupportedOdds; } struct AvailableHigher { address market; ISportsAMM.Position positionFirst; ISportsAMM.Position positionSecond; bool inverse; address marketPool; uint minOdds; uint cap; uint maxSpreadForMarket; uint spentOnGame; } function buyPriceImpactImbalancedSkew( uint amount, uint balanceOtherSide, uint balancePosition, uint balanceOtherSideAfter, uint balancePositionAfter, uint availableToBuyFromAMM, uint max_spread ) public view returns (uint) { uint maxPossibleSkew = balanceOtherSide + availableToBuyFromAMM - balancePosition; uint skew = balanceOtherSideAfter - (balancePositionAfter); uint newImpact = (max_spread * ((skew * ONE) / (maxPossibleSkew))) / ONE; if (balancePosition > 0) { uint newPriceForMintedOnes = newImpact / 2; uint tempMultiplier = (amount - balancePosition) * newPriceForMintedOnes; return (tempMultiplier * ONE) / (amount) / ONE; } else { uint previousSkew = balanceOtherSide; uint previousImpact = (max_spread * ((previousSkew * ONE) / maxPossibleSkew)) / ONE; return (newImpact + previousImpact) / 2; } } function calculateDiscount(DiscountParams memory params) public view returns (int) { uint currentBuyImpactOtherSide = buyPriceImpactImbalancedSkew( params.amount, params.balancePosition, params.balanceOtherSide, params.balanceOtherSide > ONE ? params.balancePosition : params.balancePosition + (ONE - params.balanceOtherSide), params.balanceOtherSide > ONE ? params.balanceOtherSide - ONE : 0, params.availableToBuyFromAMM, params.max_spread ); uint startDiscount = currentBuyImpactOtherSide; uint tempMultiplier = params.balancePosition - params.amount; uint finalDiscount = ((startDiscount / 2) * ((tempMultiplier * ONE) / params.balancePosition + ONE)) / ONE; return -int(finalDiscount); } function calculateDiscountFromNegativeToPositive(NegativeDiscountsParams memory params) public view returns (int priceImpact) { uint amountToBeMinted = params.amount - params.balancePosition; uint sum1 = params.balanceOtherSide + params.balancePosition; uint sum2 = params.balanceOtherSide + amountToBeMinted; uint red3 = params._availableToBuyFromAMM - params.balancePosition; uint positiveSkew = buyPriceImpactImbalancedSkew(amountToBeMinted, sum1, 0, sum2, 0, red3, params.max_spread); uint skew = (params.priceOtherPosition * positiveSkew) / params.pricePosition; int discount = calculateDiscount( DiscountParams( params.balancePosition, params.balanceOtherSide, params.balancePosition, params._availableToBuyFromAMMOtherSide, params.max_spread ) ); int discountBalance = int(params.balancePosition) * discount; int discountMinted = int(amountToBeMinted * skew); int amountInt = int(params.balancePosition + amountToBeMinted); priceImpact = (discountBalance + discountMinted) / amountInt; if (priceImpact > 0) { int numerator = int(params.pricePosition) * priceImpact; priceImpact = numerator / int(params.priceOtherPosition); } } function calculateTempQuote( int skewImpact, uint baseOdds, uint safeBoxImpact, uint amount ) public pure returns (int tempQuote) { if (skewImpact >= 0) { int impactPrice = ((ONE_INT - int(baseOdds)) * skewImpact) / ONE_INT; // add 2% to the price increase to avoid edge cases on the extremes impactPrice = (impactPrice * (ONE_INT + (ONE_PERCENT_INT * 2))) / ONE_INT; tempQuote = (int(amount) * (int(baseOdds) + impactPrice)) / ONE_INT; } else { tempQuote = ((int(amount)) * ((int(baseOdds) * (ONE_INT + skewImpact)) / ONE_INT)) / ONE_INT; } tempQuote = (tempQuote * (ONE_INT + (int(safeBoxImpact)))) / ONE_INT; } function calculateAvailableToBuy( uint capUsed, uint spentOnThisGame, uint baseOdds, uint balance, uint max_spread ) public pure returns (uint availableAmount) { uint discountedPrice = (baseOdds * (ONE - max_spread / 2)) / ONE; uint additionalBufferFromSelling = (balance * discountedPrice) / ONE; if ((capUsed + additionalBufferFromSelling) > spentOnThisGame) { uint availableUntilCapSUSD = capUsed + additionalBufferFromSelling - spentOnThisGame; if (availableUntilCapSUSD > capUsed) { availableUntilCapSUSD = capUsed; } uint midImpactPriceIncrease = ((ONE - baseOdds) * (max_spread / 2)) / ONE; uint divider_price = ONE - (baseOdds + midImpactPriceIncrease); availableAmount = balance + ((availableUntilCapSUSD * ONE) / divider_price); } } function getCanExercize(address market, address toCheck) public view returns (bool canExercize) { if ( ISportPositionalMarketManager(sportsAMM.manager()).isKnownMarket(market) && !ISportPositionalMarket(market).paused() && ISportPositionalMarket(market).resolved() ) { (IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(market).getOptions(); if (_hasNotBeenInitialized(home)) { return false; } if ( (home.getBalanceOf(address(toCheck)) > 0) || (away.getBalanceOf(address(toCheck)) > 0) || (ISportPositionalMarket(market).optionsCount() > 2 && draw.getBalanceOf(address(toCheck)) > 0) ) { canExercize = true; } } } function obtainOdds(address _market, ISportsAMM.Position _position) public view returns (uint oddsToReturn) { address theRundownConsumer = sportsAMM.theRundownConsumer(); ISportAMMRiskManager riskManager = sportsAMM.riskManager(); if (ISportPositionalMarket(_market).optionsCount() > uint(_position)) { uint[] memory odds = new uint[](ISportPositionalMarket(_market).optionsCount()); odds = ITherundownConsumer(theRundownConsumer).getNormalizedOddsForMarket(_market); (uint firstTag, uint secondTag, uint thirdTag) = _getTagsForMarket(_market); if (secondTag == TAG_NUMBER_PLAYERS) { if (!riskManager.isMarketForPlayerPropsOnePositional(thirdTag) || uint(_position) == 0) { oddsToReturn = odds[uint(_position)]; } } else { if ((!riskManager.isMarketForSportOnePositional(firstTag) || uint(_position) == 0)) { oddsToReturn = odds[uint(_position)]; } } } } function obtainOddsMulti( address _market, ISportsAMM.Position _position1, ISportsAMM.Position _position2 ) public view returns (uint oddsToReturn1, uint oddsToReturn2) { address theRundownConsumer = sportsAMM.theRundownConsumer(); uint positionsCount = ISportPositionalMarket(_market).optionsCount(); uint[] memory odds = new uint[](ISportPositionalMarket(_market).optionsCount()); odds = ITherundownConsumer(theRundownConsumer).getNormalizedOddsForMarket(_market); if (positionsCount > uint(_position1)) { oddsToReturn1 = odds[uint(_position1)]; } if (positionsCount > uint(_position2)) { oddsToReturn2 = odds[uint(_position2)]; } } function getBalanceOtherSideOnThreePositions( ISportsAMM.Position position, address addressToCheck, address market ) public view returns (uint balanceOfTheOtherSide) { (uint homeBalance, uint awayBalance, uint drawBalance) = getBalanceOfPositionsOnMarket(market, addressToCheck); if (position == ISportsAMM.Position.Home) { balanceOfTheOtherSide = awayBalance < drawBalance ? awayBalance : drawBalance; } else if (position == ISportsAMM.Position.Away) { balanceOfTheOtherSide = homeBalance < drawBalance ? homeBalance : drawBalance; } else { balanceOfTheOtherSide = homeBalance < awayBalance ? homeBalance : awayBalance; } } function getBalanceOfPositionsOnMarket(address market, address addressToCheck) public view returns ( uint homeBalance, uint awayBalance, uint drawBalance ) { (IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(market).getOptions(); if (_hasNotBeenInitialized(home)) { return (0, 0, 0); } homeBalance = home.getBalanceOf(addressToCheck); awayBalance = away.getBalanceOf(addressToCheck); if (ISportPositionalMarket(market).optionsCount() == 3) { drawBalance = draw.getBalanceOf(addressToCheck); } } function getBalanceOfPositionsOnMarketByPositions( address market, address addressToCheck, ISportsAMM.Position position1, ISportsAMM.Position position2 ) public view returns (uint firstBalance, uint secondBalance) { (uint homeBalance, uint awayBalance, uint drawBalance) = getBalanceOfPositionsOnMarket(market, addressToCheck); firstBalance = position1 == ISportsAMM.Position.Home ? homeBalance : position1 == ISportsAMM.Position.Away ? awayBalance : drawBalance; secondBalance = position2 == ISportsAMM.Position.Home ? homeBalance : position2 == ISportsAMM.Position.Away ? awayBalance : drawBalance; } function balanceOfPositionsOnMarket( address market, ISportsAMM.Position position, address addressToCheck ) public view returns ( uint, uint, uint ) { (IPosition home, IPosition away, ) = ISportPositionalMarket(market).getOptions(); if (_hasNotBeenInitialized(home)) { return (0, 0, 0); } uint balance = position == ISportsAMM.Position.Home ? home.getBalanceOf(addressToCheck) : away.getBalanceOf(addressToCheck); uint balanceOtherSideMax = position == ISportsAMM.Position.Home ? away.getBalanceOf(addressToCheck) : home.getBalanceOf(addressToCheck); uint balanceOtherSideMin = balanceOtherSideMax; if (ISportPositionalMarket(market).optionsCount() == 3) { (uint homeBalance, uint awayBalance, uint drawBalance) = getBalanceOfPositionsOnMarket(market, addressToCheck); if (position == ISportsAMM.Position.Home) { balance = homeBalance; if (awayBalance < drawBalance) { balanceOtherSideMax = drawBalance; balanceOtherSideMin = awayBalance; } else { balanceOtherSideMax = awayBalance; balanceOtherSideMin = drawBalance; } } else if (position == ISportsAMM.Position.Away) { balance = awayBalance; if (homeBalance < drawBalance) { balanceOtherSideMax = drawBalance; balanceOtherSideMin = homeBalance; } else { balanceOtherSideMax = homeBalance; balanceOtherSideMin = drawBalance; } } else if (position == ISportsAMM.Position.Draw) { balance = drawBalance; if (homeBalance < awayBalance) { balanceOtherSideMax = awayBalance; balanceOtherSideMin = homeBalance; } else { balanceOtherSideMax = homeBalance; balanceOtherSideMin = awayBalance; } } } return (balance, balanceOtherSideMax, balanceOtherSideMin); } function balanceOfPositionOnMarket( address market, ISportsAMM.Position position, address addressToCheck ) public view returns (uint) { (IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(market).getOptions(); if (_hasNotBeenInitialized(home)) { return 0; } uint balance = position == ISportsAMM.Position.Home ? home.getBalanceOf(addressToCheck) : away.getBalanceOf(addressToCheck); if (ISportPositionalMarket(market).optionsCount() == 3 && position != ISportsAMM.Position.Home) { balance = position == ISportsAMM.Position.Away ? away.getBalanceOf(addressToCheck) : draw.getBalanceOf(addressToCheck); } return balance; } function getParentMarketPositions(address market) public view returns ( ISportsAMM.Position position1, ISportsAMM.Position position2, address parentMarket ) { ISportPositionalMarket parentMarketContract = ISportPositionalMarket(market).parentMarket(); (IPosition home, IPosition away, ) = parentMarketContract.getOptions(); parentMarket = address(parentMarketContract); if (_hasNotBeenInitialized(home)) { (uint parentPosition1, uint parentPosition2) = ISportPositionalMarket(market).getParentMarketPositionsUint(); position1 = parentPosition1 == 0 ? ISportsAMM.Position.Home : parentPosition1 == 1 ? ISportsAMM.Position.Away : ISportsAMM.Position.Draw; position2 = parentPosition2 == 0 ? ISportsAMM.Position.Home : parentPosition2 == 1 ? ISportsAMM.Position.Away : ISportsAMM.Position.Draw; } else { (IPosition parentPosition1, IPosition parentPosition2) = ISportPositionalMarket(market) .getParentMarketPositions(); position1 = parentPosition1 == home ? ISportsAMM.Position.Home : parentPosition1 == away ? ISportsAMM.Position.Away : ISportsAMM.Position.Draw; position2 = parentPosition2 == home ? ISportsAMM.Position.Home : parentPosition2 == away ? ISportsAMM.Position.Away : ISportsAMM.Position.Draw; } } function getParentMarketPositionsImpactDoubleChance(address market, uint amount) public view returns (int) { (ISportsAMM.Position position1, ISportsAMM.Position position2, address parentMarket) = getParentMarketPositions( market ); int firstPriceImpact = sportsAMM.buyPriceImpact(parentMarket, position1, amount); int secondPriceImpact = sportsAMM.buyPriceImpact(parentMarket, position2, amount); return (firstPriceImpact + secondPriceImpact) / 2; } function getParentMarketPositionAddresses(address market) public view returns (address parentMarketPosition1, address parentMarketPosition2) { (IPosition position1, IPosition position2) = ISportPositionalMarket(market).getParentMarketPositions(); parentMarketPosition1 = address(position1); parentMarketPosition2 = address(position2); } function getBaseOddsForDoubleChance(address market, uint minSupportedOdds) public view returns (uint oddsPosition1, uint oddsPosition2) { (ISportsAMM.Position position1, ISportsAMM.Position position2, address parentMarket) = getParentMarketPositions( market ); oddsPosition1 = obtainOdds(parentMarket, position1); oddsPosition2 = obtainOdds(parentMarket, position2); if (oddsPosition1 > 0 && oddsPosition2 > 0) { oddsPosition1 = oddsPosition1 < minSupportedOdds ? minSupportedOdds : oddsPosition1; oddsPosition2 = oddsPosition2 < minSupportedOdds ? minSupportedOdds : oddsPosition2; } } function getBaseOddsForDoubleChanceSum(address market, uint minSupportedOdds) public view returns (uint sum) { (uint oddsPosition1, uint oddsPosition2) = getBaseOddsForDoubleChance(market, minSupportedOdds); sum = oddsPosition1 + oddsPosition2; } function getBuyPriceImpact(PriceImpactParams memory params) public view returns (int priceImpact) { (uint balancePosition, , uint balanceOtherSide) = balanceOfPositionsOnMarket( params.market, params.position, params.liquidityPool.getMarketPool(params.market) ); bool isTwoPositional = ISportPositionalMarket(params.market).optionsCount() == 2; uint balancePositionAfter = balancePosition > params.amount ? balancePosition - params.amount : 0; uint balanceOtherSideAfter = balancePosition > params.amount ? balanceOtherSide : balanceOtherSide + (params.amount - balancePosition); if (params.amount <= balancePosition) { priceImpact = calculateDiscount( DiscountParams( balancePosition, balanceOtherSide, params.amount, params._availableToBuyFromAMMOtherSide, params.max_spread ) ); } else { if (balancePosition > 0) { uint pricePosition = _obtainOdds(params.market, params.position, params.minSupportedOdds); uint priceOtherPosition = isTwoPositional ? _obtainOdds( params.market, params.position == ISportsAMM.Position.Home ? ISportsAMM.Position.Away : ISportsAMM.Position.Home, params.minSupportedOdds ) : ONE - pricePosition; priceImpact = calculateDiscountFromNegativeToPositive( NegativeDiscountsParams( params.amount, balancePosition, balanceOtherSide, params._availableToBuyFromAMMOtherSide, params._availableToBuyFromAMM, pricePosition, priceOtherPosition, params.max_spread ) ); } else { priceImpact = int( buyPriceImpactImbalancedSkew( params.amount, balanceOtherSide, balancePosition, balanceOtherSideAfter, balancePositionAfter, params._availableToBuyFromAMM, params.max_spread ) ); } } } function _obtainOdds( address _market, ISportsAMM.Position _position, uint minSupportedOdds ) internal view returns (uint) { if (ISportPositionalMarket(_market).isDoubleChance()) { if (_position == ISportsAMM.Position.Home) { return getBaseOddsForDoubleChanceSum(_market, minSupportedOdds); } } return obtainOdds(_market, _position); } function _getTagsForMarket(address _market) internal view returns ( uint tag1, uint tag2, uint tag3 ) { ISportPositionalMarket sportMarket = ISportPositionalMarket(_market); tag1 = sportMarket.tags(0); tag2 = sportMarket.isChild() ? sportMarket.tags(1) : 0; tag3 = sportMarket.isChild() && sportMarket.tags(1) == TAG_NUMBER_PLAYERS ? sportMarket.tags(2) : 0; } function getAvailableHigherForPositions(AvailableHigher memory params) public view returns (uint _availableHigher) { (uint baseOddsFirst, uint baseOddsSecond) = obtainOddsMulti( params.market, params.positionFirst, params.positionSecond ); baseOddsFirst = baseOddsFirst < params.minOdds ? params.minOdds : baseOddsFirst; baseOddsSecond = baseOddsSecond < params.minOdds ? params.minOdds : baseOddsSecond; (uint balanceFirst, uint balanceSecond) = getBalanceOfPositionsOnMarketByPositions( params.market, params.marketPool, params.positionFirst, params.positionSecond ); uint _availableOtherSideFirst = calculateAvailableToBuy( params.cap, params.spentOnGame, baseOddsFirst, baseOddsFirst, params.maxSpreadForMarket ); uint _availableOtherSideSecond = calculateAvailableToBuy( params.cap, params.spentOnGame, baseOddsSecond, balanceSecond, params.maxSpreadForMarket ); _availableHigher = _availableOtherSideFirst; if ( (params.inverse && _availableOtherSideFirst > _availableOtherSideSecond) || (!params.inverse && _availableOtherSideFirst <= _availableOtherSideSecond) ) { _availableHigher = _availableOtherSideSecond; } } function _hasNotBeenInitialized(IPosition home) internal view returns (bool) { return address(home) == address(0); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "../../utils/proxy/solidity-0.8.0/ProxyReentrancyGuard.sol"; import "../../utils/proxy/solidity-0.8.0/ProxyOwned.sol"; import "@openzeppelin/contracts-4.4.1/proxy/Clones.sol"; import "../../interfaces/ISportsAMM.sol"; import "../../interfaces/ISportPositionalMarket.sol"; import "../../interfaces/IStakingThales.sol"; import "./SportAMMLiquidityPoolRound.sol"; contract SportAMMLiquidityPool is Initializable, ProxyOwned, PausableUpgradeable, ProxyReentrancyGuard { /* ========== LIBRARIES ========== */ using SafeERC20Upgradeable for IERC20Upgradeable; struct InitParams { address _owner; ISportsAMM _sportsAmm; IERC20Upgradeable _sUSD; uint _roundLength; uint _maxAllowedDeposit; uint _minDepositAmount; uint _maxAllowedUsers; bool _needsTransformingCollateral; } /* ========== CONSTANTS ========== */ uint private constant HUNDRED = 1e20; uint private constant ONE = 1e18; uint private constant ONE_PERCENT = 1e16; /* ========== STATE VARIABLES ========== */ ISportsAMM public sportsAMM; IERC20Upgradeable public sUSD; bool public started; uint public round; uint public roundLength; uint public firstRoundStartTime; mapping(uint => address) public roundPools; mapping(uint => address[]) public usersPerRound; mapping(uint => mapping(address => bool)) public userInRound; mapping(uint => mapping(address => uint)) public balancesPerRound; mapping(uint => uint) public allocationPerRound; mapping(address => bool) public withdrawalRequested; mapping(uint => address[]) public tradingMarketsPerRound; mapping(uint => mapping(address => bool)) public isTradingMarketInARound; mapping(uint => uint) public profitAndLossPerRound; mapping(uint => uint) public cumulativeProfitAndLoss; uint public maxAllowedDeposit; uint public minDepositAmount; uint public maxAllowedUsers; uint public usersCurrentlyInPool; address public defaultLiquidityProvider; IStakingThales public stakingThales; uint public stakedThalesMultiplier; address public poolRoundMastercopy; mapping(address => bool) public whitelistedDeposits; uint public totalDeposited; bool public onlyWhitelistedStakersAllowed; mapping(address => bool) public whitelistedStakers; bool public needsTransformingCollateral; mapping(uint => mapping(address => bool)) public marketAlreadyExercisedInRound; bool public roundClosingPrepared; uint public usersProcessedInRound; mapping(address => uint) public withdrawalShare; uint public utilizationRate; address public safeBox; uint public safeBoxImpact; /* ========== CONSTRUCTOR ========== */ function initialize(InitParams calldata params) external initializer { setOwner(params._owner); initNonReentrant(); sportsAMM = ISportsAMM(params._sportsAmm); sUSD = params._sUSD; roundLength = params._roundLength; maxAllowedDeposit = params._maxAllowedDeposit; minDepositAmount = params._minDepositAmount; maxAllowedUsers = params._maxAllowedUsers; needsTransformingCollateral = params._needsTransformingCollateral; sUSD.approve(address(sportsAMM), type(uint256).max); } /// @notice Start pool and begin round #1 function start() external onlyOwner { require(!started, "Liquidity pool has already started"); require(allocationPerRound[1] > 0, "can not start with 0 deposits"); firstRoundStartTime = block.timestamp; round = 1; address roundPool = _getOrCreateRoundPool(1); SportAMMLiquidityPoolRound(roundPool).updateRoundTimes(firstRoundStartTime, getRoundEndTime(1)); started = true; emit PoolStarted(); } /// @notice Deposit funds from user into pool for the next round /// @param amount Value to be deposited function deposit(uint amount) external canDeposit(amount) nonReentrant whenNotPaused roundClosingNotPrepared { uint nextRound = round + 1; address roundPool = _getOrCreateRoundPool(nextRound); sUSD.safeTransferFrom(msg.sender, roundPool, amount); if (!whitelistedDeposits[msg.sender]) { require(!onlyWhitelistedStakersAllowed || whitelistedStakers[msg.sender], "Only whitelisted stakers allowed"); require(address(stakingThales) != address(0), "Staking Thales not set"); require( (balancesPerRound[round][msg.sender] + amount + balancesPerRound[nextRound][msg.sender]) <= _transformCollateral((stakingThales.stakedBalanceOf(msg.sender) * stakedThalesMultiplier) / ONE), "Not enough staked THALES" ); } require(msg.sender != defaultLiquidityProvider, "Can't deposit directly as default liquidity provider"); // new user enters the pool if (balancesPerRound[round][msg.sender] == 0 && balancesPerRound[nextRound][msg.sender] == 0) { require(usersCurrentlyInPool < maxAllowedUsers, "Max amount of users reached"); usersPerRound[nextRound].push(msg.sender); usersCurrentlyInPool = usersCurrentlyInPool + 1; } balancesPerRound[nextRound][msg.sender] += amount; allocationPerRound[nextRound] += amount; totalDeposited += amount; if (address(stakingThales) != address(0)) { stakingThales.updateVolume(msg.sender, amount); } emit Deposited(msg.sender, amount, round); } /// @notice get sUSD to mint for buy and store market as trading in the round /// @param market to trade /// @param amountToMint amount to get for mint function commitTrade(address market, uint amountToMint) external nonReentrant whenNotPaused onlyAMM roundClosingNotPrepared { require(started, "Pool has not started"); require(amountToMint > 0, "Can't commit a zero trade"); amountToMint = _transformCollateral(amountToMint); // add 1e-6 due to rounding issue, will be sent back to AMM at the end amountToMint = needsTransformingCollateral ? amountToMint + 1 : amountToMint; uint marketRound = getMarketRound(market); address liquidityPoolRound = _getOrCreateRoundPool(marketRound); if (marketRound == round) { sUSD.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amountToMint); require( sUSD.balanceOf(liquidityPoolRound) >= (allocationPerRound[round] - ((allocationPerRound[round] * utilizationRate) / ONE)), "Amount exceeds available utilization for round" ); } else { uint poolBalance = sUSD.balanceOf(liquidityPoolRound); if (poolBalance >= amountToMint) { sUSD.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amountToMint); } else { uint differenceToLPAsDefault = amountToMint - poolBalance; _depositAsDefault(differenceToLPAsDefault, liquidityPoolRound, marketRound); sUSD.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amountToMint); } } if (!isTradingMarketInARound[marketRound][market]) { tradingMarketsPerRound[marketRound].push(market); isTradingMarketInARound[marketRound][market] = true; } } /// @notice get options that are in the LP into the AMM for the buy tx /// @param market to get options for /// @param optionsAmount to get options for /// @param position to get options for function getOptionsForBuy( address market, uint optionsAmount, ISportsAMM.Position position ) external nonReentrant whenNotPaused onlyAMM roundClosingNotPrepared { if (optionsAmount > 0) { require(started, "Pool has not started"); uint marketRound = getMarketRound(market); address liquidityPoolRound = _getOrCreateRoundPool(marketRound); (IPosition home, IPosition away, IPosition draw) = ISportPositionalMarket(market).getOptions(); require(address(home) != address(0), "0A"); IPosition target = position == ISportsAMM.Position.Home ? home : away; if (ISportPositionalMarket(market).optionsCount() > 2 && position != ISportsAMM.Position.Home) { target = position == ISportsAMM.Position.Away ? away : draw; } SportAMMLiquidityPoolRound(liquidityPoolRound).moveOptions( IERC20Upgradeable(address(target)), optionsAmount, address(sportsAMM) ); } } /// @notice get options that are in the LP into the AMM for the buy tx /// @param market to get options for /// @param optionsAmount to get options for /// @param position to get options for function getOptionsForBuyByAddress( address market, uint optionsAmount, address position ) external nonReentrant whenNotPaused onlyAMM roundClosingNotPrepared { if (optionsAmount > 0) { require(started, "Pool has not started"); uint marketRound = getMarketRound(market); address liquidityPoolRound = _getOrCreateRoundPool(marketRound); SportAMMLiquidityPoolRound(liquidityPoolRound).moveOptions( IERC20Upgradeable(position), optionsAmount, address(sportsAMM) ); } } /// @notice Create a round pool by market maturity date if it doesnt already exist /// @param market to use /// @return roundPool the pool for the passed market function getOrCreateMarketPool(address market) external onlyAMM nonReentrant whenNotPaused roundClosingNotPrepared returns (address roundPool) { uint marketRound = getMarketRound(market); roundPool = _getOrCreateRoundPool(marketRound); } /// @notice request withdrawal from the LP function withdrawalRequest() external nonReentrant canWithdraw whenNotPaused roundClosingNotPrepared { if (totalDeposited > balancesPerRound[round][msg.sender]) { totalDeposited -= balancesPerRound[round][msg.sender]; } else { totalDeposited = 0; } usersCurrentlyInPool = usersCurrentlyInPool - 1; withdrawalRequested[msg.sender] = true; emit WithdrawalRequested(msg.sender); } /// @notice request partial withdrawal from the LP. /// @param share the percentage the user is wihdrawing from his total deposit function partialWithdrawalRequest(uint share) external nonReentrant canWithdraw whenNotPaused roundClosingNotPrepared { require(share >= ONE_PERCENT * 10 && share <= ONE_PERCENT * 90, "Share has to be between 10% and 90%"); uint toWithdraw = (balancesPerRound[round][msg.sender] * share) / ONE; if (totalDeposited > toWithdraw) { totalDeposited -= toWithdraw; } else { totalDeposited = 0; } withdrawalRequested[msg.sender] = true; withdrawalShare[msg.sender] = share; emit WithdrawalRequested(msg.sender); } /// @notice Prepare round closing /// excercise options of trading markets and ensure there are no markets left unresolved function prepareRoundClosing() external nonReentrant whenNotPaused roundClosingNotPrepared { require(canCloseCurrentRound(), "Can't close current round"); // excercise market options exerciseMarketsReadyToExercised(); address roundPool = roundPools[round]; // final balance is the final amount of sUSD in the round pool uint currentBalance = sUSD.balanceOf(roundPool); // send profit reserved for SafeBox if positive round if (currentBalance > allocationPerRound[round]) { uint safeBoxAmount = ((currentBalance - allocationPerRound[round]) * safeBoxImpact) / ONE; sUSD.safeTransferFrom(roundPool, safeBox, safeBoxAmount); currentBalance = currentBalance - safeBoxAmount; emit SafeBoxSharePaid(safeBoxImpact, safeBoxAmount); } // calculate PnL // if no allocation for current round if (allocationPerRound[round] == 0) { profitAndLossPerRound[round] = 1; } else { profitAndLossPerRound[round] = (currentBalance * ONE) / allocationPerRound[round]; } roundClosingPrepared = true; emit RoundClosingPrepared(round); } /// @notice Prepare round closing /// excercise options of trading markets and ensure there are no markets left unresolved function processRoundClosingBatch(uint batchSize) external nonReentrant whenNotPaused { require(roundClosingPrepared, "Round closing not prepared"); require(usersProcessedInRound < usersPerRound[round].length, "All users already processed"); require(batchSize > 0, "batchSize has to be greater than 0"); address roundPool = roundPools[round]; uint endCursor = usersProcessedInRound + batchSize; if (endCursor > usersPerRound[round].length) { endCursor = usersPerRound[round].length; } for (uint i = usersProcessedInRound; i < endCursor; i++) { address user = usersPerRound[round][i]; uint balanceAfterCurRound = (balancesPerRound[round][user] * profitAndLossPerRound[round]) / ONE; if (!withdrawalRequested[user] && (profitAndLossPerRound[round] > 0)) { balancesPerRound[round + 1][user] = balancesPerRound[round + 1][user] + balanceAfterCurRound; usersPerRound[round + 1].push(user); if (address(stakingThales) != address(0)) { stakingThales.updateVolume(user, balanceAfterCurRound); } } else { if (withdrawalShare[user] > 0) { uint amountToClaim = (balanceAfterCurRound * withdrawalShare[user]) / ONE; sUSD.safeTransferFrom(roundPool, user, amountToClaim); emit Claimed(user, amountToClaim); withdrawalRequested[user] = false; withdrawalShare[user] = 0; usersPerRound[round + 1].push(user); balancesPerRound[round + 1][user] = balanceAfterCurRound - amountToClaim; } else { balancesPerRound[round + 1][user] = 0; sUSD.safeTransferFrom(roundPool, user, balanceAfterCurRound); withdrawalRequested[user] = false; emit Claimed(user, balanceAfterCurRound); } } usersProcessedInRound = usersProcessedInRound + 1; } emit RoundClosingBatchProcessed(round, batchSize); } /// @notice Close current round and begin next round, /// calculate profit and loss and process withdrawals function closeRound() external nonReentrant whenNotPaused { require(roundClosingPrepared, "Round closing not prepared"); require(usersProcessedInRound == usersPerRound[round].length, "Not all users processed yet"); // set for next round to false roundClosingPrepared = false; address roundPool = roundPools[round]; //always claim for defaultLiquidityProvider if (balancesPerRound[round][defaultLiquidityProvider] > 0) { uint balanceAfterCurRound = (balancesPerRound[round][defaultLiquidityProvider] * profitAndLossPerRound[round]) / ONE; sUSD.safeTransferFrom(roundPool, defaultLiquidityProvider, balanceAfterCurRound); emit Claimed(defaultLiquidityProvider, balanceAfterCurRound); } if (round == 1) { cumulativeProfitAndLoss[round] = profitAndLossPerRound[round]; } else { cumulativeProfitAndLoss[round] = (cumulativeProfitAndLoss[round - 1] * profitAndLossPerRound[round]) / ONE; } // start next round round += 1; //add all carried over sUSD allocationPerRound[round] += sUSD.balanceOf(roundPool); totalDeposited = allocationPerRound[round] - balancesPerRound[round][defaultLiquidityProvider]; address roundPoolNewRound = _getOrCreateRoundPool(round); sUSD.safeTransferFrom(roundPool, roundPoolNewRound, sUSD.balanceOf(roundPool)); usersProcessedInRound = 0; emit RoundClosed(round - 1, profitAndLossPerRound[round - 1]); } /// @notice Iterate all markets in the current round and exercise those ready to be exercised function exerciseMarketsReadyToExercised() public whenNotPaused roundClosingNotPrepared { SportAMMLiquidityPoolRound poolRound = SportAMMLiquidityPoolRound(roundPools[round]); ISportPositionalMarket market; for (uint i = 0; i < tradingMarketsPerRound[round].length; i++) { address marketAddress = tradingMarketsPerRound[round][i]; if (!marketAlreadyExercisedInRound[round][marketAddress]) { market = ISportPositionalMarket(marketAddress); if (market.resolved()) { poolRound.exerciseMarketReadyToExercised(market); marketAlreadyExercisedInRound[round][marketAddress] = true; } } } } /// @notice Exercises markets in a round /// @param batchSize number of markets to be processed function exerciseMarketsReadyToExercisedBatch(uint batchSize) external nonReentrant whenNotPaused roundClosingNotPrepared { require(batchSize > 0, "batchSize has to be greater than 0"); SportAMMLiquidityPoolRound poolRound = SportAMMLiquidityPoolRound(roundPools[round]); uint count = 0; ISportPositionalMarket market; for (uint i = 0; i < tradingMarketsPerRound[round].length; i++) { if (count == batchSize) break; address marketAddress = tradingMarketsPerRound[round][i]; if (!marketAlreadyExercisedInRound[round][marketAddress]) { market = ISportPositionalMarket(marketAddress); if (market.resolved()) { poolRound.exerciseMarketReadyToExercised(market); marketAlreadyExercisedInRound[round][marketAddress] = true; count += 1; } } } } /* ========== VIEWS ========== */ /// @notice whether the user is currently LPing /// @param user to check /// @return isUserInLP whether the user is currently LPing function isUserLPing(address user) external view returns (bool isUserInLP) { isUserInLP = (balancesPerRound[round][user] > 0 || balancesPerRound[round + 1][user] > 0) && (!withdrawalRequested[user] || withdrawalShare[user] > 0); } /// @notice Return the maximum amount the user can deposit now /// @param user address to check /// @return maxDepositForUser the maximum amount the user can deposit in total including already deposited /// @return availableToDepositForUser the maximum amount the user can deposit now /// @return stakedThalesForUser how much THALES the user has staked function getMaxAvailableDepositForUser(address user) external view returns ( uint maxDepositForUser, uint availableToDepositForUser, uint stakedThalesForUser ) { uint nextRound = round + 1; stakedThalesForUser = stakingThales.stakedBalanceOf(user); maxDepositForUser = _transformCollateral((stakedThalesForUser * stakedThalesMultiplier) / ONE); availableToDepositForUser = maxDepositForUser > (balancesPerRound[round][user] + balancesPerRound[nextRound][user]) ? (maxDepositForUser - balancesPerRound[round][user] - balancesPerRound[nextRound][user]) : 0; } //deprecated User can now withdraw at any time /// @notice Return how much the user needs to have staked to withdraw /// @param user address to check /// @return neededStaked how much the user needs to have staked to withdraw function getNeededStakedThalesToWithdrawForUser(address user) external view returns (uint neededStaked) { uint nextRound = round + 1; neededStaked = _reverseTransformCollateral((balancesPerRound[round][user] + balancesPerRound[nextRound][user]) * ONE) / stakedThalesMultiplier; } /// @notice get the pool address for the market /// @param market to check /// @return roundPool the pool address for the market function getMarketPool(address market) external view returns (address roundPool) { roundPool = roundPools[getMarketRound(market)]; } /// @notice Checks if all conditions are met to close the round /// @return bool function canCloseCurrentRound() public view returns (bool) { if (!started || block.timestamp < getRoundEndTime(round)) { return false; } ISportPositionalMarket market; for (uint i = 0; i < tradingMarketsPerRound[round].length; i++) { address marketAddress = tradingMarketsPerRound[round][i]; if (!marketAlreadyExercisedInRound[round][marketAddress]) { market = ISportPositionalMarket(marketAddress); if (!market.resolved()) { return false; } } } return true; } /// @notice Iterate all markets in the current round and return true if at least one can be exercised function hasMarketsReadyToBeExercised() public view returns (bool) { SportAMMLiquidityPoolRound poolRound = SportAMMLiquidityPoolRound(roundPools[round]); ISportPositionalMarket market; for (uint i = 0; i < tradingMarketsPerRound[round].length; i++) { address marketAddress = tradingMarketsPerRound[round][i]; if (!marketAlreadyExercisedInRound[round][marketAddress]) { market = ISportPositionalMarket(marketAddress); if (market.resolved()) { (uint homeBalance, uint awayBalance, uint drawBalance) = market.balancesOf(address(poolRound)); if (homeBalance > 0 || awayBalance > 0 || drawBalance > 0) { return true; } } } } return false; } /// @notice Return multiplied PnLs between rounds /// @param roundA Round number from /// @param roundB Round number to /// @return uint function cumulativePnLBetweenRounds(uint roundA, uint roundB) public view returns (uint) { return (cumulativeProfitAndLoss[roundB] * profitAndLossPerRound[roundA]) / cumulativeProfitAndLoss[roundA]; } /// @notice Return the start time of the passed round /// @param _round number /// @return uint the start time of the given round function getRoundStartTime(uint _round) public view returns (uint) { return firstRoundStartTime + (_round - 1) * roundLength; } /// @notice Return the end time of the passed round /// @param _round number /// @return uint the end time of the given round function getRoundEndTime(uint _round) public view returns (uint) { return firstRoundStartTime + _round * roundLength; } /// @notice Return the round to which a market belongs to /// @param market to get the round for /// @return _round the round which the market belongs to function getMarketRound(address market) public view returns (uint _round) { ISportPositionalMarket marketContract = ISportPositionalMarket(market); (uint maturity, ) = marketContract.times(); if (maturity > firstRoundStartTime) { _round = (maturity - firstRoundStartTime) / roundLength + 1; } else { _round = 1; } } /// @notice Return the count of users in current round /// @return _the count of users in current round function getUsersCountInCurrentRound() external view returns (uint) { return usersPerRound[round].length; } /* ========== INTERNAL FUNCTIONS ========== */ function _transformCollateral(uint value) internal view returns (uint) { if (needsTransformingCollateral) { return value / 1e12; } else { return value; } } function _reverseTransformCollateral(uint value) internal view returns (uint) { if (needsTransformingCollateral) { return value * 1e12; } else { return value; } } function _depositAsDefault( uint amount, address roundPool, uint _round ) internal { require(defaultLiquidityProvider != address(0), "default liquidity provider not set"); sUSD.safeTransferFrom(defaultLiquidityProvider, roundPool, amount); balancesPerRound[_round][defaultLiquidityProvider] += amount; allocationPerRound[_round] += amount; emit Deposited(defaultLiquidityProvider, amount, _round); } function _getOrCreateRoundPool(uint _round) internal returns (address roundPool) { roundPool = roundPools[_round]; if (roundPool == address(0)) { require(poolRoundMastercopy != address(0), "Round pool mastercopy not set"); SportAMMLiquidityPoolRound newRoundPool = SportAMMLiquidityPoolRound(Clones.clone(poolRoundMastercopy)); newRoundPool.initialize(address(this), sUSD, _round, getRoundEndTime(_round - 1), getRoundEndTime(_round)); roundPool = address(newRoundPool); roundPools[_round] = roundPool; emit RoundPoolCreated(_round, roundPool); } } /* ========== SETTERS ========== */ function setPaused(bool _setPausing) external onlyOwner { _setPausing ? _pause() : _unpause(); } /// @notice Set onlyWhitelistedStakersAllowed variable /// @param flagToSet self explanatory function setOnlyWhitelistedStakersAllowed(bool flagToSet) external onlyOwner { onlyWhitelistedStakersAllowed = flagToSet; emit SetOnlyWhitelistedStakersAllowed(flagToSet); } /// @notice Set setNeedsTransformingCollateral variable /// @param _needsTransformingCollateral self explanatory function setNeedsTransformingCollateral(bool _needsTransformingCollateral) external onlyOwner { needsTransformingCollateral = _needsTransformingCollateral; emit SetNeedsTransformingCollateral(_needsTransformingCollateral); } /// @notice Set _poolRoundMastercopy /// @param _poolRoundMastercopy to clone round pools from function setPoolRoundMastercopy(address _poolRoundMastercopy) external onlyOwner { require(_poolRoundMastercopy != address(0), "Can not set a zero address!"); poolRoundMastercopy = _poolRoundMastercopy; emit PoolRoundMastercopyChanged(poolRoundMastercopy); } /// @notice Set _stakedThalesMultiplier /// @param _stakedThalesMultiplier the number of sUSD one can deposit per THALES staked function setStakedThalesMultiplier(uint _stakedThalesMultiplier) external onlyOwner { stakedThalesMultiplier = _stakedThalesMultiplier; emit StakedThalesMultiplierChanged(_stakedThalesMultiplier); } /// @notice Set IStakingThales contract /// @param _stakingThales IStakingThales address function setStakingThales(IStakingThales _stakingThales) external onlyOwner { require(address(_stakingThales) != address(0), "Can not set a zero address!"); stakingThales = _stakingThales; emit StakingThalesChanged(address(_stakingThales)); } /// @notice Set max allowed deposit /// @param _maxAllowedDeposit Deposit value function setMaxAllowedDeposit(uint _maxAllowedDeposit) external onlyOwner { maxAllowedDeposit = _maxAllowedDeposit; emit MaxAllowedDepositChanged(_maxAllowedDeposit); } /// @notice Set min allowed deposit /// @param _minDepositAmount Deposit value function setMinAllowedDeposit(uint _minDepositAmount) external onlyOwner { minDepositAmount = _minDepositAmount; emit MinAllowedDepositChanged(_minDepositAmount); } /// @notice Set _maxAllowedUsers /// @param _maxAllowedUsers Deposit value function setMaxAllowedUsers(uint _maxAllowedUsers) external onlyOwner { maxAllowedUsers = _maxAllowedUsers; emit MaxAllowedUsersChanged(_maxAllowedUsers); } /// @notice Set ThalesAMM contract /// @param _sportAMM ThalesAMM address function setSportAmm(ISportsAMM _sportAMM) external onlyOwner { require(address(_sportAMM) != address(0), "Can not set a zero address!"); sportsAMM = _sportAMM; sUSD.approve(address(sportsAMM), type(uint256).max); emit SportAMMChanged(address(_sportAMM)); } /// @notice Set defaultLiquidityProvider wallet /// @param _defaultLiquidityProvider default liquidity provider function setDefaultLiquidityProvider(address _defaultLiquidityProvider) external onlyOwner { require(_defaultLiquidityProvider != address(0), "Can not set a zero address!"); defaultLiquidityProvider = _defaultLiquidityProvider; emit DefaultLiquidityProviderChanged(_defaultLiquidityProvider); } /// @notice Set length of rounds /// @param _roundLength Length of a round in miliseconds function setRoundLength(uint _roundLength) external onlyOwner { require(!started, "Can't change round length after start"); roundLength = _roundLength; emit RoundLengthChanged(_roundLength); } /// @notice set addresses which can deposit into the AMM bypassing the staking checks /// @param _whitelistedAddresses Addresses to set the whitelist flag for /// @param _flag to set function setWhitelistedAddresses(address[] calldata _whitelistedAddresses, bool _flag) 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 (whitelistedDeposits[_whitelistedAddresses[index]] != _flag) { whitelistedDeposits[_whitelistedAddresses[index]] = _flag; emit AddedIntoWhitelist(_whitelistedAddresses[index], _flag); } } } /// @notice set addresses which can deposit into the AMM when only whitelisted stakers are allowed /// @param _whitelistedAddresses Addresses to set the whitelist flag for /// @param _flag to set function setWhitelistedStakerAddresses(address[] calldata _whitelistedAddresses, bool _flag) 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 (whitelistedStakers[_whitelistedAddresses[index]] != _flag) { whitelistedStakers[_whitelistedAddresses[index]] = _flag; emit AddedIntoWhitelistStaker(_whitelistedAddresses[index], _flag); } } } /// @notice set utilization rate parameter /// @param _utilizationRate value as percentage function setUtilizationRate(uint _utilizationRate) external onlyOwner { utilizationRate = _utilizationRate; emit UtilizationRateChanged(_utilizationRate); } /// @notice set SafeBox params /// @param _safeBox where to send a profit reserved for protocol from each round /// @param _safeBoxImpact how much is the SafeBox percentage function setSafeBoxParams(address _safeBox, uint _safeBoxImpact) external onlyOwner { safeBox = _safeBox; safeBoxImpact = _safeBoxImpact; emit SetSafeBoxParams(_safeBox, _safeBoxImpact); } /* ========== MODIFIERS ========== */ modifier canDeposit(uint amount) { require(!withdrawalRequested[msg.sender], "Withdrawal is requested, cannot deposit"); require(totalDeposited + amount <= maxAllowedDeposit, "Deposit amount exceeds AMM LP cap"); if (balancesPerRound[round][msg.sender] == 0 && balancesPerRound[round + 1][msg.sender] == 0) { require(amount >= minDepositAmount, "Amount less than minDepositAmount"); } _; } modifier canWithdraw() { require(started, "Pool has not started"); require(!withdrawalRequested[msg.sender], "Withdrawal already requested"); require(balancesPerRound[round][msg.sender] > 0, "Nothing to withdraw"); require(balancesPerRound[round + 1][msg.sender] == 0, "Can't withdraw as you already deposited for next round"); _; } modifier onlyAMM() { require(msg.sender == address(sportsAMM), "only the AMM may perform these methods"); _; } modifier roundClosingNotPrepared() { require(!roundClosingPrepared, "Not allowed during roundClosingPrepared"); _; } /* ========== EVENTS ========== */ event PoolStarted(); event Deposited(address user, uint amount, uint round); event WithdrawalRequested(address user); event RoundClosed(uint round, uint roundPnL); event Claimed(address user, uint amount); event RoundPoolCreated(uint _round, address roundPool); event PoolRoundMastercopyChanged(address newMastercopy); event StakedThalesMultiplierChanged(uint _stakedThalesMultiplier); event StakingThalesChanged(address stakingThales); event MaxAllowedDepositChanged(uint maxAllowedDeposit); event MinAllowedDepositChanged(uint minAllowedDeposit); event MaxAllowedUsersChanged(uint MaxAllowedUsersChanged); event SportAMMChanged(address sportAMM); event DefaultLiquidityProviderChanged(address newProvider); event AddedIntoWhitelist(address _whitelistAddress, bool _flag); event AddedIntoWhitelistStaker(address _whitelistAddress, bool _flag); event RoundLengthChanged(uint roundLength); event SetOnlyWhitelistedStakersAllowed(bool flagToSet); event RoundClosingPrepared(uint round); event RoundClosingBatchProcessed(uint round, uint batchSize); event UtilizationRateChanged(uint utilizationRate); event SetSafeBoxParams(address safeBox, uint safeBoxImpact); event SafeBoxSharePaid(uint safeBoxShare, uint safeBoxAmount); event SetNeedsTransformingCollateral(bool needs); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; interface IMultiCollateralOnOffRamp { function onramp(address collateral, uint collateralAmount) external returns (uint); function onrampWithEth(uint amount) external payable returns (uint); function getMinimumReceived(address collateral, uint amount) external view returns (uint); function getMinimumNeeded(address collateral, uint amount) external view returns (uint); function WETH9() external view returns (address); function offrampIntoEth(uint amount) external returns (uint); function offramp(address collateral, uint amount) external returns (uint); }
// 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); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { __Context_init_unchained(); } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
// 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; 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 // 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 // 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 pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "../../interfaces/ISportPositionalMarket.sol"; import "./SportAMMLiquidityPool.sol"; contract SportAMMLiquidityPoolRound { /* ========== LIBRARIES ========== */ using SafeERC20Upgradeable for IERC20Upgradeable; /* ========== STATE VARIABLES ========== */ SportAMMLiquidityPool public liquidityPool; IERC20Upgradeable public sUSD; uint public round; uint public roundStartTime; uint public roundEndTime; /* ========== CONSTRUCTOR ========== */ bool public initialized; function initialize( address _liquidityPool, IERC20Upgradeable _sUSD, uint _round, uint _roundStartTime, uint _roundEndTime ) external { require(!initialized, "Already initialized"); initialized = true; liquidityPool = SportAMMLiquidityPool(_liquidityPool); sUSD = _sUSD; round = _round; roundStartTime = _roundStartTime; roundEndTime = _roundEndTime; sUSD.approve(_liquidityPool, type(uint256).max); } function updateRoundTimes(uint _roundStartTime, uint _roundEndTime) external onlyLiquidityPool { roundStartTime = _roundStartTime; roundEndTime = _roundEndTime; emit RoundTimesUpdated(_roundStartTime, _roundEndTime); } function exerciseMarketReadyToExercised(ISportPositionalMarket market) external onlyLiquidityPool { if (market.resolved()) { (uint homeBalance, uint awayBalance, uint drawBalance) = market.balancesOf(address(this)); if (homeBalance > 0 || awayBalance > 0 || drawBalance > 0) { market.exerciseOptions(); } } } function moveOptions( IERC20Upgradeable option, uint optionsAmount, address destination ) external onlyLiquidityPool { option.safeTransfer(destination, optionsAmount); } modifier onlyLiquidityPool() { require(msg.sender == address(liquidityPool), "only the Pool manager may perform these methods"); _; } event RoundTimesUpdated(uint _roundStartTime, uint _roundEndTime); }
{ "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
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_safeBox","type":"address"},{"indexed":false,"internalType":"contract IERC20Upgradeable","name":"_sUSD","type":"address"},{"indexed":false,"internalType":"address","name":"_theRundownConsumer","type":"address"},{"indexed":false,"internalType":"contract IStakingThales","name":"_stakingThales","type":"address"},{"indexed":false,"internalType":"address","name":"_referrals","type":"address"},{"indexed":false,"internalType":"address","name":"_parlayAMM","type":"address"},{"indexed":false,"internalType":"address","name":"_wrapper","type":"address"},{"indexed":false,"internalType":"address","name":"_lp","type":"address"},{"indexed":false,"internalType":"address","name":"_riskManager","type":"address"}],"name":"AddressesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sUSDPaid","type":"uint256"},{"indexed":false,"internalType":"address","name":"susd","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"BoughtFromAmm","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"address","name":"collateral","type":"address"},{"indexed":false,"internalType":"bool","name":"toEth","type":"bool"},{"indexed":false,"internalType":"uint256","name":"payout","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"payoutInCollateral","type":"uint256"}],"name":"ExercisedWithOfframp","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":"uint256","name":"_minimalTimeLeftToMaturity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_minSpread","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxSpread","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_minSupportedOdds","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxSupportedOdds","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_referrerFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"threshold","type":"uint256"}],"name":"ParametersUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"refferer","type":"address"},{"indexed":false,"internalType":"address","name":"trader","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"volume","type":"uint256"}],"name":"ReferrerPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_onramper","type":"address"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"SetMultiCollateralOnOffRamp","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_manager","type":"address"}],"name":"SetSportsPositionalMarketManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"TAG_NUMBER_PLAYERS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"}],"name":"availableToBuyFromAMM","outputs":[{"internalType":"uint256","name":"_available","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"baseOdds","type":"uint256"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"bool","name":"useBalance","type":"bool"}],"name":"availableToBuyFromAMMWithBaseOdds","outputs":[{"internalType":"uint256","name":"availableAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedPayout","type":"uint256"},{"internalType":"uint256","name":"additionalSlippage","type":"uint256"}],"name":"buyFromAMM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedPayout","type":"uint256"},{"internalType":"uint256","name":"additionalSlippage","type":"uint256"},{"internalType":"address","name":"collateral","type":"address"}],"name":"buyFromAMMWithDifferentCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedPayout","type":"uint256"},{"internalType":"uint256","name":"additionalSlippage","type":"uint256"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"buyFromAMMWithDifferentCollateralAndReferrer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedPayout","type":"uint256"},{"internalType":"uint256","name":"additionalSlippage","type":"uint256"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"buyFromAMMWithEthAndReferrer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedPayout","type":"uint256"},{"internalType":"uint256","name":"additionalSlippage","type":"uint256"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"buyFromAMMWithReferrer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"buyFromAmmQuote","outputs":[{"internalType":"uint256","name":"_quote","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"buyFromAmmQuoteForParlayAMM","outputs":[{"internalType":"uint256","name":"_quote","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"collateral","type":"address"}],"name":"buyFromAmmQuoteWithDifferentCollateral","outputs":[{"internalType":"uint256","name":"collateralQuote","type":"uint256"},{"internalType":"uint256","name":"sUSDToPay","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"buyPriceImpact","outputs":[{"internalType":"int256","name":"impact","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"bool","name":"toEth","type":"bool"}],"name":"exerciseWithOfframp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"baseOdds","type":"uint256"},{"internalType":"address","name":"market","type":"address"}],"name":"floorBaseOdds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"bool","name":"isSell","type":"bool"}],"name":"getMarketDefaultOdds","outputs":[{"internalType":"uint256[]","name":"odds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initNonReentrant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IERC20Upgradeable","name":"_sUSD","type":"address"},{"internalType":"uint256","name":"_min_spread","type":"uint256"},{"internalType":"uint256","name":"_max_spread","type":"uint256"},{"internalType":"uint256","name":"_minimalTimeLeftToMaturity","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"isMarketInAMMTrading","outputs":[{"internalType":"bool","name":"isTrading","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidityPool","outputs":[{"internalType":"contract SportAMMLiquidityPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupportedOdds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"max_spread","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minSupportedOdds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"min_spread","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"min_spreadPerAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimalTimeLeftToMaturity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"multiCollateralOnOffRamp","outputs":[{"internalType":"contract IMultiCollateralOnOffRamp","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"multicollateralEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"enum ISportsAMM.Position","name":"_position","type":"uint8"}],"name":"obtainOdds","outputs":[{"internalType":"uint256","name":"oddsToReturn","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"parlayAMM","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referrals","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"riskManager","outputs":[{"internalType":"contract ISportAMMRiskManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sUSD","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeBox","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"safeBoxFeePerAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeBoxImpact","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_safeBox","type":"address"},{"internalType":"contract IERC20Upgradeable","name":"_sUSD","type":"address"},{"internalType":"address","name":"_theRundownConsumer","type":"address"},{"internalType":"contract IStakingThales","name":"_stakingThales","type":"address"},{"internalType":"address","name":"_referrals","type":"address"},{"internalType":"address","name":"_parlayAMM","type":"address"},{"internalType":"address","name":"_wrapper","type":"address"},{"internalType":"address","name":"_lp","type":"address"},{"internalType":"address","name":"_riskManager","type":"address"}],"name":"setAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract SportsAMMUtils","name":"_ammUtils","type":"address"}],"name":"setAmmUtils","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_onramper","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setMultiCollateralOnOffRamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minimalTimeLeftToMaturity","type":"uint256"},{"internalType":"uint256","name":"_minSpread","type":"uint256"},{"internalType":"uint256","name":"_maxSpread","type":"uint256"},{"internalType":"uint256","name":"_minSupportedOdds","type":"uint256"},{"internalType":"uint256","name":"_maxSupportedOdds","type":"uint256"},{"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"},{"internalType":"uint256","name":"_referrerFee","type":"uint256"},{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"setParameters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_setPausing","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"newSBFee","type":"uint256"},{"internalType":"uint256","name":"newMSFee","type":"uint256"}],"name":"setSafeBoxFeeAndMinSpreadPerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_manager","type":"address"}],"name":"setSportsPositionalMarketManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"spentOnGame","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sportAmmUtils","outputs":[{"internalType":"contract SportsAMMUtils","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingThales","outputs":[{"internalType":"contract IStakingThales","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"theRundownConsumer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"thresholdForOddsUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"updateParlayVolume","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrapper","outputs":[{"internalType":"contract ITherundownConsumerWrapper","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
608060405234801561001057600080fd5b50615f0e80620000216000396000f3fe60806040526004361061037a5760003560e01c80638875eb84116101d1578063c23ca72311610102578063df8974d0116100a0578063efc152511161006f578063efc1525114610a3d578063f8291d2b14610a5d578063f88b757114610a7d578063fd8a8cc614610a9d57600080fd5b8063df8974d0146109dc578063e88698bf146109f2578063ebc7977214610a08578063ec933f8314610a1d57600080fd5b8063d333ca19116100dc578063d333ca1914610951578063d3dc753914610971578063d4a2641b14610991578063d69fb668146109c657600080fd5b8063c23ca723146108f1578063c3b83f5f14610911578063d13f90b41461093157600080fd5b80639a618c0f1161016f578063b24ef63811610149578063b24ef63814610871578063bb96af6514610891578063bf46c0b4146108b1578063c062ef87146108d157600080fd5b80639a618c0f146108115780639f916c9f14610831578063ac210cc71461085157600080fd5b80638da5cb5b116101ab5780638da5cb5b146107855780639324cac7146107ab57806393baafd5146107d057806399c18e7e146107f057600080fd5b80638875eb841461070b5780638a7c84e51461072b5780638afdf2d81461075857600080fd5b806348663e95116102ab57806366272044116102495780636cc5a6ff116102235780636cc5a6ff146106a057806379ba5097146106c05780637b4626bd146106d55780637d550e05146106eb57600080fd5b8063662720441461064a578063665a11ca1461066a5780636aaa81b61461068a57600080fd5b806353a47bb71161028557806353a47bb7146105b55780635727a0f3146105d55780635c975abb1461060557806365f567721461061d57600080fd5b806348663e951461055557806350d851a1146105755780635266d4881461059557600080fd5b8063316425c311610318578063424f073b116102f2578063424f073b146104ca578063443a4077146104dd57806347842663146104fd578063481c6a751461053557600080fd5b8063316425c31461047e578063343d372f1461049457806334ba3c71146104aa57600080fd5b80631627540c116103545780631627540c146103f157806316c38b3c14610411578063270e13ef146104315780632972e8ab1461045157600080fd5b806309b03964146103865780630fabf206146103b957806313af4035146103cf57600080fd5b3661038157005b600080fd5b34801561039257600080fd5b506103a66103a13660046156ad565b610abd565b6040519081526020015b60405180910390f35b3480156103c557600080fd5b506103a660805481565b3480156103db57600080fd5b506103ef6103ea36600461548d565b610afd565b005b3480156103fd57600080fd5b506103ef61040c36600461548d565b610c3d565b34801561041d57600080fd5b506103ef61042c36600461590e565b610c93565b34801561043d57600080fd5b506103a661044c3660046156ad565b610cb3565b34801561045d57600080fd5b506103a661046c36600461548d565b60836020526000908152604090205481565b34801561048a57600080fd5b506103a6606b5481565b3480156104a057600080fd5b506103a661271a81565b3480156104b657600080fd5b506103ef6104c5366004615a43565b610d04565b6103ef6104d8366004615835565b610d9b565b3480156104e957600080fd5b506103ef6104f83660046158af565b610e89565b34801561050957600080fd5b50608a5461051d906001600160a01b031681565b6040516001600160a01b0390911681526020016103b0565b34801561054157600080fd5b5060685461051d906001600160a01b031681565b34801561056157600080fd5b50606e5461051d906001600160a01b031681565b34801561058157600080fd5b506103a6610590366004615680565b610f4e565b3480156105a157600080fd5b506103ef6105b03660046158da565b610f5a565b3480156105c157600080fd5b5060015461051d906001600160a01b031681565b3480156105e157600080fd5b506105f56105f036600461548d565b610f8a565b60405190151581526020016103b0565b34801561061157600080fd5b5060345460ff166105f5565b34801561062957600080fd5b506103a661063836600461548d565b60826020526000908152604090205481565b34801561065657600080fd5b506103ef610665366004615575565b6110a1565b34801561067657600080fd5b5060855461051d906001600160a01b031681565b34801561069657600080fd5b506103a6606a5481565b3480156106ac57600080fd5b506103ef6106bb366004615835565b6111c4565b3480156106cc57600080fd5b506103ef611287565b3480156106e157600080fd5b506103a660725481565b3480156106f757600080fd5b50607a5461051d906001600160a01b031681565b34801561071757600080fd5b506103ef61072636600461579d565b611384565b34801561073757600080fd5b506103a661074636600461548d565b606d6020526000908152604090205481565b34801561076457600080fd5b50610778610773366004615548565b61144a565b6040516103b09190615be1565b34801561079157600080fd5b5060005461051d906201000090046001600160a01b031681565b3480156107b757600080fd5b5060675461051d9061010090046001600160a01b031681565b3480156107dc57600080fd5b506103a66107eb3660046159cf565b611591565b3480156107fc57600080fd5b50608c546105f590600160a01b900460ff1681565b34801561081d57600080fd5b50608c5461051d906001600160a01b031681565b34801561083d57600080fd5b506103ef61084c3660046157cf565b6115b8565b34801561085d57600080fd5b5060815461051d906001600160a01b031681565b34801561087d57600080fd5b50607e5461051d906001600160a01b031681565b34801561089d57600080fd5b50606f5461051d906001600160a01b031681565b3480156108bd57600080fd5b506103a66108cc3660046156ad565b6116fc565b3480156108dd57600080fd5b506103ef6108ec3660046154fe565b61187b565b3480156108fd57600080fd5b506103a661090c36600461573f565b611e73565b34801561091d57600080fd5b506103ef61092c36600461548d565b61210b565b34801561093d57600080fd5b506103ef61094c366004615630565b612224565b34801561095d57600080fd5b506103ef61096c36600461548d565b612321565b34801561097d57600080fd5b5060785461051d906001600160a01b031681565b34801561099d57600080fd5b506109b16109ac3660046156ed565b61234b565b604080519283526020830191909152016103b0565b3480156109d257600080fd5b506103a660705481565b3480156109e857600080fd5b506103a6606c5481565b3480156109fe57600080fd5b506103a660735481565b348015610a1457600080fd5b506103ef6123e7565b348015610a2957600080fd5b506103ef610a383660046157cf565b612445565b348015610a4957600080fd5b506103a6610a58366004615680565b612493565b348015610a6957600080fd5b506103ef610a78366004615548565b6124ce565b348015610a8957600080fd5b506103ef610a9836600461548d565b61266f565b348015610aa957600080fd5b5060715461051d906001600160a01b031681565b600080610aca85856127ec565b9050610ad68186611591565b9050610af48585858460008060006001610aef8e6129a8565b612b80565b95945050505050565b6001600160a01b038116610b585760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff1615610bc45760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610b4f565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b610c45612bbf565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610c32565b610c9b612bbf565b80610cab57610ca8612c39565b50565b610ca8612ccc565b6000610cbe84610f8a565b15610cfd576000610ccf85856127ec565b90508015610cfb57610ce18186611591565b9050610af4858585846070546000806001610aef8e6129a8565b505b9392505050565b610d0c612bbf565b606c889055606a879055606b8690556072859055607384905560708390556080818155604080518a8152602081018a90528082018990526060810188905291820186905260a0820185905260c0820184905260e08201839052517f3a2276994eb7c279297bcbc22f9e4dda9af91c054220b647ffa9dd9a72d46d62918190036101000190a15050505050505050565b600160666000828254610dae9190615dbf565b909155505060665460345460ff1615610dd95760405162461bcd60e51b8152600401610b4f90615c58565b6001600160a01b03821615610e4e5760785460405163bbddaca360e01b81526001600160a01b0384811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b158015610e3557600080fd5b505af1158015610e49573d6000803e3d6000fd5b505050505b610e5e8888888888886001612d24565b6066548114610e7f5760405162461bcd60e51b8152600401610b4f90615c82565b5050505050505050565b607a546001600160a01b03163314610ed45760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21031b0b63632b960911b6044820152606401610b4f565b6071546001600160a01b031615610f4a576071546040516302c7739b60e01b81526001600160a01b03909116906302c7739b90610f179085908590600401615ba4565b600060405180830381600087803b158015610f3157600080fd5b505af1158015610f45573d6000803e3d6000fd5b505050505b5050565b6000610cfd83836127ec565b610f62612bbf565b6001600160a01b03909216600090815260826020908152604080832093909355608390522055565b606854604051633761c52760e11b81526001600160a01b0383811660048301526000921690636ec38a4e9060240160206040518083038186803b158015610fd057600080fd5b505afa158015610fe4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611008919061592a565b1561109c576000826001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b15801561104757600080fd5b505afa15801561105b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107f91906159f3565b50905042811061109a57606c546110964283615e0a565b1191505b505b919050565b6110a9612bbf565b606e80546001600160a01b038b81166001600160a01b03199283168117909355606780548c8316610100818102610100600160a81b031990931692909217909255606f80548d85169086168117909155607180548d86169087168117909155607880548d87169088168117909155607a80548d88169089168117909155608180548d8916908a168117909155608580548d8a16908b168117909155608a8054998d1699909a168917909955604080519a8b5260208b0197909752898701949094526060890192909252608088015260a087015260c086015260e085019390935291830152517fdcb493c60570bc553de543bccde79755ef6ea8eb71e9cd8a77fcbc84d24766f0918190036101200190a1505050505050505050565b6001606660008282546111d79190615dbf565b909155505060665460345460ff16156112025760405162461bcd60e51b8152600401610b4f90615c58565b6001600160a01b038216156112775760785460405163bbddaca360e01b81526001600160a01b0384811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b15801561125e57600080fd5b505af1158015611272573d6000803e3d6000fd5b505050505b610e5e8888888888886000612d24565b6001546001600160a01b031633146112ff5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610b4f565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6001606660008282546113979190615dbf565b909155505060665460345460ff16156113c25760405162461bcd60e51b8152600401610b4f90615c58565b6114296040518060e00160405280886001600160a01b031681526020018760028111156113ff57634e487b7160e01b600052602160045260246000fd5b81526020018681526020018581526020018481526020016001151581526020016000815250613136565b6066548114610f455760405162461bcd60e51b8152600401610b4f90615c82565b6060826001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561148557600080fd5b505afa158015611499573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114bd91906159b7565b67ffffffffffffffff8111156114e357634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561150c578160200160208202803683370190505b50905060005b815181101561158a5761154d8482600281111561153f57634e487b7160e01b600052602160045260246000fd5b670de0b6b3a7640000610cb3565b82828151811061156d57634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061158281615e4d565b915050611512565b5092915050565b60008061159d83613dc6565b90508084106115ac57836115ae565b805b9150505b92915050565b6001606660008282546115cb9190615dbf565b909155505060665460345460ff16156115f65760405162461bcd60e51b8152600401610b4f90615c58565b6001600160a01b0382161561166b5760785460405163bbddaca360e01b81526001600160a01b0384811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b15801561165257600080fd5b505af1158015611666573d6000803e3d6000fd5b505050505b6116d26040518060e00160405280896001600160a01b031681526020018860028111156116a857634e487b7160e01b600052602160045260246000fd5b81526020018781526020018681526020018581526020016001151581526020016000815250613136565b60665481146116f35760405162461bcd60e51b8152600401610b4f90615c82565b50505050505050565b60685460405163352feab360e11b81526001600160a01b0385811660048301526000921690636a5fd5669060240160206040518083038186803b15801561174257600080fd5b505afa158015611756573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177a919061592a565b156118315760008360028111156117a157634e487b7160e01b600052602160045260246000fd5b141561182c57607e5460405163d20f87cf60e01b81526001600160a01b039091169063d20f87cf906117d99087908690600401615ba4565b60206040518083038186803b1580156117f157600080fd5b505afa158015611805573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182991906159b7565b90505b610cfd565b600061183d8585612493565b9050600061184b8686613e4a565b905060008411801561185d5750818411155b156118725761186f8686868585613f0c565b92505b50509392505050565b60016066600082825461188e9190615dbf565b909155505060665460345460ff16156118b95760405162461bcd60e51b8152600401610b4f90615c58565b60685460405163e62b888960e01b81526001600160a01b0386811660048301529091169063e62b88899060240160206040518083038186803b1580156118fe57600080fd5b505afa158015611912573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611936919061592a565b6119735760405162461bcd60e51b815260206004820152600e60248201526d1d5b9adb9bdddb881b585c9ad95d60921b6044820152606401610b4f565b6000806000866001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b1580156119b157600080fd5b505afa1580156119c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e99190615946565b919450925090506001600160a01b038316611a2b5760405162461bcd60e51b8152602060048201526002602482015261304160f01b6044820152606401610b4f565b604051636392a51f60e01b8152336004820152600090819081906001600160a01b038b1690636392a51f9060240160606040518083038186803b158015611a7157600080fd5b505afa158015611a85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa99190615a16565b925092509250611abb33873086614012565b611ac733863085614012565b611ad333853084614012565b6067546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a082319060240160206040518083038186803b158015611b1c57600080fd5b505afa158015611b30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5491906159b7565b90508a6001600160a01b031663851492586040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611b9157600080fd5b505af1158015611ba5573d6000803e3d6000fd5b50506067546040516370a0823160e01b8152306004820152600093508492506101009091046001600160a01b0316906370a082319060240160206040518083038186803b158015611bf557600080fd5b505afa158015611c09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c2d91906159b7565b611c379190615e0a565b905060008115611dcc578a15611d3257608c5460405163b45e98d960e01b8152600481018490526001600160a01b039091169063b45e98d990602401602060405180830381600087803b158015611c8d57600080fd5b505af1158015611ca1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc591906159b7565b604051909150600090339083156108fc0290849084818181858888f19350505050905080611d2c5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610b4f565b50611dcc565b608c54604051630992646d60e31b81526001600160a01b0390911690634c93236890611d64908f908690600401615ba4565b602060405180830381600087803b158015611d7e57600080fd5b505af1158015611d92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db691906159b7565b9050611dcc6001600160a01b038d16338361402d565b7f2cec587f2a4c93b665548039853a2ceb9f413718b5e3f0549f283f51442d11cc338e8e8e8686604051611e3b969594939291906001600160a01b039687168152948616602086015292909416604084015215156060830152608082019290925260a081019190915260c00190565b60405180910390a15050505050505050506066548114611e6d5760405162461bcd60e51b8152600401610b4f90615c82565b50505050565b60008084118015611e85575060735484105b15610af457670de0b6b3a7640000606a54670de0b6b3a7640000611ea99190615dbf565b611eb39086615deb565b611ebd9190615dd7565b935081611fc557607e5460855460405163c2edfc7360e01b81526001600160a01b0389811660048301529283169263e468265c928a928a929091169063c2edfc739060240160206040518083038186803b158015611f1a57600080fd5b505afa158015611f2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5291906154a9565b6040518463ffffffff1660e01b8152600401611f7093929190615b74565b60206040518083038186803b158015611f8857600080fd5b505afa158015611f9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc091906159b7565b611fc7565b825b608a54606b54604051631b4e258760e01b815292955060009283926001600160a01b031691631b4e258791612000918c91600401615ba4565b604080518083038186803b15801561201757600080fd5b505afa15801561202b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061204f91906159f3565b607e546001600160a01b038b81166000908152606d60205260409081902054905163f947c6b360e01b8152600481018690526024810191909152604481018b9052606481018a905260848101849052939550919350169063f947c6b39060a40160206040518083038186803b1580156120c757600080fd5b505afa1580156120db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ff91906159b7565b98975050505050505050565b612113612bbf565b6001600160a01b03811661215b5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610b4f565b600154600160a81b900460ff16156121ab5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610b4f565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610c32565b600054610100900460ff1661223f5760005460ff1615612243565b303b155b6122a65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b4f565b600054610100900460ff161580156122c8576000805461ffff19166101011790555b6122d186610afd565b6122d96123e7565b60678054610100600160a81b0319166101006001600160a01b03881602179055606a849055606b839055606c8290558015610f45576000805461ff0019169055505050505050565b612329612bbf565b607e80546001600160a01b0319166001600160a01b0392909216919091179055565b600080612359868686610cb3565b608c5460405163441372ef60e11b81529192506001600160a01b031690638826e5de9061238c9086908590600401615ba4565b60206040518083038186803b1580156123a457600080fd5b505afa1580156123b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123dc91906159b7565b915094509492505050565b60675460ff16156124305760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610b4f565b6067805460ff19166001908117909155606655565b6001606660008282546124589190615dbf565b909155505060665460345460ff16156124835760405162461bcd60e51b8152600401610b4f90615c58565b6116d28787878787876000612d24565b600061249e83610f8a565b156115b25760006124af84846127ec565b9050801561158a576115ae8484836000806124c98a6129a8565b614088565b6124d6612bbf565b608c546001600160a01b03161561257757606754608c5460405163095ea7b360e01b81526001600160a01b0361010090930483169263095ea7b39261252392911690600090600401615ba4565b602060405180830381600087803b15801561253d57600080fd5b505af1158015612551573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612575919061592a565b505b608c80546001600160a01b038481166001600160a81b031990921691909117600160a01b841515021790915560675460405163095ea7b360e01b81526101009091049091169063095ea7b3906125d590859060001990600401615ba4565b602060405180830381600087803b1580156125ef57600080fd5b505af1158015612603573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612627919061592a565b50604080516001600160a01b038416815282151560208201527f7ed317979883517e462a7e4dbfde66a0b837cf91abff298bfa10d966a545298c910160405180910390a15050565b612677612bbf565b6001600160a01b038116156127115760675460405163095ea7b360e01b81526101009091046001600160a01b03169063095ea7b3906126bd908490600090600401615ba4565b602060405180830381600087803b1580156126d757600080fd5b505af11580156126eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061270f919061592a565b505b606880546001600160a01b0319166001600160a01b0383811691821790925560675460405163095ea7b360e01b81526101009091049092169163095ea7b3916127609160001990600401615ba4565b602060405180830381600087803b15801561277a57600080fd5b505af115801561278e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b2919061592a565b506040516001600160a01b03821681527f1f728ba0a73bcdf17f9e0f260b7db049043dfa6b907980f715e30767d36bc70690602001610c32565b60685460405163352feab360e11b81526001600160a01b0384811660048301526000921690636a5fd5669060240160206040518083038186803b15801561283257600080fd5b505afa158015612846573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061286a919061592a565b1561292657600082600281111561289157634e487b7160e01b600052602160045260246000fd5b141561292657607e546001600160a01b031663a119612d846128b281613dc6565b6040518363ffffffff1660e01b81526004016128cf929190615ba4565b60206040518083038186803b1580156128e757600080fd5b505afa1580156128fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061291f91906159b7565b90506115b2565b607e546040516350d851a160e01b81526001600160a01b03909116906350d851a1906129589086908690600401615b57565b60206040518083038186803b15801561297057600080fd5b505afa158015612984573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfd91906159b7565b6129d4604080516080810190915260008082526020820190815260200160008152600060209091015290565b60685460405163352feab360e11b81526001600160a01b03848116600483015290911690636a5fd5669060240160206040518083038186803b158015612a1957600080fd5b505afa158015612a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a51919061592a565b612a8157604080516080810190915260008082526020820190815260200160018152600060209091015292915050565b607e5460405163a4d682dd60e01b81526001600160a01b038481166004830152600092839283929091169063a4d682dd9060240160606040518083038186803b158015612acd57600080fd5b505afa158015612ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b059190615987565b9250925092506040518060800160405280600115158152602001846002811115612b3f57634e487b7160e01b600052602160045260246000fd5b8152602001836002811115612b6457634e487b7160e01b600052602160045260246000fd5b8152602001826001600160a01b03168152509350505050919050565b805160009015612b9f57612b988a8a8a898787614117565b9050612bb2565b612baf8a8a8a8a8a8a8a8a614250565b90505b9998505050505050505050565b6000546201000090046001600160a01b03163314612c375760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610b4f565b565b60345460ff16612c825760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b4f565b6034805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60345460ff1615612cef5760405162461bcd60e51b8152600401610b4f90615c58565b6034805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612caf3390565b600080612d338989898761234b565b9092509050612d4a85670de0b6b3a7640000615dbf565b86612d5d670de0b6b3a764000085615deb565b612d679190615dd7565b1115612daa5760405162461bcd60e51b8152602060048201526012602482015271536c69707061676520746f6f20686967682160701b6044820152606401610b4f565b60008315612f1757608c60009054906101000a90046001600160a01b03166001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b815260040160206040518083038186803b158015612e0057600080fd5b505afa158015612e14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e3891906154a9565b6001600160a01b0316856001600160a01b031614612e905760405162461bcd60e51b815260206004820152601560248201527415dc9bdb99c818dbdb1b185d195c985b081cd95b9d605a1b6044820152606401610b4f565b608c54604051631321b85d60e01b8152600481018590526001600160a01b0390911690631321b85d9085906024016020604051808303818588803b158015612ed757600080fd5b505af1158015612eeb573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612f1091906159b7565b905061303a565b612f2c6001600160a01b0386163330866143eb565b608c5460405163095ea7b360e01b81526001600160a01b038781169263095ea7b392612f6092909116908790600401615ba4565b602060405180830381600087803b158015612f7a57600080fd5b505af1158015612f8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fb2919061592a565b50608c546040516322ceb11360e21b81526001600160a01b0390911690638b3ac44c90612fe59088908790600401615ba4565b602060405180830381600087803b158015612fff57600080fd5b505af1158015613013573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061303791906159b7565b90505b8181101561308a5760405162461bcd60e51b815260206004820152601860248201527f4e6f7420656e6f756768207355534420726563656976656400000000000000006044820152606401610b4f565b818111156130c457606e546130c4906001600160a01b03166130ac8484615e0a565b60675461010090046001600160a01b0316919061402d565b61312a6040518060e001604052808c6001600160a01b031681526020018b600281111561310157634e487b7160e01b600052602160045260246000fd5b81526020018a815260200184815260200188815260200160001515815260200184815250613136565b50505050505050505050565b61314881600001518260200151614423565b600061315782600001516129a8565b8051909150158061318b575060008260200151600281111561318957634e487b7160e01b600052602160045260246000fd5b145b6131c55760405162461bcd60e51b815260206004820152600b60248201526a496e76616c696420706f7360a81b6044820152606401610b4f565b60006131d9836000015184602001516127ec565b90506000811161321a5760405162461bcd60e51b815260206004820152600c60248201526b4e6f2062617365206f64647360a01b6044820152606401610b4f565b613228818460000151611591565b607e548451602086015160855460405163c2edfc7360e01b81526001600160a01b0380851660048301529596506000959485169463e468265c949392169063c2edfc739060240160206040518083038186803b15801561328757600080fd5b505afa15801561329b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132bf91906154a9565b6040518463ffffffff1660e01b81526004016132dd93929190615b74565b60206040518083038186803b1580156132f557600080fd5b505afa158015613309573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061332d91906159b7565b90506000613348856000015186602001518585600189614088565b905067016345785d8a00008560400151118015613369575080856040015111155b6133aa5760405162461bcd60e51b815260206004820152601260248201527104c6f77206c6971756964697479207c7c20360741b6044820152606401610b4f565b8460a0015115613481576133db856000015186602001518760400151866133d033614537565b86600160008c612b80565b60c086015260808501516133f790670de0b6b3a7640000615dbf565b8560600151670de0b6b3a76400008760c001516134149190615deb565b61341e9190615dd7565b111561345c5760405162461bcd60e51b815260206004820152600d60248201526c4869676820736c69707061676560981b6044820152606401610b4f565b60c0850151606754613481916101009091046001600160a01b031690339030906143eb565b835160009080613501575085600001516001600160a01b03166311f2d4946040518163ffffffff1660e01b815260040160206040518083038186803b1580156134c957600080fd5b505afa1580156134dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613501919061592a565b61350c578551613581565b85600001516001600160a01b031663d03ecc646040518163ffffffff1660e01b815260040160206040518083038186803b15801561354957600080fd5b505afa15801561355d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061358191906154a9565b8551909150156136ee578551604080880151905163140e25ad60e31b81526001600160a01b039092169163a0712d68916135c19160040190815260200190565b600060405180830381600087803b1580156135db57600080fd5b505af11580156135ef573d6000803e3d6000fd5b505050506136068660000151876040015187614590565b607e5486516040516318dc4baf60e11b81526001600160a01b039182166004820152600092839216906331b8975e90602401604080518083038186803b15801561364f57600080fd5b505afa158015613663573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061368791906154c5565b9150915061369e8860400151838a60000151614824565b6136b18860400151828a60000151614824565b875160408901516136cc916001600160a01b0385169161402d565b875160408901516136e7916001600160a01b0384169161402d565b50506138b7565b600086604001518410613702576000613712565b8387604001516137129190615e0a565b90508015613838576085548751604051630163027360e61b81526001600160a01b03909216916358c09cc09161374c918590600401615ba4565b600060405180830381600087803b15801561376657600080fd5b505af115801561377a573d6000803e3d6000fd5b5050885160405163140e25ad60e31b8152600481018590526001600160a01b03909116925063a0712d689150602401600060405180830381600087803b1580156137c357600080fd5b505af11580156137d7573d6000803e3d6000fd5b505088516001600160a01b03166000908152606d602052604081208054859450909250613805908490615dbf565b90915550506001600160a01b0382166000908152608b602052604081208054839290613832908490615dbf565b90915550505b608554875160408901516001600160a01b039092169163828fce889190613860908590615e0a565b8a602001516040518463ffffffff1660e01b815260040161388393929190615bbd565b600060405180830381600087803b15801561389d57600080fd5b505af11580156138b1573d6000803e3d6000fd5b50505050505b600080600088600001516001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b1580156138f957600080fd5b505afa15801561390d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139319190615946565b919450925090506000808a60200151600281111561395f57634e487b7160e01b600052602160045260246000fd5b1461399b5760018a60200151600281111561398a57634e487b7160e01b600052602160045260246000fd5b14613995578161399d565b8261399d565b835b90506139c1338b60400151836001600160a01b031661402d9092919063ffffffff16565b88511580156139d257506000608054115b80156139f357506080548a60c001518b604001516139f09190615e0a565b10155b15613bcc5760008a6000015190506000816001600160a01b03166311f2d4946040518163ffffffff1660e01b815260040160206040518083038186803b158015613a3c57600080fd5b505afa158015613a50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a74919061592a565b613a7f576000613af7565b6040516308208aaf60e21b8152600160048201526001600160a01b038316906320822abc9060240160206040518083038186803b158015613abf57600080fd5b505afa158015613ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613af791906159b7565b905061271a811415613b68576081548c516040516375c1f9a560e11b81526001600160a01b03918216600482015291169063eb83f34a90602401600060405180830381600087803b158015613b4b57600080fd5b505af1158015613b5f573d6000803e3d6000fd5b50505050613bc9565b6081548c5160405163029a39cd60e01b81526001600160a01b03918216600482015291169063029a39cd90602401600060405180830381600087803b158015613bb057600080fd5b505af1158015613bc4573d6000803e3d6000fd5b505050505b50505b8851613beb90613bdd578a51613bdf565b855b868c60c00151336149ac565b608a546001600160a01b038681166000818152608b60205260409081902054905163ba0ed4ed60e01b81526004810191909152602481019190915291169063ba0ed4ed9060440160206040518083038186803b158015613c4a57600080fd5b505afa158015613c5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c82919061592a565b613cc15760405162461bcd60e51b815260206004820152601060248201526f5269736b20697320746f20686967682160801b6044820152606401610b4f565b8851613cd890613cd2578a51614d30565b85614d30565b6071546001600160a01b031615613d525760715460c08b01516040516302c7739b60e01b81526001600160a01b03909216916302c7739b91613d1f91339190600401615ba4565b600060405180830381600087803b158015613d3957600080fd5b505af1158015613d4d573d6000803e3d6000fd5b505050505b7ff3bfbc0822d1ed667a2b298e71e0304f2c1f4685398189d7c39e412f733150f4338b600001518c602001518d604001518e60c00151606760019054906101000a90046001600160a01b031687604051613db29796959493929190615b07565b60405180910390a150505050505050505050565b608a5460725460405163bf7ff78b60e01b81526000926001600160a01b03169163bf7ff78b91613dfa918691600401615ba4565b60206040518083038186803b158015613e1257600080fd5b505afa158015613e26573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b291906159b7565b6000806003836002811115613e6f57634e487b7160e01b600052602160045260246000fd5b613e7a906001615dbf565b613e849190615e68565b6002811115613ea357634e487b7160e01b600052602160045260246000fd5b905060006003846002811115613ec957634e487b7160e01b600052602160045260246000fd5b613ed4906002615dbf565b613ede9190615e68565b6002811115613efd57634e487b7160e01b600052602160045260246000fd5b9050610af48583836000614f9c565b607e546040805161010081019091526001600160a01b0387811682526000921690630381cd099060208101886002811115613f5757634e487b7160e01b600052602160045260246000fd5b81526020810188905260408101879052606081018690526085546001600160a01b0316608082015260a001613f8b8a615212565b8152602001613f998a613dc6565b8152506040518263ffffffff1660e01b8152600401613fb89190615d51565b60206040518083038186803b158015613fd057600080fd5b505afa158015613fe4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061400891906159b7565b9695505050505050565b8015611e6d57611e6d6001600160a01b0384168584846143eb565b6140838363a9059cbb60e01b848460405160240161404c929190615ba4565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152615246565b505050565b8051600090156140f35760008660028111156140b457634e487b7160e01b600052602160045260246000fd5b1480156140cd57506000851180156140cd575060735485105b156140ee576140eb8260600151836020015184604001516001614f9c565b90505b614008565b6140fd8588611591565b945061410c8787878787611e73565b979650505050505050565b60008086600281111561413a57634e487b7160e01b600052602160045260246000fd5b141561400857607e5460009081906001600160a01b0316634ab96c838a61416081613dc6565b6040518363ffffffff1660e01b815260040161417d929190615ba4565b604080518083038186803b15801561419457600080fd5b505afa1580156141a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141cc91906159f3565b915091506000821180156141e05750600081115b15614244576000614200856060015186602001518a868b6000808d614250565b9050600061421d866060015187604001518b868c6000808e614250565b905060008211801561422f5750600081115b156142415761423e8183615dbf565b94505b50505b50509695505050505050565b60008261426857614265898988600080611e73565b93505b8387116120ff57600061427b8a8a613e4a565b9050600061428c8b8b8b8986613f0c565b9050670de0b6b3a76400006142a1858d615318565b6142b390670de0b6b3a7640000615dbf565b6142bd908a615deb565b6142c79190615dd7565b607e54604051632b4b76a960e21b81526004810184905260248101839052604481018a9052606481018c90529199506000916001600160a01b039091169063ad2ddaa49060840160206040518083038186803b15801561432657600080fd5b505afa15801561433a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061435e91906159b7565b60685460405163edc892e160e01b8152600481018390529192506001600160a01b03169063edc892e19060240160206040518083038186803b1580156143a357600080fd5b505afa1580156143b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143db91906159b7565b9c9b505050505050505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611e6d9085906323b872dd60e01b9060840161404c565b61442c82610f8a565b6144665760405162461bcd60e51b815260206004820152600b60248201526a4e6f742074726164696e6760a81b6044820152606401610b4f565b6000826001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156144a157600080fd5b505afa1580156144b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144d991906159b7565b90508160028111156144fb57634e487b7160e01b600052602160045260246000fd5b81116140835760405162461bcd60e51b815260206004820152600b60248201526a496e76616c696420706f7360a81b6044820152606401610b4f565b607a546000906001600160a01b0383811691161461109c576001600160a01b038216600090815260826020526040902054614574576070546115b2565b506001600160a01b031660009081526082602052604090205490565b607e54606082015160855460405163c2edfc7360e01b81526001600160a01b03878116600483015260009485949082169363755cc89c939192169063c2edfc739060240160206040518083038186803b1580156145ec57600080fd5b505afa158015614600573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061462491906154a9565b866020015187604001516040518563ffffffff1660e01b815260040161464d9493929190615ad5565b604080518083038186803b15801561466457600080fd5b505afa158015614678573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061469c91906159f3565b9150915060008483106146b05760006146ba565b6146ba8386615e0a565b905060008583106146cc5760006146d6565b6146d68387615e0a565b905060008183106146e757826146e9565b815b90508015610e7f576085546060870151604051630163027360e61b81526001600160a01b03909216916358c09cc091614726918590600401615ba4565b600060405180830381600087803b15801561474057600080fd5b505af1158015614754573d6000803e3d6000fd5b505050606087015160405163140e25ad60e31b8152600481018490526001600160a01b03909116915063a0712d6890602401600060405180830381600087803b1580156147a057600080fd5b505af11580156147b4573d6000803e3d6000fd5b5050505060608601516001600160a01b03166000908152606d6020526040812080548392906147e4908490615dbf565b909155505060608601516001600160a01b03166000908152608b602052604081208054839290614815908490615dbf565b90915550505050505050505050565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a082319060240160206040518083038186803b15801561486657600080fd5b505afa15801561487a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061489e91906159b7565b905080841115611e6d57608560009054906101000a90046001600160a01b03166001600160a01b03166352129e48836001600160a01b031663d03ecc646040518163ffffffff1660e01b815260040160206040518083038186803b15801561490557600080fd5b505afa158015614919573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061493d91906154a9565b6149478488615e0a565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015260248101919091529086166044820152606401600060405180830381600087803b15801561499857600080fd5b505af1158015610e7f573d6000803e3d6000fd5b607854604051630293b59d60e31b81526001600160a01b038381166004830152600092169063149dace89060240160206040518083038186803b1580156149f257600080fd5b505afa158015614a06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a2a91906154a9565b905060006001600160a01b03821615614b525760785460405163c7d1f5f160e01b81526001600160a01b038481166004830152600092169063c7d1f5f19060240160206040518083038186803b158015614a8357600080fd5b505afa158015614a97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614abb91906159b7565b90508015614b5057670de0b6b3a7640000614ad68287615deb565b614ae09190615dd7565b606754909250614aff9061010090046001600160a01b0316848461402d565b604080516001600160a01b0385168152336020820152908101839052606081018690527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a15b505b600080614b5e85614537565b90508015614bbb57614b7881670de0b6b3a7640000615dbf565b614b8a670de0b6b3a764000088615deb565b614b949190615dd7565b614b9e9087615e0a565b606e54909250614bbb906001600160a01b03166130ac8585615e0a565b6068546000906001600160a01b03166317fd849a614bd9858a615e0a565b6040518263ffffffff1660e01b8152600401614bf791815260200190565b60206040518083038186803b158015614c0f57600080fd5b505afa158015614c23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c4791906159b7565b6001600160a01b038a166000908152606d6020526040902054909150811015614c9d576001600160a01b0389166000908152606d602052604081208054839290614c92908490615e0a565b925050819055614ca0565b60005b6001600160a01b03808b166000908152606d6020908152604080832094909455918b168152608b9091522054811015614d06576001600160a01b0388166000908152608b602052604081208054839290614cfb908490615e0a565b925050819055614d09565b60005b6001600160a01b039098166000908152608b60205260409020979097555050505050505050565b60855460405163f475f13b60e01b81526001600160a01b038381166004830152600092169063f475f13b90602401602060405180830381600087803b158015614d7857600080fd5b505af1158015614d8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614db091906154a9565b6067546040516370a0823160e01b8152306004820152919250614e3f916101009091046001600160a01b031690839082906370a082319060240160206040518083038186803b158015614e0257600080fd5b505afa158015614e16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e3a91906159b7565b615378565b6000806000846001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b158015614e7d57600080fd5b505afa158015614e91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614eb59190615946565b919450925090506001600160a01b038316614ef75760405162461bcd60e51b8152602060048201526002602482015261304160f01b6044820152606401610b4f565b604051636392a51f60e01b8152306004820152600090819081906001600160a01b03891690636392a51f9060240160606040518083038186803b158015614f3d57600080fd5b505afa158015614f51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f759190615a16565b925092509250614f86868885615378565b614f91858884615378565b610e7f848883615378565b608a54606b5460725460405163108a442b60e01b81526001600160a01b03888116600483015260248201939093526044810191909152600092839283928392919091169063108a442b9060640160606040518083038186803b15801561500157600080fd5b505afa158015615015573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906150399190615a16565b925092509250607e60009054906101000a90046001600160a01b03166001600160a01b03166311ecf33e6040518061012001604052808b6001600160a01b031681526020018a600281111561509e57634e487b7160e01b600052602160045260246000fd5b81526020018960028111156150c357634e487b7160e01b600052602160045260246000fd5b815288151560208201526085546040805163c2edfc7360e01b81526001600160a01b038f81166004830152919093019291169063c2edfc739060240160206040518083038186803b15801561511757600080fd5b505afa15801561512b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061514f91906154a9565b6001600160a01b03168152602001848152602001868152602001858152602001606d60008d6001600160a01b03166001600160a01b03168152602001908152602001600020548152506040518263ffffffff1660e01b81526004016151b49190615cb9565b60206040518083038186803b1580156151cc57600080fd5b505afa1580156151e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061520491906159b7565b93505050505b949350505050565b608a54606b5460405163085bbf5560e21b81526000926001600160a01b03169163216efd5491613dfa918691600401615ba4565b600061529b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166153929092919063ffffffff16565b80519091501561408357808060200190518101906152b9919061592a565b6140835760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b4f565b608a54606a5433600090815260836020526040808220549051630aca6ecb60e21b815286151560048201526001600160a01b0386811660248301526044820194909452606481019190915290929190911690632b29bb2c90608401612958565b8015614083576140836001600160a01b038416838361402d565b606061520a848460008585843b6153eb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b4f565b600080866001600160a01b031685876040516154079190615ab9565b60006040518083038185875af1925050503d8060008114615444576040519150601f19603f3d011682016040523d82523d6000602084013e615449565b606091505b509150915061410c82828660608315615463575081610cfd565b8251156154735782518084602001fd5b8160405162461bcd60e51b8152600401610b4f9190615c25565b60006020828403121561549e578081fd5b81356115ac81615ea8565b6000602082840312156154ba578081fd5b81516115ac81615ea8565b600080604083850312156154d7578081fd5b82516154e281615ea8565b60208401519092506154f381615ea8565b809150509250929050565b600080600060608486031215615512578081fd5b833561551d81615ea8565b9250602084013561552d81615ea8565b9150604084013561553d81615ebd565b809150509250925092565b6000806040838503121561555a578182fd5b823561556581615ea8565b915060208301356154f381615ebd565b60008060008060008060008060006101208a8c031215615593578485fd5b893561559e81615ea8565b985060208a01356155ae81615ea8565b975060408a01356155be81615ea8565b965060608a01356155ce81615ea8565b955060808a01356155de81615ea8565b945060a08a01356155ee81615ea8565b935060c08a01356155fe81615ea8565b925060e08a013561560e81615ea8565b91506101008a013561561f81615ea8565b809150509295985092959850929598565b600080600080600060a08688031215615647578081fd5b853561565281615ea8565b9450602086013561566281615ea8565b94979496505050506040830135926060810135926080909101359150565b60008060408385031215615692578182fd5b823561569d81615ea8565b915060208301356154f381615ecb565b6000806000606084860312156156c1578283fd5b83356156cc81615ea8565b925060208401356156dc81615ecb565b929592945050506040919091013590565b60008060008060808587031215615702578182fd5b843561570d81615ea8565b9350602085013561571d81615ecb565b925060408501359150606085013561573481615ea8565b939692955090935050565b600080600080600060a08688031215615756578283fd5b853561576181615ea8565b9450602086013561577181615ecb565b93506040860135925060608601359150608086013561578f81615ebd565b809150509295509295909350565b600080600080600060a086880312156157b4578283fd5b85356157bf81615ea8565b9450602086013561566281615ecb565b60008060008060008060c087890312156157e7578384fd5b86356157f281615ea8565b9550602087013561580281615ecb565b945060408701359350606087013592506080870135915060a087013561582781615ea8565b809150509295509295509295565b600080600080600080600060e0888a03121561584f578081fd5b873561585a81615ea8565b9650602088013561586a81615ecb565b955060408801359450606088013593506080880135925060a088013561588f81615ea8565b915060c088013561589f81615ea8565b8091505092959891949750929550565b600080604083850312156158c1578182fd5b82356158cc81615ea8565b946020939093013593505050565b6000806000606084860312156158ee578081fd5b83356158f981615ea8565b95602085013595506040909401359392505050565b60006020828403121561591f578081fd5b81356115ac81615ebd565b60006020828403121561593b578081fd5b81516115ac81615ebd565b60008060006060848603121561595a578081fd5b835161596581615ea8565b602085015190935061597681615ea8565b604085015190925061553d81615ea8565b60008060006060848603121561599b578081fd5b83516159a681615ecb565b602085015190935061597681615ecb565b6000602082840312156159c8578081fd5b5051919050565b600080604083850312156159e1578182fd5b8235915060208301356154f381615ea8565b60008060408385031215615a05578182fd5b505080516020909101519092909150565b600080600060608486031215615a2a578081fd5b8351925060208401519150604084015190509250925092565b600080600080600080600080610100898b031215615a5f578182fd5b505086359860208801359850604088013597606081013597506080810135965060a0810135955060c0810135945060e0013592509050565b60038110615ab557634e487b7160e01b600052602160045260246000fd5b9052565b60008251615acb818460208701615e21565b9190910192915050565b6001600160a01b0385811682528416602082015260808101615afa6040830185615a97565b610af46060830184615a97565b6001600160a01b038881168252878116602083015260e0820190615b2e6040840189615a97565b86606084015285608084015280851660a084015280841660c08401525098975050505050505050565b6001600160a01b038316815260408101610cfd6020830184615a97565b6001600160a01b0384811682526060820190615b936020840186615a97565b808416604084015250949350505050565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0384168152602081018390526060810161520a6040830184615a97565b6020808252825182820181905260009190848201906040850190845b81811015615c1957835183529284019291840191600101615bfd565b50909695505050505050565b6020815260008251806020840152615c44816040850160208701615e21565b601f01601f19169190910160400192915050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b81516001600160a01b03168152602080830151610120830191615cde90840182615a97565b506040830151615cf16040840182615a97565b506060830151615d05606084018215159052565b506080830151615d2060808401826001600160a01b03169052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525092915050565b81516001600160a01b03908116825260208084015161010084019291615d7990850182615a97565b506040840151604084015260608401516060840152608084015160808401528060a08501511660a08401525060c083015160c083015260e083015160e083015292915050565b60008219821115615dd257615dd2615e7c565b500190565b600082615de657615de6615e92565b500490565b6000816000190483118215151615615e0557615e05615e7c565b500290565b600082821015615e1c57615e1c615e7c565b500390565b60005b83811015615e3c578181015183820152602001615e24565b83811115611e6d5750506000910152565b6000600019821415615e6157615e61615e7c565b5060010190565b600082615e7757615e77615e92565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6001600160a01b0381168114610ca857600080fd5b8015158114610ca857600080fd5b60038110610ca857600080fdfea2646970667358221220826d769b935c11a80516194a610c724ffc0ec84c11dbf5ba1754664f3b7958f764736f6c63430008040033
Deployed Bytecode
0x60806040526004361061037a5760003560e01c80638875eb84116101d1578063c23ca72311610102578063df8974d0116100a0578063efc152511161006f578063efc1525114610a3d578063f8291d2b14610a5d578063f88b757114610a7d578063fd8a8cc614610a9d57600080fd5b8063df8974d0146109dc578063e88698bf146109f2578063ebc7977214610a08578063ec933f8314610a1d57600080fd5b8063d333ca19116100dc578063d333ca1914610951578063d3dc753914610971578063d4a2641b14610991578063d69fb668146109c657600080fd5b8063c23ca723146108f1578063c3b83f5f14610911578063d13f90b41461093157600080fd5b80639a618c0f1161016f578063b24ef63811610149578063b24ef63814610871578063bb96af6514610891578063bf46c0b4146108b1578063c062ef87146108d157600080fd5b80639a618c0f146108115780639f916c9f14610831578063ac210cc71461085157600080fd5b80638da5cb5b116101ab5780638da5cb5b146107855780639324cac7146107ab57806393baafd5146107d057806399c18e7e146107f057600080fd5b80638875eb841461070b5780638a7c84e51461072b5780638afdf2d81461075857600080fd5b806348663e95116102ab57806366272044116102495780636cc5a6ff116102235780636cc5a6ff146106a057806379ba5097146106c05780637b4626bd146106d55780637d550e05146106eb57600080fd5b8063662720441461064a578063665a11ca1461066a5780636aaa81b61461068a57600080fd5b806353a47bb71161028557806353a47bb7146105b55780635727a0f3146105d55780635c975abb1461060557806365f567721461061d57600080fd5b806348663e951461055557806350d851a1146105755780635266d4881461059557600080fd5b8063316425c311610318578063424f073b116102f2578063424f073b146104ca578063443a4077146104dd57806347842663146104fd578063481c6a751461053557600080fd5b8063316425c31461047e578063343d372f1461049457806334ba3c71146104aa57600080fd5b80631627540c116103545780631627540c146103f157806316c38b3c14610411578063270e13ef146104315780632972e8ab1461045157600080fd5b806309b03964146103865780630fabf206146103b957806313af4035146103cf57600080fd5b3661038157005b600080fd5b34801561039257600080fd5b506103a66103a13660046156ad565b610abd565b6040519081526020015b60405180910390f35b3480156103c557600080fd5b506103a660805481565b3480156103db57600080fd5b506103ef6103ea36600461548d565b610afd565b005b3480156103fd57600080fd5b506103ef61040c36600461548d565b610c3d565b34801561041d57600080fd5b506103ef61042c36600461590e565b610c93565b34801561043d57600080fd5b506103a661044c3660046156ad565b610cb3565b34801561045d57600080fd5b506103a661046c36600461548d565b60836020526000908152604090205481565b34801561048a57600080fd5b506103a6606b5481565b3480156104a057600080fd5b506103a661271a81565b3480156104b657600080fd5b506103ef6104c5366004615a43565b610d04565b6103ef6104d8366004615835565b610d9b565b3480156104e957600080fd5b506103ef6104f83660046158af565b610e89565b34801561050957600080fd5b50608a5461051d906001600160a01b031681565b6040516001600160a01b0390911681526020016103b0565b34801561054157600080fd5b5060685461051d906001600160a01b031681565b34801561056157600080fd5b50606e5461051d906001600160a01b031681565b34801561058157600080fd5b506103a6610590366004615680565b610f4e565b3480156105a157600080fd5b506103ef6105b03660046158da565b610f5a565b3480156105c157600080fd5b5060015461051d906001600160a01b031681565b3480156105e157600080fd5b506105f56105f036600461548d565b610f8a565b60405190151581526020016103b0565b34801561061157600080fd5b5060345460ff166105f5565b34801561062957600080fd5b506103a661063836600461548d565b60826020526000908152604090205481565b34801561065657600080fd5b506103ef610665366004615575565b6110a1565b34801561067657600080fd5b5060855461051d906001600160a01b031681565b34801561069657600080fd5b506103a6606a5481565b3480156106ac57600080fd5b506103ef6106bb366004615835565b6111c4565b3480156106cc57600080fd5b506103ef611287565b3480156106e157600080fd5b506103a660725481565b3480156106f757600080fd5b50607a5461051d906001600160a01b031681565b34801561071757600080fd5b506103ef61072636600461579d565b611384565b34801561073757600080fd5b506103a661074636600461548d565b606d6020526000908152604090205481565b34801561076457600080fd5b50610778610773366004615548565b61144a565b6040516103b09190615be1565b34801561079157600080fd5b5060005461051d906201000090046001600160a01b031681565b3480156107b757600080fd5b5060675461051d9061010090046001600160a01b031681565b3480156107dc57600080fd5b506103a66107eb3660046159cf565b611591565b3480156107fc57600080fd5b50608c546105f590600160a01b900460ff1681565b34801561081d57600080fd5b50608c5461051d906001600160a01b031681565b34801561083d57600080fd5b506103ef61084c3660046157cf565b6115b8565b34801561085d57600080fd5b5060815461051d906001600160a01b031681565b34801561087d57600080fd5b50607e5461051d906001600160a01b031681565b34801561089d57600080fd5b50606f5461051d906001600160a01b031681565b3480156108bd57600080fd5b506103a66108cc3660046156ad565b6116fc565b3480156108dd57600080fd5b506103ef6108ec3660046154fe565b61187b565b3480156108fd57600080fd5b506103a661090c36600461573f565b611e73565b34801561091d57600080fd5b506103ef61092c36600461548d565b61210b565b34801561093d57600080fd5b506103ef61094c366004615630565b612224565b34801561095d57600080fd5b506103ef61096c36600461548d565b612321565b34801561097d57600080fd5b5060785461051d906001600160a01b031681565b34801561099d57600080fd5b506109b16109ac3660046156ed565b61234b565b604080519283526020830191909152016103b0565b3480156109d257600080fd5b506103a660705481565b3480156109e857600080fd5b506103a6606c5481565b3480156109fe57600080fd5b506103a660735481565b348015610a1457600080fd5b506103ef6123e7565b348015610a2957600080fd5b506103ef610a383660046157cf565b612445565b348015610a4957600080fd5b506103a6610a58366004615680565b612493565b348015610a6957600080fd5b506103ef610a78366004615548565b6124ce565b348015610a8957600080fd5b506103ef610a9836600461548d565b61266f565b348015610aa957600080fd5b5060715461051d906001600160a01b031681565b600080610aca85856127ec565b9050610ad68186611591565b9050610af48585858460008060006001610aef8e6129a8565b612b80565b95945050505050565b6001600160a01b038116610b585760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff1615610bc45760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610b4f565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b610c45612bbf565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610c32565b610c9b612bbf565b80610cab57610ca8612c39565b50565b610ca8612ccc565b6000610cbe84610f8a565b15610cfd576000610ccf85856127ec565b90508015610cfb57610ce18186611591565b9050610af4858585846070546000806001610aef8e6129a8565b505b9392505050565b610d0c612bbf565b606c889055606a879055606b8690556072859055607384905560708390556080818155604080518a8152602081018a90528082018990526060810188905291820186905260a0820185905260c0820184905260e08201839052517f3a2276994eb7c279297bcbc22f9e4dda9af91c054220b647ffa9dd9a72d46d62918190036101000190a15050505050505050565b600160666000828254610dae9190615dbf565b909155505060665460345460ff1615610dd95760405162461bcd60e51b8152600401610b4f90615c58565b6001600160a01b03821615610e4e5760785460405163bbddaca360e01b81526001600160a01b0384811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b158015610e3557600080fd5b505af1158015610e49573d6000803e3d6000fd5b505050505b610e5e8888888888886001612d24565b6066548114610e7f5760405162461bcd60e51b8152600401610b4f90615c82565b5050505050505050565b607a546001600160a01b03163314610ed45760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21031b0b63632b960911b6044820152606401610b4f565b6071546001600160a01b031615610f4a576071546040516302c7739b60e01b81526001600160a01b03909116906302c7739b90610f179085908590600401615ba4565b600060405180830381600087803b158015610f3157600080fd5b505af1158015610f45573d6000803e3d6000fd5b505050505b5050565b6000610cfd83836127ec565b610f62612bbf565b6001600160a01b03909216600090815260826020908152604080832093909355608390522055565b606854604051633761c52760e11b81526001600160a01b0383811660048301526000921690636ec38a4e9060240160206040518083038186803b158015610fd057600080fd5b505afa158015610fe4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611008919061592a565b1561109c576000826001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b15801561104757600080fd5b505afa15801561105b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107f91906159f3565b50905042811061109a57606c546110964283615e0a565b1191505b505b919050565b6110a9612bbf565b606e80546001600160a01b038b81166001600160a01b03199283168117909355606780548c8316610100818102610100600160a81b031990931692909217909255606f80548d85169086168117909155607180548d86169087168117909155607880548d87169088168117909155607a80548d88169089168117909155608180548d8916908a168117909155608580548d8a16908b168117909155608a8054998d1699909a168917909955604080519a8b5260208b0197909752898701949094526060890192909252608088015260a087015260c086015260e085019390935291830152517fdcb493c60570bc553de543bccde79755ef6ea8eb71e9cd8a77fcbc84d24766f0918190036101200190a1505050505050505050565b6001606660008282546111d79190615dbf565b909155505060665460345460ff16156112025760405162461bcd60e51b8152600401610b4f90615c58565b6001600160a01b038216156112775760785460405163bbddaca360e01b81526001600160a01b0384811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b15801561125e57600080fd5b505af1158015611272573d6000803e3d6000fd5b505050505b610e5e8888888888886000612d24565b6001546001600160a01b031633146112ff5760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610b4f565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6001606660008282546113979190615dbf565b909155505060665460345460ff16156113c25760405162461bcd60e51b8152600401610b4f90615c58565b6114296040518060e00160405280886001600160a01b031681526020018760028111156113ff57634e487b7160e01b600052602160045260246000fd5b81526020018681526020018581526020018481526020016001151581526020016000815250613136565b6066548114610f455760405162461bcd60e51b8152600401610b4f90615c82565b6060826001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561148557600080fd5b505afa158015611499573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114bd91906159b7565b67ffffffffffffffff8111156114e357634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561150c578160200160208202803683370190505b50905060005b815181101561158a5761154d8482600281111561153f57634e487b7160e01b600052602160045260246000fd5b670de0b6b3a7640000610cb3565b82828151811061156d57634e487b7160e01b600052603260045260246000fd5b60209081029190910101528061158281615e4d565b915050611512565b5092915050565b60008061159d83613dc6565b90508084106115ac57836115ae565b805b9150505b92915050565b6001606660008282546115cb9190615dbf565b909155505060665460345460ff16156115f65760405162461bcd60e51b8152600401610b4f90615c58565b6001600160a01b0382161561166b5760785460405163bbddaca360e01b81526001600160a01b0384811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b15801561165257600080fd5b505af1158015611666573d6000803e3d6000fd5b505050505b6116d26040518060e00160405280896001600160a01b031681526020018860028111156116a857634e487b7160e01b600052602160045260246000fd5b81526020018781526020018681526020018581526020016001151581526020016000815250613136565b60665481146116f35760405162461bcd60e51b8152600401610b4f90615c82565b50505050505050565b60685460405163352feab360e11b81526001600160a01b0385811660048301526000921690636a5fd5669060240160206040518083038186803b15801561174257600080fd5b505afa158015611756573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177a919061592a565b156118315760008360028111156117a157634e487b7160e01b600052602160045260246000fd5b141561182c57607e5460405163d20f87cf60e01b81526001600160a01b039091169063d20f87cf906117d99087908690600401615ba4565b60206040518083038186803b1580156117f157600080fd5b505afa158015611805573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182991906159b7565b90505b610cfd565b600061183d8585612493565b9050600061184b8686613e4a565b905060008411801561185d5750818411155b156118725761186f8686868585613f0c565b92505b50509392505050565b60016066600082825461188e9190615dbf565b909155505060665460345460ff16156118b95760405162461bcd60e51b8152600401610b4f90615c58565b60685460405163e62b888960e01b81526001600160a01b0386811660048301529091169063e62b88899060240160206040518083038186803b1580156118fe57600080fd5b505afa158015611912573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611936919061592a565b6119735760405162461bcd60e51b815260206004820152600e60248201526d1d5b9adb9bdddb881b585c9ad95d60921b6044820152606401610b4f565b6000806000866001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b1580156119b157600080fd5b505afa1580156119c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e99190615946565b919450925090506001600160a01b038316611a2b5760405162461bcd60e51b8152602060048201526002602482015261304160f01b6044820152606401610b4f565b604051636392a51f60e01b8152336004820152600090819081906001600160a01b038b1690636392a51f9060240160606040518083038186803b158015611a7157600080fd5b505afa158015611a85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aa99190615a16565b925092509250611abb33873086614012565b611ac733863085614012565b611ad333853084614012565b6067546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a082319060240160206040518083038186803b158015611b1c57600080fd5b505afa158015611b30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5491906159b7565b90508a6001600160a01b031663851492586040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611b9157600080fd5b505af1158015611ba5573d6000803e3d6000fd5b50506067546040516370a0823160e01b8152306004820152600093508492506101009091046001600160a01b0316906370a082319060240160206040518083038186803b158015611bf557600080fd5b505afa158015611c09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c2d91906159b7565b611c379190615e0a565b905060008115611dcc578a15611d3257608c5460405163b45e98d960e01b8152600481018490526001600160a01b039091169063b45e98d990602401602060405180830381600087803b158015611c8d57600080fd5b505af1158015611ca1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc591906159b7565b604051909150600090339083156108fc0290849084818181858888f19350505050905080611d2c5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610b4f565b50611dcc565b608c54604051630992646d60e31b81526001600160a01b0390911690634c93236890611d64908f908690600401615ba4565b602060405180830381600087803b158015611d7e57600080fd5b505af1158015611d92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611db691906159b7565b9050611dcc6001600160a01b038d16338361402d565b7f2cec587f2a4c93b665548039853a2ceb9f413718b5e3f0549f283f51442d11cc338e8e8e8686604051611e3b969594939291906001600160a01b039687168152948616602086015292909416604084015215156060830152608082019290925260a081019190915260c00190565b60405180910390a15050505050505050506066548114611e6d5760405162461bcd60e51b8152600401610b4f90615c82565b50505050565b60008084118015611e85575060735484105b15610af457670de0b6b3a7640000606a54670de0b6b3a7640000611ea99190615dbf565b611eb39086615deb565b611ebd9190615dd7565b935081611fc557607e5460855460405163c2edfc7360e01b81526001600160a01b0389811660048301529283169263e468265c928a928a929091169063c2edfc739060240160206040518083038186803b158015611f1a57600080fd5b505afa158015611f2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f5291906154a9565b6040518463ffffffff1660e01b8152600401611f7093929190615b74565b60206040518083038186803b158015611f8857600080fd5b505afa158015611f9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fc091906159b7565b611fc7565b825b608a54606b54604051631b4e258760e01b815292955060009283926001600160a01b031691631b4e258791612000918c91600401615ba4565b604080518083038186803b15801561201757600080fd5b505afa15801561202b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061204f91906159f3565b607e546001600160a01b038b81166000908152606d60205260409081902054905163f947c6b360e01b8152600481018690526024810191909152604481018b9052606481018a905260848101849052939550919350169063f947c6b39060a40160206040518083038186803b1580156120c757600080fd5b505afa1580156120db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120ff91906159b7565b98975050505050505050565b612113612bbf565b6001600160a01b03811661215b5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610b4f565b600154600160a81b900460ff16156121ab5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610b4f565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610c32565b600054610100900460ff1661223f5760005460ff1615612243565b303b155b6122a65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b4f565b600054610100900460ff161580156122c8576000805461ffff19166101011790555b6122d186610afd565b6122d96123e7565b60678054610100600160a81b0319166101006001600160a01b03881602179055606a849055606b839055606c8290558015610f45576000805461ff0019169055505050505050565b612329612bbf565b607e80546001600160a01b0319166001600160a01b0392909216919091179055565b600080612359868686610cb3565b608c5460405163441372ef60e11b81529192506001600160a01b031690638826e5de9061238c9086908590600401615ba4565b60206040518083038186803b1580156123a457600080fd5b505afa1580156123b8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123dc91906159b7565b915094509492505050565b60675460ff16156124305760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610b4f565b6067805460ff19166001908117909155606655565b6001606660008282546124589190615dbf565b909155505060665460345460ff16156124835760405162461bcd60e51b8152600401610b4f90615c58565b6116d28787878787876000612d24565b600061249e83610f8a565b156115b25760006124af84846127ec565b9050801561158a576115ae8484836000806124c98a6129a8565b614088565b6124d6612bbf565b608c546001600160a01b03161561257757606754608c5460405163095ea7b360e01b81526001600160a01b0361010090930483169263095ea7b39261252392911690600090600401615ba4565b602060405180830381600087803b15801561253d57600080fd5b505af1158015612551573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612575919061592a565b505b608c80546001600160a01b038481166001600160a81b031990921691909117600160a01b841515021790915560675460405163095ea7b360e01b81526101009091049091169063095ea7b3906125d590859060001990600401615ba4565b602060405180830381600087803b1580156125ef57600080fd5b505af1158015612603573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612627919061592a565b50604080516001600160a01b038416815282151560208201527f7ed317979883517e462a7e4dbfde66a0b837cf91abff298bfa10d966a545298c910160405180910390a15050565b612677612bbf565b6001600160a01b038116156127115760675460405163095ea7b360e01b81526101009091046001600160a01b03169063095ea7b3906126bd908490600090600401615ba4565b602060405180830381600087803b1580156126d757600080fd5b505af11580156126eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061270f919061592a565b505b606880546001600160a01b0319166001600160a01b0383811691821790925560675460405163095ea7b360e01b81526101009091049092169163095ea7b3916127609160001990600401615ba4565b602060405180830381600087803b15801561277a57600080fd5b505af115801561278e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127b2919061592a565b506040516001600160a01b03821681527f1f728ba0a73bcdf17f9e0f260b7db049043dfa6b907980f715e30767d36bc70690602001610c32565b60685460405163352feab360e11b81526001600160a01b0384811660048301526000921690636a5fd5669060240160206040518083038186803b15801561283257600080fd5b505afa158015612846573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061286a919061592a565b1561292657600082600281111561289157634e487b7160e01b600052602160045260246000fd5b141561292657607e546001600160a01b031663a119612d846128b281613dc6565b6040518363ffffffff1660e01b81526004016128cf929190615ba4565b60206040518083038186803b1580156128e757600080fd5b505afa1580156128fb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061291f91906159b7565b90506115b2565b607e546040516350d851a160e01b81526001600160a01b03909116906350d851a1906129589086908690600401615b57565b60206040518083038186803b15801561297057600080fd5b505afa158015612984573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfd91906159b7565b6129d4604080516080810190915260008082526020820190815260200160008152600060209091015290565b60685460405163352feab360e11b81526001600160a01b03848116600483015290911690636a5fd5669060240160206040518083038186803b158015612a1957600080fd5b505afa158015612a2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a51919061592a565b612a8157604080516080810190915260008082526020820190815260200160018152600060209091015292915050565b607e5460405163a4d682dd60e01b81526001600160a01b038481166004830152600092839283929091169063a4d682dd9060240160606040518083038186803b158015612acd57600080fd5b505afa158015612ae1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b059190615987565b9250925092506040518060800160405280600115158152602001846002811115612b3f57634e487b7160e01b600052602160045260246000fd5b8152602001836002811115612b6457634e487b7160e01b600052602160045260246000fd5b8152602001826001600160a01b03168152509350505050919050565b805160009015612b9f57612b988a8a8a898787614117565b9050612bb2565b612baf8a8a8a8a8a8a8a8a614250565b90505b9998505050505050505050565b6000546201000090046001600160a01b03163314612c375760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610b4f565b565b60345460ff16612c825760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b4f565b6034805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60345460ff1615612cef5760405162461bcd60e51b8152600401610b4f90615c58565b6034805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612caf3390565b600080612d338989898761234b565b9092509050612d4a85670de0b6b3a7640000615dbf565b86612d5d670de0b6b3a764000085615deb565b612d679190615dd7565b1115612daa5760405162461bcd60e51b8152602060048201526012602482015271536c69707061676520746f6f20686967682160701b6044820152606401610b4f565b60008315612f1757608c60009054906101000a90046001600160a01b03166001600160a01b0316634aa4a4fc6040518163ffffffff1660e01b815260040160206040518083038186803b158015612e0057600080fd5b505afa158015612e14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e3891906154a9565b6001600160a01b0316856001600160a01b031614612e905760405162461bcd60e51b815260206004820152601560248201527415dc9bdb99c818dbdb1b185d195c985b081cd95b9d605a1b6044820152606401610b4f565b608c54604051631321b85d60e01b8152600481018590526001600160a01b0390911690631321b85d9085906024016020604051808303818588803b158015612ed757600080fd5b505af1158015612eeb573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612f1091906159b7565b905061303a565b612f2c6001600160a01b0386163330866143eb565b608c5460405163095ea7b360e01b81526001600160a01b038781169263095ea7b392612f6092909116908790600401615ba4565b602060405180830381600087803b158015612f7a57600080fd5b505af1158015612f8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fb2919061592a565b50608c546040516322ceb11360e21b81526001600160a01b0390911690638b3ac44c90612fe59088908790600401615ba4565b602060405180830381600087803b158015612fff57600080fd5b505af1158015613013573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061303791906159b7565b90505b8181101561308a5760405162461bcd60e51b815260206004820152601860248201527f4e6f7420656e6f756768207355534420726563656976656400000000000000006044820152606401610b4f565b818111156130c457606e546130c4906001600160a01b03166130ac8484615e0a565b60675461010090046001600160a01b0316919061402d565b61312a6040518060e001604052808c6001600160a01b031681526020018b600281111561310157634e487b7160e01b600052602160045260246000fd5b81526020018a815260200184815260200188815260200160001515815260200184815250613136565b50505050505050505050565b61314881600001518260200151614423565b600061315782600001516129a8565b8051909150158061318b575060008260200151600281111561318957634e487b7160e01b600052602160045260246000fd5b145b6131c55760405162461bcd60e51b815260206004820152600b60248201526a496e76616c696420706f7360a81b6044820152606401610b4f565b60006131d9836000015184602001516127ec565b90506000811161321a5760405162461bcd60e51b815260206004820152600c60248201526b4e6f2062617365206f64647360a01b6044820152606401610b4f565b613228818460000151611591565b607e548451602086015160855460405163c2edfc7360e01b81526001600160a01b0380851660048301529596506000959485169463e468265c949392169063c2edfc739060240160206040518083038186803b15801561328757600080fd5b505afa15801561329b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132bf91906154a9565b6040518463ffffffff1660e01b81526004016132dd93929190615b74565b60206040518083038186803b1580156132f557600080fd5b505afa158015613309573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061332d91906159b7565b90506000613348856000015186602001518585600189614088565b905067016345785d8a00008560400151118015613369575080856040015111155b6133aa5760405162461bcd60e51b815260206004820152601260248201527104c6f77206c6971756964697479207c7c20360741b6044820152606401610b4f565b8460a0015115613481576133db856000015186602001518760400151866133d033614537565b86600160008c612b80565b60c086015260808501516133f790670de0b6b3a7640000615dbf565b8560600151670de0b6b3a76400008760c001516134149190615deb565b61341e9190615dd7565b111561345c5760405162461bcd60e51b815260206004820152600d60248201526c4869676820736c69707061676560981b6044820152606401610b4f565b60c0850151606754613481916101009091046001600160a01b031690339030906143eb565b835160009080613501575085600001516001600160a01b03166311f2d4946040518163ffffffff1660e01b815260040160206040518083038186803b1580156134c957600080fd5b505afa1580156134dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613501919061592a565b61350c578551613581565b85600001516001600160a01b031663d03ecc646040518163ffffffff1660e01b815260040160206040518083038186803b15801561354957600080fd5b505afa15801561355d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061358191906154a9565b8551909150156136ee578551604080880151905163140e25ad60e31b81526001600160a01b039092169163a0712d68916135c19160040190815260200190565b600060405180830381600087803b1580156135db57600080fd5b505af11580156135ef573d6000803e3d6000fd5b505050506136068660000151876040015187614590565b607e5486516040516318dc4baf60e11b81526001600160a01b039182166004820152600092839216906331b8975e90602401604080518083038186803b15801561364f57600080fd5b505afa158015613663573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061368791906154c5565b9150915061369e8860400151838a60000151614824565b6136b18860400151828a60000151614824565b875160408901516136cc916001600160a01b0385169161402d565b875160408901516136e7916001600160a01b0384169161402d565b50506138b7565b600086604001518410613702576000613712565b8387604001516137129190615e0a565b90508015613838576085548751604051630163027360e61b81526001600160a01b03909216916358c09cc09161374c918590600401615ba4565b600060405180830381600087803b15801561376657600080fd5b505af115801561377a573d6000803e3d6000fd5b5050885160405163140e25ad60e31b8152600481018590526001600160a01b03909116925063a0712d689150602401600060405180830381600087803b1580156137c357600080fd5b505af11580156137d7573d6000803e3d6000fd5b505088516001600160a01b03166000908152606d602052604081208054859450909250613805908490615dbf565b90915550506001600160a01b0382166000908152608b602052604081208054839290613832908490615dbf565b90915550505b608554875160408901516001600160a01b039092169163828fce889190613860908590615e0a565b8a602001516040518463ffffffff1660e01b815260040161388393929190615bbd565b600060405180830381600087803b15801561389d57600080fd5b505af11580156138b1573d6000803e3d6000fd5b50505050505b600080600088600001516001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b1580156138f957600080fd5b505afa15801561390d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139319190615946565b919450925090506000808a60200151600281111561395f57634e487b7160e01b600052602160045260246000fd5b1461399b5760018a60200151600281111561398a57634e487b7160e01b600052602160045260246000fd5b14613995578161399d565b8261399d565b835b90506139c1338b60400151836001600160a01b031661402d9092919063ffffffff16565b88511580156139d257506000608054115b80156139f357506080548a60c001518b604001516139f09190615e0a565b10155b15613bcc5760008a6000015190506000816001600160a01b03166311f2d4946040518163ffffffff1660e01b815260040160206040518083038186803b158015613a3c57600080fd5b505afa158015613a50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a74919061592a565b613a7f576000613af7565b6040516308208aaf60e21b8152600160048201526001600160a01b038316906320822abc9060240160206040518083038186803b158015613abf57600080fd5b505afa158015613ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613af791906159b7565b905061271a811415613b68576081548c516040516375c1f9a560e11b81526001600160a01b03918216600482015291169063eb83f34a90602401600060405180830381600087803b158015613b4b57600080fd5b505af1158015613b5f573d6000803e3d6000fd5b50505050613bc9565b6081548c5160405163029a39cd60e01b81526001600160a01b03918216600482015291169063029a39cd90602401600060405180830381600087803b158015613bb057600080fd5b505af1158015613bc4573d6000803e3d6000fd5b505050505b50505b8851613beb90613bdd578a51613bdf565b855b868c60c00151336149ac565b608a546001600160a01b038681166000818152608b60205260409081902054905163ba0ed4ed60e01b81526004810191909152602481019190915291169063ba0ed4ed9060440160206040518083038186803b158015613c4a57600080fd5b505afa158015613c5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c82919061592a565b613cc15760405162461bcd60e51b815260206004820152601060248201526f5269736b20697320746f20686967682160801b6044820152606401610b4f565b8851613cd890613cd2578a51614d30565b85614d30565b6071546001600160a01b031615613d525760715460c08b01516040516302c7739b60e01b81526001600160a01b03909216916302c7739b91613d1f91339190600401615ba4565b600060405180830381600087803b158015613d3957600080fd5b505af1158015613d4d573d6000803e3d6000fd5b505050505b7ff3bfbc0822d1ed667a2b298e71e0304f2c1f4685398189d7c39e412f733150f4338b600001518c602001518d604001518e60c00151606760019054906101000a90046001600160a01b031687604051613db29796959493929190615b07565b60405180910390a150505050505050505050565b608a5460725460405163bf7ff78b60e01b81526000926001600160a01b03169163bf7ff78b91613dfa918691600401615ba4565b60206040518083038186803b158015613e1257600080fd5b505afa158015613e26573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b291906159b7565b6000806003836002811115613e6f57634e487b7160e01b600052602160045260246000fd5b613e7a906001615dbf565b613e849190615e68565b6002811115613ea357634e487b7160e01b600052602160045260246000fd5b905060006003846002811115613ec957634e487b7160e01b600052602160045260246000fd5b613ed4906002615dbf565b613ede9190615e68565b6002811115613efd57634e487b7160e01b600052602160045260246000fd5b9050610af48583836000614f9c565b607e546040805161010081019091526001600160a01b0387811682526000921690630381cd099060208101886002811115613f5757634e487b7160e01b600052602160045260246000fd5b81526020810188905260408101879052606081018690526085546001600160a01b0316608082015260a001613f8b8a615212565b8152602001613f998a613dc6565b8152506040518263ffffffff1660e01b8152600401613fb89190615d51565b60206040518083038186803b158015613fd057600080fd5b505afa158015613fe4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061400891906159b7565b9695505050505050565b8015611e6d57611e6d6001600160a01b0384168584846143eb565b6140838363a9059cbb60e01b848460405160240161404c929190615ba4565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152615246565b505050565b8051600090156140f35760008660028111156140b457634e487b7160e01b600052602160045260246000fd5b1480156140cd57506000851180156140cd575060735485105b156140ee576140eb8260600151836020015184604001516001614f9c565b90505b614008565b6140fd8588611591565b945061410c8787878787611e73565b979650505050505050565b60008086600281111561413a57634e487b7160e01b600052602160045260246000fd5b141561400857607e5460009081906001600160a01b0316634ab96c838a61416081613dc6565b6040518363ffffffff1660e01b815260040161417d929190615ba4565b604080518083038186803b15801561419457600080fd5b505afa1580156141a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141cc91906159f3565b915091506000821180156141e05750600081115b15614244576000614200856060015186602001518a868b6000808d614250565b9050600061421d866060015187604001518b868c6000808e614250565b905060008211801561422f5750600081115b156142415761423e8183615dbf565b94505b50505b50509695505050505050565b60008261426857614265898988600080611e73565b93505b8387116120ff57600061427b8a8a613e4a565b9050600061428c8b8b8b8986613f0c565b9050670de0b6b3a76400006142a1858d615318565b6142b390670de0b6b3a7640000615dbf565b6142bd908a615deb565b6142c79190615dd7565b607e54604051632b4b76a960e21b81526004810184905260248101839052604481018a9052606481018c90529199506000916001600160a01b039091169063ad2ddaa49060840160206040518083038186803b15801561432657600080fd5b505afa15801561433a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061435e91906159b7565b60685460405163edc892e160e01b8152600481018390529192506001600160a01b03169063edc892e19060240160206040518083038186803b1580156143a357600080fd5b505afa1580156143b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906143db91906159b7565b9c9b505050505050505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611e6d9085906323b872dd60e01b9060840161404c565b61442c82610f8a565b6144665760405162461bcd60e51b815260206004820152600b60248201526a4e6f742074726164696e6760a81b6044820152606401610b4f565b6000826001600160a01b0316631a1dbabb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156144a157600080fd5b505afa1580156144b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144d991906159b7565b90508160028111156144fb57634e487b7160e01b600052602160045260246000fd5b81116140835760405162461bcd60e51b815260206004820152600b60248201526a496e76616c696420706f7360a81b6044820152606401610b4f565b607a546000906001600160a01b0383811691161461109c576001600160a01b038216600090815260826020526040902054614574576070546115b2565b506001600160a01b031660009081526082602052604090205490565b607e54606082015160855460405163c2edfc7360e01b81526001600160a01b03878116600483015260009485949082169363755cc89c939192169063c2edfc739060240160206040518083038186803b1580156145ec57600080fd5b505afa158015614600573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061462491906154a9565b866020015187604001516040518563ffffffff1660e01b815260040161464d9493929190615ad5565b604080518083038186803b15801561466457600080fd5b505afa158015614678573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061469c91906159f3565b9150915060008483106146b05760006146ba565b6146ba8386615e0a565b905060008583106146cc5760006146d6565b6146d68387615e0a565b905060008183106146e757826146e9565b815b90508015610e7f576085546060870151604051630163027360e61b81526001600160a01b03909216916358c09cc091614726918590600401615ba4565b600060405180830381600087803b15801561474057600080fd5b505af1158015614754573d6000803e3d6000fd5b505050606087015160405163140e25ad60e31b8152600481018490526001600160a01b03909116915063a0712d6890602401600060405180830381600087803b1580156147a057600080fd5b505af11580156147b4573d6000803e3d6000fd5b5050505060608601516001600160a01b03166000908152606d6020526040812080548392906147e4908490615dbf565b909155505060608601516001600160a01b03166000908152608b602052604081208054839290614815908490615dbf565b90915550505050505050505050565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a082319060240160206040518083038186803b15801561486657600080fd5b505afa15801561487a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061489e91906159b7565b905080841115611e6d57608560009054906101000a90046001600160a01b03166001600160a01b03166352129e48836001600160a01b031663d03ecc646040518163ffffffff1660e01b815260040160206040518083038186803b15801561490557600080fd5b505afa158015614919573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061493d91906154a9565b6149478488615e0a565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015260248101919091529086166044820152606401600060405180830381600087803b15801561499857600080fd5b505af1158015610e7f573d6000803e3d6000fd5b607854604051630293b59d60e31b81526001600160a01b038381166004830152600092169063149dace89060240160206040518083038186803b1580156149f257600080fd5b505afa158015614a06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a2a91906154a9565b905060006001600160a01b03821615614b525760785460405163c7d1f5f160e01b81526001600160a01b038481166004830152600092169063c7d1f5f19060240160206040518083038186803b158015614a8357600080fd5b505afa158015614a97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614abb91906159b7565b90508015614b5057670de0b6b3a7640000614ad68287615deb565b614ae09190615dd7565b606754909250614aff9061010090046001600160a01b0316848461402d565b604080516001600160a01b0385168152336020820152908101839052606081018690527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a15b505b600080614b5e85614537565b90508015614bbb57614b7881670de0b6b3a7640000615dbf565b614b8a670de0b6b3a764000088615deb565b614b949190615dd7565b614b9e9087615e0a565b606e54909250614bbb906001600160a01b03166130ac8585615e0a565b6068546000906001600160a01b03166317fd849a614bd9858a615e0a565b6040518263ffffffff1660e01b8152600401614bf791815260200190565b60206040518083038186803b158015614c0f57600080fd5b505afa158015614c23573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c4791906159b7565b6001600160a01b038a166000908152606d6020526040902054909150811015614c9d576001600160a01b0389166000908152606d602052604081208054839290614c92908490615e0a565b925050819055614ca0565b60005b6001600160a01b03808b166000908152606d6020908152604080832094909455918b168152608b9091522054811015614d06576001600160a01b0388166000908152608b602052604081208054839290614cfb908490615e0a565b925050819055614d09565b60005b6001600160a01b039098166000908152608b60205260409020979097555050505050505050565b60855460405163f475f13b60e01b81526001600160a01b038381166004830152600092169063f475f13b90602401602060405180830381600087803b158015614d7857600080fd5b505af1158015614d8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614db091906154a9565b6067546040516370a0823160e01b8152306004820152919250614e3f916101009091046001600160a01b031690839082906370a082319060240160206040518083038186803b158015614e0257600080fd5b505afa158015614e16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e3a91906159b7565b615378565b6000806000846001600160a01b031663cc2ee1966040518163ffffffff1660e01b815260040160606040518083038186803b158015614e7d57600080fd5b505afa158015614e91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614eb59190615946565b919450925090506001600160a01b038316614ef75760405162461bcd60e51b8152602060048201526002602482015261304160f01b6044820152606401610b4f565b604051636392a51f60e01b8152306004820152600090819081906001600160a01b03891690636392a51f9060240160606040518083038186803b158015614f3d57600080fd5b505afa158015614f51573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614f759190615a16565b925092509250614f86868885615378565b614f91858884615378565b610e7f848883615378565b608a54606b5460725460405163108a442b60e01b81526001600160a01b03888116600483015260248201939093526044810191909152600092839283928392919091169063108a442b9060640160606040518083038186803b15801561500157600080fd5b505afa158015615015573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906150399190615a16565b925092509250607e60009054906101000a90046001600160a01b03166001600160a01b03166311ecf33e6040518061012001604052808b6001600160a01b031681526020018a600281111561509e57634e487b7160e01b600052602160045260246000fd5b81526020018960028111156150c357634e487b7160e01b600052602160045260246000fd5b815288151560208201526085546040805163c2edfc7360e01b81526001600160a01b038f81166004830152919093019291169063c2edfc739060240160206040518083038186803b15801561511757600080fd5b505afa15801561512b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061514f91906154a9565b6001600160a01b03168152602001848152602001868152602001858152602001606d60008d6001600160a01b03166001600160a01b03168152602001908152602001600020548152506040518263ffffffff1660e01b81526004016151b49190615cb9565b60206040518083038186803b1580156151cc57600080fd5b505afa1580156151e0573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061520491906159b7565b93505050505b949350505050565b608a54606b5460405163085bbf5560e21b81526000926001600160a01b03169163216efd5491613dfa918691600401615ba4565b600061529b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166153929092919063ffffffff16565b80519091501561408357808060200190518101906152b9919061592a565b6140835760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610b4f565b608a54606a5433600090815260836020526040808220549051630aca6ecb60e21b815286151560048201526001600160a01b0386811660248301526044820194909452606481019190915290929190911690632b29bb2c90608401612958565b8015614083576140836001600160a01b038416838361402d565b606061520a848460008585843b6153eb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610b4f565b600080866001600160a01b031685876040516154079190615ab9565b60006040518083038185875af1925050503d8060008114615444576040519150601f19603f3d011682016040523d82523d6000602084013e615449565b606091505b509150915061410c82828660608315615463575081610cfd565b8251156154735782518084602001fd5b8160405162461bcd60e51b8152600401610b4f9190615c25565b60006020828403121561549e578081fd5b81356115ac81615ea8565b6000602082840312156154ba578081fd5b81516115ac81615ea8565b600080604083850312156154d7578081fd5b82516154e281615ea8565b60208401519092506154f381615ea8565b809150509250929050565b600080600060608486031215615512578081fd5b833561551d81615ea8565b9250602084013561552d81615ea8565b9150604084013561553d81615ebd565b809150509250925092565b6000806040838503121561555a578182fd5b823561556581615ea8565b915060208301356154f381615ebd565b60008060008060008060008060006101208a8c031215615593578485fd5b893561559e81615ea8565b985060208a01356155ae81615ea8565b975060408a01356155be81615ea8565b965060608a01356155ce81615ea8565b955060808a01356155de81615ea8565b945060a08a01356155ee81615ea8565b935060c08a01356155fe81615ea8565b925060e08a013561560e81615ea8565b91506101008a013561561f81615ea8565b809150509295985092959850929598565b600080600080600060a08688031215615647578081fd5b853561565281615ea8565b9450602086013561566281615ea8565b94979496505050506040830135926060810135926080909101359150565b60008060408385031215615692578182fd5b823561569d81615ea8565b915060208301356154f381615ecb565b6000806000606084860312156156c1578283fd5b83356156cc81615ea8565b925060208401356156dc81615ecb565b929592945050506040919091013590565b60008060008060808587031215615702578182fd5b843561570d81615ea8565b9350602085013561571d81615ecb565b925060408501359150606085013561573481615ea8565b939692955090935050565b600080600080600060a08688031215615756578283fd5b853561576181615ea8565b9450602086013561577181615ecb565b93506040860135925060608601359150608086013561578f81615ebd565b809150509295509295909350565b600080600080600060a086880312156157b4578283fd5b85356157bf81615ea8565b9450602086013561566281615ecb565b60008060008060008060c087890312156157e7578384fd5b86356157f281615ea8565b9550602087013561580281615ecb565b945060408701359350606087013592506080870135915060a087013561582781615ea8565b809150509295509295509295565b600080600080600080600060e0888a03121561584f578081fd5b873561585a81615ea8565b9650602088013561586a81615ecb565b955060408801359450606088013593506080880135925060a088013561588f81615ea8565b915060c088013561589f81615ea8565b8091505092959891949750929550565b600080604083850312156158c1578182fd5b82356158cc81615ea8565b946020939093013593505050565b6000806000606084860312156158ee578081fd5b83356158f981615ea8565b95602085013595506040909401359392505050565b60006020828403121561591f578081fd5b81356115ac81615ebd565b60006020828403121561593b578081fd5b81516115ac81615ebd565b60008060006060848603121561595a578081fd5b835161596581615ea8565b602085015190935061597681615ea8565b604085015190925061553d81615ea8565b60008060006060848603121561599b578081fd5b83516159a681615ecb565b602085015190935061597681615ecb565b6000602082840312156159c8578081fd5b5051919050565b600080604083850312156159e1578182fd5b8235915060208301356154f381615ea8565b60008060408385031215615a05578182fd5b505080516020909101519092909150565b600080600060608486031215615a2a578081fd5b8351925060208401519150604084015190509250925092565b600080600080600080600080610100898b031215615a5f578182fd5b505086359860208801359850604088013597606081013597506080810135965060a0810135955060c0810135945060e0013592509050565b60038110615ab557634e487b7160e01b600052602160045260246000fd5b9052565b60008251615acb818460208701615e21565b9190910192915050565b6001600160a01b0385811682528416602082015260808101615afa6040830185615a97565b610af46060830184615a97565b6001600160a01b038881168252878116602083015260e0820190615b2e6040840189615a97565b86606084015285608084015280851660a084015280841660c08401525098975050505050505050565b6001600160a01b038316815260408101610cfd6020830184615a97565b6001600160a01b0384811682526060820190615b936020840186615a97565b808416604084015250949350505050565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0384168152602081018390526060810161520a6040830184615a97565b6020808252825182820181905260009190848201906040850190845b81811015615c1957835183529284019291840191600101615bfd565b50909695505050505050565b6020815260008251806020840152615c44816040850160208701615e21565b601f01601f19169190910160400192915050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b81516001600160a01b03168152602080830151610120830191615cde90840182615a97565b506040830151615cf16040840182615a97565b506060830151615d05606084018215159052565b506080830151615d2060808401826001600160a01b03169052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525092915050565b81516001600160a01b03908116825260208084015161010084019291615d7990850182615a97565b506040840151604084015260608401516060840152608084015160808401528060a08501511660a08401525060c083015160c083015260e083015160e083015292915050565b60008219821115615dd257615dd2615e7c565b500190565b600082615de657615de6615e92565b500490565b6000816000190483118215151615615e0557615e05615e7c565b500290565b600082821015615e1c57615e1c615e7c565b500390565b60005b83811015615e3c578181015183820152602001615e24565b83811115611e6d5750506000910152565b6000600019821415615e6157615e61615e7c565b5060010190565b600082615e7757615e77615e92565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6001600160a01b0381168114610ca857600080fd5b8015158114610ca857600080fd5b60038110610ca857600080fdfea2646970667358221220826d769b935c11a80516194a610c724ffc0ec84c11dbf5ba1754664f3b7958f764736f6c63430008040033
Multichain Portfolio | 34 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.