ERC-20
Overview
Max Total Supply
46,026.275658362932775901 ETH-LP-V2
Holders
23
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Balance
534.47527780209339215 ETH-LP-V2Value
$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.2; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IFeesCollector { function sendProfit(uint256 amount, IERC20 token) 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 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/IERC20.sol"; import "./interfaces/IETHPlatform.sol"; import "./PlatformV2.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; contract ETHPlatform is PlatformV2, IETHPlatform { constructor(string memory _lpTokenName, string memory _lpTokenSymbolName, uint256 _initialTokenToLPTokenRate, IFeesCalculatorV3 _feesCalculator, ICVIOracleV3 _cviOracle, ILiquidationV2 _liquidation) public PlatformV2(IERC20(address(0)), _lpTokenName, _lpTokenSymbolName, _initialTokenToLPTokenRate, _feesCalculator, _cviOracle, _liquidation) { } function depositETH(uint256 _minLPTokenAmount) external override payable nonReentrant returns (uint256 lpTokenAmount) { lpTokenAmount = _deposit(msg.value, _minLPTokenAmount); } function openPositionETH(uint16 _maxCVI, uint168 _maxBuyingPremiumFeePercentage, uint8 _leverage) external override payable nonReentrant returns (uint256 positionUnitsAmount) { require(uint168(msg.value) == msg.value, "Too much ETH"); positionUnitsAmount = _openPosition(uint168(msg.value), _maxCVI, _maxBuyingPremiumFeePercentage, _leverage); } function transferFunds(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); } function deposit(uint256 tokenAmount, uint256 minLPTokenAmount) external override returns (uint256 lpTokenAmount) { revert("Use depositETH"); } function openPosition(uint168 tokenAmount, uint16 maxCVI, uint168 maxBuyingPremiumFeePercentage, uint8 leverage) external override returns (uint168 positionUnitsAmount) { revert("Use openPositionETH"); } }
// 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 "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "../v1/utils/SafeMath16.sol"; import "./utils/SafeMath168.sol"; import "./interfaces/IPlatformV2.sol"; import "./interfaces/IPositionRewardsV2.sol"; contract PlatformV2 is IPlatformV2, Ownable, ERC20, ReentrancyGuard { using SafeERC20 for IERC20; using SafeMath for uint256; using SafeMath168 for uint168; uint80 public latestOracleRoundId; uint32 public latestSnapshotTimestamp; bool private canPurgeLatestSnapshot = false; bool public emergencyWithdrawAllowed = false; bool private purgeSnapshots = true; uint8 public maxAllowedLeverage = 1; 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; ILiquidationV2 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; 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, ILiquidationV2 _liquidation) public ERC20(_lpTokenName, _lpTokenSymbolName) { token = _token; initialTokenToLPTokenRate = _initialTokenToLPTokenRate; feesCalculator = _feesCalculator; cviOracle = _cviOracle; liquidation = _liquidation; } function deposit(uint256 _tokenAmount, uint256 _minLPTokenAmount) external virtual override nonReentrant returns (uint256 lpTokenAmount) { _deposit(_tokenAmount, _minLPTokenAmount); } function withdraw(uint256 _tokenAmount, uint256 _maxLPTokenBurnAmount) external override nonReentrant returns (uint256 burntAmount, uint256 withdrawnAmount) { (burntAmount, withdrawnAmount) = _withdraw(_tokenAmount, false, _maxLPTokenBurnAmount); } function withdrawLPTokens(uint256 _lpTokensAmount) external override nonReentrant 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) external override virtual nonReentrant returns (uint168 positionUnitsAmount) { _openPosition(_tokenAmount, _maxCVI, _maxBuyingPremiumFeePercentage, _leverage); } function closePosition(uint168 _positionUnitsAmount, uint16 _minCVI) external override nonReentrant 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); transferFunds(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 nonReentrant returns (uint256 finderFeeAmount) { updateSnapshots(true); bool liquidationOccured = false; for ( uint256 i = 0; i < _positionOwners.length; i++) { Position memory position = positions[_positionOwners[i]]; if (position.positionUnitsAmount > 0) { (bool wasLiquidated, uint256 liquidatedAmount, bool isPositive) = checkAndLiquidatePosition(_positionOwners[i], false); if (wasLiquidated) { liquidationOccured = true; finderFeeAmount = finderFeeAmount.add(liquidation.getLiquidationReward(liquidatedAmount, isPositive, position.positionUnitsAmount, position.openCVIValue, position.leverage)); } } } require(liquidationOccured, "No liquidatable position"); totalLeveragedTokensAmount = totalLeveragedTokensAmount.sub(finderFeeAmount); transferFunds(finderFeeAmount); } function setFeesCollector(IFeesCollector _newCollector) external override onlyOwner { if (address(feesCollector) != address(0) && address(token) != address(0)) { token.approve(address(feesCollector), 0); } feesCollector = _newCollector; if (address(_newCollector) != address(0) && address(token) != address(0)) { token.approve(address(_newCollector), 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(ILiquidationV2 _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); Position memory position = positions[_positionOwners[i]]; if (position.positionUnitsAmount > 0 && liquidation.isLiquidationCandidate(currentPositionBalance, isBalancePositive, position.positionUnitsAmount, position.openCVIValue, position.leverage)) { 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 _deposit(uint256 _tokenAmount, uint256 _minLPTokenAmount) internal 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"); totalLeveragedTokensAmount = totalLeveragedTokensAmount.add(tokenAmountToDeposit); _mint(msg.sender, lpTokenAmount); collectTokens(_tokenAmount); collectProfit(depositFee); } 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"); require(emergencyWithdrawAllowed || getTokenBalance().sub(totalPositionUnitsAmount) >= _tokenAmount, "Collateral ratio broken"); totalLeveragedTokensAmount = totalLeveragedTokensAmount.sub(_tokenAmount); uint256 withdrawFee = _tokenAmount.mul(uint256(feesCalculator.withdrawFeePercent())) / MAX_FEE_PERCENTAGE; withdrawnAmount = _tokenAmount.sub(withdrawFee); emit Withdraw(msg.sender, _tokenAmount, burntAmount, withdrawFee); _burn(msg.sender, burntAmount); collectProfit(withdrawFee); transferFunds(withdrawnAmount); } function _openPosition(uint168 _tokenAmount, uint16 _maxCVI, uint168 _maxBuyingPremiumFeePercentage, uint8 _leverage) internal 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 - locals.openPositionFee).add(locals.positionBalance).mul(_leverage)); 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 - locals.openPositionFee) * _leverage); } 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); } } 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 transferFunds(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; Position memory position = positions[_positionAddress]; if (liquidation.isLiquidationCandidate(currentPositionBalance, isBalancePositive, position.positionUnitsAmount, position.openCVIValue, position.leverage)) { (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 setMaxTurbulenceFeePercentToTrim(uint16 newMaxTurbulenceFeePercentToTrim) 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; interface ILiquidationV2 { function setMinLiquidationThresholdPercents(uint16[8] calldata newMinThresholdPercents) external; function setMinLiquidationRewardPercent(uint16 newMinRewardPercent) external; function setMaxLiquidationRewardPercents(uint16[8] calldata newMaxRewardPercents) external; function isLiquidationCandidate(uint256 positionBalance, bool isPositive, uint168 positionUnitsAmount, uint16 openCVIValue, uint8 leverage) external view returns (bool); function getLiquidationReward(uint256 positionBalance, bool isPositive, uint168 positionUnitsAmount, uint16 openCVIValue, uint8 leverage) external view returns (uint256 finderFeeAmount); }
// 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 "./ILiquidationV2.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(ILiquidationV2 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); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
{ "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 ILiquidationV2","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 ILiquidationV2","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
60a06040526008805460ff60881b1962ffffff60701b19909116600160801b1716600160881b1790556203f480600f55615460601055601480546001600160a01b03191690553480156200005257600080fd5b50604051620057b2380380620057b28339810160408190526200007591620002be565b60008686868686868585886200008a62000177565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3508151620000e99060049060208501906200017b565b508051620000ff9060059060208401906200017b565b50506006805460ff19166012179055506001600755600980546001600160a01b039889166001600160a01b031991821617909155608094909452600c805493881693851693909317909255600a8054918716918416919091179055600b80549190951691161790925550620003889650505050505050565b3390565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001be57805160ff1916838001178555620001ee565b82800160010185558215620001ee579182015b82811115620001ee578251825591602001919060010190620001d1565b50620001fc92915062000200565b5090565b5b80821115620001fc576000815560010162000201565b600082601f83011262000228578081fd5b81516001600160401b03808211156200023f578283fd5b6040516020601f8401601f191682018101838111838210171562000261578586fd5b806040525081945083825286818588010111156200027e57600080fd5b600092505b83831015620002a2578583018101518284018201529182019162000283565b83831115620002b45760008185840101525b5050505092915050565b60008060008060008060c08789031215620002d7578182fd5b86516001600160401b0380821115620002ee578384fd5b620002fc8a838b0162000217565b9750602089015191508082111562000312578384fd5b506200032189828a0162000217565b9550506040870151935060608701516200033b816200036f565b60808801519093506200034e816200036f565b60a088015190925062000361816200036f565b809150509295509295509295565b6001600160a01b03811681146200038557600080fd5b50565b60805161540a620003a860003980611ad55280612cf0525061540a6000f3fe60806040526004361061038c5760003560e01c806370a08231116101dc578063a8a1eb8c11610102578063dd62ed3e116100a0578063ec38a8621161006f578063ec38a86214610a0b578063f2fde38b14610a2b578063f40af47014610a4b578063f59ce83814610a785761038c565b8063dd62ed3e14610996578063e2bbb158146109b6578063e7cb00c1146109d6578063ebc1daf6146109f65761038c565b8063aceda7f9116100dc578063aceda7f914610937578063ad7a672f1461094c578063b00446b814610961578063b152b295146109765761038c565b8063a8a1eb8c146108e2578063a9059cbb146108f7578063ab919ee3146109175761038c565b80638c7e74751161017a57806392c35fdb1161014957806392c35fdb1461085b57806395d89b411461087b578063a457c2d714610890578063a6ca982c146108b05761038c565b80638c7e7475146108075780638d4d7e311461081c5780638da5cb5b146108315780638eb50a38146108465761038c565b80637b04bc06116101b65780637b04bc06146107925780638202c681146107b457806385da0561146107d45780638ab38ed1146107f45761038c565b806370a082311461073d578063715018a61461075d578063745dd850146107725761038c565b806339509351116102c1578063558e44d31161025f5780636185aa3a1161022e5780636185aa3a146106bb578063655d8dec146106dd57806369463fa4146106fd5780636c7156411461071d5761038c565b8063558e44d31461063157806355f575101461065357806360ebfee6146106845780636162129b146106995761038c565b8063452d003f1161029b578063452d003f146105c957806348607250146105e95780635358fbda14610609578063547ef3e61461061c5761038c565b8063395093511461055b5780633f2cdd6c1461057b578063441a3e701461059b5761038c565b80631c1f8aa31161032e5780632f811c22116103085780632f811c22146104ef578063313ce567146105045780633252799214610526578063373071f21461053b5761038c565b80631c1f8aa31461048d57806321df0da7146104ad57806323b872dd146104cf5761038c565b8063095ea7b31161036a578063095ea7b31461040b578063124805861461043857806318160ddd146104585780631a8dd8f71461046d5761038c565b806302b1ba6f1461039157806305621f1a146103c757806306fdde03146103e9575b600080fd5b34801561039d57600080fd5b506103b16103ac36600461447a565b610a98565b6040516103be91906151c9565b60405180910390f35b3480156103d357600080fd5b506103e76103e236600461476e565b610b8b565b005b3480156103f557600080fd5b506103fe610be9565b6040516103be91906148aa565b34801561041757600080fd5b5061042b6104263660046144a7565b610c80565b6040516103be919061489f565b34801561044457600080fd5b506103b16104533660046144d2565b610c9e565b34801561046457600080fd5b506103b1610eb9565b34801561047957600080fd5b506103e76104883660046143e6565b610ebf565b34801561049957600080fd5b506103e76104a83660046143e6565b610f16565b3480156104b957600080fd5b506104c2610f6d565b6040516103be91906147a5565b3480156104db57600080fd5b5061042b6104ea36600461443a565b610f7c565b3480156104fb57600080fd5b506103b1611003565b34801561051057600080fd5b50610519611009565b6040516103be91906152d4565b34801561053257600080fd5b506103b1611012565b34801561054757600080fd5b506103e76105563660046143e6565b611018565b34801561056757600080fd5b5061042b6105763660046144a7565b6111c7565b34801561058757600080fd5b506103e761059636600461471d565b611215565b3480156105a757600080fd5b506105bb6105b636600461474d565b611272565b6040516103be929190615258565b3480156105d557600080fd5b506105bb6105e436600461471d565b6112b9565b3480156105f557600080fd5b506103e7610604366004614789565b61131d565b6103b161061736600461471d565b611377565b34801561062857600080fd5b506103b16113b6565b34801561063d57600080fd5b506106466113bc565b6040516103be919061510b565b34801561065f57600080fd5b5061067361066e3660046143e6565b6113c2565b6040516103be95949392919061511f565b34801561069057600080fd5b506103b161140d565b3480156106a557600080fd5b506106ae611416565b6040516103be91906151ba565b3480156106c757600080fd5b506106d0611525565b6040516103be91906152af565b3480156106e957600080fd5b506103b16106f83660046143e6565b611538565b34801561070957600080fd5b506103b1610718366004614579565b61154a565b34801561072957600080fd5b506103e76107383660046143e6565b6118a7565b34801561074957600080fd5b506103b16107583660046143e6565b6118fe565b34801561076957600080fd5b506103e761191d565b34801561077e57600080fd5b506103e761078d366004614541565b61199c565b34801561079e57600080fd5b506107a76119bc565b6040516103be91906152c0565b3480156107c057600080fd5b506103b16107cf36600461471d565b6119cb565b3480156107e057600080fd5b506103e76107ef36600461471d565b6119dd565b6103b161080236600461464a565b611a3a565b34801561081357600080fd5b50610519611aae565b34801561082857600080fd5b506103b1611abe565b34801561083d57600080fd5b506104c2611ac4565b34801561085257600080fd5b506103b1611ad3565b34801561086757600080fd5b506106466108763660046145d4565b611af7565b34801561088757600080fd5b506103fe611b11565b34801561089c57600080fd5b5061042b6108ab3660046144a7565b611b72565b3480156108bc57600080fd5b506108d06108cb3660046143e6565b611bda565b6040516103be96959493929190615224565b3480156108ee57600080fd5b506103b1611c45565b34801561090357600080fd5b5061042b6109123660046144a7565b611c76565b34801561092357600080fd5b506103e76109323660046143e6565b611c8a565b34801561094357600080fd5b5061042b611ce1565b34801561095857600080fd5b506103b1611cf1565b34801561096d57600080fd5b506103b1611d8d565b34801561098257600080fd5b5061042b6109913660046143e6565b611d93565b3480156109a257600080fd5b506103b16109b1366004614402565b611da8565b3480156109c257600080fd5b506103b16109d136600461474d565b611dd3565b3480156109e257600080fd5b506103e76109f1366004614541565b611ded565b348015610a0257600080fd5b506103b1611e40565b348015610a1757600080fd5b506103e7610a263660046143e6565b611e46565b348015610a3757600080fd5b506103e7610a463660046143e6565b611e9d565b348015610a5757600080fd5b50610a6b610a663660046144d2565b611f53565b6040516103be91906147ff565b348015610a8457600080fd5b506103e7610a93366004614541565b61221b565b6000610aa261428b565b506001600160a01b038316600090815260176020908152604091829020825160a08101845290546001600160a81b03808216835260ff600160a81b8304169383019390935261ffff600160b01b8204169382019390935263ffffffff600160c01b840481166060830152600160e01b909304831660808201526008549092610b8392610b3a92600160501b900490911690861661226e565b606083015163ffffffff90811660009081526015602052604080822054600854600160501b90049093168252902054610b7d91906001600160a81b0388166122ab565b906122d7565b949350505050565b610b93612303565b6000546001600160a01b03908116911614610bc95760405162461bcd60e51b8152600401610bc090614c01565b60405180910390fd5b6008805460ff909216600160881b0260ff60881b19909216919091179055565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610c755780601f10610c4a57610100808354040283529160200191610c75565b820191906000526020600020905b815481529060010190602001808311610c5857829003601f168201915b505050505090505b90565b6000610c94610c8d612303565b8484612307565b5060015b92915050565b600060026007541415610cc35760405162461bcd60e51b8152600401610bc090614fe0565b6002600755610cd260016123bb565b50506000805b83811015610e7657610ce861428b565b60176000878785818110610cf857fe5b9050602002016020810190610d0d91906143e6565b6001600160a01b031681526020808201929092526040908101600020815160a08101835290546001600160a81b03811680835260ff600160a81b8304169483019490945261ffff600160b01b8204169282019290925263ffffffff600160c01b830481166060830152600160e01b9092049091166080820152915015610e6d576000806000610dbd898987818110610da157fe5b9050602002016020810190610db691906143e6565b60006125b7565b9250925092508215610e6957600b5484516040808701516020880151915163068437bd60e21b815260019a50610e66946001600160a01b031693631a10def493610e0f938993899392906004016151f1565b60206040518083038186803b158015610e2757600080fd5b505afa158015610e3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5f9190614735565b88906122d7565b96505b5050505b50600101610cd8565b5080610e945760405162461bcd60e51b8152600401610bc090615066565b601354610ea19083612783565b601355610ead826127c5565b50600160075592915050565b60035490565b610ec7612303565b6000546001600160a01b03908116911614610ef45760405162461bcd60e51b8152600401610bc090614c01565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b610f1e612303565b6000546001600160a01b03908116911614610f4b5760405162461bcd60e51b8152600401610bc090614c01565b601480546001600160a01b0319166001600160a01b0392909216919091179055565b6009546001600160a01b031690565b6000610f898484846127f2565b610ff984610f95612303565b610ff485604051806060016040528060288152602001615388602891396001600160a01b038a16600090815260026020526040812090610fd3612303565b6001600160a01b031681526020810191909152604001600020549190612907565b612307565b5060019392505050565b60115481565b60065460ff1690565b600f5481565b611020612303565b6000546001600160a01b0390811691161461104d5760405162461bcd60e51b8152600401610bc090614c01565b600d546001600160a01b03161580159061107157506009546001600160a01b031615155b1561110157600954600d5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926110ad929116906000906004016147e6565b602060405180830381600087803b1580156110c757600080fd5b505af11580156110db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ff919061455d565b505b600d80546001600160a01b0319166001600160a01b0383169081179091551580159061113757506009546001600160a01b031615155b156111c45760095460405163095ea7b360e01b81526001600160a01b039091169063095ea7b390611170908490600019906004016147e6565b602060405180830381600087803b15801561118a57600080fd5b505af115801561119e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c2919061455d565b505b50565b6000610c946111d4612303565b84610ff485600260006111e5612303565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906122d7565b61121d612303565b6000546001600160a01b0390811691161461124a5760405162461bcd60e51b8152600401610bc090614c01565b62093a8081111561126d5760405162461bcd60e51b8152600401610bc090615017565b601055565b600080600260075414156112985760405162461bcd60e51b8152600401610bc090614fe0565b60026007556112a984600085612933565b6001600755909590945092505050565b600080600260075414156112df5760405162461bcd60e51b8152600401610bc090614fe0565b6002600755826113015760405162461bcd60e51b8152600401610bc09061509d565b61130e6000600185612933565b60016007559094909350915050565b611325612303565b6000546001600160a01b039081169116146113525760405162461bcd60e51b8152600401610bc090614c01565b6008805469ffffffffffffffffffff19166001600160501b0392909216919091179055565b60006002600754141561139c5760405162461bcd60e51b8152600401610bc090614fe0565b60026007556113ab3483612ba8565b600160075592915050565b60125481565b61271081565b6017602052600090815260409020546001600160a81b0381169060ff600160a81b8204169061ffff600160b01b8204169063ffffffff600160c01b8204811691600160e01b90041685565b6402540be40081565b60006114206142b9565b60085461143990600160501b900463ffffffff16612dd3565b9050806101200151156114d757600c54604080830151606084015191516312e001c360e21b81526001600160a01b0390931692634b80070c9261147f9291600401615258565b60206040518083038186803b15801561149757600080fd5b505afa1580156114ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cf919061462e565b915050610c7d565b600c60009054906101000a90046001600160a01b03166001600160a01b031663f359b46f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561149757600080fd5b600854600160501b900463ffffffff1681565b60166020526000908152604090205481565b60006002600754141561156f5760405162461bcd60e51b8152600401610bc090614fe0565b60026007556001600160a81b03831661159a5760405162461bcd60e51b8152600401610bc090614f52565b60008261ffff161180156115b45750614e208261ffff1611155b6115d05760405162461bcd60e51b8152600401610bc090614b38565b33600090815260176020526040902080546001600160a81b038086169116101561160c5760405162461bcd60e51b8152600401610bc090614bcc565b601054815461162d90429063ffffffff600160c01b90910481169061278316565b101561164b5760405162461bcd60e51b8152600401610bc090614ded565b60008061165860016123bb565b915091508461ffff168261ffff1610156116845760405162461bcd60e51b8152600401610bc090614e91565b60008060008061169f878b6001600160a81b031687896131e2565b935093509350935080156116bd5760009750505050505050506113ab565b6000806116ca8c8661327c565b601182905560128190558a5491935091506116ee906001600160a81b03168d6132c9565b89546001600160a81b0319166001600160a81b039190911617808a55600c54604051636f6bb7a760e01b81526000926117b692612710926117b0926001600160a01b0390921691636f6bb7a79161175591600160c01b900463ffffffff16906004016152af565b60206040518083038186803b15801561176d57600080fd5b505afa158015611781573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117a5919061462e565b8a9061ffff1661330b565b90613345565b9050337f3989dab79971090c83b28eb2d423aa507b7d4c16f5cf10a4fdb05835cafba36a6117e489896122d7565b6117ee848a6122d7565b8d60000160009054906101000a90046001600160a81b03168e60000160159054906101000a900460ff168e60405161182a959493929190615266565b60405180910390a289546001600160a81b031661185257336000908152601760205260408120555b6118718561186b8960135461278390919063ffffffff16565b90612783565b60135561187e8782612783565b9a5061188981613387565b6118928b6127c5565b50505050505050505050600160075592915050565b6118af612303565b6000546001600160a01b039081169116146118dc5760405162461bcd60e51b8152600401610bc090614c01565b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166000908152600160205260409020545b919050565b611925612303565b6000546001600160a01b039081169116146119525760405162461bcd60e51b8152600401610bc090614c01565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b336000908152601860205260409020805460ff1916911515919091179055565b6008546001600160501b031681565b60156020526000908152604090205481565b6119e5612303565b6000546001600160a01b03908116911614611a125760405162461bcd60e51b8152600401610bc090614c01565b62127500811115611a355760405162461bcd60e51b8152600401610bc090615017565b600f55565b600060026007541415611a5f5760405162461bcd60e51b8152600401610bc090614fe0565b6002600755346001600160a81b03811614611a8c5760405162461bcd60e51b8152600401610bc090614975565b611a98348585856133bd565b60016007556001600160a81b0316949350505050565b600854600160881b900460ff1681565b60135481565b6000546001600160a01b031690565b7f000000000000000000000000000000000000000000000000000000000000000081565b600060405162461bcd60e51b8152600401610bc090614fb3565b60058054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610c755780601f10610c4a57610100808354040283529160200191610c75565b6000610c94611b7f612303565b84610ff4856040518060600160405280602581526020016153b06025913960026000611ba9612303565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190612907565b6001600160a01b03811660009081526017602052604081205481906001600160a81b03811690600160a81b900460ff16828083611c295760405162461bcd60e51b8152600401610bc090614ab3565b611c34876001613b0c565b929a91995095975093955092915050565b600854601154600091611c7191611c6991600160501b900463ffffffff169061226e565b610b7d611cf1565b905090565b6000610c94611c83612303565b84846127f2565b611c92612303565b6000546001600160a01b03908116911614611cbf5760405162461bcd60e51b8152600401610bc090614c01565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b600854600160781b900460ff1681565b600080600a60009054906101000a90046001600160a01b03166001600160a01b031663c1639a2b6040518163ffffffff1660e01b815260040160606040518083038186803b158015611d4257600080fd5b505afa158015611d56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7a91906146db565b50509050611d8781613cb8565b91505090565b614e2081565b60186020526000908152604090205460ff1681565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b600060405162461bcd60e51b8152600401610bc090614b63565b611df5612303565b6000546001600160a01b03908116911614611e225760405162461bcd60e51b8152600401610bc090614c01565b60088054911515600160801b0260ff60801b19909216919091179055565b60105481565b611e4e612303565b6000546001600160a01b03908116911614611e7b5760405162461bcd60e51b8152600401610bc090614c01565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b611ea5612303565b6000546001600160a01b03908116911614611ed25760405162461bcd60e51b8152600401610bc090614c01565b6001600160a01b038116611ef85760405162461bcd60e51b8152600401610bc09061499b565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6060808267ffffffffffffffff81118015611f6d57600080fd5b50604051908082528060200260200182016040528015611f97578160200160208202803683370190505b5090506000805b8481101561217f57600080611fd4888885818110611fb857fe5b9050602002016020810190611fcd91906143e6565b6001613b0c565b505091509150611fe261428b565b601760008a8a87818110611ff257fe5b905060200201602081019061200791906143e6565b6001600160a01b031681526020808201929092526040908101600020815160a08101835290546001600160a81b03811680835260ff600160a81b8304169483019490945261ffff600160b01b8204169282019290925263ffffffff600160c01b830481166060830152600160e01b909204909116608082015291501580159061211c5750600b548151604080840151602085015191516304fb2f7560e51b81526001600160a01b0390941693639f65eea0936120cc93899389939091906004016151f1565b60206040518083038186803b1580156120e457600080fd5b505afa1580156120f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211c919061455d565b156121745788888581811061212d57fe5b905060200201602081019061214291906143e6565b86868151811061214e57fe5b6001600160a01b03909216602092830291909101909101526121718560016122d7565b94505b505050600101611f9e565b5060608167ffffffffffffffff8111801561219957600080fd5b506040519080825280602002602001820160405280156121c3578160200160208202803683370190505b50905060005b82811015612211578381815181106121dd57fe5b60200260200101518282815181106121f157fe5b6001600160a01b03909216602092830291909101909101526001016121c9565b5095945050505050565b612223612303565b6000546001600160a01b039081169116146122505760405162461bcd60e51b8152600401610bc090614c01565b60088054911515600160781b0260ff60781b19909216919091179055565b60006122786142b9565b60085461229190600160501b900463ffffffff16612dd3565b6000858152601560205260409020548151919250610b8391855b60006402540be4006122c7836122c18688612783565b9061330b565b816122ce57fe5b04949350505050565b6000828201838110156122fc5760405162461bcd60e51b8152600401610bc090614a7c565b9392505050565b3390565b6001600160a01b03831661232d5760405162461bcd60e51b8152600401610bc090614e16565b6001600160a01b0382166123535760405162461bcd60e51b8152600401610bc0906149e1565b6001600160a01b0380841660008181526002602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906123ae9085906151c9565b60405180910390a3505050565b6008546000908190600160501b900463ffffffff166123d86142b9565b6123e182612dd3565b90508060c00151156124365780514260009081526015602090815260409091209190915560115490820151612432916402540be400916124209161330b565b8161242757fe5b6012549190046122d7565b6012555b8060e00151156124685760808101516008805469ffffffffffffffffffff19166001600160501b039092169190911790555b8061012001511561250057600c5460408083015160608401519151630d14ef1560e41b81526001600160a01b039093169263d14ef150926124ac9291600401615258565b602060405180830381600087803b1580156124c657600080fd5b505af11580156124da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fe919061462e565b505b8061010001511561257b576008805463ffffffff60501b1916600160501b4263ffffffff16021790819055600160701b900460ff16801561254a5750600854600160801b900460ff165b1561255f576000828152601560205260408120555b6008805460ff60701b1916600160701b871515021790556125a5565b600854600160701b900460ff16156125a5576008805460ff60701b1916600160701b871515021790555b60a08101519051909350915050915091565b60008060008060008060006125cc8989613b0c565b93509350935093508294508395506125e261428b565b506001600160a01b03808a16600090815260176020908152604091829020825160a08101845290546001600160a81b03811680835260ff600160a81b83041693830184905261ffff600160b01b83041683860181905263ffffffff600160c01b840481166060860152600160e01b9093049092166080840152600b5494516304fb2f7560e51b815292959490941693639f65eea09361268a938b938b939290916004016151f1565b60206040518083038186803b1580156126a257600080fd5b505afa1580156126b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126da919061455d565b15612777576000806126f083600001518661327c565b60118290556012819055601354919350915061270c9085612783565b60135582516040516001600160a01b038e16917f302eaf71224bcd9ed28854139aa87a32dc89622b38a4d8ce4160475aa57a7f139161274f918b918b91906151d2565b60405180910390a250506001600160a01b038a16600090815260176020526040812055600197505b50505050509250925092565b60006122fc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612907565b604051339082156108fc029083906000818181858888f193505050501580156111c2573d6000803e3d6000fd5b6001600160a01b0383166128185760405162461bcd60e51b8152600401610bc090614d47565b6001600160a01b03821661283e5760405162461bcd60e51b8152600401610bc0906148fd565b612849838383613cf8565b61288681604051806060016040528060268152602001615362602691396001600160a01b0386166000908152600160205260409020549190612907565b6001600160a01b0380851660009081526001602052604080822093909355908416815220546128b590826122d7565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906123ae9085906151c9565b6000818484111561292b5760405162461bcd60e51b8152600401610bc091906148aa565b505050900390565b600f543360009081526016602052604081205490918291429161295691906122d7565b11156129745760405162461bcd60e51b8152600401610bc090614f89565b600061298060016123bb565b50905084156129b1578392506129aa612997610eb9565b6117b06129a384613cb8565b869061330b565b9550612a1b565b600086116129d15760405162461bcd60e51b8152600401610bc090614ccf565b6129f96001610b7d6129e284613cb8565b6117b0600161186b6129f2610eb9565b8d9061330b565b925083831115612a1b5760405162461bcd60e51b8152600401610bc090614c6d565b612a24336118fe565b831115612a435760405162461bcd60e51b8152600401610bc090614940565b600854600160781b900460ff1680612a68575085612a6560115461186b613de8565b10155b612a845760405162461bcd60e51b8152600401610bc090614e5a565b601354612a919087612783565b601355600c546040805163495ef70560e01b8152905160009261271092612b27926001600160a01b039092169163495ef70591600480820192602092909190829003018186803b158015612ae457600080fd5b505afa158015612af8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b1c919061462e565b899061ffff1661330b565b81612b2e57fe5b049050612b3b8782612783565b9250336001600160a01b03167f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca94888684604051612b7a93929190615299565b60405180910390a2612b8c3385613df4565b612b9581613387565b612b9e836127c5565b5050935093915050565b6000808311612bc95760405162461bcd60e51b8152600401610bc090614ccf565b336000908152601660205260408120429055612be560016123bb565b50905060006127106001600160a81b0316612c8a600c60009054906101000a90046001600160a01b03166001600160a01b031663cc1252ae6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c4757600080fd5b505afa158015612c5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7f919061462e565b879061ffff1661330b565b81612c9157fe5b0490506000612ca08683612783565b90506000612cac610eb9565b90506000612cb985613cb8565b9050600082118015612ccb5750600081115b15612cea5780612cdb848461330b565b81612ce257fe5b049550612d17565b612d14837f000000000000000000000000000000000000000000000000000000000000000061330b565b95505b336001600160a01b03167f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e898887604051612d5493929190615299565b60405180910390a286861015612d7c5760405162461bcd60e51b8152600401610bc090614a51565b60008611612d9c5760405162461bcd60e51b8152600401610bc090614b10565b601354612da990846122d7565b601355612db63387613ed6565b612dbf886111c4565b612dc884613387565b505050505092915050565b612ddb6142b9565b6000806000600a60009054906101000a90046001600160a01b03166001600160a01b031663c1639a2b6040518163ffffffff1660e01b815260040160606040518083038186803b158015612e2e57600080fd5b505afa158015612e42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e6691906146db565b61ffff831660a088015242600090815260156020526040902054808852929550909350915015612e9f5750506000602083015250611918565b600854600160501b900463ffffffff16612eef57506402540be4008352600160c084018190526001600160501b03909116608084015260e083018190526101008301525060006020820152611918565b6008546001600160501b03908116908316811115612f1f5760405162461bcd60e51b8152600401610bc090615040565b6001600160501b038184031660608601819052600090612f40576001612f43565b60025b60ff16905060608167ffffffffffffffff81118015612f6157600080fd5b50604051908082528060200260200182016040528015612f9b57816020015b612f8861430d565b815260200190600190039081612f805790505b506060880151909150156130eb57600a54604051635a7b84b160e01b815260009182916001600160a01b0390911690635a7b84b190612fde9088906004016152c0565b604080518083038186803b158015612ff557600080fd5b505afa158015613009573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061302d91906146ae565b91509150604051806040016040528061304f8c8961278390919063ffffffff16565b81526020018361ffff168152508360008151811061306957fe5b60200260200101819052506040518060400160405280613092884261278390919063ffffffff16565b81526020018961ffff16815250836001815181106130ac57fe5b60209081029190910101526001600160501b03871660808a0152600160e08a01526130d78682612783565b60408a015250506001610120880152613126565b6040805180820190915280613100428b612783565b81526020018761ffff168152508160008151811061311a57fe5b60200260200101819052505b600c54604051635d769d1760e11b81526001600160a01b039091169063baed3a2e9061315690849060040161484c565b60206040518083038186803b15801561316e57600080fd5b505afa158015613182573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131a69190614735565b602080890182905260008a8152601590915260409020546131c6916122d7565b87525050600160c0860181905261010086015250505050919050565b8354600160c01b900463ffffffff166000908152601560205260408120548190819081906132119087896122ab565b885490935060009081908190613241908b90600160a81b810460ff16908b90600160b01b900461ffff168a613f8a565b92509250925081613267576132573360006125b7565b505050600193506000955061326e565b8296508094505b505050945094509450949050565b60008061329d846001600160a81b031660115461278390919063ffffffff16565b9150601254905081600014156132b5575060006132c2565b6132bf8184612783565b90505b9250929050565b60006122fc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061403b565b60008261331a57506000610c98565b8282028284828161332757fe5b04146122fc5760405162461bcd60e51b8152600401610bc090614b8b565b60006122fc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614072565b6000811180156133a15750600d546001600160a01b031615155b156111c4576009546111c49082906001600160a01b03166140a9565b6000808260ff16116133e15760405162461bcd60e51b8152600401610bc090614eb6565b60085460ff600160881b909104811690831611156134115760405162461bcd60e51b8152600401610bc090614db6565b6000856001600160a81b03161161343a5760405162461bcd60e51b8152600401610bc090614ccf565b60008461ffff161180156134545750614e208461ffff1611155b6134705760405162461bcd60e51b8152600401610bc090614ca4565b613478614324565b61348260006123bb565b608083015261ffff908116610160830181905290861610156134b65760405162461bcd60e51b8152600401610bc090614aea565b600c54604080516307e3dd0f60e41b8152815160009384936001600160a01b0390911692637e3dd0f09260048083019392829003018186803b1580156134fb57600080fd5b505afa15801561350f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135339190614691565b909250905061271061355961ffff84166122c16001600160a81b038c1660ff8a1661330b565b8161356057fe5b0460a0840181905261016084015161ffff169061359690614e20906122c19060ff8a169082906001600160a81b038f1690612783565b8161359d57fe5b046101408401526127106135cd6135b88261ffff85166132c9565b610140860151906001600160a81b031661330b565b816135d457fe5b0460c08401526135ec6001600160a81b0389166140e3565b80845260006020850152156136435760a0830151835161363d9161361b91906001600160a81b038c16036122d7565b6117b06402540be4006122c18760c001516011546122d790919063ffffffff16565b60208401525b600c546020840151604051630d82490360e41b81526001600160a01b039092169163d82490309161367a918c918a9160040161515d565b604080518083038186803b15801561369157600080fd5b505afa1580156136a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136c991906145a6565b61ffff1661010085018190526001600160a81b0391821660e086015290871610156137065760405162461bcd60e51b8152600401610bc090614a23565b876001600160a81b03168360a00151106137325760405162461bcd60e51b8152600401610bc090614d8c565b61376e8560ff1661375f8560e001518660a001518c036001600160a81b03166132c990919063ffffffff16565b6001600160a81b0316906140ef565b6001600160a81b03908116610120850152336000908152601760205260409020805490911615613837576137bc8185608001518661016001518761012001516001600160a81b03168a61414a565b86604001876060018281525082815250829750505050600061380d6138048860ff166122c188606001518960a001518f6001600160a81b0316036122d790919063ffffffff16565b601354906122d7565b905061382e856060015161186b87604001518461278390919063ffffffff16565b601355506139be565b600084610160015161ffff16613866614e208761012001516001600160a81b031661330b90919063ffffffff16565b8161386d57fe5b04905080955080866001600160a81b03161461389b5760405162461bcd60e51b8152600401610bc090614f1b565b6138a361428b565b506040805160a0810182526001600160a81b0380891680835260ff808c1660208086019182526101608c015161ffff90811687890190815263ffffffff42811660608a0181815260808b0191825233600090815260179096529a90942089518154965193519b5195518316600160e01b026001600160e01b03968416600160c01b0263ffffffff60c01b199d909616600160b01b0261ffff60b01b1995909916600160a81b0260ff60a81b1992909b166001600160a81b031990981697909717169890981791909116949094179790971696909617959095169490941790915560115491926139949291906122d716565b60115560a08601516013546139b8916001600160a81b038e160360ff8b16026122d7565b60135550505b336001600160a01b03167fe485c81af56f49547b2ea1b6886083d8e3a7ef50fe670c9574bd5d4b2dd7d4628a88613a0f8860e001516001600160a81b03168960a001516122d790919063ffffffff16565b610160890151604051613a26949392918c91615181565b60405180910390a2613a40896001600160a81b03166111c4565b8351613a55906001600160a81b038b166122d7565b845260a0840151613a6590613387565b83516011541115613a885760405162461bcd60e51b8152600401610bc090614eed565b600e546001600160a01b031615613b0057600e54604051630bf1944760e21b81526001600160a01b0390911690632fc6511c90613acd90339089908b906004016147b9565b600060405180830381600087803b158015613ae757600080fd5b505af1158015613afb573d6000803e3d6000fd5b505050505b50505050949350505050565b600080600080613b1a61428b565b506001600160a01b038087166000908152601760209081526040808320815160a08101835290546001600160a81b038116825260ff600160a81b8204169382019390935261ffff600160b01b8404168183015263ffffffff600160c01b84048116606080840191909152600160e01b909404166080820152600a54825163c1639a2b60e01b815292519195169263c1639a2b9260048082019391829003018186803b158015613bc857600080fd5b505afa158015613bdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0091906146db565b5050606083015163ffffffff90811660009081526015602052604080822054600854600160501b900490931682529020548451929350613c48926001600160a81b03166122ab565b93508615613c84576008548251613c8191613c7a91600160501b90910463ffffffff16906001600160a81b031661226e565b85906122d7565b93505b613ca682600001516001600160a81b0316836020015183856040015188613f8a565b919a9099509497509550929350505050565b6000610c98614e20613cd98461ffff1660115461330b90919063ffffffff16565b81613ce057fe5b0461186b6012546013546122d790919063ffffffff16565b600f546001600160a01b0384166000908152601660205260409020544291613d2091906122d7565b118015613d4d57506001600160a01b03808316600090815260166020526040808220549286168252902054115b8015613d6757506014546001600160a01b03848116911614155b8015613d8157506014546001600160a01b03838116911614155b15613de3576001600160a01b03821660009081526018602052604090205460ff1615613dbf5760405162461bcd60e51b8152600401610bc090614c36565b6001600160a01b038084166000908152601660205260408082205492851682529020555b505050565b6000611c7160006140e3565b6001600160a01b038216613e1a5760405162461bcd60e51b8152600401610bc090614d06565b613e2682600083613cf8565b613e6381604051806060016040528060228152602001615340602291396001600160a01b0385166000908152600160205260409020549190612907565b6001600160a01b038316600090815260016020526040902055600354613e899082612783565b6003556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90613eca9085906151c9565b60405180910390a35050565b6001600160a01b038216613efc5760405162461bcd60e51b8152600401610bc0906150d4565b613f0860008383613cf8565b600354613f1590826122d7565b6003556001600160a01b038216600090815260016020526040902054613f3b90826122d7565b6001600160a01b0383166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90613eca9085906151c9565b6000808080614e20613fa08a61ffff8a1661330b565b81613fa757fe5b04905060018860ff1611613fbc576000613ff5565b8760ff16614e20613fe460018b0360ff166122c18a61ffff168e61330b90919063ffffffff16565b81613feb57fe5b0481613ff357fe5b045b9150600061400383876122d7565b9050808210614021576140168282612783565b94506001935061402e565b61402b8183612783565b94505b5050955095509592505050565b6000836001600160a81b0316836001600160a81b03161115829061292b5760405162461bcd60e51b8152600401610bc091906148aa565b600081836140935760405162461bcd60e51b8152600401610bc091906148aa565b50600083858161409f57fe5b0495945050505050565b600d546040516001600160a01b039091169083156108fc029084906000818181858888f19350505050158015613de3573d6000803e3d6000fd5b6000610c984783612783565b60006001600160a81b03831661410757506000610c98565b8282026001600160a81b03808416908086169083168161412357fe5b046001600160a81b0316146122fc5760405162461bcd60e51b8152600401610bc090614b8b565b60008060006141576143a4565b88546001600160a81b031680825260009081908190819061417b908e908e8e6131e2565b9350935093509350801561419457600080865293508391505b6141bc8b61ffff166117b0614e206122c18e610b7d8f60ff168b61330b90919063ffffffff16565b6020860181905297506001600160a81b03881688146141ed5760405162461bcd60e51b8152600401610bc090614f1b565b8c5463ffffffff60c01b1916600160c01b4263ffffffff1602176001600160a81b0319166001600160a81b0389161761ffff60b01b1916600160b01b61ffff8d16021760ff60a81b1916600160a81b60ff8b1602178d558451614250908461327c565b6060870181905260408701829052601255614274906001600160a81b038a166122d7565b60115550959b959a50909850939650505050505050565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b604080518082019091526000808252602082015290565b6040518061018001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a81b0316815260200160006001600160a81b0316815260200160006001600160a81b0316815260200160008152602001600061ffff1681525090565b604051806080016040528060006001600160a81b031681526020016000815260200160008152602001600081525090565b803560ff81168114610c9857600080fd5b6000602082840312156143f7578081fd5b81356122fc816152e2565b60008060408385031215614414578081fd5b823561441f816152e2565b9150602083013561442f816152e2565b809150509250929050565b60008060006060848603121561444e578081fd5b8335614459816152e2565b92506020840135614469816152e2565b929592945050506040919091013590565b6000806040838503121561448c578182fd5b8235614497816152e2565b9150602083013561442f81615315565b600080604083850312156144b9578182fd5b82356144c4816152e2565b946020939093013593505050565b600080602083850312156144e4578182fd5b823567ffffffffffffffff808211156144fb578384fd5b818501915085601f83011261450e578384fd5b81358181111561451c578485fd5b866020808302850101111561452f578485fd5b60209290920196919550909350505050565b600060208284031215614552578081fd5b81356122fc816152f7565b60006020828403121561456e578081fd5b81516122fc816152f7565b6000806040838503121561458b578182fd5b823561459681615315565b9150602083013561442f81615305565b600080604083850312156145b8578182fd5b82516145c381615315565b602084015190925061442f81615305565b600080600080608085870312156145e9578182fd5b84356145f481615315565b9350602085013561460481615305565b9250604085013561461481615315565b915061462386606087016143d5565b905092959194509250565b60006020828403121561463f578081fd5b81516122fc81615305565b60008060006060848603121561465e578081fd5b833561466981615305565b9250602084013561467981615315565b915061468885604086016143d5565b90509250925092565b600080604083850312156146a3578182fd5b82516145c381615305565b600080604083850312156146c0578182fd5b82516146cb81615305565b6020939093015192949293505050565b6000806000606084860312156146ef578081fd5b83516146fa81615305565b602085015190935061470b8161532a565b80925050604084015190509250925092565b60006020828403121561472e578081fd5b5035919050565b600060208284031215614746578081fd5b5051919050565b6000806040838503121561475f578182fd5b50508035926020909101359150565b60006020828403121561477f578081fd5b6122fc83836143d5565b60006020828403121561479a578081fd5b81356122fc8161532a565b6001600160a01b0391909116815260200190565b6001600160a01b039390931683526001600160a81b0391909116602083015260ff16604082015260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156148405783516001600160a01b03168352928401929184019160010161481b565b50909695505050505050565b602080825282518282018190526000919060409081850190868401855b828110156148925781518051855286015161ffff16868501529284019290850190600101614869565b5091979650505050505050565b901515815260200190565b6000602080835283518082850152825b818110156148d6578581018301518582016040015282016148ba565b818111156148e75783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252818101527f4e6f7420656e6f756768204c5020746f6b656e7320666f72206163636f756e74604082015260600190565b6020808252600c908201526b0a8dede40daeac6d0408aa8960a31b604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601490820152730a0e4cadad2eada40cccaca40e8dede40d0d2ced60631b604082015260600190565b602080825260119082015270546f6f20666577204c5020746f6b656e7360781b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601d908201527f4e6f20706f736974696f6e20666f7220676976656e2061646472657373000000604082015260600190565b6020808252600c908201526b086ac9240e8dede40d0d2ced60a31b604082015260600190565b6020808252600e908201526d546f6f2066657720746f6b656e7360901b604082015260600190565b602080825260119082015270426164206d696e204356492076616c756560781b604082015260600190565b6020808252600e908201526d0aae6ca40c8cae0dee6d2e88aa8960931b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4e6f7420656e6f756768206f70656e656420706f736974696f6e20756e697473604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f526563697069656e742072656675736573206c6f636b656420746f6b656e7300604082015260600190565b6020808252601a908201527f546f6f206d756368204c5020746f6b656e7320746f206275726e000000000000604082015260600190565b602080825260119082015270426164206d6178204356492076616c756560781b604082015260600190565b6020808252601e908201527f546f6b656e7320616d6f756e74206d75737420626520706f7369746976650000604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526010908201526f4f70656e2066656520746f6f2062696760801b604082015260600190565b6020808252601d908201527f4c65766572616765206578636365656473206d617820616c6c6f776564000000604082015260600190565b6020808252600f908201526e141bdcda5d1a5bdb881b1bd8dad959608a1b604082015260600190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526017908201527f436f6c6c61746572616c20726174696f2062726f6b656e000000000000000000604082015260600190565b6020808252600b908201526a43564920746f6f206c6f7760a81b604082015260600190565b60208082526019908201527f4c65766572616765206d75737420626520706f73697469766500000000000000604082015260600190565b6020808252601490820152734e6f7420656e6f756768206c697175696469747960601b604082015260600190565b60208082526017908201527f546f6f206d75636820706f736974696f6e20756e697473000000000000000000604082015260600190565b6020808252601b908201527f506f736974696f6e20756e697473206e6f7420706f7369746976650000000000604082015260600190565b60208082526010908201526f119d5b991cc8185c99481b1bd8dad95960821b604082015260600190565b6020808252601390820152720aae6ca40dee0cadca0dee6d2e8d2dedc8aa89606b1b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600f908201526e4c6f636b757020746f6f206c6f6e6760881b604082015260600190565b6020808252600c908201526b109859081c9bdd5b99081a5960a21b604082015260600190565b60208082526018908201527f4e6f206c6971756964617461626c6520706f736974696f6e0000000000000000604082015260600190565b60208082526017908201527f416d6f756e74206d75737420626520706f736974697665000000000000000000604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b6001600160a81b0391909116815260200190565b6001600160a81b0395909516855260ff93909316602085015261ffff91909116604084015263ffffffff908116606084015216608082015260a00190565b6001600160a81b0393909316835260ff919091166020830152604082015260600190565b6001600160a81b03958616815260ff9490941660208501526040840192909252909216606082015261ffff909116608082015260a00190565b61ffff91909116815260200190565b90815260200190565b92835290151560208301526001600160a81b0316604082015260600190565b94855292151560208501526001600160a81b0391909116604084015261ffff16606083015260ff16608082015260a00190565b95865293151560208601526001600160a81b0392909216604085015260ff166060840152608083015260a082015260c00190565b918252602082015260400190565b94855260208501939093526001600160a81b0391909116604084015260ff16606083015261ffff16608082015260a00190565b9283526020830191909152604082015260600190565b63ffffffff91909116815260200190565b6001600160501b0391909116815260200190565b60ff91909116815260200190565b6001600160a01b03811681146111c457600080fd5b80151581146111c457600080fd5b61ffff811681146111c457600080fd5b6001600160a81b03811681146111c457600080fd5b6001600160501b03811681146111c457600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212207dbb4d2f078e38d126687127c39ee742673819017ce3a196fe92c3af2fb0229264736f6c634300060c003300000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000000000000000000000000000006fc8cc3e6d3da8b29c4480e77e24dea298293ace0000000000000000000000008d55c22ea6610e3fa4659d3d5f4d751ca1e6257300000000000000000000000000000000000000000000000000000000000000094554482d4c502d5632000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000094554482d4c502d56320000000000000000000000000000000000000000000000
Deployed Bytecode
0x60806040526004361061038c5760003560e01c806370a08231116101dc578063a8a1eb8c11610102578063dd62ed3e116100a0578063ec38a8621161006f578063ec38a86214610a0b578063f2fde38b14610a2b578063f40af47014610a4b578063f59ce83814610a785761038c565b8063dd62ed3e14610996578063e2bbb158146109b6578063e7cb00c1146109d6578063ebc1daf6146109f65761038c565b8063aceda7f9116100dc578063aceda7f914610937578063ad7a672f1461094c578063b00446b814610961578063b152b295146109765761038c565b8063a8a1eb8c146108e2578063a9059cbb146108f7578063ab919ee3146109175761038c565b80638c7e74751161017a57806392c35fdb1161014957806392c35fdb1461085b57806395d89b411461087b578063a457c2d714610890578063a6ca982c146108b05761038c565b80638c7e7475146108075780638d4d7e311461081c5780638da5cb5b146108315780638eb50a38146108465761038c565b80637b04bc06116101b65780637b04bc06146107925780638202c681146107b457806385da0561146107d45780638ab38ed1146107f45761038c565b806370a082311461073d578063715018a61461075d578063745dd850146107725761038c565b806339509351116102c1578063558e44d31161025f5780636185aa3a1161022e5780636185aa3a146106bb578063655d8dec146106dd57806369463fa4146106fd5780636c7156411461071d5761038c565b8063558e44d31461063157806355f575101461065357806360ebfee6146106845780636162129b146106995761038c565b8063452d003f1161029b578063452d003f146105c957806348607250146105e95780635358fbda14610609578063547ef3e61461061c5761038c565b8063395093511461055b5780633f2cdd6c1461057b578063441a3e701461059b5761038c565b80631c1f8aa31161032e5780632f811c22116103085780632f811c22146104ef578063313ce567146105045780633252799214610526578063373071f21461053b5761038c565b80631c1f8aa31461048d57806321df0da7146104ad57806323b872dd146104cf5761038c565b8063095ea7b31161036a578063095ea7b31461040b578063124805861461043857806318160ddd146104585780631a8dd8f71461046d5761038c565b806302b1ba6f1461039157806305621f1a146103c757806306fdde03146103e9575b600080fd5b34801561039d57600080fd5b506103b16103ac36600461447a565b610a98565b6040516103be91906151c9565b60405180910390f35b3480156103d357600080fd5b506103e76103e236600461476e565b610b8b565b005b3480156103f557600080fd5b506103fe610be9565b6040516103be91906148aa565b34801561041757600080fd5b5061042b6104263660046144a7565b610c80565b6040516103be919061489f565b34801561044457600080fd5b506103b16104533660046144d2565b610c9e565b34801561046457600080fd5b506103b1610eb9565b34801561047957600080fd5b506103e76104883660046143e6565b610ebf565b34801561049957600080fd5b506103e76104a83660046143e6565b610f16565b3480156104b957600080fd5b506104c2610f6d565b6040516103be91906147a5565b3480156104db57600080fd5b5061042b6104ea36600461443a565b610f7c565b3480156104fb57600080fd5b506103b1611003565b34801561051057600080fd5b50610519611009565b6040516103be91906152d4565b34801561053257600080fd5b506103b1611012565b34801561054757600080fd5b506103e76105563660046143e6565b611018565b34801561056757600080fd5b5061042b6105763660046144a7565b6111c7565b34801561058757600080fd5b506103e761059636600461471d565b611215565b3480156105a757600080fd5b506105bb6105b636600461474d565b611272565b6040516103be929190615258565b3480156105d557600080fd5b506105bb6105e436600461471d565b6112b9565b3480156105f557600080fd5b506103e7610604366004614789565b61131d565b6103b161061736600461471d565b611377565b34801561062857600080fd5b506103b16113b6565b34801561063d57600080fd5b506106466113bc565b6040516103be919061510b565b34801561065f57600080fd5b5061067361066e3660046143e6565b6113c2565b6040516103be95949392919061511f565b34801561069057600080fd5b506103b161140d565b3480156106a557600080fd5b506106ae611416565b6040516103be91906151ba565b3480156106c757600080fd5b506106d0611525565b6040516103be91906152af565b3480156106e957600080fd5b506103b16106f83660046143e6565b611538565b34801561070957600080fd5b506103b1610718366004614579565b61154a565b34801561072957600080fd5b506103e76107383660046143e6565b6118a7565b34801561074957600080fd5b506103b16107583660046143e6565b6118fe565b34801561076957600080fd5b506103e761191d565b34801561077e57600080fd5b506103e761078d366004614541565b61199c565b34801561079e57600080fd5b506107a76119bc565b6040516103be91906152c0565b3480156107c057600080fd5b506103b16107cf36600461471d565b6119cb565b3480156107e057600080fd5b506103e76107ef36600461471d565b6119dd565b6103b161080236600461464a565b611a3a565b34801561081357600080fd5b50610519611aae565b34801561082857600080fd5b506103b1611abe565b34801561083d57600080fd5b506104c2611ac4565b34801561085257600080fd5b506103b1611ad3565b34801561086757600080fd5b506106466108763660046145d4565b611af7565b34801561088757600080fd5b506103fe611b11565b34801561089c57600080fd5b5061042b6108ab3660046144a7565b611b72565b3480156108bc57600080fd5b506108d06108cb3660046143e6565b611bda565b6040516103be96959493929190615224565b3480156108ee57600080fd5b506103b1611c45565b34801561090357600080fd5b5061042b6109123660046144a7565b611c76565b34801561092357600080fd5b506103e76109323660046143e6565b611c8a565b34801561094357600080fd5b5061042b611ce1565b34801561095857600080fd5b506103b1611cf1565b34801561096d57600080fd5b506103b1611d8d565b34801561098257600080fd5b5061042b6109913660046143e6565b611d93565b3480156109a257600080fd5b506103b16109b1366004614402565b611da8565b3480156109c257600080fd5b506103b16109d136600461474d565b611dd3565b3480156109e257600080fd5b506103e76109f1366004614541565b611ded565b348015610a0257600080fd5b506103b1611e40565b348015610a1757600080fd5b506103e7610a263660046143e6565b611e46565b348015610a3757600080fd5b506103e7610a463660046143e6565b611e9d565b348015610a5757600080fd5b50610a6b610a663660046144d2565b611f53565b6040516103be91906147ff565b348015610a8457600080fd5b506103e7610a93366004614541565b61221b565b6000610aa261428b565b506001600160a01b038316600090815260176020908152604091829020825160a08101845290546001600160a81b03808216835260ff600160a81b8304169383019390935261ffff600160b01b8204169382019390935263ffffffff600160c01b840481166060830152600160e01b909304831660808201526008549092610b8392610b3a92600160501b900490911690861661226e565b606083015163ffffffff90811660009081526015602052604080822054600854600160501b90049093168252902054610b7d91906001600160a81b0388166122ab565b906122d7565b949350505050565b610b93612303565b6000546001600160a01b03908116911614610bc95760405162461bcd60e51b8152600401610bc090614c01565b60405180910390fd5b6008805460ff909216600160881b0260ff60881b19909216919091179055565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610c755780601f10610c4a57610100808354040283529160200191610c75565b820191906000526020600020905b815481529060010190602001808311610c5857829003601f168201915b505050505090505b90565b6000610c94610c8d612303565b8484612307565b5060015b92915050565b600060026007541415610cc35760405162461bcd60e51b8152600401610bc090614fe0565b6002600755610cd260016123bb565b50506000805b83811015610e7657610ce861428b565b60176000878785818110610cf857fe5b9050602002016020810190610d0d91906143e6565b6001600160a01b031681526020808201929092526040908101600020815160a08101835290546001600160a81b03811680835260ff600160a81b8304169483019490945261ffff600160b01b8204169282019290925263ffffffff600160c01b830481166060830152600160e01b9092049091166080820152915015610e6d576000806000610dbd898987818110610da157fe5b9050602002016020810190610db691906143e6565b60006125b7565b9250925092508215610e6957600b5484516040808701516020880151915163068437bd60e21b815260019a50610e66946001600160a01b031693631a10def493610e0f938993899392906004016151f1565b60206040518083038186803b158015610e2757600080fd5b505afa158015610e3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5f9190614735565b88906122d7565b96505b5050505b50600101610cd8565b5080610e945760405162461bcd60e51b8152600401610bc090615066565b601354610ea19083612783565b601355610ead826127c5565b50600160075592915050565b60035490565b610ec7612303565b6000546001600160a01b03908116911614610ef45760405162461bcd60e51b8152600401610bc090614c01565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b610f1e612303565b6000546001600160a01b03908116911614610f4b5760405162461bcd60e51b8152600401610bc090614c01565b601480546001600160a01b0319166001600160a01b0392909216919091179055565b6009546001600160a01b031690565b6000610f898484846127f2565b610ff984610f95612303565b610ff485604051806060016040528060288152602001615388602891396001600160a01b038a16600090815260026020526040812090610fd3612303565b6001600160a01b031681526020810191909152604001600020549190612907565b612307565b5060019392505050565b60115481565b60065460ff1690565b600f5481565b611020612303565b6000546001600160a01b0390811691161461104d5760405162461bcd60e51b8152600401610bc090614c01565b600d546001600160a01b03161580159061107157506009546001600160a01b031615155b1561110157600954600d5460405163095ea7b360e01b81526001600160a01b039283169263095ea7b3926110ad929116906000906004016147e6565b602060405180830381600087803b1580156110c757600080fd5b505af11580156110db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ff919061455d565b505b600d80546001600160a01b0319166001600160a01b0383169081179091551580159061113757506009546001600160a01b031615155b156111c45760095460405163095ea7b360e01b81526001600160a01b039091169063095ea7b390611170908490600019906004016147e6565b602060405180830381600087803b15801561118a57600080fd5b505af115801561119e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c2919061455d565b505b50565b6000610c946111d4612303565b84610ff485600260006111e5612303565b6001600160a01b03908116825260208083019390935260409182016000908120918c1681529252902054906122d7565b61121d612303565b6000546001600160a01b0390811691161461124a5760405162461bcd60e51b8152600401610bc090614c01565b62093a8081111561126d5760405162461bcd60e51b8152600401610bc090615017565b601055565b600080600260075414156112985760405162461bcd60e51b8152600401610bc090614fe0565b60026007556112a984600085612933565b6001600755909590945092505050565b600080600260075414156112df5760405162461bcd60e51b8152600401610bc090614fe0565b6002600755826113015760405162461bcd60e51b8152600401610bc09061509d565b61130e6000600185612933565b60016007559094909350915050565b611325612303565b6000546001600160a01b039081169116146113525760405162461bcd60e51b8152600401610bc090614c01565b6008805469ffffffffffffffffffff19166001600160501b0392909216919091179055565b60006002600754141561139c5760405162461bcd60e51b8152600401610bc090614fe0565b60026007556113ab3483612ba8565b600160075592915050565b60125481565b61271081565b6017602052600090815260409020546001600160a81b0381169060ff600160a81b8204169061ffff600160b01b8204169063ffffffff600160c01b8204811691600160e01b90041685565b6402540be40081565b60006114206142b9565b60085461143990600160501b900463ffffffff16612dd3565b9050806101200151156114d757600c54604080830151606084015191516312e001c360e21b81526001600160a01b0390931692634b80070c9261147f9291600401615258565b60206040518083038186803b15801561149757600080fd5b505afa1580156114ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114cf919061462e565b915050610c7d565b600c60009054906101000a90046001600160a01b03166001600160a01b031663f359b46f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561149757600080fd5b600854600160501b900463ffffffff1681565b60166020526000908152604090205481565b60006002600754141561156f5760405162461bcd60e51b8152600401610bc090614fe0565b60026007556001600160a81b03831661159a5760405162461bcd60e51b8152600401610bc090614f52565b60008261ffff161180156115b45750614e208261ffff1611155b6115d05760405162461bcd60e51b8152600401610bc090614b38565b33600090815260176020526040902080546001600160a81b038086169116101561160c5760405162461bcd60e51b8152600401610bc090614bcc565b601054815461162d90429063ffffffff600160c01b90910481169061278316565b101561164b5760405162461bcd60e51b8152600401610bc090614ded565b60008061165860016123bb565b915091508461ffff168261ffff1610156116845760405162461bcd60e51b8152600401610bc090614e91565b60008060008061169f878b6001600160a81b031687896131e2565b935093509350935080156116bd5760009750505050505050506113ab565b6000806116ca8c8661327c565b601182905560128190558a5491935091506116ee906001600160a81b03168d6132c9565b89546001600160a81b0319166001600160a81b039190911617808a55600c54604051636f6bb7a760e01b81526000926117b692612710926117b0926001600160a01b0390921691636f6bb7a79161175591600160c01b900463ffffffff16906004016152af565b60206040518083038186803b15801561176d57600080fd5b505afa158015611781573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117a5919061462e565b8a9061ffff1661330b565b90613345565b9050337f3989dab79971090c83b28eb2d423aa507b7d4c16f5cf10a4fdb05835cafba36a6117e489896122d7565b6117ee848a6122d7565b8d60000160009054906101000a90046001600160a81b03168e60000160159054906101000a900460ff168e60405161182a959493929190615266565b60405180910390a289546001600160a81b031661185257336000908152601760205260408120555b6118718561186b8960135461278390919063ffffffff16565b90612783565b60135561187e8782612783565b9a5061188981613387565b6118928b6127c5565b50505050505050505050600160075592915050565b6118af612303565b6000546001600160a01b039081169116146118dc5760405162461bcd60e51b8152600401610bc090614c01565b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166000908152600160205260409020545b919050565b611925612303565b6000546001600160a01b039081169116146119525760405162461bcd60e51b8152600401610bc090614c01565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b336000908152601860205260409020805460ff1916911515919091179055565b6008546001600160501b031681565b60156020526000908152604090205481565b6119e5612303565b6000546001600160a01b03908116911614611a125760405162461bcd60e51b8152600401610bc090614c01565b62127500811115611a355760405162461bcd60e51b8152600401610bc090615017565b600f55565b600060026007541415611a5f5760405162461bcd60e51b8152600401610bc090614fe0565b6002600755346001600160a81b03811614611a8c5760405162461bcd60e51b8152600401610bc090614975565b611a98348585856133bd565b60016007556001600160a81b0316949350505050565b600854600160881b900460ff1681565b60135481565b6000546001600160a01b031690565b7f00000000000000000000000000000000000000000000000000000000000003e881565b600060405162461bcd60e51b8152600401610bc090614fb3565b60058054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610c755780601f10610c4a57610100808354040283529160200191610c75565b6000610c94611b7f612303565b84610ff4856040518060600160405280602581526020016153b06025913960026000611ba9612303565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190612907565b6001600160a01b03811660009081526017602052604081205481906001600160a81b03811690600160a81b900460ff16828083611c295760405162461bcd60e51b8152600401610bc090614ab3565b611c34876001613b0c565b929a91995095975093955092915050565b600854601154600091611c7191611c6991600160501b900463ffffffff169061226e565b610b7d611cf1565b905090565b6000610c94611c83612303565b84846127f2565b611c92612303565b6000546001600160a01b03908116911614611cbf5760405162461bcd60e51b8152600401610bc090614c01565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b600854600160781b900460ff1681565b600080600a60009054906101000a90046001600160a01b03166001600160a01b031663c1639a2b6040518163ffffffff1660e01b815260040160606040518083038186803b158015611d4257600080fd5b505afa158015611d56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7a91906146db565b50509050611d8781613cb8565b91505090565b614e2081565b60186020526000908152604090205460ff1681565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b600060405162461bcd60e51b8152600401610bc090614b63565b611df5612303565b6000546001600160a01b03908116911614611e225760405162461bcd60e51b8152600401610bc090614c01565b60088054911515600160801b0260ff60801b19909216919091179055565b60105481565b611e4e612303565b6000546001600160a01b03908116911614611e7b5760405162461bcd60e51b8152600401610bc090614c01565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b611ea5612303565b6000546001600160a01b03908116911614611ed25760405162461bcd60e51b8152600401610bc090614c01565b6001600160a01b038116611ef85760405162461bcd60e51b8152600401610bc09061499b565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6060808267ffffffffffffffff81118015611f6d57600080fd5b50604051908082528060200260200182016040528015611f97578160200160208202803683370190505b5090506000805b8481101561217f57600080611fd4888885818110611fb857fe5b9050602002016020810190611fcd91906143e6565b6001613b0c565b505091509150611fe261428b565b601760008a8a87818110611ff257fe5b905060200201602081019061200791906143e6565b6001600160a01b031681526020808201929092526040908101600020815160a08101835290546001600160a81b03811680835260ff600160a81b8304169483019490945261ffff600160b01b8204169282019290925263ffffffff600160c01b830481166060830152600160e01b909204909116608082015291501580159061211c5750600b548151604080840151602085015191516304fb2f7560e51b81526001600160a01b0390941693639f65eea0936120cc93899389939091906004016151f1565b60206040518083038186803b1580156120e457600080fd5b505afa1580156120f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061211c919061455d565b156121745788888581811061212d57fe5b905060200201602081019061214291906143e6565b86868151811061214e57fe5b6001600160a01b03909216602092830291909101909101526121718560016122d7565b94505b505050600101611f9e565b5060608167ffffffffffffffff8111801561219957600080fd5b506040519080825280602002602001820160405280156121c3578160200160208202803683370190505b50905060005b82811015612211578381815181106121dd57fe5b60200260200101518282815181106121f157fe5b6001600160a01b03909216602092830291909101909101526001016121c9565b5095945050505050565b612223612303565b6000546001600160a01b039081169116146122505760405162461bcd60e51b8152600401610bc090614c01565b60088054911515600160781b0260ff60781b19909216919091179055565b60006122786142b9565b60085461229190600160501b900463ffffffff16612dd3565b6000858152601560205260409020548151919250610b8391855b60006402540be4006122c7836122c18688612783565b9061330b565b816122ce57fe5b04949350505050565b6000828201838110156122fc5760405162461bcd60e51b8152600401610bc090614a7c565b9392505050565b3390565b6001600160a01b03831661232d5760405162461bcd60e51b8152600401610bc090614e16565b6001600160a01b0382166123535760405162461bcd60e51b8152600401610bc0906149e1565b6001600160a01b0380841660008181526002602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906123ae9085906151c9565b60405180910390a3505050565b6008546000908190600160501b900463ffffffff166123d86142b9565b6123e182612dd3565b90508060c00151156124365780514260009081526015602090815260409091209190915560115490820151612432916402540be400916124209161330b565b8161242757fe5b6012549190046122d7565b6012555b8060e00151156124685760808101516008805469ffffffffffffffffffff19166001600160501b039092169190911790555b8061012001511561250057600c5460408083015160608401519151630d14ef1560e41b81526001600160a01b039093169263d14ef150926124ac9291600401615258565b602060405180830381600087803b1580156124c657600080fd5b505af11580156124da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124fe919061462e565b505b8061010001511561257b576008805463ffffffff60501b1916600160501b4263ffffffff16021790819055600160701b900460ff16801561254a5750600854600160801b900460ff165b1561255f576000828152601560205260408120555b6008805460ff60701b1916600160701b871515021790556125a5565b600854600160701b900460ff16156125a5576008805460ff60701b1916600160701b871515021790555b60a08101519051909350915050915091565b60008060008060008060006125cc8989613b0c565b93509350935093508294508395506125e261428b565b506001600160a01b03808a16600090815260176020908152604091829020825160a08101845290546001600160a81b03811680835260ff600160a81b83041693830184905261ffff600160b01b83041683860181905263ffffffff600160c01b840481166060860152600160e01b9093049092166080840152600b5494516304fb2f7560e51b815292959490941693639f65eea09361268a938b938b939290916004016151f1565b60206040518083038186803b1580156126a257600080fd5b505afa1580156126b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126da919061455d565b15612777576000806126f083600001518661327c565b60118290556012819055601354919350915061270c9085612783565b60135582516040516001600160a01b038e16917f302eaf71224bcd9ed28854139aa87a32dc89622b38a4d8ce4160475aa57a7f139161274f918b918b91906151d2565b60405180910390a250506001600160a01b038a16600090815260176020526040812055600197505b50505050509250925092565b60006122fc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612907565b604051339082156108fc029083906000818181858888f193505050501580156111c2573d6000803e3d6000fd5b6001600160a01b0383166128185760405162461bcd60e51b8152600401610bc090614d47565b6001600160a01b03821661283e5760405162461bcd60e51b8152600401610bc0906148fd565b612849838383613cf8565b61288681604051806060016040528060268152602001615362602691396001600160a01b0386166000908152600160205260409020549190612907565b6001600160a01b0380851660009081526001602052604080822093909355908416815220546128b590826122d7565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906123ae9085906151c9565b6000818484111561292b5760405162461bcd60e51b8152600401610bc091906148aa565b505050900390565b600f543360009081526016602052604081205490918291429161295691906122d7565b11156129745760405162461bcd60e51b8152600401610bc090614f89565b600061298060016123bb565b50905084156129b1578392506129aa612997610eb9565b6117b06129a384613cb8565b869061330b565b9550612a1b565b600086116129d15760405162461bcd60e51b8152600401610bc090614ccf565b6129f96001610b7d6129e284613cb8565b6117b0600161186b6129f2610eb9565b8d9061330b565b925083831115612a1b5760405162461bcd60e51b8152600401610bc090614c6d565b612a24336118fe565b831115612a435760405162461bcd60e51b8152600401610bc090614940565b600854600160781b900460ff1680612a68575085612a6560115461186b613de8565b10155b612a845760405162461bcd60e51b8152600401610bc090614e5a565b601354612a919087612783565b601355600c546040805163495ef70560e01b8152905160009261271092612b27926001600160a01b039092169163495ef70591600480820192602092909190829003018186803b158015612ae457600080fd5b505afa158015612af8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b1c919061462e565b899061ffff1661330b565b81612b2e57fe5b049050612b3b8782612783565b9250336001600160a01b03167f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca94888684604051612b7a93929190615299565b60405180910390a2612b8c3385613df4565b612b9581613387565b612b9e836127c5565b5050935093915050565b6000808311612bc95760405162461bcd60e51b8152600401610bc090614ccf565b336000908152601660205260408120429055612be560016123bb565b50905060006127106001600160a81b0316612c8a600c60009054906101000a90046001600160a01b03166001600160a01b031663cc1252ae6040518163ffffffff1660e01b815260040160206040518083038186803b158015612c4757600080fd5b505afa158015612c5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7f919061462e565b879061ffff1661330b565b81612c9157fe5b0490506000612ca08683612783565b90506000612cac610eb9565b90506000612cb985613cb8565b9050600082118015612ccb5750600081115b15612cea5780612cdb848461330b565b81612ce257fe5b049550612d17565b612d14837f00000000000000000000000000000000000000000000000000000000000003e861330b565b95505b336001600160a01b03167f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e898887604051612d5493929190615299565b60405180910390a286861015612d7c5760405162461bcd60e51b8152600401610bc090614a51565b60008611612d9c5760405162461bcd60e51b8152600401610bc090614b10565b601354612da990846122d7565b601355612db63387613ed6565b612dbf886111c4565b612dc884613387565b505050505092915050565b612ddb6142b9565b6000806000600a60009054906101000a90046001600160a01b03166001600160a01b031663c1639a2b6040518163ffffffff1660e01b815260040160606040518083038186803b158015612e2e57600080fd5b505afa158015612e42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e6691906146db565b61ffff831660a088015242600090815260156020526040902054808852929550909350915015612e9f5750506000602083015250611918565b600854600160501b900463ffffffff16612eef57506402540be4008352600160c084018190526001600160501b03909116608084015260e083018190526101008301525060006020820152611918565b6008546001600160501b03908116908316811115612f1f5760405162461bcd60e51b8152600401610bc090615040565b6001600160501b038184031660608601819052600090612f40576001612f43565b60025b60ff16905060608167ffffffffffffffff81118015612f6157600080fd5b50604051908082528060200260200182016040528015612f9b57816020015b612f8861430d565b815260200190600190039081612f805790505b506060880151909150156130eb57600a54604051635a7b84b160e01b815260009182916001600160a01b0390911690635a7b84b190612fde9088906004016152c0565b604080518083038186803b158015612ff557600080fd5b505afa158015613009573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061302d91906146ae565b91509150604051806040016040528061304f8c8961278390919063ffffffff16565b81526020018361ffff168152508360008151811061306957fe5b60200260200101819052506040518060400160405280613092884261278390919063ffffffff16565b81526020018961ffff16815250836001815181106130ac57fe5b60209081029190910101526001600160501b03871660808a0152600160e08a01526130d78682612783565b60408a015250506001610120880152613126565b6040805180820190915280613100428b612783565b81526020018761ffff168152508160008151811061311a57fe5b60200260200101819052505b600c54604051635d769d1760e11b81526001600160a01b039091169063baed3a2e9061315690849060040161484c565b60206040518083038186803b15801561316e57600080fd5b505afa158015613182573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131a69190614735565b602080890182905260008a8152601590915260409020546131c6916122d7565b87525050600160c0860181905261010086015250505050919050565b8354600160c01b900463ffffffff166000908152601560205260408120548190819081906132119087896122ab565b885490935060009081908190613241908b90600160a81b810460ff16908b90600160b01b900461ffff168a613f8a565b92509250925081613267576132573360006125b7565b505050600193506000955061326e565b8296508094505b505050945094509450949050565b60008061329d846001600160a81b031660115461278390919063ffffffff16565b9150601254905081600014156132b5575060006132c2565b6132bf8184612783565b90505b9250929050565b60006122fc83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061403b565b60008261331a57506000610c98565b8282028284828161332757fe5b04146122fc5760405162461bcd60e51b8152600401610bc090614b8b565b60006122fc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614072565b6000811180156133a15750600d546001600160a01b031615155b156111c4576009546111c49082906001600160a01b03166140a9565b6000808260ff16116133e15760405162461bcd60e51b8152600401610bc090614eb6565b60085460ff600160881b909104811690831611156134115760405162461bcd60e51b8152600401610bc090614db6565b6000856001600160a81b03161161343a5760405162461bcd60e51b8152600401610bc090614ccf565b60008461ffff161180156134545750614e208461ffff1611155b6134705760405162461bcd60e51b8152600401610bc090614ca4565b613478614324565b61348260006123bb565b608083015261ffff908116610160830181905290861610156134b65760405162461bcd60e51b8152600401610bc090614aea565b600c54604080516307e3dd0f60e41b8152815160009384936001600160a01b0390911692637e3dd0f09260048083019392829003018186803b1580156134fb57600080fd5b505afa15801561350f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135339190614691565b909250905061271061355961ffff84166122c16001600160a81b038c1660ff8a1661330b565b8161356057fe5b0460a0840181905261016084015161ffff169061359690614e20906122c19060ff8a169082906001600160a81b038f1690612783565b8161359d57fe5b046101408401526127106135cd6135b88261ffff85166132c9565b610140860151906001600160a81b031661330b565b816135d457fe5b0460c08401526135ec6001600160a81b0389166140e3565b80845260006020850152156136435760a0830151835161363d9161361b91906001600160a81b038c16036122d7565b6117b06402540be4006122c18760c001516011546122d790919063ffffffff16565b60208401525b600c546020840151604051630d82490360e41b81526001600160a01b039092169163d82490309161367a918c918a9160040161515d565b604080518083038186803b15801561369157600080fd5b505afa1580156136a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136c991906145a6565b61ffff1661010085018190526001600160a81b0391821660e086015290871610156137065760405162461bcd60e51b8152600401610bc090614a23565b876001600160a81b03168360a00151106137325760405162461bcd60e51b8152600401610bc090614d8c565b61376e8560ff1661375f8560e001518660a001518c036001600160a81b03166132c990919063ffffffff16565b6001600160a81b0316906140ef565b6001600160a81b03908116610120850152336000908152601760205260409020805490911615613837576137bc8185608001518661016001518761012001516001600160a81b03168a61414a565b86604001876060018281525082815250829750505050600061380d6138048860ff166122c188606001518960a001518f6001600160a81b0316036122d790919063ffffffff16565b601354906122d7565b905061382e856060015161186b87604001518461278390919063ffffffff16565b601355506139be565b600084610160015161ffff16613866614e208761012001516001600160a81b031661330b90919063ffffffff16565b8161386d57fe5b04905080955080866001600160a81b03161461389b5760405162461bcd60e51b8152600401610bc090614f1b565b6138a361428b565b506040805160a0810182526001600160a81b0380891680835260ff808c1660208086019182526101608c015161ffff90811687890190815263ffffffff42811660608a0181815260808b0191825233600090815260179096529a90942089518154965193519b5195518316600160e01b026001600160e01b03968416600160c01b0263ffffffff60c01b199d909616600160b01b0261ffff60b01b1995909916600160a81b0260ff60a81b1992909b166001600160a81b031990981697909717169890981791909116949094179790971696909617959095169490941790915560115491926139949291906122d716565b60115560a08601516013546139b8916001600160a81b038e160360ff8b16026122d7565b60135550505b336001600160a01b03167fe485c81af56f49547b2ea1b6886083d8e3a7ef50fe670c9574bd5d4b2dd7d4628a88613a0f8860e001516001600160a81b03168960a001516122d790919063ffffffff16565b610160890151604051613a26949392918c91615181565b60405180910390a2613a40896001600160a81b03166111c4565b8351613a55906001600160a81b038b166122d7565b845260a0840151613a6590613387565b83516011541115613a885760405162461bcd60e51b8152600401610bc090614eed565b600e546001600160a01b031615613b0057600e54604051630bf1944760e21b81526001600160a01b0390911690632fc6511c90613acd90339089908b906004016147b9565b600060405180830381600087803b158015613ae757600080fd5b505af1158015613afb573d6000803e3d6000fd5b505050505b50505050949350505050565b600080600080613b1a61428b565b506001600160a01b038087166000908152601760209081526040808320815160a08101835290546001600160a81b038116825260ff600160a81b8204169382019390935261ffff600160b01b8404168183015263ffffffff600160c01b84048116606080840191909152600160e01b909404166080820152600a54825163c1639a2b60e01b815292519195169263c1639a2b9260048082019391829003018186803b158015613bc857600080fd5b505afa158015613bdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613c0091906146db565b5050606083015163ffffffff90811660009081526015602052604080822054600854600160501b900490931682529020548451929350613c48926001600160a81b03166122ab565b93508615613c84576008548251613c8191613c7a91600160501b90910463ffffffff16906001600160a81b031661226e565b85906122d7565b93505b613ca682600001516001600160a81b0316836020015183856040015188613f8a565b919a9099509497509550929350505050565b6000610c98614e20613cd98461ffff1660115461330b90919063ffffffff16565b81613ce057fe5b0461186b6012546013546122d790919063ffffffff16565b600f546001600160a01b0384166000908152601660205260409020544291613d2091906122d7565b118015613d4d57506001600160a01b03808316600090815260166020526040808220549286168252902054115b8015613d6757506014546001600160a01b03848116911614155b8015613d8157506014546001600160a01b03838116911614155b15613de3576001600160a01b03821660009081526018602052604090205460ff1615613dbf5760405162461bcd60e51b8152600401610bc090614c36565b6001600160a01b038084166000908152601660205260408082205492851682529020555b505050565b6000611c7160006140e3565b6001600160a01b038216613e1a5760405162461bcd60e51b8152600401610bc090614d06565b613e2682600083613cf8565b613e6381604051806060016040528060228152602001615340602291396001600160a01b0385166000908152600160205260409020549190612907565b6001600160a01b038316600090815260016020526040902055600354613e899082612783565b6003556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90613eca9085906151c9565b60405180910390a35050565b6001600160a01b038216613efc5760405162461bcd60e51b8152600401610bc0906150d4565b613f0860008383613cf8565b600354613f1590826122d7565b6003556001600160a01b038216600090815260016020526040902054613f3b90826122d7565b6001600160a01b0383166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90613eca9085906151c9565b6000808080614e20613fa08a61ffff8a1661330b565b81613fa757fe5b04905060018860ff1611613fbc576000613ff5565b8760ff16614e20613fe460018b0360ff166122c18a61ffff168e61330b90919063ffffffff16565b81613feb57fe5b0481613ff357fe5b045b9150600061400383876122d7565b9050808210614021576140168282612783565b94506001935061402e565b61402b8183612783565b94505b5050955095509592505050565b6000836001600160a81b0316836001600160a81b03161115829061292b5760405162461bcd60e51b8152600401610bc091906148aa565b600081836140935760405162461bcd60e51b8152600401610bc091906148aa565b50600083858161409f57fe5b0495945050505050565b600d546040516001600160a01b039091169083156108fc029084906000818181858888f19350505050158015613de3573d6000803e3d6000fd5b6000610c984783612783565b60006001600160a81b03831661410757506000610c98565b8282026001600160a81b03808416908086169083168161412357fe5b046001600160a81b0316146122fc5760405162461bcd60e51b8152600401610bc090614b8b565b60008060006141576143a4565b88546001600160a81b031680825260009081908190819061417b908e908e8e6131e2565b9350935093509350801561419457600080865293508391505b6141bc8b61ffff166117b0614e206122c18e610b7d8f60ff168b61330b90919063ffffffff16565b6020860181905297506001600160a81b03881688146141ed5760405162461bcd60e51b8152600401610bc090614f1b565b8c5463ffffffff60c01b1916600160c01b4263ffffffff1602176001600160a81b0319166001600160a81b0389161761ffff60b01b1916600160b01b61ffff8d16021760ff60a81b1916600160a81b60ff8b1602178d558451614250908461327c565b6060870181905260408701829052601255614274906001600160a81b038a166122d7565b60115550959b959a50909850939650505050505050565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915290565b604080518082019091526000808252602082015290565b6040518061018001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a81b0316815260200160006001600160a81b0316815260200160006001600160a81b0316815260200160008152602001600061ffff1681525090565b604051806080016040528060006001600160a81b031681526020016000815260200160008152602001600081525090565b803560ff81168114610c9857600080fd5b6000602082840312156143f7578081fd5b81356122fc816152e2565b60008060408385031215614414578081fd5b823561441f816152e2565b9150602083013561442f816152e2565b809150509250929050565b60008060006060848603121561444e578081fd5b8335614459816152e2565b92506020840135614469816152e2565b929592945050506040919091013590565b6000806040838503121561448c578182fd5b8235614497816152e2565b9150602083013561442f81615315565b600080604083850312156144b9578182fd5b82356144c4816152e2565b946020939093013593505050565b600080602083850312156144e4578182fd5b823567ffffffffffffffff808211156144fb578384fd5b818501915085601f83011261450e578384fd5b81358181111561451c578485fd5b866020808302850101111561452f578485fd5b60209290920196919550909350505050565b600060208284031215614552578081fd5b81356122fc816152f7565b60006020828403121561456e578081fd5b81516122fc816152f7565b6000806040838503121561458b578182fd5b823561459681615315565b9150602083013561442f81615305565b600080604083850312156145b8578182fd5b82516145c381615315565b602084015190925061442f81615305565b600080600080608085870312156145e9578182fd5b84356145f481615315565b9350602085013561460481615305565b9250604085013561461481615315565b915061462386606087016143d5565b905092959194509250565b60006020828403121561463f578081fd5b81516122fc81615305565b60008060006060848603121561465e578081fd5b833561466981615305565b9250602084013561467981615315565b915061468885604086016143d5565b90509250925092565b600080604083850312156146a3578182fd5b82516145c381615305565b600080604083850312156146c0578182fd5b82516146cb81615305565b6020939093015192949293505050565b6000806000606084860312156146ef578081fd5b83516146fa81615305565b602085015190935061470b8161532a565b80925050604084015190509250925092565b60006020828403121561472e578081fd5b5035919050565b600060208284031215614746578081fd5b5051919050565b6000806040838503121561475f578182fd5b50508035926020909101359150565b60006020828403121561477f578081fd5b6122fc83836143d5565b60006020828403121561479a578081fd5b81356122fc8161532a565b6001600160a01b0391909116815260200190565b6001600160a01b039390931683526001600160a81b0391909116602083015260ff16604082015260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156148405783516001600160a01b03168352928401929184019160010161481b565b50909695505050505050565b602080825282518282018190526000919060409081850190868401855b828110156148925781518051855286015161ffff16868501529284019290850190600101614869565b5091979650505050505050565b901515815260200190565b6000602080835283518082850152825b818110156148d6578581018301518582016040015282016148ba565b818111156148e75783604083870101525b50601f01601f1916929092016040019392505050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252818101527f4e6f7420656e6f756768204c5020746f6b656e7320666f72206163636f756e74604082015260600190565b6020808252600c908201526b0a8dede40daeac6d0408aa8960a31b604082015260600190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601490820152730a0e4cadad2eada40cccaca40e8dede40d0d2ced60631b604082015260600190565b602080825260119082015270546f6f20666577204c5020746f6b656e7360781b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601d908201527f4e6f20706f736974696f6e20666f7220676976656e2061646472657373000000604082015260600190565b6020808252600c908201526b086ac9240e8dede40d0d2ced60a31b604082015260600190565b6020808252600e908201526d546f6f2066657720746f6b656e7360901b604082015260600190565b602080825260119082015270426164206d696e204356492076616c756560781b604082015260600190565b6020808252600e908201526d0aae6ca40c8cae0dee6d2e88aa8960931b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4e6f7420656e6f756768206f70656e656420706f736974696f6e20756e697473604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f526563697069656e742072656675736573206c6f636b656420746f6b656e7300604082015260600190565b6020808252601a908201527f546f6f206d756368204c5020746f6b656e7320746f206275726e000000000000604082015260600190565b602080825260119082015270426164206d6178204356492076616c756560781b604082015260600190565b6020808252601e908201527f546f6b656e7320616d6f756e74206d75737420626520706f7369746976650000604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526010908201526f4f70656e2066656520746f6f2062696760801b604082015260600190565b6020808252601d908201527f4c65766572616765206578636365656473206d617820616c6c6f776564000000604082015260600190565b6020808252600f908201526e141bdcda5d1a5bdb881b1bd8dad959608a1b604082015260600190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526017908201527f436f6c6c61746572616c20726174696f2062726f6b656e000000000000000000604082015260600190565b6020808252600b908201526a43564920746f6f206c6f7760a81b604082015260600190565b60208082526019908201527f4c65766572616765206d75737420626520706f73697469766500000000000000604082015260600190565b6020808252601490820152734e6f7420656e6f756768206c697175696469747960601b604082015260600190565b60208082526017908201527f546f6f206d75636820706f736974696f6e20756e697473000000000000000000604082015260600190565b6020808252601b908201527f506f736974696f6e20756e697473206e6f7420706f7369746976650000000000604082015260600190565b60208082526010908201526f119d5b991cc8185c99481b1bd8dad95960821b604082015260600190565b6020808252601390820152720aae6ca40dee0cadca0dee6d2e8d2dedc8aa89606b1b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252600f908201526e4c6f636b757020746f6f206c6f6e6760881b604082015260600190565b6020808252600c908201526b109859081c9bdd5b99081a5960a21b604082015260600190565b60208082526018908201527f4e6f206c6971756964617461626c6520706f736974696f6e0000000000000000604082015260600190565b60208082526017908201527f416d6f756e74206d75737420626520706f736974697665000000000000000000604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b6001600160a81b0391909116815260200190565b6001600160a81b0395909516855260ff93909316602085015261ffff91909116604084015263ffffffff908116606084015216608082015260a00190565b6001600160a81b0393909316835260ff919091166020830152604082015260600190565b6001600160a81b03958616815260ff9490941660208501526040840192909252909216606082015261ffff909116608082015260a00190565b61ffff91909116815260200190565b90815260200190565b92835290151560208301526001600160a81b0316604082015260600190565b94855292151560208501526001600160a81b0391909116604084015261ffff16606083015260ff16608082015260a00190565b95865293151560208601526001600160a81b0392909216604085015260ff166060840152608083015260a082015260c00190565b918252602082015260400190565b94855260208501939093526001600160a81b0391909116604084015260ff16606083015261ffff16608082015260a00190565b9283526020830191909152604082015260600190565b63ffffffff91909116815260200190565b6001600160501b0391909116815260200190565b60ff91909116815260200190565b6001600160a01b03811681146111c457600080fd5b80151581146111c457600080fd5b61ffff811681146111c457600080fd5b6001600160a81b03811681146111c457600080fd5b6001600160501b03811681146111c457600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212207dbb4d2f078e38d126687127c39ee742673819017ce3a196fe92c3af2fb0229264736f6c634300060c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000000000000000000000000000006fc8cc3e6d3da8b29c4480e77e24dea298293ace0000000000000000000000008d55c22ea6610e3fa4659d3d5f4d751ca1e6257300000000000000000000000000000000000000000000000000000000000000094554482d4c502d5632000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000094554482d4c502d56320000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _lpTokenName (string): ETH-LP-V2
Arg [1] : _lpTokenSymbolName (string): ETH-LP-V2
Arg [2] : _initialTokenToLPTokenRate (uint256): 1000
Arg [3] : _feesCalculator (address): 0x0000000000000000000000000000000000000000
Arg [4] : _cviOracle (address): 0x6fC8cC3E6D3da8B29c4480e77E24Dea298293ACE
Arg [5] : _liquidation (address): 0x8d55c22Ea6610E3fa4659d3D5f4d751cA1e62573
-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [2] : 00000000000000000000000000000000000000000000000000000000000003e8
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [4] : 0000000000000000000000006fc8cc3e6d3da8b29c4480e77e24dea298293ace
Arg [5] : 0000000000000000000000008d55c22ea6610e3fa4659d3d5f4d751ca1e62573
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000009
Arg [7] : 4554482d4c502d56320000000000000000000000000000000000000000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000009
Arg [9] : 4554482d4c502d56320000000000000000000000000000000000000000000000
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.