Contract Overview
Balance:
0 ETH
EtherValue:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash | Method |
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x176d199376ec66f9e676c361ec73764a1125ca9cb282e09e574a96879831168e | 0x60806040 | 3866324 | 18 days 2 hrs ago | 0x34ad8d8c3e12b5a500fe983c43f2a0306dcf0ad1 | IN | Create: SpeedMarketsAMM | 0 ETH | 0.008711604791 |
[ Download CSV Export ]
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
SpeedMarketsAMM
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // external import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-4.4.1/proxy/Clones.sol"; import "@pythnetwork/pyth-sdk-solidity/IPyth.sol"; import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol"; // internal import "../utils/proxy/solidity-0.8.0/ProxyReentrancyGuard.sol"; import "../utils/proxy/solidity-0.8.0/ProxyOwned.sol"; import "../utils/proxy/solidity-0.8.0/ProxyPausable.sol"; import "../utils/libraries/AddressSetLib.sol"; import "../interfaces/IStakingThales.sol"; import "../interfaces/IMultiCollateralOnOffRamp.sol"; import {IReferrals} from "../interfaces/IReferrals.sol"; import "./SpeedMarket.sol"; /// @title An AMM for Thales speed markets contract SpeedMarketsAMM is Initializable, ProxyOwned, ProxyPausable, ProxyReentrancyGuard { using SafeERC20Upgradeable for IERC20Upgradeable; using AddressSetLib for AddressSetLib.AddressSet; AddressSetLib.AddressSet internal _activeMarkets; AddressSetLib.AddressSet internal _maturedMarkets; uint private constant ONE = 1e18; IERC20Upgradeable public sUSD; address public speedMarketMastercopy; uint public safeBoxImpact; uint public lpFee; address public safeBox; mapping(bytes32 => bool) public supportedAsset; uint public minimalTimeToMaturity; uint public maximalTimeToMaturity; uint public minBuyinAmount; uint public maxBuyinAmount; mapping(bytes32 => uint) public maxRiskPerAsset; mapping(bytes32 => uint) public currentRiskPerAsset; mapping(bytes32 => bytes32) public assetToPythId; //eth 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace IPyth public pyth; uint64 public maximumPriceDelay; /// @return The address of the Staking contract IStakingThales public stakingThales; mapping(address => AddressSetLib.AddressSet) internal _activeMarketsPerUser; mapping(address => AddressSetLib.AddressSet) internal _maturedMarketsPerUser; struct MarketData { address user; bytes32 asset; uint64 strikeTime; int64 strikePrice; SpeedMarket.Direction direction; uint buyinAmount; bool resolved; int64 finalPrice; SpeedMarket.Direction result; bool isUserWinner; uint256 createdAt; } mapping(address => bool) public whitelistedAddresses; IMultiCollateralOnOffRamp public multiCollateralOnOffRamp; bool public multicollateralEnabled; mapping(bytes32 => mapping(SpeedMarket.Direction => uint)) public maxRiskPerAssetAndDirection; mapping(bytes32 => mapping(SpeedMarket.Direction => uint)) public currentRiskPerAssetAndDirection; struct Risk { SpeedMarket.Direction direction; uint current; uint max; } uint64 public maximumPriceDelayForResolving; mapping(address => bool) private marketHasCreatedAtAttribute; address public referrals; function initialize( address _owner, IERC20Upgradeable _sUSD, IPyth _pyth ) public initializer { setOwner(_owner); initNonReentrant(); sUSD = _sUSD; pyth = _pyth; } function createNewMarket( bytes32 asset, uint64 strikeTime, SpeedMarket.Direction direction, uint buyinAmount, bytes[] calldata priceUpdateData, address _referrer ) external payable nonReentrant notPaused { _createNewMarket(asset, strikeTime, direction, buyinAmount, priceUpdateData, true, _referrer); } function createNewMarketWithDelta( bytes32 asset, uint64 delta, SpeedMarket.Direction direction, uint buyinAmount, bytes[] calldata priceUpdateData, address _referrer ) external payable nonReentrant notPaused { _createNewMarket(asset, uint64(block.timestamp + delta), direction, buyinAmount, priceUpdateData, true, _referrer); } function createNewMarketWithDifferentCollateral( bytes32 asset, uint64 strikeTime, SpeedMarket.Direction direction, bytes[] calldata priceUpdateData, address collateral, uint collateralAmount, bool isEth, address _referrer ) external payable nonReentrant notPaused { _createNewMarketWithDifferentCollateral( asset, strikeTime, direction, priceUpdateData, collateral, collateralAmount, isEth, _referrer ); } function createNewMarketWithDifferentCollateralAndDelta( bytes32 asset, uint64 delta, SpeedMarket.Direction direction, bytes[] calldata priceUpdateData, address collateral, uint collateralAmount, bool isEth, address _referrer ) external payable nonReentrant notPaused { _createNewMarketWithDifferentCollateral( asset, uint64(block.timestamp + delta), direction, priceUpdateData, collateral, collateralAmount, isEth, _referrer ); } function _convertCollateral( address collateral, uint collateralAmount, bool isEth ) internal returns (uint buyinAmount) { uint convertedAmount; if (isEth) { convertedAmount = multiCollateralOnOffRamp.onrampWithEth{value: collateralAmount}(collateralAmount); } else { IERC20Upgradeable(collateral).safeTransferFrom(msg.sender, address(this), collateralAmount); IERC20Upgradeable(collateral).approve(address(multiCollateralOnOffRamp), collateralAmount); convertedAmount = multiCollateralOnOffRamp.onramp(collateral, collateralAmount); } buyinAmount = (convertedAmount * (ONE - safeBoxImpact - lpFee)) / ONE; } function _createNewMarketWithDifferentCollateral( bytes32 asset, uint64 strikeTime, SpeedMarket.Direction direction, bytes[] calldata priceUpdateData, address collateral, uint collateralAmount, bool isEth, address _referrer ) internal { require(multicollateralEnabled, "Multicollateral onramp not enabled"); uint buyinAmount = _convertCollateral(collateral, collateralAmount, isEth); _createNewMarket(asset, strikeTime, direction, buyinAmount, priceUpdateData, false, _referrer); } function _handleReferrer(address buyer, uint volume) internal returns (uint referrerShare) { if (referrals != address(0)) { address referrer = IReferrals(referrals).referrals(buyer); if (referrer != address(0)) { uint referrerFeeByTier = IReferrals(referrals).getReferrerFee(referrer); if (referrerFeeByTier > 0) { referrerShare = (volume * referrerFeeByTier) / ONE; sUSD.safeTransfer(referrer, referrerShare); emit ReferrerPaid(referrer, buyer, referrerShare, volume); } } } } function _handleRisk( bytes32 asset, SpeedMarket.Direction direction, uint buyinAmount ) internal { currentRiskPerAsset[asset] += buyinAmount; require(currentRiskPerAsset[asset] <= maxRiskPerAsset[asset], "OI cap breached"); SpeedMarket.Direction oppositeDirection = direction == SpeedMarket.Direction.Up ? SpeedMarket.Direction.Down : SpeedMarket.Direction.Up; uint amountToIncreaseRisk = buyinAmount; // decrease risk for opposite direction if (currentRiskPerAssetAndDirection[asset][oppositeDirection] > buyinAmount) { currentRiskPerAssetAndDirection[asset][oppositeDirection] -= buyinAmount; } else { amountToIncreaseRisk = buyinAmount - currentRiskPerAssetAndDirection[asset][oppositeDirection]; currentRiskPerAssetAndDirection[asset][oppositeDirection] = 0; } // until there is risk for opposite direction, don't modify/check risk for current direction if (currentRiskPerAssetAndDirection[asset][oppositeDirection] == 0) { currentRiskPerAssetAndDirection[asset][direction] += amountToIncreaseRisk; require( currentRiskPerAssetAndDirection[asset][direction] <= maxRiskPerAssetAndDirection[asset][direction], "Risk per direction exceeded" ); } } function _createNewMarket( bytes32 asset, uint64 strikeTime, SpeedMarket.Direction direction, uint buyinAmount, bytes[] memory priceUpdateData, bool transferSusd, address _referrer ) internal { if (_referrer != address(0)) { IReferrals(referrals).setReferrer(_referrer, msg.sender); } require(supportedAsset[asset], "Asset is not supported"); require(buyinAmount >= minBuyinAmount && buyinAmount <= maxBuyinAmount, "wrong buy in amount"); require( strikeTime >= (block.timestamp + minimalTimeToMaturity), "time has to be in the future + minimalTimeToMaturity" ); require(strikeTime <= block.timestamp + maximalTimeToMaturity, "time too far into the future"); _handleRisk(asset, direction, buyinAmount); uint fee = pyth.getUpdateFee(priceUpdateData); pyth.updatePriceFeeds{value: fee}(priceUpdateData); PythStructs.Price memory price = pyth.getPrice(assetToPythId[asset]); require((price.publishTime + maximumPriceDelay) > block.timestamp && price.price > 0, "Stale price"); if (transferSusd) { uint totalAmountToTransfer = (buyinAmount * (ONE + safeBoxImpact + lpFee)) / ONE; sUSD.safeTransferFrom(msg.sender, address(this), totalAmountToTransfer); } SpeedMarket srm = SpeedMarket(Clones.clone(speedMarketMastercopy)); srm.initialize( SpeedMarket.InitParams(address(this), msg.sender, asset, strikeTime, price.price, direction, buyinAmount) ); sUSD.safeTransfer(address(srm), buyinAmount * 2); uint referrerShare = _handleReferrer(msg.sender, buyinAmount); sUSD.safeTransfer(safeBox, (buyinAmount * safeBoxImpact) / ONE - referrerShare); _activeMarkets.add(address(srm)); _activeMarketsPerUser[msg.sender].add(address(srm)); if (address(stakingThales) != address(0)) { stakingThales.updateVolume(msg.sender, buyinAmount); } marketHasCreatedAtAttribute[address(srm)] = true; emit MarketCreated(address(srm), msg.sender, asset, strikeTime, price.price, direction, buyinAmount); } /// @notice resolveMarket resolves an active market /// @param market address of the market function resolveMarket(address market, bytes[] calldata priceUpdateData) external payable nonReentrant notPaused { _resolveMarket(market, priceUpdateData); } /// @notice resolveMarkets in a batch function resolveMarketsBatch(address[] calldata markets, bytes[] calldata priceUpdateData) external payable nonReentrant notPaused { for (uint i = 0; i < markets.length; i++) { address market = markets[i]; if (canResolveMarket(market)) { bytes[] memory subarray = new bytes[](1); subarray[0] = priceUpdateData[i]; _resolveMarket(market, subarray); } } } function _resolveMarket(address market, bytes[] memory priceUpdateData) internal { require(canResolveMarket(market), "Can not resolve"); uint fee = pyth.getUpdateFee(priceUpdateData); bytes32[] memory priceIds = new bytes32[](1); priceIds[0] = assetToPythId[SpeedMarket(market).asset()]; PythStructs.PriceFeed[] memory prices = pyth.parsePriceFeedUpdates{value: fee}( priceUpdateData, priceIds, SpeedMarket(market).strikeTime(), SpeedMarket(market).strikeTime() + maximumPriceDelayForResolving ); PythStructs.Price memory price = prices[0].price; require(price.price > 0, "invalid price"); _resolveMarketWithPrice(market, price.price); } /// @notice admin resolve market for a given market address with finalPrice function resolveMarketManually(address _market, int64 _finalPrice) external isAddressWhitelisted { _resolveMarketManually(_market, _finalPrice); } /// @notice admin resolve for a given markets with finalPrices function resolveMarketManuallyBatch(address[] calldata markets, int64[] calldata finalPrices) external isAddressWhitelisted { for (uint i = 0; i < markets.length; i++) { if (canResolveMarket(markets[i])) { _resolveMarketManually(markets[i], finalPrices[i]); } } } function _resolveMarketManually(address _market, int64 _finalPrice) internal { require(canResolveMarket(_market), "Can not resolve"); _resolveMarketWithPrice(_market, _finalPrice); } function _resolveMarketWithPrice(address market, int64 _finalPrice) internal { SpeedMarket(market).resolve(_finalPrice); _activeMarkets.remove(market); _maturedMarkets.add(market); address user = SpeedMarket(market).user(); if (_activeMarketsPerUser[user].contains(market)) { _activeMarketsPerUser[user].remove(market); } _maturedMarketsPerUser[user].add(market); bytes32 asset = SpeedMarket(market).asset(); uint buyinAmount = SpeedMarket(market).buyinAmount(); SpeedMarket.Direction direction = SpeedMarket(market).direction(); if (currentRiskPerAssetAndDirection[asset][direction] > buyinAmount) { currentRiskPerAssetAndDirection[asset][direction] -= buyinAmount; } else { currentRiskPerAssetAndDirection[asset][direction] = 0; } if (!SpeedMarket(market).isUserWinner()) { if (currentRiskPerAsset[asset] > 2 * buyinAmount) { currentRiskPerAsset[asset] -= (2 * buyinAmount); } else { currentRiskPerAsset[asset] = 0; } } emit MarketResolved(market, SpeedMarket(market).result(), SpeedMarket(market).isUserWinner()); } //////////// getters for active and matured markets///////////////// /// @notice isKnownMarket checks if market is among matured or active markets /// @param candidate Address of the market. /// @return bool function isKnownMarket(address candidate) public view returns (bool) { return _activeMarkets.contains(candidate) || _maturedMarkets.contains(candidate); } /// @notice isActiveMarket checks if market is active market /// @param candidate Address of the market. /// @return bool function isActiveMarket(address candidate) public view returns (bool) { return _activeMarkets.contains(candidate); } /// @notice numActiveMarkets returns number of active markets /// @return uint function numActiveMarkets() external view returns (uint) { return _activeMarkets.elements.length; } /// @notice activeMarkets returns list of active markets /// @param index index of the page /// @param pageSize number of addresses per page /// @return address[] active market list function activeMarkets(uint index, uint pageSize) external view returns (address[] memory) { return _activeMarkets.getPage(index, pageSize); } /// @notice numMaturedMarkets returns number of mature markets /// @return uint function numMaturedMarkets() external view returns (uint) { return _maturedMarkets.elements.length; } /// @notice maturedMarkets returns list of matured markets /// @param index index of the page /// @param pageSize number of addresses per page /// @return address[] matured market list function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory) { return _maturedMarkets.getPage(index, pageSize); } /// @notice numActiveMarkets returns number of active markets per use function numActiveMarketsPerUser(address user) external view returns (uint) { return _activeMarketsPerUser[user].elements.length; } /// @notice activeMarkets returns list of active markets per user function activeMarketsPerUser( uint index, uint pageSize, address user ) external view returns (address[] memory) { return _activeMarketsPerUser[user].getPage(index, pageSize); } /// @notice numMaturedMarkets returns number of matured markets per use function numMaturedMarketsPerUser(address user) external view returns (uint) { return _maturedMarketsPerUser[user].elements.length; } /// @notice maturedMarkets returns list of matured markets per user function maturedMarketsPerUser( uint index, uint pageSize, address user ) external view returns (address[] memory) { return _maturedMarketsPerUser[user].getPage(index, pageSize); } /// @notice whether a market can be resolved function canResolveMarket(address market) public view returns (bool) { return _activeMarkets.contains(market) && (SpeedMarket(market).strikeTime() < block.timestamp) && !SpeedMarket(market).resolved(); } /// @notice return all market data for an array of markets function getMarketsData(address[] calldata marketsArray) external view returns (MarketData[] memory) { MarketData[] memory markets = new MarketData[](marketsArray.length); for (uint i = 0; i < marketsArray.length; i++) { SpeedMarket market = SpeedMarket(marketsArray[i]); markets[i].user = market.user(); markets[i].asset = market.asset(); markets[i].strikeTime = market.strikeTime(); markets[i].strikePrice = market.strikePrice(); markets[i].direction = market.direction(); markets[i].buyinAmount = market.buyinAmount(); markets[i].resolved = market.resolved(); markets[i].finalPrice = market.finalPrice(); markets[i].result = market.result(); markets[i].isUserWinner = market.isUserWinner(); if (marketHasCreatedAtAttribute[marketsArray[i]]) { markets[i].createdAt = market.createdAt(); } } return markets; } /// @notice return all risk data (direction, current and max) for both directions (Up and Down) by specified asset function getDirectionalRiskPerAsset(bytes32 asset) external view returns (Risk[] memory) { SpeedMarket.Direction[] memory directions = new SpeedMarket.Direction[](2); directions[0] = SpeedMarket.Direction.Up; directions[1] = SpeedMarket.Direction.Down; Risk[] memory risks = new Risk[](directions.length); for (uint i = 0; i < directions.length; i++) { SpeedMarket.Direction currentDirection = directions[i]; risks[i].direction = currentDirection; risks[i].current = currentRiskPerAssetAndDirection[asset][currentDirection]; risks[i].max = maxRiskPerAssetAndDirection[asset][currentDirection]; } return risks; } //////////////////setters///////////////// /// @notice Set mastercopy to use to create markets /// @param _mastercopy to use to create markets function setMastercopy(address _mastercopy) external onlyOwner { speedMarketMastercopy = _mastercopy; emit MastercopyChanged(_mastercopy); } /// @notice Set minimum and maximum buyin amounts function setAmounts(uint _minBuyinAmount, uint _maxBuyinAmount) external onlyOwner { minBuyinAmount = _minBuyinAmount; maxBuyinAmount = _maxBuyinAmount; emit AmountsChanged(_minBuyinAmount, _maxBuyinAmount); } /// @notice Set minimum and maximum time to maturity function setTimes(uint _minimalTimeToMaturity, uint _maximalTimeToMaturity) external onlyOwner { minimalTimeToMaturity = _minimalTimeToMaturity; maximalTimeToMaturity = _maximalTimeToMaturity; emit TimesChanged(_minimalTimeToMaturity, _maximalTimeToMaturity); } /// @notice map asset to PythID, e.g. "ETH" as bytes 32 to an equivalent ID from pyth docs function setAssetToPythID(bytes32 asset, bytes32 pythId) external onlyOwner { assetToPythId[asset] = pythId; emit SetAssetToPythID(asset, pythId); } /// @notice whats the longest a price can be delayed function setMaximumPriceDelay(uint64 _maximumPriceDelay) external onlyOwner { maximumPriceDelay = _maximumPriceDelay; emit SetMaximumPriceDelay(maximumPriceDelay); } /// @notice whats the longest a price can be delayed when resolving function setMaximumPriceDelayForResolving(uint64 _maximumPriceDelayForResolving) external onlyOwner { maximumPriceDelayForResolving = _maximumPriceDelayForResolving; emit SetMaximumPriceDelayForResolving(maximumPriceDelayForResolving); } /// @notice maximum open interest per asset function setMaxRiskPerAsset(bytes32 asset, uint _maxRiskPerAsset) external onlyOwner { maxRiskPerAsset[asset] = _maxRiskPerAsset; emit SetMaxRiskPerAsset(asset, _maxRiskPerAsset); } /// @notice maximum risk per asset and direction function setMaxRiskPerAssetAndDirection(bytes32 asset, uint _maxRiskPerAssetAndDirection) external onlyOwner { maxRiskPerAssetAndDirection[asset][SpeedMarket.Direction.Up] = _maxRiskPerAssetAndDirection; maxRiskPerAssetAndDirection[asset][SpeedMarket.Direction.Down] = _maxRiskPerAssetAndDirection; emit SetMaxRiskPerAssetAndDirection(asset, _maxRiskPerAssetAndDirection); } /// @notice set SafeBox params function setSafeBoxParams(address _safeBox, uint _safeBoxImpact) external onlyOwner { safeBox = _safeBox; safeBoxImpact = _safeBoxImpact; emit SetSafeBoxParams(_safeBox, _safeBoxImpact); } /// @notice set LP fee function setLPFee(uint _lpFee) external onlyOwner { lpFee = _lpFee; emit SetLPFee(_lpFee); } /// @notice Set staking thales function setStakingThales(address _stakingThales) external onlyOwner { //TODO: dont set till StakingThalesBonusRewardsManager is ready for it stakingThales = IStakingThales(_stakingThales); emit SetStakingThales(_stakingThales); } /// @notice set referrals /// @param _referrals contract for referrals storage function setReferrals(address _referrals) external onlyOwner { require(_referrals != address(0), "Can not be zero address"); referrals = _referrals; } /// @notice Set pyth function setPyth(address _pyth) external onlyOwner { pyth = IPyth(_pyth); emit SetPyth(_pyth); } /// @notice set whether an asset is supported function setSupportedAsset(bytes32 asset, bool _supported) external onlyOwner { supportedAsset[asset] = _supported; emit SetSupportedAsset(asset, _supported); } /// @notice set multicollateral onramp contract function setMultiCollateralOnOffRamp(address _onramper, bool enabled) external onlyOwner { multiCollateralOnOffRamp = IMultiCollateralOnOffRamp(_onramper); multicollateralEnabled = enabled; emit SetMultiCollateralOnOffRamp(_onramper, enabled); } /// @notice adding/removing whitelist address depending on a flag /// @param _whitelistAddress address that needed to be whitelisted/ ore removed from WL /// @param _flag adding or removing from whitelist (true: add, false: remove) function addToWhitelist(address _whitelistAddress, bool _flag) external onlyOwner { require(_whitelistAddress != address(0) && whitelistedAddresses[_whitelistAddress] != _flag); whitelistedAddresses[_whitelistAddress] = _flag; emit AddedIntoWhitelist(_whitelistAddress, _flag); } //////////////////modifiers///////////////// modifier isAddressWhitelisted() { require(whitelistedAddresses[msg.sender], "Resolver not whitelisted"); _; } //////////////////events///////////////// event MarketCreated( address market, address user, bytes32 asset, uint strikeTime, int64 strikePrice, SpeedMarket.Direction direction, uint buyinAmount ); event MarketResolved(address market, SpeedMarket.Direction result, bool userIsWinner); event MastercopyChanged(address mastercopy); event AmountsChanged(uint _minBuyinAmount, uint _maxBuyinAmount); event TimesChanged(uint _minimalTimeToMaturity, uint _maximalTimeToMaturity); event SetAssetToPythID(bytes32 asset, bytes32 pythId); event SetMaximumPriceDelay(uint _maximumPriceDelay); event SetMaximumPriceDelayForResolving(uint _maximumPriceDelayForResolving); event SetMaxRiskPerAsset(bytes32 asset, uint _maxRiskPerAsset); event SetMaxRiskPerAssetAndDirection(bytes32 asset, uint _maxRiskPerAssetAndDirection); event SetSafeBoxParams(address _safeBox, uint _safeBoxImpact); event SetLPFee(uint _lpFee); event SetStakingThales(address _stakingThales); event SetPyth(address _pyth); event SetSupportedAsset(bytes32 asset, bool _supported); event AddedIntoWhitelist(address _whitelistAddress, bool _flag); event SetMultiCollateralOnOffRamp(address _onramper, bool enabled); event ReferrerPaid(address refferer, address trader, uint amount, uint volume); }
// 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 (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } }
// 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 (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMathUpgradeable { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT // 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 // 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: Apache-2.0 pragma solidity ^0.8.0; import "./PythStructs.sol"; import "./IPythEvents.sol"; /// @title Consume prices from the Pyth Network (https://pyth.network/). /// @dev Please refer to the guidance at https://docs.pyth.network/consumers/best-practices for how to consume prices safely. /// @author Pyth Data Association interface IPyth is IPythEvents { /// @notice Returns the period (in seconds) that a price feed is considered valid since its publish time function getValidTimePeriod() external view returns (uint validTimePeriod); /// @notice Returns the price and confidence interval. /// @dev Reverts if the price has not been updated within the last `getValidTimePeriod()` seconds. /// @param id The Pyth Price Feed ID of which to fetch the price and confidence interval. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getPrice( bytes32 id ) external view returns (PythStructs.Price memory price); /// @notice Returns the exponentially-weighted moving average price and confidence interval. /// @dev Reverts if the EMA price is not available. /// @param id The Pyth Price Feed ID of which to fetch the EMA price and confidence interval. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getEmaPrice( bytes32 id ) external view returns (PythStructs.Price memory price); /// @notice Returns the price of a price feed without any sanity checks. /// @dev This function returns the most recent price update in this contract without any recency checks. /// This function is unsafe as the returned price update may be arbitrarily far in the past. /// /// Users of this function should check the `publishTime` in the price to ensure that the returned price is /// sufficiently recent for their application. If you are considering using this function, it may be /// safer / easier to use either `getPrice` or `getPriceNoOlderThan`. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getPriceUnsafe( bytes32 id ) external view returns (PythStructs.Price memory price); /// @notice Returns the price that is no older than `age` seconds of the current time. /// @dev This function is a sanity-checked version of `getPriceUnsafe` which is useful in /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently /// recently. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getPriceNoOlderThan( bytes32 id, uint age ) external view returns (PythStructs.Price memory price); /// @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks. /// @dev This function returns the same price as `getEmaPrice` in the case where the price is available. /// However, if the price is not recent this function returns the latest available price. /// /// The returned price can be from arbitrarily far in the past; this function makes no guarantees that /// the returned price is recent or useful for any particular application. /// /// Users of this function should check the `publishTime` in the price to ensure that the returned price is /// sufficiently recent for their application. If you are considering using this function, it may be /// safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getEmaPriceUnsafe( bytes32 id ) external view returns (PythStructs.Price memory price); /// @notice Returns the exponentially-weighted moving average price that is no older than `age` seconds /// of the current time. /// @dev This function is a sanity-checked version of `getEmaPriceUnsafe` which is useful in /// applications that require a sufficiently-recent price. Reverts if the price wasn't updated sufficiently /// recently. /// @return price - please read the documentation of PythStructs.Price to understand how to use this safely. function getEmaPriceNoOlderThan( bytes32 id, uint age ) external view returns (PythStructs.Price memory price); /// @notice Update price feeds with given update messages. /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling /// `getUpdateFee` with the length of the `updateData` array. /// Prices will be updated if they are more recent than the current stored prices. /// The call will succeed even if the update is not the most recent. /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid. /// @param updateData Array of price update data. function updatePriceFeeds(bytes[] calldata updateData) external payable; /// @notice Wrapper around updatePriceFeeds that rejects fast if a price update is not necessary. A price update is /// necessary if the current on-chain publishTime is older than the given publishTime. It relies solely on the /// given `publishTimes` for the price feeds and does not read the actual price update publish time within `updateData`. /// /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling /// `getUpdateFee` with the length of the `updateData` array. /// /// `priceIds` and `publishTimes` are two arrays with the same size that correspond to senders known publishTime /// of each priceId when calling this method. If all of price feeds within `priceIds` have updated and have /// a newer or equal publish time than the given publish time, it will reject the transaction to save gas. /// Otherwise, it calls updatePriceFeeds method to update the prices. /// /// @dev Reverts if update is not needed or the transferred fee is not sufficient or the updateData is invalid. /// @param updateData Array of price update data. /// @param priceIds Array of price ids. /// @param publishTimes Array of publishTimes. `publishTimes[i]` corresponds to known `publishTime` of `priceIds[i]` function updatePriceFeedsIfNecessary( bytes[] calldata updateData, bytes32[] calldata priceIds, uint64[] calldata publishTimes ) external payable; /// @notice Returns the required fee to update an array of price updates. /// @param updateData Array of price update data. /// @return feeAmount The required fee in Wei. function getUpdateFee( bytes[] calldata updateData ) external view returns (uint feeAmount); /// @notice Parse `updateData` and return price feeds of the given `priceIds` if they are all published /// within `minPublishTime` and `maxPublishTime`. /// /// You can use this method if you want to use a Pyth price at a fixed time and not the most recent price; /// otherwise, please consider using `updatePriceFeeds`. This method does not store the price updates on-chain. /// /// This method requires the caller to pay a fee in wei; the required fee can be computed by calling /// `getUpdateFee` with the length of the `updateData` array. /// /// /// @dev Reverts if the transferred fee is not sufficient or the updateData is invalid or there is /// no update for any of the given `priceIds` within the given time range. /// @param updateData Array of price update data. /// @param priceIds Array of price ids. /// @param minPublishTime minimum acceptable publishTime for the given `priceIds`. /// @param maxPublishTime maximum acceptable publishTime for the given `priceIds`. /// @return priceFeeds Array of the price feeds corresponding to the given `priceIds` (with the same order). function parsePriceFeedUpdates( bytes[] calldata updateData, bytes32[] calldata priceIds, uint64 minPublishTime, uint64 maxPublishTime ) external payable returns (PythStructs.PriceFeed[] memory priceFeeds); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; contract PythStructs { // A price with a degree of uncertainty, represented as a price +- a confidence interval. // // The confidence interval roughly corresponds to the standard error of a normal distribution. // Both the price and confidence are stored in a fixed-point numeric representation, // `x * (10^expo)`, where `expo` is the exponent. // // Please refer to the documentation at https://docs.pyth.network/consumers/best-practices for how // to how this price safely. struct Price { // Price int64 price; // Confidence interval around the price uint64 conf; // Price exponent int32 expo; // Unix timestamp describing when the price was published uint publishTime; } // PriceFeed represents a current aggregate price from pyth publisher feeds. struct PriceFeed { // The price ID. bytes32 id; // Latest available price Price price; // Latest available exponentially-weighted moving average price Price emaPrice; } }
// 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.8.0; // Inheritance import "./ProxyOwned.sol"; // Clone of syntetix contract without constructor contract ProxyPausable is ProxyOwned { uint public lastPauseTime; bool public paused; /** * @notice Change the paused state of the contract * @dev Only the contract owner may call this. */ function setPaused(bool _paused) external onlyOwner { // Ensure we're actually changing the state before we do anything if (_paused == paused) { return; } // Set our paused state. paused = _paused; // If applicable, set the last pause time. if (paused) { lastPauseTime = block.timestamp; } // Let everyone know that our pause state has changed. emit PauseChanged(paused); } event PauseChanged(bool isPaused); modifier notPaused { require(!paused, "This action cannot be performed while the contract is paused"); _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library AddressSetLib { struct AddressSet { address[] elements; mapping(address => uint) indices; } function contains(AddressSet storage set, address candidate) internal view returns (bool) { if (set.elements.length == 0) { return false; } uint index = set.indices[candidate]; return index != 0 || set.elements[0] == candidate; } function getPage( AddressSet storage set, uint index, uint pageSize ) internal view returns (address[] memory) { // NOTE: This implementation should be converted to slice operators if the compiler is updated to v0.6.0+ uint endIndex = index + pageSize; // The check below that endIndex <= index handles overflow. // If the page extends past the end of the list, truncate it. if (endIndex > set.elements.length) { endIndex = set.elements.length; } if (endIndex <= index) { return new address[](0); } uint n = endIndex - index; // We already checked for negative overflow. address[] memory page = new address[](n); for (uint i; i < n; i++) { page[i] = set.elements[i + index]; } return page; } function add(AddressSet storage set, address element) internal { // Adding to a set is an idempotent operation. if (!contains(set, element)) { set.indices[element] = set.elements.length; set.elements.push(element); } } function remove(AddressSet storage set, address element) internal { require(contains(set, element), "Element not in set."); // Replace the removed element with the last element of the list. uint index = set.indices[element]; uint lastIndex = set.elements.length - 1; // We required that element is in the list, so it is not empty. if (index != lastIndex) { // No need to shift the last element if it is the one we want to delete. address shiftedElement = set.elements[lastIndex]; set.elements[index] = shiftedElement; set.indices[shiftedElement] = index; } set.elements.pop(); delete set.indices[element]; } }
// 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.5.16; interface IMultiCollateralOnOffRamp { function onramp(address collateral, uint collateralAmount) external returns (uint); function onrampWithEth(uint amount) external payable returns (uint); }
// 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 "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "./SpeedMarketsAMM.sol"; contract SpeedMarket { using SafeERC20Upgradeable for IERC20Upgradeable; struct InitParams { address _speedMarketsAMM; address _user; bytes32 _asset; uint64 _strikeTime; int64 _strikePrice; Direction _direction; uint _buyinAmount; } enum Direction { Up, Down } address public user; bytes32 public asset; uint64 public strikeTime; int64 public strikePrice; Direction public direction; uint public buyinAmount; bool public resolved; int64 public finalPrice; Direction public result; SpeedMarketsAMM public speedMarketsAMM; uint256 public createdAt; /* ========== CONSTRUCTOR ========== */ bool public initialized = false; function initialize(InitParams calldata params) external { require(!initialized, "Speed market already initialized"); initialized = true; speedMarketsAMM = SpeedMarketsAMM(params._speedMarketsAMM); user = params._user; asset = params._asset; strikeTime = params._strikeTime; strikePrice = params._strikePrice; direction = params._direction; buyinAmount = params._buyinAmount; speedMarketsAMM.sUSD().approve(params._speedMarketsAMM, type(uint256).max); createdAt = block.timestamp; } function resolve(int64 _finalPrice) external onlyAMM { require(!resolved, "already resolved"); require(block.timestamp > strikeTime, "not ready to be resolved"); resolved = true; finalPrice = _finalPrice; if (finalPrice < strikePrice) { result = Direction.Down; } else { result = Direction.Up; } if (direction == result) { speedMarketsAMM.sUSD().safeTransfer(user, speedMarketsAMM.sUSD().balanceOf(address(this))); } else { speedMarketsAMM.sUSD().safeTransfer(address(speedMarketsAMM), speedMarketsAMM.sUSD().balanceOf(address(this))); } emit Resolved(finalPrice, result, direction == result); } function isUserWinner() external view returns (bool) { return resolved && (direction == result); } modifier onlyAMM() { require(msg.sender == address(speedMarketsAMM), "only the AMM may perform these methods"); _; } event Resolved(int64 finalPrice, Direction result, bool userIsWinner); }
// 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: Apache-2.0 pragma solidity ^0.8.0; /// @title IPythEvents contains the events that Pyth contract emits. /// @dev This interface can be used for listening to the updates for off-chain and testing purposes. interface IPythEvents { /// @dev Emitted when the price feed with `id` has received a fresh update. /// @param id The Pyth Price Feed ID. /// @param publishTime Publish time of the given price update. /// @param price Price of the given price update. /// @param conf Confidence interval of the given price update. event PriceFeedUpdate( bytes32 indexed id, uint64 publishTime, int64 price, uint64 conf ); /// @dev Emitted when a batch price update is processed successfully. /// @param chainId ID of the source chain that the batch price update comes from. /// @param sequenceNumber Sequence number of the batch price update. event BatchPriceFeedUpdate(uint16 chainId, uint64 sequenceNumber); }
{ "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
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_whitelistAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"_flag","type":"bool"}],"name":"AddedIntoWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_minBuyinAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maxBuyinAmount","type":"uint256"}],"name":"AmountsChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"strikeTime","type":"uint256"},{"indexed":false,"internalType":"int64","name":"strikePrice","type":"int64"},{"indexed":false,"internalType":"enum SpeedMarket.Direction","name":"direction","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"buyinAmount","type":"uint256"}],"name":"MarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"enum SpeedMarket.Direction","name":"result","type":"uint8"},{"indexed":false,"internalType":"bool","name":"userIsWinner","type":"bool"}],"name":"MarketResolved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"mastercopy","type":"address"}],"name":"MastercopyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","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":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"pythId","type":"bytes32"}],"name":"SetAssetToPythID","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_lpFee","type":"uint256"}],"name":"SetLPFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"_maxRiskPerAsset","type":"uint256"}],"name":"SetMaxRiskPerAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"_maxRiskPerAssetAndDirection","type":"uint256"}],"name":"SetMaxRiskPerAssetAndDirection","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maximumPriceDelay","type":"uint256"}],"name":"SetMaximumPriceDelay","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maximumPriceDelayForResolving","type":"uint256"}],"name":"SetMaximumPriceDelayForResolving","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":"_pyth","type":"address"}],"name":"SetPyth","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_safeBox","type":"address"},{"indexed":false,"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"}],"name":"SetSafeBoxParams","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_stakingThales","type":"address"}],"name":"SetStakingThales","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"bool","name":"_supported","type":"bool"}],"name":"SetSupportedAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_minimalTimeToMaturity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_maximalTimeToMaturity","type":"uint256"}],"name":"TimesChanged","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"activeMarkets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"activeMarketsPerUser","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_whitelistAddress","type":"address"},{"internalType":"bool","name":"_flag","type":"bool"}],"name":"addToWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"assetToPythId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"canResolveMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint64","name":"strikeTime","type":"uint64"},{"internalType":"enum SpeedMarket.Direction","name":"direction","type":"uint8"},{"internalType":"uint256","name":"buyinAmount","type":"uint256"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"createNewMarket","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint64","name":"delta","type":"uint64"},{"internalType":"enum SpeedMarket.Direction","name":"direction","type":"uint8"},{"internalType":"uint256","name":"buyinAmount","type":"uint256"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"createNewMarketWithDelta","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint64","name":"strikeTime","type":"uint64"},{"internalType":"enum SpeedMarket.Direction","name":"direction","type":"uint8"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"bool","name":"isEth","type":"bool"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"createNewMarketWithDifferentCollateral","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint64","name":"delta","type":"uint64"},{"internalType":"enum SpeedMarket.Direction","name":"direction","type":"uint8"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"collateralAmount","type":"uint256"},{"internalType":"bool","name":"isEth","type":"bool"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"createNewMarketWithDifferentCollateralAndDelta","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"currentRiskPerAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"enum SpeedMarket.Direction","name":"","type":"uint8"}],"name":"currentRiskPerAssetAndDirection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"}],"name":"getDirectionalRiskPerAsset","outputs":[{"components":[{"internalType":"enum SpeedMarket.Direction","name":"direction","type":"uint8"},{"internalType":"uint256","name":"current","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"internalType":"struct SpeedMarketsAMM.Risk[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"marketsArray","type":"address[]"}],"name":"getMarketsData","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint64","name":"strikeTime","type":"uint64"},{"internalType":"int64","name":"strikePrice","type":"int64"},{"internalType":"enum SpeedMarket.Direction","name":"direction","type":"uint8"},{"internalType":"uint256","name":"buyinAmount","type":"uint256"},{"internalType":"bool","name":"resolved","type":"bool"},{"internalType":"int64","name":"finalPrice","type":"int64"},{"internalType":"enum SpeedMarket.Direction","name":"result","type":"uint8"},{"internalType":"bool","name":"isUserWinner","type":"bool"},{"internalType":"uint256","name":"createdAt","type":"uint256"}],"internalType":"struct SpeedMarketsAMM.MarketData[]","name":"","type":"tuple[]"}],"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":"contract IPyth","name":"_pyth","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"candidate","type":"address"}],"name":"isActiveMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"candidate","type":"address"}],"name":"isKnownMarket","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"maturedMarkets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"maturedMarketsPerUser","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBuyinAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"maxRiskPerAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"enum SpeedMarket.Direction","name":"","type":"uint8"}],"name":"maxRiskPerAssetAndDirection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximalTimeToMaturity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumPriceDelay","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumPriceDelayForResolving","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBuyinAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimalTimeToMaturity","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":[],"name":"numActiveMarkets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"numActiveMarketsPerUser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numMaturedMarkets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"numMaturedMarketsPerUser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","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":"pyth","outputs":[{"internalType":"contract IPyth","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referrals","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"}],"name":"resolveMarket","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_market","type":"address"},{"internalType":"int64","name":"_finalPrice","type":"int64"}],"name":"resolveMarketManually","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"markets","type":"address[]"},{"internalType":"int64[]","name":"finalPrices","type":"int64[]"}],"name":"resolveMarketManuallyBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"markets","type":"address[]"},{"internalType":"bytes[]","name":"priceUpdateData","type":"bytes[]"}],"name":"resolveMarketsBatch","outputs":[],"stateMutability":"payable","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":[],"name":"safeBoxImpact","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minBuyinAmount","type":"uint256"},{"internalType":"uint256","name":"_maxBuyinAmount","type":"uint256"}],"name":"setAmounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"bytes32","name":"pythId","type":"bytes32"}],"name":"setAssetToPythID","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lpFee","type":"uint256"}],"name":"setLPFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_mastercopy","type":"address"}],"name":"setMastercopy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint256","name":"_maxRiskPerAsset","type":"uint256"}],"name":"setMaxRiskPerAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint256","name":"_maxRiskPerAssetAndDirection","type":"uint256"}],"name":"setMaxRiskPerAssetAndDirection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_maximumPriceDelay","type":"uint64"}],"name":"setMaximumPriceDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_maximumPriceDelayForResolving","type":"uint64"}],"name":"setMaximumPriceDelayForResolving","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":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pyth","type":"address"}],"name":"setPyth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_referrals","type":"address"}],"name":"setReferrals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_safeBox","type":"address"},{"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"}],"name":"setSafeBoxParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingThales","type":"address"}],"name":"setStakingThales","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"bool","name":"_supported","type":"bool"}],"name":"setSupportedAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minimalTimeToMaturity","type":"uint256"},{"internalType":"uint256","name":"_maximalTimeToMaturity","type":"uint256"}],"name":"setTimes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"speedMarketMastercopy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingThales","outputs":[{"internalType":"contract IStakingThales","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"supportedAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50615ae080620000216000396000f3fe6080604052600436106104105760003560e01c80639324cac71161021e578063ce87e2ee11610123578063e60a4d25116100ab578063ee22fd6f1161007a578063ee22fd6f14610cb8578063f8291d2b14610cd8578063f8335cde14610cf8578063f98d06f014610d18578063fd8a8cc614610d3857600080fd5b8063e60a4d2514610c36578063e62b888914610c63578063e73efc9b14610c83578063ebc7977214610ca357600080fd5b8063d69fb668116100f2578063d69fb66814610b85578063d8a4e37314610b9b578063deada50914610bae578063e11f951d14610bce578063e396ed2614610c0657600080fd5b8063ce87e2ee14610b05578063cf898ca914610b25578063d17ecac514610b45578063d3dc753914610b6557600080fd5b8063ac60c486116101a6578063bce5b7bf11610175578063bce5b7bf14610a4b578063bd47a9b814610a6b578063c0c53b8b14610a98578063c3b83f5f14610ab8578063c453180214610ad857600080fd5b8063ac60c486146109cd578063af71af6e146109e2578063b240eb4d14610a18578063bc93233f14610a2b57600080fd5b80639f293fb1116101ed5780639f293fb11461090e5780639fc427031461093b578063a201b3071461095b578063a3a2adf01461099a578063a8da1a17146109ad57600080fd5b80639324cac71461088d578063983234b6146108ad57806399c18e7e146108cd5780639a618c0f146108ee57600080fd5b80633e7ad1de11610324578063704ce43e116102ac5780637de926d11161027b5780637de926d1146107f15780637f8525821461081157806389c6318d146108315780638da5cb5b1461085157806391b4ded91461087757600080fd5b8063704ce43e1461078657806372855a6e1461079c57806379ba5097146107bc5780637a1e0aa8146107d157600080fd5b806353cb6a5e116102f357806353cb6a5e146107035780635403f80f146107235780635c975abb1461073957806368666b8b146107535780636ec38a4e1461076657600080fd5b80633e7ad1de1461065f57806348663e951461067557806348db54a8146106ad57806353a47bb7146106e357600080fd5b806314527f3a116103a75780631ca7415c116103765780631ca7415c146105bf5780631d477b33146105ec5780631f50899b146105ff578063224348361461061f5780632c43dc831461063f57600080fd5b806314527f3a1461054c5780631627540c1461056c57806316c38b3c1461058c57806317b94eac146105ac57600080fd5b80630dde1ff1116103e35780630dde1ff1146104c757806312039b6d146104e957806312aa38331461051657806313af40351461052c57600080fd5b806302610c501461041557806305bfdfd41461043957806306c933d81461047157806307b53bb4146104b1575b600080fd5b34801561042157600080fd5b506006545b6040519081526020015b60405180910390f35b34801561044557600080fd5b50610426610454366004615143565b601e60209081526000928352604080842090915290825290205481565b34801561047d57600080fd5b506104a161048c366004614db6565b601b6020526000908152604090205460ff1681565b6040519015158152602001610430565b3480156104bd57600080fd5b5061042660135481565b3480156104d357600080fd5b506104e76104e2366004615122565b610d58565b005b3480156104f557600080fd5b50610509610504366004615315565b610dc2565b60405161043091906154bc565b34801561052257600080fd5b5061042660125481565b34801561053857600080fd5b506104e7610547366004614db6565b610df2565b34801561055857600080fd5b506104a1610567366004614db6565b610f32565b34801561057857600080fd5b506104e7610587366004614db6565b611043565b34801561059857600080fd5b506104e76105a7366004615096565b611099565b6104e76105ba366004614dee565b61110f565b3480156105cb57600080fd5b506105df6105da3660046150ce565b611187565b604051610430919061565f565b6104e76105fa366004615167565b6114ee565b34801561060b57600080fd5b506104e761061a366004614db6565b61156a565b34801561062b57600080fd5b506104e761063a366004615122565b6115c0565b34801561064b57600080fd5b506104e761065a366004614f59565b611608565b34801561066b57600080fd5b5061042660105481565b34801561068157600080fd5b50600e54610695906001600160a01b031681565b6040516001600160a01b039091168152602001610430565b3480156106b957600080fd5b506104266106c8366004614db6565b6001600160a01b03166000908152601a602052604090205490565b3480156106ef57600080fd5b50600154610695906001600160a01b031681565b34801561070f57600080fd5b506104e761071e3660046150ce565b611735565b34801561072f57600080fd5b5061042660115481565b34801561074557600080fd5b506003546104a19060ff1681565b6104e7610761366004615219565b611772565b34801561077257600080fd5b506104a1610781366004614db6565b611806565b34801561079257600080fd5b50610426600d5481565b3480156107a857600080fd5b506104e76107b7366004615342565b611813565b3480156107c857600080fd5b506104e7611879565b3480156107dd57600080fd5b506104e76107ec366004614eef565b611976565b3480156107fd57600080fd5b506104e761080c3660046150fe565b6119d7565b34801561081d57600080fd5b506104e761082c366004614db6565b611a31565b34801561083d57600080fd5b5061050961084c366004615122565b611a87565b34801561085d57600080fd5b50600054610695906201000090046001600160a01b031681565b34801561088357600080fd5b5061042660025481565b34801561089957600080fd5b50600a54610695906001600160a01b031681565b3480156108b957600080fd5b506104e76108c8366004615122565b611a95565b3480156108d957600080fd5b50601c546104a190600160a01b900460ff1681565b3480156108fa57600080fd5b50601c54610695906001600160a01b031681565b34801561091a57600080fd5b5061092e610929366004614f1a565b611add565b604051610430919061558e565b34801561094757600080fd5b50610509610956366004615315565b6123f6565b34801561096757600080fd5b5060175461098290600160a01b90046001600160401b031681565b6040516001600160401b039091168152602001610430565b6104e76109a8366004614f59565b61241c565b3480156109b957600080fd5b506104e76109c8366004614ec2565b6125ae565b3480156109d957600080fd5b50600854610426565b3480156109ee57600080fd5b506104266109fd366004614db6565b6001600160a01b031660009081526019602052604090205490565b6104e7610a26366004615219565b612616565b348015610a3757600080fd5b506104e7610a46366004614e40565b612665565b348015610a5757600080fd5b506104e7610a66366004614db6565b612709565b348015610a7757600080fd5b50610426610a863660046150ce565b60166020526000908152604090205481565b348015610aa457600080fd5b506104e7610ab3366004614e78565b612789565b348015610ac457600080fd5b506104e7610ad3366004614db6565b612885565b348015610ae457600080fd5b50610426610af33660046150ce565b60146020526000908152604090205481565b348015610b1157600080fd5b50600b54610695906001600160a01b031681565b348015610b3157600080fd5b50601f54610982906001600160401b031681565b348015610b5157600080fd5b506104e7610b60366004615342565b61299e565b348015610b7157600080fd5b50602154610695906001600160a01b031681565b348015610b9157600080fd5b50610426600c5481565b6104e7610ba9366004615167565b6129f5565b348015610bba57600080fd5b506104e7610bc9366004615122565b612a56565b348015610bda57600080fd5b50610426610be9366004615143565b601d60209081526000928352604080842090915290825290205481565b348015610c1257600080fd5b506104a1610c213660046150ce565b600f6020526000908152604090205460ff1681565b348015610c4257600080fd5b50610426610c513660046150ce565b60156020526000908152604090205481565b348015610c6f57600080fd5b506104a1610c7e366004614db6565b612aa6565b348015610c8f57600080fd5b50610509610c9e366004615122565b612ac4565b348015610caf57600080fd5b506104e7612ad2565b348015610cc457600080fd5b506104e7610cd3366004614db6565b612b30565b348015610ce457600080fd5b506104e7610cf3366004614e40565b612b86565b348015610d0457600080fd5b506104e7610d13366004615122565b612bf3565b348015610d2457600080fd5b50601754610695906001600160a01b031681565b348015610d4457600080fd5b50601854610695906001600160a01b031681565b610d60612c43565b6000828152601d602090815260408083208380528252808320849055600183529182902083905581518481529081018390527f66e57984531cf3acb9c9e88511daf994910e4d99d05689bf8938517203d8a6d591015b60405180910390a15050565b6001600160a01b0381166000908152601960205260409020606090610de8908585612cbd565b90505b9392505050565b6001600160a01b038116610e4d5760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff1615610eb95760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b6064820152608401610e44565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b6000610f3f600683612e01565b8015610fc3575042826001600160a01b03166351d8044f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f8057600080fd5b505afa158015610f94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb8919061535e565b6001600160401b0316105b801561103d5750816001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561100357600080fd5b505afa158015611017573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103b91906150b2565b155b92915050565b61104b612c43565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610f27565b6110a1612c43565b60035460ff16151581151514156110b55750565b6003805460ff191682151590811790915560ff16156110d357426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001610f27565b50565b6001600460008282546111229190615885565b909155505060045460035460ff161561114d5760405162461bcd60e51b8152600401610e44906156c5565b6111608461115b848661591e565b612e83565b60045481146111815760405162461bcd60e51b8152600401610e4490615722565b50505050565b604080516002808252606080830184529260009291906020830190803683370190505090506000816000815181106111cf57634e487b7160e01b600052603260045260246000fd5b602002602001019060018111156111f657634e487b7160e01b600052602160045260246000fd5b9081600181111561121757634e487b7160e01b600052602160045260246000fd5b8152505060018160018151811061123e57634e487b7160e01b600052603260045260246000fd5b6020026020010190600181111561126557634e487b7160e01b600052602160045260246000fd5b9081600181111561128657634e487b7160e01b600052602160045260246000fd5b81525050600081516001600160401b038111156112b357634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561130957816020015b6112f66040805160608101909152806000815260200160008152602001600081525090565b8152602001906001900390816112d15790505b50905060005b82518110156114e657600083828151811061133a57634e487b7160e01b600052603260045260246000fd5b602002602001015190508083838151811061136557634e487b7160e01b600052603260045260246000fd5b602002602001015160000190600181111561139057634e487b7160e01b600052602160045260246000fd5b908160018111156113b157634e487b7160e01b600052602160045260246000fd5b9052506000868152601e60205260408120908260018111156113e357634e487b7160e01b600052602160045260246000fd5b600181111561140257634e487b7160e01b600052602160045260246000fd5b81526020019081526020016000205483838151811061143157634e487b7160e01b600052603260045260246000fd5b60200260200101516020018181525050601d6000878152602001908152602001600020600082600181111561147657634e487b7160e01b600052602160045260246000fd5b600181111561149557634e487b7160e01b600052602160045260246000fd5b8152602001908152602001600020548383815181106114c457634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040015250806114de81615a0f565b91505061130f565b509392505050565b6001600460008282546115019190615885565b909155505060045460035460ff161561152c5760405162461bcd60e51b8152600401610e44906156c5565b61153d8a8a8a8a8a8a8a8a8a613252565b600454811461155e5760405162461bcd60e51b8152600401610e4490615722565b50505050505050505050565b611572612c43565b600b80546001600160a01b0319166001600160a01b0383169081179091556040519081527fe9f33266a193fa018a5d4acaa6790d296c2344e2edcb5647eee2a01575d39b3690602001610f27565b6115c8612c43565b6010829055601181905560408051838152602081018390527f909dd93796494a5dfcffa9fe02c36571a83843bb5aec8750c61be1a238e8e6bf9101610db6565b336000908152601b602052604090205460ff166116625760405162461bcd60e51b815260206004820152601860248201527714995cdbdb1d995c881b9bdd081dda1a5d195b1a5cdd195960421b6044820152606401610e44565b60005b8381101561172e576116a585858381811061169057634e487b7160e01b600052603260045260246000fd5b90506020020160208101906105679190614db6565b1561171c5761171c8585838181106116cd57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906116e29190614db6565b84848481811061170257634e487b7160e01b600052603260045260246000fd5b905060200201602081019061171791906152c2565b6132de565b8061172681615a0f565b915050611665565b5050505050565b61173d612c43565b600d8190556040518181527fd46d2e06354316808045dc5836e4f7aefa845b689f4f7c09dc3688bb838f076890602001610f27565b6001600460008282546117859190615885565b909155505060045460035460ff16156117b05760405162461bcd60e51b8152600401610e44906156c5565b6117db886117c76001600160401b038a1642615885565b88886117d3888a61591e565b60018861332f565b60045481146117fc5760405162461bcd60e51b8152600401610e4490615722565b5050505050505050565b600061103d600683612e01565b61181b612c43565b6017805467ffffffffffffffff60a01b1916600160a01b6001600160401b038481168202929092179283905560405192041681527f266dc49207101e7265f8b227655e15c3aa08140fd50edc0ae1bdb50103d3c29d90602001610f27565b6001546001600160a01b031633146118f15760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b6064820152608401610e44565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b61197e612c43565b600e80546001600160a01b0319166001600160a01b038416908117909155600c82905560408051918252602082018390527fa1a8623472ca4e2879372be60dfd1ff0675778e49f7379eedd98ca57cf36b21a9101610db6565b6119df612c43565b6000828152600f6020908152604091829020805460ff19168415159081179091558251858152918201527f6af8d0ea20290a2d8dcbb43a77926d5993cd89bac2c6a72cd7813c4eacc2124b9101610db6565b611a39612c43565b601880546001600160a01b0319166001600160a01b0383169081179091556040519081527f475a2179b9b6a155e7ba3f46a461beb6798279b265026364944e38dcb4bacafe90602001610f27565b6060610deb60088484612cbd565b611a9d612c43565b6012829055601381905560408051838152602081018390527f2bed2865fdf57e3bd99997a5acdf1689597ce1c9c6b9f75d75454761aa357fb69101610db6565b60606000826001600160401b03811115611b0757634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611b8e57816020015b604080516101608101825260008082526020808301829052928201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082018190526101408201528252600019909201910181611b255790505b50905060005b838110156114e6576000858583818110611bbe57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611bd39190614db6565b9050806001600160a01b0316634f8632ba6040518163ffffffff1660e01b815260040160206040518083038186803b158015611c0e57600080fd5b505afa158015611c22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c469190614dd2565b838381518110611c6657634e487b7160e01b600052603260045260246000fd5b6020026020010151600001906001600160a01b031690816001600160a01b031681525050806001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b158015611cc357600080fd5b505afa158015611cd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfb91906150e6565b838381518110611d1b57634e487b7160e01b600052603260045260246000fd5b60200260200101516020018181525050806001600160a01b03166351d8044f6040518163ffffffff1660e01b815260040160206040518083038186803b158015611d6457600080fd5b505afa158015611d78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d9c919061535e565b838381518110611dbc57634e487b7160e01b600052603260045260246000fd5b6020026020010151604001906001600160401b031690816001600160401b031681525050806001600160a01b031663c52987cf6040518163ffffffff1660e01b815260040160206040518083038186803b158015611e1957600080fd5b505afa158015611e2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5191906152de565b838381518110611e7157634e487b7160e01b600052603260045260246000fd5b60200260200101516060019060070b908160070b81525050806001600160a01b031663645539ed6040518163ffffffff1660e01b815260040160206040518083038186803b158015611ec257600080fd5b505afa158015611ed6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611efa91906152a6565b838381518110611f1a57634e487b7160e01b600052603260045260246000fd5b6020026020010151608001906001811115611f4557634e487b7160e01b600052602160045260246000fd5b90816001811115611f6657634e487b7160e01b600052602160045260246000fd5b81525050806001600160a01b0316631fcc8bb26040518163ffffffff1660e01b815260040160206040518083038186803b158015611fa357600080fd5b505afa158015611fb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fdb91906150e6565b838381518110611ffb57634e487b7160e01b600052603260045260246000fd5b602002602001015160a0018181525050806001600160a01b0316633f6fa6556040518163ffffffff1660e01b815260040160206040518083038186803b15801561204457600080fd5b505afa158015612058573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207c91906150b2565b83838151811061209c57634e487b7160e01b600052603260045260246000fd5b602002602001015160c0019015159081151581525050806001600160a01b031663a6b513ee6040518163ffffffff1660e01b815260040160206040518083038186803b1580156120eb57600080fd5b505afa1580156120ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061212391906152de565b83838151811061214357634e487b7160e01b600052603260045260246000fd5b602002602001015160e0019060070b908160070b81525050806001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b15801561219457600080fd5b505afa1580156121a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121cc91906152a6565b8383815181106121ec57634e487b7160e01b600052603260045260246000fd5b60200260200101516101000190600181111561221857634e487b7160e01b600052602160045260246000fd5b9081600181111561223957634e487b7160e01b600052602160045260246000fd5b81525050806001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b15801561227657600080fd5b505afa15801561228a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ae91906150b2565b8383815181106122ce57634e487b7160e01b600052603260045260246000fd5b60200260200101516101200190151590811515815250506020600087878581811061230957634e487b7160e01b600052603260045260246000fd5b905060200201602081019061231e9190614db6565b6001600160a01b0316815260208101919091526040016000205460ff16156123e357806001600160a01b031663cf09e0d06040518163ffffffff1660e01b815260040160206040518083038186803b15801561237957600080fd5b505afa15801561238d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b191906150e6565b8383815181106123d157634e487b7160e01b600052603260045260246000fd5b60200260200101516101400181815250505b50806123ee81615a0f565b915050611b94565b6001600160a01b0381166000908152601a60205260409020606090610de8908585612cbd565b60016004600082825461242f9190615885565b909155505060045460035460ff161561245a5760405162461bcd60e51b8152600401610e44906156c5565b60005b8481101561258c57600086868381811061248757634e487b7160e01b600052603260045260246000fd5b905060200201602081019061249c9190614db6565b90506124a781610f32565b1561257957604080516001808252818301909252600091816020015b60608152602001906001900390816124c35790505090508585848181106124fa57634e487b7160e01b600052603260045260246000fd5b905060200281019061250c91906157c6565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092018290525085518694509092501515905061256257634e487b7160e01b600052603260045260246000fd5b60200260200101819052506125778282612e83565b505b508061258481615a0f565b91505061245d565b50600454811461172e5760405162461bcd60e51b8152600401610e4490615722565b336000908152601b602052604090205460ff166126085760405162461bcd60e51b815260206004820152601860248201527714995cdbdb1d995c881b9bdd081dda1a5d195b1a5cdd195960421b6044820152606401610e44565b61261282826132de565b5050565b6001600460008282546126299190615885565b909155505060045460035460ff16156126545760405162461bcd60e51b8152600401610e44906156c5565b6117db888888886117d3888a61591e565b61266d612c43565b6001600160a01b038216158015906126a457506001600160a01b0382166000908152601b602052604090205460ff16151581151514155b6126ad57600080fd5b6001600160a01b0382166000818152601b6020908152604091829020805460ff19168515159081179091558251938452908301527f58d7a3ccc34541e162fcfc87b84be7b78c34d1e1e7f15de6e4dd67d0fe70aecd9101610db6565b612711612c43565b6001600160a01b0381166127675760405162461bcd60e51b815260206004820152601760248201527f43616e206e6f74206265207a65726f20616464726573730000000000000000006044820152606401610e44565b602180546001600160a01b0319166001600160a01b0392909216919091179055565b600054610100900460ff166127a45760005460ff16156127a8565b303b155b61280b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610e44565b600054610100900460ff1615801561282d576000805461ffff19166101011790555b61283684610df2565b61283e612ad2565b600a80546001600160a01b038086166001600160a01b03199283161790925560178054928516929091169190911790558015611181576000805461ff001916905550505050565b61288d612c43565b6001600160a01b0381166128d55760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610e44565b600154600160a81b900460ff16156129255760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b6044820152606401610e44565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610f27565b6129a6612c43565b601f805467ffffffffffffffff19166001600160401b0383169081179091556040519081527fc4dd90acfe53336def98012b1269c669192d5de5a7ff2ac8b56abc75bbb816c390602001610f27565b600160046000828254612a089190615885565b909155505060045460035460ff1615612a335760405162461bcd60e51b8152600401610e44906156c5565b61153d8a612a4a6001600160401b038c1642615885565b8a8a8a8a8a8a8a613252565b612a5e612c43565b60008281526014602090815260409182902083905581518481529081018390527f14c8e58ca065b6a9b79f3f4a2a548d35e2a01d09c345a1238714c3847fcd377c9101610db6565b6000612ab3600683612e01565b8061103d575061103d600883612e01565b6060610deb60068484612cbd565b60055460ff1615612b1b5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b6044820152606401610e44565b6005805460ff19166001908117909155600455565b612b38612c43565b601780546001600160a01b0319166001600160a01b0383169081179091556040519081527f49ce9340ac24a9b23918fd1daaa7e264303b79b17a3e08d2f94b8b24c681c10f90602001610f27565b612b8e612c43565b601c80546001600160a01b0384166001600160a81b03199091168117600160a01b841515908102919091179092556040805191825260208201929092527f7ed317979883517e462a7e4dbfde66a0b837cf91abff298bfa10d966a545298c9101610db6565b612bfb612c43565b60008281526016602090815260409182902083905581518481529081018390527fbe9b5564f6075c4b92cab3a707053c7e8828f045a5d233c3157bc3407cb009639101610db6565b6000546201000090046001600160a01b03163314612cbb5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b6064820152608401610e44565b565b60606000612ccb8385615885565b8554909150811115612cdb575083545b838111612cf8575050604080516000815260208101909152610deb565b6000612d048583615907565b90506000816001600160401b03811115612d2e57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612d57578160200160208202803683370190505b50905060005b82811015612df65787612d708883615885565b81548110612d8e57634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b0316828281518110612dcc57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015280612dee81615a0f565b915050612d5d565b509695505050505050565b8154600090612e125750600061103d565b6001600160a01b038216600090815260018401602052604090205480151580612e7b5750826001600160a01b031684600001600081548110612e6457634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316145b949350505050565b612e8c82610f32565b612eca5760405162461bcd60e51b815260206004820152600f60248201526e43616e206e6f74207265736f6c766560881b6044820152606401610e44565b60175460405163d47eed4560e01b81526000916001600160a01b03169063d47eed4590612efb908590600401615509565b60206040518083038186803b158015612f1357600080fd5b505afa158015612f27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f4b91906150e6565b604080516001808252818301909252919250600091906020808301908036833701905050905060166000856001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b158015612fae57600080fd5b505afa158015612fc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fe691906150e6565b8152602001908152602001600020548160008151811061301657634e487b7160e01b600052603260045260246000fd5b6020026020010181815250506000601760009054906101000a90046001600160a01b03166001600160a01b0316634716e9c5848685896001600160a01b03166351d8044f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561308457600080fd5b505afa158015613098573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130bc919061535e565b601f60009054906101000a90046001600160401b03168b6001600160a01b03166351d8044f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561310b57600080fd5b505afa15801561311f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613143919061535e565b61314d919061589d565b6040518663ffffffff1660e01b815260040161316c949392919061551c565b6000604051808303818588803b15801561318557600080fd5b505af1158015613199573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f191682016040526131c29190810190614fc1565b90506000816000815181106131e757634e487b7160e01b600052603260045260246000fd5b60200260200101516020015190506000816000015160070b1361323c5760405162461bcd60e51b815260206004820152600d60248201526c696e76616c696420707269636560981b6044820152606401610e44565b61324a868260000151613a09565b505050505050565b601c54600160a01b900460ff166132b65760405162461bcd60e51b815260206004820152602260248201527f4d756c7469636f6c6c61746572616c206f6e72616d70206e6f7420656e61626c604482015261195960f21b6064820152608401610e44565b60006132c3858585613ffe565b905061155e8a8a8a846132d68b8d61591e565b60008861332f565b6132e782610f32565b6133255760405162461bcd60e51b815260206004820152600f60248201526e43616e206e6f74207265736f6c766560881b6044820152606401610e44565b6126128282613a09565b6001600160a01b038116156133a45760215460405163bbddaca360e01b81526001600160a01b0383811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b15801561338b57600080fd5b505af115801561339f573d6000803e3d6000fd5b505050505b6000878152600f602052604090205460ff166133fb5760405162461bcd60e51b8152602060048201526016602482015275105cdcd95d081a5cc81b9bdd081cdd5c1c1bdc9d195960521b6044820152606401610e44565b601254841015801561340f57506013548411155b6134515760405162461bcd60e51b81526020600482015260136024820152721ddc9bdb99c8189d5e481a5b88185b5bdd5b9d606a1b6044820152606401610e44565b60105461345e9042615885565b866001600160401b031610156134d35760405162461bcd60e51b815260206004820152603460248201527f74696d652068617320746f20626520696e2074686520667574757265202b206d604482015273696e696d616c54696d65546f4d6174757269747960601b6064820152608401610e44565b6011546134e09042615885565b866001600160401b031611156135385760405162461bcd60e51b815260206004820152601c60248201527f74696d6520746f6f2066617220696e746f2074686520667574757265000000006044820152606401610e44565b6135438786866141fc565b60175460405163d47eed4560e01b81526000916001600160a01b03169063d47eed4590613574908790600401615509565b60206040518083038186803b15801561358c57600080fd5b505afa1580156135a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135c491906150e6565b601754604051631df3cbc560e31b81529192506001600160a01b03169063ef9e5e289083906135f7908890600401615509565b6000604051808303818588803b15801561361057600080fd5b505af1158015613624573d6000803e3d6000fd5b505060175460008c8152601660205260408082205490516331d98b3f60e01b815260048101919091529094506001600160a01b0390911692506331d98b3f915060240160806040518083038186803b15801561367f57600080fd5b505afa158015613693573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136b791906152fa565b601754606082015191925042916136de91600160a01b90046001600160401b031690615885565b1180156136f257506000816000015160070b135b61372c5760405162461bcd60e51b815260206004820152600b60248201526a5374616c6520707269636560a81b6044820152606401610e44565b8315613791576000670de0b6b3a7640000600d54600c54670de0b6b3a76400006137569190615885565b6137609190615885565b61376a90896158e8565b61377491906158c8565b600a5490915061378f906001600160a01b031633308461463c565b505b600b546000906137a9906001600160a01b03166146a7565b6040805160e0810182523081523360208201529081018c90526001600160401b038b166060820152835160070b60808201529091506001600160a01b03821690639db5d4039060a081018b600181111561381357634e487b7160e01b600052602160045260246000fd5b81526020018a8152506040518263ffffffff1660e01b81526004016138389190615759565b600060405180830381600087803b15801561385257600080fd5b505af1158015613866573d6000803e3d6000fd5b5050505061388e8188600261387b91906158e8565b600a546001600160a01b03169190614744565b600061389a3389614779565b600e54600c549192506138dd916001600160a01b03909116908390670de0b6b3a7640000906138c9908d6158e8565b6138d391906158c8565b61387b9190615907565b6138e8600683614935565b3360009081526019602052604090206139019083614935565b6018546001600160a01b031615613977576018546040516302c7739b60e01b8152336004820152602481018a90526001600160a01b03909116906302c7739b90604401600060405180830381600087803b15801561395e57600080fd5b505af1158015613972573d6000803e3d6000fd5b505050505b600160206000846001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507f4fb5dd0be05638074eabb1b37a9bdf9ab8cbad8d83c7bce9298aca16de5b79c382338d8d87600001518e8e6040516139f49796959493929190615438565b60405180910390a15050505050505050505050565b604051631f67c49160e01b8152600782900b60048201526001600160a01b03831690631f67c49190602401600060405180830381600087803b158015613a4e57600080fd5b505af1158015613a62573d6000803e3d6000fd5b50505050613a7a82600661498790919063ffffffff16565b613a85600883614935565b6000826001600160a01b0316634f8632ba6040518163ffffffff1660e01b815260040160206040518083038186803b158015613ac057600080fd5b505afa158015613ad4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613af89190614dd2565b6001600160a01b0381166000908152601960205260409020909150613b1d9084612e01565b15613b44576001600160a01b0381166000908152601960205260409020613b449084614987565b6001600160a01b0381166000908152601a60205260409020613b669084614935565b6000836001600160a01b03166338d52e0f6040518163ffffffff1660e01b815260040160206040518083038186803b158015613ba157600080fd5b505afa158015613bb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bd991906150e6565b90506000846001600160a01b0316631fcc8bb26040518163ffffffff1660e01b815260040160206040518083038186803b158015613c1657600080fd5b505afa158015613c2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c4e91906150e6565b90506000856001600160a01b031663645539ed6040518163ffffffff1660e01b815260040160206040518083038186803b158015613c8b57600080fd5b505afa158015613c9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613cc391906152a6565b6000848152601e60205260408120919250839190836001811115613cf757634e487b7160e01b600052602160045260246000fd5b6001811115613d1657634e487b7160e01b600052602160045260246000fd5b8152602001908152602001600020541115613da2576000838152601e602052604081208391836001811115613d5b57634e487b7160e01b600052602160045260246000fd5b6001811115613d7a57634e487b7160e01b600052602160045260246000fd5b81526020019081526020016000206000828254613d979190615907565b90915550613e029050565b6000838152601e6020526040812081836001811115613dd157634e487b7160e01b600052602160045260246000fd5b6001811115613df057634e487b7160e01b600052602160045260246000fd5b81526020810191909152604001600020555b856001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b158015613e3b57600080fd5b505afa158015613e4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613e7391906150b2565b613edb57613e828260026158e8565b6000848152601560205260409020541115613ecb57613ea28260026158e8565b60008481526015602052604081208054909190613ec0908490615907565b90915550613edb9050565b6000838152601560205260408120555b7f738ac9ca76b7fd50246d5acdc827b2852e656ed2c287d6538e57b046f0ecf64b86876001600160a01b031663653721476040518163ffffffff1660e01b815260040160206040518083038186803b158015613f3657600080fd5b505afa158015613f4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f6e91906152a6565b886001600160a01b0316633a2c1e556040518163ffffffff1660e01b815260040160206040518083038186803b158015613fa757600080fd5b505afa158015613fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fdf91906150b2565b604051613fee9392919061548f565b60405180910390a1505050505050565b600080821561408e57601c54604051631321b85d60e01b8152600481018690526001600160a01b0390911690631321b85d9086906024016020604051808303818588803b15801561404e57600080fd5b505af1158015614062573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061408791906150e6565b90506141b3565b6140a36001600160a01b03861633308761463c565b601c5460405163095ea7b360e01b81526001600160a01b039182166004820152602481018690529086169063095ea7b390604401602060405180830381600087803b1580156140f157600080fd5b505af1158015614105573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061412991906150b2565b50601c546040516322ceb11360e21b81526001600160a01b0387811660048301526024820187905290911690638b3ac44c90604401602060405180830381600087803b15801561417857600080fd5b505af115801561418c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141b091906150e6565b90505b670de0b6b3a7640000600d54600c54670de0b6b3a76400006141d59190615907565b6141df9190615907565b6141e990836158e8565b6141f391906158c8565b95945050505050565b6000838152601560205260408120805483929061421a908490615885565b9091555050600083815260146020908152604080832054601590925290912054111561427a5760405162461bcd60e51b815260206004820152600f60248201526e13d24818d85c08189c995858da1959608a1b6044820152606401610e44565b60008083600181111561429d57634e487b7160e01b600052602160045260246000fd5b146142a95760006142ac565b60015b6000858152601e60205260408120919250839182918460018111156142e157634e487b7160e01b600052602160045260246000fd5b600181111561430057634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054111561438c576000858152601e60205260408120849184600181111561434557634e487b7160e01b600052602160045260246000fd5b600181111561436457634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002060008282546143819190615907565b909155506144589050565b6000858152601e60205260408120908360018111156143bb57634e487b7160e01b600052602160045260246000fd5b60018111156143da57634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054836143f49190615907565b6000868152601e60205260408120919250908184600181111561442757634e487b7160e01b600052602160045260246000fd5b600181111561444657634e487b7160e01b600052602160045260246000fd5b81526020810191909152604001600020555b6000858152601e602052604081209083600181111561448757634e487b7160e01b600052602160045260246000fd5b60018111156144a657634e487b7160e01b600052602160045260246000fd5b8152602001908152602001600020546000141561172e576000858152601e6020526040812082918660018111156144ed57634e487b7160e01b600052602160045260246000fd5b600181111561450c57634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002060008282546145299190615885565b90915550506000858152601d602052604081209085600181111561455d57634e487b7160e01b600052602160045260246000fd5b600181111561457c57634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054601e600087815260200190815260200160002060008660018111156145c057634e487b7160e01b600052602160045260246000fd5b60018111156145df57634e487b7160e01b600052602160045260246000fd5b815260200190815260200160002054111561172e5760405162461bcd60e51b815260206004820152601b60248201527f5269736b2070657220646972656374696f6e20657863656564656400000000006044820152606401610e44565b6040516001600160a01b03808516602483015283166044820152606481018290526111819085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152614b0a565b6000604051733d602d80600a3d3981f3363d3d373d3d3d363d7360601b81528260601b60148201526e5af43d82803e903d91602b57fd5bf360881b60288201526037816000f09150506001600160a01b03811661473f5760405162461bcd60e51b8152602060048201526016602482015275115490cc4c4d8dce8818dc99585d194819985a5b195960521b6044820152606401610e44565b919050565b6040516001600160a01b03831660248201526044810182905261477490849063a9059cbb60e01b90606401614670565b505050565b6021546000906001600160a01b03161561103d57602154604051639ca423b360e01b81526001600160a01b0385811660048301526000921690639ca423b39060240160206040518083038186803b1580156147d357600080fd5b505afa1580156147e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061480b9190614dd2565b90506001600160a01b0381161561492e5760215460405163c7d1f5f160e01b81526001600160a01b038381166004830152600092169063c7d1f5f19060240160206040518083038186803b15801561486257600080fd5b505afa158015614876573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061489a91906150e6565b9050801561492c57670de0b6b3a76400006148b582866158e8565b6148bf91906158c8565b600a549093506148d9906001600160a01b03168385614744565b604080516001600160a01b03808516825287166020820152908101849052606081018590527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a15b505b5092915050565b61493f8282612e01565b6126125781546001600160a01b038216600081815260018086016020908152604083208590559084018655858252902090910180546001600160a01b03191690911790555050565b6149918282612e01565b6149d35760405162461bcd60e51b815260206004820152601360248201527222b632b6b2b73a103737ba1034b71039b2ba1760691b6044820152606401610e44565b6001600160a01b03811660009081526001808401602052604082205484549092916149fd91615907565b9050808214614aa5576000846000018281548110614a2b57634e487b7160e01b600052603260045260246000fd5b60009182526020909120015485546001600160a01b0390911691508190869085908110614a6857634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b0394851617905592909116815260018601909152604090208290555b8354849080614ac457634e487b7160e01b600052603160045260246000fd5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b0394909416815260019490940190925250506040812055565b6000614b5f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614bdc9092919063ffffffff16565b8051909150156147745780806020019051810190614b7d91906150b2565b6147745760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610e44565b6060610de8848460008585843b614c355760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610e44565b600080866001600160a01b03168587604051614c51919061541c565b60006040518083038185875af1925050503d8060008114614c8e576040519150601f19603f3d011682016040523d82523d6000602084013e614c93565b606091505b5091509150614ca3828286614cae565b979650505050505050565b60608315614cbd575081610deb565b825115614ccd5782518084602001fd5b8160405162461bcd60e51b8152600401610e4491906156b2565b60008083601f840112614cf8578182fd5b5081356001600160401b03811115614d0e578182fd5b6020830191508360208260051b8501011115614d2957600080fd5b9250929050565b600060808284031215614d41578081fd5b604051608081018181106001600160401b0382111715614d6357614d63615a40565b80604052508091508251614d7681615a86565b81526020830151614d8681615a95565b60208201526040830151600381900b8114614da057600080fd5b6040820152606092830151920191909152919050565b600060208284031215614dc7578081fd5b8135610deb81615a56565b600060208284031215614de3578081fd5b8151610deb81615a56565b600080600060408486031215614e02578182fd5b8335614e0d81615a56565b925060208401356001600160401b03811115614e27578283fd5b614e3386828701614ce7565b9497909650939450505050565b60008060408385031215614e52578182fd5b8235614e5d81615a56565b91506020830135614e6d81615a6b565b809150509250929050565b600080600060608486031215614e8c578081fd5b8335614e9781615a56565b92506020840135614ea781615a56565b91506040840135614eb781615a56565b809150509250925092565b60008060408385031215614ed4578182fd5b8235614edf81615a56565b91506020830135614e6d81615a86565b60008060408385031215614f01578182fd5b8235614f0c81615a56565b946020939093013593505050565b60008060208385031215614f2c578182fd5b82356001600160401b03811115614f41578283fd5b614f4d85828601614ce7565b90969095509350505050565b60008060008060408587031215614f6e578182fd5b84356001600160401b0380821115614f84578384fd5b614f9088838901614ce7565b90965094506020870135915080821115614fa8578384fd5b50614fb587828801614ce7565b95989497509550505050565b60006020808385031215614fd3578182fd5b82516001600160401b03811115614fe8578283fd5b8301601f81018513614ff8578283fd5b805161500b61500682615862565b615832565b81815283810190838501610120808502860187018a101561502a578788fd5b8795505b848610156150885780828b031215615044578788fd5b61504c61580a565b8251815261505c8b898501614d30565b8882015261506d8b60a08501614d30565b6040820152845260019590950194928601929081019061502e565b509098975050505050505050565b6000602082840312156150a7578081fd5b8135610deb81615a6b565b6000602082840312156150c3578081fd5b8151610deb81615a6b565b6000602082840312156150df578081fd5b5035919050565b6000602082840312156150f7578081fd5b5051919050565b60008060408385031215615110578182fd5b823591506020830135614e6d81615a6b565b60008060408385031215615134578182fd5b50508035926020909101359150565b60008060408385031215615155578182fd5b823591506020830135614e6d81615a79565b60008060008060008060008060006101008a8c031215615185578687fd5b8935985060208a013561519781615a95565b975060408a01356151a781615a79565b965060608a01356001600160401b038111156151c1578586fd5b6151cd8c828d01614ce7565b90975095505060808a01356151e181615a56565b935060a08a0135925060c08a01356151f881615a6b565b915060e08a013561520881615a56565b809150509295985092959850929598565b600080600080600080600060c0888a031215615233578081fd5b87359650602088013561524581615a95565b9550604088013561525581615a79565b94506060880135935060808801356001600160401b03811115615276578182fd5b6152828a828b01614ce7565b90945092505060a088013561529681615a56565b8091505092959891949750929550565b6000602082840312156152b7578081fd5b8151610deb81615a79565b6000602082840312156152d3578081fd5b8135610deb81615a86565b6000602082840312156152ef578081fd5b8151610deb81615a86565b60006080828403121561530b578081fd5b610deb8383614d30565b600080600060608486031215615329578081fd5b83359250602084013591506040840135614eb781615a56565b600060208284031215615353578081fd5b8135610deb81615a95565b60006020828403121561536f578081fd5b8151610deb81615a95565b600081518084526020808501808196508360051b81019150828601855b858110156153c15782840389526153af8483516153ce565b98850198935090840190600101615397565b5091979650505050505050565b600081518084526153e68160208601602086016159e3565b601f01601f19169290920160200192915050565b6002811061541857634e487b7160e01b600052602160045260246000fd5b9052565b6000825161542e8184602087016159e3565b9190910192915050565b6001600160a01b03888116825287166020820152604081018690526001600160401b0385166060820152600784900b608082015260e0810161547d60a08301856153fa565b8260c083015298975050505050505050565b6001600160a01b0384168152606081016154ac60208301856153fa565b8215156040830152949350505050565b6020808252825182820181905260009190848201906040850190845b818110156154fd5783516001600160a01b0316835292840192918401916001016154d8565b50909695505050505050565b602081526000610deb602083018461537a565b60808152600061552f608083018761537a565b828103602084810191909152865180835287820192820190845b8181101561556557845183529383019391830191600101615549565b50506001600160401b039687166040860152949095166060909301929092525090949350505050565b602080825282518282018190526000919060409081850190868401855b828110156153c157815180516001600160a01b031685528681015187860152858101516001600160401b03168686015260608082015160070b908601526080808201516155fa828801826153fa565b505060a0818101519086015260c08082015115159086015260e08082015160070b9086015261010080820151615632828801826153fa565b505061012081810151151590860152610140908101519085015261016090930192908501906001016155ab565b602080825282518282018190526000919060409081850190868401855b828110156153c15781516156918582516153fa565b8087015185880152850151858501526060909301929085019060010161567c565b602081526000610deb60208301846153ce565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600060e08201905060018060a01b0380845116835280602085015116602084015250604083015160408301526001600160401b036060840151166060830152608083015160070b608083015260a08301516157b760a08401826153fa565b5060c092830151919092015290565b6000808335601e198436030181126157dc578283fd5b8301803591506001600160401b038211156157f5578283fd5b602001915036819003821315614d2957600080fd5b604051606081016001600160401b038111828210171561582c5761582c615a40565b60405290565b604051601f8201601f191681016001600160401b038111828210171561585a5761585a615a40565b604052919050565b60006001600160401b0382111561587b5761587b615a40565b5060051b60200190565b6000821982111561589857615898615a2a565b500190565b60006001600160401b038083168185168083038211156158bf576158bf615a2a565b01949350505050565b6000826158e357634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561590257615902615a2a565b500290565b60008282101561591957615919615a2a565b500390565b600061592c61500684615862565b808482526020808301925084368760051b87011115615949578485fd5b845b878110156159d75781356001600160401b0380821115615969578788fd5b90880190601f368184011261597c578889fd5b82358281111561598e5761598e615a40565b61599f818301601f19168801615832565b925080835236878286010111156159b457898afd5b80878501888501378201860189905250865250938201939082019060010161594b565b50919695505050505050565b60005b838110156159fe5781810151838201526020016159e6565b838111156111815750506000910152565b6000600019821415615a2357615a23615a2a565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461110c57600080fd5b801515811461110c57600080fd5b6002811061110c57600080fd5b8060070b811461110c57600080fd5b6001600160401b038116811461110c57600080fdfea26469706673582212200fca1da49d9cfc1ea58007f77515290e03786b5aeeab3f01a6ce00e16d40e30564736f6c63430008040033
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.