Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
ThalesAMM
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"; // 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 "../interfaces/IPriceFeed.sol"; import "../interfaces/IThalesAMMUtils.sol"; import "../interfaces/IPositionalMarket.sol"; import "../interfaces/IPositionalMarketManager.sol"; import "../interfaces/IPosition.sol"; import "../interfaces/IStakingThales.sol"; import "../interfaces/IReferrals.sol"; import "../interfaces/ICurveSUSD.sol"; /// @title An AMM using BlackScholes odds algorithm to provide liqudidity for traders of UP or DOWN positions contract ThalesAMM is Initializable, ProxyOwned, ProxyPausable, ProxyReentrancyGuard { using SafeERC20Upgradeable for IERC20Upgradeable; struct PriceImpactParams { uint amount; uint balanceOtherSide; uint balancePosition; uint balanceOtherSideAfter; uint balancePositionAfter; uint availableToBuyFromAMM; } struct DiscountParams { uint balancePosition; uint balanceOtherSide; uint amount; uint availableToBuyFromAMM; } struct BuyPriceImpactParams { address market; Position position; uint amount; uint _availableToBuyFromAMM; uint _availableToBuyFromAMMOtherSide; uint basePrice; } uint private constant ONE = 1e18; uint private constant ONE_PERCENT = 1e16; IPriceFeed public priceFeed; IERC20Upgradeable public sUSD; address public manager; uint public capPerMarket; uint public min_spread; uint public max_spread; mapping(bytes32 => uint) public impliedVolatilityPerAsset; uint public minimalTimeLeftToMaturity; enum Position { Up, Down } mapping(address => uint) public spentOnMarket; address public safeBox; uint public safeBoxImpact; IStakingThales public stakingThales; uint public minSupportedPrice; uint public maxSupportedPrice; mapping(bytes32 => uint) private _capPerAsset; mapping(address => bool) public whitelistedAddresses; address public referrals; uint public referrerFee; ICurveSUSD public curveSUSD; address public usdc; address public usdt; address public dai; bool public curveOnrampEnabled; uint public maxAllowedPegSlippagePercentage; IThalesAMMUtils ammUtils; int private constant ONE_INT = 1e18; int private constant ONE_PERCENT_INT = 1e16; mapping(address => uint) public safeBoxFeePerAddress; mapping(address => uint) public min_spreadPerAddress; function initialize( address _owner, IPriceFeed _priceFeed, IERC20Upgradeable _sUSD, uint _capPerMarket, address _deciMath, uint _min_spread, uint _max_spread, uint _minimalTimeLeftToMaturity ) public initializer { setOwner(_owner); initNonReentrant(); priceFeed = _priceFeed; sUSD = _sUSD; capPerMarket = _capPerMarket; min_spread = _min_spread; max_spread = _max_spread; minimalTimeLeftToMaturity = _minimalTimeLeftToMaturity; } // READ public methods /// @notice get how many positions of a certain type (UP or DOWN) can be bought from the given positional market /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @return _available how many positions of that type can be bought function availableToBuyFromAMM(address market, Position position) public view returns (uint _available) { if (isMarketInAMMTrading(market)) { uint basePrice = price(market, position); if (basePrice > 0) { basePrice = basePrice < minSupportedPrice ? minSupportedPrice : basePrice; _available = _availableToBuyFromAMMWithBasePrice(market, position, basePrice, false); } } } /// @notice get a quote in sUSD on how much the trader would need to pay to buy the amount of UP or DOWN positions /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @param amount number of positions to buy with 18 decimals /// @return _quote in sUSD on how much the trader would need to pay to buy the amount of UP or DOWN positions function buyFromAmmQuote( address market, Position position, uint amount ) public view returns (uint _quote) { uint basePrice = price(market, position); uint basePriceOtherSide = ONE - basePrice; if (basePrice > 0) { basePrice = basePrice < minSupportedPrice ? minSupportedPrice : basePrice; _quote = _buyFromAmmQuoteWithBasePrice(market, position, amount, basePrice, basePriceOtherSide, safeBoxImpact); } } /// @notice get a quote in the collateral of choice (USDC, USDT or DAI) on how much the trader would need to pay to buy the amount of UP or DOWN positions /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @param amount number of positions to buy with 18 decimals /// @param collateral USDT, USDC or DAI address /// @return collateralQuote a quote in collateral on how much the trader would need to pay to buy the amount of UP or DOWN positions /// @return sUSDToPay a quote in sUSD on how much the trader would need to pay to buy the amount of UP or DOWN positions function buyFromAmmQuoteWithDifferentCollateral( address market, Position position, uint amount, address collateral ) public view returns (uint collateralQuote, uint sUSDToPay) { int128 curveIndex = _mapCollateralToCurveIndex(collateral); if (curveIndex > 0 && curveOnrampEnabled) { sUSDToPay = buyFromAmmQuote(market, position, amount); //cant get a quote on how much collateral is needed from curve for sUSD, //so rather get how much of collateral you get for the sUSD quote and add 0.2% to that collateralQuote = (curveSUSD.get_dy_underlying(0, curveIndex, sUSDToPay) * (ONE + (ONE_PERCENT / 5))) / ONE; } } /// @notice get the skew impact applied to that side of the market on buy /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @param amount number of positions to buy with 18 decimals /// @return _priceImpact the skew impact applied to that side of the market function buyPriceImpact( address market, Position position, uint amount ) public view returns (int _priceImpact) { Position positionOtherSide = position == Position.Up ? Position.Down : Position.Up; uint basePrice = price(market, position); uint basePriceOtherSide = ONE - basePrice; basePrice = basePrice < minSupportedPrice ? minSupportedPrice : basePrice; uint _availableToBuyFromAMM = _availableToBuyFromAMMWithBasePrice(market, position, basePrice, true); uint _availableToBuyFromAMMOtherSide = _availableToBuyFromAMMWithBasePrice( market, positionOtherSide, basePriceOtherSide, true ); if (amount > 0 && amount <= _availableToBuyFromAMM) { _priceImpact = _buyPriceImpact( BuyPriceImpactParams( market, position, amount, _availableToBuyFromAMM, _availableToBuyFromAMMOtherSide, basePrice ) ); } } /// @notice get how many positions of a certain type (UP or DOWN) can be sold for the given positional market /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @return _available how many positions of that type can be sold function availableToSellToAMM(address market, Position position) public view returns (uint _available) { if (isMarketInAMMTrading(market)) { uint basePrice = price(market, position); basePrice = basePrice > maxSupportedPrice ? maxSupportedPrice : basePrice; _available = _availableToSellToAMM(market, position, basePrice); } } /// @notice get a quote in sUSD on how much the trader would receive as payment to sell the amount of UP or DOWN positions /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @param amount number of positions to buy with 18 decimals /// @return _quote in sUSD on how much the trader would receive as payment to sell the amount of UP or DOWN positions function sellToAmmQuote( address market, Position position, uint amount ) public view returns (uint _quote) { uint basePrice = price(market, position); basePrice = basePrice > maxSupportedPrice ? maxSupportedPrice : basePrice; uint _available = _availableToSellToAMM(market, position, basePrice); _quote = _sellToAmmQuote(market, position, amount, basePrice, _available); } /// @notice get the skew impact applied to that side of the market on sell /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @param amount number of positions to buy with 18 decimals /// @return _impact the skew impact applied to that side of the market function sellPriceImpact( address market, Position position, uint amount ) public view returns (uint _impact) { uint _available = availableToSellToAMM(market, position); if (amount <= _available) { _impact = _sellPriceImpact(market, position, amount, _available); } } /// @notice get the base price (odds) of a given side of the market /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @return priceToReturn the base price (odds) of a given side of the market function price(address market, Position position) public view returns (uint priceToReturn) { if (isMarketInAMMTrading(market)) { // add price calculation IPositionalMarket marketContract = IPositionalMarket(market); (uint maturity, ) = marketContract.times(); uint timeLeftToMaturity = maturity - block.timestamp; uint timeLeftToMaturityInDays = (timeLeftToMaturity * ONE) / 86400; uint oraclePrice = marketContract.oraclePrice(); (bytes32 key, uint strikePrice, ) = marketContract.getOracleDetails(); priceToReturn = ammUtils.calculateOdds(oraclePrice, strikePrice, timeLeftToMaturityInDays, impliedVolatilityPerAsset[key]) / 1e2; if (position == Position.Down) { priceToReturn = ONE - priceToReturn; } } } /// @notice check if market is supported by the AMM /// @param market positional market known to manager /// @return isTrading is market supported by the AMM function isMarketInAMMTrading(address market) public view returns (bool isTrading) { if (IPositionalMarketManager(manager).isActiveMarket(market)) { IPositionalMarket marketContract = IPositionalMarket(market); (bytes32 key, , ) = marketContract.getOracleDetails(); (uint maturity, ) = marketContract.times(); if (!(impliedVolatilityPerAsset[key] == 0 || maturity < block.timestamp)) { uint timeLeftToMaturity = maturity - block.timestamp; isTrading = timeLeftToMaturity > minimalTimeLeftToMaturity; } } } /// @notice check if AMM market has exercisable positions on a given market /// @param market positional market known to manager /// @return _canExercise if AMM market has exercisable positions on a given market function canExerciseMaturedMarket(address market) public view returns (bool _canExercise) { if ( IPositionalMarketManager(manager).isKnownMarket(market) && (IPositionalMarket(market).phase() == IPositionalMarket.Phase.Maturity) ) { (IPosition up, IPosition down) = IPositionalMarket(market).getOptions(); _canExercise = (up.getBalanceOf(address(this)) > 0) || (down.getBalanceOf(address(this)) > 0); } } /// @notice get the maximum risk in sUSD the AMM will offer on a certain asset on an individual market /// @param asset e.g. ETH, BTC, SNX.... /// @return _cap the maximum risk in sUSD the AMM will offer on a certain asset on an individual market function getCapPerAsset(bytes32 asset) public view returns (uint _cap) { if (!(priceFeed.rateForCurrency(asset) == 0)) { _cap = _capPerAsset[asset] == 0 ? capPerMarket : _capPerAsset[asset]; } } // write methods /// @notice buy positions of the defined type of a given market from the AMM coming from a referrer /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @param amount how many positions /// @param expectedPayout how much does the buyer expect to pay (retrieved via quote) /// @param additionalSlippage how much of a slippage on the sUSD expectedPayout will the buyer accept /// @param _referrer who referred the buyer to Thales function buyFromAMMWithReferrer( address market, Position position, uint amount, uint expectedPayout, uint additionalSlippage, address _referrer ) public nonReentrant notPaused returns (uint) { if (_referrer != address(0)) { IReferrals(referrals).setReferrer(_referrer, msg.sender); } return _buyFromAMM(market, position, amount, expectedPayout, additionalSlippage, true, 0); } /// @notice buy positions of the defined type of a given market from the AMM with USDC, USDT or DAI /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @param amount how many positions /// @param expectedPayout how much does the buyer expect to pay (retrieved via quote) /// @param collateral USDC, USDT or DAI /// @param additionalSlippage how much of a slippage on the sUSD expectedPayout will the buyer accept /// @param _referrer who referred the buyer to Thales function buyFromAMMWithDifferentCollateralAndReferrer( address market, Position position, uint amount, uint expectedPayout, uint additionalSlippage, address collateral, address _referrer ) public nonReentrant notPaused returns (uint) { if (_referrer != address(0)) { IReferrals(referrals).setReferrer(_referrer, msg.sender); } int128 curveIndex = _mapCollateralToCurveIndex(collateral); require(curveIndex > 0 && curveOnrampEnabled, "unsupported collateral"); (uint collateralQuote, uint susdQuote) = buyFromAmmQuoteWithDifferentCollateral( market, position, amount, collateral ); uint transformedCollateralForPegCheck = collateral == usdc || collateral == usdt ? collateralQuote * (1e12) : collateralQuote; require( maxAllowedPegSlippagePercentage > 0 && transformedCollateralForPegCheck >= (susdQuote * (ONE - (maxAllowedPegSlippagePercentage))) / ONE, "Amount below max allowed peg slippage" ); require((collateralQuote * ONE) / (expectedPayout) <= (ONE + additionalSlippage), "Slippage too high!"); IERC20Upgradeable collateralToken = IERC20Upgradeable(collateral); collateralToken.safeTransferFrom(msg.sender, address(this), collateralQuote); curveSUSD.exchange_underlying(curveIndex, 0, collateralQuote, susdQuote); return _buyFromAMM(market, position, amount, susdQuote, additionalSlippage, false, susdQuote); } /// @notice buy positions of the defined type of a given market from the AMM /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @param amount how many positions /// @param expectedPayout how much does the buyer expect to pay (retrieved via quote) /// @param additionalSlippage how much of a slippage on the sUSD expectedPayout will the buyer accept function buyFromAMM( address market, Position position, uint amount, uint expectedPayout, uint additionalSlippage ) public nonReentrant notPaused returns (uint) { return _buyFromAMM(market, position, amount, expectedPayout, additionalSlippage, true, 0); } /// @notice sell positions of the defined type of a given market to the AMM /// @param market a Positional Market known to Market Manager /// @param position UP or DOWN /// @param amount how many positions /// @param expectedPayout how much does the seller to receive(retrieved via quote) /// @param additionalSlippage how much of a slippage on the sUSD expectedPayout will the seller accept function sellToAMM( address market, Position position, uint amount, uint expectedPayout, uint additionalSlippage ) public nonReentrant notPaused returns (uint) { require(isMarketInAMMTrading(market), "Market is not in Trading phase"); uint basePrice = price(market, position); basePrice = basePrice > maxSupportedPrice ? maxSupportedPrice : basePrice; uint availableToSellToAMMATM = _availableToSellToAMM(market, position, basePrice); require(availableToSellToAMMATM > 0 && amount <= availableToSellToAMMATM, "Not enough liquidity."); uint pricePaid = _sellToAmmQuote(market, position, amount, basePrice, availableToSellToAMMATM); require((expectedPayout * ONE) / (pricePaid) <= (ONE + (additionalSlippage)), "Slippage too high"); address target = _getTarget(market, position); //transfer options first to have max burn available IERC20Upgradeable(target).safeTransferFrom(msg.sender, address(this), amount); uint sUSDFromBurning = IPositionalMarketManager(manager).transformCollateral( IPositionalMarket(market).getMaximumBurnable(address(this)) ); if (sUSDFromBurning > 0) { IPositionalMarket(market).burnOptionsMaximum(); } sUSD.safeTransfer(msg.sender, pricePaid); if (address(stakingThales) != address(0)) { stakingThales.updateVolume(msg.sender, pricePaid); } _updateSpentOnMarketOnSell(market, pricePaid, sUSDFromBurning, msg.sender); emit SoldToAMM(msg.sender, market, position, amount, pricePaid, address(sUSD), target); return pricePaid; } /// @notice Exercise positions on a certain matured market to retrieve sUSD /// @param market a Positional Market known to Market Manager function exerciseMaturedMarket(address market) external { require(canExerciseMaturedMarket(market), "Can't exercise that market"); IPositionalMarket(market).exerciseOptions(); } /// @notice Retrieve sUSD from the contract /// @param account whom to send the sUSD /// @param amount how much sUSD to retrieve function retrieveSUSDAmount(address payable account, uint amount) external onlyOwner { sUSD.safeTransfer(account, amount); } // Internal function _availableToSellToAMM( address market, Position position, uint basePrice ) internal view returns (uint _available) { uint sell_max_price = _getSellMaxPrice(basePrice); if (sell_max_price > 0) { (IPosition up, IPosition down) = IPositionalMarket(market).getOptions(); uint balanceOfTheOtherSide = position == Position.Up ? down.getBalanceOf(address(this)) : up.getBalanceOf(address(this)); // any balanceOfTheOtherSide will be burned to get sUSD back (1 to 1) at the `willPay` cost uint willPay = (balanceOfTheOtherSide * (sell_max_price)) / ONE; uint capWithBalance = _capOnMarket(market) + (balanceOfTheOtherSide); if (capWithBalance >= (spentOnMarket[market] + willPay)) { uint usdAvailable = capWithBalance - (spentOnMarket[market]) - (willPay); _available = (usdAvailable / (sell_max_price)) * ONE + (balanceOfTheOtherSide); } } } function _sellToAmmQuote( address market, Position position, uint amount, uint basePrice, uint _available ) internal view returns (uint _quote) { if (amount <= _available) { basePrice = basePrice - (min_spread); uint tempAmount = (amount * ((basePrice * (ONE - (_sellPriceImpact(market, position, amount, _available)))) / ONE)) / ONE; uint returnQuote = (tempAmount * (ONE - (safeBoxImpact))) / ONE; _quote = IPositionalMarketManager(manager).transformCollateral(returnQuote); } } function _availableToBuyFromAMMWithBasePrice( address market, Position position, uint basePrice, bool skipCheck ) internal view returns (uint availableAmount) { if (skipCheck || basePrice < maxSupportedPrice) { basePrice = basePrice + min_spread; if (basePrice < ONE) { uint discountedPrice = (basePrice * (ONE - max_spread / 4)) / ONE; uint balance = _balanceOfPositionOnMarket(market, position); uint additionalBufferFromSelling = (balance * discountedPrice) / ONE; if ((_capOnMarket(market) + additionalBufferFromSelling) > spentOnMarket[market]) { uint availableUntilCapSUSD = _capOnMarket(market) + additionalBufferFromSelling - spentOnMarket[market]; if (availableUntilCapSUSD > _capOnMarket(market)) { availableUntilCapSUSD = _capOnMarket(market); } uint midImpactPriceIncrease = ((ONE - basePrice) * (max_spread / 2)) / ONE; if ((basePrice + midImpactPriceIncrease) < ONE) { uint divider_price = ONE - (basePrice + midImpactPriceIncrease); availableAmount = balance + ((availableUntilCapSUSD * ONE) / divider_price); } } } } } function _buyFromAmmQuoteWithBasePrice( address market, Position position, uint amount, uint basePrice, uint basePriceOtherSide, uint safeBoxImpactForCaller ) internal view returns (uint returnQuote) { uint _available = _availableToBuyFromAMMWithBasePrice(market, position, basePrice, false); uint _availableOtherSide = _availableToBuyFromAMMWithBasePrice( market, position == Position.Up ? Position.Down : Position.Up, basePriceOtherSide, true ); if (amount <= _available) { int tempQuote; int skewImpact = _buyPriceImpact( BuyPriceImpactParams(market, position, amount, _available, _availableOtherSide, basePrice) ); basePrice = basePrice + (min_spreadPerAddress[msg.sender] > 0 ? min_spreadPerAddress[msg.sender] : min_spread); if (skewImpact >= 0) { int impactPrice = ((ONE_INT - int(basePrice)) * skewImpact) / ONE_INT; // add 2% to the price increase to avoid edge cases on the extremes impactPrice = (impactPrice * (ONE_INT + (ONE_PERCENT_INT * 2))) / ONE_INT; tempQuote = (int(amount) * (int(basePrice) + impactPrice)) / ONE_INT; } else { tempQuote = ((int(amount)) * ((int(basePrice) * (ONE_INT + skewImpact)) / ONE_INT)) / ONE_INT; } tempQuote = (tempQuote * (ONE_INT + (int(safeBoxImpactForCaller)))) / ONE_INT; returnQuote = IPositionalMarketManager(manager).transformCollateral(uint(tempQuote)); } } function _getSellMaxPrice(uint basePrice) internal view returns (uint sell_max_price) { if (basePrice > minSupportedPrice) { sell_max_price = ((basePrice - min_spread) * (ONE - (max_spread / (2)))) / ONE; } } function _buyFromAMM( address market, Position position, uint amount, uint expectedPayout, uint additionalSlippage, bool sendSUSD, uint sUSDPaidCarried ) internal returns (uint sUSDPaid) { require(isMarketInAMMTrading(market), "Market is not in Trading phase"); sUSDPaid = sUSDPaidCarried; uint basePrice = price(market, position); uint basePriceOtherSide = ONE - basePrice; basePrice = basePrice < minSupportedPrice ? minSupportedPrice : basePrice; uint availableToBuyFromAMMatm = _availableToBuyFromAMMWithBasePrice(market, position, basePrice, false); require(amount > 0 && amount <= availableToBuyFromAMMatm, "Not enough liquidity."); if (sendSUSD) { sUSDPaid = _buyFromAmmQuoteWithBasePrice( market, position, amount, basePrice, basePriceOtherSide, safeBoxFeePerAddress[msg.sender] > 0 ? safeBoxFeePerAddress[msg.sender] : safeBoxImpact ); require((sUSDPaid * ONE) / (expectedPayout) <= (ONE + additionalSlippage), "Slippage too high"); sUSD.safeTransferFrom(msg.sender, address(this), sUSDPaid); } uint toMint = _getMintableAmount(market, position, amount); if (toMint > 0) { require( sUSD.balanceOf(address(this)) >= IPositionalMarketManager(manager).transformCollateral(toMint), "Not enough sUSD in contract." ); IPositionalMarket(market).mint(toMint); spentOnMarket[market] = spentOnMarket[market] + (toMint); } address target = _getTarget(market, position); IERC20Upgradeable(target).safeTransfer(msg.sender, amount); if (address(stakingThales) != address(0)) { stakingThales.updateVolume(msg.sender, sUSDPaid); } _updateSpentOnMarketOnBuy(market, sUSDPaid, msg.sender); if (amount > toMint) { uint discountedAmount = amount - toMint; uint paidForDiscountedAmount = (sUSDPaid * discountedAmount) / amount; emit BoughtWithDiscount(msg.sender, discountedAmount, paidForDiscountedAmount); } emit BoughtFromAmm(msg.sender, market, position, amount, sUSDPaid, address(sUSD), target); _handleInTheMoneyEvent(market, position, sUSDPaid, msg.sender); } function _handleInTheMoneyEvent( address market, Position position, uint sUSDPaid, address sender ) internal { (bytes32 key, uint strikePrice, ) = IPositionalMarket(market).getOracleDetails(); uint currentAssetPrice = priceFeed.rateForCurrency(key); bool inTheMoney = position == Position.Up ? currentAssetPrice >= strikePrice : currentAssetPrice < strikePrice; emit BoughtOptionType(msg.sender, sUSDPaid, inTheMoney); } function _getTarget(address market, Position position) internal view returns (address target) { (IPosition up, IPosition down) = IPositionalMarket(market).getOptions(); target = address(position == Position.Up ? up : down); } function _updateSpentOnMarketOnSell( address market, uint sUSDPaid, uint sUSDFromBurning, address seller ) internal { uint safeBoxShare = (sUSDPaid * ONE) / (ONE - (safeBoxImpact)) - (sUSDPaid); if (safeBoxImpact > 0) { sUSD.safeTransfer(safeBox, safeBoxShare); } else { safeBoxShare = 0; } spentOnMarket[market] = spentOnMarket[market] + (IPositionalMarketManager(manager).reverseTransformCollateral(sUSDPaid + (safeBoxShare))); if (spentOnMarket[market] <= IPositionalMarketManager(manager).reverseTransformCollateral(sUSDFromBurning)) { spentOnMarket[market] = 0; } else { spentOnMarket[market] = spentOnMarket[market] - (IPositionalMarketManager(manager).reverseTransformCollateral(sUSDFromBurning)); } if (referrerFee > 0 && referrals != address(0)) { uint referrerShare = (sUSDPaid * ONE) / (ONE - (referrerFee)) - (sUSDPaid); _handleReferrer(seller, referrerShare, sUSDPaid); } } function _updateSpentOnMarketOnBuy( address market, uint sUSDPaid, address buyer ) internal { uint safeBoxShare; if (safeBoxImpact > 0) { safeBoxShare = (sUSDPaid - (sUSDPaid * ONE) / (ONE + (safeBoxFeePerAddress[msg.sender] > 0 ? safeBoxFeePerAddress[msg.sender] : safeBoxImpact))); sUSD.safeTransfer(safeBox, safeBoxShare); } if ( spentOnMarket[market] <= IPositionalMarketManager(manager).reverseTransformCollateral(sUSDPaid - (safeBoxShare)) ) { spentOnMarket[market] = 0; } else { spentOnMarket[market] = spentOnMarket[market] - (IPositionalMarketManager(manager).reverseTransformCollateral(sUSDPaid - (safeBoxShare))); } if (referrerFee > 0 && referrals != address(0)) { uint referrerShare = sUSDPaid - ((sUSDPaid * ONE) / (ONE + (referrerFee))); _handleReferrer(buyer, referrerShare, sUSDPaid); } } function _buyPriceImpact(BuyPriceImpactParams memory params) internal view returns (int priceImpact) { if (params.basePrice >= minSupportedPrice && params.basePrice <= maxSupportedPrice) { (uint balancePosition, uint balanceOtherSide) = _balanceOfPositionsOnMarket(params.market, params.position); uint balancePositionAfter = balancePosition > params.amount ? balancePosition - params.amount : 0; uint balanceOtherSideAfter = balanceOtherSide + (balancePosition > params.amount ? 0 : (params.amount - balancePosition)); if (balancePositionAfter >= balanceOtherSideAfter) { priceImpact = _calculateDiscount( DiscountParams(balancePosition, balanceOtherSide, params.amount, params._availableToBuyFromAMMOtherSide) ); } else { if (params.amount > balancePosition && balancePosition > 0) { uint amountToBeMinted = params.amount - balancePosition; uint positiveSkew = _buyPriceImpactImbalancedSkew( PriceImpactParams( amountToBeMinted, balanceOtherSide + balancePosition, 0, balanceOtherSide + amountToBeMinted, 0, params._availableToBuyFromAMM - balancePosition ) ); uint pricePosition = price(params.market, params.position); uint priceOtherPosition = price( params.market, params.position == Position.Up ? Position.Down : Position.Up ); uint skew = (priceOtherPosition * positiveSkew) / pricePosition; int discount = _calculateDiscount( DiscountParams( balancePosition, balanceOtherSide, balancePosition, params._availableToBuyFromAMMOtherSide ) ); int discountBalance = int(balancePosition) * discount; int discountMinted = int(amountToBeMinted * skew); int amountInt = int(balancePosition + amountToBeMinted); priceImpact = (discountBalance + discountMinted) / amountInt; if (priceImpact > 0) { int numerator = int(pricePosition) * priceImpact; priceImpact = numerator / int(priceOtherPosition); } } else { priceImpact = int( _buyPriceImpactImbalancedSkew( PriceImpactParams( params.amount, balanceOtherSide, balancePosition, balanceOtherSideAfter, balancePositionAfter, params._availableToBuyFromAMM ) ) ); } } } } function _buyPriceImpactImbalancedSkew(PriceImpactParams memory params) internal view returns (uint) { uint maxPossibleSkew = params.balanceOtherSide + params.availableToBuyFromAMM - params.balancePosition; uint skew = params.balanceOtherSideAfter - (params.balancePositionAfter); uint newImpact = (max_spread * ((skew * ONE) / (maxPossibleSkew))) / ONE; if (params.balancePosition > 0) { uint newPriceForMintedOnes = newImpact / (2); uint tempMultiplier = (params.amount - params.balancePosition) * (newPriceForMintedOnes); return (tempMultiplier * ONE) / (params.amount) / ONE; } else { uint previousSkew = params.balanceOtherSide; uint previousImpact = (max_spread * ((previousSkew * ONE) / (maxPossibleSkew))) / ONE; return (newImpact + previousImpact) / (2); } } function _calculateDiscount(DiscountParams memory params) internal view returns (int) { uint currentBuyImpactOtherSide = _buyPriceImpactImbalancedSkew( PriceImpactParams( params.amount, params.balancePosition, params.balanceOtherSide, params.balanceOtherSide > ONE ? params.balancePosition : params.balancePosition + (ONE - params.balanceOtherSide), params.balanceOtherSide > ONE ? params.balanceOtherSide - ONE : 0, params.availableToBuyFromAMM ) ); uint startDiscount = currentBuyImpactOtherSide / 2; uint tempMultiplier = params.balancePosition - params.amount; uint finalDiscount = ((startDiscount / 2) * ((tempMultiplier * ONE) / params.balancePosition + ONE)) / ONE; return -int(finalDiscount); } function _handleReferrer( address buyer, uint referrerShare, uint volume ) internal { address referrer = IReferrals(referrals).referrals(buyer); if (referrer != address(0) && referrerFee > 0) { sUSD.safeTransfer(referrer, referrerShare); emit ReferrerPaid(referrer, buyer, referrerShare, volume); } } function _sellPriceImpact( address market, Position position, uint amount, uint available ) internal view returns (uint _sellImpact) { (uint _balancePosition, uint balanceOtherSide) = _balanceOfPositionsOnMarket(market, position); uint balancePositionAfter = _balancePosition > 0 ? _balancePosition + (amount) : balanceOtherSide > amount ? 0 : amount - (balanceOtherSide); uint balanceOtherSideAfter = balanceOtherSide > amount ? balanceOtherSide - (amount) : 0; if (!(balancePositionAfter < balanceOtherSideAfter)) { _sellImpact = _sellPriceImpactImbalancedSkew( amount, balanceOtherSide, _balancePosition, balanceOtherSideAfter, balancePositionAfter, available ); } } function _sellPriceImpactImbalancedSkew( uint amount, uint balanceOtherSide, uint _balancePosition, uint balanceOtherSideAfter, uint balancePositionAfter, uint available ) internal view returns (uint _sellImpactReturned) { uint maxPossibleSkew = _balancePosition + (available) - (balanceOtherSide); uint skew = balancePositionAfter - (balanceOtherSideAfter); uint newImpact = (max_spread * ((skew * ONE) / (maxPossibleSkew))) / ONE; if (balanceOtherSide > 0) { uint newPriceForMintedOnes = newImpact / (2); uint tempMultiplier = (amount - _balancePosition) * (newPriceForMintedOnes); _sellImpactReturned = tempMultiplier / (amount); } else { uint previousSkew = _balancePosition; uint previousImpact = (max_spread * ((previousSkew * ONE) / (maxPossibleSkew))) / ONE; _sellImpactReturned = (newImpact + previousImpact) / (2); } } function _getMintableAmount( address market, Position position, uint amount ) internal view returns (uint mintable) { uint availableInContract = _balanceOfPositionOnMarket(market, position); if (availableInContract < amount) { mintable = amount - availableInContract; } } function _balanceOfPositionOnMarket(address market, Position position) internal view returns (uint balance) { (IPosition up, IPosition down) = IPositionalMarket(market).getOptions(); balance = position == Position.Up ? up.getBalanceOf(address(this)) : down.getBalanceOf(address(this)); } function _balanceOfPositionsOnMarket(address market, Position position) internal view returns (uint balance, uint balanceOtherSide) { (IPosition up, IPosition down) = IPositionalMarket(market).getOptions(); balance = position == Position.Up ? up.getBalanceOf(address(this)) : down.getBalanceOf(address(this)); balanceOtherSide = position == Position.Up ? down.getBalanceOf(address(this)) : up.getBalanceOf(address(this)); } function _capOnMarket(address market) internal view returns (uint) { (bytes32 key, , ) = IPositionalMarket(market).getOracleDetails(); return getCapPerAsset(key); } function _mapCollateralToCurveIndex(address collateral) internal view returns (int128) { if (collateral == dai) { return 1; } if (collateral == usdc) { return 2; } if (collateral == usdt) { return 3; } return 0; } // setters /// @notice Updates contract parametars /// @param _minimalTimeLeftToMaturity how long till maturity will AMM support trading on a given market function setMinimalTimeLeftToMaturity(uint _minimalTimeLeftToMaturity) external onlyOwner { minimalTimeLeftToMaturity = _minimalTimeLeftToMaturity; emit SetMinimalTimeLeftToMaturity(_minimalTimeLeftToMaturity); } /// @notice Updates contract parametars /// @param _address which can update implied volatility /// @param enabled update if the address can set implied volatility function setWhitelistedAddress(address _address, bool enabled) external onlyOwner { whitelistedAddresses[_address] = enabled; } /// @notice Updates contract parametars /// @param _address which has a specific safe box fee /// @param newFee the fee function setSafeBoxFeePerAddress(address _address, uint newFee) external onlyOwner { safeBoxFeePerAddress[_address] = newFee; } /// @notice Updates contract parametars /// @param _address which has a specific min_spread fee /// @param newFee the fee function setMinSpreadPerAddress(address _address, uint newFee) external onlyOwner { min_spreadPerAddress[_address] = newFee; } /// @notice Updates contract parametars /// @param _minspread minimum spread applied to base price /// @param _maxspread maximum skew impact, e.g. if all UP positions are drained, skewImpact on that side = _maxspread function setMinMaxSpread(uint _minspread, uint _maxspread) external onlyOwner { min_spread = _minspread; max_spread = _maxspread; emit SetMinSpread(_minspread); emit SetMaxSpread(_maxspread); } /// @notice Updates contract parametars /// @param _safeBox where to send a fee reserved for protocol from each trade /// @param _safeBoxImpact how much is the SafeBoxFee function setSafeBoxData(address _safeBox, uint _safeBoxImpact) external onlyOwner { safeBoxImpact = _safeBoxImpact; safeBox = _safeBox; emit SetSafeBoxImpact(_safeBoxImpact); } /// @notice Updates contract parametars /// @param _minSupportedPrice whats the max price AMM supports, e.g. 10 cents /// @param _maxSupportedPrice whats the max price AMM supports, e.g. 90 cents /// @param _capPerMarket default amount the AMM will risk on markets, overrided by capPerAsset if existing function setMinMaxSupportedPriceAndCap( uint _minSupportedPrice, uint _maxSupportedPrice, uint _capPerMarket ) external onlyOwner { minSupportedPrice = _minSupportedPrice; maxSupportedPrice = _maxSupportedPrice; capPerMarket = _capPerMarket; emit SetMinMaxSupportedPriceCapPerMarket(_minSupportedPrice, _maxSupportedPrice, _capPerMarket); } /// @notice Updates contract parametars. Can be set by owner or whitelisted addresses. In the future try to get it as a feed from Chainlink. /// @param asset e.g. ETH, BTC, SNX... /// @param _impliedVolatility IV for BlackScholes function setImpliedVolatilityPerAsset(bytes32 asset, uint _impliedVolatility) external { require( whitelistedAddresses[msg.sender] || owner == msg.sender, "Only whitelisted addresses or owner can change IV!" ); require(_impliedVolatility > ONE * 10 && _impliedVolatility < ONE * 300, "IV outside min/max range!"); require(priceFeed.rateForCurrency(asset) != 0, "Asset has no price!"); impliedVolatilityPerAsset[asset] = _impliedVolatility; emit SetImpliedVolatilityPerAsset(asset, _impliedVolatility); } /// @notice Updates contract parametars /// @param _priceFeed contract from which we read prices, can be chainlink or twap /// @param _sUSD address of sUSD function setPriceFeedAndSUSD(IPriceFeed _priceFeed, IERC20Upgradeable _sUSD) external onlyOwner { priceFeed = _priceFeed; emit SetPriceFeed(address(_priceFeed)); sUSD = _sUSD; emit SetSUSD(address(sUSD)); } /// @notice Updates contract parametars /// @param _ammUtils address of AMMUtils function setAmmUtils(IThalesAMMUtils _ammUtils) external onlyOwner { ammUtils = _ammUtils; } /// @notice Updates contract parametars /// @param _stakingThales contract address for staking bonuses /// @param _referrals contract for referrals storage /// @param _referrerFee how much of a fee to pay to referrers function setStakingThalesAndReferrals( IStakingThales _stakingThales, address _referrals, uint _referrerFee ) external onlyOwner { stakingThales = _stakingThales; referrals = _referrals; referrerFee = _referrerFee; } /// @notice Updates contract parametars /// @param _manager Positional Market Manager contract function setPositionalMarketManager(address _manager) external onlyOwner { if (address(manager) != address(0)) { sUSD.approve(address(manager), 0); } manager = _manager; sUSD.approve(manager, type(uint256).max); emit SetPositionalMarketManager(_manager); } /// @notice Updates contract parametars /// @param _curveSUSD curve sUSD pool exchanger contract /// @param _dai DAI address /// @param _usdc USDC address /// @param _usdt USDT addresss /// @param _curveOnrampEnabled whether AMM supports curve onramp /// @param _maxAllowedPegSlippagePercentage maximum discount AMM accepts for sUSD purchases function setCurveSUSD( address _curveSUSD, address _dai, address _usdc, address _usdt, bool _curveOnrampEnabled, uint _maxAllowedPegSlippagePercentage ) external onlyOwner { curveSUSD = ICurveSUSD(_curveSUSD); dai = _dai; usdc = _usdc; usdt = _usdt; IERC20Upgradeable(dai).approve(_curveSUSD, type(uint256).max); IERC20Upgradeable(usdc).approve(_curveSUSD, type(uint256).max); IERC20Upgradeable(usdt).approve(_curveSUSD, type(uint256).max); // not needed unless selling into different collateral is enabled //sUSD.approve(_curveSUSD, type(uint256).max); curveOnrampEnabled = _curveOnrampEnabled; maxAllowedPegSlippagePercentage = _maxAllowedPegSlippagePercentage; } /// @notice Updates contract parametars /// @param asset e.g. ETH, BTC, SNX /// @param _cap how much risk can AMM take on markets for given asset function setCapPerAsset(bytes32 asset, uint _cap) external onlyOwner { _capPerAsset[asset] = _cap; emit SetCapPerAsset(asset, _cap); } // events event SoldToAMM( address seller, address market, Position position, uint amount, uint sUSDPaid, address susd, address asset ); event BoughtFromAmm( address buyer, address market, Position position, uint amount, uint sUSDPaid, address susd, address asset ); event BoughtWithDiscount(address buyer, uint amount, uint sUSDPaid); event BoughtOptionType(address buyer, uint sUSDPaid, bool inTheMoney); event SetPositionalMarketManager(address _manager); event SetSUSD(address sUSD); event SetPriceFeed(address _priceFeed); event SetImpliedVolatilityPerAsset(bytes32 asset, uint _impliedVolatility); event SetCapPerAsset(bytes32 asset, uint _cap); event SetMaxSpread(uint _spread); event SetMinSpread(uint _spread); event SetSafeBoxImpact(uint _safeBoxImpact); event SetSafeBox(address _safeBox); event SetMinimalTimeLeftToMaturity(uint _minimalTimeLeftToMaturity); event SetMinMaxSupportedPriceCapPerMarket(uint minPrice, uint maxPrice, uint capPerMarket); 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 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.5.16; interface IPriceFeed { // Structs struct RateAndUpdatedTime { uint216 rate; uint40 time; } // Mutative functions function addAggregator(bytes32 currencyKey, address aggregatorAddress) external; function removeAggregator(bytes32 currencyKey) external; // Views function rateForCurrency(bytes32 currencyKey) external view returns (uint); function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time); function getRates() external view returns (uint[] memory); function getCurrencies() external view returns (bytes32[] memory); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; interface IThalesAMMUtils { function calculateOdds( uint _price, uint strike, uint timeLeftInDays, uint volatility ) external view returns (uint); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "../interfaces/IPositionalMarketManager.sol"; import "../interfaces/IPosition.sol"; import "../interfaces/IPriceFeed.sol"; interface IPositionalMarket { /* ========== TYPES ========== */ enum Phase { Trading, Maturity, Expiry } enum Side { Up, Down } /* ========== VIEWS / VARIABLES ========== */ function getOptions() external view returns (IPosition up, IPosition down); function times() external view returns (uint maturity, uint destructino); function getOracleDetails() external view returns ( bytes32 key, uint strikePrice, uint finalPrice ); function fees() external view returns (uint poolFee, uint creatorFee); function deposited() external view returns (uint); function creator() external view returns (address); function resolved() external view returns (bool); function phase() external view returns (Phase); function oraclePrice() external view returns (uint); function oraclePriceAndTimestamp() external view returns (uint price, uint updatedAt); function canResolve() external view returns (bool); function result() external view returns (Side); function balancesOf(address account) external view returns (uint up, uint down); function totalSupplies() external view returns (uint up, uint down); function getMaximumBurnable(address account) external view returns (uint amount); /* ========== MUTATIVE FUNCTIONS ========== */ function mint(uint value) external; function exerciseOptions() external returns (uint); function burnOptions(uint amount) external; function burnOptionsMaximum() external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "../interfaces/IPositionalMarket.sol"; interface IPositionalMarketManager { /* ========== VIEWS / VARIABLES ========== */ function durations() external view returns (uint expiryDuration, uint maxTimeToMaturity); function capitalRequirement() external view returns (uint); function marketCreationEnabled() external view returns (bool); function onlyAMMMintingAndBurning() external view returns (bool); function transformCollateral(uint value) external view returns (uint); function reverseTransformCollateral(uint value) external view returns (uint); function totalDeposited() external view returns (uint); function numActiveMarkets() external view returns (uint); function activeMarkets(uint index, uint pageSize) external view returns (address[] memory); function numMaturedMarkets() external view returns (uint); function maturedMarkets(uint index, uint pageSize) external view returns (address[] memory); function isActiveMarket(address candidate) external view returns (bool); function isKnownMarket(address candidate) external view returns (bool); function getThalesAMM() external view returns (address); /* ========== MUTATIVE FUNCTIONS ========== */ function createMarket( bytes32 oracleKey, uint strikePrice, uint maturity, uint initialMint // initial sUSD to mint options for, ) external returns (IPositionalMarket); function resolveMarket(address market) external; function expireMarkets(address[] calldata market) external; function transferSusdTo( address sender, address receiver, uint amount ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; import "./IPositionalMarket.sol"; interface IPosition { /* ========== VIEWS / VARIABLES ========== */ function getBalanceOf(address account) external view returns (uint); function getTotalSupply() external view returns (uint); function exerciseWithAmount(address claimant, uint amount) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; interface 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); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; interface IReferrals { function referrals(address) external view returns (address); function sportReferrals(address) external view returns (address); function setReferrer(address, address) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.16; interface ICurveSUSD { function exchange_underlying( int128 i, int128 j, uint256 _dx, uint256 _min_dy ) external returns (uint256); function get_dy_underlying( int128 i, int128 j, uint256 _dx ) external view returns (uint256); // @notice Perform an exchange between two underlying coins // @param i Index value for the underlying coin to send // @param j Index valie of the underlying coin to receive // @param _dx Amount of `i` being exchanged // @param _min_dy Minimum amount of `j` to receive // @param _receiver Address that receives `j` // @return Actual amount of `j` received // indexes: // 0 = sUSD 18 dec 0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9 // 1= DAI 18 dec 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1 // 2= USDC 6 dec 0x7F5c764cBc14f9669B88837ca1490cCa17c31607 // 3= USDT 6 dec 0x94b008aA00579c1307B0EF2c499aD98a8ce58e58 }
// SPDX-License-Identifier: MIT // 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; }
{ "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":"buyer","type":"address"},{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sUSDPaid","type":"uint256"},{"indexed":false,"internalType":"address","name":"susd","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"BoughtFromAmm","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"sUSDPaid","type":"uint256"},{"indexed":false,"internalType":"bool","name":"inTheMoney","type":"bool"}],"name":"BoughtOptionType","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sUSDPaid","type":"uint256"}],"name":"BoughtWithDiscount","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":"uint256","name":"_cap","type":"uint256"}],"name":"SetCapPerAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"asset","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"_impliedVolatility","type":"uint256"}],"name":"SetImpliedVolatilityPerAsset","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_spread","type":"uint256"}],"name":"SetMaxSpread","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"capPerMarket","type":"uint256"}],"name":"SetMinMaxSupportedPriceCapPerMarket","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_spread","type":"uint256"}],"name":"SetMinSpread","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_minimalTimeLeftToMaturity","type":"uint256"}],"name":"SetMinimalTimeLeftToMaturity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_manager","type":"address"}],"name":"SetPositionalMarketManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_priceFeed","type":"address"}],"name":"SetPriceFeed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sUSD","type":"address"}],"name":"SetSUSD","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_safeBox","type":"address"}],"name":"SetSafeBox","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"}],"name":"SetSafeBoxImpact","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"address","name":"market","type":"address"},{"indexed":false,"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sUSDPaid","type":"uint256"},{"indexed":false,"internalType":"address","name":"susd","type":"address"},{"indexed":false,"internalType":"address","name":"asset","type":"address"}],"name":"SoldToAMM","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"}],"name":"availableToBuyFromAMM","outputs":[{"internalType":"uint256","name":"_available","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"}],"name":"availableToSellToAMM","outputs":[{"internalType":"uint256","name":"_available","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedPayout","type":"uint256"},{"internalType":"uint256","name":"additionalSlippage","type":"uint256"}],"name":"buyFromAMM","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedPayout","type":"uint256"},{"internalType":"uint256","name":"additionalSlippage","type":"uint256"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"buyFromAMMWithDifferentCollateralAndReferrer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedPayout","type":"uint256"},{"internalType":"uint256","name":"additionalSlippage","type":"uint256"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"buyFromAMMWithReferrer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"buyFromAmmQuote","outputs":[{"internalType":"uint256","name":"_quote","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"collateral","type":"address"}],"name":"buyFromAmmQuoteWithDifferentCollateral","outputs":[{"internalType":"uint256","name":"collateralQuote","type":"uint256"},{"internalType":"uint256","name":"sUSDToPay","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"buyPriceImpact","outputs":[{"internalType":"int256","name":"_priceImpact","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"canExerciseMaturedMarket","outputs":[{"internalType":"bool","name":"_canExercise","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"capPerMarket","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curveOnrampEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"curveSUSD","outputs":[{"internalType":"contract ICurveSUSD","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dai","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"exerciseMaturedMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"}],"name":"getCapPerAsset","outputs":[{"internalType":"uint256","name":"_cap","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"impliedVolatilityPerAsset","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initNonReentrant","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract IPriceFeed","name":"_priceFeed","type":"address"},{"internalType":"contract IERC20Upgradeable","name":"_sUSD","type":"address"},{"internalType":"uint256","name":"_capPerMarket","type":"uint256"},{"internalType":"address","name":"_deciMath","type":"address"},{"internalType":"uint256","name":"_min_spread","type":"uint256"},{"internalType":"uint256","name":"_max_spread","type":"uint256"},{"internalType":"uint256","name":"_minimalTimeLeftToMaturity","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"}],"name":"isMarketInAMMTrading","outputs":[{"internalType":"bool","name":"isTrading","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAllowedPegSlippagePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupportedPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"max_spread","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minSupportedPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"min_spread","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"min_spreadPerAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimalTimeLeftToMaturity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"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":"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":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"}],"name":"price","outputs":[{"internalType":"uint256","name":"priceToReturn","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceFeed","outputs":[{"internalType":"contract IPriceFeed","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referrals","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referrerFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"retrieveSUSDAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sUSD","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeBox","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"safeBoxFeePerAddress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"safeBoxImpact","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sellPriceImpact","outputs":[{"internalType":"uint256","name":"_impact","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedPayout","type":"uint256"},{"internalType":"uint256","name":"additionalSlippage","type":"uint256"}],"name":"sellToAMM","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"market","type":"address"},{"internalType":"enum ThalesAMM.Position","name":"position","type":"uint8"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sellToAmmQuote","outputs":[{"internalType":"uint256","name":"_quote","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IThalesAMMUtils","name":"_ammUtils","type":"address"}],"name":"setAmmUtils","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint256","name":"_cap","type":"uint256"}],"name":"setCapPerAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_curveSUSD","type":"address"},{"internalType":"address","name":"_dai","type":"address"},{"internalType":"address","name":"_usdc","type":"address"},{"internalType":"address","name":"_usdt","type":"address"},{"internalType":"bool","name":"_curveOnrampEnabled","type":"bool"},{"internalType":"uint256","name":"_maxAllowedPegSlippagePercentage","type":"uint256"}],"name":"setCurveSUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"asset","type":"bytes32"},{"internalType":"uint256","name":"_impliedVolatility","type":"uint256"}],"name":"setImpliedVolatilityPerAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minspread","type":"uint256"},{"internalType":"uint256","name":"_maxspread","type":"uint256"}],"name":"setMinMaxSpread","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minSupportedPrice","type":"uint256"},{"internalType":"uint256","name":"_maxSupportedPrice","type":"uint256"},{"internalType":"uint256","name":"_capPerMarket","type":"uint256"}],"name":"setMinMaxSupportedPriceAndCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"setMinSpreadPerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minimalTimeLeftToMaturity","type":"uint256"}],"name":"setMinimalTimeLeftToMaturity","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":"_manager","type":"address"}],"name":"setPositionalMarketManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPriceFeed","name":"_priceFeed","type":"address"},{"internalType":"contract IERC20Upgradeable","name":"_sUSD","type":"address"}],"name":"setPriceFeedAndSUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_safeBox","type":"address"},{"internalType":"uint256","name":"_safeBoxImpact","type":"uint256"}],"name":"setSafeBoxData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"setSafeBoxFeePerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStakingThales","name":"_stakingThales","type":"address"},{"internalType":"address","name":"_referrals","type":"address"},{"internalType":"uint256","name":"_referrerFee","type":"uint256"}],"name":"setStakingThalesAndReferrals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setWhitelistedAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"spentOnMarket","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingThales","outputs":[{"internalType":"contract IStakingThales","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usdc","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"usdt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50615b7180620000216000396000f3fe608060405234801561001057600080fd5b50600436106103f15760003560e01c80638875eb8411610215578063cafb3ca211610125578063ebc79772116100b8578063f502b00311610087578063f502b003146108af578063f8debeb7146108cf578063fb91d41c146108e2578063fc1ed857146108eb578063fd8a8cc6146108fe57600080fd5b8063ebc797721461086e578063efb1fe3514610876578063efc1525114610889578063f4b9fa751461089c57600080fd5b8063d3dc7539116100f4578063d3dc753914610821578063d4a2641b14610834578063d69fb6681461085c578063df8974d01461086557600080fd5b8063cafb3ca2146107d5578063d1624924146107e8578063d333ca19146107fb578063d3c4297c1461080e57600080fd5b8063ad18f0da116101a8578063c2783f9211610177578063c2783f9214610769578063c3b83f5f1461077c578063c4dc27d71461078f578063c8f0b4ec146107af578063ca1d578e146107c257600080fd5b8063ad18f0da1461071d578063bbdf88ce14610730578063bf46c0b414610743578063bf996ae31461075657600080fd5b80639324cac7116101e45780639324cac7146106d15780639f916c9f146106e4578063a273ecf1146106f7578063a5bf660d1461070a57600080fd5b80638875eb84146106935780638da5cb5b146106a657806391b4ded9146106bf578063931b2040146106c857600080fd5b8063481c6a75116103105780636aaa81b6116102a3578063741bef1a11610272578063741bef1a1461063a57806379ba5097146106525780637b337a361461065a578063826153491461066d578063851702091461068057600080fd5b80636aaa81b6146106025780636cc5a6ff1461060b5780636e88a7bd1461061e5780636ed033f81461062757600080fd5b80635727a0f3116102df5780635727a0f3146105af5780635c975abb146105c25780635ef85b26146105cf57806365f56772146105e257600080fd5b8063481c6a751461056357806348663e951461057657806351b9181f1461058957806353a47bb71461059c57600080fd5b8063270e13ef11610388578063316425c311610357578063316425c3146105215780633443b3261461052a5780633ce1108d1461053d5780633e413bee1461055057600080fd5b8063270e13ef146104ba5780632909f51a146104cd5780632972e8ab146104d65780632f48ab7d146104f657600080fd5b806316c38b3c116103c457806316c38b3c1461047757806319b844a61461048a5780631c37d04b146104935780631fbb38e8146104a657600080fd5b806306c933d8146103f65780630f13aae81461042e57806313af40351461044f5780631627540c14610464575b600080fd5b61041961040436600461527b565b60146020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b61044161043c366004615442565b610911565b604051908152602001610425565b61046261045d36600461527b565b61095b565b005b61046261047236600461527b565b610a9b565b61046261048536600461560b565b610af1565b61044160125481565b6104416104a1366004615442565b610b67565b601a5461041990600160a01b900460ff1681565b6104416104c8366004615442565b610b94565b610441601b5481565b6104416104e436600461527b565b601e6020526000908152604090205481565b601954610509906001600160a01b031681565b6040516001600160a01b039091168152602001610425565b610441600a5481565b6104626105383660046155f9565b610bed565b61044161054b3660046154cf565b610c11565b601854610509906001600160a01b031681565b600754610509906001600160a01b031681565b600e54610509906001600160a01b031681565b61046261059736600461527b565b611045565b600154610509906001600160a01b031681565b6104196105bd36600461527b565b611111565b6003546104199060ff1681565b6104626105dd36600461565b565b6112c1565b6104416105f036600461527b565b601d6020526000908152604090205481565b61044160095481565b610441610619366004615581565b6114e7565b61044160165481565b61044161063536600461540e565b611866565b6005546105099061010090046001600160a01b031681565b610462611b0e565b610462610668366004615356565b611c0b565b61046261067b36600461565b565b611c3e565b61046261068e366004615643565b611cb3565b6104416106a13660046154cf565b611cf0565b600054610509906201000090046001600160a01b031681565b61044160025481565b61044160115481565b600654610509906001600160a01b031681565b6104416106f236600461551d565b611d64565b6104626107053660046155f9565b611e58565b601754610509906001600160a01b031681565b61046261072b36600461538e565b611e7c565b61046261073e3660046156d7565b611fa1565b610441610751366004615442565b612050565b61046261076436600461527b565b612161565b61044161077736600461540e565b6122dc565b61046261078a36600461527b565b612322565b61044161079d36600461527b565b600d6020526000908152604090205481565b6104626107bd36600461579e565b61243b565b6104196107d036600461527b565b612498565b6104626107e3366004615704565b612732565b6104626107f636600461565b565b61276f565b61046261080936600461527b565b6127bf565b61046261081c3660046152de565b6127e9565b601554610509906001600160a01b031681565b61084761084236600461547f565b6129ed565b60408051928352602083019190915201610425565b610441600f5481565b610441600c5481565b610462612b06565b6104626108843660046152b3565b612b64565b61044161089736600461540e565b612b83565b601a54610509906001600160a01b031681565b6104416108bd366004615643565b600b6020526000908152604090205481565b6104416108dd366004615643565b612bd0565b61044160085481565b6104626108f93660046155f9565b612c87565b601054610509906001600160a01b031681565b60008061091e8585611866565b9050601254811161092f5780610933565b6012545b90506000610942868684612cdf565b90506109518686868585612f56565b9695505050505050565b6001600160a01b0381166109b65760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff1615610a225760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b60648201526084016109ad565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b610aa3613082565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610a90565b610af9613082565b60035460ff1615158115151415610b0d5750565b6003805460ff191682151590811790915560ff1615610b2b57426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001610a90565b50565b600080610b7485856122dc565b9050808311610b8c57610b89858585846130fc565b91505b509392505050565b600080610ba18585611866565b90506000610bb782670de0b6b3a7640000615a8f565b90508115610be4576011548210610bce5781610bd2565b6011545b91506109518686868585600f54613181565b50509392505050565b610bf5613082565b6001600160a01b039091166000908152601e6020526040902055565b6000600160046000828254610c269190615954565b909155505060045460035460ff1615610c515760405162461bcd60e51b81526004016109ad9061587f565b610c5a87611111565b610ca65760405162461bcd60e51b815260206004820152601e60248201527f4d61726b6574206973206e6f7420696e2054726164696e67207068617365000060448201526064016109ad565b6000610cb28888611866565b90506012548111610cc35780610cc7565b6012545b90506000610cd6898984612cdf565b9050600081118015610ce85750808711155b610d2c5760405162461bcd60e51b81526020600482015260156024820152742737ba1032b737bab3b4103634b8bab4b234ba3c9760591b60448201526064016109ad565b6000610d3b8a8a8a8686612f56565b9050610d4f86670de0b6b3a7640000615954565b81610d62670de0b6b3a76400008a615a31565b610d6c919061599a565b1115610dae5760405162461bcd60e51b81526020600482015260116024820152700a6d8d2e0e0c2ceca40e8dede40d0d2ced607b1b60448201526064016109ad565b6000610dba8b8b613410565b9050610dd16001600160a01b03821633308c6134b7565b6007546040516314edbee160e31b81523060048201526000916001600160a01b039081169163edc892e1918f169063a76df7089060240160206040518083038186803b158015610e2057600080fd5b505afa158015610e34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e589190615763565b6040518263ffffffff1660e01b8152600401610e7691815260200190565b60206040518083038186803b158015610e8e57600080fd5b505afa158015610ea2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec69190615763565b90508015610f22578b6001600160a01b031663f5571beb6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610f0957600080fd5b505af1158015610f1d573d6000803e3d6000fd5b505050505b600654610f39906001600160a01b03163385613528565b6010546001600160a01b031615610faf576010546040516302c7739b60e01b8152336004820152602481018590526001600160a01b03909116906302c7739b90604401600060405180830381600087803b158015610f9657600080fd5b505af1158015610faa573d6000803e3d6000fd5b505050505b610fbb8c84833361355d565b7f1d6ff70c632edb1e6aba7fbc0148db68c8392e30f9dfaadae2543a2543757cf6338d8d8d87600660009054906101000a90046001600160a01b03168860405161100b97969594939291906157e5565b60405180910390a150909450505050600454811461103b5760405162461bcd60e51b81526004016109ad906158dc565b5095945050505050565b61104e81612498565b61109a5760405162461bcd60e51b815260206004820152601a60248201527f43616e27742065786572636973652074686174206d61726b657400000000000060448201526064016109ad565b806001600160a01b031663851492586040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156110d557600080fd5b505af11580156110e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110d9190615763565b5050565b600754604051633761c52760e11b81526001600160a01b0383811660048301526000921690636ec38a4e9060240160206040518083038186803b15801561115757600080fd5b505afa15801561116b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118f9190615627565b156112bc5760008290506000816001600160a01b03166341bc7b1f6040518163ffffffff1660e01b815260040160606040518083038186803b1580156111d457600080fd5b505afa1580156111e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120c919061567c565b505090506000826001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b15801561124a57600080fd5b505afa15801561125e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611282919061577b565b506000838152600b602052604090205490915015806112a057504281105b6112b85760006112b04283615a8f565b600c54109450505b5050505b919050565b3360009081526014602052604090205460ff16806112ef57506000546201000090046001600160a01b031633145b6113565760405162461bcd60e51b815260206004820152603260248201527f4f6e6c792077686974656c697374656420616464726573736573206f72206f776044820152716e65722063616e206368616e67652049562160701b60648201526084016109ad565b611369670de0b6b3a7640000600a615a31565b811180156113895750611386670de0b6b3a764000061012c615a31565b81105b6113d55760405162461bcd60e51b815260206004820152601960248201527f4956206f757473696465206d696e2f6d61782072616e6765210000000000000060448201526064016109ad565b6005546040516315905ec160e31b8152600481018490526101009091046001600160a01b03169063ac82f6089060240160206040518083038186803b15801561141d57600080fd5b505afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114559190615763565b6114975760405162461bcd60e51b8152602060048201526013602482015272417373657420686173206e6f2070726963652160681b60448201526064016109ad565b6000828152600b602090815260409182902083905581518481529081018390527f715e0a52c0b74c77d2d2012a363ac95b494302ad2abb78ac7406ec93451f1adb91015b60405180910390a15050565b60006001600460008282546114fc9190615954565b909155505060045460035460ff16156115275760405162461bcd60e51b81526004016109ad9061587f565b6001600160a01b0383161561159c5760155460405163bbddaca360e01b81526001600160a01b0385811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b15801561158357600080fd5b505af1158015611597573d6000803e3d6000fd5b505050505b60006115a785613875565b9050600081600f0b1380156115c55750601a54600160a01b900460ff165b61160a5760405162461bcd60e51b81526020600482015260166024820152751d5b9cdd5c1c1bdc9d19590818dbdb1b185d195c985b60521b60448201526064016109ad565b6000806116198c8c8c8a6129ed565b60185491935091506000906001600160a01b038981169116148061164a57506019546001600160a01b038981169116145b6116545782611663565b6116638364e8d4a51000615a31565b90506000601b541180156116a95750670de0b6b3a7640000601b54670de0b6b3a76400006116919190615a8f565b61169b9084615a31565b6116a5919061599a565b8110155b6117035760405162461bcd60e51b815260206004820152602560248201527f416d6f756e742062656c6f77206d617820616c6c6f7765642070656720736c69604482015264707061676560d81b60648201526084016109ad565b61171589670de0b6b3a7640000615954565b8a611728670de0b6b3a764000086615a31565b611732919061599a565b11156117755760405162461bcd60e51b8152602060048201526012602482015271536c69707061676520746f6f20686967682160701b60448201526064016109ad565b8761178b6001600160a01b0382163330876134b7565b601754604051635320bf6b60e11b8152600f87900b60048201526000602482015260448101869052606481018590526001600160a01b039091169063a6417ed690608401602060405180830381600087803b1580156117e957600080fd5b505af11580156117fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118219190615763565b506118328e8e8e868e6000896138da565b96505050505050600454811461185a5760405162461bcd60e51b81526004016109ad906158dc565b50979650505050505050565b600061187183611111565b15611b085760008390506000816001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b1580156118b557600080fd5b505afa1580156118c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ed919061577b565b50905060006118fc4283615a8f565b9050600062015180611916670de0b6b3a764000084615a31565b611920919061599a565b90506000846001600160a01b031663668aa8246040518163ffffffff1660e01b815260040160206040518083038186803b15801561195d57600080fd5b505afa158015611971573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119959190615763565b9050600080866001600160a01b03166341bc7b1f6040518163ffffffff1660e01b815260040160606040518083038186803b1580156119d357600080fd5b505afa1580156119e7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0b919061567c565b50601c546000838152600b602052604090819020549051631519a0dd60e31b815260048101889052602481018490526044810189905260648082019290925293955091935090916001600160a01b039091169063a8cd06e89060840160206040518083038186803b158015611a7f57600080fd5b505afa158015611a93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab79190615763565b611ac1919061599a565b97506001896001811115611ae557634e487b7160e01b600052602160045260246000fd5b1415611b0057611afd88670de0b6b3a7640000615a8f565b97505b505050505050505b92915050565b6001546001600160a01b03163314611b865760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b60648201526084016109ad565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b611c13613082565b6001600160a01b03919091166000908152601460205260409020805460ff1916911515919091179055565b611c46613082565b6009829055600a8190556040518281527f1e6a338a58debcc786781a079c4459466b102ad0156cc84f51d25ef7dd8cb9b09060200160405180910390a16040518181527f4af6d03c4624e0a6b868b8f6453e047f23f3ea15e9d08c938bd4c445d7ef19b3906020016114db565b611cbb613082565b600c8190556040518181527fdc469b5583fa9b7ebd3245e1665334cd758c4bef4c5a132c62baca85effacfec90602001610a90565b6000600160046000828254611d059190615954565b909155505060045460035460ff1615611d305760405162461bcd60e51b81526004016109ad9061587f565b611d418787878787600160006138da565b9150600454811461103b5760405162461bcd60e51b81526004016109ad906158dc565b6000600160046000828254611d799190615954565b909155505060045460035460ff1615611da45760405162461bcd60e51b81526004016109ad9061587f565b6001600160a01b03831615611e195760155460405163bbddaca360e01b81526001600160a01b0385811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b158015611e0057600080fd5b505af1158015611e14573d6000803e3d6000fd5b505050505b611e2a8888888888600160006138da565b91506004548114611e4d5760405162461bcd60e51b81526004016109ad906158dc565b509695505050505050565b611e60613082565b6001600160a01b039091166000908152601d6020526040902055565b600054610100900460ff16611e975760005460ff1615611e9b565b303b155b611efe5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016109ad565b600054610100900460ff16158015611f20576000805461ffff19166101011790555b611f298961095b565b611f31612b06565b60058054610100600160a81b0319166101006001600160a01b038b81169190910291909117909155600680546001600160a01b03191691891691909117905560088690556009849055600a839055600c8290558015611f96576000805461ff00191690555b505050505050505050565b611fa9613082565b60058054610100600160a81b0319166101006001600160a01b038516908102919091179091556040519081527ff724a45d041687842411f2b977ef22ab8f43c8f1104f4592b42a00f9b34a643d9060200160405180910390a1600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f74a8764fc8d62d2d844c8c54426bd94ad034e0e92abdf5280ff75e2cbd678fb6906020016114db565b6000808084600181111561207457634e487b7160e01b600052602160045260246000fd5b14612080576000612083565b60015b905060006120918686611866565b905060006120a782670de0b6b3a7640000615a8f565b905060115482106120b857816120bc565b6011545b915060006120cd8888856001613e1e565b905060006120de8986856001613e1e565b90506000871180156120f05750818711155b15612155576121526040518060c001604052808b6001600160a01b031681526020018a600181111561213257634e487b7160e01b600052602160045260246000fd5b815260200189815260200184815260200183815260200186815250613fff565b95505b50505050509392505050565b612169613082565b6007546001600160a01b0316156122045760065460075460405163095ea7b360e01b81526001600160a01b0391821660048201526000602482015291169063095ea7b390604401602060405180830381600087803b1580156121ca57600080fd5b505af11580156121de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122029190615627565b505b600780546001600160a01b0319166001600160a01b0383811691821790925560065460405163095ea7b360e01b8152600481019290925260001960248301529091169063095ea7b390604401602060405180830381600087803b15801561226a57600080fd5b505af115801561227e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122a29190615627565b506040516001600160a01b03821681527f9987372437ace1af79923f26b948aa04afef92b2b7786144c5aae621ea84eb0a90602001610a90565b60006122e783611111565b15611b085760006122f88484611866565b90506012548111612309578061230d565b6012545b905061231a848483612cdf565b949350505050565b61232a613082565b6001600160a01b0381166123725760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b60448201526064016109ad565b600154600160a81b900460ff16156123c25760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b60448201526064016109ad565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610a90565b612443613082565b60118390556012829055600881905560408051848152602081018490529081018290527f0e8c2ebd67ea2d796a34f02c777ec06f5faedd1669b272dc08dc7875486ae0809060600160405180910390a1505050565b60075460405163e62b888960e01b81526001600160a01b038381166004830152600092169063e62b88899060240160206040518083038186803b1580156124de57600080fd5b505afa1580156124f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125169190615627565b80156125b157506001826001600160a01b031663b1c9fe6e6040518163ffffffff1660e01b815260040160206040518083038186803b15801561255857600080fd5b505afa15801561256c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125909190615744565b60028111156125af57634e487b7160e01b600052602160045260246000fd5b145b156112bc57600080836001600160a01b031663cc2ee1966040518163ffffffff1660e01b8152600401604080518083038186803b1580156125f157600080fd5b505afa158015612605573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061262991906156a9565b604051634dcb776760e11b815230600482015291935091506000906001600160a01b03841690639b96eece9060240160206040518083038186803b15801561267057600080fd5b505afa158015612684573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a89190615763565b118061231a5750604051634dcb776760e11b81523060048201526000906001600160a01b03831690639b96eece9060240160206040518083038186803b1580156126f157600080fd5b505afa158015612705573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127299190615763565b11949350505050565b61273a613082565b601080546001600160a01b039485166001600160a01b0319918216179091556015805493909416921691909117909155601655565b612777613082565b60008281526013602090815260409182902083905581518481529081018390527f5af395595015797b4d0f26b77c38dd4831298dabc7906ee3d62b80fa75d35c1e91016114db565b6127c7613082565b601c80546001600160a01b0319166001600160a01b0392909216919091179055565b6127f1613082565b601780546001600160a01b03199081166001600160a01b03898116918217909355601a80548316898516908117909155601880548416898616179055601980549093169387169390931790915560405163095ea7b360e01b81526004810191909152600019602482015263095ea7b390604401602060405180830381600087803b15801561287e57600080fd5b505af1158015612892573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128b69190615627565b5060185460405163095ea7b360e01b81526001600160a01b03888116600483015260001960248301529091169063095ea7b390604401602060405180830381600087803b15801561290657600080fd5b505af115801561291a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061293e9190615627565b5060195460405163095ea7b360e01b81526001600160a01b03888116600483015260001960248301529091169063095ea7b390604401602060405180830381600087803b15801561298e57600080fd5b505af11580156129a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c69190615627565b50601a8054921515600160a01b0260ff60a01b1990931692909217909155601b5550505050565b60008060006129fb84613875565b9050600081600f0b138015612a195750601a54600160a01b900460ff165b15612afc57612a29878787610b94565b9150670de0b6b3a7640000612a466005662386f26fc1000061599a565b612a5890670de0b6b3a7640000615954565b6017546040516307211ef760e01b815260006004820152600f85900b6024820152604481018690526001600160a01b03909116906307211ef79060640160206040518083038186803b158015612aad57600080fd5b505afa158015612ac1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ae59190615763565b612aef9190615a31565b612af9919061599a565b92505b5094509492505050565b60055460ff1615612b4f5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b60448201526064016109ad565b6005805460ff19166001908117909155600455565b612b6c613082565b60065461110d906001600160a01b03168383613528565b6000612b8e83611111565b15611b08576000612b9f8484611866565b90508015612bc9576011548110612bb65780612bba565b6011545b905061231a8484836000613e1e565b5092915050565b6005546040516315905ec160e31b81526004810183905260009161010090046001600160a01b03169063ac82f6089060240160206040518083038186803b158015612c1a57600080fd5b505afa158015612c2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c529190615763565b156112bc5760008281526013602052604090205415612c7f57600082815260136020526040902054611b08565b505060085490565b612c8f613082565b600f819055600e80546001600160a01b0319166001600160a01b0384161790556040518181527f01edd423db862fb00774918e3b06d9c1dd3db9a99b5a194c439d2f141876f444906020016114db565b600080612ceb836142ba565b90508015610b8c57600080866001600160a01b031663cc2ee1966040518163ffffffff1660e01b8152600401604080518083038186803b158015612d2e57600080fd5b505afa158015612d42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6691906156a9565b9092509050600080876001811115612d8e57634e487b7160e01b600052602160045260246000fd5b14612e0f57604051634dcb776760e11b81523060048201526001600160a01b03841690639b96eece9060240160206040518083038186803b158015612dd257600080fd5b505afa158015612de6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e0a9190615763565b612e86565b604051634dcb776760e11b81523060048201526001600160a01b03831690639b96eece9060240160206040518083038186803b158015612e4e57600080fd5b505afa158015612e62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e869190615763565b90506000670de0b6b3a7640000612e9d8684615a31565b612ea7919061599a565b9050600082612eb58b614311565b612ebf9190615954565b6001600160a01b038b166000908152600d6020526040902054909150612ee6908390615954565b8110612f49576001600160a01b038a166000908152600d60205260408120548390612f119084615a8f565b612f1b9190615a8f565b905083670de0b6b3a7640000612f31898461599a565b612f3b9190615a31565b612f459190615954565b9750505b5050505050509392505050565b600081841161307957600954612f6c9084615a8f565b92506000670de0b6b3a764000080612f86898989886130fc565b612f9890670de0b6b3a7640000615a8f565b612fa29087615a31565b612fac919061599a565b612fb69087615a31565b612fc0919061599a565b90506000670de0b6b3a7640000600f54670de0b6b3a7640000612fe39190615a8f565b612fed9084615a31565b612ff7919061599a565b60075460405163edc892e160e01b8152600481018390529192506001600160a01b03169063edc892e19060240160206040518083038186803b15801561303c57600080fd5b505afa158015613050573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130749190615763565b925050505b95945050505050565b6000546201000090046001600160a01b031633146130fa5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b60648201526084016109ad565b565b600080600061310b8787614399565b9150915060008083116131355785821161312e576131298287615a8f565b61313f565b600061313f565b61313f8684615954565b9050600086831161315157600061315b565b61315b8784615a8f565b90508082106131755761317287848684868b614655565b94505b50505050949350505050565b6000806131918888876000613e1e565b905060006131d189828a60018111156131ba57634e487b7160e01b600052602160045260246000fd5b146131c65760006131c9565b60015b876001613e1e565b90508187116134045760008061323a6040518060c001604052808d6001600160a01b031681526020018c600181111561321a57634e487b7160e01b600052602160045260246000fd5b81526020018b81526020018681526020018581526020018a815250613fff565b336000908152601e60205260409020549091506132595760095461326a565b336000908152601e60205260409020545b6132749089615954565b97506000811261331c576000670de0b6b3a7640000826132948b83615a50565b61329e91906159ae565b6132a8919061596c565b9050670de0b6b3a76400006132c5662386f26fc1000060026159ae565b6132d790670de0b6b3a7640000615913565b6132e190836159ae565b6132eb919061596c565b9050670de0b6b3a7640000613300828b615913565b61330a908c6159ae565b613314919061596c565b92505061335b565b670de0b6b3a7640000806133308382615913565b61333a908b6159ae565b613344919061596c565b61334e908b6159ae565b613358919061596c565b91505b670de0b6b3a764000061336e8782615913565b61337890846159ae565b613382919061596c565b60075460405163edc892e160e01b8152600481018390529193506001600160a01b03169063edc892e19060240160206040518083038186803b1580156133c757600080fd5b505afa1580156133db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133ff9190615763565b945050505b50509695505050505050565b6000806000846001600160a01b031663cc2ee1966040518163ffffffff1660e01b8152600401604080518083038186803b15801561344d57600080fd5b505afa158015613461573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061348591906156a9565b909250905060008460018111156134ac57634e487b7160e01b600052602160045260246000fd5b14610b8c5780613079565b6040516001600160a01b03808516602483015283166044820152606481018290526135229085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152614759565b50505050565b6040516001600160a01b03831660248201526044810182905261355890849063a9059cbb60e01b906064016134eb565b505050565b600083600f54670de0b6b3a76400006135769190615a8f565b613588670de0b6b3a764000087615a31565b613592919061599a565b61359c9190615a8f565b600f54909150156135c957600e546006546135c4916001600160a01b03918216911683613528565b6135cd565b5060005b6007546001600160a01b03166317fd849a6135e88387615954565b6040518263ffffffff1660e01b815260040161360691815260200190565b60206040518083038186803b15801561361e57600080fd5b505afa158015613632573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136569190615763565b6001600160a01b0386166000908152600d60205260409020546136799190615954565b6001600160a01b038681166000908152600d602052604090819020929092556007549151630bfec24d60e11b8152600481018690529116906317fd849a9060240160206040518083038186803b1580156136d257600080fd5b505afa1580156136e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061370a9190615763565b6001600160a01b0386166000908152600d602052604090205411613746576001600160a01b0385166000908152600d60205260408120556137ff565b600754604051630bfec24d60e11b8152600481018590526001600160a01b03909116906317fd849a9060240160206040518083038186803b15801561378a57600080fd5b505afa15801561379e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c29190615763565b6001600160a01b0386166000908152600d60205260409020546137e59190615a8f565b6001600160a01b0386166000908152600d60205260409020555b600060165411801561381b57506015546001600160a01b031615155b1561386e57600084601654670de0b6b3a76400006138399190615a8f565b61384b670de0b6b3a764000088615a31565b613855919061599a565b61385f9190615a8f565b905061386c83828761482b565b505b5050505050565b601a546000906001600160a01b038381169116141561389657506001919050565b6018546001600160a01b03838116911614156138b457506002919050565b6019546001600160a01b03838116911614156138d257506003919050565b506000919050565b60006138e588611111565b6139315760405162461bcd60e51b815260206004820152601e60248201527f4d61726b6574206973206e6f7420696e2054726164696e67207068617365000060448201526064016109ad565b5080600061393f8989611866565b9050600061395582670de0b6b3a7640000615a8f565b90506011548210613966578161396a565b6011545b9150600061397b8b8b856000613e1e565b905060008911801561398d5750808911155b6139d15760405162461bcd60e51b81526020600482015260156024820152742737ba1032b737bab3b4103634b8bab4b234ba3c9760591b60448201526064016109ad565b8515613aa157336000908152601d6020526040902054613a16908c908c908c9087908790613a0157600f54613181565b336000908152601d6020526040902054613181565b9350613a2a87670de0b6b3a7640000615954565b88613a3d670de0b6b3a764000087615a31565b613a47919061599a565b1115613a895760405162461bcd60e51b81526020600482015260116024820152700a6d8d2e0e0c2ceca40e8dede40d0d2ced607b1b60448201526064016109ad565b600654613aa1906001600160a01b03163330876134b7565b6000613aae8c8c8c614939565b90508015613c935760075460405163edc892e160e01b8152600481018390526001600160a01b039091169063edc892e19060240160206040518083038186803b158015613afa57600080fd5b505afa158015613b0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b329190615763565b6006546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015613b7557600080fd5b505afa158015613b89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bad9190615763565b1015613bfb5760405162461bcd60e51b815260206004820152601c60248201527f4e6f7420656e6f756768207355534420696e20636f6e74726163742e0000000060448201526064016109ad565b60405163140e25ad60e31b8152600481018290526001600160a01b038d169063a0712d6890602401600060405180830381600087803b158015613c3d57600080fd5b505af1158015613c51573d6000803e3d6000fd5b5050506001600160a01b038d166000908152600d6020526040902054613c7991508290615954565b6001600160a01b038d166000908152600d60205260409020555b6000613c9f8d8d613410565b9050613cb56001600160a01b038216338d613528565b6010546001600160a01b031615613d2b576010546040516302c7739b60e01b8152336004820152602481018890526001600160a01b03909116906302c7739b90604401600060405180830381600087803b158015613d1257600080fd5b505af1158015613d26573d6000803e3d6000fd5b505050505b613d368d873361495a565b818b1115613daa576000613d4a838d615a8f565b905060008c613d59838a615a31565b613d63919061599a565b60408051338152602081018590529081018290529091507ff8a5b21533fcaaeee91cd7b3c6ccbaa3f4ab6dd200e61bc560713565b20b1e9a9060600160405180910390a150505b7ff3bfbc0822d1ed667a2b298e71e0304f2c1f4685398189d7c39e412f733150f4338e8e8e8a600660009054906101000a90046001600160a01b031687604051613dfa97969594939291906157e5565b60405180910390a1613e0e8d8d8833614be1565b5050505050979650505050505050565b60008180613e2d575060125483105b1561231a57600954613e3f9084615954565b9250670de0b6b3a764000083101561231a576000670de0b6b3a76400006004600a54613e6b919061599a565b613e7d90670de0b6b3a7640000615a8f565b613e879086615a31565b613e91919061599a565b90506000613e9f8787614d65565b90506000670de0b6b3a7640000613eb68484615a31565b613ec0919061599a565b6001600160a01b0389166000908152600d602052604090205490915081613ee68a614311565b613ef09190615954565b1115613ff4576001600160a01b0388166000908152600d602052604081205482613f198b614311565b613f239190615954565b613f2d9190615a8f565b9050613f3889614311565b811115613f4b57613f4889614311565b90505b6000670de0b6b3a76400006002600a54613f65919061599a565b613f778a670de0b6b3a7640000615a8f565b613f819190615a31565b613f8b919061599a565b9050670de0b6b3a7640000613fa0828a615954565b1015613ff1576000613fb2828a615954565b613fc490670de0b6b3a7640000615a8f565b905080613fd9670de0b6b3a764000085615a31565b613fe3919061599a565b613fed9086615954565b9650505b50505b505050949350505050565b60006011548260a001511015801561401d57506012548260a0015111155b156112bc5760008061403784600001518560200151614399565b9150915060008460400151831161404f57600061405e565b604085015161405e9084615a8f565b90506000856040015184116140825783866040015161407d9190615a8f565b614085565b60005b61408f9084615954565b90508082106140d0576140c96040518060800160405280868152602001858152602001886040015181526020018860800151815250614ef9565b94506142b1565b8386604001511180156140e35750600084115b156142715760008487604001516140fa9190615a8f565b905060006141576040518060c00160405280848152602001888861411e9190615954565b8152600060208201526040016141348589615954565b815260200160008152602001888b606001516141509190615a8f565b905261503b565b9050600061416d89600001518a60200151611866565b89519091506000906141b190828c60200151600181111561419e57634e487b7160e01b600052602160045260246000fd5b146141aa576000611866565b6001611866565b90506000826141c08584615a31565b6141ca919061599a565b905060006141fb60405180608001604052808c81526020018b81526020018c81526020018e60800151815250614ef9565b90506000614209828c6159ae565b905060006142178489615a31565b90506000614225898e615954565b9050806142328385615913565b61423c919061596c565b9d5060008e13156142635760006142538f896159ae565b905061425f878261596c565b9e50505b5050505050505050506142b1565b6142ae6040518060c0016040528088604001518152602001858152602001868152602001838152602001848152602001886060015181525061503b565b94505b50505050919050565b60006011548211156112bc57670de0b6b3a76400006002600a546142de919061599a565b6142f090670de0b6b3a7640000615a8f565b6009546142fd9085615a8f565b6143079190615a31565b611b08919061599a565b600080826001600160a01b03166341bc7b1f6040518163ffffffff1660e01b815260040160606040518083038186803b15801561434d57600080fd5b505afa158015614361573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614385919061567c565b5050905061439281612bd0565b9392505050565b600080600080856001600160a01b031663cc2ee1966040518163ffffffff1660e01b8152600401604080518083038186803b1580156143d757600080fd5b505afa1580156143eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061440f91906156a9565b9092509050600085600181111561443657634e487b7160e01b600052602160045260246000fd5b146144b757604051634dcb776760e11b81523060048201526001600160a01b03821690639b96eece9060240160206040518083038186803b15801561447a57600080fd5b505afa15801561448e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144b29190615763565b61452e565b604051634dcb776760e11b81523060048201526001600160a01b03831690639b96eece9060240160206040518083038186803b1580156144f657600080fd5b505afa15801561450a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061452e9190615763565b9350600085600181111561455257634e487b7160e01b600052602160045260246000fd5b146145d357604051634dcb776760e11b81523060048201526001600160a01b03831690639b96eece9060240160206040518083038186803b15801561459657600080fd5b505afa1580156145aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145ce9190615763565b61464a565b604051634dcb776760e11b81523060048201526001600160a01b03821690639b96eece9060240160206040518083038186803b15801561461257600080fd5b505afa158015614626573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061464a9190615763565b925050509250929050565b600080866146638488615954565b61466d9190615a8f565b9050600061467b8686615a8f565b90506000670de0b6b3a7640000836146938285615a31565b61469d919061599a565b600a546146aa9190615a31565b6146b4919061599a565b905088156146f75760006146c960028361599a565b90506000816146d88b8e615a8f565b6146e29190615a31565b90506146ee8c8261599a565b9550505061474c565b876000670de0b6b3a76400008561470e8285615a31565b614718919061599a565b600a546147259190615a31565b61472f919061599a565b9050600261473d8285615954565b614747919061599a565b955050505b5050509695505050505050565b60006147ae826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166151719092919063ffffffff16565b80519091501561355857808060200190518101906147cc9190615627565b6135585760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109ad565b601554604051639ca423b360e01b81526001600160a01b0385811660048301526000921690639ca423b39060240160206040518083038186803b15801561487157600080fd5b505afa158015614885573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148a99190615297565b90506001600160a01b038116158015906148c557506000601654115b15613522576006546148e1906001600160a01b03168285613528565b604080516001600160a01b03808416825286166020820152908101849052606081018390527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a150505050565b6000806149468585614d65565b905082811015610b8c57610b898184615a8f565b600f54600090156149ea57336000908152601d602052604090205461498157600f54614992565b336000908152601d60205260409020545b6149a490670de0b6b3a7640000615954565b6149b6670de0b6b3a764000085615a31565b6149c0919061599a565b6149ca9084615a8f565b600e546006549192506149ea916001600160a01b03908116911683613528565b6007546001600160a01b03166317fd849a614a058386615a8f565b6040518263ffffffff1660e01b8152600401614a2391815260200190565b60206040518083038186803b158015614a3b57600080fd5b505afa158015614a4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a739190615763565b6001600160a01b0385166000908152600d602052604090205411614aaf576001600160a01b0384166000908152600d6020526040812055614b75565b6007546001600160a01b03166317fd849a614aca8386615a8f565b6040518263ffffffff1660e01b8152600401614ae891815260200190565b60206040518083038186803b158015614b0057600080fd5b505afa158015614b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b389190615763565b6001600160a01b0385166000908152600d6020526040902054614b5b9190615a8f565b6001600160a01b0385166000908152600d60205260409020555b6000601654118015614b9157506015546001600160a01b031615155b15613522576000601654670de0b6b3a7640000614bae9190615954565b614bc0670de0b6b3a764000086615a31565b614bca919061599a565b614bd49085615a8f565b905061386e83828661482b565b600080856001600160a01b03166341bc7b1f6040518163ffffffff1660e01b815260040160606040518083038186803b158015614c1d57600080fd5b505afa158015614c31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c55919061567c565b506005546040516315905ec160e31b8152600481018490529294509092506000916101009091046001600160a01b03169063ac82f6089060240160206040518083038186803b158015614ca757600080fd5b505afa158015614cbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614cdf9190615763565b9050600080876001811115614d0457634e487b7160e01b600052602160045260246000fd5b14614d1157828210614d16565b828210155b60408051338152602081018990528215158183015290519192507f80631c28c8a8100630a9d2bce38b276a55426b59f4d47fb06072105118083ec1919081900360600190a15050505050505050565b6000806000846001600160a01b031663cc2ee1966040518163ffffffff1660e01b8152600401604080518083038186803b158015614da257600080fd5b505afa158015614db6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614dda91906156a9565b90925090506000846001811115614e0157634e487b7160e01b600052602160045260246000fd5b14614e8257604051634dcb776760e11b81523060048201526001600160a01b03821690639b96eece9060240160206040518083038186803b158015614e4557600080fd5b505afa158015614e59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e7d9190615763565b613079565b604051634dcb776760e11b81523060048201526001600160a01b03831690639b96eece9060240160206040518083038186803b158015614ec157600080fd5b505afa158015614ed5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130799190615763565b600080614faf6040518060c00160405280856040015181526020018560000151815260200185602001518152602001670de0b6b3a7640000866020015111614f63576020860151614f5290670de0b6b3a7640000615a8f565b8651614f5e9190615954565b614f66565b85515b8152602001670de0b6b3a7640000866020015111614f85576000614f9d565b670de0b6b3a76400008660200151614f9d9190615a8f565b8152602001856060015181525061503b565b90506000614fbe60028361599a565b9050600084604001518560000151614fd69190615a8f565b90506000670de0b6b3a7640000808760000151670de0b6b3a764000085614ffd9190615a31565b615007919061599a565b6150119190615954565b61501c60028661599a565b6150269190615a31565b615030919061599a565b90506142ae81615ad2565b60008082604001518360a0015184602001516150579190615954565b6150619190615a8f565b90506000836080015184606001516150799190615a8f565b90506000670de0b6b3a7640000836150918285615a31565b61509b919061599a565b600a546150a89190615a31565b6150b2919061599a565b6040860151909150156151275760006150cc60028361599a565b9050600081876040015188600001516150e59190615a8f565b6150ef9190615a31565b8751909150670de0b6b3a7640000906151088284615a31565b615112919061599a565b61511c919061599a565b979650505050505050565b60208501516000670de0b6b3a7640000856151428285615a31565b61514c919061599a565b600a546151599190615a31565b615163919061599a565b905060026151128285615954565b606061231a848460008585843b6151ca5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109ad565b600080866001600160a01b031685876040516151e691906157c9565b60006040518083038185875af1925050503d8060008114615223576040519150601f19603f3d011682016040523d82523d6000602084013e615228565b606091505b509150915061511c82828660608315615242575081614392565b8251156152525782518084602001fd5b8160405162461bcd60e51b81526004016109ad919061584c565b8035600281106112bc57600080fd5b60006020828403121561528c578081fd5b813561439281615b18565b6000602082840312156152a8578081fd5b815161439281615b18565b600080604083850312156152c5578081fd5b82356152d081615b18565b946020939093013593505050565b60008060008060008060c087890312156152f6578182fd5b863561530181615b18565b9550602087013561531181615b18565b9450604087013561532181615b18565b9350606087013561533181615b18565b9250608087013561534181615b2d565b8092505060a087013590509295509295509295565b60008060408385031215615368578182fd5b823561537381615b18565b9150602083013561538381615b2d565b809150509250929050565b600080600080600080600080610100898b0312156153aa578182fd5b88356153b581615b18565b975060208901356153c581615b18565b965060408901356153d581615b18565b95506060890135945060808901356153ec81615b18565b979a969950949793969560a0850135955060c08501359460e001359350915050565b60008060408385031215615420578182fd5b823561542b81615b18565b91506154396020840161526c565b90509250929050565b600080600060608486031215615456578283fd5b833561546181615b18565b925061546f6020850161526c565b9150604084013590509250925092565b60008060008060808587031215615494578182fd5b843561549f81615b18565b93506154ad6020860161526c565b92506040850135915060608501356154c481615b18565b939692955090935050565b600080600080600060a086880312156154e6578283fd5b85356154f181615b18565b94506154ff6020870161526c565b94979496505050506040830135926060810135926080909101359150565b60008060008060008060c08789031215615535578384fd5b863561554081615b18565b955061554e6020880161526c565b945060408701359350606087013592506080870135915060a087013561557381615b18565b809150509295509295509295565b600080600080600080600060e0888a03121561559b578081fd5b87356155a681615b18565b96506155b46020890161526c565b955060408801359450606088013593506080880135925060a08801356155d981615b18565b915060c08801356155e981615b18565b8091505092959891949750929550565b600080604083850312156152c5578182fd5b60006020828403121561561c578081fd5b813561439281615b2d565b600060208284031215615638578081fd5b815161439281615b2d565b600060208284031215615654578081fd5b5035919050565b6000806040838503121561566d578182fd5b50508035926020909101359150565b600080600060608486031215615690578081fd5b8351925060208401519150604084015190509250925092565b600080604083850312156156bb578182fd5b82516156c681615b18565b602084015190925061538381615b18565b600080604083850312156156e9578182fd5b82356156f481615b18565b9150602083013561538381615b18565b600080600060608486031215615718578081fd5b833561572381615b18565b9250602084013561573381615b18565b929592945050506040919091013590565b600060208284031215615755578081fd5b815160038110614392578182fd5b600060208284031215615774578081fd5b5051919050565b6000806040838503121561578d578182fd5b505080516020909101519092909150565b6000806000606084860312156157b2578081fd5b505081359360208301359350604090920135919050565b600082516157db818460208701615aa6565b9190910192915050565b6001600160a01b038881168252878116602083015260e08201906002881061581d57634e487b7160e01b600052602160045260246000fd5b87604084015286606084015285608084015280851660a084015280841660c08401525098975050505050505050565b602081526000825180602084015261586b816040850160208701615aa6565b601f01601f19169190910160400192915050565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600080821280156001600160ff1b038490038513161561593557615935615aec565b600160ff1b839003841281161561594e5761594e615aec565b50500190565b6000821982111561596757615967615aec565b500190565b60008261597b5761597b615b02565b600160ff1b82146000198414161561599557615995615aec565b500590565b6000826159a9576159a9615b02565b500490565b60006001600160ff1b03818413828413808216868404861116156159d4576159d4615aec565b600160ff1b848712828116878305891216156159f2576159f2615aec565b858712925087820587128484161615615a0d57615a0d615aec565b87850587128184161615615a2357615a23615aec565b505050929093029392505050565b6000816000190483118215151615615a4b57615a4b615aec565b500290565b60008083128015600160ff1b850184121615615a6e57615a6e615aec565b6001600160ff1b0384018313811615615a8957615a89615aec565b50500390565b600082821015615aa157615aa1615aec565b500390565b60005b83811015615ac1578181015183820152602001615aa9565b838111156135225750506000910152565b6000600160ff1b821415615ae857615ae8615aec565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6001600160a01b0381168114610b6457600080fd5b8015158114610b6457600080fdfea2646970667358221220e4f298dc9ba6737b28f580045b8d4edc910789c1f0e310f3455bf38da080f8ae64736f6c63430008040033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106103f15760003560e01c80638875eb8411610215578063cafb3ca211610125578063ebc79772116100b8578063f502b00311610087578063f502b003146108af578063f8debeb7146108cf578063fb91d41c146108e2578063fc1ed857146108eb578063fd8a8cc6146108fe57600080fd5b8063ebc797721461086e578063efb1fe3514610876578063efc1525114610889578063f4b9fa751461089c57600080fd5b8063d3dc7539116100f4578063d3dc753914610821578063d4a2641b14610834578063d69fb6681461085c578063df8974d01461086557600080fd5b8063cafb3ca2146107d5578063d1624924146107e8578063d333ca19146107fb578063d3c4297c1461080e57600080fd5b8063ad18f0da116101a8578063c2783f9211610177578063c2783f9214610769578063c3b83f5f1461077c578063c4dc27d71461078f578063c8f0b4ec146107af578063ca1d578e146107c257600080fd5b8063ad18f0da1461071d578063bbdf88ce14610730578063bf46c0b414610743578063bf996ae31461075657600080fd5b80639324cac7116101e45780639324cac7146106d15780639f916c9f146106e4578063a273ecf1146106f7578063a5bf660d1461070a57600080fd5b80638875eb84146106935780638da5cb5b146106a657806391b4ded9146106bf578063931b2040146106c857600080fd5b8063481c6a75116103105780636aaa81b6116102a3578063741bef1a11610272578063741bef1a1461063a57806379ba5097146106525780637b337a361461065a578063826153491461066d578063851702091461068057600080fd5b80636aaa81b6146106025780636cc5a6ff1461060b5780636e88a7bd1461061e5780636ed033f81461062757600080fd5b80635727a0f3116102df5780635727a0f3146105af5780635c975abb146105c25780635ef85b26146105cf57806365f56772146105e257600080fd5b8063481c6a751461056357806348663e951461057657806351b9181f1461058957806353a47bb71461059c57600080fd5b8063270e13ef11610388578063316425c311610357578063316425c3146105215780633443b3261461052a5780633ce1108d1461053d5780633e413bee1461055057600080fd5b8063270e13ef146104ba5780632909f51a146104cd5780632972e8ab146104d65780632f48ab7d146104f657600080fd5b806316c38b3c116103c457806316c38b3c1461047757806319b844a61461048a5780631c37d04b146104935780631fbb38e8146104a657600080fd5b806306c933d8146103f65780630f13aae81461042e57806313af40351461044f5780631627540c14610464575b600080fd5b61041961040436600461527b565b60146020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b61044161043c366004615442565b610911565b604051908152602001610425565b61046261045d36600461527b565b61095b565b005b61046261047236600461527b565b610a9b565b61046261048536600461560b565b610af1565b61044160125481565b6104416104a1366004615442565b610b67565b601a5461041990600160a01b900460ff1681565b6104416104c8366004615442565b610b94565b610441601b5481565b6104416104e436600461527b565b601e6020526000908152604090205481565b601954610509906001600160a01b031681565b6040516001600160a01b039091168152602001610425565b610441600a5481565b6104626105383660046155f9565b610bed565b61044161054b3660046154cf565b610c11565b601854610509906001600160a01b031681565b600754610509906001600160a01b031681565b600e54610509906001600160a01b031681565b61046261059736600461527b565b611045565b600154610509906001600160a01b031681565b6104196105bd36600461527b565b611111565b6003546104199060ff1681565b6104626105dd36600461565b565b6112c1565b6104416105f036600461527b565b601d6020526000908152604090205481565b61044160095481565b610441610619366004615581565b6114e7565b61044160165481565b61044161063536600461540e565b611866565b6005546105099061010090046001600160a01b031681565b610462611b0e565b610462610668366004615356565b611c0b565b61046261067b36600461565b565b611c3e565b61046261068e366004615643565b611cb3565b6104416106a13660046154cf565b611cf0565b600054610509906201000090046001600160a01b031681565b61044160025481565b61044160115481565b600654610509906001600160a01b031681565b6104416106f236600461551d565b611d64565b6104626107053660046155f9565b611e58565b601754610509906001600160a01b031681565b61046261072b36600461538e565b611e7c565b61046261073e3660046156d7565b611fa1565b610441610751366004615442565b612050565b61046261076436600461527b565b612161565b61044161077736600461540e565b6122dc565b61046261078a36600461527b565b612322565b61044161079d36600461527b565b600d6020526000908152604090205481565b6104626107bd36600461579e565b61243b565b6104196107d036600461527b565b612498565b6104626107e3366004615704565b612732565b6104626107f636600461565b565b61276f565b61046261080936600461527b565b6127bf565b61046261081c3660046152de565b6127e9565b601554610509906001600160a01b031681565b61084761084236600461547f565b6129ed565b60408051928352602083019190915201610425565b610441600f5481565b610441600c5481565b610462612b06565b6104626108843660046152b3565b612b64565b61044161089736600461540e565b612b83565b601a54610509906001600160a01b031681565b6104416108bd366004615643565b600b6020526000908152604090205481565b6104416108dd366004615643565b612bd0565b61044160085481565b6104626108f93660046155f9565b612c87565b601054610509906001600160a01b031681565b60008061091e8585611866565b9050601254811161092f5780610933565b6012545b90506000610942868684612cdf565b90506109518686868585612f56565b9695505050505050565b6001600160a01b0381166109b65760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff1615610a225760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b60648201526084016109ad565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b03831662010000810262010000600160b01b03199092169190911782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b610aa3613082565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce2290602001610a90565b610af9613082565b60035460ff1615158115151415610b0d5750565b6003805460ff191682151590811790915560ff1615610b2b57426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec590602001610a90565b50565b600080610b7485856122dc565b9050808311610b8c57610b89858585846130fc565b91505b509392505050565b600080610ba18585611866565b90506000610bb782670de0b6b3a7640000615a8f565b90508115610be4576011548210610bce5781610bd2565b6011545b91506109518686868585600f54613181565b50509392505050565b610bf5613082565b6001600160a01b039091166000908152601e6020526040902055565b6000600160046000828254610c269190615954565b909155505060045460035460ff1615610c515760405162461bcd60e51b81526004016109ad9061587f565b610c5a87611111565b610ca65760405162461bcd60e51b815260206004820152601e60248201527f4d61726b6574206973206e6f7420696e2054726164696e67207068617365000060448201526064016109ad565b6000610cb28888611866565b90506012548111610cc35780610cc7565b6012545b90506000610cd6898984612cdf565b9050600081118015610ce85750808711155b610d2c5760405162461bcd60e51b81526020600482015260156024820152742737ba1032b737bab3b4103634b8bab4b234ba3c9760591b60448201526064016109ad565b6000610d3b8a8a8a8686612f56565b9050610d4f86670de0b6b3a7640000615954565b81610d62670de0b6b3a76400008a615a31565b610d6c919061599a565b1115610dae5760405162461bcd60e51b81526020600482015260116024820152700a6d8d2e0e0c2ceca40e8dede40d0d2ced607b1b60448201526064016109ad565b6000610dba8b8b613410565b9050610dd16001600160a01b03821633308c6134b7565b6007546040516314edbee160e31b81523060048201526000916001600160a01b039081169163edc892e1918f169063a76df7089060240160206040518083038186803b158015610e2057600080fd5b505afa158015610e34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e589190615763565b6040518263ffffffff1660e01b8152600401610e7691815260200190565b60206040518083038186803b158015610e8e57600080fd5b505afa158015610ea2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ec69190615763565b90508015610f22578b6001600160a01b031663f5571beb6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610f0957600080fd5b505af1158015610f1d573d6000803e3d6000fd5b505050505b600654610f39906001600160a01b03163385613528565b6010546001600160a01b031615610faf576010546040516302c7739b60e01b8152336004820152602481018590526001600160a01b03909116906302c7739b90604401600060405180830381600087803b158015610f9657600080fd5b505af1158015610faa573d6000803e3d6000fd5b505050505b610fbb8c84833361355d565b7f1d6ff70c632edb1e6aba7fbc0148db68c8392e30f9dfaadae2543a2543757cf6338d8d8d87600660009054906101000a90046001600160a01b03168860405161100b97969594939291906157e5565b60405180910390a150909450505050600454811461103b5760405162461bcd60e51b81526004016109ad906158dc565b5095945050505050565b61104e81612498565b61109a5760405162461bcd60e51b815260206004820152601a60248201527f43616e27742065786572636973652074686174206d61726b657400000000000060448201526064016109ad565b806001600160a01b031663851492586040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156110d557600080fd5b505af11580156110e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110d9190615763565b5050565b600754604051633761c52760e11b81526001600160a01b0383811660048301526000921690636ec38a4e9060240160206040518083038186803b15801561115757600080fd5b505afa15801561116b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118f9190615627565b156112bc5760008290506000816001600160a01b03166341bc7b1f6040518163ffffffff1660e01b815260040160606040518083038186803b1580156111d457600080fd5b505afa1580156111e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120c919061567c565b505090506000826001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b15801561124a57600080fd5b505afa15801561125e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611282919061577b565b506000838152600b602052604090205490915015806112a057504281105b6112b85760006112b04283615a8f565b600c54109450505b5050505b919050565b3360009081526014602052604090205460ff16806112ef57506000546201000090046001600160a01b031633145b6113565760405162461bcd60e51b815260206004820152603260248201527f4f6e6c792077686974656c697374656420616464726573736573206f72206f776044820152716e65722063616e206368616e67652049562160701b60648201526084016109ad565b611369670de0b6b3a7640000600a615a31565b811180156113895750611386670de0b6b3a764000061012c615a31565b81105b6113d55760405162461bcd60e51b815260206004820152601960248201527f4956206f757473696465206d696e2f6d61782072616e6765210000000000000060448201526064016109ad565b6005546040516315905ec160e31b8152600481018490526101009091046001600160a01b03169063ac82f6089060240160206040518083038186803b15801561141d57600080fd5b505afa158015611431573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114559190615763565b6114975760405162461bcd60e51b8152602060048201526013602482015272417373657420686173206e6f2070726963652160681b60448201526064016109ad565b6000828152600b602090815260409182902083905581518481529081018390527f715e0a52c0b74c77d2d2012a363ac95b494302ad2abb78ac7406ec93451f1adb91015b60405180910390a15050565b60006001600460008282546114fc9190615954565b909155505060045460035460ff16156115275760405162461bcd60e51b81526004016109ad9061587f565b6001600160a01b0383161561159c5760155460405163bbddaca360e01b81526001600160a01b0385811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b15801561158357600080fd5b505af1158015611597573d6000803e3d6000fd5b505050505b60006115a785613875565b9050600081600f0b1380156115c55750601a54600160a01b900460ff165b61160a5760405162461bcd60e51b81526020600482015260166024820152751d5b9cdd5c1c1bdc9d19590818dbdb1b185d195c985b60521b60448201526064016109ad565b6000806116198c8c8c8a6129ed565b60185491935091506000906001600160a01b038981169116148061164a57506019546001600160a01b038981169116145b6116545782611663565b6116638364e8d4a51000615a31565b90506000601b541180156116a95750670de0b6b3a7640000601b54670de0b6b3a76400006116919190615a8f565b61169b9084615a31565b6116a5919061599a565b8110155b6117035760405162461bcd60e51b815260206004820152602560248201527f416d6f756e742062656c6f77206d617820616c6c6f7765642070656720736c69604482015264707061676560d81b60648201526084016109ad565b61171589670de0b6b3a7640000615954565b8a611728670de0b6b3a764000086615a31565b611732919061599a565b11156117755760405162461bcd60e51b8152602060048201526012602482015271536c69707061676520746f6f20686967682160701b60448201526064016109ad565b8761178b6001600160a01b0382163330876134b7565b601754604051635320bf6b60e11b8152600f87900b60048201526000602482015260448101869052606481018590526001600160a01b039091169063a6417ed690608401602060405180830381600087803b1580156117e957600080fd5b505af11580156117fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118219190615763565b506118328e8e8e868e6000896138da565b96505050505050600454811461185a5760405162461bcd60e51b81526004016109ad906158dc565b50979650505050505050565b600061187183611111565b15611b085760008390506000816001600160a01b0316639e3b34bf6040518163ffffffff1660e01b8152600401604080518083038186803b1580156118b557600080fd5b505afa1580156118c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ed919061577b565b50905060006118fc4283615a8f565b9050600062015180611916670de0b6b3a764000084615a31565b611920919061599a565b90506000846001600160a01b031663668aa8246040518163ffffffff1660e01b815260040160206040518083038186803b15801561195d57600080fd5b505afa158015611971573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119959190615763565b9050600080866001600160a01b03166341bc7b1f6040518163ffffffff1660e01b815260040160606040518083038186803b1580156119d357600080fd5b505afa1580156119e7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a0b919061567c565b50601c546000838152600b602052604090819020549051631519a0dd60e31b815260048101889052602481018490526044810189905260648082019290925293955091935090916001600160a01b039091169063a8cd06e89060840160206040518083038186803b158015611a7f57600080fd5b505afa158015611a93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ab79190615763565b611ac1919061599a565b97506001896001811115611ae557634e487b7160e01b600052602160045260246000fd5b1415611b0057611afd88670de0b6b3a7640000615a8f565b97505b505050505050505b92915050565b6001546001600160a01b03163314611b865760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b60648201526084016109ad565b60005460015460408051620100009093046001600160a01b03908116845290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a1600180546000805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b611c13613082565b6001600160a01b03919091166000908152601460205260409020805460ff1916911515919091179055565b611c46613082565b6009829055600a8190556040518281527f1e6a338a58debcc786781a079c4459466b102ad0156cc84f51d25ef7dd8cb9b09060200160405180910390a16040518181527f4af6d03c4624e0a6b868b8f6453e047f23f3ea15e9d08c938bd4c445d7ef19b3906020016114db565b611cbb613082565b600c8190556040518181527fdc469b5583fa9b7ebd3245e1665334cd758c4bef4c5a132c62baca85effacfec90602001610a90565b6000600160046000828254611d059190615954565b909155505060045460035460ff1615611d305760405162461bcd60e51b81526004016109ad9061587f565b611d418787878787600160006138da565b9150600454811461103b5760405162461bcd60e51b81526004016109ad906158dc565b6000600160046000828254611d799190615954565b909155505060045460035460ff1615611da45760405162461bcd60e51b81526004016109ad9061587f565b6001600160a01b03831615611e195760155460405163bbddaca360e01b81526001600160a01b0385811660048301523360248301529091169063bbddaca390604401600060405180830381600087803b158015611e0057600080fd5b505af1158015611e14573d6000803e3d6000fd5b505050505b611e2a8888888888600160006138da565b91506004548114611e4d5760405162461bcd60e51b81526004016109ad906158dc565b509695505050505050565b611e60613082565b6001600160a01b039091166000908152601d6020526040902055565b600054610100900460ff16611e975760005460ff1615611e9b565b303b155b611efe5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016109ad565b600054610100900460ff16158015611f20576000805461ffff19166101011790555b611f298961095b565b611f31612b06565b60058054610100600160a81b0319166101006001600160a01b038b81169190910291909117909155600680546001600160a01b03191691891691909117905560088690556009849055600a839055600c8290558015611f96576000805461ff00191690555b505050505050505050565b611fa9613082565b60058054610100600160a81b0319166101006001600160a01b038516908102919091179091556040519081527ff724a45d041687842411f2b977ef22ab8f43c8f1104f4592b42a00f9b34a643d9060200160405180910390a1600680546001600160a01b0319166001600160a01b0383169081179091556040519081527f74a8764fc8d62d2d844c8c54426bd94ad034e0e92abdf5280ff75e2cbd678fb6906020016114db565b6000808084600181111561207457634e487b7160e01b600052602160045260246000fd5b14612080576000612083565b60015b905060006120918686611866565b905060006120a782670de0b6b3a7640000615a8f565b905060115482106120b857816120bc565b6011545b915060006120cd8888856001613e1e565b905060006120de8986856001613e1e565b90506000871180156120f05750818711155b15612155576121526040518060c001604052808b6001600160a01b031681526020018a600181111561213257634e487b7160e01b600052602160045260246000fd5b815260200189815260200184815260200183815260200186815250613fff565b95505b50505050509392505050565b612169613082565b6007546001600160a01b0316156122045760065460075460405163095ea7b360e01b81526001600160a01b0391821660048201526000602482015291169063095ea7b390604401602060405180830381600087803b1580156121ca57600080fd5b505af11580156121de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122029190615627565b505b600780546001600160a01b0319166001600160a01b0383811691821790925560065460405163095ea7b360e01b8152600481019290925260001960248301529091169063095ea7b390604401602060405180830381600087803b15801561226a57600080fd5b505af115801561227e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122a29190615627565b506040516001600160a01b03821681527f9987372437ace1af79923f26b948aa04afef92b2b7786144c5aae621ea84eb0a90602001610a90565b60006122e783611111565b15611b085760006122f88484611866565b90506012548111612309578061230d565b6012545b905061231a848483612cdf565b949350505050565b61232a613082565b6001600160a01b0381166123725760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b60448201526064016109ad565b600154600160a81b900460ff16156123c25760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b60448201526064016109ad565b600080546001600160a01b038381166201000081810262010000600160b01b031990941693909317938490556001805460ff60a81b1916600160a81b1790556040805193909404909116825260208201527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c9101610a90565b612443613082565b60118390556012829055600881905560408051848152602081018490529081018290527f0e8c2ebd67ea2d796a34f02c777ec06f5faedd1669b272dc08dc7875486ae0809060600160405180910390a1505050565b60075460405163e62b888960e01b81526001600160a01b038381166004830152600092169063e62b88899060240160206040518083038186803b1580156124de57600080fd5b505afa1580156124f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125169190615627565b80156125b157506001826001600160a01b031663b1c9fe6e6040518163ffffffff1660e01b815260040160206040518083038186803b15801561255857600080fd5b505afa15801561256c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125909190615744565b60028111156125af57634e487b7160e01b600052602160045260246000fd5b145b156112bc57600080836001600160a01b031663cc2ee1966040518163ffffffff1660e01b8152600401604080518083038186803b1580156125f157600080fd5b505afa158015612605573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061262991906156a9565b604051634dcb776760e11b815230600482015291935091506000906001600160a01b03841690639b96eece9060240160206040518083038186803b15801561267057600080fd5b505afa158015612684573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a89190615763565b118061231a5750604051634dcb776760e11b81523060048201526000906001600160a01b03831690639b96eece9060240160206040518083038186803b1580156126f157600080fd5b505afa158015612705573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127299190615763565b11949350505050565b61273a613082565b601080546001600160a01b039485166001600160a01b0319918216179091556015805493909416921691909117909155601655565b612777613082565b60008281526013602090815260409182902083905581518481529081018390527f5af395595015797b4d0f26b77c38dd4831298dabc7906ee3d62b80fa75d35c1e91016114db565b6127c7613082565b601c80546001600160a01b0319166001600160a01b0392909216919091179055565b6127f1613082565b601780546001600160a01b03199081166001600160a01b03898116918217909355601a80548316898516908117909155601880548416898616179055601980549093169387169390931790915560405163095ea7b360e01b81526004810191909152600019602482015263095ea7b390604401602060405180830381600087803b15801561287e57600080fd5b505af1158015612892573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128b69190615627565b5060185460405163095ea7b360e01b81526001600160a01b03888116600483015260001960248301529091169063095ea7b390604401602060405180830381600087803b15801561290657600080fd5b505af115801561291a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061293e9190615627565b5060195460405163095ea7b360e01b81526001600160a01b03888116600483015260001960248301529091169063095ea7b390604401602060405180830381600087803b15801561298e57600080fd5b505af11580156129a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c69190615627565b50601a8054921515600160a01b0260ff60a01b1990931692909217909155601b5550505050565b60008060006129fb84613875565b9050600081600f0b138015612a195750601a54600160a01b900460ff165b15612afc57612a29878787610b94565b9150670de0b6b3a7640000612a466005662386f26fc1000061599a565b612a5890670de0b6b3a7640000615954565b6017546040516307211ef760e01b815260006004820152600f85900b6024820152604481018690526001600160a01b03909116906307211ef79060640160206040518083038186803b158015612aad57600080fd5b505afa158015612ac1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ae59190615763565b612aef9190615a31565b612af9919061599a565b92505b5094509492505050565b60055460ff1615612b4f5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b60448201526064016109ad565b6005805460ff19166001908117909155600455565b612b6c613082565b60065461110d906001600160a01b03168383613528565b6000612b8e83611111565b15611b08576000612b9f8484611866565b90508015612bc9576011548110612bb65780612bba565b6011545b905061231a8484836000613e1e565b5092915050565b6005546040516315905ec160e31b81526004810183905260009161010090046001600160a01b03169063ac82f6089060240160206040518083038186803b158015612c1a57600080fd5b505afa158015612c2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c529190615763565b156112bc5760008281526013602052604090205415612c7f57600082815260136020526040902054611b08565b505060085490565b612c8f613082565b600f819055600e80546001600160a01b0319166001600160a01b0384161790556040518181527f01edd423db862fb00774918e3b06d9c1dd3db9a99b5a194c439d2f141876f444906020016114db565b600080612ceb836142ba565b90508015610b8c57600080866001600160a01b031663cc2ee1966040518163ffffffff1660e01b8152600401604080518083038186803b158015612d2e57600080fd5b505afa158015612d42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d6691906156a9565b9092509050600080876001811115612d8e57634e487b7160e01b600052602160045260246000fd5b14612e0f57604051634dcb776760e11b81523060048201526001600160a01b03841690639b96eece9060240160206040518083038186803b158015612dd257600080fd5b505afa158015612de6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e0a9190615763565b612e86565b604051634dcb776760e11b81523060048201526001600160a01b03831690639b96eece9060240160206040518083038186803b158015612e4e57600080fd5b505afa158015612e62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e869190615763565b90506000670de0b6b3a7640000612e9d8684615a31565b612ea7919061599a565b9050600082612eb58b614311565b612ebf9190615954565b6001600160a01b038b166000908152600d6020526040902054909150612ee6908390615954565b8110612f49576001600160a01b038a166000908152600d60205260408120548390612f119084615a8f565b612f1b9190615a8f565b905083670de0b6b3a7640000612f31898461599a565b612f3b9190615a31565b612f459190615954565b9750505b5050505050509392505050565b600081841161307957600954612f6c9084615a8f565b92506000670de0b6b3a764000080612f86898989886130fc565b612f9890670de0b6b3a7640000615a8f565b612fa29087615a31565b612fac919061599a565b612fb69087615a31565b612fc0919061599a565b90506000670de0b6b3a7640000600f54670de0b6b3a7640000612fe39190615a8f565b612fed9084615a31565b612ff7919061599a565b60075460405163edc892e160e01b8152600481018390529192506001600160a01b03169063edc892e19060240160206040518083038186803b15801561303c57600080fd5b505afa158015613050573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130749190615763565b925050505b95945050505050565b6000546201000090046001600160a01b031633146130fa5760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b60648201526084016109ad565b565b600080600061310b8787614399565b9150915060008083116131355785821161312e576131298287615a8f565b61313f565b600061313f565b61313f8684615954565b9050600086831161315157600061315b565b61315b8784615a8f565b90508082106131755761317287848684868b614655565b94505b50505050949350505050565b6000806131918888876000613e1e565b905060006131d189828a60018111156131ba57634e487b7160e01b600052602160045260246000fd5b146131c65760006131c9565b60015b876001613e1e565b90508187116134045760008061323a6040518060c001604052808d6001600160a01b031681526020018c600181111561321a57634e487b7160e01b600052602160045260246000fd5b81526020018b81526020018681526020018581526020018a815250613fff565b336000908152601e60205260409020549091506132595760095461326a565b336000908152601e60205260409020545b6132749089615954565b97506000811261331c576000670de0b6b3a7640000826132948b83615a50565b61329e91906159ae565b6132a8919061596c565b9050670de0b6b3a76400006132c5662386f26fc1000060026159ae565b6132d790670de0b6b3a7640000615913565b6132e190836159ae565b6132eb919061596c565b9050670de0b6b3a7640000613300828b615913565b61330a908c6159ae565b613314919061596c565b92505061335b565b670de0b6b3a7640000806133308382615913565b61333a908b6159ae565b613344919061596c565b61334e908b6159ae565b613358919061596c565b91505b670de0b6b3a764000061336e8782615913565b61337890846159ae565b613382919061596c565b60075460405163edc892e160e01b8152600481018390529193506001600160a01b03169063edc892e19060240160206040518083038186803b1580156133c757600080fd5b505afa1580156133db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133ff9190615763565b945050505b50509695505050505050565b6000806000846001600160a01b031663cc2ee1966040518163ffffffff1660e01b8152600401604080518083038186803b15801561344d57600080fd5b505afa158015613461573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061348591906156a9565b909250905060008460018111156134ac57634e487b7160e01b600052602160045260246000fd5b14610b8c5780613079565b6040516001600160a01b03808516602483015283166044820152606481018290526135229085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152614759565b50505050565b6040516001600160a01b03831660248201526044810182905261355890849063a9059cbb60e01b906064016134eb565b505050565b600083600f54670de0b6b3a76400006135769190615a8f565b613588670de0b6b3a764000087615a31565b613592919061599a565b61359c9190615a8f565b600f54909150156135c957600e546006546135c4916001600160a01b03918216911683613528565b6135cd565b5060005b6007546001600160a01b03166317fd849a6135e88387615954565b6040518263ffffffff1660e01b815260040161360691815260200190565b60206040518083038186803b15801561361e57600080fd5b505afa158015613632573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136569190615763565b6001600160a01b0386166000908152600d60205260409020546136799190615954565b6001600160a01b038681166000908152600d602052604090819020929092556007549151630bfec24d60e11b8152600481018690529116906317fd849a9060240160206040518083038186803b1580156136d257600080fd5b505afa1580156136e6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061370a9190615763565b6001600160a01b0386166000908152600d602052604090205411613746576001600160a01b0385166000908152600d60205260408120556137ff565b600754604051630bfec24d60e11b8152600481018590526001600160a01b03909116906317fd849a9060240160206040518083038186803b15801561378a57600080fd5b505afa15801561379e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c29190615763565b6001600160a01b0386166000908152600d60205260409020546137e59190615a8f565b6001600160a01b0386166000908152600d60205260409020555b600060165411801561381b57506015546001600160a01b031615155b1561386e57600084601654670de0b6b3a76400006138399190615a8f565b61384b670de0b6b3a764000088615a31565b613855919061599a565b61385f9190615a8f565b905061386c83828761482b565b505b5050505050565b601a546000906001600160a01b038381169116141561389657506001919050565b6018546001600160a01b03838116911614156138b457506002919050565b6019546001600160a01b03838116911614156138d257506003919050565b506000919050565b60006138e588611111565b6139315760405162461bcd60e51b815260206004820152601e60248201527f4d61726b6574206973206e6f7420696e2054726164696e67207068617365000060448201526064016109ad565b5080600061393f8989611866565b9050600061395582670de0b6b3a7640000615a8f565b90506011548210613966578161396a565b6011545b9150600061397b8b8b856000613e1e565b905060008911801561398d5750808911155b6139d15760405162461bcd60e51b81526020600482015260156024820152742737ba1032b737bab3b4103634b8bab4b234ba3c9760591b60448201526064016109ad565b8515613aa157336000908152601d6020526040902054613a16908c908c908c9087908790613a0157600f54613181565b336000908152601d6020526040902054613181565b9350613a2a87670de0b6b3a7640000615954565b88613a3d670de0b6b3a764000087615a31565b613a47919061599a565b1115613a895760405162461bcd60e51b81526020600482015260116024820152700a6d8d2e0e0c2ceca40e8dede40d0d2ced607b1b60448201526064016109ad565b600654613aa1906001600160a01b03163330876134b7565b6000613aae8c8c8c614939565b90508015613c935760075460405163edc892e160e01b8152600481018390526001600160a01b039091169063edc892e19060240160206040518083038186803b158015613afa57600080fd5b505afa158015613b0e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b329190615763565b6006546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015613b7557600080fd5b505afa158015613b89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613bad9190615763565b1015613bfb5760405162461bcd60e51b815260206004820152601c60248201527f4e6f7420656e6f756768207355534420696e20636f6e74726163742e0000000060448201526064016109ad565b60405163140e25ad60e31b8152600481018290526001600160a01b038d169063a0712d6890602401600060405180830381600087803b158015613c3d57600080fd5b505af1158015613c51573d6000803e3d6000fd5b5050506001600160a01b038d166000908152600d6020526040902054613c7991508290615954565b6001600160a01b038d166000908152600d60205260409020555b6000613c9f8d8d613410565b9050613cb56001600160a01b038216338d613528565b6010546001600160a01b031615613d2b576010546040516302c7739b60e01b8152336004820152602481018890526001600160a01b03909116906302c7739b90604401600060405180830381600087803b158015613d1257600080fd5b505af1158015613d26573d6000803e3d6000fd5b505050505b613d368d873361495a565b818b1115613daa576000613d4a838d615a8f565b905060008c613d59838a615a31565b613d63919061599a565b60408051338152602081018590529081018290529091507ff8a5b21533fcaaeee91cd7b3c6ccbaa3f4ab6dd200e61bc560713565b20b1e9a9060600160405180910390a150505b7ff3bfbc0822d1ed667a2b298e71e0304f2c1f4685398189d7c39e412f733150f4338e8e8e8a600660009054906101000a90046001600160a01b031687604051613dfa97969594939291906157e5565b60405180910390a1613e0e8d8d8833614be1565b5050505050979650505050505050565b60008180613e2d575060125483105b1561231a57600954613e3f9084615954565b9250670de0b6b3a764000083101561231a576000670de0b6b3a76400006004600a54613e6b919061599a565b613e7d90670de0b6b3a7640000615a8f565b613e879086615a31565b613e91919061599a565b90506000613e9f8787614d65565b90506000670de0b6b3a7640000613eb68484615a31565b613ec0919061599a565b6001600160a01b0389166000908152600d602052604090205490915081613ee68a614311565b613ef09190615954565b1115613ff4576001600160a01b0388166000908152600d602052604081205482613f198b614311565b613f239190615954565b613f2d9190615a8f565b9050613f3889614311565b811115613f4b57613f4889614311565b90505b6000670de0b6b3a76400006002600a54613f65919061599a565b613f778a670de0b6b3a7640000615a8f565b613f819190615a31565b613f8b919061599a565b9050670de0b6b3a7640000613fa0828a615954565b1015613ff1576000613fb2828a615954565b613fc490670de0b6b3a7640000615a8f565b905080613fd9670de0b6b3a764000085615a31565b613fe3919061599a565b613fed9086615954565b9650505b50505b505050949350505050565b60006011548260a001511015801561401d57506012548260a0015111155b156112bc5760008061403784600001518560200151614399565b9150915060008460400151831161404f57600061405e565b604085015161405e9084615a8f565b90506000856040015184116140825783866040015161407d9190615a8f565b614085565b60005b61408f9084615954565b90508082106140d0576140c96040518060800160405280868152602001858152602001886040015181526020018860800151815250614ef9565b94506142b1565b8386604001511180156140e35750600084115b156142715760008487604001516140fa9190615a8f565b905060006141576040518060c00160405280848152602001888861411e9190615954565b8152600060208201526040016141348589615954565b815260200160008152602001888b606001516141509190615a8f565b905261503b565b9050600061416d89600001518a60200151611866565b89519091506000906141b190828c60200151600181111561419e57634e487b7160e01b600052602160045260246000fd5b146141aa576000611866565b6001611866565b90506000826141c08584615a31565b6141ca919061599a565b905060006141fb60405180608001604052808c81526020018b81526020018c81526020018e60800151815250614ef9565b90506000614209828c6159ae565b905060006142178489615a31565b90506000614225898e615954565b9050806142328385615913565b61423c919061596c565b9d5060008e13156142635760006142538f896159ae565b905061425f878261596c565b9e50505b5050505050505050506142b1565b6142ae6040518060c0016040528088604001518152602001858152602001868152602001838152602001848152602001886060015181525061503b565b94505b50505050919050565b60006011548211156112bc57670de0b6b3a76400006002600a546142de919061599a565b6142f090670de0b6b3a7640000615a8f565b6009546142fd9085615a8f565b6143079190615a31565b611b08919061599a565b600080826001600160a01b03166341bc7b1f6040518163ffffffff1660e01b815260040160606040518083038186803b15801561434d57600080fd5b505afa158015614361573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614385919061567c565b5050905061439281612bd0565b9392505050565b600080600080856001600160a01b031663cc2ee1966040518163ffffffff1660e01b8152600401604080518083038186803b1580156143d757600080fd5b505afa1580156143eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061440f91906156a9565b9092509050600085600181111561443657634e487b7160e01b600052602160045260246000fd5b146144b757604051634dcb776760e11b81523060048201526001600160a01b03821690639b96eece9060240160206040518083038186803b15801561447a57600080fd5b505afa15801561448e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906144b29190615763565b61452e565b604051634dcb776760e11b81523060048201526001600160a01b03831690639b96eece9060240160206040518083038186803b1580156144f657600080fd5b505afa15801561450a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061452e9190615763565b9350600085600181111561455257634e487b7160e01b600052602160045260246000fd5b146145d357604051634dcb776760e11b81523060048201526001600160a01b03831690639b96eece9060240160206040518083038186803b15801561459657600080fd5b505afa1580156145aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145ce9190615763565b61464a565b604051634dcb776760e11b81523060048201526001600160a01b03821690639b96eece9060240160206040518083038186803b15801561461257600080fd5b505afa158015614626573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061464a9190615763565b925050509250929050565b600080866146638488615954565b61466d9190615a8f565b9050600061467b8686615a8f565b90506000670de0b6b3a7640000836146938285615a31565b61469d919061599a565b600a546146aa9190615a31565b6146b4919061599a565b905088156146f75760006146c960028361599a565b90506000816146d88b8e615a8f565b6146e29190615a31565b90506146ee8c8261599a565b9550505061474c565b876000670de0b6b3a76400008561470e8285615a31565b614718919061599a565b600a546147259190615a31565b61472f919061599a565b9050600261473d8285615954565b614747919061599a565b955050505b5050509695505050505050565b60006147ae826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166151719092919063ffffffff16565b80519091501561355857808060200190518101906147cc9190615627565b6135585760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109ad565b601554604051639ca423b360e01b81526001600160a01b0385811660048301526000921690639ca423b39060240160206040518083038186803b15801561487157600080fd5b505afa158015614885573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148a99190615297565b90506001600160a01b038116158015906148c557506000601654115b15613522576006546148e1906001600160a01b03168285613528565b604080516001600160a01b03808416825286166020820152908101849052606081018390527f8fa68a6a8e2fc9ff758a6e64afba8bc2f66fb082999a2c5225c8c49633faded49060800160405180910390a150505050565b6000806149468585614d65565b905082811015610b8c57610b898184615a8f565b600f54600090156149ea57336000908152601d602052604090205461498157600f54614992565b336000908152601d60205260409020545b6149a490670de0b6b3a7640000615954565b6149b6670de0b6b3a764000085615a31565b6149c0919061599a565b6149ca9084615a8f565b600e546006549192506149ea916001600160a01b03908116911683613528565b6007546001600160a01b03166317fd849a614a058386615a8f565b6040518263ffffffff1660e01b8152600401614a2391815260200190565b60206040518083038186803b158015614a3b57600080fd5b505afa158015614a4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614a739190615763565b6001600160a01b0385166000908152600d602052604090205411614aaf576001600160a01b0384166000908152600d6020526040812055614b75565b6007546001600160a01b03166317fd849a614aca8386615a8f565b6040518263ffffffff1660e01b8152600401614ae891815260200190565b60206040518083038186803b158015614b0057600080fd5b505afa158015614b14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614b389190615763565b6001600160a01b0385166000908152600d6020526040902054614b5b9190615a8f565b6001600160a01b0385166000908152600d60205260409020555b6000601654118015614b9157506015546001600160a01b031615155b15613522576000601654670de0b6b3a7640000614bae9190615954565b614bc0670de0b6b3a764000086615a31565b614bca919061599a565b614bd49085615a8f565b905061386e83828661482b565b600080856001600160a01b03166341bc7b1f6040518163ffffffff1660e01b815260040160606040518083038186803b158015614c1d57600080fd5b505afa158015614c31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c55919061567c565b506005546040516315905ec160e31b8152600481018490529294509092506000916101009091046001600160a01b03169063ac82f6089060240160206040518083038186803b158015614ca757600080fd5b505afa158015614cbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614cdf9190615763565b9050600080876001811115614d0457634e487b7160e01b600052602160045260246000fd5b14614d1157828210614d16565b828210155b60408051338152602081018990528215158183015290519192507f80631c28c8a8100630a9d2bce38b276a55426b59f4d47fb06072105118083ec1919081900360600190a15050505050505050565b6000806000846001600160a01b031663cc2ee1966040518163ffffffff1660e01b8152600401604080518083038186803b158015614da257600080fd5b505afa158015614db6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614dda91906156a9565b90925090506000846001811115614e0157634e487b7160e01b600052602160045260246000fd5b14614e8257604051634dcb776760e11b81523060048201526001600160a01b03821690639b96eece9060240160206040518083038186803b158015614e4557600080fd5b505afa158015614e59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e7d9190615763565b613079565b604051634dcb776760e11b81523060048201526001600160a01b03831690639b96eece9060240160206040518083038186803b158015614ec157600080fd5b505afa158015614ed5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130799190615763565b600080614faf6040518060c00160405280856040015181526020018560000151815260200185602001518152602001670de0b6b3a7640000866020015111614f63576020860151614f5290670de0b6b3a7640000615a8f565b8651614f5e9190615954565b614f66565b85515b8152602001670de0b6b3a7640000866020015111614f85576000614f9d565b670de0b6b3a76400008660200151614f9d9190615a8f565b8152602001856060015181525061503b565b90506000614fbe60028361599a565b9050600084604001518560000151614fd69190615a8f565b90506000670de0b6b3a7640000808760000151670de0b6b3a764000085614ffd9190615a31565b615007919061599a565b6150119190615954565b61501c60028661599a565b6150269190615a31565b615030919061599a565b90506142ae81615ad2565b60008082604001518360a0015184602001516150579190615954565b6150619190615a8f565b90506000836080015184606001516150799190615a8f565b90506000670de0b6b3a7640000836150918285615a31565b61509b919061599a565b600a546150a89190615a31565b6150b2919061599a565b6040860151909150156151275760006150cc60028361599a565b9050600081876040015188600001516150e59190615a8f565b6150ef9190615a31565b8751909150670de0b6b3a7640000906151088284615a31565b615112919061599a565b61511c919061599a565b979650505050505050565b60208501516000670de0b6b3a7640000856151428285615a31565b61514c919061599a565b600a546151599190615a31565b615163919061599a565b905060026151128285615954565b606061231a848460008585843b6151ca5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109ad565b600080866001600160a01b031685876040516151e691906157c9565b60006040518083038185875af1925050503d8060008114615223576040519150601f19603f3d011682016040523d82523d6000602084013e615228565b606091505b509150915061511c82828660608315615242575081614392565b8251156152525782518084602001fd5b8160405162461bcd60e51b81526004016109ad919061584c565b8035600281106112bc57600080fd5b60006020828403121561528c578081fd5b813561439281615b18565b6000602082840312156152a8578081fd5b815161439281615b18565b600080604083850312156152c5578081fd5b82356152d081615b18565b946020939093013593505050565b60008060008060008060c087890312156152f6578182fd5b863561530181615b18565b9550602087013561531181615b18565b9450604087013561532181615b18565b9350606087013561533181615b18565b9250608087013561534181615b2d565b8092505060a087013590509295509295509295565b60008060408385031215615368578182fd5b823561537381615b18565b9150602083013561538381615b2d565b809150509250929050565b600080600080600080600080610100898b0312156153aa578182fd5b88356153b581615b18565b975060208901356153c581615b18565b965060408901356153d581615b18565b95506060890135945060808901356153ec81615b18565b979a969950949793969560a0850135955060c08501359460e001359350915050565b60008060408385031215615420578182fd5b823561542b81615b18565b91506154396020840161526c565b90509250929050565b600080600060608486031215615456578283fd5b833561546181615b18565b925061546f6020850161526c565b9150604084013590509250925092565b60008060008060808587031215615494578182fd5b843561549f81615b18565b93506154ad6020860161526c565b92506040850135915060608501356154c481615b18565b939692955090935050565b600080600080600060a086880312156154e6578283fd5b85356154f181615b18565b94506154ff6020870161526c565b94979496505050506040830135926060810135926080909101359150565b60008060008060008060c08789031215615535578384fd5b863561554081615b18565b955061554e6020880161526c565b945060408701359350606087013592506080870135915060a087013561557381615b18565b809150509295509295509295565b600080600080600080600060e0888a03121561559b578081fd5b87356155a681615b18565b96506155b46020890161526c565b955060408801359450606088013593506080880135925060a08801356155d981615b18565b915060c08801356155e981615b18565b8091505092959891949750929550565b600080604083850312156152c5578182fd5b60006020828403121561561c578081fd5b813561439281615b2d565b600060208284031215615638578081fd5b815161439281615b2d565b600060208284031215615654578081fd5b5035919050565b6000806040838503121561566d578182fd5b50508035926020909101359150565b600080600060608486031215615690578081fd5b8351925060208401519150604084015190509250925092565b600080604083850312156156bb578182fd5b82516156c681615b18565b602084015190925061538381615b18565b600080604083850312156156e9578182fd5b82356156f481615b18565b9150602083013561538381615b18565b600080600060608486031215615718578081fd5b833561572381615b18565b9250602084013561573381615b18565b929592945050506040919091013590565b600060208284031215615755578081fd5b815160038110614392578182fd5b600060208284031215615774578081fd5b5051919050565b6000806040838503121561578d578182fd5b505080516020909101519092909150565b6000806000606084860312156157b2578081fd5b505081359360208301359350604090920135919050565b600082516157db818460208701615aa6565b9190910192915050565b6001600160a01b038881168252878116602083015260e08201906002881061581d57634e487b7160e01b600052602160045260246000fd5b87604084015286606084015285608084015280851660a084015280841660c08401525098975050505050505050565b602081526000825180602084015261586b816040850160208701615aa6565b601f01601f19169190910160400192915050565b6020808252603c908201527f5468697320616374696f6e2063616e6e6f7420626520706572666f726d65642060408201527f7768696c652074686520636f6e74726163742069732070617573656400000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b600080821280156001600160ff1b038490038513161561593557615935615aec565b600160ff1b839003841281161561594e5761594e615aec565b50500190565b6000821982111561596757615967615aec565b500190565b60008261597b5761597b615b02565b600160ff1b82146000198414161561599557615995615aec565b500590565b6000826159a9576159a9615b02565b500490565b60006001600160ff1b03818413828413808216868404861116156159d4576159d4615aec565b600160ff1b848712828116878305891216156159f2576159f2615aec565b858712925087820587128484161615615a0d57615a0d615aec565b87850587128184161615615a2357615a23615aec565b505050929093029392505050565b6000816000190483118215151615615a4b57615a4b615aec565b500290565b60008083128015600160ff1b850184121615615a6e57615a6e615aec565b6001600160ff1b0384018313811615615a8957615a89615aec565b50500390565b600082821015615aa157615aa1615aec565b500390565b60005b83811015615ac1578181015183820152602001615aa9565b838111156135225750506000910152565b6000600160ff1b821415615ae857615ae8615aec565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6001600160a01b0381168114610b6457600080fd5b8015158114610b6457600080fdfea2646970667358221220e4f298dc9ba6737b28f580045b8d4edc910789c1f0e310f3455bf38da080f8ae64736f6c63430008040033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.