ERC-20
Overview
Max Total Supply
1,275,384.465883890977615934 ETH-LP
Holders
26
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Balance
3,001.223588319703120249 ETH-LPValue
$0.00Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
ETHPlatform
Compiler Version
v0.6.12+commit.27d51765
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IETHPlatform.sol"; import "./PlatformV2.sol"; //TOOD: Have a transfer function overridden! contract ETHPlatform is PlatformV2, IETHPlatform { constructor(string memory _lpTokenName, string memory _lpTokenSymbolName, uint256 _initialTokenToLPTokenRate, IFeesCalculatorV3 _feesCalculator, ICVIOracleV3 _cviOracle, ILiquidation _liquidation) public PlatformV2(IERC20(address(0)), _lpTokenName, _lpTokenSymbolName, _initialTokenToLPTokenRate, _feesCalculator, _cviOracle, _liquidation) { } function depositETH(uint256 _minLPTokenAmount) external override payable returns (uint256 lpTokenAmount) { lpTokenAmount = deposit(msg.value, _minLPTokenAmount); } function openPositionETH(uint16 _maxCVI, uint168 _maxBuyingPremiumFeePercentage, uint8 _leverage) external override payable returns (uint256 positionUnitsAmount) { require(uint168(msg.value) == msg.value, "Too much ETH"); positionUnitsAmount = openPosition(uint168(msg.value), _maxCVI, _maxBuyingPremiumFeePercentage, _leverage); } function transferTokens(uint256 _tokenAmount) internal override { msg.sender.transfer(_tokenAmount); } // ETH is passed automatically, nothing to do function collectTokens(uint256 _tokenAmount) internal override { } // ETH has already passed, so subtract amount to get balance before run function getTokenBalance(uint256 _tokenAmount) internal view override returns (uint256) { return address(this).balance.sub(_tokenAmount); } function sendProfit(uint256 _amount, IERC20 _token) internal override { payable(address(feesCollector)).transfer(_amount); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.2; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IFeesCollector { function sendProfit(uint256 amount, IERC20 token) external; }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.2; pragma experimental ABIEncoderV2; interface ILiquidation { function setMinLiquidationThreshold(uint16 newMinThreshold) external; function setMinLiquidationReward(uint16 newMaxRewardAmount) external; function setMaxLiquidationReward(uint16 newMaxRewardAmount) external; function isLiquidationCandidate(uint256 positionBalance, bool isPositive, uint256 positionUnitsAmount) external view returns (bool); function getLiquidationReward(uint256 positionBalance, bool isPositive, uint256 positionUnitsAmount) external view returns (uint256 finderFeeAmount); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath16 { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint16 a, uint16 b) internal pure returns (uint16) { uint16 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @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(uint16 a, uint16 b) internal pure returns (uint16) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint16 a, uint16 b, string memory errorMessage) internal pure returns (uint16) { require(b <= a, errorMessage); uint16 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint16 a, uint16 b) internal pure returns (uint16) { // 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 0; } uint16 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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(uint16 a, uint16 b) internal pure returns (uint16) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts 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(uint16 a, uint16 b, string memory errorMessage) internal pure returns (uint16) { require(b > 0, errorMessage); uint16 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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(uint16 a, uint16 b) internal pure returns (uint16) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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(uint16 a, uint16 b, string memory errorMessage) internal pure returns (uint16) { require(b != 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.6.12; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../v1/utils/SafeMath16.sol"; import "./utils/SafeMath168.sol"; import "./interfaces/IPlatformV2.sol"; import "./interfaces/IPositionRewardsV2.sol"; contract PlatformV2 is IPlatformV2, Ownable, ERC20 { using SafeERC20 for IERC20; using SafeMath for uint256; using SafeMath168 for uint168; uint168 public constant MAX_FEE_PERCENTAGE = 10000; uint256 public constant PRECISION_DECIMALS = 1e10; uint256 public constant MAX_CVI_VALUE = 20000; uint256 public immutable initialTokenToLPTokenRate; IERC20 private token; ICVIOracleV3 private cviOracle; ILiquidation private liquidation; IFeesCalculatorV3 private feesCalculator; IFeesCollector internal feesCollector; IPositionRewardsV2 private rewards; uint256 public lpsLockupPeriod = 3 days; uint256 public buyersLockupPeriod = 6 hours; uint256 public totalPositionUnitsAmount; uint256 public totalFundingFeesAmount; uint256 public totalLeveragedTokensAmount; uint80 public latestOracleRoundId; uint32 public latestSnapshotTimestamp; bool private canPurgeLatestSnapshot = false; bool public emergencyWithdrawAllowed = false; bool private purgeSnapshots = true; uint8 public maxAllowedLeverage = 1; address private stakingContractAddress = address(0); mapping(uint256 => uint256) public cviSnapshots; mapping(address => uint256) public lastDepositTimestamp; mapping(address => Position) public override positions; mapping(address => bool) public revertLockedTransfered; constructor(IERC20 _token, string memory _lpTokenName, string memory _lpTokenSymbolName, uint256 _initialTokenToLPTokenRate, IFeesCalculatorV3 _feesCalculator, ICVIOracleV3 _cviOracle, ILiquidation _liquidation) public ERC20(_lpTokenName, _lpTokenSymbolName) { token = _token; initialTokenToLPTokenRate = _initialTokenToLPTokenRate; feesCalculator = _feesCalculator; cviOracle = _cviOracle; liquidation = _liquidation; } function deposit(uint256 _tokenAmount, uint256 _minLPTokenAmount) public override returns (uint256 lpTokenAmount) { require(_tokenAmount > 0, "Tokens amount must be positive"); lastDepositTimestamp[msg.sender] = block.timestamp; (uint16 cviValue,) = updateSnapshots(true); uint256 depositFee = _tokenAmount.mul(uint256(feesCalculator.depositFeePercent())) / MAX_FEE_PERCENTAGE; uint256 tokenAmountToDeposit = _tokenAmount.sub(depositFee); uint256 supply = totalSupply(); uint256 balance = _totalBalance(cviValue); if (supply > 0 && balance > 0) { lpTokenAmount = tokenAmountToDeposit.mul(supply) / balance; } else { lpTokenAmount = tokenAmountToDeposit.mul(initialTokenToLPTokenRate); } emit Deposit(msg.sender, _tokenAmount, lpTokenAmount, depositFee); require(lpTokenAmount >= _minLPTokenAmount, "Too few LP tokens"); require(lpTokenAmount > 0, "Too few tokens"); _mint(msg.sender, lpTokenAmount); collectTokens(_tokenAmount); totalLeveragedTokensAmount = totalLeveragedTokensAmount.add(tokenAmountToDeposit); collectProfit(depositFee); } function withdraw(uint256 _tokenAmount, uint256 _maxLPTokenBurnAmount) external override returns (uint256 burntAmount, uint256 withdrawnAmount) { (burntAmount, withdrawnAmount) = _withdraw(_tokenAmount, false, _maxLPTokenBurnAmount); } function withdrawLPTokens(uint256 _lpTokensAmount) external override returns (uint256 burntAmount, uint256 withdrawnAmount) { require(_lpTokensAmount > 0, "Amount must be positive"); (burntAmount, withdrawnAmount) = _withdraw(0, true, _lpTokensAmount); } struct OpenPositionLocals { uint256 balance; uint256 collateralRatio; uint256 marginDebt; uint256 positionBalance; uint256 latestSnapshot; uint256 openPositionFee; uint256 minPositionUnitsAmount; uint168 buyingPremiumFee; uint168 buyingPremiumFeePercentage; uint168 tokenAmountToOpenPosition; uint256 maxPositionUnitsAmount; uint16 cviValue; } function openPosition(uint168 _tokenAmount, uint16 _maxCVI, uint168 _maxBuyingPremiumFeePercentage, uint8 _leverage) public override returns (uint168 positionUnitsAmount) { require(_leverage > 0, "Leverage must be positive"); require(_leverage <= maxAllowedLeverage, "Leverage excceeds max allowed"); require(_tokenAmount > 0, "Tokens amount must be positive"); require(_maxCVI > 0 && _maxCVI <= MAX_CVI_VALUE, "Bad max CVI value"); OpenPositionLocals memory locals; (locals.cviValue, locals.latestSnapshot) = updateSnapshots(false); require(locals.cviValue <= _maxCVI, "CVI too high"); (uint16 openPositionFeePercent, uint16 buyingPremiumFeeMaxPercent) = feesCalculator.openPositionFees(); // Calculate buying premium fee, assuming the maxmimum locals.openPositionFee = uint256(_tokenAmount).mul(_leverage).mul(openPositionFeePercent) / MAX_FEE_PERCENTAGE; locals.maxPositionUnitsAmount = uint256(_tokenAmount).sub(locals.openPositionFee).mul(_leverage).mul(MAX_CVI_VALUE) / locals.cviValue; locals.minPositionUnitsAmount = locals.maxPositionUnitsAmount. mul(MAX_FEE_PERCENTAGE.sub(buyingPremiumFeeMaxPercent)) / MAX_FEE_PERCENTAGE; locals.balance = getTokenBalance(_tokenAmount); locals.collateralRatio = 0; if (locals.balance > 0) { locals.collateralRatio = (totalPositionUnitsAmount.add(locals.minPositionUnitsAmount)).mul(PRECISION_DECIMALS). div((locals.balance.add(uint256(_tokenAmount) - locals.openPositionFee))); } (locals.buyingPremiumFee, locals.buyingPremiumFeePercentage) = feesCalculator.calculateBuyingPremiumFee(_tokenAmount, _leverage, locals.collateralRatio); require(locals.buyingPremiumFeePercentage <= _maxBuyingPremiumFeePercentage, "Premium fee too high"); // Leaving buying premium in shared pool require(locals.openPositionFee < _tokenAmount, "Open fee too big"); locals.tokenAmountToOpenPosition = (_tokenAmount - uint168(locals.openPositionFee)).sub(locals.buyingPremiumFee).mul(_leverage); Position storage position = positions[msg.sender]; if (position.positionUnitsAmount > 0) { (positionUnitsAmount, locals.marginDebt, locals.positionBalance) = _mergePosition(position, locals.latestSnapshot, locals.cviValue, locals.tokenAmountToOpenPosition, _leverage); uint256 addedTotalLeveragedTokensAmount = totalLeveragedTokensAmount.add(uint256(_tokenAmount).add(locals.positionBalance).mul(_leverage) - locals.openPositionFee); totalLeveragedTokensAmount = addedTotalLeveragedTokensAmount.sub(locals.marginDebt).sub(locals.positionBalance); } else { uint256 __positionUnitsAmount = uint256(locals.tokenAmountToOpenPosition).mul(MAX_CVI_VALUE) / locals.cviValue; positionUnitsAmount = uint168(__positionUnitsAmount); require(positionUnitsAmount == __positionUnitsAmount, "Too much position units"); Position memory newPosition = Position(positionUnitsAmount, _leverage, locals.cviValue, uint32(block.timestamp), uint32(block.timestamp)); positions[msg.sender] = newPosition; totalPositionUnitsAmount = totalPositionUnitsAmount.add(positionUnitsAmount); totalLeveragedTokensAmount = totalLeveragedTokensAmount.add(_tokenAmount * _leverage - locals.openPositionFee); } emit OpenPosition(msg.sender, _tokenAmount, _leverage, locals.openPositionFee.add(locals.buyingPremiumFee), positionUnitsAmount, locals.cviValue); collectTokens(_tokenAmount); locals.balance = locals.balance.add(_tokenAmount); collectProfit(locals.openPositionFee); require(totalPositionUnitsAmount <= locals.balance, "Not enough liquidity"); if (address(rewards) != address(0)) { rewards.reward(msg.sender, positionUnitsAmount, _leverage); } } function closePosition(uint168 _positionUnitsAmount, uint16 _minCVI) external override returns (uint256 tokenAmount) { require(_positionUnitsAmount > 0, "Position units not positive"); require(_minCVI > 0 && _minCVI <= MAX_CVI_VALUE, "Bad min CVI value"); Position storage position = positions[msg.sender]; require(position.positionUnitsAmount >= _positionUnitsAmount, "Not enough opened position units"); require(block.timestamp.sub(position.creationTimestamp) >= buyersLockupPeriod, "Position locked"); (uint16 cviValue, uint256 latestSnapshot) = updateSnapshots(true); require(cviValue >= _minCVI, "CVI too low"); (uint256 positionBalance, uint256 fundingFees, uint256 marginDebt, bool wasLiquidated) = _closePosition(position, _positionUnitsAmount, latestSnapshot, cviValue); // If was liquidated, balance is negative, nothing to return if (wasLiquidated) { return 0; } (uint256 newTotalPositionUnitsAmount, uint256 newTotalFundingFeesAmount) = subtractTotalPositionUnits(_positionUnitsAmount, fundingFees); totalPositionUnitsAmount = newTotalPositionUnitsAmount; totalFundingFeesAmount = newTotalFundingFeesAmount; position.positionUnitsAmount = position.positionUnitsAmount.sub(_positionUnitsAmount); uint256 closePositionFee = positionBalance .mul(uint256(feesCalculator.calculateClosePositionFeePercent(position.creationTimestamp))) .div(MAX_FEE_PERCENTAGE); emit ClosePosition(msg.sender, positionBalance.add(fundingFees), closePositionFee.add(fundingFees), position.positionUnitsAmount, position.leverage, cviValue); if (position.positionUnitsAmount == 0) { delete positions[msg.sender]; } totalLeveragedTokensAmount = totalLeveragedTokensAmount.sub(positionBalance).sub(marginDebt); tokenAmount = positionBalance.sub(closePositionFee); collectProfit(closePositionFee); transferTokens(tokenAmount); } function _closePosition(Position storage _position, uint256 _positionUnitsAmount, uint256 _latestSnapshot, uint16 _cviValue) private returns (uint256 positionBalance, uint256 fundingFees, uint256 marginDebt, bool wasLiquidated) { fundingFees = _calculateFundingFees(cviSnapshots[_position.creationTimestamp], _latestSnapshot, _positionUnitsAmount); (uint256 currentPositionBalance, bool isPositive, uint256 __marginDebt) = __calculatePositionBalance(_positionUnitsAmount, _position.leverage, _cviValue, _position.openCVIValue, fundingFees); // Position might be liquidable but balance is positive, we allow to avoid liquidity in such a condition if (!isPositive) { checkAndLiquidatePosition(msg.sender, false); // Will always liquidate wasLiquidated = true; fundingFees = 0; } else { positionBalance = currentPositionBalance; marginDebt = __marginDebt; } } function liquidatePositions(address[] calldata _positionOwners) external override returns (uint256 finderFeeAmount) { updateSnapshots(true); bool liquidationOccured = false; for ( uint256 i = 0; i < _positionOwners.length; i++) { uint256 positionUnitsAmount = positions[_positionOwners[i]].positionUnitsAmount; if (positionUnitsAmount > 0) { (bool wasLiquidated, uint256 liquidatedAmount, bool isPositive) = checkAndLiquidatePosition(_positionOwners[i], false); if (wasLiquidated) { liquidationOccured = true; finderFeeAmount = finderFeeAmount.add(liquidation.getLiquidationReward(liquidatedAmount, isPositive, positionUnitsAmount)); } } } require(liquidationOccured, "No liquidatable position"); transferTokens(finderFeeAmount); totalLeveragedTokensAmount = totalLeveragedTokensAmount.sub(finderFeeAmount); } function setFeesCollector(IFeesCollector _newCollector) external override onlyOwner { if (address(feesCollector) != address(0) && address(token) != address(0)) { token.safeApprove(address(feesCollector), uint256(-1)); } feesCollector = _newCollector; if (address(_newCollector) != address(0) && address(token) != address(0)) { token.safeApprove(address(feesCollector), uint256(-1)); } } function setFeesCalculator(IFeesCalculatorV3 _newCalculator) external override onlyOwner { feesCalculator = _newCalculator; } function setCVIOracle(ICVIOracleV3 _newOracle) external override onlyOwner { cviOracle = _newOracle; } function setRewards(IPositionRewardsV2 _newRewards) external override onlyOwner { rewards = _newRewards; } function setLiquidation(ILiquidation _newLiquidation) external override onlyOwner { liquidation = _newLiquidation; } function setLatestOracleRoundId(uint80 _newOracleRoundId) external override onlyOwner { latestOracleRoundId = _newOracleRoundId; } function setLPLockupPeriod(uint256 _newLPLockupPeriod) external override onlyOwner { require(_newLPLockupPeriod <= 2 weeks, "Lockup too long"); lpsLockupPeriod = _newLPLockupPeriod; } function setBuyersLockupPeriod(uint256 _newBuyersLockupPeriod) external override onlyOwner { require(_newBuyersLockupPeriod <= 1 weeks, "Lockup too long"); buyersLockupPeriod = _newBuyersLockupPeriod; } function setRevertLockedTransfers(bool _revertLockedTransfers) external override { revertLockedTransfered[msg.sender] = _revertLockedTransfers; } function setEmergencyWithdrawAllowed(bool _newEmergencyWithdrawAllowed) external override onlyOwner { emergencyWithdrawAllowed = _newEmergencyWithdrawAllowed; } function setStakingContractAddress(address _newStakingContractAddress) external override onlyOwner { stakingContractAddress = _newStakingContractAddress; } function setCanPurgeSnapshots(bool _newCanPurgeSnapshots) external override onlyOwner { purgeSnapshots = _newCanPurgeSnapshots; } function setMaxAllowedLeverage(uint8 _newMaxAllowedLeverage) external override onlyOwner { maxAllowedLeverage = _newMaxAllowedLeverage; } function getToken() external view override returns (IERC20) { return token; } function calculatePositionBalance(address _positionAddress) external view override returns (uint256 currentPositionBalance, bool isPositive, uint168 positionUnitsAmount, uint8 leverage, uint256 fundingFees, uint256 marginDebt) { positionUnitsAmount = positions[_positionAddress].positionUnitsAmount; leverage = positions[_positionAddress].leverage; require(positionUnitsAmount > 0, "No position for given address"); (currentPositionBalance, isPositive, fundingFees, marginDebt) = _calculatePositionBalance(_positionAddress, true); } function calculatePositionPendingFees(address _positionAddress, uint168 _positionUnitsAmount) external view override returns (uint256 pendingFees) { Position memory position = positions[_positionAddress]; pendingFees = _calculateFundingFees(cviSnapshots[position.creationTimestamp], cviSnapshots[latestSnapshotTimestamp], _positionUnitsAmount).add( calculateLatestFundingFees(latestSnapshotTimestamp, _positionUnitsAmount)); } function totalBalance() public view override returns (uint256 balance) { (uint16 cviValue,,) = cviOracle.getCVILatestRoundData(); return _totalBalance(cviValue); } function totalBalanceWithAddendum() external view override returns (uint256 balance) { return totalBalance().add(calculateLatestFundingFees(latestSnapshotTimestamp, totalPositionUnitsAmount)); } function calculateLatestTurbulenceIndicatorPercent() external view override returns (uint16) { SnapshotUpdate memory updateData = _updateSnapshots(latestSnapshotTimestamp); if (updateData.updatedTurbulenceData) { return feesCalculator.calculateTurbulenceIndicatorPercent(updateData.totalTime, updateData.totalRounds); } else { return feesCalculator.turbulenceIndicatorPercent(); } } function getLiquidableAddresses(address[] calldata _positionOwners) external view override returns (address[] memory) { address[] memory addressesToLiquidate = new address[](_positionOwners.length); uint256 liquidationAddressesAmount = 0; for (uint256 i = 0; i < _positionOwners.length; i++) { (uint256 currentPositionBalance, bool isBalancePositive,, ) = _calculatePositionBalance(_positionOwners[i], true); if (liquidation.isLiquidationCandidate(currentPositionBalance, isBalancePositive, positions[_positionOwners[i]].positionUnitsAmount)) { addressesToLiquidate[liquidationAddressesAmount] = _positionOwners[i]; liquidationAddressesAmount = liquidationAddressesAmount.add(1); } } address[] memory addressesToActuallyLiquidate = new address[](liquidationAddressesAmount); for (uint256 i = 0; i < liquidationAddressesAmount; i++) { addressesToActuallyLiquidate[i] = addressesToLiquidate[i]; } return addressesToActuallyLiquidate; } function collectTokens(uint256 _tokenAmount) internal virtual { token.safeTransferFrom(msg.sender, address(this), _tokenAmount); } function _withdraw(uint256 _tokenAmount, bool _shouldBurnMax, uint256 _maxLPTokenBurnAmount) internal returns (uint256 burntAmount, uint256 withdrawnAmount) { require(lastDepositTimestamp[msg.sender].add(lpsLockupPeriod) <= block.timestamp, "Funds are locked"); (uint16 cviValue,) = updateSnapshots(true); if (_shouldBurnMax) { burntAmount = _maxLPTokenBurnAmount; _tokenAmount = burntAmount.mul(_totalBalance(cviValue)).div(totalSupply()); } else { require(_tokenAmount > 0, "Tokens amount must be positive"); // Note: rounding up (ceiling) the to-burn amount to prevent precision loss burntAmount = _tokenAmount.mul(totalSupply()).sub(1).div(_totalBalance(cviValue)).add(1); require(burntAmount <= _maxLPTokenBurnAmount, "Too much LP tokens to burn"); } require(burntAmount <= balanceOf(msg.sender), "Not enough LP tokens for account"); uint256 withdrawFee = _tokenAmount.mul(uint256(feesCalculator.withdrawFeePercent())) / MAX_FEE_PERCENTAGE; withdrawnAmount = _tokenAmount.sub(withdrawFee); require(emergencyWithdrawAllowed || getTokenBalance().sub(totalPositionUnitsAmount) >= _tokenAmount, "Collateral ratio broken"); emit Withdraw(msg.sender, _tokenAmount, burntAmount, withdrawFee); _burn(msg.sender, burntAmount); collectProfit(withdrawFee); transferTokens(withdrawnAmount); totalLeveragedTokensAmount = totalLeveragedTokensAmount.sub(_tokenAmount); } struct MergePositionLocals { uint168 oldPositionUnits; uint256 newPositionUnits; uint256 newTotalPositionUnitsAmount; uint256 newTotalFundingFeesAmount; } function _mergePosition(Position storage _position, uint256 _latestSnapshot, uint16 _cviValue, uint256 _leveragedTokenAmount, uint8 _leverage) private returns (uint168 positionUnitsAmount, uint256 marginDebt, uint256 positionBalance) { MergePositionLocals memory locals; locals.oldPositionUnits = _position.positionUnitsAmount; (uint256 currentPositionBalance, uint256 fundingFees, uint256 __marginDebt, bool wasLiquidated) = _closePosition(_position, locals.oldPositionUnits, _latestSnapshot, _cviValue); // If was liquidated, balance is negative if (wasLiquidated) { currentPositionBalance = 0; locals.oldPositionUnits = 0; __marginDebt = 0; locals.oldPositionUnits = 0; } locals.newPositionUnits = currentPositionBalance.mul(_leverage).add(_leveragedTokenAmount).mul(MAX_CVI_VALUE).div(_cviValue); positionUnitsAmount = uint168(locals.newPositionUnits); require(positionUnitsAmount == locals.newPositionUnits, "Too much position units"); _position.creationTimestamp = uint32(block.timestamp); _position.positionUnitsAmount = positionUnitsAmount; _position.openCVIValue = _cviValue; _position.leverage = _leverage; (locals.newTotalPositionUnitsAmount, locals.newTotalFundingFeesAmount) = subtractTotalPositionUnits(locals.oldPositionUnits, fundingFees); totalFundingFeesAmount = locals.newTotalFundingFeesAmount; totalPositionUnitsAmount = locals.newTotalPositionUnitsAmount.add(positionUnitsAmount); marginDebt = __marginDebt; positionBalance = currentPositionBalance; } function transferTokens(uint256 _tokenAmount) internal virtual { token.safeTransfer(msg.sender, _tokenAmount); } function _beforeTokenTransfer(address from, address to, uint256) internal override { if (lastDepositTimestamp[from].add(lpsLockupPeriod) > block.timestamp && lastDepositTimestamp[from] > lastDepositTimestamp[to] && from != stakingContractAddress && to != stakingContractAddress) { require(!revertLockedTransfered[to], "Recipient refuses locked tokens"); lastDepositTimestamp[to] = lastDepositTimestamp[from]; } } function sendProfit(uint256 _amount, IERC20 _token) internal virtual { feesCollector.sendProfit(_amount, _token); } function getTokenBalance() private view returns (uint256) { return getTokenBalance(0); } function getTokenBalance(uint256 _tokenAmount) internal view virtual returns (uint256) { return token.balanceOf(address(this)); } struct SnapshotUpdate { uint256 latestSnapshot; uint256 singleUnitFundingFee; uint256 totalTime; uint256 totalRounds; uint80 newLatestRoundId; uint16 cviValue; bool updatedSnapshot; bool updatedLatestRoundId; bool updatedLatestTimestamp; bool updatedTurbulenceData; } function updateSnapshots(bool _canPurgeLatestSnapshot) private returns (uint16 latestCVIValue, uint256 latestSnapshot) { uint256 latestTimestamp = latestSnapshotTimestamp; SnapshotUpdate memory updateData = _updateSnapshots(latestTimestamp); if (updateData.updatedSnapshot) { cviSnapshots[block.timestamp] = updateData.latestSnapshot; totalFundingFeesAmount = totalFundingFeesAmount.add(updateData.singleUnitFundingFee.mul(totalPositionUnitsAmount) / PRECISION_DECIMALS); } if (updateData.updatedLatestRoundId) { latestOracleRoundId = updateData.newLatestRoundId; } if (updateData.updatedTurbulenceData) { feesCalculator.updateTurbulenceIndicatorPercent(updateData.totalTime, updateData.totalRounds); } if (updateData.updatedLatestTimestamp) { latestSnapshotTimestamp = uint32(block.timestamp); // Delete old snapshot if it can be deleted (not an open snapshot) to save gas if (canPurgeLatestSnapshot && purgeSnapshots) { delete cviSnapshots[latestTimestamp]; } // Update purge since timestamp has changed and it is safe canPurgeLatestSnapshot = _canPurgeLatestSnapshot; } else if (canPurgeLatestSnapshot) { // Update purge only from true to false, so if an open was in the block, will never be purged canPurgeLatestSnapshot = _canPurgeLatestSnapshot; } return (updateData.cviValue, updateData.latestSnapshot); } function _updateSnapshots(uint256 _latestTimestamp) private view returns (SnapshotUpdate memory snapshotUpdate) { (uint16 cviValue, uint80 periodEndRoundId, uint256 periodEndTimestamp) = cviOracle.getCVILatestRoundData(); snapshotUpdate.cviValue = cviValue; snapshotUpdate.latestSnapshot = cviSnapshots[block.timestamp]; if (snapshotUpdate.latestSnapshot != 0) { // Block was already updated snapshotUpdate.singleUnitFundingFee = 0; return snapshotUpdate; } if (latestSnapshotTimestamp == 0) { // For first recorded block snapshotUpdate.latestSnapshot = PRECISION_DECIMALS; snapshotUpdate.updatedSnapshot = true; snapshotUpdate.newLatestRoundId = periodEndRoundId; snapshotUpdate.updatedLatestRoundId = true; snapshotUpdate.updatedLatestTimestamp = true; snapshotUpdate.singleUnitFundingFee = 0; return snapshotUpdate; } uint80 periodStartRoundId = latestOracleRoundId; require(periodEndRoundId >= periodStartRoundId, "Bad round id"); snapshotUpdate.totalRounds = periodEndRoundId - periodStartRoundId; uint256 cviValuesNum = snapshotUpdate.totalRounds > 0 ? 2 : 1; IFeesCalculatorV3.CVIValue[] memory cviValues = new IFeesCalculatorV3.CVIValue[](cviValuesNum); if (snapshotUpdate.totalRounds > 0) { (uint16 periodStartCVIValue, uint256 periodStartTimestamp) = cviOracle.getCVIRoundData(periodStartRoundId); cviValues[0] = IFeesCalculatorV3.CVIValue(periodEndTimestamp.sub(_latestTimestamp), periodStartCVIValue); cviValues[1] = IFeesCalculatorV3.CVIValue(block.timestamp.sub(periodEndTimestamp), cviValue); snapshotUpdate.newLatestRoundId = periodEndRoundId; snapshotUpdate.updatedLatestRoundId = true; snapshotUpdate.totalTime = periodEndTimestamp.sub(periodStartTimestamp); snapshotUpdate.updatedTurbulenceData = true; } else { cviValues[0] = IFeesCalculatorV3.CVIValue(block.timestamp.sub(_latestTimestamp), cviValue); } snapshotUpdate.singleUnitFundingFee = feesCalculator.calculateSingleUnitFundingFee(cviValues); snapshotUpdate.latestSnapshot = cviSnapshots[_latestTimestamp].add(snapshotUpdate.singleUnitFundingFee); snapshotUpdate.updatedSnapshot = true; snapshotUpdate.updatedLatestTimestamp = true; } function _totalBalance(uint16 _cviValue) private view returns (uint256 balance) { return totalLeveragedTokensAmount.add(totalFundingFeesAmount).sub(totalPositionUnitsAmount.mul(_cviValue) / MAX_CVI_VALUE); } function collectProfit(uint256 amount) private { if (amount > 0 && address(feesCollector) != address(0)) { sendProfit(amount, token); } } function checkAndLiquidatePosition(address _positionAddress, bool _withAddendum) private returns (bool wasLiquidated, uint256 liquidatedAmount, bool isPositive) { (uint256 currentPositionBalance, bool isBalancePositive, uint256 fundingFees, uint256 marginDebt) = _calculatePositionBalance(_positionAddress, _withAddendum); isPositive = isBalancePositive; liquidatedAmount = currentPositionBalance; if (liquidation.isLiquidationCandidate(currentPositionBalance, isBalancePositive, positions[_positionAddress].positionUnitsAmount)) { Position memory position = positions[_positionAddress]; (uint256 newTotalPositionUnitsAmount, uint256 newTotalFundingFeesAmount) = subtractTotalPositionUnits(position.positionUnitsAmount, fundingFees); totalPositionUnitsAmount = newTotalPositionUnitsAmount; totalFundingFeesAmount = newTotalFundingFeesAmount; totalLeveragedTokensAmount = totalLeveragedTokensAmount.sub(marginDebt); emit LiquidatePosition(_positionAddress, currentPositionBalance, isBalancePositive, position.positionUnitsAmount); delete positions[_positionAddress]; wasLiquidated = true; } } function subtractTotalPositionUnits(uint168 _positionUnitsAmountToSubtract, uint256 _fundingFeesToSubtract) private view returns (uint256 newTotalPositionUnitsAmount, uint256 newTotalFundingFeesAMount) { newTotalPositionUnitsAmount = totalPositionUnitsAmount.sub(_positionUnitsAmountToSubtract); newTotalFundingFeesAMount = totalFundingFeesAmount; if (newTotalPositionUnitsAmount == 0) { newTotalFundingFeesAMount = 0; } else { newTotalFundingFeesAMount = newTotalFundingFeesAMount.sub(_fundingFeesToSubtract); } } function _calculatePositionBalance(address _positionAddress, bool _withAddendum) private view returns (uint256 currentPositionBalance, bool isPositive, uint256 fundingFees, uint256 marginDebt) { Position memory position = positions[_positionAddress]; (uint16 cviValue,,) = cviOracle.getCVILatestRoundData(); fundingFees = _calculateFundingFees(cviSnapshots[position.creationTimestamp], cviSnapshots[latestSnapshotTimestamp], position.positionUnitsAmount); if (_withAddendum) { fundingFees = fundingFees.add(calculateLatestFundingFees(latestSnapshotTimestamp, position.positionUnitsAmount)); } (currentPositionBalance, isPositive, marginDebt) = __calculatePositionBalance(position.positionUnitsAmount, position.leverage, cviValue, position.openCVIValue, fundingFees); } function __calculatePositionBalance(uint256 _positionUnits, uint8 _leverage, uint16 _cviValue, uint16 _openCVIValue, uint256 _fundingFees) private pure returns (uint256 currentPositionBalance, bool isPositive, uint256 marginDebt) { uint256 positionBalanceWithoutFees = _positionUnits.mul(_cviValue) / MAX_CVI_VALUE; marginDebt = _leverage > 1 ? _positionUnits.mul(_openCVIValue).mul(_leverage - 1) / MAX_CVI_VALUE / _leverage: 0; uint256 totalDebt = marginDebt.add(_fundingFees); if (positionBalanceWithoutFees >= totalDebt) { currentPositionBalance = positionBalanceWithoutFees.sub(totalDebt); isPositive = true; } else { currentPositionBalance = totalDebt.sub(positionBalanceWithoutFees); } } function _calculateFundingFees(uint256 startTimeSnapshot, uint256 endTimeSnapshot, uint256 positionUnitsAmount) private pure returns (uint256) { return endTimeSnapshot.sub(startTimeSnapshot).mul(positionUnitsAmount) / PRECISION_DECIMALS; } function calculateLatestFundingFees(uint256 startTime, uint256 positionUnitsAmount) private view returns (uint256) { SnapshotUpdate memory updateData = _updateSnapshots(latestSnapshotTimestamp); return _calculateFundingFees(cviSnapshots[startTime], updateData.latestSnapshot, positionUnitsAmount); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.2; pragma experimental ABIEncoderV2; interface ICVIOracleV3 { function getCVIRoundData(uint80 roundId) external view returns (uint16 cviValue, uint256 cviTimestamp); function getCVILatestRoundData() external view returns (uint16 cviValue, uint80 cviRoundId, uint256 cviTimestamp); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.2; interface IETHPlatform { function depositETH(uint256 minLPTokenAmount) external payable returns (uint256 lpTokenAmount); function openPositionETH(uint16 maxCVI, uint168 maxBuyingPremiumFeePercentage, uint8 leverage) external payable returns (uint256 positionUnitsAmount); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.2; pragma experimental ABIEncoderV2; interface IFeesCalculatorV3 { struct CVIValue { uint256 period; uint16 cviValue; } function updateTurbulenceIndicatorPercent(uint256 totalTime, uint256 newRounds) external returns (uint16); function setTurbulenceUpdator(address newUpdator) external; function setDepositFee(uint16 newDepositFeePercentage) external; function setWithdrawFee(uint16 newWithdrawFeePercentage) external; function setOpenPositionFee(uint16 newOpenPositionFeePercentage) external; function setClosePositionFee(uint16 newClosePositionFeePercentage) external; function setClosePositionMaxFee(uint16 newClosePositionMaxFeePercentage) external; function setClosePositionFeeDecay(uint256 newClosePositionFeeDecayPeriod) external; function setOracleHeartbeatPeriod(uint256 newOracleHeartbeatPeriod) external; function setBuyingPremiumFeeMax(uint16 newBuyingPremiumFeeMaxPercentage) external; function setBuyingPremiumThreshold(uint16 newBuyingPremiumThreshold) external; function setTurbulenceStep(uint16 newTurbulenceStepPercentage) external; function setTurbulenceFeeMinPercentThreshold(uint16 _newTurbulenceFeeMinPercentThreshold) external; function calculateTurbulenceIndicatorPercent(uint256 totalHeartbeats, uint256 newRounds) external view returns (uint16); function calculateBuyingPremiumFee(uint168 tokenAmount, uint8 _leverage, uint256 collateralRatio) external view returns (uint168 buyingPremiumFee, uint16 combinedPremiumFeePercentage); function calculateBuyingPremiumFeeWithTurbulence(uint168 _tokenAmount, uint8 _leverage, uint256 _collateralRatio, uint16 _turbulenceIndicatorPercent) external view returns (uint168 buyingPremiumFee, uint16 combinedPremiumFeePercentage); function calculateSingleUnitFundingFee(CVIValue[] calldata cviValues) external pure returns (uint256 fundingFee); function calculateClosePositionFeePercent(uint256 creationTimestamp) external view returns (uint16); function calculateWithdrawFeePercent(uint256 lastDepositTimestamp) external view returns (uint16); function depositFeePercent() external view returns (uint16); function withdrawFeePercent() external view returns (uint16); function openPositionFeePercent() external view returns (uint16); function closePositionFeePercent() external view returns (uint16); function buyingPremiumFeeMaxPercent() external view returns (uint16); function openPositionFees() external view returns (uint16 openPositionFeePercentResult, uint16 buyingPremiumFeeMaxPercentResult); function turbulenceIndicatorPercent() external view returns (uint16); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.2; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./ICVIOracleV3.sol"; import "./IFeesCalculatorV3.sol"; import "./IPositionRewardsV2.sol"; import "../../v1/interfaces/IFeesCollector.sol"; import "../../v1/interfaces/ILiquidation.sol"; interface IPlatformV2 { struct Position { uint168 positionUnitsAmount; uint8 leverage; uint16 openCVIValue; uint32 creationTimestamp; uint32 originalCreationTimestamp; } event Deposit(address indexed account, uint256 tokenAmount, uint256 lpTokensAmount, uint256 feeAmount); event Withdraw(address indexed account, uint256 tokenAmount, uint256 lpTokensAmount, uint256 feeAmount); event OpenPosition(address indexed account, uint256 tokenAmount, uint8 leverage, uint256 feeAmount, uint256 positionUnitsAmount, uint256 cviValue); event ClosePosition(address indexed account, uint256 tokenAmount, uint256 feeAmount, uint256 positionUnitsAmount, uint8 leverage, uint256 cviValue); event LiquidatePosition(address indexed positionAddress, uint256 currentPositionBalance, bool isBalancePositive, uint256 positionUnitsAmount); function deposit(uint256 tokenAmount, uint256 minLPTokenAmount) external returns (uint256 lpTokenAmount); function withdraw(uint256 tokenAmount, uint256 maxLPTokenBurnAmount) external returns (uint256 burntAmount, uint256 withdrawnAmount); function withdrawLPTokens(uint256 lpTokenAmount) external returns (uint256 burntAmount, uint256 withdrawnAmount); function openPosition(uint168 tokenAmount, uint16 maxCVI, uint168 maxBuyingPremiumFeePercentage, uint8 leverage) external returns (uint168 positionUnitsAmount); function closePosition(uint168 positionUnitsAmount, uint16 minCVI) external returns (uint256 tokenAmount); function liquidatePositions(address[] calldata positionOwners) external returns (uint256 finderFeeAmount); function getLiquidableAddresses(address[] calldata positionOwners) external view returns (address[] memory); function setRevertLockedTransfers(bool revertLockedTransfers) external; function setFeesCollector(IFeesCollector newCollector) external; function setFeesCalculator(IFeesCalculatorV3 newCalculator) external; function setCVIOracle(ICVIOracleV3 newOracle) external; function setRewards(IPositionRewardsV2 newRewards) external; function setLiquidation(ILiquidation newLiquidation) external; function setLatestOracleRoundId(uint80 newOracleRoundId) external; function setLPLockupPeriod(uint256 newLPLockupPeriod) external; function setBuyersLockupPeriod(uint256 newBuyersLockupPeriod) external; function setEmergencyWithdrawAllowed(bool newEmergencyWithdrawAllowed) external; function setStakingContractAddress(address newStakingContractAddress) external; function setCanPurgeSnapshots(bool newCanPurgeSnapshots) external; function setMaxAllowedLeverage(uint8 newMaxAllowedLeverage) external; function getToken() external view returns (IERC20); function calculatePositionBalance(address positionAddress) external view returns (uint256 currentPositionBalance, bool isPositive, uint168 positionUnitsAmount, uint8 leverage, uint256 fundingFees, uint256 marginDebt); function calculatePositionPendingFees(address positionAddress, uint168 positionUnitsAmount) external view returns (uint256 pendingFees); function totalBalance() external view returns (uint256 balance); function totalBalanceWithAddendum() external view returns (uint256 balance); function calculateLatestTurbulenceIndicatorPercent() external view returns (uint16); function positions(address positionAddress) external view returns (uint168 positionUnitsAmount, uint8 leverage, uint16 openCVIValue, uint32 creationTimestamp, uint32 originalCreationTimestamp); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.6.2; pragma experimental ABIEncoderV2; import "../../v3/PlatformV2.sol"; interface IPositionRewardsV2 { event Claimed(address indexed account, uint256 rewardAmount); function reward(address account, uint256 positionUnits, uint8 leverage) external; function claimReward() external; function calculatePositionReward(uint256 positionUnits, uint256 positionTimestamp) external view returns (uint256 rewardAmount); function setRewarder(address newRewarder) external; function setMaxDailyReward(uint256 newMaxDailyReward) external; function setRewardCalculationParameters(uint256 newMaxSingleReward, uint256 rewardMaxLinearPositionUnits, uint256 rewardMaxLinearGOVI) external; function setRewardFactor(uint256 newRewardFactor) external; function setMaxClaimPeriod(uint256 newMaxClaimPeriod) external; function setMaxRewardTime(uint256 newMaxRewardTime) external; function setMaxRewardTimePercentageGain(uint256 _newMaxRewardTimePercentageGain) external; function setPlatform(PlatformV2 newPlatform) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath168 { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint168 a, uint168 b) internal pure returns (uint168) { uint168 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @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(uint168 a, uint168 b) internal pure returns (uint168) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint168 a, uint168 b, string memory errorMessage) internal pure returns (uint168) { require(b <= a, errorMessage); uint168 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint168 a, uint168 b) internal pure returns (uint168) { // 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 0; } uint168 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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(uint168 a, uint168 b) internal pure returns (uint168) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts 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(uint168 a, uint168 b, string memory errorMessage) internal pure returns (uint168) { require(b > 0, errorMessage); uint168 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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(uint168 a, uint168 b) internal pure returns (uint168) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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(uint168 a, uint168 b, string memory errorMessage) internal pure returns (uint168) { require(b != 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /* * @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 GSN 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 Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../GSN/Context.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. */ contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view 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 { emit OwnershipTransferred(_owner, address(0)); _owner = 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"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @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) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @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 sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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 mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "../../GSN/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.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 SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 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(IERC20 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' // solhint-disable-next-line max-line-length 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(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _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(IERC20 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 // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @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 in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly 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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
{ "remappings": [], "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "istanbul", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"_lpTokenName","type":"string"},{"internalType":"string","name":"_lpTokenSymbolName","type":"string"},{"internalType":"uint256","name":"_initialTokenToLPTokenRate","type":"uint256"},{"internalType":"contract IFeesCalculatorV3","name":"_feesCalculator","type":"address"},{"internalType":"contract ICVIOracleV3","name":"_cviOracle","type":"address"},{"internalType":"contract ILiquidation","name":"_liquidation","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"positionUnitsAmount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"leverage","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"cviValue","type":"uint256"}],"name":"ClosePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lpTokensAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"positionAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"currentPositionBalance","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isBalancePositive","type":"bool"},{"indexed":false,"internalType":"uint256","name":"positionUnitsAmount","type":"uint256"}],"name":"LiquidatePosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"leverage","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"positionUnitsAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cviValue","type":"uint256"}],"name":"OpenPosition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lpTokensAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"MAX_CVI_VALUE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FEE_PERCENTAGE","outputs":[{"internalType":"uint168","name":"","type":"uint168"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION_DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyersLockupPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"calculateLatestTurbulenceIndicatorPercent","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_positionAddress","type":"address"}],"name":"calculatePositionBalance","outputs":[{"internalType":"uint256","name":"currentPositionBalance","type":"uint256"},{"internalType":"bool","name":"isPositive","type":"bool"},{"internalType":"uint168","name":"positionUnitsAmount","type":"uint168"},{"internalType":"uint8","name":"leverage","type":"uint8"},{"internalType":"uint256","name":"fundingFees","type":"uint256"},{"internalType":"uint256","name":"marginDebt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_positionAddress","type":"address"},{"internalType":"uint168","name":"_positionUnitsAmount","type":"uint168"}],"name":"calculatePositionPendingFees","outputs":[{"internalType":"uint256","name":"pendingFees","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint168","name":"_positionUnitsAmount","type":"uint168"},{"internalType":"uint16","name":"_minCVI","type":"uint16"}],"name":"closePosition","outputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cviSnapshots","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenAmount","type":"uint256"},{"internalType":"uint256","name":"_minLPTokenAmount","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"lpTokenAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minLPTokenAmount","type":"uint256"}],"name":"depositETH","outputs":[{"internalType":"uint256","name":"lpTokenAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"emergencyWithdrawAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_positionOwners","type":"address[]"}],"name":"getLiquidableAddresses","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialTokenToLPTokenRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastDepositTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestOracleRoundId","outputs":[{"internalType":"uint80","name":"","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestSnapshotTimestamp","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_positionOwners","type":"address[]"}],"name":"liquidatePositions","outputs":[{"internalType":"uint256","name":"finderFeeAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lpsLockupPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAllowedLeverage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint168","name":"_tokenAmount","type":"uint168"},{"internalType":"uint16","name":"_maxCVI","type":"uint16"},{"internalType":"uint168","name":"_maxBuyingPremiumFeePercentage","type":"uint168"},{"internalType":"uint8","name":"_leverage","type":"uint8"}],"name":"openPosition","outputs":[{"internalType":"uint168","name":"positionUnitsAmount","type":"uint168"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_maxCVI","type":"uint16"},{"internalType":"uint168","name":"_maxBuyingPremiumFeePercentage","type":"uint168"},{"internalType":"uint8","name":"_leverage","type":"uint8"}],"name":"openPositionETH","outputs":[{"internalType":"uint256","name":"positionUnitsAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"positions","outputs":[{"internalType":"uint168","name":"positionUnitsAmount","type":"uint168"},{"internalType":"uint8","name":"leverage","type":"uint8"},{"internalType":"uint16","name":"openCVIValue","type":"uint16"},{"internalType":"uint32","name":"creationTimestamp","type":"uint32"},{"internalType":"uint32","name":"originalCreationTimestamp","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"revertLockedTransfered","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newBuyersLockupPeriod","type":"uint256"}],"name":"setBuyersLockupPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ICVIOracleV3","name":"_newOracle","type":"address"}],"name":"setCVIOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_newCanPurgeSnapshots","type":"bool"}],"name":"setCanPurgeSnapshots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_newEmergencyWithdrawAllowed","type":"bool"}],"name":"setEmergencyWithdrawAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IFeesCalculatorV3","name":"_newCalculator","type":"address"}],"name":"setFeesCalculator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IFeesCollector","name":"_newCollector","type":"address"}],"name":"setFeesCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newLPLockupPeriod","type":"uint256"}],"name":"setLPLockupPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint80","name":"_newOracleRoundId","type":"uint80"}],"name":"setLatestOracleRoundId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ILiquidation","name":"_newLiquidation","type":"address"}],"name":"setLiquidation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_newMaxAllowedLeverage","type":"uint8"}],"name":"setMaxAllowedLeverage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_revertLockedTransfers","type":"bool"}],"name":"setRevertLockedTransfers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPositionRewardsV2","name":"_newRewards","type":"address"}],"name":"setRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newStakingContractAddress","type":"address"}],"name":"setStakingContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBalanceWithAddendum","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFundingFeesAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalLeveragedTokensAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalPositionUnitsAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenAmount","type":"uint256"},{"internalType":"uint256","name":"_maxLPTokenBurnAmount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"burntAmount","type":"uint256"},{"internalType":"uint256","name":"withdrawnAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lpTokensAmount","type":"uint256"}],"name":"withdrawLPTokens","outputs":[{"internalType":"uint256","name":"burntAmount","type":"uint256"},{"internalType":"uint256","name":"withdrawnAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a06040526203f480600c55615460600d556011805460ff60881b1962ffffff60701b19909116600160801b1716600160881b179055601280546001600160a01b03191690553480156200005257600080fd5b50604051620057ec380380620057ec8339810160408190526200007591620002bf565b60008686868686868585886200008a62000178565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508151620000e99060049060208501906200017c565b508051620000ff9060059060208401906200017c565b5050600680546001600160a01b03998a1661010002610100600160a81b031960ff199092166012179190911617905550608093909352600980549287166001600160a01b031993841617905560078054918716918316919091179055600880549290951691161790925550620003899650505050505050565b3390565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001bf57805160ff1916838001178555620001ef565b82800160010185558215620001ef579182015b82811115620001ef578251825591602001919060010190620001d2565b50620001fd92915062000201565b5090565b5b80821115620001fd576000815560010162000202565b600082601f83011262000229578081fd5b81516001600160401b038082111562000240578283fd5b6040516020601f8401601f191682018101838111838210171562000262578586fd5b806040525081945083825286818588010111156200027f57600080fd5b600092505b83831015620002a3578583018101518284018201529182019162000284565b83831115620002b55760008185840101525b5050505092915050565b60008060008060008060c08789031215620002d8578182fd5b86516001600160401b0380821115620002ef578384fd5b620002fd8a838b0162000218565b9750602089015191508082111562000313578384fd5b506200032289828a0162000218565b9550506040870151935060608701516200033c8162000370565b60808801519093506200034f8162000370565b60a0880151909250620003628162000370565b809150509295509295509295565b6001600160a01b03811681146200038657600080fd5b50565b608051615443620003a9600039806118a3528061242552506154436000f3fe60806040526004361061038c5760003560e01c806370a08231116101dc578063a8a1eb8c11610102578063dd62ed3e116100a0578063ec38a8621161006f578063ec38a86214610a0b578063f2fde38b14610a2b578063f40af47014610a4b578063f59ce83814610a785761038c565b8063dd62ed3e14610996578063e2bbb158146109b6578063e7cb00c1146109d6578063ebc1daf6146109f65761038c565b8063aceda7f9116100dc578063aceda7f914610937578063ad7a672f1461094c578063b00446b814610961578063b152b295146109765761038c565b8063a8a1eb8c146108e2578063a9059cbb146108f7578063ab919ee3146109175761038c565b80638c7e74751161017a57806392c35fdb1161014957806392c35fdb1461085b57806395d89b411461087b578063a457c2d714610890578063a6ca982c146108b05761038c565b80638c7e7475146108075780638d4d7e311461081c5780638da5cb5b146108315780638eb50a38146108465761038c565b80637b04bc06116101b65780637b04bc06146107925780638202c681146107b457806385da0561146107d45780638ab38ed1146107f45761038c565b806370a082311461073d578063715018a61461075d578063745dd850146107725761038c565b806339509351116102c1578063558e44d31161025f5780636185aa3a1161022e5780636185aa3a146106bb578063655d8dec146106dd57806369463fa4146106fd5780636c7156411461071d5761038c565b8063558e44d31461063157806355f575101461065357806360ebfee6146106845780636162129b146106995761038c565b8063452d003f1161029b578063452d003f146105c957806348607250146105e95780635358fbda14610609578063547ef3e61461061c5761038c565b8063395093511461055b5780633f2cdd6c1461057b578063441a3e701461059b5761038c565b80631c1f8aa31161032e5780632f811c22116103085780632f811c22146104ef578063313ce567146105045780633252799214610526578063373071f21461053b5761038c565b80631c1f8aa31461048d57806321df0da7146104ad57806323b872dd146104cf5761038c565b8063095ea7b31161036a578063095ea7b31461040b578063124805861461043857806318160ddd146104585780631a8dd8f71461046d5761038c565b806302b1ba6f1461039157806305621f1a146103c757806306fdde03146103e9575b600080fd5b34801561039d57600080fd5b506103b16103ac36600461443f565b610a98565b6040516103be91906151ef565b60405180910390f35b3480156103d357600080fd5b506103e76103e2366004614733565b610b8b565b005b3480156103f557600080fd5b506103fe610be9565b6040516103be91906148a5565b34801561041757600080fd5b5061042b61042636600461446c565b610c80565b6040516103be919061489a565b34801561044457600080fd5b506103b1610453366004614497565b610c9e565b34801561046457600080fd5b506103b1610e25565b34801561047957600080fd5b506103e76104883660046143ab565b610e2b565b34801561049957600080fd5b506103e76104a83660046143ab565b610e82565b3480156104b957600080fd5b506104c2610ed9565b6040516103be9190614786565b3480156104db57600080fd5b5061042b6104ea3660046143ff565b610eed565b3480156104fb57600080fd5b506103b1610f74565b34801561051057600080fd5b50610519610f7a565b6040516103be91906152dd565b34801561053257600080fd5b506103b1610f83565b34801561054757600080fd5b506103e76105563660046143ab565b610f89565b34801561056757600080fd5b5061042b61057636600461446c565b611077565b34801561058757600080fd5b506103e76105963660046146e2565b6110c5565b3480156105a757600080fd5b506105bb6105b6366004614712565b611122565b6040516103be929190615261565b3480156105d557600080fd5b506105bb6105e43660046146e2565b61113c565b3480156105f557600080fd5b506103e761060436600461474e565b611176565b6103b16106173660046146e2565b6111d0565b34801561062857600080fd5b506103b16111dc565b34801561063d57600080fd5b506106466111e2565b6040516103be9190615131565b34801561065f57600080fd5b5061067361066e3660046143ab565b6111e8565b6040516103be959493929190615145565b34801561069057600080fd5b506103b1611233565b3480156106a557600080fd5b506106ae61123c565b6040516103be91906151e0565b3480156106c757600080fd5b506106d061134b565b6040516103be91906152b8565b3480156106e957600080fd5b506103b16106f83660046143ab565b61135e565b34801561070957600080fd5b506103b161071836600461453e565b611370565b34801561072957600080fd5b506103e76107383660046143ab565b6116a2565b34801561074957600080fd5b506103b16107583660046143ab565b6116f9565b34801561076957600080fd5b506103e7611718565b34801561077e57600080fd5b506103e761078d366004614506565b611797565b34801561079e57600080fd5b506107a76117b7565b6040516103be91906152c9565b3480156107c057600080fd5b506103b16107cf3660046146e2565b6117c6565b3480156107e057600080fd5b506103e76107ef3660046146e2565b6117d8565b6103b161080236600461460f565b611835565b34801561081357600080fd5b5061051961187c565b34801561082857600080fd5b506103b161188c565b34801561083d57600080fd5b506104c2611892565b34801561085257600080fd5b506103b16118a1565b34801561086757600080fd5b50610646610876366004614599565b6118c5565b34801561088757600080fd5b506103fe61201b565b34801561089c57600080fd5b5061042b6108ab36600461446c565b61207c565b3480156108bc57600080fd5b506108d06108cb3660046143ab565b6120e4565b6040516103be96959493929190615217565b3480156108ee57600080fd5b506103b161214f565b34801561090357600080fd5b5061042b61091236600461446c565b612180565b34801561092357600080fd5b506103e76109323660046143ab565b612194565b34801561094357600080fd5b5061042b6121eb565b34801561095857600080fd5b506103b16121fb565b34801561096d57600080fd5b506103b1612297565b34801561098257600080fd5b5061042b6109913660046143ab565b61229d565b3480156109a257600080fd5b506103b16109b13660046143c7565b6122b2565b3480156109c257600080fd5b506103b16109d1366004614712565b6122dd565b3480156109e257600080fd5b506103e76109f1366004614506565b612508565b348015610a0257600080fd5b506103b161255b565b348015610a1757600080fd5b506103e7610a263660046143ab565b612561565b348015610a3757600080fd5b506103e7610a463660046143ab565b6125b8565b348015610a5757600080fd5b50610a6b610a66366004614497565b61266e565b6040516103be91906147fa565b348015610a8457600080fd5b506103e7610a93366004614506565b6128c3565b6000610aa2614250565b506001600160a01b038316600090815260156020908152604091829020825160a08101845290546001600160a81b03808216835260ff600160a81b8304169383019390935261ffff600160b01b8204169382019390935263ffffffff600160c01b840481166060830152600160e01b909304831660808201526011549092610b8392610b3a92600160501b9004909116908616612916565b606083015163ffffffff90811660009081526013602052604080822054601154600160501b90049093168252902054610b7d91906001600160a81b038816612953565b90612979565b949350505050565b610b936129a5565b6000546001600160a01b03908116911614610bc95760405162461bcd60e51b8152600401610bc090614bb4565b60405180910390fd5b6011805460ff909216600160881b0260ff60881b19909216919091179055565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610c755780601f10610c4a57610100808354040283529160200191610c75565b820191906000526020600020905b815481529060010190602001808311610c5857829003601f168201915b505050505090505b90565b6000610c94610c8d6129a5565b84846129a9565b5060015b92915050565b6000610caa6001612a5d565b50506000805b83811015610de757600060156000878785818110610cca57fe5b9050602002016020810190610cdf91906143ab565b6001600160a01b031681526020810191909152604001600020546001600160a81b031690508015610dde576000806000610d3a898987818110610d1e57fe5b9050602002016020810190610d3391906143ab565b6000612c59565b9250925092508215610dda576008546040516332d1de6760e01b815260019750610dd7916001600160a01b0316906332d1de6790610d8090869086908a9060040161524b565b60206040518083038186803b158015610d9857600080fd5b505afa158015610dac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd091906146fa565b8890612979565b96505b5050505b50600101610cb0565b5080610e055760405162461bcd60e51b8152600401610bc09061508c565b610e0e82612e46565b601054610e1b9083612e77565b6010555092915050565b60035490565b610e336129a5565b6000546001600160a01b03908116911614610e605760405162461bcd60e51b8152600401610bc090614bb4565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b610e8a6129a5565b6000546001600160a01b03908116911614610eb75760405162461bcd60e51b8152600401610bc090614bb4565b601280546001600160a01b0319166001600160a01b0392909216919091179055565b60065461010090046001600160a01b031690565b6000610efa848484612eb9565b610f6a84610f066129a5565b610f65856040518060600160405280602881526020016153c1602891396001600160a01b038a16600090815260026020526040812090610f446129a5565b6001600160a01b031681526020810191909152604001600020549190612fce565b6129a9565b5060019392505050565b600e5481565b60065460ff1690565b600c5481565b610f916129a5565b6000546001600160a01b03908116911614610fbe5760405162461bcd60e51b8152600401610bc090614bb4565b600a546001600160a01b031615801590610fe7575060065461010090046001600160a01b031615155b1561101057600a54600654611010916001600160a01b0361010090920482169116600019612ffa565b600a80546001600160a01b0319166001600160a01b0383169081179091551580159061104b575060065461010090046001600160a01b031615155b1561107457600a54600654611074916001600160a01b0361010090920482169116600019612ffa565b50565b6000610c946110846129a5565b84610f6585600260006110956129a5565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490612979565b6110cd6129a5565b6000546001600160a01b039081169116146110fa5760405162461bcd60e51b8152600401610bc090614bb4565b62093a8081111561111d5760405162461bcd60e51b8152600401610bc09061503d565b600d55565b600080611131846000856130f9565b909590945092505050565b6000806000831161115f5760405162461bcd60e51b8152600401610bc0906150c3565b61116c60006001856130f9565b9094909350915050565b61117e6129a5565b6000546001600160a01b039081169116146111ab5760405162461bcd60e51b8152600401610bc090614bb4565b6011805469ffffffffffffffffffff19166001600160501b0392909216919091179055565b6000610c9834836122dd565b600f5481565b61271081565b6015602052600090815260409020546001600160a81b0381169060ff600160a81b8204169061ffff600160b01b8204169063ffffffff600160c01b8204811691600160e01b90041685565b6402540be40081565b600061124661427e565b60115461125f90600160501b900463ffffffff16613380565b9050806101200151156112fd57600954604080830151606084015191516312e001c360e21b81526001600160a01b0390931692634b80070c926112a59291600401615261565b60206040518083038186803b1580156112bd57600080fd5b505afa1580156112d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f591906145f3565b915050610c7d565b600960009054906101000a90046001600160a01b03166001600160a01b031663f359b46f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156112bd57600080fd5b601154600160501b900463ffffffff1681565b60146020526000908152604090205481565b600080836001600160a81b03161161139a5760405162461bcd60e51b8152600401610bc090614f3c565b60008261ffff161180156113b45750614e208261ffff1611155b6113d05760405162461bcd60e51b8152600401610bc090614b13565b33600090815260156020526040902080546001600160a81b038086169116101561140c5760405162461bcd60e51b8152600401610bc090614b7f565b600d54815461142d90429063ffffffff600160c01b909104811690612e7716565b101561144b5760405162461bcd60e51b8152600401610bc090614da0565b6000806114586001612a5d565b915091508461ffff168261ffff1610156114845760405162461bcd60e51b8152600401610bc090614e7b565b60008060008061149f878b6001600160a81b0316878961378f565b935093509350935080156114bd576000975050505050505050610c98565b6000806114ca8c86613829565b600e829055600f8190558a5491935091506114ee906001600160a81b03168d613876565b89546001600160a81b0319166001600160a81b039190911617808a55600954604051636f6bb7a760e01b81526000926115b692612710926115b0926001600160a01b0390921691636f6bb7a79161155591600160c01b900463ffffffff16906004016152b8565b60206040518083038186803b15801561156d57600080fd5b505afa158015611581573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a591906145f3565b8a9061ffff166138b8565b906138f2565b9050337f3989dab79971090c83b28eb2d423aa507b7d4c16f5cf10a4fdb05835cafba36a6115e48989612979565b6115ee848a612979565b8d60000160009054906101000a90046001600160a81b03168e60000160159054906101000a900460ff168e60405161162a95949392919061526f565b60405180910390a289546001600160a81b031661165257336000908152601560205260408120555b6116718561166b89601054612e7790919063ffffffff16565b90612e77565b60105561167e8782612e77565b9a5061168981613934565b6116928b612e46565b5050505050505050505092915050565b6116aa6129a5565b6000546001600160a01b039081169116146116d75760405162461bcd60e51b8152600401610bc090614bb4565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166000908152600160205260409020545b919050565b6117206129a5565b6000546001600160a01b0390811691161461174d5760405162461bcd60e51b8152600401610bc090614bb4565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b336000908152601660205260409020805460ff1916911515919091179055565b6011546001600160501b031681565b60136020526000908152604090205481565b6117e06129a5565b6000546001600160a01b0390811691161461180d5760405162461bcd60e51b8152600401610bc090614bb4565b621275008111156118305760405162461bcd60e51b8152600401610bc09061503d565b600c55565b600034346001600160a81b03161461185f5760405162461bcd60e51b8152600401610bc090614950565b61186b348585856118c5565b6001600160a81b0316949350505050565b601154600160881b900460ff1681565b60105481565b6000546001600160a01b031690565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000808260ff16116118e95760405162461bcd60e51b8152600401610bc090614ea0565b60115460ff600160881b909104811690831611156119195760405162461bcd60e51b8152600401610bc090614d69565b6000856001600160a81b0316116119425760405162461bcd60e51b8152600401610bc090614c82565b60008461ffff1611801561195c5750614e208461ffff1611155b6119785760405162461bcd60e51b8152600401610bc090614c57565b6119806142d2565b61198a6000612a5d565b608083015261ffff908116610160830181905290861610156119be5760405162461bcd60e51b8152600401610bc090614ac5565b600954604080516307e3dd0f60e41b8152815160009384936001600160a01b0390911692637e3dd0f09260048083019392829003018186803b158015611a0357600080fd5b505afa158015611a17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3b9190614656565b9092509050612710611a6761ffff8416611a616001600160a81b038c1660ff8a166138b8565b906138b8565b81611a6e57fe5b0460a0840181905261016084015161ffff1690611aa490614e2090611a619060ff8a169082906001600160a81b038f1690612e77565b81611aab57fe5b04610140840152612710611adb611ac68261ffff8516613876565b610140860151906001600160a81b03166138b8565b81611ae257fe5b0460c0840152611afa6001600160a81b03891661396f565b8084526000602085015215611b515760a08301518351611b4b91611b2991906001600160a81b038c1603612979565b6115b06402540be400611a618760c00151600e5461297990919063ffffffff16565b60208401525b6009546020840151604051630d82490360e41b81526001600160a01b039092169163d824903091611b88918c918a91600401615183565b604080518083038186803b158015611b9f57600080fd5b505afa158015611bb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd7919061456b565b61ffff1661010085018190526001600160a81b0391821660e08601529087161015611c145760405162461bcd60e51b8152600401610bc0906149fe565b876001600160a81b03168360a0015110611c405760405162461bcd60e51b8152600401610bc090614d3f565b611c7c8560ff16611c6d8560e001518660a001518c036001600160a81b031661387690919063ffffffff16565b6001600160a81b03169061397b565b6001600160a81b03908116610120850152336000908152601560205260409020805490911615611d4657611cca8185608001518661016001518761012001516001600160a81b03168a6139d6565b866040018760600182815250828152508297505050506000611d1c8560a00151611d118960ff16611a6189606001518f6001600160a81b031661297990919063ffffffff16565b601054919003612979565b9050611d3d856060015161166b876040015184612e7790919063ffffffff16565b60105550611ecd565b600084610160015161ffff16611d75614e208761012001516001600160a81b03166138b890919063ffffffff16565b81611d7c57fe5b04905080955080866001600160a81b031614611daa5760405162461bcd60e51b8152600401610bc090614f05565b611db2614250565b506040805160a0810182526001600160a81b0380891680835260ff808c1660208086019182526101608c015161ffff90811687890190815263ffffffff42811660608a0181815260808b0191825233600090815260159096529a90942089518154965193519b5195518316600160e01b026001600160e01b03968416600160c01b0263ffffffff60c01b199d909616600160b01b0261ffff60b01b1995909916600160a81b0260ff60a81b1992909b166001600160a81b0319909816979097171698909817919091169490941797909716969096179590951694909417909155600e549192611ea392919061297916565b600e5560a0860151601054611ec7916001600160a81b0360ff8c168f021603612979565b60105550505b336001600160a01b03167fe485c81af56f49547b2ea1b6886083d8e3a7ef50fe670c9574bd5d4b2dd7d4628a88611f1e8860e001516001600160a81b03168960a0015161297990919063ffffffff16565b610160890151604051611f35949392918c916151a7565b60405180910390a2611f4f896001600160a81b0316611074565b8351611f64906001600160a81b038b16612979565b845260a0840151611f7490613934565b8351600e541115611f975760405162461bcd60e51b8152600401610bc090614ed7565b600b546001600160a01b03161561200f57600b54604051630bf1944760e21b81526001600160a01b0390911690632fc6511c90611fdc90339089908b9060040161479a565b600060405180830381600087803b158015611ff657600080fd5b505af115801561200a573d6000803e3d6000fd5b505050505b50505050949350505050565b60058054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610c755780601f10610c4a57610100808354040283529160200191610c75565b6000610c946120896129a5565b84610f65856040518060600160405280602581526020016153e960259139600260006120b36129a5565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190612fce565b6001600160a01b03811660009081526015602052604081205481906001600160a81b03811690600160a81b900460ff168280836121335760405162461bcd60e51b8152600401610bc090614a8e565b61213e876001613b17565b929a91995095975093955092915050565b601154600e5460009161217b9161217391600160501b900463ffffffff1690612916565b610b7d6121fb565b905090565b6000610c9461218d6129a5565b8484612eb9565b61219c6129a5565b6000546001600160a01b039081169116146121c95760405162461bcd60e51b8152600401610bc090614bb4565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b601154600160781b900460ff1681565b600080600760009054906101000a90046001600160a01b03166001600160a01b031663c1639a2b6040518163ffffffff1660e01b815260040160606040518083038186803b15801561224c57600080fd5b505afa158015612260573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061228491906146a0565b5050905061229181613cc3565b91505090565b614e2081565b60166020526000908152604090205460ff1681565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b60008083116122fe5760405162461bcd60e51b8152600401610bc090614c82565b33600090815260146020526040812042905561231a6001612a5d565b50905060006127106001600160a81b03166123bf600960009054906101000a90046001600160a01b03166001600160a01b031663cc1252ae6040518163ffffffff1660e01b815260040160206040518083038186803b15801561237c57600080fd5b505afa158015612390573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b491906145f3565b879061ffff166138b8565b816123c657fe5b04905060006123d58683612e77565b905060006123e1610e25565b905060006123ee85613cc3565b90506000821180156124005750600081115b1561241f578061241084846138b8565b8161241757fe5b04955061244c565b612449837f00000000000000000000000000000000000000000000000000000000000000006138b8565b95505b336001600160a01b03167f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e898887604051612489939291906152a2565b60405180910390a2868610156124b15760405162461bcd60e51b8152600401610bc090614a2c565b600086116124d15760405162461bcd60e51b8152600401610bc090614aeb565b6124db3387613d03565b6124e488611074565b6010546124f19084612979565b6010556124fd84613934565b505050505092915050565b6125106129a5565b6000546001600160a01b0390811691161461253d5760405162461bcd60e51b8152600401610bc090614bb4565b60118054911515600160801b0260ff60801b19909216919091179055565b600d5481565b6125696129a5565b6000546001600160a01b039081169116146125965760405162461bcd60e51b8152600401610bc090614bb4565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b6125c06129a5565b6000546001600160a01b039081169116146125ed5760405162461bcd60e51b8152600401610bc090614bb4565b6001600160a01b0381166126135760405162461bcd60e51b8152600401610bc090614976565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6060808267ffffffffffffffff8111801561268857600080fd5b506040519080825280602002602001820160405280156126b2578160200160208202803683370190505b5090506000805b84811015612827576000806126ef8888858181106126d357fe5b90506020020160208101906126e891906143ab565b6001613b17565b505060085491935091506001600160a01b031663f66f29e88383601560008d8d8a81811061271957fe5b905060200201602081019061272e91906143ab565b6001600160a01b03168152602081019190915260409081016000205490516001600160e01b031960e086901b1681526127759392916001600160a81b0316906004016151f8565b60206040518083038186803b15801561278d57600080fd5b505afa1580156127a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c59190614522565b1561281d578787848181106127d657fe5b90506020020160208101906127eb91906143ab565b8585815181106127f757fe5b6001600160a01b039092166020928302919091019091015261281a846001612979565b93505b50506001016126b9565b5060608167ffffffffffffffff8111801561284157600080fd5b5060405190808252806020026020018201604052801561286b578160200160208202803683370190505b50905060005b828110156128b95783818151811061288557fe5b602002602001015182828151811061289957fe5b6001600160a01b0390921660209283029190910190910152600101612871565b5095945050505050565b6128cb6129a5565b6000546001600160a01b039081169116146128f85760405162461bcd60e51b8152600401610bc090614bb4565b60118054911515600160781b0260ff60781b19909216919091179055565b600061292061427e565b60115461293990600160501b900463ffffffff16613380565b6000858152601360205260409020548151919250610b8391855b60006402540be40061296983611a618688612e77565b8161297057fe5b04949350505050565b60008282018381101561299e5760405162461bcd60e51b8152600401610bc090614a57565b9392505050565b3390565b6001600160a01b0383166129cf5760405162461bcd60e51b8152600401610bc090614dc9565b6001600160a01b0382166129f55760405162461bcd60e51b8152600401610bc0906149bc565b6001600160a01b0380841660008181526002602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590612a509085906151ef565b60405180910390a3505050565b6011546000908190600160501b900463ffffffff16612a7a61427e565b612a8382613380565b90508060c0015115612ad857805142600090815260136020908152604090912091909155600e5490820151612ad4916402540be40091612ac2916138b8565b81612ac957fe5b600f54919004612979565b600f555b8060e0015115612b0a5760808101516011805469ffffffffffffffffffff19166001600160501b039092169190911790555b80610120015115612ba25760095460408083015160608401519151630d14ef1560e41b81526001600160a01b039093169263d14ef15092612b4e9291600401615261565b602060405180830381600087803b158015612b6857600080fd5b505af1158015612b7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba091906145f3565b505b80610100015115612c1d576011805463ffffffff60501b1916600160501b4263ffffffff16021790819055600160701b900460ff168015612bec5750601154600160801b900460ff165b15612c01576000828152601360205260408120555b6011805460ff60701b1916600160701b87151502179055612c47565b601154600160701b900460ff1615612c47576011805460ff60701b1916600160701b871515021790555b60a08101519051909350915050915091565b6000806000806000806000612c6e8989613b17565b6008546001600160a01b038e811660009081526015602052604090819020549051631ecde53d60e31b8152969c50949a508b99508a9850929650909450169163f66f29e891612ccf91889188916001600160a81b03909116906004016151f8565b60206040518083038186803b158015612ce757600080fd5b505afa158015612cfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1f9190614522565b15612e3b57612d2c614250565b506001600160a01b0389166000908152601560209081526040808320815160a08101835290546001600160a81b03811680835260ff600160a81b8304169483019490945261ffff600160b01b8204169282019290925263ffffffff600160c01b830481166060830152600160e01b909204909116608082015291908190612db39086613829565b600e829055600f8190556010549193509150612dcf9085612e77565b60105582516040516001600160a01b038e16917f302eaf71224bcd9ed28854139aa87a32dc89622b38a4d8ce4160475aa57a7f1391612e12918b918b91906151f8565b60405180910390a25050506001600160a01b038916600090815260156020526040812055600196505b505050509250925092565b604051339082156108fc029083906000818181858888f19350505050158015612e73573d6000803e3d6000fd5b5050565b600061299e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612fce565b6001600160a01b038316612edf5760405162461bcd60e51b8152600401610bc090614cfa565b6001600160a01b038216612f055760405162461bcd60e51b8152600401610bc0906148d8565b612f10838383613dc3565b612f4d8160405180606001604052806026815260200161539b602691396001600160a01b0386166000908152600160205260409020549190612fce565b6001600160a01b038085166000908152600160205260408082209390935590841681522054612f7c9082612979565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612a509085906151ef565b60008184841115612ff25760405162461bcd60e51b8152600401610bc091906148a5565b505050900390565b8015806130825750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e9061303090309086906004016147c7565b60206040518083038186803b15801561304857600080fd5b505afa15801561305c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308091906146fa565b155b61309e5760405162461bcd60e51b8152600401610bc090614fe7565b6130f48363095ea7b360e01b84846040516024016130bd9291906147e1565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613eb2565b505050565b600c543360009081526014602052604081205490918291429161311c9190612979565b111561313a5760405162461bcd60e51b8152600401610bc090614fbd565b60006131466001612a5d565b50905084156131775783925061317061315d610e25565b6115b061316984613cc3565b86906138b8565b95506131e1565b600086116131975760405162461bcd60e51b8152600401610bc090614c82565b6131bf6001610b7d6131a884613cc3565b6115b0600161166b6131b8610e25565b8d906138b8565b9250838311156131e15760405162461bcd60e51b8152600401610bc090614c20565b6131ea336116f9565b8311156132095760405162461bcd60e51b8152600401610bc09061491b565b60006127106001600160a81b03166132ab600960009054906101000a90046001600160a01b03166001600160a01b031663495ef7056040518163ffffffff1660e01b815260040160206040518083038186803b15801561326857600080fd5b505afa15801561327c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132a091906145f3565b899061ffff166138b8565b816132b257fe5b0490506132bf8782612e77565b601154909350600160781b900460ff16806132e75750866132e4600e5461166b613f41565b10155b6133035760405162461bcd60e51b8152600401610bc090614e44565b336001600160a01b03167f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca94888684604051613340939291906152a2565b60405180910390a26133523385613f4d565b61335b81613934565b61336483612e46565b6010546133719088612e77565b60105550919590945092505050565b61338861427e565b6000806000600760009054906101000a90046001600160a01b03166001600160a01b031663c1639a2b6040518163ffffffff1660e01b815260040160606040518083038186803b1580156133db57600080fd5b505afa1580156133ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341391906146a0565b61ffff831660a08801524260009081526013602052604090205480885292955090935091501561344c5750506000602083015250611713565b601154600160501b900463ffffffff1661349c57506402540be4008352600160c084018190526001600160501b03909116608084015260e083018190526101008301525060006020820152611713565b6011546001600160501b039081169083168111156134cc5760405162461bcd60e51b8152600401610bc090615066565b6001600160501b0381840316606086018190526000906134ed5760016134f0565b60025b60ff16905060608167ffffffffffffffff8111801561350e57600080fd5b5060405190808252806020026020018201604052801561354857816020015b613535614352565b81526020019060019003908161352d5790505b5060608801519091501561369857600754604051635a7b84b160e01b815260009182916001600160a01b0390911690635a7b84b19061358b9088906004016152c9565b604080518083038186803b1580156135a257600080fd5b505afa1580156135b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135da9190614673565b9150915060405180604001604052806135fc8c89612e7790919063ffffffff16565b81526020018361ffff168152508360008151811061361657fe5b6020026020010181905250604051806040016040528061363f8842612e7790919063ffffffff16565b81526020018961ffff168152508360018151811061365957fe5b60209081029190910101526001600160501b03871660808a0152600160e08a01526136848682612e77565b60408a0152505060016101208801526136d3565b60408051808201909152806136ad428b612e77565b81526020018761ffff16815250816000815181106136c757fe5b60200260200101819052505b600954604051635d769d1760e11b81526001600160a01b039091169063baed3a2e90613703908490600401614847565b60206040518083038186803b15801561371b57600080fd5b505afa15801561372f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061375391906146fa565b602080890182905260008a81526013909152604090205461377391612979565b87525050600160c0860181905261010086015250505050919050565b8354600160c01b900463ffffffff166000908152601360205260408120548190819081906137be908789612953565b8854909350600090819081906137ee908b90600160a81b810460ff16908b90600160b01b900461ffff168a614023565b9250925092508161381457613804336000612c59565b505050600193506000955061381b565b8296508094505b505050945094509450949050565b60008061384a846001600160a81b0316600e54612e7790919063ffffffff16565b9150600f54905081600014156138625750600061386f565b61386c8184612e77565b90505b9250929050565b600061299e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506140d4565b6000826138c757506000610c98565b828202828482816138d457fe5b041461299e5760405162461bcd60e51b8152600401610bc090614b3e565b600061299e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061410b565b60008111801561394e5750600a546001600160a01b031615155b156110745760065461107490829061010090046001600160a01b0316614142565b6000610c984783612e77565b60006001600160a81b03831661399357506000610c98565b8282026001600160a81b0380841690808616908316816139af57fe5b046001600160a81b03161461299e5760405162461bcd60e51b8152600401610bc090614b3e565b60008060006139e3614369565b88546001600160a81b0316808252600090819081908190613a07908e908e8e61378f565b93509350935093508015613a2057600080865293508391505b613a488b61ffff166115b0614e20611a618e610b7d8f60ff168b6138b890919063ffffffff16565b6020860181905297506001600160a81b0388168814613a795760405162461bcd60e51b8152600401610bc090614f05565b8c5463ffffffff60c01b1916600160c01b4263ffffffff1602176001600160a81b0319166001600160a81b0389161761ffff60b01b1916600160b01b61ffff8d16021760ff60a81b1916600160a81b60ff8b1602178d558451613adc9084613829565b6060870181905260408701829052600f55613b00906001600160a81b038a16612979565b600e5550959b959a50909850939650505050505050565b600080600080613b25614250565b506001600160a01b038087166000908152601560209081526040808320815160a08101835290546001600160a81b038116825260ff600160a81b8204169382019390935261ffff600160b01b8404168183015263ffffffff600160c01b84048116606080840191909152600160e01b909404166080820152600754825163c1639a2b60e01b815292519195169263c1639a2b9260048082019391829003018186803b158015613bd357600080fd5b505afa158015613be7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0b91906146a0565b5050606083015163ffffffff90811660009081526013602052604080822054601154600160501b900490931682529020548451929350613c53926001600160a81b0316612953565b93508615613c8f576011548251613c8c91613c8591600160501b90910463ffffffff16906001600160a81b0316612916565b8590612979565b93505b613cb182600001516001600160a81b0316836020015183856040015188614023565b919a9099509497509550929350505050565b6000610c98614e20613ce48461ffff16600e546138b890919063ffffffff16565b81613ceb57fe5b0461166b600f5460105461297990919063ffffffff16565b6001600160a01b038216613d295760405162461bcd60e51b8152600401610bc0906150fa565b613d3560008383613dc3565b600354613d429082612979565b6003556001600160a01b038216600090815260016020526040902054613d689082612979565b6001600160a01b0383166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90613db79085906151ef565b60405180910390a35050565b600c546001600160a01b0384166000908152601460205260409020544291613deb9190612979565b118015613e1857506001600160a01b03808316600090815260146020526040808220549286168252902054115b8015613e3257506012546001600160a01b03848116911614155b8015613e4c57506012546001600160a01b03838116911614155b156130f4576001600160a01b03821660009081526016602052604090205460ff1615613e8a5760405162461bcd60e51b8152600401610bc090614be9565b6001600160a01b03808416600090815260146020526040808220549285168252902055505050565b6060613f07826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661417c9092919063ffffffff16565b8051909150156130f45780806020019051810190613f259190614522565b6130f45760405162461bcd60e51b8152600401610bc090614f73565b600061217b600061396f565b6001600160a01b038216613f735760405162461bcd60e51b8152600401610bc090614cb9565b613f7f82600083613dc3565b613fbc81604051806060016040528060228152602001615379602291396001600160a01b0385166000908152600160205260409020549190612fce565b6001600160a01b038316600090815260016020526040902055600354613fe29082612e77565b6003556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90613db79085906151ef565b6000808080614e206140398a61ffff8a166138b8565b8161404057fe5b04905060018860ff161161405557600061408e565b8760ff16614e2061407d60018b0360ff16611a618a61ffff168e6138b890919063ffffffff16565b8161408457fe5b048161408c57fe5b045b9150600061409c8387612979565b90508082106140ba576140af8282612e77565b9450600193506140c7565b6140c48183612e77565b94505b5050955095509592505050565b6000836001600160a81b0316836001600160a81b031611158290612ff25760405162461bcd60e51b8152600401610bc091906148a5565b6000818361412c5760405162461bcd60e51b8152600401610bc091906148a5565b50600083858161413857fe5b0495945050505050565b600a546040516001600160a01b039091169083156108fc029084906000818181858888f193505050501580156130f4573d6000803e3d6000fd5b6060610b83848460008560606141918561424a565b6141ad5760405162461bcd60e51b8152600401610bc090614e0d565b60006060866001600160a01b031685876040516141ca919061476a565b60006040518083038185875af1925050503d8060008114614207576040519150601f19603f3d011682016040523d82523d6000602084013e61420c565b606091505b50915091508115614220579150610b839050565b8051156142305780518082602001fd5b8360405162461bcd60e51b8152600401610bc091906148a5565b3b151590565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b6040518061018001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a81b0316815260200160006001600160a81b0316815260200160006001600160a81b0316815260200160008152602001600061ffff1681525090565b604080518082019091526000808252602082015290565b604051806080016040528060006001600160a81b031681526020016000815260200160008152602001600081525090565b803560ff81168114610c9857600080fd5b6000602082840312156143bc578081fd5b813561299e8161531b565b600080604083850312156143d9578081fd5b82356143e48161531b565b915060208301356143f48161531b565b809150509250929050565b600080600060608486031215614413578081fd5b833561441e8161531b565b9250602084013561442e8161531b565b929592945050506040919091013590565b60008060408385031215614451578182fd5b823561445c8161531b565b915060208301356143f48161534e565b6000806040838503121561447e578182fd5b82356144898161531b565b946020939093013593505050565b600080602083850312156144a9578182fd5b823567ffffffffffffffff808211156144c0578384fd5b818501915085601f8301126144d3578384fd5b8135818111156144e1578485fd5b86602080830285010111156144f4578485fd5b60209290920196919550909350505050565b600060208284031215614517578081fd5b813561299e81615330565b600060208284031215614533578081fd5b815161299e81615330565b60008060408385031215614550578182fd5b823561455b8161534e565b915060208301356143f48161533e565b6000806040838503121561457d578182fd5b82516145888161534e565b60208401519092506143f48161533e565b600080600080608085870312156145ae578182fd5b84356145b98161534e565b935060208501356145c98161533e565b925060408501356145d98161534e565b91506145e8866060870161439a565b905092959194509250565b600060208284031215614604578081fd5b815161299e8161533e565b600080600060608486031215614623578081fd5b833561462e8161533e565b9250602084013561463e8161534e565b915061464d856040860161439a565b90509250925092565b60008060408385031215614668578182fd5b82516145888161533e565b60008060408385031215614685578182fd5b82516146908161533e565b6020939093015192949293505050565b6000806000606084860312156146b4578081fd5b83516146bf8161533e565b60208501519093506146d081615363565b80925050604084015190509250925092565b6000602082840312156146f3578081fd5b5035919050565b60006020828403121561470b578081fd5b5051919050565b60008060408385031215614724578182fd5b50508035926020909101359150565b600060208284031215614744578081fd5b61299e838361439a565b60006020828403121561475f578081fd5b813561299e81615363565b6000825161477c8184602087016152eb565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039390931683526001600160a81b0391909116602083015260ff16604082015260600190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561483b5783516001600160a01b031683529284019291840191600101614816565b50909695505050505050565b602080825282518282018190526000919060409081850190868401855b8281101561488d5781518051855286015161ffff16868501529284019290850190600101614864565b5091979650505050505050565b901515815260200190565b60006020825282518060208401526148c48160408501602087016152eb565b601f01601f19169190910160400192915050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252818101527f4e6f7420656e6f756768204c5020746f6b656e7320666f72206163636f756e74604082015260600190565b6020808252600c908201526b0a8dede40daeac6d0408aa8960a31b604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601490820152730a0e4cadad2eada40cccaca40e8dede40d0d2ced60631b604082015260600190565b602080825260119082015270546f6f20666577204c5020746f6b656e7360781b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601d908201527f4e6f20706f736974696f6e20666f7220676976656e2061646472657373000000604082015260600190565b6020808252600c908201526b086ac9240e8dede40d0d2ced60a31b604082015260600190565b6020808252600e908201526d546f6f2066657720746f6b656e7360901b604082015260600190565b602080825260119082015270426164206d696e204356492076616c756560781b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4e6f7420656e6f756768206f70656e656420706f736974696f6e20756e697473604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f526563697069656e742072656675736573206c6f636b656420746f6b656e7300604082015260600190565b6020808252601a908201527f546f6f206d756368204c5020746f6b656e7320746f206275726e000000000000604082015260600190565b602080825260119082015270426164206d6178204356492076616c756560781b604082015260600190565b6020808252601e908201527f546f6b656e7320616d6f756e74206d75737420626520706f7369746976650000604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526010908201526f4f70656e2066656520746f6f2062696760801b604082015260600190565b6020808252601d908201527f4c65766572616765206578636365656473206d617820616c6c6f776564000000604082015260600190565b6020808252600f908201526e141bdcda5d1a5bdb881b1bd8dad959608a1b604082015260600190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526017908201527f436f6c6c61746572616c20726174696f2062726f6b656e000000000000000000604082015260600190565b6020808252600b908201526a43564920746f6f206c6f7760a81b604082015260600190565b60208082526019908201527f4c65766572616765206d75737420626520706f73697469766500000000000000604082015260600190565b6020808252601490820152734e6f7420656e6f756768206c697175696469747960601b604082015260600190565b60208082526017908201527f546f6f206d75636820706f736974696f6e20756e697473000000000000000000604082015260600190565b6020808252601b908201527f506f736974696f6e20756e697473206e6f7420706f7369746976650000000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526010908201526f119d5b991cc8185c99481b1bd8dad95960821b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b6020808252600f908201526e4c6f636b757020746f6f206c6f6e6760881b604082015260600190565b6020808252600c908201526b109859081c9bdd5b99081a5960a21b604082015260600190565b60208082526018908201527f4e6f206c6971756964617461626c6520706f736974696f6e0000000000000000604082015260600190565b60208082526017908201527f416d6f756e74206d75737420626520706f736974697665000000000000000000604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b6001600160a81b0391909116815260200190565b6001600160a81b0395909516855260ff93909316602085015261ffff91909116604084015263ffffffff908116606084015216608082015260a00190565b6001600160a81b0393909316835260ff919091166020830152604082015260600190565b6001600160a81b03958616815260ff9490941660208501526040840192909252909216606082015261ffff909116608082015260a00190565b61ffff91909116815260200190565b90815260200190565b92835290151560208301526001600160a81b0316604082015260600190565b95865293151560208601526001600160a81b0392909216604085015260ff166060840152608083015260a082015260c00190565b9283529015156020830152604082015260600190565b918252602082015260400190565b94855260208501939093526001600160a81b0391909116604084015260ff16606083015261ffff16608082015260a00190565b9283526020830191909152604082015260600190565b63ffffffff91909116815260200190565b6001600160501b0391909116815260200190565b60ff91909116815260200190565b60005b838110156153065781810151838201526020016152ee565b83811115615315576000848401525b50505050565b6001600160a01b038116811461107457600080fd5b801515811461107457600080fd5b61ffff8116811461107457600080fd5b6001600160a81b038116811461107457600080fd5b6001600160501b038116811461107457600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212202df1c0e07754a188ecfa7a562c489faecb8a366df5dcf8a8b0c42772381c5e4664736f6c634300060c003300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000000000000000000000000000006fc8cc3e6d3da8b29c4480e77e24dea298293ace000000000000000000000000bb2a8986f1feb41c374658bcd4a5e0b6b536ba1a00000000000000000000000000000000000000000000000000000000000000064554482d4c50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064554482d4c500000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x60806040526004361061038c5760003560e01c806370a08231116101dc578063a8a1eb8c11610102578063dd62ed3e116100a0578063ec38a8621161006f578063ec38a86214610a0b578063f2fde38b14610a2b578063f40af47014610a4b578063f59ce83814610a785761038c565b8063dd62ed3e14610996578063e2bbb158146109b6578063e7cb00c1146109d6578063ebc1daf6146109f65761038c565b8063aceda7f9116100dc578063aceda7f914610937578063ad7a672f1461094c578063b00446b814610961578063b152b295146109765761038c565b8063a8a1eb8c146108e2578063a9059cbb146108f7578063ab919ee3146109175761038c565b80638c7e74751161017a57806392c35fdb1161014957806392c35fdb1461085b57806395d89b411461087b578063a457c2d714610890578063a6ca982c146108b05761038c565b80638c7e7475146108075780638d4d7e311461081c5780638da5cb5b146108315780638eb50a38146108465761038c565b80637b04bc06116101b65780637b04bc06146107925780638202c681146107b457806385da0561146107d45780638ab38ed1146107f45761038c565b806370a082311461073d578063715018a61461075d578063745dd850146107725761038c565b806339509351116102c1578063558e44d31161025f5780636185aa3a1161022e5780636185aa3a146106bb578063655d8dec146106dd57806369463fa4146106fd5780636c7156411461071d5761038c565b8063558e44d31461063157806355f575101461065357806360ebfee6146106845780636162129b146106995761038c565b8063452d003f1161029b578063452d003f146105c957806348607250146105e95780635358fbda14610609578063547ef3e61461061c5761038c565b8063395093511461055b5780633f2cdd6c1461057b578063441a3e701461059b5761038c565b80631c1f8aa31161032e5780632f811c22116103085780632f811c22146104ef578063313ce567146105045780633252799214610526578063373071f21461053b5761038c565b80631c1f8aa31461048d57806321df0da7146104ad57806323b872dd146104cf5761038c565b8063095ea7b31161036a578063095ea7b31461040b578063124805861461043857806318160ddd146104585780631a8dd8f71461046d5761038c565b806302b1ba6f1461039157806305621f1a146103c757806306fdde03146103e9575b600080fd5b34801561039d57600080fd5b506103b16103ac36600461443f565b610a98565b6040516103be91906151ef565b60405180910390f35b3480156103d357600080fd5b506103e76103e2366004614733565b610b8b565b005b3480156103f557600080fd5b506103fe610be9565b6040516103be91906148a5565b34801561041757600080fd5b5061042b61042636600461446c565b610c80565b6040516103be919061489a565b34801561044457600080fd5b506103b1610453366004614497565b610c9e565b34801561046457600080fd5b506103b1610e25565b34801561047957600080fd5b506103e76104883660046143ab565b610e2b565b34801561049957600080fd5b506103e76104a83660046143ab565b610e82565b3480156104b957600080fd5b506104c2610ed9565b6040516103be9190614786565b3480156104db57600080fd5b5061042b6104ea3660046143ff565b610eed565b3480156104fb57600080fd5b506103b1610f74565b34801561051057600080fd5b50610519610f7a565b6040516103be91906152dd565b34801561053257600080fd5b506103b1610f83565b34801561054757600080fd5b506103e76105563660046143ab565b610f89565b34801561056757600080fd5b5061042b61057636600461446c565b611077565b34801561058757600080fd5b506103e76105963660046146e2565b6110c5565b3480156105a757600080fd5b506105bb6105b6366004614712565b611122565b6040516103be929190615261565b3480156105d557600080fd5b506105bb6105e43660046146e2565b61113c565b3480156105f557600080fd5b506103e761060436600461474e565b611176565b6103b16106173660046146e2565b6111d0565b34801561062857600080fd5b506103b16111dc565b34801561063d57600080fd5b506106466111e2565b6040516103be9190615131565b34801561065f57600080fd5b5061067361066e3660046143ab565b6111e8565b6040516103be959493929190615145565b34801561069057600080fd5b506103b1611233565b3480156106a557600080fd5b506106ae61123c565b6040516103be91906151e0565b3480156106c757600080fd5b506106d061134b565b6040516103be91906152b8565b3480156106e957600080fd5b506103b16106f83660046143ab565b61135e565b34801561070957600080fd5b506103b161071836600461453e565b611370565b34801561072957600080fd5b506103e76107383660046143ab565b6116a2565b34801561074957600080fd5b506103b16107583660046143ab565b6116f9565b34801561076957600080fd5b506103e7611718565b34801561077e57600080fd5b506103e761078d366004614506565b611797565b34801561079e57600080fd5b506107a76117b7565b6040516103be91906152c9565b3480156107c057600080fd5b506103b16107cf3660046146e2565b6117c6565b3480156107e057600080fd5b506103e76107ef3660046146e2565b6117d8565b6103b161080236600461460f565b611835565b34801561081357600080fd5b5061051961187c565b34801561082857600080fd5b506103b161188c565b34801561083d57600080fd5b506104c2611892565b34801561085257600080fd5b506103b16118a1565b34801561086757600080fd5b50610646610876366004614599565b6118c5565b34801561088757600080fd5b506103fe61201b565b34801561089c57600080fd5b5061042b6108ab36600461446c565b61207c565b3480156108bc57600080fd5b506108d06108cb3660046143ab565b6120e4565b6040516103be96959493929190615217565b3480156108ee57600080fd5b506103b161214f565b34801561090357600080fd5b5061042b61091236600461446c565b612180565b34801561092357600080fd5b506103e76109323660046143ab565b612194565b34801561094357600080fd5b5061042b6121eb565b34801561095857600080fd5b506103b16121fb565b34801561096d57600080fd5b506103b1612297565b34801561098257600080fd5b5061042b6109913660046143ab565b61229d565b3480156109a257600080fd5b506103b16109b13660046143c7565b6122b2565b3480156109c257600080fd5b506103b16109d1366004614712565b6122dd565b3480156109e257600080fd5b506103e76109f1366004614506565b612508565b348015610a0257600080fd5b506103b161255b565b348015610a1757600080fd5b506103e7610a263660046143ab565b612561565b348015610a3757600080fd5b506103e7610a463660046143ab565b6125b8565b348015610a5757600080fd5b50610a6b610a66366004614497565b61266e565b6040516103be91906147fa565b348015610a8457600080fd5b506103e7610a93366004614506565b6128c3565b6000610aa2614250565b506001600160a01b038316600090815260156020908152604091829020825160a08101845290546001600160a81b03808216835260ff600160a81b8304169383019390935261ffff600160b01b8204169382019390935263ffffffff600160c01b840481166060830152600160e01b909304831660808201526011549092610b8392610b3a92600160501b9004909116908616612916565b606083015163ffffffff90811660009081526013602052604080822054601154600160501b90049093168252902054610b7d91906001600160a81b038816612953565b90612979565b949350505050565b610b936129a5565b6000546001600160a01b03908116911614610bc95760405162461bcd60e51b8152600401610bc090614bb4565b60405180910390fd5b6011805460ff909216600160881b0260ff60881b19909216919091179055565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610c755780601f10610c4a57610100808354040283529160200191610c75565b820191906000526020600020905b815481529060010190602001808311610c5857829003601f168201915b505050505090505b90565b6000610c94610c8d6129a5565b84846129a9565b5060015b92915050565b6000610caa6001612a5d565b50506000805b83811015610de757600060156000878785818110610cca57fe5b9050602002016020810190610cdf91906143ab565b6001600160a01b031681526020810191909152604001600020546001600160a81b031690508015610dde576000806000610d3a898987818110610d1e57fe5b9050602002016020810190610d3391906143ab565b6000612c59565b9250925092508215610dda576008546040516332d1de6760e01b815260019750610dd7916001600160a01b0316906332d1de6790610d8090869086908a9060040161524b565b60206040518083038186803b158015610d9857600080fd5b505afa158015610dac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd091906146fa565b8890612979565b96505b5050505b50600101610cb0565b5080610e055760405162461bcd60e51b8152600401610bc09061508c565b610e0e82612e46565b601054610e1b9083612e77565b6010555092915050565b60035490565b610e336129a5565b6000546001600160a01b03908116911614610e605760405162461bcd60e51b8152600401610bc090614bb4565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b610e8a6129a5565b6000546001600160a01b03908116911614610eb75760405162461bcd60e51b8152600401610bc090614bb4565b601280546001600160a01b0319166001600160a01b0392909216919091179055565b60065461010090046001600160a01b031690565b6000610efa848484612eb9565b610f6a84610f066129a5565b610f65856040518060600160405280602881526020016153c1602891396001600160a01b038a16600090815260026020526040812090610f446129a5565b6001600160a01b031681526020810191909152604001600020549190612fce565b6129a9565b5060019392505050565b600e5481565b60065460ff1690565b600c5481565b610f916129a5565b6000546001600160a01b03908116911614610fbe5760405162461bcd60e51b8152600401610bc090614bb4565b600a546001600160a01b031615801590610fe7575060065461010090046001600160a01b031615155b1561101057600a54600654611010916001600160a01b0361010090920482169116600019612ffa565b600a80546001600160a01b0319166001600160a01b0383169081179091551580159061104b575060065461010090046001600160a01b031615155b1561107457600a54600654611074916001600160a01b0361010090920482169116600019612ffa565b50565b6000610c946110846129a5565b84610f6585600260006110956129a5565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490612979565b6110cd6129a5565b6000546001600160a01b039081169116146110fa5760405162461bcd60e51b8152600401610bc090614bb4565b62093a8081111561111d5760405162461bcd60e51b8152600401610bc09061503d565b600d55565b600080611131846000856130f9565b909590945092505050565b6000806000831161115f5760405162461bcd60e51b8152600401610bc0906150c3565b61116c60006001856130f9565b9094909350915050565b61117e6129a5565b6000546001600160a01b039081169116146111ab5760405162461bcd60e51b8152600401610bc090614bb4565b6011805469ffffffffffffffffffff19166001600160501b0392909216919091179055565b6000610c9834836122dd565b600f5481565b61271081565b6015602052600090815260409020546001600160a81b0381169060ff600160a81b8204169061ffff600160b01b8204169063ffffffff600160c01b8204811691600160e01b90041685565b6402540be40081565b600061124661427e565b60115461125f90600160501b900463ffffffff16613380565b9050806101200151156112fd57600954604080830151606084015191516312e001c360e21b81526001600160a01b0390931692634b80070c926112a59291600401615261565b60206040518083038186803b1580156112bd57600080fd5b505afa1580156112d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f591906145f3565b915050610c7d565b600960009054906101000a90046001600160a01b03166001600160a01b031663f359b46f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156112bd57600080fd5b601154600160501b900463ffffffff1681565b60146020526000908152604090205481565b600080836001600160a81b03161161139a5760405162461bcd60e51b8152600401610bc090614f3c565b60008261ffff161180156113b45750614e208261ffff1611155b6113d05760405162461bcd60e51b8152600401610bc090614b13565b33600090815260156020526040902080546001600160a81b038086169116101561140c5760405162461bcd60e51b8152600401610bc090614b7f565b600d54815461142d90429063ffffffff600160c01b909104811690612e7716565b101561144b5760405162461bcd60e51b8152600401610bc090614da0565b6000806114586001612a5d565b915091508461ffff168261ffff1610156114845760405162461bcd60e51b8152600401610bc090614e7b565b60008060008061149f878b6001600160a81b0316878961378f565b935093509350935080156114bd576000975050505050505050610c98565b6000806114ca8c86613829565b600e829055600f8190558a5491935091506114ee906001600160a81b03168d613876565b89546001600160a81b0319166001600160a81b039190911617808a55600954604051636f6bb7a760e01b81526000926115b692612710926115b0926001600160a01b0390921691636f6bb7a79161155591600160c01b900463ffffffff16906004016152b8565b60206040518083038186803b15801561156d57600080fd5b505afa158015611581573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a591906145f3565b8a9061ffff166138b8565b906138f2565b9050337f3989dab79971090c83b28eb2d423aa507b7d4c16f5cf10a4fdb05835cafba36a6115e48989612979565b6115ee848a612979565b8d60000160009054906101000a90046001600160a81b03168e60000160159054906101000a900460ff168e60405161162a95949392919061526f565b60405180910390a289546001600160a81b031661165257336000908152601560205260408120555b6116718561166b89601054612e7790919063ffffffff16565b90612e77565b60105561167e8782612e77565b9a5061168981613934565b6116928b612e46565b5050505050505050505092915050565b6116aa6129a5565b6000546001600160a01b039081169116146116d75760405162461bcd60e51b8152600401610bc090614bb4565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166000908152600160205260409020545b919050565b6117206129a5565b6000546001600160a01b0390811691161461174d5760405162461bcd60e51b8152600401610bc090614bb4565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b336000908152601660205260409020805460ff1916911515919091179055565b6011546001600160501b031681565b60136020526000908152604090205481565b6117e06129a5565b6000546001600160a01b0390811691161461180d5760405162461bcd60e51b8152600401610bc090614bb4565b621275008111156118305760405162461bcd60e51b8152600401610bc09061503d565b600c55565b600034346001600160a81b03161461185f5760405162461bcd60e51b8152600401610bc090614950565b61186b348585856118c5565b6001600160a81b0316949350505050565b601154600160881b900460ff1681565b60105481565b6000546001600160a01b031690565b7f00000000000000000000000000000000000000000000000000000000000003e881565b6000808260ff16116118e95760405162461bcd60e51b8152600401610bc090614ea0565b60115460ff600160881b909104811690831611156119195760405162461bcd60e51b8152600401610bc090614d69565b6000856001600160a81b0316116119425760405162461bcd60e51b8152600401610bc090614c82565b60008461ffff1611801561195c5750614e208461ffff1611155b6119785760405162461bcd60e51b8152600401610bc090614c57565b6119806142d2565b61198a6000612a5d565b608083015261ffff908116610160830181905290861610156119be5760405162461bcd60e51b8152600401610bc090614ac5565b600954604080516307e3dd0f60e41b8152815160009384936001600160a01b0390911692637e3dd0f09260048083019392829003018186803b158015611a0357600080fd5b505afa158015611a17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3b9190614656565b9092509050612710611a6761ffff8416611a616001600160a81b038c1660ff8a166138b8565b906138b8565b81611a6e57fe5b0460a0840181905261016084015161ffff1690611aa490614e2090611a619060ff8a169082906001600160a81b038f1690612e77565b81611aab57fe5b04610140840152612710611adb611ac68261ffff8516613876565b610140860151906001600160a81b03166138b8565b81611ae257fe5b0460c0840152611afa6001600160a81b03891661396f565b8084526000602085015215611b515760a08301518351611b4b91611b2991906001600160a81b038c1603612979565b6115b06402540be400611a618760c00151600e5461297990919063ffffffff16565b60208401525b6009546020840151604051630d82490360e41b81526001600160a01b039092169163d824903091611b88918c918a91600401615183565b604080518083038186803b158015611b9f57600080fd5b505afa158015611bb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd7919061456b565b61ffff1661010085018190526001600160a81b0391821660e08601529087161015611c145760405162461bcd60e51b8152600401610bc0906149fe565b876001600160a81b03168360a0015110611c405760405162461bcd60e51b8152600401610bc090614d3f565b611c7c8560ff16611c6d8560e001518660a001518c036001600160a81b031661387690919063ffffffff16565b6001600160a81b03169061397b565b6001600160a81b03908116610120850152336000908152601560205260409020805490911615611d4657611cca8185608001518661016001518761012001516001600160a81b03168a6139d6565b866040018760600182815250828152508297505050506000611d1c8560a00151611d118960ff16611a6189606001518f6001600160a81b031661297990919063ffffffff16565b601054919003612979565b9050611d3d856060015161166b876040015184612e7790919063ffffffff16565b60105550611ecd565b600084610160015161ffff16611d75614e208761012001516001600160a81b03166138b890919063ffffffff16565b81611d7c57fe5b04905080955080866001600160a81b031614611daa5760405162461bcd60e51b8152600401610bc090614f05565b611db2614250565b506040805160a0810182526001600160a81b0380891680835260ff808c1660208086019182526101608c015161ffff90811687890190815263ffffffff42811660608a0181815260808b0191825233600090815260159096529a90942089518154965193519b5195518316600160e01b026001600160e01b03968416600160c01b0263ffffffff60c01b199d909616600160b01b0261ffff60b01b1995909916600160a81b0260ff60a81b1992909b166001600160a81b0319909816979097171698909817919091169490941797909716969096179590951694909417909155600e549192611ea392919061297916565b600e5560a0860151601054611ec7916001600160a81b0360ff8c168f021603612979565b60105550505b336001600160a01b03167fe485c81af56f49547b2ea1b6886083d8e3a7ef50fe670c9574bd5d4b2dd7d4628a88611f1e8860e001516001600160a81b03168960a0015161297990919063ffffffff16565b610160890151604051611f35949392918c916151a7565b60405180910390a2611f4f896001600160a81b0316611074565b8351611f64906001600160a81b038b16612979565b845260a0840151611f7490613934565b8351600e541115611f975760405162461bcd60e51b8152600401610bc090614ed7565b600b546001600160a01b03161561200f57600b54604051630bf1944760e21b81526001600160a01b0390911690632fc6511c90611fdc90339089908b9060040161479a565b600060405180830381600087803b158015611ff657600080fd5b505af115801561200a573d6000803e3d6000fd5b505050505b50505050949350505050565b60058054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610c755780601f10610c4a57610100808354040283529160200191610c75565b6000610c946120896129a5565b84610f65856040518060600160405280602581526020016153e960259139600260006120b36129a5565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190612fce565b6001600160a01b03811660009081526015602052604081205481906001600160a81b03811690600160a81b900460ff168280836121335760405162461bcd60e51b8152600401610bc090614a8e565b61213e876001613b17565b929a91995095975093955092915050565b601154600e5460009161217b9161217391600160501b900463ffffffff1690612916565b610b7d6121fb565b905090565b6000610c9461218d6129a5565b8484612eb9565b61219c6129a5565b6000546001600160a01b039081169116146121c95760405162461bcd60e51b8152600401610bc090614bb4565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b601154600160781b900460ff1681565b600080600760009054906101000a90046001600160a01b03166001600160a01b031663c1639a2b6040518163ffffffff1660e01b815260040160606040518083038186803b15801561224c57600080fd5b505afa158015612260573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061228491906146a0565b5050905061229181613cc3565b91505090565b614e2081565b60166020526000908152604090205460ff1681565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b60008083116122fe5760405162461bcd60e51b8152600401610bc090614c82565b33600090815260146020526040812042905561231a6001612a5d565b50905060006127106001600160a81b03166123bf600960009054906101000a90046001600160a01b03166001600160a01b031663cc1252ae6040518163ffffffff1660e01b815260040160206040518083038186803b15801561237c57600080fd5b505afa158015612390573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123b491906145f3565b879061ffff166138b8565b816123c657fe5b04905060006123d58683612e77565b905060006123e1610e25565b905060006123ee85613cc3565b90506000821180156124005750600081115b1561241f578061241084846138b8565b8161241757fe5b04955061244c565b612449837f00000000000000000000000000000000000000000000000000000000000003e86138b8565b95505b336001600160a01b03167f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e898887604051612489939291906152a2565b60405180910390a2868610156124b15760405162461bcd60e51b8152600401610bc090614a2c565b600086116124d15760405162461bcd60e51b8152600401610bc090614aeb565b6124db3387613d03565b6124e488611074565b6010546124f19084612979565b6010556124fd84613934565b505050505092915050565b6125106129a5565b6000546001600160a01b0390811691161461253d5760405162461bcd60e51b8152600401610bc090614bb4565b60118054911515600160801b0260ff60801b19909216919091179055565b600d5481565b6125696129a5565b6000546001600160a01b039081169116146125965760405162461bcd60e51b8152600401610bc090614bb4565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b6125c06129a5565b6000546001600160a01b039081169116146125ed5760405162461bcd60e51b8152600401610bc090614bb4565b6001600160a01b0381166126135760405162461bcd60e51b8152600401610bc090614976565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6060808267ffffffffffffffff8111801561268857600080fd5b506040519080825280602002602001820160405280156126b2578160200160208202803683370190505b5090506000805b84811015612827576000806126ef8888858181106126d357fe5b90506020020160208101906126e891906143ab565b6001613b17565b505060085491935091506001600160a01b031663f66f29e88383601560008d8d8a81811061271957fe5b905060200201602081019061272e91906143ab565b6001600160a01b03168152602081019190915260409081016000205490516001600160e01b031960e086901b1681526127759392916001600160a81b0316906004016151f8565b60206040518083038186803b15801561278d57600080fd5b505afa1580156127a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c59190614522565b1561281d578787848181106127d657fe5b90506020020160208101906127eb91906143ab565b8585815181106127f757fe5b6001600160a01b039092166020928302919091019091015261281a846001612979565b93505b50506001016126b9565b5060608167ffffffffffffffff8111801561284157600080fd5b5060405190808252806020026020018201604052801561286b578160200160208202803683370190505b50905060005b828110156128b95783818151811061288557fe5b602002602001015182828151811061289957fe5b6001600160a01b0390921660209283029190910190910152600101612871565b5095945050505050565b6128cb6129a5565b6000546001600160a01b039081169116146128f85760405162461bcd60e51b8152600401610bc090614bb4565b60118054911515600160781b0260ff60781b19909216919091179055565b600061292061427e565b60115461293990600160501b900463ffffffff16613380565b6000858152601360205260409020548151919250610b8391855b60006402540be40061296983611a618688612e77565b8161297057fe5b04949350505050565b60008282018381101561299e5760405162461bcd60e51b8152600401610bc090614a57565b9392505050565b3390565b6001600160a01b0383166129cf5760405162461bcd60e51b8152600401610bc090614dc9565b6001600160a01b0382166129f55760405162461bcd60e51b8152600401610bc0906149bc565b6001600160a01b0380841660008181526002602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590612a509085906151ef565b60405180910390a3505050565b6011546000908190600160501b900463ffffffff16612a7a61427e565b612a8382613380565b90508060c0015115612ad857805142600090815260136020908152604090912091909155600e5490820151612ad4916402540be40091612ac2916138b8565b81612ac957fe5b600f54919004612979565b600f555b8060e0015115612b0a5760808101516011805469ffffffffffffffffffff19166001600160501b039092169190911790555b80610120015115612ba25760095460408083015160608401519151630d14ef1560e41b81526001600160a01b039093169263d14ef15092612b4e9291600401615261565b602060405180830381600087803b158015612b6857600080fd5b505af1158015612b7c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ba091906145f3565b505b80610100015115612c1d576011805463ffffffff60501b1916600160501b4263ffffffff16021790819055600160701b900460ff168015612bec5750601154600160801b900460ff165b15612c01576000828152601360205260408120555b6011805460ff60701b1916600160701b87151502179055612c47565b601154600160701b900460ff1615612c47576011805460ff60701b1916600160701b871515021790555b60a08101519051909350915050915091565b6000806000806000806000612c6e8989613b17565b6008546001600160a01b038e811660009081526015602052604090819020549051631ecde53d60e31b8152969c50949a508b99508a9850929650909450169163f66f29e891612ccf91889188916001600160a81b03909116906004016151f8565b60206040518083038186803b158015612ce757600080fd5b505afa158015612cfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1f9190614522565b15612e3b57612d2c614250565b506001600160a01b0389166000908152601560209081526040808320815160a08101835290546001600160a81b03811680835260ff600160a81b8304169483019490945261ffff600160b01b8204169282019290925263ffffffff600160c01b830481166060830152600160e01b909204909116608082015291908190612db39086613829565b600e829055600f8190556010549193509150612dcf9085612e77565b60105582516040516001600160a01b038e16917f302eaf71224bcd9ed28854139aa87a32dc89622b38a4d8ce4160475aa57a7f1391612e12918b918b91906151f8565b60405180910390a25050506001600160a01b038916600090815260156020526040812055600196505b505050509250925092565b604051339082156108fc029083906000818181858888f19350505050158015612e73573d6000803e3d6000fd5b5050565b600061299e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612fce565b6001600160a01b038316612edf5760405162461bcd60e51b8152600401610bc090614cfa565b6001600160a01b038216612f055760405162461bcd60e51b8152600401610bc0906148d8565b612f10838383613dc3565b612f4d8160405180606001604052806026815260200161539b602691396001600160a01b0386166000908152600160205260409020549190612fce565b6001600160a01b038085166000908152600160205260408082209390935590841681522054612f7c9082612979565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90612a509085906151ef565b60008184841115612ff25760405162461bcd60e51b8152600401610bc091906148a5565b505050900390565b8015806130825750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e9061303090309086906004016147c7565b60206040518083038186803b15801561304857600080fd5b505afa15801561305c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308091906146fa565b155b61309e5760405162461bcd60e51b8152600401610bc090614fe7565b6130f48363095ea7b360e01b84846040516024016130bd9291906147e1565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613eb2565b505050565b600c543360009081526014602052604081205490918291429161311c9190612979565b111561313a5760405162461bcd60e51b8152600401610bc090614fbd565b60006131466001612a5d565b50905084156131775783925061317061315d610e25565b6115b061316984613cc3565b86906138b8565b95506131e1565b600086116131975760405162461bcd60e51b8152600401610bc090614c82565b6131bf6001610b7d6131a884613cc3565b6115b0600161166b6131b8610e25565b8d906138b8565b9250838311156131e15760405162461bcd60e51b8152600401610bc090614c20565b6131ea336116f9565b8311156132095760405162461bcd60e51b8152600401610bc09061491b565b60006127106001600160a81b03166132ab600960009054906101000a90046001600160a01b03166001600160a01b031663495ef7056040518163ffffffff1660e01b815260040160206040518083038186803b15801561326857600080fd5b505afa15801561327c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132a091906145f3565b899061ffff166138b8565b816132b257fe5b0490506132bf8782612e77565b601154909350600160781b900460ff16806132e75750866132e4600e5461166b613f41565b10155b6133035760405162461bcd60e51b8152600401610bc090614e44565b336001600160a01b03167f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca94888684604051613340939291906152a2565b60405180910390a26133523385613f4d565b61335b81613934565b61336483612e46565b6010546133719088612e77565b60105550919590945092505050565b61338861427e565b6000806000600760009054906101000a90046001600160a01b03166001600160a01b031663c1639a2b6040518163ffffffff1660e01b815260040160606040518083038186803b1580156133db57600080fd5b505afa1580156133ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341391906146a0565b61ffff831660a08801524260009081526013602052604090205480885292955090935091501561344c5750506000602083015250611713565b601154600160501b900463ffffffff1661349c57506402540be4008352600160c084018190526001600160501b03909116608084015260e083018190526101008301525060006020820152611713565b6011546001600160501b039081169083168111156134cc5760405162461bcd60e51b8152600401610bc090615066565b6001600160501b0381840316606086018190526000906134ed5760016134f0565b60025b60ff16905060608167ffffffffffffffff8111801561350e57600080fd5b5060405190808252806020026020018201604052801561354857816020015b613535614352565b81526020019060019003908161352d5790505b5060608801519091501561369857600754604051635a7b84b160e01b815260009182916001600160a01b0390911690635a7b84b19061358b9088906004016152c9565b604080518083038186803b1580156135a257600080fd5b505afa1580156135b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135da9190614673565b9150915060405180604001604052806135fc8c89612e7790919063ffffffff16565b81526020018361ffff168152508360008151811061361657fe5b6020026020010181905250604051806040016040528061363f8842612e7790919063ffffffff16565b81526020018961ffff168152508360018151811061365957fe5b60209081029190910101526001600160501b03871660808a0152600160e08a01526136848682612e77565b60408a0152505060016101208801526136d3565b60408051808201909152806136ad428b612e77565b81526020018761ffff16815250816000815181106136c757fe5b60200260200101819052505b600954604051635d769d1760e11b81526001600160a01b039091169063baed3a2e90613703908490600401614847565b60206040518083038186803b15801561371b57600080fd5b505afa15801561372f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061375391906146fa565b602080890182905260008a81526013909152604090205461377391612979565b87525050600160c0860181905261010086015250505050919050565b8354600160c01b900463ffffffff166000908152601360205260408120548190819081906137be908789612953565b8854909350600090819081906137ee908b90600160a81b810460ff16908b90600160b01b900461ffff168a614023565b9250925092508161381457613804336000612c59565b505050600193506000955061381b565b8296508094505b505050945094509450949050565b60008061384a846001600160a81b0316600e54612e7790919063ffffffff16565b9150600f54905081600014156138625750600061386f565b61386c8184612e77565b90505b9250929050565b600061299e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506140d4565b6000826138c757506000610c98565b828202828482816138d457fe5b041461299e5760405162461bcd60e51b8152600401610bc090614b3e565b600061299e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061410b565b60008111801561394e5750600a546001600160a01b031615155b156110745760065461107490829061010090046001600160a01b0316614142565b6000610c984783612e77565b60006001600160a81b03831661399357506000610c98565b8282026001600160a81b0380841690808616908316816139af57fe5b046001600160a81b03161461299e5760405162461bcd60e51b8152600401610bc090614b3e565b60008060006139e3614369565b88546001600160a81b0316808252600090819081908190613a07908e908e8e61378f565b93509350935093508015613a2057600080865293508391505b613a488b61ffff166115b0614e20611a618e610b7d8f60ff168b6138b890919063ffffffff16565b6020860181905297506001600160a81b0388168814613a795760405162461bcd60e51b8152600401610bc090614f05565b8c5463ffffffff60c01b1916600160c01b4263ffffffff1602176001600160a81b0319166001600160a81b0389161761ffff60b01b1916600160b01b61ffff8d16021760ff60a81b1916600160a81b60ff8b1602178d558451613adc9084613829565b6060870181905260408701829052600f55613b00906001600160a81b038a16612979565b600e5550959b959a50909850939650505050505050565b600080600080613b25614250565b506001600160a01b038087166000908152601560209081526040808320815160a08101835290546001600160a81b038116825260ff600160a81b8204169382019390935261ffff600160b01b8404168183015263ffffffff600160c01b84048116606080840191909152600160e01b909404166080820152600754825163c1639a2b60e01b815292519195169263c1639a2b9260048082019391829003018186803b158015613bd357600080fd5b505afa158015613be7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0b91906146a0565b5050606083015163ffffffff90811660009081526013602052604080822054601154600160501b900490931682529020548451929350613c53926001600160a81b0316612953565b93508615613c8f576011548251613c8c91613c8591600160501b90910463ffffffff16906001600160a81b0316612916565b8590612979565b93505b613cb182600001516001600160a81b0316836020015183856040015188614023565b919a9099509497509550929350505050565b6000610c98614e20613ce48461ffff16600e546138b890919063ffffffff16565b81613ceb57fe5b0461166b600f5460105461297990919063ffffffff16565b6001600160a01b038216613d295760405162461bcd60e51b8152600401610bc0906150fa565b613d3560008383613dc3565b600354613d429082612979565b6003556001600160a01b038216600090815260016020526040902054613d689082612979565b6001600160a01b0383166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90613db79085906151ef565b60405180910390a35050565b600c546001600160a01b0384166000908152601460205260409020544291613deb9190612979565b118015613e1857506001600160a01b03808316600090815260146020526040808220549286168252902054115b8015613e3257506012546001600160a01b03848116911614155b8015613e4c57506012546001600160a01b03838116911614155b156130f4576001600160a01b03821660009081526016602052604090205460ff1615613e8a5760405162461bcd60e51b8152600401610bc090614be9565b6001600160a01b03808416600090815260146020526040808220549285168252902055505050565b6060613f07826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661417c9092919063ffffffff16565b8051909150156130f45780806020019051810190613f259190614522565b6130f45760405162461bcd60e51b8152600401610bc090614f73565b600061217b600061396f565b6001600160a01b038216613f735760405162461bcd60e51b8152600401610bc090614cb9565b613f7f82600083613dc3565b613fbc81604051806060016040528060228152602001615379602291396001600160a01b0385166000908152600160205260409020549190612fce565b6001600160a01b038316600090815260016020526040902055600354613fe29082612e77565b6003556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90613db79085906151ef565b6000808080614e206140398a61ffff8a166138b8565b8161404057fe5b04905060018860ff161161405557600061408e565b8760ff16614e2061407d60018b0360ff16611a618a61ffff168e6138b890919063ffffffff16565b8161408457fe5b048161408c57fe5b045b9150600061409c8387612979565b90508082106140ba576140af8282612e77565b9450600193506140c7565b6140c48183612e77565b94505b5050955095509592505050565b6000836001600160a81b0316836001600160a81b031611158290612ff25760405162461bcd60e51b8152600401610bc091906148a5565b6000818361412c5760405162461bcd60e51b8152600401610bc091906148a5565b50600083858161413857fe5b0495945050505050565b600a546040516001600160a01b039091169083156108fc029084906000818181858888f193505050501580156130f4573d6000803e3d6000fd5b6060610b83848460008560606141918561424a565b6141ad5760405162461bcd60e51b8152600401610bc090614e0d565b60006060866001600160a01b031685876040516141ca919061476a565b60006040518083038185875af1925050503d8060008114614207576040519150601f19603f3d011682016040523d82523d6000602084013e61420c565b606091505b50915091508115614220579150610b839050565b8051156142305780518082602001fd5b8360405162461bcd60e51b8152600401610bc091906148a5565b3b151590565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b6040518061018001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a81b0316815260200160006001600160a81b0316815260200160006001600160a81b0316815260200160008152602001600061ffff1681525090565b604080518082019091526000808252602082015290565b604051806080016040528060006001600160a81b031681526020016000815260200160008152602001600081525090565b803560ff81168114610c9857600080fd5b6000602082840312156143bc578081fd5b813561299e8161531b565b600080604083850312156143d9578081fd5b82356143e48161531b565b915060208301356143f48161531b565b809150509250929050565b600080600060608486031215614413578081fd5b833561441e8161531b565b9250602084013561442e8161531b565b929592945050506040919091013590565b60008060408385031215614451578182fd5b823561445c8161531b565b915060208301356143f48161534e565b6000806040838503121561447e578182fd5b82356144898161531b565b946020939093013593505050565b600080602083850312156144a9578182fd5b823567ffffffffffffffff808211156144c0578384fd5b818501915085601f8301126144d3578384fd5b8135818111156144e1578485fd5b86602080830285010111156144f4578485fd5b60209290920196919550909350505050565b600060208284031215614517578081fd5b813561299e81615330565b600060208284031215614533578081fd5b815161299e81615330565b60008060408385031215614550578182fd5b823561455b8161534e565b915060208301356143f48161533e565b6000806040838503121561457d578182fd5b82516145888161534e565b60208401519092506143f48161533e565b600080600080608085870312156145ae578182fd5b84356145b98161534e565b935060208501356145c98161533e565b925060408501356145d98161534e565b91506145e8866060870161439a565b905092959194509250565b600060208284031215614604578081fd5b815161299e8161533e565b600080600060608486031215614623578081fd5b833561462e8161533e565b9250602084013561463e8161534e565b915061464d856040860161439a565b90509250925092565b60008060408385031215614668578182fd5b82516145888161533e565b60008060408385031215614685578182fd5b82516146908161533e565b6020939093015192949293505050565b6000806000606084860312156146b4578081fd5b83516146bf8161533e565b60208501519093506146d081615363565b80925050604084015190509250925092565b6000602082840312156146f3578081fd5b5035919050565b60006020828403121561470b578081fd5b5051919050565b60008060408385031215614724578182fd5b50508035926020909101359150565b600060208284031215614744578081fd5b61299e838361439a565b60006020828403121561475f578081fd5b813561299e81615363565b6000825161477c8184602087016152eb565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039390931683526001600160a81b0391909116602083015260ff16604082015260600190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561483b5783516001600160a01b031683529284019291840191600101614816565b50909695505050505050565b602080825282518282018190526000919060409081850190868401855b8281101561488d5781518051855286015161ffff16868501529284019290850190600101614864565b5091979650505050505050565b901515815260200190565b60006020825282518060208401526148c48160408501602087016152eb565b601f01601f19169190910160400192915050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252818101527f4e6f7420656e6f756768204c5020746f6b656e7320666f72206163636f756e74604082015260600190565b6020808252600c908201526b0a8dede40daeac6d0408aa8960a31b604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601490820152730a0e4cadad2eada40cccaca40e8dede40d0d2ced60631b604082015260600190565b602080825260119082015270546f6f20666577204c5020746f6b656e7360781b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601d908201527f4e6f20706f736974696f6e20666f7220676976656e2061646472657373000000604082015260600190565b6020808252600c908201526b086ac9240e8dede40d0d2ced60a31b604082015260600190565b6020808252600e908201526d546f6f2066657720746f6b656e7360901b604082015260600190565b602080825260119082015270426164206d696e204356492076616c756560781b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4e6f7420656e6f756768206f70656e656420706f736974696f6e20756e697473604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f526563697069656e742072656675736573206c6f636b656420746f6b656e7300604082015260600190565b6020808252601a908201527f546f6f206d756368204c5020746f6b656e7320746f206275726e000000000000604082015260600190565b602080825260119082015270426164206d6178204356492076616c756560781b604082015260600190565b6020808252601e908201527f546f6b656e7320616d6f756e74206d75737420626520706f7369746976650000604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526010908201526f4f70656e2066656520746f6f2062696760801b604082015260600190565b6020808252601d908201527f4c65766572616765206578636365656473206d617820616c6c6f776564000000604082015260600190565b6020808252600f908201526e141bdcda5d1a5bdb881b1bd8dad959608a1b604082015260600190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526017908201527f436f6c6c61746572616c20726174696f2062726f6b656e000000000000000000604082015260600190565b6020808252600b908201526a43564920746f6f206c6f7760a81b604082015260600190565b60208082526019908201527f4c65766572616765206d75737420626520706f73697469766500000000000000604082015260600190565b6020808252601490820152734e6f7420656e6f756768206c697175696469747960601b604082015260600190565b60208082526017908201527f546f6f206d75636820706f736974696f6e20756e697473000000000000000000604082015260600190565b6020808252601b908201527f506f736974696f6e20756e697473206e6f7420706f7369746976650000000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526010908201526f119d5b991cc8185c99481b1bd8dad95960821b604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b6020808252600f908201526e4c6f636b757020746f6f206c6f6e6760881b604082015260600190565b6020808252600c908201526b109859081c9bdd5b99081a5960a21b604082015260600190565b60208082526018908201527f4e6f206c6971756964617461626c6520706f736974696f6e0000000000000000604082015260600190565b60208082526017908201527f416d6f756e74206d75737420626520706f736974697665000000000000000000604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b6001600160a81b0391909116815260200190565b6001600160a81b0395909516855260ff93909316602085015261ffff91909116604084015263ffffffff908116606084015216608082015260a00190565b6001600160a81b0393909316835260ff919091166020830152604082015260600190565b6001600160a81b03958616815260ff9490941660208501526040840192909252909216606082015261ffff909116608082015260a00190565b61ffff91909116815260200190565b90815260200190565b92835290151560208301526001600160a81b0316604082015260600190565b95865293151560208601526001600160a81b0392909216604085015260ff166060840152608083015260a082015260c00190565b9283529015156020830152604082015260600190565b918252602082015260400190565b94855260208501939093526001600160a81b0391909116604084015260ff16606083015261ffff16608082015260a00190565b9283526020830191909152604082015260600190565b63ffffffff91909116815260200190565b6001600160501b0391909116815260200190565b60ff91909116815260200190565b60005b838110156153065781810151838201526020016152ee565b83811115615315576000848401525b50505050565b6001600160a01b038116811461107457600080fd5b801515811461107457600080fd5b61ffff8116811461107457600080fd5b6001600160a81b038116811461107457600080fd5b6001600160501b038116811461107457600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212202df1c0e07754a188ecfa7a562c489faecb8a366df5dcf8a8b0c42772381c5e4664736f6c634300060c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000000000000000000000000000006fc8cc3e6d3da8b29c4480e77e24dea298293ace000000000000000000000000bb2a8986f1feb41c374658bcd4a5e0b6b536ba1a00000000000000000000000000000000000000000000000000000000000000064554482d4c50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064554482d4c500000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _lpTokenName (string): ETH-LP
Arg [1] : _lpTokenSymbolName (string): ETH-LP
Arg [2] : _initialTokenToLPTokenRate (uint256): 1000
Arg [3] : _feesCalculator (address): 0x0000000000000000000000000000000000000000
Arg [4] : _cviOracle (address): 0x6fC8cC3E6D3da8B29c4480e77E24Dea298293ACE
Arg [5] : _liquidation (address): 0xbB2a8986F1feB41C374658Bcd4A5E0B6b536Ba1a
-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [2] : 00000000000000000000000000000000000000000000000000000000000003e8
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [4] : 0000000000000000000000006fc8cc3e6d3da8b29c4480e77e24dea298293ace
Arg [5] : 000000000000000000000000bb2a8986f1feb41c374658bcd4a5e0b6b536ba1a
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [7] : 4554482d4c500000000000000000000000000000000000000000000000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [9] : 4554482d4c500000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.