Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
AVTLiquidityMiner
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 2000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import './libraries/FullMath.sol'; import './libraries/RewardMath.sol'; import './libraries/TickMath.sol'; import './libraries/LiquidityAmounts.sol'; import './interfaces/IAVTLiquidityMiner.sol'; import './interfaces/IERC20.sol'; import './interfaces/uniswap/IPositionManager.sol'; import './interfaces/uniswap/IUniswapV3Pool.sol'; import './interfaces/uniswap/IUniswapV3Staker.sol'; import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; import '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; import '@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol'; contract AVTLiquidityMiner is IAVTLiquidityMiner, IERC721Receiver, Initializable, UUPSUpgradeable, OwnableUpgradeable, ReentrancyGuardUpgradeable { mapping(uint8 => RewardRound) public rewardRounds; uint256 public roundDuration; uint256 public aventusTokenId; uint8 public activeRewardRound; IERC20 private constant avt = IERC20(0x0d88eD6E74bbFD96B831231638b66C05571e824F); address private constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; IPositionManager private constant positionManager = IPositionManager(0xC36442b4a4522E871399CD717aBDD847Ab11FE88); IPoolV3 private constant v3Pool = IPoolV3(0xCDff6ddfC9e4807C9927Fd58708C2Ef3484CC305); IUniswapV3Staker private constant v3Staker = IUniswapV3Staker(0xe34139463bA50bD61336E0c446Bd8C0867c6fE65); uint256 private constant PERMIT_LIFETIME = 30 minutes; uint256 private constant CLAIM_WINDOW = 90 days; uint24 private constant FEE_TIER = 3000; mapping(uint8 => uint256) private _aventusRewards; mapping(uint256 => StakedToken) private _stakedTokens; mapping(address => uint256[]) private _managedTokens; address private aventusPositionOwner; Permit private _emptyPermit; Domain private _domain; error AddressZero(); // 0x9fabe1c1 error ClaimWindowOpen(); // 0x29dfa3ce error EarlyExitOnly(); // 0x74201bfa error NewRoundNotOpen(); // 0x3a01a74b error NotEnoughETH(uint256 provided, uint256 required); // 0xbd8d1c98 error OutOfRange(); // 0x7db3aba7 error PositionInactive(); // 0x0be4c53e error PositionIsStaked(); // 0xd3afc592 error PositionNotStaked(); // // 0x82141ff0 error PositionOwnerOnly(); // 0x7c0e1da6 error RoundStillActive(); // 0xa02b8484 error TransferFailed(); // 0x90b8ec18 /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function initialize() external initializer { __Ownable_init(msg.sender); __UUPSUpgradeable_init(); __ReentrancyGuard_init(); roundDuration = 30 days; avt.approve(address(positionManager), type(uint256).max); _domain = Domain({ name: positionManager.name(), version: '1', chainId: block.chainid, verifyingContract: address(positionManager) }); } receive() external payable {} function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) { return this.onERC721Received.selector; } /// @dev Sets the Aventus LP token to reallocate its rewards. Replaces any existing token, provided it is not currently staked. If 0 is passed no new token is set. /// @param tokenId The Aventus liquidity position token ID function ownerSetAventusPosition(uint256 tokenId) external onlyOwner { if (aventusTokenId != 0) { uint8 activeRound = activeRewardRound; if (activeRound != 0) { if (block.timestamp <= rewardRounds[activeRound].incentive.endTime) revert RoundStillActive(); _ensureAventusReward(activeRound); } v3Staker.withdrawToken(aventusTokenId, aventusPositionOwner, ''); aventusPositionOwner = address(0); } aventusTokenId = tokenId; if (tokenId != 0) { address positionOwner = positionManager.ownerOf(tokenId); positionManager.transferFrom(positionOwner, address(this), tokenId); positionManager.safeTransferFrom(address(this), address(v3Staker), tokenId, ''); aventusPositionOwner = positionOwner; } } /// @dev Sets the duration of subsequent reward rounds /// @param secondsPerRound The seconds per reward round function ownerSetRoundDuration(uint256 secondsPerRound) external onlyOwner { roundDuration = secondsPerRound; } /// @dev Immediately starts a new reward round, provided that the previous one has ended. /// @param rewardPot Total amount of AVT allocated to reward stakers in the round. function ownerStartRound(uint256 rewardPot) external onlyOwner { uint8 round = activeRewardRound; uint256 start = block.timestamp; uint256 end; if (round != 0) { if (start <= rewardRounds[round].incentive.endTime) revert RoundStillActive(); _ensureAventusReward(round); } unchecked { activeRewardRound = ++round; end = start + roundDuration; } IUniswapV3Staker.IncentiveKey memory incentive = IUniswapV3Staker.IncentiveKey( address(avt), address(v3Pool), start, end, address(this) ); rewardRounds[round] = RewardRound(rewardPot, incentive); avt.transferFrom(msg.sender, address(this), rewardPot); avt.approve(address(v3Staker), rewardPot); v3Staker.createIncentive(incentive, rewardPot); _stake(aventusTokenId, false); emit LogStartRound(round, start, end, rewardPot); } /// @dev Ends an incentive in the Uniswap V3 staker contract, collecting any unclaimed rewards. Callable once all positions have unstaked or the claim window has expired. /// @param round The round number to complete. /// @param tokenIds An optional array of token IDs to forcibly unstake if the claim window has expired. function ownerCompleteRound(uint8 round, uint256[] calldata tokenIds) external onlyOwner { IUniswapV3Staker.IncentiveKey memory incentive = rewardRounds[round].incentive; if (_aventusRewards[round] == 0) v3Staker.unstakeToken(incentive, aventusTokenId); if (tokenIds.length != 0 && block.timestamp <= incentive.endTime + CLAIM_WINDOW) revert ClaimWindowOpen(); for (uint256 i; i < tokenIds.length; ++i) { uint256 tokenId = tokenIds[i]; v3Staker.unstakeToken(incentive, tokenId); _stakedTokens[tokenId].rewardRound = 0; } uint256 aventusReward = v3Staker.claimReward(address(avt), address(this), 0); if (_aventusRewards[round] == 0) _aventusRewards[round] = aventusReward; emit LogRoundCompleted(round, v3Staker.endIncentive(incentive)); } function ownerDrain(address recipient, uint256 avtAmount, uint256 ethAmount) external onlyOwner { if (recipient == address(0)) revert AddressZero(); if (avtAmount != 0) avt.transfer(recipient, avtAmount); if (ethAmount != 0) { (bool success, ) = recipient.call{ value: ethAmount }(''); if (!success) revert TransferFailed(); } } /// @dev Authorizes this contract to manage the liquidity position via an ERC-721 permit, then stakes it in the current round. /// @param tokenId The position's token ID /// @param deadline The permit's deadline /// @param signedPermit The permit signature function stake(uint256 tokenId, uint256 deadline, bytes calldata signedPermit) external { _managePosition(tokenId, deadline, signedPermit); emit LogStake(tokenId, _stake(tokenId, true), msg.sender); } /// @dev Claims the rewards earned from the position's last completed round before restaking the position in the current round. /// @param tokenId The position's token ID function restake(uint256 tokenId) external { _confirmPositionOwner(tokenId); (uint256 reward, uint8 settledRound) = _settleStake(tokenId, false); if (reward != 0) avt.transfer(msg.sender, reward); emit LogRestake(tokenId, settledRound, _stake(tokenId, false), reward); } /// @dev Uses the ETH sent to the function and the rewards from the last completed round to increase the position's liquidity before restaking it. The amount of ETH to send can be determined by making a static call to the "restake" method first. /// @param tokenId The position's token ID function compound(uint256 tokenId) external payable nonReentrant { _confirmPositionOwner(tokenId); (uint256 reward, uint8 settledRound) = _settleStake(tokenId, false); uint8 stakingRound; if (reward != 0) { _increaseLiquidity(tokenId, reward, msg.value); stakingRound = _stake(tokenId, true); } else { stakingRound = _stake(tokenId, false); } emit LogCompound(tokenId, settledRound, stakingRound, reward); } /// @dev Claims any outstanding and releases the position back to its original positionOwner. /// @param tokenId The position's token ID /// @param earlyExit Setting to true exits a position staked in the current round at the cost of forfeiting the rewards function exit(uint256 tokenId, bool earlyExit) external { _confirmPositionOwner(tokenId); (uint256 reward, uint8 settledRound) = _settleStake(tokenId, earlyExit); if (reward != 0) avt.transfer(msg.sender, reward); _releasePosition(msg.sender, tokenId); emit LogExit(tokenId, settledRound, reward); } /// @dev Increases the liquidity of a staked position. /// @param tokenId The position's token ID /// @param avtAmount The amount of AVT to increase the position by, which must be suitably balanced by the provided ETH amount. function increaseLiquidity(uint256 tokenId, uint256 avtAmount) external payable nonReentrant { _confirmPositionOwner(tokenId); avt.transferFrom(msg.sender, address(this), avtAmount); IUniswapV3Staker.IncentiveKey memory incentive = rewardRounds[_stakedTokens[tokenId].rewardRound].incentive; if (block.timestamp < incentive.endTime) { v3Staker.unstakeToken(incentive, tokenId); _increaseLiquidity(tokenId, avtAmount, msg.value); positionManager.safeTransferFrom(address(this), address(v3Staker), tokenId, abi.encode(incentive)); } else { revert PositionInactive(); } } /// @dev Retrieves all stakeable and staked positions held by the passed address. /// @param positionOwner Address of the owner of the positions /// @return Array of Positions function getPositions(address positionOwner) external view returns (Position[] memory) { return _getAllPositions(positionOwner); } /// @dev Returns the amount of ETH required to compound a position. /// @param tokenId The position's token ID /// @return ethAmount The amount of ETH required to compound. function ethRequiredToCompound(uint256 tokenId) external view returns (uint256 ethAmount) { uint256 estimatedReward = _estimateReward(tokenId); unchecked { ethAmount = _ethRequired(tokenId, estimatedReward); ethAmount = (ethAmount * 1025) / 1000; // Adjust by 2.5% } } /// @dev Returns the amount of ETH required to increase a position's liquidity for a given AVT amount. /// @param avtAmount The amount of AVT for which the required ETH is being calculated. /// @return ethAmount The amount of ETH required to balance the AVT amount. function ethRequiredToIncreaseLiquidity(uint256 tokenId, uint256 avtAmount) external view returns (uint256 ethAmount) { unchecked { ethAmount = _ethRequired(tokenId, avtAmount); ethAmount = (ethAmount * 101) / 100; // Adjust by 1% } } function _managePosition(uint256 tokenId, uint256 deadline, bytes calldata signedPermit) private { if (positionManager.ownerOf(tokenId) != msg.sender) { if (_stakedTokens[tokenId].positionOwner == msg.sender) revert PositionIsStaked(); revert PositionOwnerOnly(); } (uint8 v, bytes32 r, bytes32 s) = _splitSignature(signedPermit); positionManager.permit(address(this), tokenId, deadline, v, r, s); positionManager.safeTransferFrom(msg.sender, address(this), tokenId, ''); _managedTokens[msg.sender].push(tokenId); } function _stake(uint256 tokenId, bool transferRequired) private returns (uint8 activeRound) { activeRound = activeRewardRound; StakedToken storage stakedToken = _stakedTokens[tokenId]; if (stakedToken.rewardRound == activeRound) revert NewRoundNotOpen(); if (transferRequired) { positionManager.safeTransferFrom( address(this), address(v3Staker), tokenId, abi.encode(rewardRounds[activeRound].incentive) ); stakedToken.positionOwner = msg.sender; } else { v3Staker.stakeToken(rewardRounds[activeRound].incentive, tokenId); } stakedToken.rewardRound = activeRound; } function _settleStake(uint256 tokenId, bool earlyExit) private returns (uint256 reward, uint8 round) { round = _stakedTokens[tokenId].rewardRound; if (block.timestamp >= rewardRounds[round].incentive.endTime) { _ensureAventusReward(round); reward = _unstakeAndClaim(tokenId, round); unchecked { reward += _calculateTopup(reward, _aventusRewards[round], rewardRounds[round].rewardPot); } } else if (earlyExit) { v3Staker.unstakeToken(rewardRounds[round].incentive, tokenId); } else { revert EarlyExitOnly(); } } function _ensureAventusReward(uint8 round) private { if (_aventusRewards[round] != 0) return; _aventusRewards[round] = _unstakeAndClaim(aventusTokenId, round); } function _unstakeAndClaim(uint256 tokenId, uint8 round) private returns (uint256) { v3Staker.unstakeToken(rewardRounds[round].incentive, tokenId); return v3Staker.claimReward(address(avt), address(this), 0); } function _calculateTopup(uint256 stakerReward, uint256 aventusReward, uint256 rewardPot) private pure returns (uint256) { unchecked { return (stakerReward * aventusReward) / (rewardPot - aventusReward); } } function _estimateReward(uint256 tokenId) private view returns (uint256 stakerReward) { uint8 round = _stakedTokens[tokenId].rewardRound; RewardRound memory rewardRound = rewardRounds[round]; uint256 aventusReward = _aventusRewards[round]; if (aventusReward != 0) (stakerReward, ) = v3Staker.getRewardInfo(rewardRound.incentive, tokenId); else (aventusReward, stakerReward) = _estimateFirstReward(tokenId, rewardRound); stakerReward += _calculateTopup(stakerReward, aventusReward, rewardRound.rewardPot); } function _estimateFirstReward( uint256 tokenId, RewardRound memory rewardRound ) private view returns (uint256 aventusReward, uint256 stakerReward) { uint160 aventusSecondsInsideX128; (aventusReward, aventusSecondsInsideX128) = v3Staker.getRewardInfo(rewardRound.incentive, tokenId); (uint160 secondsPerLiquidityInsideInitialX128, uint128 liquidity) = v3Staker.stakes( tokenId, keccak256(abi.encode(rewardRound.incentive)) ); IUniswapV3Staker.Deposit memory deposit = v3Staker.deposits(tokenId); (, uint160 secondsPerLiquidityInsideX128, ) = v3Pool.snapshotCumulativesInside(deposit.tickLower, deposit.tickUpper); uint256 totalRewardUnclaimed = rewardRound.rewardPot - aventusReward; (stakerReward, ) = RewardMath.computeRewardAmount( totalRewardUnclaimed, aventusSecondsInsideX128, rewardRound.incentive.startTime, rewardRound.incentive.endTime, liquidity, secondsPerLiquidityInsideInitialX128, secondsPerLiquidityInsideX128, block.timestamp ); } function _increaseLiquidity(uint256 tokenId, uint256 avtAmount, uint256 ethReceived) private { uint256 ethRequired = _ethRequired(tokenId, avtAmount); if (ethReceived < ethRequired) revert NotEnoughETH(ethReceived, ethRequired); v3Staker.withdrawToken(tokenId, address(this), ''); (, , uint256 ethUsed) = positionManager.increaseLiquidity{ value: ethRequired }( IPositionManager.IncreaseLiquidityParams({ tokenId: tokenId, amount0Desired: avtAmount, amount1Desired: ethRequired, amount0Min: _adjustForSlippage(avtAmount), amount1Min: _adjustForSlippage(ethRequired), deadline: block.timestamp }) ); unchecked { (bool success, ) = msg.sender.call{ value: ethReceived - ethUsed }(''); if (!success) revert TransferFailed(); } } function _releasePosition(address positionOwner, uint256 tokenId) private { uint256[] storage tokenIds = _managedTokens[positionOwner]; uint256 length = tokenIds.length; for (uint256 i; i < length; ++i) { if (tokenIds[i] == tokenId) { tokenIds[i] = tokenIds[length - 1]; tokenIds.pop(); break; } } delete _stakedTokens[tokenId]; v3Staker.withdrawToken(tokenId, msg.sender, ''); } function _confirmPositionOwner(uint256 tokenId) private view { address positionOwner = _stakedTokens[tokenId].positionOwner; if (positionOwner == address(0)) revert PositionNotStaked(); if (positionOwner != msg.sender) revert PositionOwnerOnly(); } function _splitSignature(bytes calldata signature) private pure returns (uint8 v, bytes32 r, bytes32 s) { assembly { r := calldataload(signature.offset) s := calldataload(add(signature.offset, 32)) v := byte(0, calldataload(add(signature.offset, 64))) } } function _ethRequired(uint256 tokenId, uint256 avtAmount) private view returns (uint256 ethAmount) { (, , , , , int24 tickLower, int24 tickUpper, , , , , ) = positionManager.positions(tokenId); (uint160 sqrtPriceX96, int24 currentTick, , , , , ) = v3Pool.slot0(); if (currentTick < tickLower) return 0; if (currentTick >= tickUpper) revert OutOfRange(); uint160 sqrtPriceLowerX96 = TickMath.getSqrtRatioAtTick(tickLower); uint160 sqrtPriceUpperX96 = TickMath.getSqrtRatioAtTick(tickUpper); uint128 liquidity = LiquidityAmounts.getLiquidityForAmount0(sqrtPriceX96, sqrtPriceUpperX96, avtAmount); (, ethAmount) = LiquidityAmounts.getAmountsForLiquidity(sqrtPriceX96, sqrtPriceLowerX96, sqrtPriceUpperX96, liquidity); } function _adjustForSlippage(uint256 amount) private pure returns (uint256) { unchecked { return (amount * 99) / 100; // Allow 1% slippage } } function _getAllPositions(address positionOwner) private view returns (Position[] memory) { Position[] memory unmanagedPositions = _getUnmanagedPositions(positionOwner); if (positionOwner == aventusPositionOwner) return unmanagedPositions; uint256[] storage managedPositions = _managedTokens[positionOwner]; Position[] memory allPositions = new Position[](unmanagedPositions.length + managedPositions.length); for (uint256 i; i < unmanagedPositions.length; i++) { allPositions[i] = unmanagedPositions[i]; } for (uint256 j = 0; j < managedPositions.length; j++) { uint256 tokenId = managedPositions[j]; ( , , , , , int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = positionManager.positions(tokenId); Amounts memory principal = _getCurrentPrincipal(tickLower, tickUpper, liquidity); Amounts memory fees = _getCurrentFees( tickLower, tickUpper, liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128 ); Amounts memory rewards = Amounts(_estimateReward(tokenId), 0); allPositions[unmanagedPositions.length + j] = Position({ status: _stakedTokens[tokenId].rewardRound == activeRewardRound && block.timestamp < rewardRounds[activeRewardRound].incentive.endTime ? PositionStatus.Staking : PositionStatus.Rewarded, rewardRound: _stakedTokens[tokenId].rewardRound, tokenId: tokenId, principal: principal, fees: fees, rewards: rewards, total: Amounts(principal.avt + fees.avt + rewards.avt, principal.eth + fees.eth + rewards.eth), permit: _emptyPermit, tokenURI: positionManager.tokenURI(tokenId) }); } return allPositions; } function _getUnmanagedPositions(address positionOwner) private view returns (Position[] memory) { Position[] memory positions = new Position[](positionManager.balanceOf(positionOwner)); uint256 numUnmanagedPositions; for (uint256 i = 0; i < positions.length; i++) { uint256 tokenId = positionManager.tokenOfOwnerByIndex(positionOwner, i); ( , , address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = positionManager.positions(tokenId); Amounts memory principal = _getCurrentPrincipal(tickLower, tickUpper, liquidity); Amounts memory fees = _getCurrentFees( tickLower, tickUpper, liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128 ); if (liquidity != 0 && token0 == address(avt) && token1 == weth && fee == FEE_TIER) { positions[numUnmanagedPositions++] = Position({ status: PositionStatus.Unmanaged, rewardRound: 0, tokenId: tokenId, principal: principal, fees: fees, rewards: Amounts(0, 0), total: Amounts(principal.avt + fees.avt, principal.eth + fees.eth), permit: _generatePermit(tokenId), tokenURI: positionManager.tokenURI(tokenId) }); } } Position[] memory unmanagedPositions = new Position[](numUnmanagedPositions); for (uint256 j = 0; j < numUnmanagedPositions; j++) { unmanagedPositions[j] = positions[j]; } return unmanagedPositions; } function _getCurrentPrincipal(int24 tickLower, int24 tickUpper, uint128 liquidity) private view returns (Amounts memory) { (uint160 sqrtPriceX96, , , , , , ) = v3Pool.slot0(); uint160 sqrtPriceLowerX96 = TickMath.getSqrtRatioAtTick(tickLower); uint160 sqrtPriceUpperX96 = TickMath.getSqrtRatioAtTick(tickUpper); (uint256 amount0, uint256 amount1) = LiquidityAmounts.getAmountsForLiquidity( sqrtPriceX96, sqrtPriceLowerX96, sqrtPriceUpperX96, liquidity ); return Amounts(amount0, amount1); } function _getCurrentFees( int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128 ) private view returns (Amounts memory) { if (liquidity == 0) return Amounts(0, 0); (, int24 currentTick, , , , , ) = v3Pool.slot0(); (, , uint256 feeGrowthOutsideLowerX128, , , , , ) = v3Pool.ticks(tickLower); (, , uint256 feeGrowthOutsideUpperX128, , , , , ) = v3Pool.ticks(tickUpper); uint256 feeGrowthGlobalX128 = v3Pool.feeGrowthGlobal0X128(); uint256 feeGrowthBelowX128; uint256 feeGrowthAboveX128; uint256 feeGrowthInsideX128; uint256 fees0; uint256 fees1; { feeGrowthBelowX128 = currentTick >= tickLower ? feeGrowthOutsideLowerX128 : feeGrowthGlobalX128 - feeGrowthOutsideLowerX128; feeGrowthAboveX128 = currentTick < tickUpper ? feeGrowthOutsideUpperX128 : feeGrowthGlobalX128 - feeGrowthOutsideUpperX128; feeGrowthInsideX128 = feeGrowthGlobalX128 - feeGrowthBelowX128 - feeGrowthAboveX128; fees0 = FullMath.mulDivQ128(liquidity, feeGrowthInsideX128 - feeGrowthInside0LastX128); } { feeGrowthBelowX128 = currentTick >= tickLower ? feeGrowthOutsideLowerX128 : feeGrowthGlobalX128 - feeGrowthOutsideLowerX128; feeGrowthAboveX128 = currentTick < tickUpper ? feeGrowthOutsideUpperX128 : feeGrowthGlobalX128 - feeGrowthOutsideUpperX128; feeGrowthInsideX128 = feeGrowthGlobalX128 - feeGrowthBelowX128 - feeGrowthAboveX128; fees1 = FullMath.mulDivQ128(liquidity, feeGrowthInsideX128 - feeGrowthInside1LastX128); } return Amounts(fees0, fees1); } function _generatePermit(uint256 tokenId) private view returns (Permit memory permit) { permit.domain = _domain; permit.spender = address(this); permit.tokenId = tokenId; (permit.nonce, , , , , , , , , , , ) = positionManager.positions(tokenId); permit.deadline = block.timestamp + PERMIT_LIFETIME; } function _authorizeUpgrade(address) internal override onlyOwner {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable struct OwnableStorage { address _owner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300; function _getOwnableStorage() private pure returns (OwnableStorage storage $) { assembly { $.slot := OwnableStorageLocation } } /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ function __Ownable_init(address initialOwner) internal onlyInitializing { __Ownable_init_unchained(initialOwner); } function __Ownable_init_unchained(address initialOwner) internal onlyInitializing { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { OwnableStorage storage $ = _getOwnableStorage(); return $._owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { OwnableStorage storage $ = _getOwnableStorage(); address oldOwner = $._owner; $._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC-1967 compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC-1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @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 EIP-1153 (transient storage) is available on the chain you're deploying at, * consider using {ReentrancyGuardTransient} instead. * * 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]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // 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; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._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 making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol) pragma solidity ^0.8.20; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. */ interface IERC1967 { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.21; import {IBeacon} from "../beacon/IBeacon.sol"; import {IERC1967} from "../../interfaces/IERC1967.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This library provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots. */ library ERC1967Utils { /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit IERC1967.Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit IERC1967.AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the ERC-1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit IERC1967.BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC-721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC-721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert Errors.FailedCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC-1967 implementation slot: * ```solidity * contract ERC1967 { * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * TIP: Consider using this library along with {SlotDerivation}. */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct Int256Slot { int256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Int256Slot` with member `value` located at `slot`. */ function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } /** * @dev Returns a `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import './uniswap/IUniswapV3Staker.sol'; interface IAVTLiquidityMiner { struct RewardRound { uint256 rewardPot; IUniswapV3Staker.IncentiveKey incentive; } struct StakedToken { uint8 rewardRound; address positionOwner; } struct Position { PositionStatus status; uint8 rewardRound; uint256 tokenId; Amounts principal; Amounts fees; Amounts rewards; Amounts total; Permit permit; string tokenURI; } struct Amounts { uint256 avt; uint256 eth; } struct Permit { address spender; uint256 tokenId; uint256 nonce; uint256 deadline; Domain domain; } struct Domain { string name; string version; uint256 chainId; address verifyingContract; } enum PositionStatus { Unmanaged, Staking, Rewarded } event LogStartRound(uint8 rewardRound, uint256 startTime, uint256 endTime, uint256 rewardPot); event LogRoundCompleted(uint8 completedRound, uint256 refund); event LogStake(uint256 indexed tokenId, uint8 roundStaked, address indexed staker); event LogRestake(uint256 indexed tokenId, uint8 settledRound, uint8 roundStaked, uint256 reward); event LogCompound(uint256 indexed tokenId, uint8 settledRound, uint8 roundStaked, uint256 reward); event LogExit(uint256 indexed tokenId, uint8 settledRound, uint256 reward); function ownerSetAventusPosition(uint256 tokenId) external; function ownerSetRoundDuration(uint256 secondsPerRound) external; function ownerStartRound(uint256 rewardPot) external; function ownerCompleteRound(uint8 round, uint256[] calldata tokenIds) external; function ownerDrain(address recipient, uint256 avtAmount, uint256 ethAmount) external; function stake(uint256 tokenId, uint256 deadline, bytes calldata signedPermit) external; function restake(uint256 tokenId) external; function compound(uint256 tokenId) external payable; function exit(uint256 tokenId, bool earlyExit) external; function increaseLiquidity(uint256 tokenId, uint256 avtAmount) external payable; function getPositions(address positionOwner) external view returns (Position[] memory positions); function ethRequiredToCompound(uint256 tokenId) external view returns (uint256 ethAmount); function ethRequiredToIncreaseLiquidity(uint256 tokenId, uint256 avtAmount) external view returns (uint256 ethAmount); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; interface IERC20 { function balanceOf(address account) external view returns (uint256); function transfer(address to, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; interface IPositionManager { struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external view returns (bytes32); function balanceOf(address owner) external view returns (uint256 balance); function ownerOf(uint256 tokenId) external view returns (address owner); function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); function positions( uint256 tokenId ) external view returns ( uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); function increaseLiquidity( IncreaseLiquidityParams calldata params ) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1); function permit(address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable; function transferFrom(address from, address to, uint256 tokenId) external; function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata _data) external; function name() external view returns (string memory); function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; interface IPoolV3 { struct PoolKey { address token0; address token1; uint24 fee; } function feeGrowthGlobal0X128() external view returns (uint256); function feeGrowthGlobal1X128() external view returns (uint256); function liquidity() external view returns (uint128); function positions( bytes32 key ) external view returns ( uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); function ticks( int24 tick ) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 econdsOutside, bool initialized ); function snapshotCumulativesInside( int24 tickLower, int24 tickUpper ) external view returns (int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; interface IUniswapV3Staker { struct IncentiveKey { address rewardToken; address pool; uint256 startTime; uint256 endTime; address refundee; } struct Deposit { address owner; uint48 numberOfStakes; int24 tickLower; int24 tickUpper; } function createIncentive(IncentiveKey calldata key, uint256 reward) external; function endIncentive(IncentiveKey calldata key) external returns (uint256 refund); function withdrawToken(uint256 tokenId, address to, bytes calldata data) external; function stakeToken(IncentiveKey calldata key, uint256 tokenId) external; function unstakeToken(IncentiveKey calldata key, uint256 tokenId) external; function claimReward(address rewardToken, address to, uint256 amountRequested) external returns (uint256 reward); function getRewardInfo( IncentiveKey calldata key, uint256 tokenId ) external view returns (uint256 reward, uint160 secondsInsideX128); function deposits(uint256 tokenId) external view returns (Deposit memory deposit); function stakes( uint256 tokenId, bytes32 incentiveId ) external view returns (uint160 secondsPerLiquidityInsideInitialX128, uint128 liquidity); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Arithmetic library with operations for fixed-point numbers. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/FixedPointMathLib.sol) /// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol) library FixedPointMathLib { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The operation failed, as the output exceeds the maximum value of uint256. error ExpOverflow(); /// @dev The operation failed, as the output exceeds the maximum value of uint256. error FactorialOverflow(); /// @dev The operation failed, due to an overflow. error RPowOverflow(); /// @dev The mantissa is too big to fit. error MantissaOverflow(); /// @dev The operation failed, due to an multiplication overflow. error MulWadFailed(); /// @dev The operation failed, due to an multiplication overflow. error SMulWadFailed(); /// @dev The operation failed, either due to a multiplication overflow, or a division by a zero. error DivWadFailed(); /// @dev The operation failed, either due to a multiplication overflow, or a division by a zero. error SDivWadFailed(); /// @dev The operation failed, either due to a multiplication overflow, or a division by a zero. error MulDivFailed(); /// @dev The division failed, as the denominator is zero. error DivFailed(); /// @dev The full precision multiply-divide operation failed, either due /// to the result being larger than 256 bits, or a division by a zero. error FullMulDivFailed(); /// @dev The output is undefined, as the input is less-than-or-equal to zero. error LnWadUndefined(); /// @dev The input outside the acceptable domain. error OutOfDomain(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The scalar of ETH and most ERC20s. uint256 internal constant WAD = 1e18; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* SIMPLIFIED FIXED POINT OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Equivalent to `(x * y) / WAD` rounded down. function mulWad(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { // Equivalent to `require(y == 0 || x <= type(uint256).max / y)`. if gt(x, div(not(0), y)) { if y { mstore(0x00, 0xbac65e5b) // `MulWadFailed()`. revert(0x1c, 0x04) } } z := div(mul(x, y), WAD) } } /// @dev Equivalent to `(x * y) / WAD` rounded down. function sMulWad(int256 x, int256 y) internal pure returns (int256 z) { /// @solidity memory-safe-assembly assembly { z := mul(x, y) // Equivalent to `require((x == 0 || z / x == y) && !(x == -1 && y == type(int256).min))`. if iszero(gt(or(iszero(x), eq(sdiv(z, x), y)), lt(not(x), eq(y, shl(255, 1))))) { mstore(0x00, 0xedcd4dd4) // `SMulWadFailed()`. revert(0x1c, 0x04) } z := sdiv(z, WAD) } } /// @dev Equivalent to `(x * y) / WAD` rounded down, but without overflow checks. function rawMulWad(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := div(mul(x, y), WAD) } } /// @dev Equivalent to `(x * y) / WAD` rounded down, but without overflow checks. function rawSMulWad(int256 x, int256 y) internal pure returns (int256 z) { /// @solidity memory-safe-assembly assembly { z := sdiv(mul(x, y), WAD) } } /// @dev Equivalent to `(x * y) / WAD` rounded up. function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := mul(x, y) // Equivalent to `require(y == 0 || x <= type(uint256).max / y)`. if iszero(eq(div(z, y), x)) { if y { mstore(0x00, 0xbac65e5b) // `MulWadFailed()`. revert(0x1c, 0x04) } } z := add(iszero(iszero(mod(z, WAD))), div(z, WAD)) } } /// @dev Equivalent to `(x * y) / WAD` rounded up, but without overflow checks. function rawMulWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := add(iszero(iszero(mod(mul(x, y), WAD))), div(mul(x, y), WAD)) } } /// @dev Equivalent to `(x * WAD) / y` rounded down. function divWad(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { // Equivalent to `require(y != 0 && x <= type(uint256).max / WAD)`. if iszero(mul(y, lt(x, add(1, div(not(0), WAD))))) { mstore(0x00, 0x7c5f487d) // `DivWadFailed()`. revert(0x1c, 0x04) } z := div(mul(x, WAD), y) } } /// @dev Equivalent to `(x * WAD) / y` rounded down. function sDivWad(int256 x, int256 y) internal pure returns (int256 z) { /// @solidity memory-safe-assembly assembly { z := mul(x, WAD) // Equivalent to `require(y != 0 && ((x * WAD) / WAD == x))`. if iszero(mul(y, eq(sdiv(z, WAD), x))) { mstore(0x00, 0x5c43740d) // `SDivWadFailed()`. revert(0x1c, 0x04) } z := sdiv(z, y) } } /// @dev Equivalent to `(x * WAD) / y` rounded down, but without overflow and divide by zero checks. function rawDivWad(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := div(mul(x, WAD), y) } } /// @dev Equivalent to `(x * WAD) / y` rounded down, but without overflow and divide by zero checks. function rawSDivWad(int256 x, int256 y) internal pure returns (int256 z) { /// @solidity memory-safe-assembly assembly { z := sdiv(mul(x, WAD), y) } } /// @dev Equivalent to `(x * WAD) / y` rounded up. function divWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { // Equivalent to `require(y != 0 && x <= type(uint256).max / WAD)`. if iszero(mul(y, lt(x, add(1, div(not(0), WAD))))) { mstore(0x00, 0x7c5f487d) // `DivWadFailed()`. revert(0x1c, 0x04) } z := add(iszero(iszero(mod(mul(x, WAD), y))), div(mul(x, WAD), y)) } } /// @dev Equivalent to `(x * WAD) / y` rounded up, but without overflow and divide by zero checks. function rawDivWadUp(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := add(iszero(iszero(mod(mul(x, WAD), y))), div(mul(x, WAD), y)) } } /// @dev Equivalent to `x` to the power of `y`. /// because `x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)`. /// Note: This function is an approximation. function powWad(int256 x, int256 y) internal pure returns (int256) { // Using `ln(x)` means `x` must be greater than 0. return expWad((lnWad(x) * y) / int256(WAD)); } /// @dev Returns `exp(x)`, denominated in `WAD`. /// Credit to Remco Bloemen under MIT license: https://2π.com/22/exp-ln /// Note: This function is an approximation. Monotonically increasing. function expWad(int256 x) internal pure returns (int256 r) { unchecked { // When the result is less than 0.5 we return zero. // This happens when `x <= (log(1e-18) * 1e18) ~ -4.15e19`. if (x <= -41446531673892822313) return r; /// @solidity memory-safe-assembly assembly { // When the result is greater than `(2**255 - 1) / 1e18` we can not represent it as // an int. This happens when `x >= floor(log((2**255 - 1) / 1e18) * 1e18) ≈ 135`. if iszero(slt(x, 135305999368893231589)) { mstore(0x00, 0xa37bfec9) // `ExpOverflow()`. revert(0x1c, 0x04) } } // `x` is now in the range `(-42, 136) * 1e18`. Convert to `(-42, 136) * 2**96` // for more intermediate precision and a binary basis. This base conversion // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78. x = (x << 78) / 5 ** 18; // Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers // of two such that exp(x) = exp(x') * 2**k, where k is an integer. // Solving this gives k = round(x / log(2)) and x' = x - k * log(2). int256 k = ((x << 96) / 54916777467707473351141471128 + 2 ** 95) >> 96; x = x - k * 54916777467707473351141471128; // `k` is in the range `[-61, 195]`. // Evaluate using a (6, 7)-term rational approximation. // `p` is made monic, we'll multiply by a scale factor later. int256 y = x + 1346386616545796478920950773328; y = ((y * x) >> 96) + 57155421227552351082224309758442; int256 p = y + x - 94201549194550492254356042504812; p = ((p * y) >> 96) + 28719021644029726153956944680412240; p = p * x + (4385272521454847904659076985693276 << 96); // We leave `p` in `2**192` basis so we don't need to scale it back up for the division. int256 q = x - 2855989394907223263936484059900; q = ((q * x) >> 96) + 50020603652535783019961831881945; q = ((q * x) >> 96) - 533845033583426703283633433725380; q = ((q * x) >> 96) + 3604857256930695427073651918091429; q = ((q * x) >> 96) - 14423608567350463180887372962807573; q = ((q * x) >> 96) + 26449188498355588339934803723976023; /// @solidity memory-safe-assembly assembly { // Div in assembly because solidity adds a zero check despite the unchecked. // The q polynomial won't have zeros in the domain as all its roots are complex. // No scaling is necessary because p is already `2**96` too large. r := sdiv(p, q) } // r should be in the range `(0.09, 0.25) * 2**96`. // We now need to multiply r by: // - The scale factor `s ≈ 6.031367120`. // - The `2**k` factor from the range reduction. // - The `1e18 / 2**96` factor for base conversion. // We do this all at once, with an intermediate result in `2**213` // basis, so the final right shift is always by a positive amount. r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k)); } } /// @dev Returns `ln(x)`, denominated in `WAD`. /// Credit to Remco Bloemen under MIT license: https://2π.com/22/exp-ln /// Note: This function is an approximation. Monotonically increasing. function lnWad(int256 x) internal pure returns (int256 r) { /// @solidity memory-safe-assembly assembly { // We want to convert `x` from `10**18` fixed point to `2**96` fixed point. // We do this by multiplying by `2**96 / 10**18`. But since // `ln(x * C) = ln(x) + ln(C)`, we can simply do nothing here // and add `ln(2**96 / 10**18)` at the end. // Compute `k = log2(x) - 96`, `r = 159 - k = 255 - log2(x) = 255 ^ log2(x)`. r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x)) r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x)))) r := or(r, shl(5, lt(0xffffffff, shr(r, x)))) r := or(r, shl(4, lt(0xffff, shr(r, x)))) r := or(r, shl(3, lt(0xff, shr(r, x)))) // We place the check here for more optimal stack operations. if iszero(sgt(x, 0)) { mstore(0x00, 0x1615e638) // `LnWadUndefined()`. revert(0x1c, 0x04) } // forgefmt: disable-next-item r := xor( r, byte( and(0x1f, shr(shr(r, x), 0x8421084210842108cc6318c6db6d54be)), 0xf8f9f9faf9fdfafbf9fdfcfdfafbfcfef9fafdfafcfcfbfefafafcfbffffffff ) ) // Reduce range of x to (1, 2) * 2**96 // ln(2^k * x) = k * ln(2) + ln(x) x := shr(159, shl(r, x)) // Evaluate using a (8, 8)-term rational approximation. // `p` is made monic, we will multiply by a scale factor later. // forgefmt: disable-next-item let p := sub( // This heavily nested expression is to avoid stack-too-deep for via-ir. sar( 96, mul( add( 43456485725739037958740375743393, sar(96, mul(add(24828157081833163892658089445524, sar(96, mul(add(3273285459638523848632254066296, x), x))), x)) ), x ) ), 11111509109440967052023855526967 ) p := sub(sar(96, mul(p, x)), 45023709667254063763336534515857) p := sub(sar(96, mul(p, x)), 14706773417378608786704636184526) p := sub(mul(p, x), shl(96, 795164235651350426258249787498)) // We leave `p` in `2**192` basis so we don't need to scale it back up for the division. // `q` is monic by convention. let q := add(5573035233440673466300451813936, x) q := add(71694874799317883764090561454958, sar(96, mul(x, q))) q := add(283447036172924575727196451306956, sar(96, mul(x, q))) q := add(401686690394027663651624208769553, sar(96, mul(x, q))) q := add(204048457590392012362485061816622, sar(96, mul(x, q))) q := add(31853899698501571402653359427138, sar(96, mul(x, q))) q := add(909429971244387300277376558375, sar(96, mul(x, q))) // `p / q` is in the range `(0, 0.125) * 2**96`. // Finalization, we need to: // - Multiply by the scale factor `s = 5.549…`. // - Add `ln(2**96 / 10**18)`. // - Add `k * ln(2)`. // - Multiply by `10**18 / 2**96 = 5**18 >> 78`. // The q polynomial is known not to have zeros in the domain. // No scaling required because p is already `2**96` too large. p := sdiv(p, q) // Multiply by the scaling factor: `s * 5**18 * 2**96`, base is now `5**18 * 2**192`. p := mul(1677202110996718588342820967067443963516166, p) // Add `ln(2) * k * 5**18 * 2**192`. // forgefmt: disable-next-item p := add(mul(16597577552685614221487285958193947469193820559219878177908093499208371, sub(159, r)), p) // Add `ln(2**96 / 10**18) * 5**18 * 2**192`. p := add(600920179829731861736702779321621459595472258049074101567377883020018308, p) // Base conversion: mul `2**18 / 2**192`. r := sar(174, p) } } /// @dev Returns `W_0(x)`, denominated in `WAD`. /// See: https://en.wikipedia.org/wiki/Lambert_W_function /// a.k.a. Product log function. This is an approximation of the principal branch. /// Note: This function is an approximation. Monotonically increasing. function lambertW0Wad(int256 x) internal pure returns (int256 w) { // forgefmt: disable-next-item unchecked { if ((w = x) <= -367879441171442322) revert OutOfDomain(); // `x` less than `-1/e`. (int256 wad, int256 p) = (int256(WAD), x); uint256 c; // Whether we need to avoid catastrophic cancellation. uint256 i = 4; // Number of iterations. if (w <= 0x1ffffffffffff) { if (-0x4000000000000 <= w) { i = 1; // Inputs near zero only take one step to converge. } else if (w <= -0x3ffffffffffffff) { i = 32; // Inputs near `-1/e` take very long to converge. } } else if (uint256(w >> 63) == uint256(0)) { /// @solidity memory-safe-assembly assembly { // Inline log2 for more performance, since the range is small. let v := shr(49, w) let l := shl(3, lt(0xff, v)) l := add( or( l, byte( and(0x1f, shr(shr(l, v), 0x8421084210842108cc6318c6db6d54be)), 0x0706060506020504060203020504030106050205030304010505030400000000 ) ), 49 ) w := sdiv(shl(l, 7), byte(sub(l, 31), 0x0303030303030303040506080c13)) c := gt(l, 60) i := add(2, add(gt(l, 53), c)) } } else { int256 ll = lnWad(w = lnWad(w)); /// @solidity memory-safe-assembly assembly { // `w = ln(x) - ln(ln(x)) + b * ln(ln(x)) / ln(x)`. w := add(sdiv(mul(ll, 1023715080943847266), w), sub(w, ll)) i := add(3, iszero(shr(68, x))) c := iszero(shr(143, x)) } if (c == uint256(0)) { do { // If `x` is big, use Newton's so that intermediate values won't overflow. int256 e = expWad(w); /// @solidity memory-safe-assembly assembly { let t := mul(w, div(e, wad)) w := sub(w, sdiv(sub(t, x), div(add(e, t), wad))) } if (p <= w) break; p = w; } while (--i != uint256(0)); /// @solidity memory-safe-assembly assembly { w := sub(w, sgt(w, 2)) } return w; } } do { // Otherwise, use Halley's for faster convergence. int256 e = expWad(w); /// @solidity memory-safe-assembly assembly { let t := add(w, wad) let s := sub(mul(w, e), mul(x, wad)) w := sub(w, sdiv(mul(s, wad), sub(mul(e, t), sdiv(mul(add(t, wad), s), add(t, t))))) } if (p <= w) break; p = w; } while (--i != c); /// @solidity memory-safe-assembly assembly { w := sub(w, sgt(w, 2)) } // For certain ranges of `x`, we'll use the quadratic-rate recursive formula of // R. Iacono and J.P. Boyd for the last iteration, to avoid catastrophic cancellation. if (c == uint256(0)) return w; int256 t = w | 1; /// @solidity memory-safe-assembly assembly { x := sdiv(mul(x, wad), t) } x = (t * (wad + lnWad(x))); /// @solidity memory-safe-assembly assembly { w := sdiv(x, add(wad, t)) } } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* GENERAL NUMBER UTILITIES */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Calculates `floor(x * y / d)` with full precision. /// Throws if result overflows a uint256 or when `d` is zero. /// Credit to Remco Bloemen under MIT license: https://2π.com/21/muldiv function fullMulDiv(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 result) { /// @solidity memory-safe-assembly assembly { // 512-bit multiply `[p1 p0] = x * y`. // Compute the product mod `2**256` and mod `2**256 - 1` // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that `product = p1 * 2**256 + p0`. // Temporarily use `result` as `p0` to save gas. result := mul(x, y) // Lower 256 bits of `x * y`. for {} 1 {} { // If overflows. if iszero(mul(or(iszero(x), eq(div(result, x), y)), d)) { let mm := mulmod(x, y, not(0)) let p1 := sub(mm, add(result, lt(mm, result))) // Upper 256 bits of `x * y`. /*------------------- 512 by 256 division --------------------*/ // Make division exact by subtracting the remainder from `[p1 p0]`. let r := mulmod(x, y, d) // Compute remainder using mulmod. let t := and(d, sub(0, d)) // The least significant bit of `d`. `t >= 1`. // Make sure the result is less than `2**256`. Also prevents `d == 0`. // Placing the check here seems to give more optimal stack operations. if iszero(gt(d, p1)) { mstore(0x00, 0xae47f702) // `FullMulDivFailed()`. revert(0x1c, 0x04) } d := div(d, t) // Divide `d` by `t`, which is a power of two. // Invert `d mod 2**256` // Now that `d` is an odd number, it has an inverse // modulo `2**256` such that `d * inv = 1 mod 2**256`. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, `d * inv = 1 mod 2**4`. let inv := xor(2, mul(3, d)) // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**8 inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**16 inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**32 inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**64 inv := mul(inv, sub(2, mul(d, inv))) // inverse mod 2**128 result := mul( // Divide [p1 p0] by the factors of two. // Shift in bits from `p1` into `p0`. For this we need // to flip `t` such that it is `2**256 / t`. or(mul(sub(p1, gt(r, result)), add(div(sub(0, t), t), 1)), div(sub(result, r), t)), mul(sub(2, mul(d, inv)), inv) // inverse mod 2**256 ) break } result := div(result, d) break } } } /// @dev Calculates `floor(x * y / d)` with full precision. /// Behavior is undefined if `d` is zero or the final result cannot fit in 256 bits. /// Performs the full 512 bit calculation regardless. function fullMulDivUnchecked(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 result) { /// @solidity memory-safe-assembly assembly { result := mul(x, y) let mm := mulmod(x, y, not(0)) let p1 := sub(mm, add(result, lt(mm, result))) let t := and(d, sub(0, d)) let r := mulmod(x, y, d) d := div(d, t) let inv := xor(2, mul(3, d)) inv := mul(inv, sub(2, mul(d, inv))) inv := mul(inv, sub(2, mul(d, inv))) inv := mul(inv, sub(2, mul(d, inv))) inv := mul(inv, sub(2, mul(d, inv))) inv := mul(inv, sub(2, mul(d, inv))) result := mul( or(mul(sub(p1, gt(r, result)), add(div(sub(0, t), t), 1)), div(sub(result, r), t)), mul(sub(2, mul(d, inv)), inv) ) } } /// @dev Calculates `floor(x * y / d)` with full precision, rounded up. /// Throws if result overflows a uint256 or when `d` is zero. /// Credit to Uniswap-v3-core under MIT license: /// https://github.com/Uniswap/v3-core/blob/main/contracts/libraries/FullMath.sol function fullMulDivUp(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 result) { result = fullMulDiv(x, y, d); /// @solidity memory-safe-assembly assembly { if mulmod(x, y, d) { result := add(result, 1) if iszero(result) { mstore(0x00, 0xae47f702) // `FullMulDivFailed()`. revert(0x1c, 0x04) } } } } /// @dev Returns `floor(x * y / d)`. /// Reverts if `x * y` overflows, or `d` is zero. function mulDiv(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := mul(x, y) // Equivalent to `require(d != 0 && (y == 0 || x <= type(uint256).max / y))`. if iszero(mul(or(iszero(x), eq(div(z, x), y)), d)) { mstore(0x00, 0xad251c27) // `MulDivFailed()`. revert(0x1c, 0x04) } z := div(z, d) } } /// @dev Returns `ceil(x * y / d)`. /// Reverts if `x * y` overflows, or `d` is zero. function mulDivUp(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := mul(x, y) // Equivalent to `require(d != 0 && (y == 0 || x <= type(uint256).max / y))`. if iszero(mul(or(iszero(x), eq(div(z, x), y)), d)) { mstore(0x00, 0xad251c27) // `MulDivFailed()`. revert(0x1c, 0x04) } z := add(iszero(iszero(mod(z, d))), div(z, d)) } } /// @dev Returns `ceil(x / d)`. /// Reverts if `d` is zero. function divUp(uint256 x, uint256 d) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { if iszero(d) { mstore(0x00, 0x65244e4e) // `DivFailed()`. revert(0x1c, 0x04) } z := add(iszero(iszero(mod(x, d))), div(x, d)) } } /// @dev Returns `max(0, x - y)`. function zeroFloorSub(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := mul(gt(x, y), sub(x, y)) } } /// @dev Returns `condition ? x : y`, without branching. function ternary(bool condition, uint256 x, uint256 y) internal pure returns (uint256 result) { /// @solidity memory-safe-assembly assembly { result := xor(x, mul(xor(x, y), iszero(condition))) } } /// @dev Exponentiate `x` to `y` by squaring, denominated in base `b`. /// Reverts if the computation overflows. function rpow(uint256 x, uint256 y, uint256 b) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := mul(b, iszero(y)) // `0 ** 0 = 1`. Otherwise, `0 ** n = 0`. if x { z := xor(b, mul(xor(b, x), and(y, 1))) // `z = isEven(y) ? scale : x` let half := shr(1, b) // Divide `b` by 2. // Divide `y` by 2 every iteration. for { y := shr(1, y) } y { y := shr(1, y) } { let xx := mul(x, x) // Store x squared. let xxRound := add(xx, half) // Round to the nearest number. // Revert if `xx + half` overflowed, or if `x ** 2` overflows. if or(lt(xxRound, xx), shr(128, x)) { mstore(0x00, 0x49f7642b) // `RPowOverflow()`. revert(0x1c, 0x04) } x := div(xxRound, b) // Set `x` to scaled `xxRound`. // If `y` is odd: if and(y, 1) { let zx := mul(z, x) // Compute `z * x`. let zxRound := add(zx, half) // Round to the nearest number. // If `z * x` overflowed or `zx + half` overflowed: if or(xor(div(zx, x), z), lt(zxRound, zx)) { // Revert if `x` is non-zero. if x { mstore(0x00, 0x49f7642b) // `RPowOverflow()`. revert(0x1c, 0x04) } } z := div(zxRound, b) // Return properly scaled `zxRound`. } } } } } /// @dev Returns the square root of `x`, rounded down. function sqrt(uint256 x) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { // `floor(sqrt(2**15)) = 181`. `sqrt(2**15) - 181 = 2.84`. z := 181 // The "correct" value is 1, but this saves a multiplication later. // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically. // Let `y = x / 2**r`. We check `y >= 2**(k + 8)` // but shift right by `k` bits to ensure that if `x >= 256`, then `y >= 256`. let r := shl(7, lt(0xffffffffffffffffffffffffffffffffff, x)) r := or(r, shl(6, lt(0xffffffffffffffffff, shr(r, x)))) r := or(r, shl(5, lt(0xffffffffff, shr(r, x)))) r := or(r, shl(4, lt(0xffffff, shr(r, x)))) z := shl(shr(1, r), z) // Goal was to get `z*z*y` within a small factor of `x`. More iterations could // get y in a tighter range. Currently, we will have y in `[256, 256*(2**16))`. // We ensured `y >= 256` so that the relative difference between `y` and `y+1` is small. // That's not possible if `x < 256` but we can just verify those cases exhaustively. // Now, `z*z*y <= x < z*z*(y+1)`, and `y <= 2**(16+8)`, and either `y >= 256`, or `x < 256`. // Correctness can be checked exhaustively for `x < 256`, so we assume `y >= 256`. // Then `z*sqrt(y)` is within `sqrt(257)/sqrt(256)` of `sqrt(x)`, or about 20bps. // For `s` in the range `[1/256, 256]`, the estimate `f(s) = (181/1024) * (s+1)` // is in the range `(1/2.84 * sqrt(s), 2.84 * sqrt(s))`, // with largest error when `s = 1` and when `s = 256` or `1/256`. // Since `y` is in `[256, 256*(2**16))`, let `a = y/65536`, so that `a` is in `[1/256, 256)`. // Then we can estimate `sqrt(y)` using // `sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2**18`. // There is no overflow risk here since `y < 2**136` after the first branch above. z := shr(18, mul(z, add(shr(r, x), 65536))) // A `mul()` is saved from starting `z` at 181. // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough. z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) // If `x+1` is a perfect square, the Babylonian method cycles between // `floor(sqrt(x))` and `ceil(sqrt(x))`. This statement ensures we return floor. // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division z := sub(z, lt(div(x, z), z)) } } /// @dev Returns the cube root of `x`, rounded down. /// Credit to bout3fiddy and pcaversaccio under AGPLv3 license: /// https://github.com/pcaversaccio/snekmate/blob/main/src/utils/Math.vy /// Formally verified by xuwinnie: /// https://github.com/vectorized/solady/blob/main/audits/xuwinnie-solady-cbrt-proof.pdf function cbrt(uint256 x) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { let r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x)) r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x)))) r := or(r, shl(5, lt(0xffffffff, shr(r, x)))) r := or(r, shl(4, lt(0xffff, shr(r, x)))) r := or(r, shl(3, lt(0xff, shr(r, x)))) // Makeshift lookup table to nudge the approximate log2 result. z := div(shl(div(r, 3), shl(lt(0xf, shr(r, x)), 0xf)), xor(7, mod(r, 3))) // Newton-Raphson's. z := div(add(add(div(x, mul(z, z)), z), z), 3) z := div(add(add(div(x, mul(z, z)), z), z), 3) z := div(add(add(div(x, mul(z, z)), z), z), 3) z := div(add(add(div(x, mul(z, z)), z), z), 3) z := div(add(add(div(x, mul(z, z)), z), z), 3) z := div(add(add(div(x, mul(z, z)), z), z), 3) z := div(add(add(div(x, mul(z, z)), z), z), 3) // Round down. z := sub(z, lt(div(x, mul(z, z)), z)) } } /// @dev Returns the square root of `x`, denominated in `WAD`, rounded down. function sqrtWad(uint256 x) internal pure returns (uint256 z) { unchecked { if (x <= type(uint256).max / 10 ** 18) return sqrt(x * 10 ** 18); z = (1 + sqrt(x)) * 10 ** 9; z = (fullMulDivUnchecked(x, 10 ** 18, z) + z) >> 1; } /// @solidity memory-safe-assembly assembly { z := sub(z, gt(999999999999999999, sub(mulmod(z, z, x), 1))) // Round down. } } /// @dev Returns the cube root of `x`, denominated in `WAD`, rounded down. /// Formally verified by xuwinnie: /// https://github.com/vectorized/solady/blob/main/audits/xuwinnie-solady-cbrt-proof.pdf function cbrtWad(uint256 x) internal pure returns (uint256 z) { unchecked { if (x <= type(uint256).max / 10 ** 36) return cbrt(x * 10 ** 36); z = (1 + cbrt(x)) * 10 ** 12; z = (fullMulDivUnchecked(x, 10 ** 36, z * z) + z + z) / 3; } /// @solidity memory-safe-assembly assembly { let p := x for {} 1 {} { if iszero(shr(229, p)) { if iszero(shr(199, p)) { p := mul(p, 100000000000000000) // 10 ** 17. break } p := mul(p, 100000000) // 10 ** 8. break } if iszero(shr(249, p)) { p := mul(p, 100) } break } let t := mulmod(mul(z, z), z, p) z := sub(z, gt(lt(t, shr(1, p)), iszero(t))) // Round down. } } /// @dev Returns the factorial of `x`. function factorial(uint256 x) internal pure returns (uint256 result) { /// @solidity memory-safe-assembly assembly { result := 1 if iszero(lt(x, 58)) { mstore(0x00, 0xaba0f2a2) // `FactorialOverflow()`. revert(0x1c, 0x04) } for {} x { x := sub(x, 1) } { result := mul(result, x) } } } /// @dev Returns the log2 of `x`. /// Equivalent to computing the index of the most significant bit (MSB) of `x`. /// Returns 0 if `x` is zero. function log2(uint256 x) internal pure returns (uint256 r) { /// @solidity memory-safe-assembly assembly { r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x)) r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x)))) r := or(r, shl(5, lt(0xffffffff, shr(r, x)))) r := or(r, shl(4, lt(0xffff, shr(r, x)))) r := or(r, shl(3, lt(0xff, shr(r, x)))) // forgefmt: disable-next-item r := or( r, byte( and(0x1f, shr(shr(r, x), 0x8421084210842108cc6318c6db6d54be)), 0x0706060506020504060203020504030106050205030304010505030400000000 ) ) } } /// @dev Returns the log2 of `x`, rounded up. /// Returns 0 if `x` is zero. function log2Up(uint256 x) internal pure returns (uint256 r) { r = log2(x); /// @solidity memory-safe-assembly assembly { r := add(r, lt(shl(r, 1), x)) } } /// @dev Returns the log10 of `x`. /// Returns 0 if `x` is zero. function log10(uint256 x) internal pure returns (uint256 r) { /// @solidity memory-safe-assembly assembly { if iszero(lt(x, 100000000000000000000000000000000000000)) { x := div(x, 100000000000000000000000000000000000000) r := 38 } if iszero(lt(x, 100000000000000000000)) { x := div(x, 100000000000000000000) r := add(r, 20) } if iszero(lt(x, 10000000000)) { x := div(x, 10000000000) r := add(r, 10) } if iszero(lt(x, 100000)) { x := div(x, 100000) r := add(r, 5) } r := add(r, add(gt(x, 9), add(gt(x, 99), add(gt(x, 999), gt(x, 9999))))) } } /// @dev Returns the log10 of `x`, rounded up. /// Returns 0 if `x` is zero. function log10Up(uint256 x) internal pure returns (uint256 r) { r = log10(x); /// @solidity memory-safe-assembly assembly { r := add(r, lt(exp(10, r), x)) } } /// @dev Returns the log256 of `x`. /// Returns 0 if `x` is zero. function log256(uint256 x) internal pure returns (uint256 r) { /// @solidity memory-safe-assembly assembly { r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x)) r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x)))) r := or(r, shl(5, lt(0xffffffff, shr(r, x)))) r := or(r, shl(4, lt(0xffff, shr(r, x)))) r := or(shr(3, r), lt(0xff, shr(r, x))) } } /// @dev Returns the log256 of `x`, rounded up. /// Returns 0 if `x` is zero. function log256Up(uint256 x) internal pure returns (uint256 r) { r = log256(x); /// @solidity memory-safe-assembly assembly { r := add(r, lt(shl(shl(3, r), 1), x)) } } /// @dev Returns the scientific notation format `mantissa * 10 ** exponent` of `x`. /// Useful for compressing prices (e.g. using 25 bit mantissa and 7 bit exponent). function sci(uint256 x) internal pure returns (uint256 mantissa, uint256 exponent) { /// @solidity memory-safe-assembly assembly { mantissa := x if mantissa { if iszero(mod(mantissa, 1000000000000000000000000000000000)) { mantissa := div(mantissa, 1000000000000000000000000000000000) exponent := 33 } if iszero(mod(mantissa, 10000000000000000000)) { mantissa := div(mantissa, 10000000000000000000) exponent := add(exponent, 19) } if iszero(mod(mantissa, 1000000000000)) { mantissa := div(mantissa, 1000000000000) exponent := add(exponent, 12) } if iszero(mod(mantissa, 1000000)) { mantissa := div(mantissa, 1000000) exponent := add(exponent, 6) } if iszero(mod(mantissa, 10000)) { mantissa := div(mantissa, 10000) exponent := add(exponent, 4) } if iszero(mod(mantissa, 100)) { mantissa := div(mantissa, 100) exponent := add(exponent, 2) } if iszero(mod(mantissa, 10)) { mantissa := div(mantissa, 10) exponent := add(exponent, 1) } } } } /// @dev Convenience function for packing `x` into a smaller number using `sci`. /// The `mantissa` will be in bits [7..255] (the upper 249 bits). /// The `exponent` will be in bits [0..6] (the lower 7 bits). /// Use `SafeCastLib` to safely ensure that the `packed` number is small /// enough to fit in the desired unsigned integer type: /// ``` /// uint32 packed = SafeCastLib.toUint32(FixedPointMathLib.packSci(777 ether)); /// ``` function packSci(uint256 x) internal pure returns (uint256 packed) { (x, packed) = sci(x); // Reuse for `mantissa` and `exponent`. /// @solidity memory-safe-assembly assembly { if shr(249, x) { mstore(0x00, 0xce30380c) // `MantissaOverflow()`. revert(0x1c, 0x04) } packed := or(shl(7, x), packed) } } /// @dev Convenience function for unpacking a packed number from `packSci`. function unpackSci(uint256 packed) internal pure returns (uint256 unpacked) { unchecked { unpacked = (packed >> 7) * 10 ** (packed & 0x7f); } } /// @dev Returns the average of `x` and `y`. Rounds towards zero. function avg(uint256 x, uint256 y) internal pure returns (uint256 z) { unchecked { z = (x & y) + ((x ^ y) >> 1); } } /// @dev Returns the average of `x` and `y`. Rounds towards negative infinity. function avg(int256 x, int256 y) internal pure returns (int256 z) { unchecked { z = (x >> 1) + (y >> 1) + (x & y & 1); } } /// @dev Returns the absolute value of `x`. function abs(int256 x) internal pure returns (uint256 z) { unchecked { z = (uint256(x) + uint256(x >> 255)) ^ uint256(x >> 255); } } /// @dev Returns the absolute distance between `x` and `y`. function dist(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := add(xor(sub(0, gt(x, y)), sub(y, x)), gt(x, y)) } } /// @dev Returns the absolute distance between `x` and `y`. function dist(int256 x, int256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := add(xor(sub(0, sgt(x, y)), sub(y, x)), sgt(x, y)) } } /// @dev Returns the minimum of `x` and `y`. function min(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := xor(x, mul(xor(x, y), lt(y, x))) } } /// @dev Returns the minimum of `x` and `y`. function min(int256 x, int256 y) internal pure returns (int256 z) { /// @solidity memory-safe-assembly assembly { z := xor(x, mul(xor(x, y), slt(y, x))) } } /// @dev Returns the maximum of `x` and `y`. function max(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := xor(x, mul(xor(x, y), gt(y, x))) } } /// @dev Returns the maximum of `x` and `y`. function max(int256 x, int256 y) internal pure returns (int256 z) { /// @solidity memory-safe-assembly assembly { z := xor(x, mul(xor(x, y), sgt(y, x))) } } /// @dev Returns `x`, bounded to `minValue` and `maxValue`. function clamp(uint256 x, uint256 minValue, uint256 maxValue) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := xor(x, mul(xor(x, minValue), gt(minValue, x))) z := xor(z, mul(xor(z, maxValue), lt(maxValue, z))) } } /// @dev Returns `x`, bounded to `minValue` and `maxValue`. function clamp(int256 x, int256 minValue, int256 maxValue) internal pure returns (int256 z) { /// @solidity memory-safe-assembly assembly { z := xor(x, mul(xor(x, minValue), sgt(minValue, x))) z := xor(z, mul(xor(z, maxValue), slt(maxValue, z))) } } /// @dev Returns greatest common divisor of `x` and `y`. function gcd(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { for { z := x } y {} { let t := y y := mod(z, y) z := t } } } /// @dev Returns `a + (b - a) * (t - begin) / (end - begin)`, /// with `t` clamped between `begin` and `end` (inclusive). /// Agnostic to the order of (`a`, `b`) and (`end`, `begin`). /// If `begins == end`, returns `t <= begin ? a : b`. function lerp(uint256 a, uint256 b, uint256 t, uint256 begin, uint256 end) internal pure returns (uint256) { if (begin > end) (t, begin, end) = (~t, ~begin, ~end); if (t <= begin) return a; if (t >= end) return b; unchecked { if (b >= a) return a + fullMulDiv(b - a, t - begin, end - begin); return a - fullMulDiv(a - b, t - begin, end - begin); } } /// @dev Returns `a + (b - a) * (t - begin) / (end - begin)`. /// with `t` clamped between `begin` and `end` (inclusive). /// Agnostic to the order of (`a`, `b`) and (`end`, `begin`). /// If `begins == end`, returns `t <= begin ? a : b`. function lerp(int256 a, int256 b, int256 t, int256 begin, int256 end) internal pure returns (int256) { if (begin > end) (t, begin, end) = (~t, ~begin, ~end); if (t <= begin) return a; if (t >= end) return b; // forgefmt: disable-next-item unchecked { if (b >= a) return int256(uint256(a) + fullMulDiv(uint256(b - a), uint256(t - begin), uint256(end - begin))); return int256(uint256(a) - fullMulDiv(uint256(a - b), uint256(t - begin), uint256(end - begin))); } } /// @dev Returns if `x` is an even number. Some people may need this. function isEven(uint256 x) internal pure returns (bool) { return x & uint256(1) == uint256(0); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* RAW NUMBER OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns `x + y`, without checking for overflow. function rawAdd(uint256 x, uint256 y) internal pure returns (uint256 z) { unchecked { z = x + y; } } /// @dev Returns `x + y`, without checking for overflow. function rawAdd(int256 x, int256 y) internal pure returns (int256 z) { unchecked { z = x + y; } } /// @dev Returns `x - y`, without checking for underflow. function rawSub(uint256 x, uint256 y) internal pure returns (uint256 z) { unchecked { z = x - y; } } /// @dev Returns `x - y`, without checking for underflow. function rawSub(int256 x, int256 y) internal pure returns (int256 z) { unchecked { z = x - y; } } /// @dev Returns `x * y`, without checking for overflow. function rawMul(uint256 x, uint256 y) internal pure returns (uint256 z) { unchecked { z = x * y; } } /// @dev Returns `x * y`, without checking for overflow. function rawMul(int256 x, int256 y) internal pure returns (int256 z) { unchecked { z = x * y; } } /// @dev Returns `x / y`, returning 0 if `y` is zero. function rawDiv(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := div(x, y) } } /// @dev Returns `x / y`, returning 0 if `y` is zero. function rawSDiv(int256 x, int256 y) internal pure returns (int256 z) { /// @solidity memory-safe-assembly assembly { z := sdiv(x, y) } } /// @dev Returns `x % y`, returning 0 if `y` is zero. function rawMod(uint256 x, uint256 y) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := mod(x, y) } } /// @dev Returns `x % y`, returning 0 if `y` is zero. function rawSMod(int256 x, int256 y) internal pure returns (int256 z) { /// @solidity memory-safe-assembly assembly { z := smod(x, y) } } /// @dev Returns `(x + y) % d`, return 0 if `d` if zero. function rawAddMod(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := addmod(x, y, d) } } /// @dev Returns `(x * y) % d`, return 0 if `d` if zero. function rawMulMod(uint256 x, uint256 y, uint256 d) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { z := mulmod(x, y, d) } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.4; import './FixedPointMathLib.sol'; /// @title Contains 512-bit math functions /// @author Aperture Finance /// @author Modified from Uniswap (https://github.com/uniswap/v3-core/blob/main/contracts/libraries/FullMath.sol) /// @author Credit to Solady (https://github.com/vectorized/solady/blob/main/src/utils/FixedPointMathLib.sol) /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath { /// @dev The full precision multiply-divide operation failed, either due /// to the result being larger than 256 bits, or a division by a zero. error FullMulDivFailed(); /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256) { return FixedPointMathLib.fullMulDiv(a, b, denominator); } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256) { return FixedPointMathLib.fullMulDivUp(a, b, denominator); } /// @notice Calculates a * b / 2^96 with full precision. /// @param a The multiplicand /// @param b The multiplier /// @return result The 256-bit result function mulDivQ96(uint256 a, uint256 b) internal pure returns (uint256 result) { assembly ('memory-safe') { // 512-bit multiply `[prod1 prod0] = a * b`. // Compute the product mod `2**256` and mod `2**256 - 1` // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that `product = prod1 * 2**256 + prod0`. // Least significant 256 bits of the product. let prod0 := mul(a, b) let mm := mulmod(a, b, not(0)) // Most significant 256 bits of the product. let prod1 := sub(mm, add(prod0, lt(mm, prod0))) // Make sure the result is less than `2**256`. if iszero(gt(0x1000000000000000000000000, prod1)) { // Store the function selector of `FullMulDivFailed()`. mstore(0x00, 0xae47f702) // Revert with (offset, size). revert(0x1c, 0x04) } // Divide [prod1 prod0] by 2^96. result := or(shr(96, prod0), shl(160, prod1)) } } /// @notice Calculates a * b / 2^128 with full precision. /// @param a The multiplicand /// @param b The multiplier /// @return result The 256-bit result function mulDivQ128(uint256 a, uint256 b) internal pure returns (uint256 result) { assembly ('memory-safe') { // 512-bit multiply `[prod1 prod0] = a * b`. // Compute the product mod `2**256` and mod `2**256 - 1` // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that `product = prod1 * 2**256 + prod0`. // Least significant 256 bits of the product. let prod0 := mul(a, b) let mm := mulmod(a, b, not(0)) // Most significant 256 bits of the product. let prod1 := sub(mm, add(prod0, lt(mm, prod0))) // Make sure the result is less than `2**256`. if iszero(gt(0x100000000000000000000000000000000, prod1)) { // Store the function selector of `FullMulDivFailed()`. mstore(0x00, 0xae47f702) // Revert with (offset, size). revert(0x1c, 0x04) } // Divide [prod1 prod0] by 2^128. result := or(shr(128, prod0), shl(128, prod1)) } } /// @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. function sqrt(uint256 x) internal pure returns (uint256) { return FixedPointMathLib.sqrt(x); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.4; import '@uniswap/v3-core/contracts/libraries/FixedPoint96.sol'; import './FullMath.sol'; import './SafeCast.sol'; import './TernaryLib.sol'; import './UnsafeMath.sol'; /// @title Liquidity amount functions /// @author Aperture Finance /// @author Modified from Uniswap (https://github.com/uniswap/v3-periphery/blob/main/contracts/libraries/LiquidityAmounts.sol) /// @notice Provides functions for computing liquidity amounts from token amounts and prices library LiquidityAmounts { using UnsafeMath for *; using SafeCast for uint256; /// @notice Computes the amount of liquidity received for a given amount of token0 and price range /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount0 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount0( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0 ) internal pure returns (uint128) { uint256 intermediate = FullMath.mulDivQ96(sqrtRatioAX96, sqrtRatioBX96); return FullMath.mulDiv(amount0, intermediate, TernaryLib.absDiffU160(sqrtRatioAX96, sqrtRatioBX96)).toUint128(); } /// @notice Computes the amount of liquidity received for a given amount of token0 and price range /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price representing the lower tick boundary /// @param sqrtRatioBX96 A sqrt price representing the upper tick boundary /// @param amount0 The amount0 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount0Sorted( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0 ) internal pure returns (uint128 liquidity) { unchecked { uint256 intermediate = FullMath.mulDivQ96(sqrtRatioAX96, sqrtRatioBX96); return FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96).toUint128(); } } /// @notice Computes the amount of liquidity received for a given amount of token1 and price range /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)). /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount1 The amount1 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1 ) internal pure returns (uint128 liquidity) { return FullMath.mulDiv(amount1, FixedPoint96.Q96, TernaryLib.absDiffU160(sqrtRatioAX96, sqrtRatioBX96)).toUint128(); } /// @notice Computes the amount of liquidity received for a given amount of token1 and price range /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)). /// @param sqrtRatioAX96 A sqrt price representing the lower tick boundary /// @param sqrtRatioBX96 A sqrt price representing the upper tick boundary /// @param amount1 The amount1 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount1Sorted( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1 ) internal pure returns (uint128 liquidity) { unchecked { return FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96).toUint128(); } } /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount of token0 being sent in /// @param amount1 The amount of token1 being sent in /// @return liquidity The maximum amount of liquidity received function getLiquidityForAmounts( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1 ) internal pure returns (uint128 liquidity) { (sqrtRatioAX96, sqrtRatioBX96) = TernaryLib.sort2U160(sqrtRatioAX96, sqrtRatioBX96); if (sqrtRatioX96 <= sqrtRatioAX96) { liquidity = getLiquidityForAmount0Sorted(sqrtRatioAX96, sqrtRatioBX96, amount0); } else if (sqrtRatioX96 < sqrtRatioBX96) { uint128 liquidity0 = getLiquidityForAmount0Sorted(sqrtRatioX96, sqrtRatioBX96, amount0); uint128 liquidity1 = getLiquidityForAmount1Sorted(sqrtRatioAX96, sqrtRatioX96, amount1); // liquidity = min(liquidity0, liquidity1); assembly { liquidity := xor(liquidity0, mul(xor(liquidity0, liquidity1), lt(liquidity1, liquidity0))) } } else { liquidity = getLiquidityForAmount1Sorted(sqrtRatioAX96, sqrtRatioBX96, amount1); } } /// @notice Computes the amount of token0 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 function getAmount0ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0) { unchecked { (sqrtRatioAX96, sqrtRatioBX96) = TernaryLib.sort2U160(sqrtRatioAX96, sqrtRatioBX96); return FullMath.mulDiv(uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96).div( sqrtRatioAX96 ); } } /// @notice Computes the amount of token0 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the lower tick boundary /// @param sqrtRatioBX96 A sqrt price representing the upper tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 function getAmount0ForLiquiditySorted( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0) { unchecked { return FullMath.mulDiv(uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96).div( sqrtRatioAX96 ); } } /// @notice Computes the amount of token1 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount1 The amount of token1 function getAmount1ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount1) { return FullMath.mulDivQ96(liquidity, TernaryLib.absDiffU160(sqrtRatioAX96, sqrtRatioBX96)); } /// @notice Computes the amount of token1 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the lower tick boundary /// @param sqrtRatioBX96 A sqrt price representing the upper tick boundary /// @param liquidity The liquidity being valued /// @return amount1 The amount of token1 function getAmount1ForLiquiditySorted( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount1) { unchecked { return FullMath.mulDivQ96(liquidity, sqrtRatioBX96 - sqrtRatioAX96); } } /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function getAmountsForLiquidity( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { (sqrtRatioAX96, sqrtRatioBX96) = TernaryLib.sort2U160(sqrtRatioAX96, sqrtRatioBX96); if (sqrtRatioX96 <= sqrtRatioAX96) { amount0 = getAmount0ForLiquiditySorted(sqrtRatioAX96, sqrtRatioBX96, liquidity); } else if (sqrtRatioX96 <= sqrtRatioBX96) { amount0 = getAmount0ForLiquiditySorted(sqrtRatioX96, sqrtRatioBX96, liquidity); amount1 = getAmount1ForLiquiditySorted(sqrtRatioAX96, sqrtRatioX96, liquidity); } else { amount1 = getAmount1ForLiquiditySorted(sqrtRatioAX96, sqrtRatioBX96, liquidity); } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.28; import './FullMath.sol'; import './TernaryLib.sol'; library RewardMath { /// @notice Compute the amount of rewards owed given parameters of the incentive and stake /// @param totalRewardUnclaimed The total amount of unclaimed rewards left for an incentive /// @param totalSecondsClaimedX128 How many full liquidity-seconds have been already claimed for the incentive /// @param startTime When the incentive rewards began in epoch seconds /// @param endTime When rewards are no longer being dripped out in epoch seconds /// @param liquidity The amount of liquidity, assumed to be constant over the period over which the snapshots are measured /// @param secondsPerLiquidityInsideInitialX128 The seconds per liquidity of the liquidity tick range as of the beginning of the period /// @param secondsPerLiquidityInsideX128 The seconds per liquidity of the liquidity tick range as of the current block timestamp /// @param currentTime The current block timestamp, which must be greater than or equal to the start time /// @return reward The amount of rewards owed /// @return secondsInsideX128 The total liquidity seconds inside the position's range for the duration of the stake function computeRewardAmount( uint256 totalRewardUnclaimed, uint160 totalSecondsClaimedX128, uint256 startTime, uint256 endTime, uint128 liquidity, uint160 secondsPerLiquidityInsideInitialX128, uint160 secondsPerLiquidityInsideX128, uint256 currentTime ) internal pure returns (uint256 reward, uint160 secondsInsideX128) { secondsInsideX128 = (secondsPerLiquidityInsideX128 - secondsPerLiquidityInsideInitialX128) * liquidity; uint256 totalSecondsUnclaimedX128 = ((TernaryLib.max(endTime, currentTime) - startTime) << 128) - totalSecondsClaimedX128; reward = FullMath.mulDiv(totalRewardUnclaimed, secondsInsideX128, totalSecondsUnclaimedX128); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; /// @title Safe casting methods /// @author Aperture Finance /// @author Modified from Uniswap (https://github.com/uniswap/v3-core/blob/main/contracts/libraries/SafeCast.sol) /// @notice Contains methods for safely casting between types library SafeCast { /// @notice Cast a uint256 to a uint160, revert on overflow /// @param x The uint256 to be downcasted /// @return The downcasted integer, now type uint160 function toUint160(uint256 x) internal pure returns (uint160) { if (x >= 1 << 160) revert(); return uint160(x); } /// @notice Cast a uint256 to a uint128, revert on overflow /// @param x The uint256 to be downcasted /// @return The downcasted integer, now type uint128 function toUint128(uint256 x) internal pure returns (uint128) { if (x >= 1 << 128) revert(); return uint128(x); } /// @notice Cast a int256 to a int128, revert on overflow or underflow /// @param x The int256 to be downcasted /// @return The downcasted integer, now type int128 function toInt128(int256 x) internal pure returns (int128) { unchecked { if (((1 << 127) + uint256(x)) >> 128 == uint256(0)) return int128(x); revert(); } } /// @notice Cast a uint256 to a int256, revert on overflow /// @param x The uint256 to be casted /// @return The casted integer, now type int256 function toInt256(uint256 x) internal pure returns (int256) { if (int256(x) >= 0) return int256(x); revert(); } /// @notice Cast a uint256 to a int128, revert on overflow /// @param x The uint256 to be downcasted /// @return The downcasted integer, now type int128 function toInt128(uint256 x) internal pure returns (int128) { if (x >= 1 << 127) revert(); return int128(int256(x)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; /// @title Library for efficient ternary operations /// @author Aperture Finance library TernaryLib { /// @notice Equivalent to the ternary operator: `condition ? a : b` function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256 res) { assembly { res := xor(b, mul(xor(a, b), condition)) } } /// @notice Equivalent to the ternary operator: `condition ? a : b` function ternary(bool condition, address a, address b) internal pure returns (address res) { assembly { res := xor(b, mul(xor(a, b), condition)) } } /// @notice Equivalent to: `uint256(x < 0 ? -x : x)` function abs(int256 x) internal pure returns (uint256 y) { assembly { // mask = 0 if x >= 0 else -1 let mask := sar(255, x) // If x >= 0, |x| = x = 0 ^ x // If x < 0, |x| = ~~|x| = ~(-|x| - 1) = ~(x - 1) = -1 ^ (x - 1) // Either case, |x| = mask ^ (x + mask) y := xor(mask, add(mask, x)) } } /// @notice Equivalent to: `a > b ? a - b : b - a` function absDiff(uint256 a, uint256 b) internal pure returns (uint256 res) { assembly { // The diff between two `uint256` may overflow `int256` let diff0 := sub(a, b) let diff1 := sub(b, a) res := xor(diff1, mul(xor(diff0, diff1), gt(a, b))) } } /// @notice Equivalent to: `a > b ? a - b : b - a` function absDiffU160(uint160 a, uint160 b) internal pure returns (uint256 res) { assembly { let diff := sub(a, b) let mask := sar(255, diff) res := xor(mask, add(mask, diff)) } } /// @notice Equivalent to: `a < b ? a : b` function min(uint256 a, uint256 b) internal pure returns (uint256 res) { assembly { res := xor(b, mul(xor(a, b), lt(a, b))) } } /// @notice Equivalent to: `a > b ? a : b` function max(uint256 a, uint256 b) internal pure returns (uint256 res) { assembly { res := xor(b, mul(xor(a, b), gt(a, b))) } } /// @notice Equivalent to: `condition ? (b, a) : (a, b)` function switchIf(bool condition, uint256 a, uint256 b) internal pure returns (uint256, uint256) { assembly { let diff := mul(xor(a, b), condition) a := xor(a, diff) b := xor(b, diff) } return (a, b); } /// @notice Equivalent to: `condition ? (b, a) : (a, b)` function switchIf(bool condition, address a, address b) internal pure returns (address, address) { assembly { let diff := mul(xor(a, b), condition) a := xor(a, diff) b := xor(b, diff) } return (a, b); } /// @notice Sorts two addresses and returns them in ascending order function sort2(address a, address b) internal pure returns (address, address) { assembly { let diff := mul(xor(a, b), lt(b, a)) a := xor(a, diff) b := xor(b, diff) } return (a, b); } /// @notice Sorts two uint256s and returns them in ascending order function sort2(uint256 a, uint256 b) internal pure returns (uint256, uint256) { assembly { let diff := mul(xor(a, b), lt(b, a)) a := xor(a, diff) b := xor(b, diff) } return (a, b); } /// @notice Sorts two uint160s and returns them in ascending order function sort2U160(uint160 a, uint160 b) internal pure returns (uint160, uint160) { assembly { let diff := mul(xor(a, b), lt(b, a)) a := xor(a, diff) b := xor(b, diff) } return (a, b); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.28; library TickMath { function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); require(absTick <= 887272, 'T'); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Math functions that do not check inputs or outputs /// @author Aperture Finance /// @author Modified from Uniswap (https://github.com/uniswap/v3-core/blob/main/contracts/libraries/UnsafeMath.sol) /// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks library UnsafeMath { function add(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := add(x, y) } } function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := sub(x, y) } } function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := mul(x, y) } } function div(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := div(x, y) } } /// @notice Returns ceil(x / y) /// @dev division by 0 has unspecified behavior, and must be checked externally /// @param x The dividend /// @param y The divisor /// @return z The quotient, ceil(x / y) function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly { z := add(div(x, y), gt(mod(x, y), 0)) } } }
{ "optimizer": { "enabled": true, "runs": 2000, "details": { "yul": true } }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[],"name":"AddressZero","type":"error"},{"inputs":[],"name":"ClaimWindowOpen","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"EarlyExitOnly","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NewRoundNotOpen","type":"error"},{"inputs":[{"internalType":"uint256","name":"provided","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"NotEnoughETH","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OutOfRange","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"PositionInactive","type":"error"},{"inputs":[],"name":"PositionIsStaked","type":"error"},{"inputs":[],"name":"PositionNotStaked","type":"error"},{"inputs":[],"name":"PositionOwnerOnly","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"RoundStillActive","type":"error"},{"inputs":[],"name":"TransferFailed","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"settledRound","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"roundStaked","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"LogCompound","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"settledRound","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"LogExit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"settledRound","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"roundStaked","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"LogRestake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"completedRound","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"refund","type":"uint256"}],"name":"LogRoundCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"roundStaked","type":"uint8"},{"indexed":true,"internalType":"address","name":"staker","type":"address"}],"name":"LogStake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"rewardRound","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardPot","type":"uint256"}],"name":"LogStartRound","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":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"activeRewardRound","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aventusTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"compound","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ethRequiredToCompound","outputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"avtAmount","type":"uint256"}],"name":"ethRequiredToIncreaseLiquidity","outputs":[{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"earlyExit","type":"bool"}],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"positionOwner","type":"address"}],"name":"getPositions","outputs":[{"components":[{"internalType":"enum IAVTLiquidityMiner.PositionStatus","name":"status","type":"uint8"},{"internalType":"uint8","name":"rewardRound","type":"uint8"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"uint256","name":"avt","type":"uint256"},{"internalType":"uint256","name":"eth","type":"uint256"}],"internalType":"struct IAVTLiquidityMiner.Amounts","name":"principal","type":"tuple"},{"components":[{"internalType":"uint256","name":"avt","type":"uint256"},{"internalType":"uint256","name":"eth","type":"uint256"}],"internalType":"struct IAVTLiquidityMiner.Amounts","name":"fees","type":"tuple"},{"components":[{"internalType":"uint256","name":"avt","type":"uint256"},{"internalType":"uint256","name":"eth","type":"uint256"}],"internalType":"struct IAVTLiquidityMiner.Amounts","name":"rewards","type":"tuple"},{"components":[{"internalType":"uint256","name":"avt","type":"uint256"},{"internalType":"uint256","name":"eth","type":"uint256"}],"internalType":"struct IAVTLiquidityMiner.Amounts","name":"total","type":"tuple"},{"components":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"}],"internalType":"struct IAVTLiquidityMiner.Domain","name":"domain","type":"tuple"}],"internalType":"struct IAVTLiquidityMiner.Permit","name":"permit","type":"tuple"},{"internalType":"string","name":"tokenURI","type":"string"}],"internalType":"struct IAVTLiquidityMiner.Position[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"avtAmount","type":"uint256"}],"name":"increaseLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"round","type":"uint8"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"ownerCompleteRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"avtAmount","type":"uint256"},{"internalType":"uint256","name":"ethAmount","type":"uint256"}],"name":"ownerDrain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerSetAventusPosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"secondsPerRound","type":"uint256"}],"name":"ownerSetRoundDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rewardPot","type":"uint256"}],"name":"ownerStartRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"restake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"","type":"uint8"}],"name":"rewardRounds","outputs":[{"internalType":"uint256","name":"rewardPot","type":"uint256"},{"components":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"address","name":"refundee","type":"address"}],"internalType":"struct IUniswapV3Staker.IncentiveKey","name":"incentive","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"roundDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signedPermit","type":"bytes"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60a06040523060805234801561001457600080fd5b5061001d610022565b6100d4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100725760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d15780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b608051615deb6100fd600039600081816126f60152818161271f01526128cf0152615deb6000f3fe60806040526004361061019a5760003560e01c806375b935d4116100e1578063aa5f7e261161008a578063c5db878511610064578063c5db87851461050e578063cb8173161461052e578063f2fde38b1461055a578063f7cb789a1461057a57600080fd5b8063aa5f7e2614610485578063ad3cb1cc14610498578063bce1b520146104ee57600080fd5b80638129fc1c116100bb5780638129fc1c1461040957806383b43dfd1461041e5780638da5cb5b1461043e57600080fd5b806375b935d4146103a95780637f139d24146103c95780637f48f001146103e957600080fd5b806348c35d461161014357806352d1902d1161011d57806352d1902d1461036c578063696f9c8114610381578063715018a61461039457600080fd5b806348c35d46146103195780634c41c61b146103395780634f1ef2861461035957600080fd5b8063361e45dd11610174578063361e45dd1461023e57806338c50f4d146102625780633eeb530e146102ec57600080fd5b8063150b7a02146101a6578063280a9a4a146101fc578063282252191461021e57600080fd5b366101a157005b600080fd5b3480156101b257600080fd5b506101c66101c1366004614e7d565b610590565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b34801561020857600080fd5b5061021c610217366004614eff565b6105bb565b005b34801561022a57600080fd5b5061021c610239366004614f89565b610968565b34801561024a57600080fd5b5061025460025481565b6040519081526020016101f3565b34801561026e57600080fd5b506102de61027d366004614fbe565b600060208181529181526040908190208054825160a08101845260018301546001600160a01b039081168252600284015481169582019590955260038301549381019390935260048201546060840152600590910154909216608082015282565b6040516101f3929190614fdb565b3480156102f857600080fd5b5061030c610307366004615035565b610ad7565b6040516101f39190615190565b34801561032557600080fd5b5061021c6103343660046152d4565b610ae8565b34801561034557600080fd5b5061021c610354366004615327565b610b3d565b61021c6103673660046153af565b610e66565b34801561037857600080fd5b50610254610e85565b61021c61038f366004615442565b610eb4565b3480156103a057600080fd5b5061021c611151565b3480156103b557600080fd5b5061021c6103c4366004615472565b611165565b3480156103d557600080fd5b506102546103e4366004615327565b611253565b3480156103f557600080fd5b50610254610404366004615442565b61127c565b34801561041557600080fd5b5061021c611297565b34801561042a57600080fd5b5061021c610439366004615327565b6115ef565b34801561044a57600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546040516001600160a01b0390911681526020016101f3565b61021c610493366004615327565b6119fe565b3480156104a457600080fd5b506104e16040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b6040516101f391906154a2565b3480156104fa57600080fd5b5061021c610509366004615327565b611ac9565b34801561051a57600080fd5b5061021c610529366004615327565b611bc1565b34801561053a57600080fd5b506003546105489060ff1681565b60405160ff90911681526020016101f3565b34801561056657600080fd5b5061021c610575366004615035565b611bce565b34801561058657600080fd5b5061025460015481565b7f150b7a02000000000000000000000000000000000000000000000000000000005b95945050505050565b6105c3611c27565b60ff8316600081815260208181526040808320815160a08101835260018201546001600160a01b03908116825260028301548116828601526003830154828501526004808401546060840152600590930154166080820152948452909152812054900361069757600254604051637aa4d5a160e11b815273e34139463ba50bd61336e0c446bd8c0867c6fe659163f549ab42916106649185916004016154b5565b600060405180830381600087803b15801561067e57600080fd5b505af1158015610692573d6000803e3d6000fd5b505050505b81158015906106b857506276a70081606001516106b4919061552c565b4211155b156106ef576040517f29dfa3ce00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b828110156107a957600084848381811061070e5761070e61553f565b90506020020135905073e34139463ba50bd61336e0c446bd8c0867c6fe656001600160a01b031663f549ab4284836040518363ffffffff1660e01b81526004016107599291906154b5565b600060405180830381600087803b15801561077357600080fd5b505af1158015610787573d6000803e3d6000fd5b505050600091825250600560205260409020805460ff191690556001016106f2565b506040517f2f2d783d000000000000000000000000000000000000000000000000000000008152730d88ed6e74bbfd96b831231638b66c05571e824f60048201523060248201526000604482018190529073e34139463ba50bd61336e0c446bd8c0867c6fe6590632f2d783d906064016020604051808303816000875af1158015610838573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061085c9190615555565b60ff86166000908152600460205260408120549192500361088d5760ff851660009081526004602052604090208190555b6040517fb5ada6e40000000000000000000000000000000000000000000000000000000081527fb7ce5dc3fb768be7f1d5162cf10a703ea6de142d2e838a7e01d17ef597267a8c90869073e34139463ba50bd61336e0c446bd8c0867c6fe659063b5ada6e49061090190879060040161556e565b6020604051808303816000875af1158015610920573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109449190615555565b6040805160ff90931683526020830191909152015b60405180910390a15050505050565b610970611c27565b6001600160a01b0383166109b0576040517f9fabe1c100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8115610a3d5760405163a9059cbb60e01b81526001600160a01b038416600482015260248101839052730d88ed6e74bbfd96b831231638b66c05571e824f9063a9059cbb906044016020604051808303816000875af1158015610a17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3b91906155c2565b505b8015610ad2576000836001600160a01b03168260405160006040518083038185875af1925050503d8060008114610a90576040519150601f19603f3d011682016040523d82523d6000602084013e610a95565b606091505b5050905080610ad0576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b505050565b6060610ae282611c9b565b92915050565b610af48484848461220d565b33847f358ab7edfe7bd2dfdc010aed6ecda882fb863d29a1df135e180361cb34391928610b228260016124b1565b60405160ff909116815260200160405180910390a350505050565b610b45611c27565b60025415610c575760035460ff168015610bb05760ff81166000908152602081905260409020600401544211610ba7576040517fa02b848400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bb0816126ae565b600254600754604051633c423f0b60e01b815260048101929092526001600160a01b03166024820152606060448201526000606482015273e34139463ba50bd61336e0c446bd8c0867c6fe6590633c423f0b90608401600060405180830381600087803b158015610c2057600080fd5b505af1158015610c34573d6000803e3d6000fd5b50506007805473ffffffffffffffffffffffffffffffffffffffff191690555050505b60028190558015610e63576040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810182905260009073c36442b4a4522e871399cd717abdd847ab11fe8890636352211e90602401602060405180830381865afa158015610cce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf291906155ef565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081526001600160a01b03821660048201523060248201526044810184905290915073c36442b4a4522e871399cd717abdd847ab11fe88906323b872dd90606401600060405180830381600087803b158015610d7057600080fd5b505af1158015610d84573d6000803e3d6000fd5b50506040517fb88d4fde00000000000000000000000000000000000000000000000000000000815230600482015273e34139463ba50bd61336e0c446bd8c0867c6fe65602482015260448101859052608060648201526000608482015273c36442b4a4522e871399cd717abdd847ab11fe88925063b88d4fde915060a401600060405180830381600087803b158015610e1c57600080fd5b505af1158015610e30573d6000803e3d6000fd5b50506007805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03949094169390931790925550505b50565b610e6e6126eb565b610e77826127bb565b610e8182826127c3565b5050565b6000610e8f6128c4565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b610ebc612926565b610ec5826129a7565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101829052730d88ed6e74bbfd96b831231638b66c05571e824f906323b872dd906064016020604051808303816000875af1158015610f3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6091906155c2565b5060008281526005602081815260408084205460ff16845283825292839020835160a08101855260018201546001600160a01b03908116825260028301548116938201939093526003820154948101949094526004810154606085018190529201541660808301524210156110f557604051637aa4d5a160e11b815273e34139463ba50bd61336e0c446bd8c0867c6fe659063f549ab429061100890849087906004016154b5565b600060405180830381600087803b15801561102257600080fd5b505af1158015611036573d6000803e3d6000fd5b50505050611045838334612a3d565b73c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663b88d4fde3073e34139463ba50bd61336e0c446bd8c0867c6fe658685604051602001611090919061556e565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016110be949392919061560c565b600060405180830381600087803b1580156110d857600080fd5b505af11580156110ec573d6000803e3d6000fd5b50505050611127565b6040517f0be4c53e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50610e8160017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b611159611c27565b6111636000612cd1565b565b61116e826129a7565b60008061117b8484612d4f565b91509150816000146112055760405163a9059cbb60e01b815233600482015260248101839052730d88ed6e74bbfd96b831231638b66c05571e824f9063a9059cbb906044016020604051808303816000875af11580156111df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120391906155c2565b505b61120f3385612e84565b6040805160ff831681526020810184905285917f055177919500243f7dfb7b0021457c2fc3323b25f50cf4599de21f0e472e828c910160405180910390a250505050565b60008061125f83612ffa565b905061126b8382613148565b6103e8610401909102049392505050565b60006112888383613148565b60646065909102049392505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff166000811580156112e25750825b905060008267ffffffffffffffff1660011480156112ff5750303b155b90508115801561130d575080155b15611344576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000166001178555831561138f57845468ff00000000000000001916680100000000000000001785555b6113983361330b565b6113a061331c565b6113a8613324565b62278d006001556040517f095ea7b300000000000000000000000000000000000000000000000000000000815273c36442b4a4522e871399cd717abdd847ab11fe8860048201526000196024820152730d88ed6e74bbfd96b831231638b66c05571e824f9063095ea7b3906044016020604051808303816000875af1158015611435573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145991906155c2565b50604051806080016040528073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156114b7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114df9190810190615663565b8152604080518082018252600181527f3100000000000000000000000000000000000000000000000000000000000000602082810191909152830152469082015273c36442b4a4522e871399cd717abdd847ab11fe886060909101528051601090819061154c9082615752565b50602082015160018201906115619082615752565b50604082015160028201556060909101516003909101805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0390921691909117905583156115e857845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602001610959565b5050505050565b6115f7611c27565b60035460ff16426000821561165d5760ff83166000908152602081905260409020600401548211611654576040517fa02b848400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61165d836126ae565b82600101925082600360006101000a81548160ff021916908360ff1602179055506001548201905060006040518060a00160405280730d88ed6e74bbfd96b831231638b66c05571e824f6001600160a01b0316815260200173cdff6ddfc9e4807c9927fd58708c2ef3484cc3056001600160a01b03168152602001848152602001838152602001306001600160a01b031681525090506040518060400160405280868152602001828152506000808660ff1660ff1681526020019081526020016000206000820151816000015560208201518160010160008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550604082015181600201556060820151816003015560808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505050905050730d88ed6e74bbfd96b831231638b66c05571e824f6001600160a01b03166323b872dd3330886040518463ffffffff1660e01b8152600401611836939291906001600160a01b039384168152919092166020820152604081019190915260600190565b6020604051808303816000875af1158015611855573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187991906155c2565b506040517f095ea7b300000000000000000000000000000000000000000000000000000000815273e34139463ba50bd61336e0c446bd8c0867c6fe65600482015260248101869052730d88ed6e74bbfd96b831231638b66c05571e824f9063095ea7b3906044016020604051808303816000875af11580156118ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192391906155c2565b506040517f5cc5e3d900000000000000000000000000000000000000000000000000000000815273e34139463ba50bd61336e0c446bd8c0867c6fe6590635cc5e3d99061197690849089906004016154b5565b600060405180830381600087803b15801561199057600080fd5b505af11580156119a4573d6000803e3d6000fd5b505050506119b560025460006124b1565b506040805160ff8616815260208101859052908101839052606081018690527faa9a0cc80edfcd2bb4844f1aa12e83fca4b7da9eabe81dd300918a0d743de73990608001610959565b611a06612926565b611a0f816129a7565b600080611a1d836000612d4f565b91509150600082600014611a4857611a36848434612a3d565b611a418460016124b1565b9050611a56565b611a538460006124b1565b90505b6040805160ff80851682528316602082015290810184905284907f3c21daa3b2f153a12fefa37bcc71b37dddfc06ae523edc4e8d5d08489be2ce059060600160405180910390a2505050610e6360017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b611ad2816129a7565b600080611ae0836000612d4f565b9150915081600014611b6a5760405163a9059cbb60e01b815233600482015260248101839052730d88ed6e74bbfd96b831231638b66c05571e824f9063a9059cbb906044016020604051808303816000875af1158015611b44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6891906155c2565b505b827fc5d9622ce8617d64c648843231286e332a549dd6d743153ff856cc62dbbce62482611b988660006124b1565b6040805160ff9384168152929091166020830152810185905260600160405180910390a2505050565b611bc9611c27565b600155565b611bd6611c27565b6001600160a01b038116611c1e576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b610e6381612cd1565b33611c597f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b031614611163576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611c15565b60606000611ca883613334565b6007549091506001600160a01b0390811690841603611cc75792915050565b6001600160a01b038316600090815260066020526040812080548351919291611cf0919061552c565b67ffffffffffffffff811115611d0857611d08615340565b604051908082528060200260200182016040528015611d4157816020015b611d2e614d32565b815260200190600190039081611d265790505b50905060005b8351811015611d8f57838181518110611d6257611d6261553f565b6020026020010151828281518110611d7c57611d7c61553f565b6020908102919091010152600101611d47565b5060005b8254811015612204576000838281548110611db057611db061553f565b90600052602060002001549050600080600080600073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166399fbab88876040518263ffffffff1660e01b8152600401611e0791815260200190565b61018060405180830381865afa158015611e25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e499190615856565b50509950995099509950995050505050506000611e67868686613822565b90506000611e788787878787613900565b905060006040518060400160405280611e908b612ffa565b81526000602091820181905260408051610120810182526003548e8452600590945291205492935091829160ff9182169116148015611ee5575060035460ff1660009081526020819052604090206004015442105b611ef0576002611ef3565b60015b6002811115611f0457611f04615052565b815260008b8152600560209081526040918290205460ff16908301528082018c9052606082018690526080820185905260a08201849052805180820190915283518551875160c090940193839291611f5b9161552c565b611f65919061552c565b8152602001846020015186602001518860200151611f83919061552c565b611f8d919061552c565b905281526040805160a081018252600880546001600160a01b03168252600954602083810191909152600a5483850152600b54606084015283516080818101909552600c805492909601959394929392850192909182908290611fef906156d1565b80601f016020809104026020016040519081016040528092919081815260200182805461201b906156d1565b80156120685780601f1061203d57610100808354040283529160200191612068565b820191906000526020600020905b81548152906001019060200180831161204b57829003601f168201915b50505050508152602001600182018054612081906156d1565b80601f01602080910402602001604051908101604052809291908181526020018280546120ad906156d1565b80156120fa5780601f106120cf576101008083540402835291602001916120fa565b820191906000526020600020905b8154815290600101906020018083116120dd57829003601f168201915b505050918352505060028201546020808301919091526003909201546001600160a01b03166040918201529190925292845291517fc87b56dd000000000000000000000000000000000000000000000000000000008152600481018e9052929091019173c36442b4a4522e871399cd717abdd847ab11fe88915063c87b56dd90602401600060405180830381865afa15801561219a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121c29190810190615663565b8152508b8b8f516121d3919061552c565b815181106121e3576121e361553f565b60200260200101819052505050505050505050508080600101915050611d93565b50949350505050565b6040517f6352211e00000000000000000000000000000000000000000000000000000000815260048101859052339073c36442b4a4522e871399cd717abdd847ab11fe8890636352211e90602401602060405180830381865afa158015612278573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229c91906155ef565b6001600160a01b03161461233257600084815260056020526040902054336101009091046001600160a01b031603612300576040517fd3afc59200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f7c0e1da600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080806040850135811a853560208701356040517f7ac2ff7b000000000000000000000000000000000000000000000000000000008152306004820152602481018b9052604481018a905260ff841660648201526084810183905260a48101829052929550909350915073c36442b4a4522e871399cd717abdd847ab11fe8890637ac2ff7b9060c401600060405180830381600087803b1580156123d657600080fd5b505af11580156123ea573d6000803e3d6000fd5b50506040517fb88d4fde000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018a9052608060648201526000608482015273c36442b4a4522e871399cd717abdd847ab11fe88925063b88d4fde915060a401600060405180830381600087803b15801561246e57600080fd5b505af1158015612482573d6000803e3d6000fd5b505033600090815260066020908152604082208054600181018255908352912001989098555050505050505050565b6003546000838152600560205260409020805460ff9283169216829003612504576040517f3a01a74b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82156126015773c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663b88d4fde3073e34139463ba50bd61336e0c446bd8c0867c6fe65876000808860ff1660ff16815260200190815260200160002060010160405160200161256f9190615938565b6040516020818303038152906040526040518563ffffffff1660e01b815260040161259d949392919061560c565b600060405180830381600087803b1580156125b757600080fd5b505af11580156125cb573d6000803e3d6000fd5b505082547fffffffffffffffffffffff0000000000000000000000000000000000000000ff1633610100021783555061269b9050565b60ff82166000908152602081905260409081902090517ff2d2909b00000000000000000000000000000000000000000000000000000000815273e34139463ba50bd61336e0c446bd8c0867c6fe659163f2d2909b916126689160010190889060040161597b565b600060405180830381600087803b15801561268257600080fd5b505af1158015612696573d6000803e3d6000fd5b505050505b805460ff191660ff831617905592915050565b60ff8116600090815260046020526040902054156126c95750565b6126d560025482613caf565b60ff909116600090815260046020526040902055565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148061278457507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166127787f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b15611163576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e63611c27565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561281d575060408051601f3d908101601f1916820190925261281a91810190615555565b60015b61285e576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401611c15565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc81146128ba576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401611c15565b610ad28383613ddd565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611163576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0080547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016129a1576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60029055565b60008181526005602052604090205461010090046001600160a01b0316806129fb576040517f82141ff000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381163314610e81576040517f7c0e1da600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612a498484613148565b905080821015612a8f576040517fbd8d1c980000000000000000000000000000000000000000000000000000000081526004810183905260248101829052604401611c15565b604051633c423f0b60e01b815260048101859052306024820152606060448201526000606482015273e34139463ba50bd61336e0c446bd8c0867c6fe6590633c423f0b90608401600060405180830381600087803b158015612af057600080fd5b505af1158015612b04573d6000803e3d6000fd5b50505050600073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663219f5d17836040518060c00160405280898152602001888152602001868152602001612b5b8960646063919091020490565b815260200160646063880204815242602091820152604080517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b168152835160048201529183015160248301528201516044820152606082015160648201526080820151608482015260a09091015160a482015260c40160606040518083038185885af1158015612bf5573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612c1a91906159be565b60405190935060009250339150838603908381818185875af1925050503d8060008114612c63576040519150601f19603f3d011682016040523d82523d6000602084013e612c68565b606091505b5050905080612ca3576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505050565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300805473ffffffffffffffffffffffffffffffffffffffff1981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60008281526005602090815260408083205460ff16808452918390528220600401544210612dc057612d80816126ae565b612d8a8482613caf565b60ff82166000908152600460209081526040808320549183905290912054919350612db791849190613e33565b82019150612e7d565b8215612e4b5760ff8116600090815260208190526040908190209051637aa4d5a160e11b815273e34139463ba50bd61336e0c446bd8c0867c6fe659163f549ab4291612e149160010190889060040161597b565b600060405180830381600087803b158015612e2e57600080fd5b505af1158015612e42573d6000803e3d6000fd5b50505050612e7d565b6040517f74201bfa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250929050565b6001600160a01b0382166000908152600660205260408120805490915b81811015612f465783838281548110612ebc57612ebc61553f565b906000526020600020015403612f3e5782612ed86001846159f3565b81548110612ee857612ee861553f565b9060005260206000200154838281548110612f0557612f0561553f565b906000526020600020018190555082805480612f2357612f23615a06565b60019003818190600052602060002001600090559055612f46565b600101612ea1565b5060008381526005602052604080822080547fffffffffffffffffffffff00000000000000000000000000000000000000000016905551633c423f0b60e01b81526004810185905233602482015260606044820152606481019190915273e34139463ba50bd61336e0c446bd8c0867c6fe6590633c423f0b90608401600060405180830381600087803b158015612fdc57600080fd5b505af1158015612ff0573d6000803e3d6000fd5b5050505050505050565b60008181526005602081815260408084205460ff168085528483528185208251808401845281548152835160a08101855260018301546001600160a01b03908116825260028401548116828801526003840154828701526004808501546060840152939097015490961660808701528085019590955281865290925283205490919080156131205760208201516040517fd953186e00000000000000000000000000000000000000000000000000000000815273e34139463ba50bd61336e0c446bd8c0867c6fe659163d953186e916130d8919089906004016154b5565b6040805180830381865afa1580156130f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131189190615a1c565b50935061312f565b61312a8583613e51565b945090505b61313e84828460000151613e33565b6105b2908561552c565b6040517f99fbab88000000000000000000000000000000000000000000000000000000008152600481018390526000908190819073c36442b4a4522e871399cd717abdd847ab11fe88906399fbab889060240161018060405180830381865afa1580156131b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131dd9190615856565b505050505096509650505050505060008073cdff6ddfc9e4807c9927fd58708c2ef3484cc3056001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015613240573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132649190615a54565b5050505050915091508360020b8160020b1215613288576000945050505050610ae2565b8260020b8160020b126132c7576040517f7db3aba700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006132d285614134565b905060006132df85614134565b905060006132ee85838b61458b565b90506132fc858484846145ca565b9b9a5050505050505050505050565b613313614650565b610e63816146b7565b611163614650565b61332c614650565b6111636146bf565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260609060009073c36442b4a4522e871399cd717abdd847ab11fe88906370a0823190602401602060405180830381865afa1580156133ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133cf9190615555565b67ffffffffffffffff8111156133e7576133e7615340565b60405190808252806020026020018201604052801561342057816020015b61340d614d32565b8152602001906001900390816134055790505b5090506000805b8251811015613780576040517f2f745c590000000000000000000000000000000000000000000000000000000081526001600160a01b03861660048201526024810182905260009073c36442b4a4522e871399cd717abdd847ab11fe8890632f745c5990604401602060405180830381865afa1580156134ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134cf9190615555565b905060008060008060008060008073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166399fbab888a6040518263ffffffff1660e01b815260040161351f91815260200190565b61018060405180830381865afa15801561353d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135619190615856565b50509950995099509950995099509950995050506000613582868686613822565b905060006135938787878787613900565b90506fffffffffffffffffffffffffffffffff8516158015906135d257506001600160a01b038a16730d88ed6e74bbfd96b831231638b66c05571e824f145b80156135fa57506001600160a01b03891673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2145b801561360c575062ffffff8816610bb8145b15613769576040805161012081019091528060008152602001600060ff1681526020018c81526020018381526020018281526020016040518060400160405280600081526020016000815250815260200160405180604001604052808460000151866000015161367c919061552c565b815260200184602001518660200151613695919061552c565b905281526020016136a58d6146c7565b81526040517fc87b56dd000000000000000000000000000000000000000000000000000000008152600481018e905260209091019073c36442b4a4522e871399cd717abdd847ab11fe889063c87b56dd90602401600060405180830381865afa158015613716573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261373e9190810190615663565b90528e8e61374b81615ae3565b9f508151811061375d5761375d61553f565b60200260200101819052505b505060019099019850613427975050505050505050565b5060008167ffffffffffffffff81111561379c5761379c615340565b6040519080825280602002602001820160405280156137d557816020015b6137c2614d32565b8152602001906001900390816137ba5790505b50905060005b82811015612204578381815181106137f5576137f561553f565b602002602001015182828151811061380f5761380f61553f565b60209081029190910101526001016137db565b6040805180820190915260008082526020820152600073cdff6ddfc9e4807c9927fd58708c2ef3484cc3056001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa15801561388a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138ae9190615a54565b505050505050905060006138c186614134565b905060006138ce86614134565b90506000806138df8585858a6145ca565b604080518082019091529182526020820152955050505050505b9392505050565b6040805180820190915260008082526020820152836fffffffffffffffffffffffffffffffff16600003613948575060408051808201909152600080825260208201526105b2565b600073cdff6ddfc9e4807c9927fd58708c2ef3484cc3056001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa15801561399c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139c09190615a54565b50506040517ff30dba9300000000000000000000000000000000000000000000000000000000815260028d900b60048201529395506000945073cdff6ddfc9e4807c9927fd58708c2ef3484cc3059363f30dba9393506024019150613a229050565b61010060405180830381865afa158015613a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a649190615b23565b50506040517ff30dba9300000000000000000000000000000000000000000000000000000000815260028e900b60048201529396506000955073cdff6ddfc9e4807c9927fd58708c2ef3484cc305945063f30dba93936024019250613ac7915050565b61010060405180830381865afa158015613ae5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b099190615b23565b505050505092505050600073cdff6ddfc9e4807c9927fd58708c2ef3484cc3056001600160a01b031663f30583996040518163ffffffff1660e01b8152600401602060405180830381865afa158015613b66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b8a9190615555565b905060008060008060008e60020b8960020b1215613bb157613bac88876159f3565b613bb3565b875b94508d60020b8960020b12613bd157613bcc87876159f3565b613bd3565b865b935083613be086886159f3565b613bea91906159f3565b9250613c116fffffffffffffffffffffffffffffffff8e16613c0c8e866159f3565b6148f8565b91508e60020b8960020b1215613c3057613c2b88876159f3565b613c32565b875b94508d60020b8960020b12613c5057613c4b87876159f3565b613c52565b865b935083613c5f86886159f3565b613c6991906159f3565b9250613c8b6fffffffffffffffffffffffffffffffff8e16613c0c8d866159f3565b604080518082019091529283526020830152509d9c50505050505050505050505050565b60ff81166000908152602081905260408082209051637aa4d5a160e11b815273e34139463ba50bd61336e0c446bd8c0867c6fe659163f549ab4291613cfc9160010190879060040161597b565b600060405180830381600087803b158015613d1657600080fd5b505af1158015613d2a573d6000803e3d6000fd5b50506040517f2f2d783d000000000000000000000000000000000000000000000000000000008152730d88ed6e74bbfd96b831231638b66c05571e824f60048201523060248201526000604482015273e34139463ba50bd61336e0c446bd8c0867c6fe659250632f2d783d91506064016020604051808303816000875af1158015613db9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138f99190615555565b613de68261493f565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115613e2b57610ad282826149dc565b610e81614a49565b600082820383850281613e4857613e4861564d565b04949350505050565b60208101516040517fd953186e0000000000000000000000000000000000000000000000000000000081526000918291829173e34139463ba50bd61336e0c446bd8c0867c6fe659163d953186e91613ead9189906004016154b5565b6040805180830381865afa158015613ec9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613eed9190615a1c565b809250819450505060008073e34139463ba50bd61336e0c446bd8c0867c6fe656001600160a01b031663c36c1ea5888860200151604051602001613f31919061556e565b604051602081830303815290604052805190602001206040518363ffffffff1660e01b8152600401613f6d929190918252602082015260400190565b6040805180830381865afa158015613f89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fad9190615bbb565b6040517fb02c43d0000000000000000000000000000000000000000000000000000000008152600481018a9052919350915060009073e34139463ba50bd61336e0c446bd8c0867c6fe659063b02c43d090602401608060405180830381865afa15801561401e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140429190615bf0565b604080820151606083015191517fa38807f2000000000000000000000000000000000000000000000000000000008152600291820b600482015291900b602482015290915060009073cdff6ddfc9e4807c9927fd58708c2ef3484cc3059063a38807f290604401606060405180830381865afa1580156140c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140ea9190615c7e565b50915050600087896000015161410091906159f3565b905061412281878b60200151604001518c6020015160600151888a8842614a81565b50809750505050505050509250929050565b60008060008360020b1261414b578260020b614158565b8260020b61415890615cc3565b9050620d89e88111156141c7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f54000000000000000000000000000000000000000000000000000000000000006044820152606401611c15565b6000816001166000036141eb577001000000000000000000000000000000006141fd565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561423c576080614237826ffff97272373d413259a46990580e213a615cfb565b901c90505b6004821615614266576080614261826ffff2e50f5f656932ef12357cf3c7fdcc615cfb565b901c90505b600882161561429057608061428b826fffe5caca7e10e4e61c3624eaa0941cd0615cfb565b901c90505b60108216156142ba5760806142b5826fffcb9843d60f6159c9db58835c926644615cfb565b901c90505b60208216156142e45760806142df826fff973b41fa98c081472e6896dfb254c0615cfb565b901c90505b604082161561430e576080614309826fff2ea16466c96a3843ec78b326b52861615cfb565b901c90505b6080821615614338576080614333826ffe5dee046a99a2a811c461f1969c3053615cfb565b901c90505b61010082161561436357608061435e826ffcbe86c7900a88aedcffc83b479aa3a4615cfb565b901c90505b61020082161561438e576080614389826ff987a7253ac413176f2b074cf7815e54615cfb565b901c90505b6104008216156143b95760806143b4826ff3392b0822b70005940c7a398e4b70f3615cfb565b901c90505b6108008216156143e45760806143df826fe7159475a2c29b7443b29c7fa6e889d9615cfb565b901c90505b61100082161561440f57608061440a826fd097f3bdfd2022b8845ad8f792aa5825615cfb565b901c90505b61200082161561443a576080614435826fa9f746462d870fdf8a65dc1f90e061e5615cfb565b901c90505b614000821615614465576080614460826f70d869a156d2a1b890bb3df62baf32f7615cfb565b901c90505b61800082161561449057608061448b826f31be135f97d08fd981231505542fcfa6615cfb565b901c90505b620100008216156144bc5760806144b7826f09aa508b5b7a84e1c677de54f3e99bc9615cfb565b901c90505b620200008216156144e75760806144e2826e5d6af8dedb81196699c329225ee604615cfb565b901c90505b6204000082161561451157608061450c826d2216e584f5fa1ea926041bedfe98615cfb565b901c90505b62080000821615614539576080614534826b048a170391f7dc42444e8fa2615cfb565b901c90505b60008460020b13156145545761455181600019615d12565b90505b61456364010000000082615d26565b1561456f576001614572565b60005b6145839060ff16602083901c61552c565b949350505050565b6000806145aa856001600160a01b0316856001600160a01b0316614afe565b90506105b26145c5848387890360ff81901d90810118614b45565b614b52565b8282108383180292831892909118906000806001600160a01b0380861690871611614601576145fa858585614b75565b9150614647565b836001600160a01b0316866001600160a01b03161161463957614625868585614b75565b9150614632858785614bc0565b9050614647565b614644858585614bc0565b90505b94509492505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16611163576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611bd6614650565b612cab614650565b6146cf614dbd565b60106040518060800160405290816000820180546146ec906156d1565b80601f0160208091040260200160405190810160405280929190818152602001828054614718906156d1565b80156147655780601f1061473a57610100808354040283529160200191614765565b820191906000526020600020905b81548152906001019060200180831161474857829003601f168201915b5050505050815260200160018201805461477e906156d1565b80601f01602080910402602001604051908101604052809291908181526020018280546147aa906156d1565b80156147f75780601f106147cc576101008083540402835291602001916147f7565b820191906000526020600020905b8154815290600101906020018083116147da57829003601f168201915b505050918352505060028201546020808301919091526003909201546001600160a01b031660409182015260808401929092523083528201839052517f99fbab880000000000000000000000000000000000000000000000000000000081526004810183905273c36442b4a4522e871399cd717abdd847ab11fe88906399fbab889060240161018060405180830381865afa15801561489a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148be9190615856565b5050506bffffffffffffffffffffffff90981660408a0152506148ee9650610708955042945061552c9350505050565b6060820152919050565b60008282026000198385098181108201900370010000000000000000000000000000000081106149305763ae47f7026000526004601cfd5b608091821c911b179392505050565b806001600160a01b03163b60000361498e576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611c15565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6060600080846001600160a01b0316846040516149f99190615d3a565b600060405180830381855af49150503d8060008114614a34576040519150601f19603f3d011682016040523d82523d6000602084013e614a39565b606091505b50915091506105b2858383614be9565b3415611163576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806fffffffffffffffffffffffffffffffff8616614aa18686615d56565b614aab9190615d75565b905060006001600160a01b038a166080614acd8b878c188c89100288186159f3565b614ad892911b6159f3565b9050614aee8b836001600160a01b031683614b45565b9250509850989650505050505050565b6000828202600019838509818110820190036c010000000000000000000000008110614b325763ae47f7026000526004601cfd5b8060a01b8260601c179250505092915050565b6000614583848484614c5e565b60007001000000000000000000000000000000008210614b7157600080fd5b5090565b6000614583846001600160a01b0316614bbc606060ff16856fffffffffffffffffffffffffffffffff16901b8787036001600160a01b0316876001600160a01b0316614b45565b0490565b6000614583826fffffffffffffffffffffffffffffffff168585036001600160a01b0316614afe565b606082614bfe57614bf982614cf0565b6138f9565b8151158015614c1557506001600160a01b0384163b155b15614c57576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611c15565b50806138f9565b82820281838583041485151702614ce9576000198385098181108201900382848609836000038416828511614c9b5763ae47f7026000526004601cfd5b938490049383821190920360008390038390046001010292030417600260038302811880840282030280840282030280840282030280840282030280840282030280840290910302026138f9565b0492915050565b805115614d005780518082602001fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805161012081018252600080825260208083018290528284018290528351808501855282815280820183905260608401528351808501855282815280820183905260808401528351808501855282815280820183905260a084015283518085019094528184528301529060c08201908152602001614db0614dbd565b8152602001606081525090565b6040518060a0016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001614e21604051806080016040528060608152602001606081526020016000815260200160006001600160a01b031681525090565b905290565b6001600160a01b0381168114610e6357600080fd5b60008083601f840112614e4d57600080fd5b50813567ffffffffffffffff811115614e6557600080fd5b602083019150836020828501011115612e7d57600080fd5b600080600080600060808688031215614e9557600080fd5b8535614ea081614e26565b94506020860135614eb081614e26565b935060408601359250606086013567ffffffffffffffff811115614ed357600080fd5b614edf88828901614e3b565b969995985093965092949392505050565b60ff81168114610e6357600080fd5b600080600060408486031215614f1457600080fd5b8335614f1f81614ef0565b9250602084013567ffffffffffffffff811115614f3b57600080fd5b8401601f81018613614f4c57600080fd5b803567ffffffffffffffff811115614f6357600080fd5b8660208260051b8401011115614f7857600080fd5b939660209190910195509293505050565b600080600060608486031215614f9e57600080fd5b8335614fa981614e26565b95602085013595506040909401359392505050565b600060208284031215614fd057600080fd5b81356138f981614ef0565b82815260c081016138f960208301846001600160a01b0381511682526001600160a01b03602082015116602083015260408101516040830152606081015160608301526001600160a01b0360808201511660808301525050565b60006020828403121561504757600080fd5b81356138f981614e26565b634e487b7160e01b600052602160045260246000fd5b6003811061508657634e487b7160e01b600052602160045260246000fd5b9052565b60005b838110156150a557818101518382015260200161508d565b50506000910152565b600081518084526150c681602086016020860161508a565b601f01601f19169290920160200192915050565b6001600160a01b0381511682526020810151602083015260408101516040830152606081015160608301526000608082015160a060808501528051608060a086015261512a6101208601826150ae565b905060208201517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff608683030160c087015261516582826150ae565b604084015160e08801526060909301516001600160a01b031661010090960195909552509392505050565b6000602082016020835280845180835260408501915060408160051b86010192506020860160005b828110156152c8577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc087860301845281516151f4868251615068565b6020810151615208602088018260ff169052565b5060408101516040870152606081015161522f606088018280518252602090810151910152565b506080810151805160a0880152602081015160c08801525060a0810151805160e088015260208101516101008801525060c0810151805161012088015260208101516101408801525060e08101516101a06101608801526152946101a08801826150da565b905061010082015191508681036101808801526152b181836150ae565b9650505060209384019391909101906001016151b8565b50929695505050505050565b600080600080606085870312156152ea57600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561530f57600080fd5b61531b87828801614e3b565b95989497509550505050565b60006020828403121561533957600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561537f5761537f615340565b604052919050565b600067ffffffffffffffff8211156153a1576153a1615340565b50601f01601f191660200190565b600080604083850312156153c257600080fd5b82356153cd81614e26565b9150602083013567ffffffffffffffff8111156153e957600080fd5b8301601f810185136153fa57600080fd5b803561540d61540882615387565b615356565b81815286602083850101111561542257600080fd5b816020840160208301376000602083830101528093505050509250929050565b6000806040838503121561545557600080fd5b50508035926020909101359150565b8015158114610e6357600080fd5b6000806040838503121561548557600080fd5b82359150602083013561549781615464565b809150509250929050565b6020815260006138f960208301846150ae565b60c0810161550982856001600160a01b0381511682526001600160a01b03602082015116602083015260408101516040830152606081015160608301526001600160a01b0360808201511660808301525050565b8260a08301529392505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610ae257610ae2615516565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561556757600080fd5b5051919050565b60a08101610ae282846001600160a01b0381511682526001600160a01b03602082015116602083015260408101516040830152606081015160608301526001600160a01b0360808201511660808301525050565b6000602082840312156155d457600080fd5b81516138f981615464565b80516155ea81614e26565b919050565b60006020828403121561560157600080fd5b81516138f981614e26565b6001600160a01b03851681526001600160a01b038416602082015282604082015260806060820152600061564360808301846150ae565b9695505050505050565b634e487b7160e01b600052601260045260246000fd5b60006020828403121561567557600080fd5b815167ffffffffffffffff81111561568c57600080fd5b8201601f8101841361569d57600080fd5b80516156ab61540882615387565b8181528560208385010111156156c057600080fd5b6105b282602083016020860161508a565b600181811c908216806156e557607f821691505b60208210810361570557634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610ad257806000526020600020601f840160051c810160208510156157325750805b601f840160051c820191505b818110156115e8576000815560010161573e565b815167ffffffffffffffff81111561576c5761576c615340565b6157808161577a84546156d1565b8461570b565b6020601f8211600181146157b4576000831561579c5750848201515b600019600385901b1c1916600184901b1784556115e8565b600084815260208120601f198516915b828110156157e457878501518255602094850194600190920191016157c4565b50848210156158025786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b805162ffffff811681146155ea57600080fd5b8051600281900b81146155ea57600080fd5b80516fffffffffffffffffffffffffffffffff811681146155ea57600080fd5b6000806000806000806000806000806000806101808d8f03121561587957600080fd5b8c516bffffffffffffffffffffffff8116811461589557600080fd5b9b506158a360208e016155df565b9a506158b160408e016155df565b99506158bf60608e016155df565b98506158cd60808e01615811565b97506158db60a08e01615824565b96506158e960c08e01615824565b95506158f760e08e01615836565b6101008e01516101208f0151919650945092506159176101408e01615836565b91506159266101608e01615836565b90509295989b509295989b509295989b565b81546001600160a01b0390811682526001830154811660208301526002830154604083015260038301546060830152600483015416608082015260a08101610ae2565b82546001600160a01b0390811682526001840154811660208301526002840154604083015260038401546060830152600484015416608082015260c08101615509565b6000806000606084860312156159d357600080fd5b6159dc84615836565b602085015160409095015190969495509392505050565b81810381811115610ae257610ae2615516565b634e487b7160e01b600052603160045260246000fd5b60008060408385031215615a2f57600080fd5b8251602084015190925061549781614e26565b805161ffff811681146155ea57600080fd5b600080600080600080600060e0888a031215615a6f57600080fd5b8751615a7a81614e26565b9650615a8860208901615824565b9550615a9660408901615a42565b9450615aa460608901615a42565b9350615ab260808901615a42565b925060a0880151615ac281614ef0565b60c0890151909250615ad381615464565b8091505092959891949750929550565b60006000198203615af657615af6615516565b5060010190565b8051600681900b81146155ea57600080fd5b805163ffffffff811681146155ea57600080fd5b600080600080600080600080610100898b031215615b4057600080fd5b615b4989615836565b9750602089015180600f0b8114615b5f57600080fd5b60408a015160608b015191985096509450615b7c60808a01615afd565b935060a0890151615b8c81614e26565b9250615b9a60c08a01615b0f565b915060e0890151615baa81615464565b809150509295985092959890939650565b60008060408385031215615bce57600080fd5b8251615bd981614e26565b9150615be760208401615836565b90509250929050565b60006080828403128015615c0357600080fd5b506040516080810167ffffffffffffffff81118282101715615c2757615c27615340565b6040528251615c3581614e26565b8152602083015165ffffffffffff81168114615c5057600080fd5b6020820152615c6160408401615824565b6040820152615c7260608401615824565b60608201529392505050565b600080600060608486031215615c9357600080fd5b615c9c84615afd565b92506020840151615cac81614e26565b9150615cba60408501615b0f565b90509250925092565b60007f80000000000000000000000000000000000000000000000000000000000000008203615cf457615cf4615516565b5060000390565b8082028115828204841417610ae257610ae2615516565b600082615d2157615d2161564d565b500490565b600082615d3557615d3561564d565b500690565b60008251615d4c81846020870161508a565b9190910192915050565b6001600160a01b038281168282160390811115610ae257610ae2615516565b60006001600160a01b0382166001600160a01b0384166001600160a01b038183021692508183048114821517615dad57615dad615516565b50509291505056fea264697066735822122040d718ee9a35dc8cb98c6e6decd024e1e54df57f01588bb3ef3f17fd62f4fe4464736f6c634300081c0033
Deployed Bytecode
0x60806040526004361061019a5760003560e01c806375b935d4116100e1578063aa5f7e261161008a578063c5db878511610064578063c5db87851461050e578063cb8173161461052e578063f2fde38b1461055a578063f7cb789a1461057a57600080fd5b8063aa5f7e2614610485578063ad3cb1cc14610498578063bce1b520146104ee57600080fd5b80638129fc1c116100bb5780638129fc1c1461040957806383b43dfd1461041e5780638da5cb5b1461043e57600080fd5b806375b935d4146103a95780637f139d24146103c95780637f48f001146103e957600080fd5b806348c35d461161014357806352d1902d1161011d57806352d1902d1461036c578063696f9c8114610381578063715018a61461039457600080fd5b806348c35d46146103195780634c41c61b146103395780634f1ef2861461035957600080fd5b8063361e45dd11610174578063361e45dd1461023e57806338c50f4d146102625780633eeb530e146102ec57600080fd5b8063150b7a02146101a6578063280a9a4a146101fc578063282252191461021e57600080fd5b366101a157005b600080fd5b3480156101b257600080fd5b506101c66101c1366004614e7d565b610590565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b34801561020857600080fd5b5061021c610217366004614eff565b6105bb565b005b34801561022a57600080fd5b5061021c610239366004614f89565b610968565b34801561024a57600080fd5b5061025460025481565b6040519081526020016101f3565b34801561026e57600080fd5b506102de61027d366004614fbe565b600060208181529181526040908190208054825160a08101845260018301546001600160a01b039081168252600284015481169582019590955260038301549381019390935260048201546060840152600590910154909216608082015282565b6040516101f3929190614fdb565b3480156102f857600080fd5b5061030c610307366004615035565b610ad7565b6040516101f39190615190565b34801561032557600080fd5b5061021c6103343660046152d4565b610ae8565b34801561034557600080fd5b5061021c610354366004615327565b610b3d565b61021c6103673660046153af565b610e66565b34801561037857600080fd5b50610254610e85565b61021c61038f366004615442565b610eb4565b3480156103a057600080fd5b5061021c611151565b3480156103b557600080fd5b5061021c6103c4366004615472565b611165565b3480156103d557600080fd5b506102546103e4366004615327565b611253565b3480156103f557600080fd5b50610254610404366004615442565b61127c565b34801561041557600080fd5b5061021c611297565b34801561042a57600080fd5b5061021c610439366004615327565b6115ef565b34801561044a57600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546040516001600160a01b0390911681526020016101f3565b61021c610493366004615327565b6119fe565b3480156104a457600080fd5b506104e16040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b6040516101f391906154a2565b3480156104fa57600080fd5b5061021c610509366004615327565b611ac9565b34801561051a57600080fd5b5061021c610529366004615327565b611bc1565b34801561053a57600080fd5b506003546105489060ff1681565b60405160ff90911681526020016101f3565b34801561056657600080fd5b5061021c610575366004615035565b611bce565b34801561058657600080fd5b5061025460015481565b7f150b7a02000000000000000000000000000000000000000000000000000000005b95945050505050565b6105c3611c27565b60ff8316600081815260208181526040808320815160a08101835260018201546001600160a01b03908116825260028301548116828601526003830154828501526004808401546060840152600590930154166080820152948452909152812054900361069757600254604051637aa4d5a160e11b815273e34139463ba50bd61336e0c446bd8c0867c6fe659163f549ab42916106649185916004016154b5565b600060405180830381600087803b15801561067e57600080fd5b505af1158015610692573d6000803e3d6000fd5b505050505b81158015906106b857506276a70081606001516106b4919061552c565b4211155b156106ef576040517f29dfa3ce00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b828110156107a957600084848381811061070e5761070e61553f565b90506020020135905073e34139463ba50bd61336e0c446bd8c0867c6fe656001600160a01b031663f549ab4284836040518363ffffffff1660e01b81526004016107599291906154b5565b600060405180830381600087803b15801561077357600080fd5b505af1158015610787573d6000803e3d6000fd5b505050600091825250600560205260409020805460ff191690556001016106f2565b506040517f2f2d783d000000000000000000000000000000000000000000000000000000008152730d88ed6e74bbfd96b831231638b66c05571e824f60048201523060248201526000604482018190529073e34139463ba50bd61336e0c446bd8c0867c6fe6590632f2d783d906064016020604051808303816000875af1158015610838573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061085c9190615555565b60ff86166000908152600460205260408120549192500361088d5760ff851660009081526004602052604090208190555b6040517fb5ada6e40000000000000000000000000000000000000000000000000000000081527fb7ce5dc3fb768be7f1d5162cf10a703ea6de142d2e838a7e01d17ef597267a8c90869073e34139463ba50bd61336e0c446bd8c0867c6fe659063b5ada6e49061090190879060040161556e565b6020604051808303816000875af1158015610920573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109449190615555565b6040805160ff90931683526020830191909152015b60405180910390a15050505050565b610970611c27565b6001600160a01b0383166109b0576040517f9fabe1c100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8115610a3d5760405163a9059cbb60e01b81526001600160a01b038416600482015260248101839052730d88ed6e74bbfd96b831231638b66c05571e824f9063a9059cbb906044016020604051808303816000875af1158015610a17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3b91906155c2565b505b8015610ad2576000836001600160a01b03168260405160006040518083038185875af1925050503d8060008114610a90576040519150601f19603f3d011682016040523d82523d6000602084013e610a95565b606091505b5050905080610ad0576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b505050565b6060610ae282611c9b565b92915050565b610af48484848461220d565b33847f358ab7edfe7bd2dfdc010aed6ecda882fb863d29a1df135e180361cb34391928610b228260016124b1565b60405160ff909116815260200160405180910390a350505050565b610b45611c27565b60025415610c575760035460ff168015610bb05760ff81166000908152602081905260409020600401544211610ba7576040517fa02b848400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bb0816126ae565b600254600754604051633c423f0b60e01b815260048101929092526001600160a01b03166024820152606060448201526000606482015273e34139463ba50bd61336e0c446bd8c0867c6fe6590633c423f0b90608401600060405180830381600087803b158015610c2057600080fd5b505af1158015610c34573d6000803e3d6000fd5b50506007805473ffffffffffffffffffffffffffffffffffffffff191690555050505b60028190558015610e63576040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810182905260009073c36442b4a4522e871399cd717abdd847ab11fe8890636352211e90602401602060405180830381865afa158015610cce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf291906155ef565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000081526001600160a01b03821660048201523060248201526044810184905290915073c36442b4a4522e871399cd717abdd847ab11fe88906323b872dd90606401600060405180830381600087803b158015610d7057600080fd5b505af1158015610d84573d6000803e3d6000fd5b50506040517fb88d4fde00000000000000000000000000000000000000000000000000000000815230600482015273e34139463ba50bd61336e0c446bd8c0867c6fe65602482015260448101859052608060648201526000608482015273c36442b4a4522e871399cd717abdd847ab11fe88925063b88d4fde915060a401600060405180830381600087803b158015610e1c57600080fd5b505af1158015610e30573d6000803e3d6000fd5b50506007805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03949094169390931790925550505b50565b610e6e6126eb565b610e77826127bb565b610e8182826127c3565b5050565b6000610e8f6128c4565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b610ebc612926565b610ec5826129a7565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101829052730d88ed6e74bbfd96b831231638b66c05571e824f906323b872dd906064016020604051808303816000875af1158015610f3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6091906155c2565b5060008281526005602081815260408084205460ff16845283825292839020835160a08101855260018201546001600160a01b03908116825260028301548116938201939093526003820154948101949094526004810154606085018190529201541660808301524210156110f557604051637aa4d5a160e11b815273e34139463ba50bd61336e0c446bd8c0867c6fe659063f549ab429061100890849087906004016154b5565b600060405180830381600087803b15801561102257600080fd5b505af1158015611036573d6000803e3d6000fd5b50505050611045838334612a3d565b73c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663b88d4fde3073e34139463ba50bd61336e0c446bd8c0867c6fe658685604051602001611090919061556e565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016110be949392919061560c565b600060405180830381600087803b1580156110d857600080fd5b505af11580156110ec573d6000803e3d6000fd5b50505050611127565b6040517f0be4c53e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50610e8160017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b611159611c27565b6111636000612cd1565b565b61116e826129a7565b60008061117b8484612d4f565b91509150816000146112055760405163a9059cbb60e01b815233600482015260248101839052730d88ed6e74bbfd96b831231638b66c05571e824f9063a9059cbb906044016020604051808303816000875af11580156111df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120391906155c2565b505b61120f3385612e84565b6040805160ff831681526020810184905285917f055177919500243f7dfb7b0021457c2fc3323b25f50cf4599de21f0e472e828c910160405180910390a250505050565b60008061125f83612ffa565b905061126b8382613148565b6103e8610401909102049392505050565b60006112888383613148565b60646065909102049392505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff166000811580156112e25750825b905060008267ffffffffffffffff1660011480156112ff5750303b155b90508115801561130d575080155b15611344576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000166001178555831561138f57845468ff00000000000000001916680100000000000000001785555b6113983361330b565b6113a061331c565b6113a8613324565b62278d006001556040517f095ea7b300000000000000000000000000000000000000000000000000000000815273c36442b4a4522e871399cd717abdd847ab11fe8860048201526000196024820152730d88ed6e74bbfd96b831231638b66c05571e824f9063095ea7b3906044016020604051808303816000875af1158015611435573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145991906155c2565b50604051806080016040528073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa1580156114b7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114df9190810190615663565b8152604080518082018252600181527f3100000000000000000000000000000000000000000000000000000000000000602082810191909152830152469082015273c36442b4a4522e871399cd717abdd847ab11fe886060909101528051601090819061154c9082615752565b50602082015160018201906115619082615752565b50604082015160028201556060909101516003909101805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0390921691909117905583156115e857845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602001610959565b5050505050565b6115f7611c27565b60035460ff16426000821561165d5760ff83166000908152602081905260409020600401548211611654576040517fa02b848400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61165d836126ae565b82600101925082600360006101000a81548160ff021916908360ff1602179055506001548201905060006040518060a00160405280730d88ed6e74bbfd96b831231638b66c05571e824f6001600160a01b0316815260200173cdff6ddfc9e4807c9927fd58708c2ef3484cc3056001600160a01b03168152602001848152602001838152602001306001600160a01b031681525090506040518060400160405280868152602001828152506000808660ff1660ff1681526020019081526020016000206000820151816000015560208201518160010160008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550604082015181600201556060820151816003015560808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505050905050730d88ed6e74bbfd96b831231638b66c05571e824f6001600160a01b03166323b872dd3330886040518463ffffffff1660e01b8152600401611836939291906001600160a01b039384168152919092166020820152604081019190915260600190565b6020604051808303816000875af1158015611855573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187991906155c2565b506040517f095ea7b300000000000000000000000000000000000000000000000000000000815273e34139463ba50bd61336e0c446bd8c0867c6fe65600482015260248101869052730d88ed6e74bbfd96b831231638b66c05571e824f9063095ea7b3906044016020604051808303816000875af11580156118ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192391906155c2565b506040517f5cc5e3d900000000000000000000000000000000000000000000000000000000815273e34139463ba50bd61336e0c446bd8c0867c6fe6590635cc5e3d99061197690849089906004016154b5565b600060405180830381600087803b15801561199057600080fd5b505af11580156119a4573d6000803e3d6000fd5b505050506119b560025460006124b1565b506040805160ff8616815260208101859052908101839052606081018690527faa9a0cc80edfcd2bb4844f1aa12e83fca4b7da9eabe81dd300918a0d743de73990608001610959565b611a06612926565b611a0f816129a7565b600080611a1d836000612d4f565b91509150600082600014611a4857611a36848434612a3d565b611a418460016124b1565b9050611a56565b611a538460006124b1565b90505b6040805160ff80851682528316602082015290810184905284907f3c21daa3b2f153a12fefa37bcc71b37dddfc06ae523edc4e8d5d08489be2ce059060600160405180910390a2505050610e6360017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b611ad2816129a7565b600080611ae0836000612d4f565b9150915081600014611b6a5760405163a9059cbb60e01b815233600482015260248101839052730d88ed6e74bbfd96b831231638b66c05571e824f9063a9059cbb906044016020604051808303816000875af1158015611b44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b6891906155c2565b505b827fc5d9622ce8617d64c648843231286e332a549dd6d743153ff856cc62dbbce62482611b988660006124b1565b6040805160ff9384168152929091166020830152810185905260600160405180910390a2505050565b611bc9611c27565b600155565b611bd6611c27565b6001600160a01b038116611c1e576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024015b60405180910390fd5b610e6381612cd1565b33611c597f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b031614611163576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611c15565b60606000611ca883613334565b6007549091506001600160a01b0390811690841603611cc75792915050565b6001600160a01b038316600090815260066020526040812080548351919291611cf0919061552c565b67ffffffffffffffff811115611d0857611d08615340565b604051908082528060200260200182016040528015611d4157816020015b611d2e614d32565b815260200190600190039081611d265790505b50905060005b8351811015611d8f57838181518110611d6257611d6261553f565b6020026020010151828281518110611d7c57611d7c61553f565b6020908102919091010152600101611d47565b5060005b8254811015612204576000838281548110611db057611db061553f565b90600052602060002001549050600080600080600073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166399fbab88876040518263ffffffff1660e01b8152600401611e0791815260200190565b61018060405180830381865afa158015611e25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e499190615856565b50509950995099509950995050505050506000611e67868686613822565b90506000611e788787878787613900565b905060006040518060400160405280611e908b612ffa565b81526000602091820181905260408051610120810182526003548e8452600590945291205492935091829160ff9182169116148015611ee5575060035460ff1660009081526020819052604090206004015442105b611ef0576002611ef3565b60015b6002811115611f0457611f04615052565b815260008b8152600560209081526040918290205460ff16908301528082018c9052606082018690526080820185905260a08201849052805180820190915283518551875160c090940193839291611f5b9161552c565b611f65919061552c565b8152602001846020015186602001518860200151611f83919061552c565b611f8d919061552c565b905281526040805160a081018252600880546001600160a01b03168252600954602083810191909152600a5483850152600b54606084015283516080818101909552600c805492909601959394929392850192909182908290611fef906156d1565b80601f016020809104026020016040519081016040528092919081815260200182805461201b906156d1565b80156120685780601f1061203d57610100808354040283529160200191612068565b820191906000526020600020905b81548152906001019060200180831161204b57829003601f168201915b50505050508152602001600182018054612081906156d1565b80601f01602080910402602001604051908101604052809291908181526020018280546120ad906156d1565b80156120fa5780601f106120cf576101008083540402835291602001916120fa565b820191906000526020600020905b8154815290600101906020018083116120dd57829003601f168201915b505050918352505060028201546020808301919091526003909201546001600160a01b03166040918201529190925292845291517fc87b56dd000000000000000000000000000000000000000000000000000000008152600481018e9052929091019173c36442b4a4522e871399cd717abdd847ab11fe88915063c87b56dd90602401600060405180830381865afa15801561219a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121c29190810190615663565b8152508b8b8f516121d3919061552c565b815181106121e3576121e361553f565b60200260200101819052505050505050505050508080600101915050611d93565b50949350505050565b6040517f6352211e00000000000000000000000000000000000000000000000000000000815260048101859052339073c36442b4a4522e871399cd717abdd847ab11fe8890636352211e90602401602060405180830381865afa158015612278573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061229c91906155ef565b6001600160a01b03161461233257600084815260056020526040902054336101009091046001600160a01b031603612300576040517fd3afc59200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f7c0e1da600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080806040850135811a853560208701356040517f7ac2ff7b000000000000000000000000000000000000000000000000000000008152306004820152602481018b9052604481018a905260ff841660648201526084810183905260a48101829052929550909350915073c36442b4a4522e871399cd717abdd847ab11fe8890637ac2ff7b9060c401600060405180830381600087803b1580156123d657600080fd5b505af11580156123ea573d6000803e3d6000fd5b50506040517fb88d4fde000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018a9052608060648201526000608482015273c36442b4a4522e871399cd717abdd847ab11fe88925063b88d4fde915060a401600060405180830381600087803b15801561246e57600080fd5b505af1158015612482573d6000803e3d6000fd5b505033600090815260066020908152604082208054600181018255908352912001989098555050505050505050565b6003546000838152600560205260409020805460ff9283169216829003612504576040517f3a01a74b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82156126015773c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663b88d4fde3073e34139463ba50bd61336e0c446bd8c0867c6fe65876000808860ff1660ff16815260200190815260200160002060010160405160200161256f9190615938565b6040516020818303038152906040526040518563ffffffff1660e01b815260040161259d949392919061560c565b600060405180830381600087803b1580156125b757600080fd5b505af11580156125cb573d6000803e3d6000fd5b505082547fffffffffffffffffffffff0000000000000000000000000000000000000000ff1633610100021783555061269b9050565b60ff82166000908152602081905260409081902090517ff2d2909b00000000000000000000000000000000000000000000000000000000815273e34139463ba50bd61336e0c446bd8c0867c6fe659163f2d2909b916126689160010190889060040161597b565b600060405180830381600087803b15801561268257600080fd5b505af1158015612696573d6000803e3d6000fd5b505050505b805460ff191660ff831617905592915050565b60ff8116600090815260046020526040902054156126c95750565b6126d560025482613caf565b60ff909116600090815260046020526040902055565b306001600160a01b037f00000000000000000000000052d9614fa68e6221475b45a2d5eaaa94614c1ef616148061278457507f00000000000000000000000052d9614fa68e6221475b45a2d5eaaa94614c1ef66001600160a01b03166127787f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b15611163576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e63611c27565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561281d575060408051601f3d908101601f1916820190925261281a91810190615555565b60015b61285e576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401611c15565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc81146128ba576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401611c15565b610ad28383613ddd565b306001600160a01b037f00000000000000000000000052d9614fa68e6221475b45a2d5eaaa94614c1ef61614611163576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0080547ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016129a1576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60029055565b60008181526005602052604090205461010090046001600160a01b0316806129fb576040517f82141ff000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381163314610e81576040517f7c0e1da600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000612a498484613148565b905080821015612a8f576040517fbd8d1c980000000000000000000000000000000000000000000000000000000081526004810183905260248101829052604401611c15565b604051633c423f0b60e01b815260048101859052306024820152606060448201526000606482015273e34139463ba50bd61336e0c446bd8c0867c6fe6590633c423f0b90608401600060405180830381600087803b158015612af057600080fd5b505af1158015612b04573d6000803e3d6000fd5b50505050600073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b031663219f5d17836040518060c00160405280898152602001888152602001868152602001612b5b8960646063919091020490565b815260200160646063880204815242602091820152604080517fffffffff0000000000000000000000000000000000000000000000000000000060e087901b168152835160048201529183015160248301528201516044820152606082015160648201526080820151608482015260a09091015160a482015260c40160606040518083038185885af1158015612bf5573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612c1a91906159be565b60405190935060009250339150838603908381818185875af1925050503d8060008114612c63576040519150601f19603f3d011682016040523d82523d6000602084013e612c68565b606091505b5050905080612ca3576040517f90b8ec1800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505050565b60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300805473ffffffffffffffffffffffffffffffffffffffff1981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b60008281526005602090815260408083205460ff16808452918390528220600401544210612dc057612d80816126ae565b612d8a8482613caf565b60ff82166000908152600460209081526040808320549183905290912054919350612db791849190613e33565b82019150612e7d565b8215612e4b5760ff8116600090815260208190526040908190209051637aa4d5a160e11b815273e34139463ba50bd61336e0c446bd8c0867c6fe659163f549ab4291612e149160010190889060040161597b565b600060405180830381600087803b158015612e2e57600080fd5b505af1158015612e42573d6000803e3d6000fd5b50505050612e7d565b6040517f74201bfa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9250929050565b6001600160a01b0382166000908152600660205260408120805490915b81811015612f465783838281548110612ebc57612ebc61553f565b906000526020600020015403612f3e5782612ed86001846159f3565b81548110612ee857612ee861553f565b9060005260206000200154838281548110612f0557612f0561553f565b906000526020600020018190555082805480612f2357612f23615a06565b60019003818190600052602060002001600090559055612f46565b600101612ea1565b5060008381526005602052604080822080547fffffffffffffffffffffff00000000000000000000000000000000000000000016905551633c423f0b60e01b81526004810185905233602482015260606044820152606481019190915273e34139463ba50bd61336e0c446bd8c0867c6fe6590633c423f0b90608401600060405180830381600087803b158015612fdc57600080fd5b505af1158015612ff0573d6000803e3d6000fd5b5050505050505050565b60008181526005602081815260408084205460ff168085528483528185208251808401845281548152835160a08101855260018301546001600160a01b03908116825260028401548116828801526003840154828701526004808501546060840152939097015490961660808701528085019590955281865290925283205490919080156131205760208201516040517fd953186e00000000000000000000000000000000000000000000000000000000815273e34139463ba50bd61336e0c446bd8c0867c6fe659163d953186e916130d8919089906004016154b5565b6040805180830381865afa1580156130f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131189190615a1c565b50935061312f565b61312a8583613e51565b945090505b61313e84828460000151613e33565b6105b2908561552c565b6040517f99fbab88000000000000000000000000000000000000000000000000000000008152600481018390526000908190819073c36442b4a4522e871399cd717abdd847ab11fe88906399fbab889060240161018060405180830381865afa1580156131b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131dd9190615856565b505050505096509650505050505060008073cdff6ddfc9e4807c9927fd58708c2ef3484cc3056001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015613240573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132649190615a54565b5050505050915091508360020b8160020b1215613288576000945050505050610ae2565b8260020b8160020b126132c7576040517f7db3aba700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006132d285614134565b905060006132df85614134565b905060006132ee85838b61458b565b90506132fc858484846145ca565b9b9a5050505050505050505050565b613313614650565b610e63816146b7565b611163614650565b61332c614650565b6111636146bf565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260609060009073c36442b4a4522e871399cd717abdd847ab11fe88906370a0823190602401602060405180830381865afa1580156133ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133cf9190615555565b67ffffffffffffffff8111156133e7576133e7615340565b60405190808252806020026020018201604052801561342057816020015b61340d614d32565b8152602001906001900390816134055790505b5090506000805b8251811015613780576040517f2f745c590000000000000000000000000000000000000000000000000000000081526001600160a01b03861660048201526024810182905260009073c36442b4a4522e871399cd717abdd847ab11fe8890632f745c5990604401602060405180830381865afa1580156134ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134cf9190615555565b905060008060008060008060008073c36442b4a4522e871399cd717abdd847ab11fe886001600160a01b03166399fbab888a6040518263ffffffff1660e01b815260040161351f91815260200190565b61018060405180830381865afa15801561353d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135619190615856565b50509950995099509950995099509950995050506000613582868686613822565b905060006135938787878787613900565b90506fffffffffffffffffffffffffffffffff8516158015906135d257506001600160a01b038a16730d88ed6e74bbfd96b831231638b66c05571e824f145b80156135fa57506001600160a01b03891673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2145b801561360c575062ffffff8816610bb8145b15613769576040805161012081019091528060008152602001600060ff1681526020018c81526020018381526020018281526020016040518060400160405280600081526020016000815250815260200160405180604001604052808460000151866000015161367c919061552c565b815260200184602001518660200151613695919061552c565b905281526020016136a58d6146c7565b81526040517fc87b56dd000000000000000000000000000000000000000000000000000000008152600481018e905260209091019073c36442b4a4522e871399cd717abdd847ab11fe889063c87b56dd90602401600060405180830381865afa158015613716573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261373e9190810190615663565b90528e8e61374b81615ae3565b9f508151811061375d5761375d61553f565b60200260200101819052505b505060019099019850613427975050505050505050565b5060008167ffffffffffffffff81111561379c5761379c615340565b6040519080825280602002602001820160405280156137d557816020015b6137c2614d32565b8152602001906001900390816137ba5790505b50905060005b82811015612204578381815181106137f5576137f561553f565b602002602001015182828151811061380f5761380f61553f565b60209081029190910101526001016137db565b6040805180820190915260008082526020820152600073cdff6ddfc9e4807c9927fd58708c2ef3484cc3056001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa15801561388a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138ae9190615a54565b505050505050905060006138c186614134565b905060006138ce86614134565b90506000806138df8585858a6145ca565b604080518082019091529182526020820152955050505050505b9392505050565b6040805180820190915260008082526020820152836fffffffffffffffffffffffffffffffff16600003613948575060408051808201909152600080825260208201526105b2565b600073cdff6ddfc9e4807c9927fd58708c2ef3484cc3056001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa15801561399c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139c09190615a54565b50506040517ff30dba9300000000000000000000000000000000000000000000000000000000815260028d900b60048201529395506000945073cdff6ddfc9e4807c9927fd58708c2ef3484cc3059363f30dba9393506024019150613a229050565b61010060405180830381865afa158015613a40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a649190615b23565b50506040517ff30dba9300000000000000000000000000000000000000000000000000000000815260028e900b60048201529396506000955073cdff6ddfc9e4807c9927fd58708c2ef3484cc305945063f30dba93936024019250613ac7915050565b61010060405180830381865afa158015613ae5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b099190615b23565b505050505092505050600073cdff6ddfc9e4807c9927fd58708c2ef3484cc3056001600160a01b031663f30583996040518163ffffffff1660e01b8152600401602060405180830381865afa158015613b66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b8a9190615555565b905060008060008060008e60020b8960020b1215613bb157613bac88876159f3565b613bb3565b875b94508d60020b8960020b12613bd157613bcc87876159f3565b613bd3565b865b935083613be086886159f3565b613bea91906159f3565b9250613c116fffffffffffffffffffffffffffffffff8e16613c0c8e866159f3565b6148f8565b91508e60020b8960020b1215613c3057613c2b88876159f3565b613c32565b875b94508d60020b8960020b12613c5057613c4b87876159f3565b613c52565b865b935083613c5f86886159f3565b613c6991906159f3565b9250613c8b6fffffffffffffffffffffffffffffffff8e16613c0c8d866159f3565b604080518082019091529283526020830152509d9c50505050505050505050505050565b60ff81166000908152602081905260408082209051637aa4d5a160e11b815273e34139463ba50bd61336e0c446bd8c0867c6fe659163f549ab4291613cfc9160010190879060040161597b565b600060405180830381600087803b158015613d1657600080fd5b505af1158015613d2a573d6000803e3d6000fd5b50506040517f2f2d783d000000000000000000000000000000000000000000000000000000008152730d88ed6e74bbfd96b831231638b66c05571e824f60048201523060248201526000604482015273e34139463ba50bd61336e0c446bd8c0867c6fe659250632f2d783d91506064016020604051808303816000875af1158015613db9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138f99190615555565b613de68261493f565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115613e2b57610ad282826149dc565b610e81614a49565b600082820383850281613e4857613e4861564d565b04949350505050565b60208101516040517fd953186e0000000000000000000000000000000000000000000000000000000081526000918291829173e34139463ba50bd61336e0c446bd8c0867c6fe659163d953186e91613ead9189906004016154b5565b6040805180830381865afa158015613ec9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613eed9190615a1c565b809250819450505060008073e34139463ba50bd61336e0c446bd8c0867c6fe656001600160a01b031663c36c1ea5888860200151604051602001613f31919061556e565b604051602081830303815290604052805190602001206040518363ffffffff1660e01b8152600401613f6d929190918252602082015260400190565b6040805180830381865afa158015613f89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613fad9190615bbb565b6040517fb02c43d0000000000000000000000000000000000000000000000000000000008152600481018a9052919350915060009073e34139463ba50bd61336e0c446bd8c0867c6fe659063b02c43d090602401608060405180830381865afa15801561401e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140429190615bf0565b604080820151606083015191517fa38807f2000000000000000000000000000000000000000000000000000000008152600291820b600482015291900b602482015290915060009073cdff6ddfc9e4807c9927fd58708c2ef3484cc3059063a38807f290604401606060405180830381865afa1580156140c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906140ea9190615c7e565b50915050600087896000015161410091906159f3565b905061412281878b60200151604001518c6020015160600151888a8842614a81565b50809750505050505050509250929050565b60008060008360020b1261414b578260020b614158565b8260020b61415890615cc3565b9050620d89e88111156141c7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f54000000000000000000000000000000000000000000000000000000000000006044820152606401611c15565b6000816001166000036141eb577001000000000000000000000000000000006141fd565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561423c576080614237826ffff97272373d413259a46990580e213a615cfb565b901c90505b6004821615614266576080614261826ffff2e50f5f656932ef12357cf3c7fdcc615cfb565b901c90505b600882161561429057608061428b826fffe5caca7e10e4e61c3624eaa0941cd0615cfb565b901c90505b60108216156142ba5760806142b5826fffcb9843d60f6159c9db58835c926644615cfb565b901c90505b60208216156142e45760806142df826fff973b41fa98c081472e6896dfb254c0615cfb565b901c90505b604082161561430e576080614309826fff2ea16466c96a3843ec78b326b52861615cfb565b901c90505b6080821615614338576080614333826ffe5dee046a99a2a811c461f1969c3053615cfb565b901c90505b61010082161561436357608061435e826ffcbe86c7900a88aedcffc83b479aa3a4615cfb565b901c90505b61020082161561438e576080614389826ff987a7253ac413176f2b074cf7815e54615cfb565b901c90505b6104008216156143b95760806143b4826ff3392b0822b70005940c7a398e4b70f3615cfb565b901c90505b6108008216156143e45760806143df826fe7159475a2c29b7443b29c7fa6e889d9615cfb565b901c90505b61100082161561440f57608061440a826fd097f3bdfd2022b8845ad8f792aa5825615cfb565b901c90505b61200082161561443a576080614435826fa9f746462d870fdf8a65dc1f90e061e5615cfb565b901c90505b614000821615614465576080614460826f70d869a156d2a1b890bb3df62baf32f7615cfb565b901c90505b61800082161561449057608061448b826f31be135f97d08fd981231505542fcfa6615cfb565b901c90505b620100008216156144bc5760806144b7826f09aa508b5b7a84e1c677de54f3e99bc9615cfb565b901c90505b620200008216156144e75760806144e2826e5d6af8dedb81196699c329225ee604615cfb565b901c90505b6204000082161561451157608061450c826d2216e584f5fa1ea926041bedfe98615cfb565b901c90505b62080000821615614539576080614534826b048a170391f7dc42444e8fa2615cfb565b901c90505b60008460020b13156145545761455181600019615d12565b90505b61456364010000000082615d26565b1561456f576001614572565b60005b6145839060ff16602083901c61552c565b949350505050565b6000806145aa856001600160a01b0316856001600160a01b0316614afe565b90506105b26145c5848387890360ff81901d90810118614b45565b614b52565b8282108383180292831892909118906000806001600160a01b0380861690871611614601576145fa858585614b75565b9150614647565b836001600160a01b0316866001600160a01b03161161463957614625868585614b75565b9150614632858785614bc0565b9050614647565b614644858585614bc0565b90505b94509492505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16611163576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611bd6614650565b612cab614650565b6146cf614dbd565b60106040518060800160405290816000820180546146ec906156d1565b80601f0160208091040260200160405190810160405280929190818152602001828054614718906156d1565b80156147655780601f1061473a57610100808354040283529160200191614765565b820191906000526020600020905b81548152906001019060200180831161474857829003601f168201915b5050505050815260200160018201805461477e906156d1565b80601f01602080910402602001604051908101604052809291908181526020018280546147aa906156d1565b80156147f75780601f106147cc576101008083540402835291602001916147f7565b820191906000526020600020905b8154815290600101906020018083116147da57829003601f168201915b505050918352505060028201546020808301919091526003909201546001600160a01b031660409182015260808401929092523083528201839052517f99fbab880000000000000000000000000000000000000000000000000000000081526004810183905273c36442b4a4522e871399cd717abdd847ab11fe88906399fbab889060240161018060405180830381865afa15801561489a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148be9190615856565b5050506bffffffffffffffffffffffff90981660408a0152506148ee9650610708955042945061552c9350505050565b6060820152919050565b60008282026000198385098181108201900370010000000000000000000000000000000081106149305763ae47f7026000526004601cfd5b608091821c911b179392505050565b806001600160a01b03163b60000361498e576040517f4c9c8ce30000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611c15565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6060600080846001600160a01b0316846040516149f99190615d3a565b600060405180830381855af49150503d8060008114614a34576040519150601f19603f3d011682016040523d82523d6000602084013e614a39565b606091505b50915091506105b2858383614be9565b3415611163576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806fffffffffffffffffffffffffffffffff8616614aa18686615d56565b614aab9190615d75565b905060006001600160a01b038a166080614acd8b878c188c89100288186159f3565b614ad892911b6159f3565b9050614aee8b836001600160a01b031683614b45565b9250509850989650505050505050565b6000828202600019838509818110820190036c010000000000000000000000008110614b325763ae47f7026000526004601cfd5b8060a01b8260601c179250505092915050565b6000614583848484614c5e565b60007001000000000000000000000000000000008210614b7157600080fd5b5090565b6000614583846001600160a01b0316614bbc606060ff16856fffffffffffffffffffffffffffffffff16901b8787036001600160a01b0316876001600160a01b0316614b45565b0490565b6000614583826fffffffffffffffffffffffffffffffff168585036001600160a01b0316614afe565b606082614bfe57614bf982614cf0565b6138f9565b8151158015614c1557506001600160a01b0384163b155b15614c57576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611c15565b50806138f9565b82820281838583041485151702614ce9576000198385098181108201900382848609836000038416828511614c9b5763ae47f7026000526004601cfd5b938490049383821190920360008390038390046001010292030417600260038302811880840282030280840282030280840282030280840282030280840282030280840290910302026138f9565b0492915050565b805115614d005780518082602001fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805161012081018252600080825260208083018290528284018290528351808501855282815280820183905260608401528351808501855282815280820183905260808401528351808501855282815280820183905260a084015283518085019094528184528301529060c08201908152602001614db0614dbd565b8152602001606081525090565b6040518060a0016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001614e21604051806080016040528060608152602001606081526020016000815260200160006001600160a01b031681525090565b905290565b6001600160a01b0381168114610e6357600080fd5b60008083601f840112614e4d57600080fd5b50813567ffffffffffffffff811115614e6557600080fd5b602083019150836020828501011115612e7d57600080fd5b600080600080600060808688031215614e9557600080fd5b8535614ea081614e26565b94506020860135614eb081614e26565b935060408601359250606086013567ffffffffffffffff811115614ed357600080fd5b614edf88828901614e3b565b969995985093965092949392505050565b60ff81168114610e6357600080fd5b600080600060408486031215614f1457600080fd5b8335614f1f81614ef0565b9250602084013567ffffffffffffffff811115614f3b57600080fd5b8401601f81018613614f4c57600080fd5b803567ffffffffffffffff811115614f6357600080fd5b8660208260051b8401011115614f7857600080fd5b939660209190910195509293505050565b600080600060608486031215614f9e57600080fd5b8335614fa981614e26565b95602085013595506040909401359392505050565b600060208284031215614fd057600080fd5b81356138f981614ef0565b82815260c081016138f960208301846001600160a01b0381511682526001600160a01b03602082015116602083015260408101516040830152606081015160608301526001600160a01b0360808201511660808301525050565b60006020828403121561504757600080fd5b81356138f981614e26565b634e487b7160e01b600052602160045260246000fd5b6003811061508657634e487b7160e01b600052602160045260246000fd5b9052565b60005b838110156150a557818101518382015260200161508d565b50506000910152565b600081518084526150c681602086016020860161508a565b601f01601f19169290920160200192915050565b6001600160a01b0381511682526020810151602083015260408101516040830152606081015160608301526000608082015160a060808501528051608060a086015261512a6101208601826150ae565b905060208201517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff608683030160c087015261516582826150ae565b604084015160e08801526060909301516001600160a01b031661010090960195909552509392505050565b6000602082016020835280845180835260408501915060408160051b86010192506020860160005b828110156152c8577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc087860301845281516151f4868251615068565b6020810151615208602088018260ff169052565b5060408101516040870152606081015161522f606088018280518252602090810151910152565b506080810151805160a0880152602081015160c08801525060a0810151805160e088015260208101516101008801525060c0810151805161012088015260208101516101408801525060e08101516101a06101608801526152946101a08801826150da565b905061010082015191508681036101808801526152b181836150ae565b9650505060209384019391909101906001016151b8565b50929695505050505050565b600080600080606085870312156152ea57600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561530f57600080fd5b61531b87828801614e3b565b95989497509550505050565b60006020828403121561533957600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561537f5761537f615340565b604052919050565b600067ffffffffffffffff8211156153a1576153a1615340565b50601f01601f191660200190565b600080604083850312156153c257600080fd5b82356153cd81614e26565b9150602083013567ffffffffffffffff8111156153e957600080fd5b8301601f810185136153fa57600080fd5b803561540d61540882615387565b615356565b81815286602083850101111561542257600080fd5b816020840160208301376000602083830101528093505050509250929050565b6000806040838503121561545557600080fd5b50508035926020909101359150565b8015158114610e6357600080fd5b6000806040838503121561548557600080fd5b82359150602083013561549781615464565b809150509250929050565b6020815260006138f960208301846150ae565b60c0810161550982856001600160a01b0381511682526001600160a01b03602082015116602083015260408101516040830152606081015160608301526001600160a01b0360808201511660808301525050565b8260a08301529392505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610ae257610ae2615516565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561556757600080fd5b5051919050565b60a08101610ae282846001600160a01b0381511682526001600160a01b03602082015116602083015260408101516040830152606081015160608301526001600160a01b0360808201511660808301525050565b6000602082840312156155d457600080fd5b81516138f981615464565b80516155ea81614e26565b919050565b60006020828403121561560157600080fd5b81516138f981614e26565b6001600160a01b03851681526001600160a01b038416602082015282604082015260806060820152600061564360808301846150ae565b9695505050505050565b634e487b7160e01b600052601260045260246000fd5b60006020828403121561567557600080fd5b815167ffffffffffffffff81111561568c57600080fd5b8201601f8101841361569d57600080fd5b80516156ab61540882615387565b8181528560208385010111156156c057600080fd5b6105b282602083016020860161508a565b600181811c908216806156e557607f821691505b60208210810361570557634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610ad257806000526020600020601f840160051c810160208510156157325750805b601f840160051c820191505b818110156115e8576000815560010161573e565b815167ffffffffffffffff81111561576c5761576c615340565b6157808161577a84546156d1565b8461570b565b6020601f8211600181146157b4576000831561579c5750848201515b600019600385901b1c1916600184901b1784556115e8565b600084815260208120601f198516915b828110156157e457878501518255602094850194600190920191016157c4565b50848210156158025786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b805162ffffff811681146155ea57600080fd5b8051600281900b81146155ea57600080fd5b80516fffffffffffffffffffffffffffffffff811681146155ea57600080fd5b6000806000806000806000806000806000806101808d8f03121561587957600080fd5b8c516bffffffffffffffffffffffff8116811461589557600080fd5b9b506158a360208e016155df565b9a506158b160408e016155df565b99506158bf60608e016155df565b98506158cd60808e01615811565b97506158db60a08e01615824565b96506158e960c08e01615824565b95506158f760e08e01615836565b6101008e01516101208f0151919650945092506159176101408e01615836565b91506159266101608e01615836565b90509295989b509295989b509295989b565b81546001600160a01b0390811682526001830154811660208301526002830154604083015260038301546060830152600483015416608082015260a08101610ae2565b82546001600160a01b0390811682526001840154811660208301526002840154604083015260038401546060830152600484015416608082015260c08101615509565b6000806000606084860312156159d357600080fd5b6159dc84615836565b602085015160409095015190969495509392505050565b81810381811115610ae257610ae2615516565b634e487b7160e01b600052603160045260246000fd5b60008060408385031215615a2f57600080fd5b8251602084015190925061549781614e26565b805161ffff811681146155ea57600080fd5b600080600080600080600060e0888a031215615a6f57600080fd5b8751615a7a81614e26565b9650615a8860208901615824565b9550615a9660408901615a42565b9450615aa460608901615a42565b9350615ab260808901615a42565b925060a0880151615ac281614ef0565b60c0890151909250615ad381615464565b8091505092959891949750929550565b60006000198203615af657615af6615516565b5060010190565b8051600681900b81146155ea57600080fd5b805163ffffffff811681146155ea57600080fd5b600080600080600080600080610100898b031215615b4057600080fd5b615b4989615836565b9750602089015180600f0b8114615b5f57600080fd5b60408a015160608b015191985096509450615b7c60808a01615afd565b935060a0890151615b8c81614e26565b9250615b9a60c08a01615b0f565b915060e0890151615baa81615464565b809150509295985092959890939650565b60008060408385031215615bce57600080fd5b8251615bd981614e26565b9150615be760208401615836565b90509250929050565b60006080828403128015615c0357600080fd5b506040516080810167ffffffffffffffff81118282101715615c2757615c27615340565b6040528251615c3581614e26565b8152602083015165ffffffffffff81168114615c5057600080fd5b6020820152615c6160408401615824565b6040820152615c7260608401615824565b60608201529392505050565b600080600060608486031215615c9357600080fd5b615c9c84615afd565b92506020840151615cac81614e26565b9150615cba60408501615b0f565b90509250925092565b60007f80000000000000000000000000000000000000000000000000000000000000008203615cf457615cf4615516565b5060000390565b8082028115828204841417610ae257610ae2615516565b600082615d2157615d2161564d565b500490565b600082615d3557615d3561564d565b500690565b60008251615d4c81846020870161508a565b9190910192915050565b6001600160a01b038281168282160390811115610ae257610ae2615516565b60006001600160a01b0382166001600160a01b0384166001600160a01b038183021692508183048114821517615dad57615dad615516565b50509291505056fea264697066735822122040d718ee9a35dc8cb98c6e6decd024e1e54df57f01588bb3ef3f17fd62f4fe4464736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.