More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 282 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Set Burn Limit W... | 21754893 | 17 days ago | IN | 0 ETH | 0.00014384 | ||||
Set Burn Commit ... | 21754889 | 17 days ago | IN | 0 ETH | 0.00014739 | ||||
Commit Burn | 21754834 | 17 days ago | IN | 0 ETH | 0.00107668 | ||||
Commit Burn | 21754787 | 17 days ago | IN | 0 ETH | 0.00097112 | ||||
Commit Burn | 21754747 | 17 days ago | IN | 0 ETH | 0.00064491 | ||||
Commit Burn | 21754701 | 17 days ago | IN | 0 ETH | 0.00078346 | ||||
Commit Burn | 21754667 | 17 days ago | IN | 0 ETH | 0.00041041 | ||||
Commit Burn | 21754601 | 17 days ago | IN | 0 ETH | 0.0005721 | ||||
Commit Burn | 21754543 | 17 days ago | IN | 0 ETH | 0.00065565 | ||||
Commit Burn | 21754502 | 17 days ago | IN | 0 ETH | 0.00073659 | ||||
Set Burn Commit ... | 21754492 | 17 days ago | IN | 0 ETH | 0.00009664 | ||||
Commit Burn | 21754444 | 17 days ago | IN | 0 ETH | 0.00059808 | ||||
Commit Burn | 21754403 | 17 days ago | IN | 0 ETH | 0.00067606 | ||||
Set Burn Limit W... | 21754397 | 17 days ago | IN | 0 ETH | 0.00008149 | ||||
Commit Burn | 21753572 | 17 days ago | IN | 0 ETH | 0.00083123 | ||||
Commit Burn | 21753535 | 17 days ago | IN | 0 ETH | 0.0005421 | ||||
Set Burn Commit ... | 21753532 | 17 days ago | IN | 0 ETH | 0.00007875 | ||||
Commit Burn | 21753486 | 17 days ago | IN | 0 ETH | 0.00046422 | ||||
Commit Burn | 21753448 | 17 days ago | IN | 0 ETH | 0.00051418 | ||||
Commit Burn | 21753393 | 17 days ago | IN | 0 ETH | 0.00051499 | ||||
Commit Burn | 21753354 | 17 days ago | IN | 0 ETH | 0.00060224 | ||||
Commit Burn | 21753316 | 17 days ago | IN | 0 ETH | 0.000536 | ||||
Commit Burn | 21752676 | 17 days ago | IN | 0 ETH | 0.00066816 | ||||
Commit Burn | 21752637 | 17 days ago | IN | 0 ETH | 0.00069449 | ||||
Commit Burn | 21752595 | 17 days ago | IN | 0 ETH | 0.00078741 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
21754834 | 17 days ago | 0.021175 ETH | ||||
21754834 | 17 days ago | 0.021175 ETH | ||||
21754787 | 17 days ago | 0.021175 ETH | ||||
21754787 | 17 days ago | 0.021175 ETH | ||||
21754747 | 17 days ago | 0.021175 ETH | ||||
21754747 | 17 days ago | 0.021175 ETH | ||||
21754701 | 17 days ago | 0.021175 ETH | ||||
21754701 | 17 days ago | 0.021175 ETH | ||||
21754667 | 17 days ago | 0.021175 ETH | ||||
21754667 | 17 days ago | 0.021175 ETH | ||||
21754601 | 17 days ago | 0.021175 ETH | ||||
21754601 | 17 days ago | 0.021175 ETH | ||||
21754543 | 17 days ago | 0.021175 ETH | ||||
21754543 | 17 days ago | 0.021175 ETH | ||||
21754502 | 17 days ago | 0.021175 ETH | ||||
21754502 | 17 days ago | 0.021175 ETH | ||||
21754444 | 17 days ago | 0.02156 ETH | ||||
21754444 | 17 days ago | 0.02156 ETH | ||||
21754403 | 17 days ago | 0.02156 ETH | ||||
21754403 | 17 days ago | 0.02156 ETH | ||||
21753572 | 17 days ago | 0.0266 ETH | ||||
21753572 | 17 days ago | 0.0266 ETH | ||||
21753535 | 17 days ago | 0.0266 ETH | ||||
21753535 | 17 days ago | 0.0266 ETH | ||||
21753486 | 17 days ago | 0.0285 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
BuyAndBurn
Compiler Version
v0.8.22+commit.4fc1097e
Optimization Enabled:
No with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.22; import {Pulsar} from './Pulsar.sol'; import {IWeth} from './external/weth/IWeth.sol'; import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {ReentrancyGuard} from '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; import {IUniswapV3Pool} from '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol'; import {INonfungiblePositionManager} from '@uniswap/v3-periphery/contracts/interfaces/INonfungiblePositionManager.sol'; import {IUniswapV3Factory} from '@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol'; import {TransferHelper} from '@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol'; import {PoolAddress} from '@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol'; import {CallbackValidation} from '@uniswap/v3-periphery/contracts/libraries/CallbackValidation.sol'; import {PoolAddress} from '@uniswap/v3-periphery/contracts/libraries/PoolAddress.sol'; import {TransferHelper} from '@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol'; import {TickMath} from '@uniswap/v3-core/contracts/libraries/TickMath.sol'; import {FullMath} from '@uniswap/v3-core/contracts/libraries/FullMath.sol'; import {ISwapRouter} from '@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol'; import {SignatureVerification} from './SignatureVerification.sol'; struct UniswapCallbackData { address token0; address token1; } error PaymentRequired(); error IncorrectFee(); error InvalidRecipient(); abstract contract GenesisAmount is Ownable { struct GenesisMember { address member; uint16 basisPoints; } struct GenesisMemberData { address member; uint256 basisPoints; uint256 withdrawn; uint256 available; } uint256 internal _accumulated; mapping(address account => uint256 data) internal _genesisMembers; constructor(GenesisMember[] memory _genesis) payable Ownable(msg.sender) { // assign genesis addresses and amounts uint256 total; uint256 i; uint256 len = _genesis.length; do { _genesisMembers[_genesis[i].member] = _genesis[i].basisPoints; unchecked { total += _genesis[i].basisPoints; ++i; } } while (i < len); if (total != 10_000) { revert IncorrectFee(); } } function _incrementAccumulated(uint256 amount) internal { unchecked { _accumulated += amount; } } function _genesisSettings(address member) internal view returns (GenesisMemberData memory gmd) { unchecked { uint256 genesisSetting = _genesisMembers[member]; gmd.basisPoints = uint256(uint16(genesisSetting)); if (gmd.basisPoints == 0) { return gmd; } gmd.member = member; gmd.withdrawn = uint256(uint240(genesisSetting >> 16)); gmd.available = _available(_accumulated, gmd.basisPoints, gmd.withdrawn); } } function _incrementWithdrawn(GenesisMemberData memory gmd, uint256 amount) internal { _genesisMembers[gmd.member] = (((gmd.withdrawn + amount) << 16) | gmd.basisPoints); } function _available(uint256 accumulatedNow, uint256 basisPoints, uint256 withdrawn) internal pure returns (uint256) { return ((accumulatedNow * basisPoints) / 10_000) - withdrawn; } function distributeFeeTo(address recipient, uint256 amount) external { GenesisMemberData memory gmd = _genesisSettings(msg.sender); amount = amount > gmd.available ? gmd.available : amount; if (amount == 0) { return; } // the 1's are where the amount withdrawn is stored, the 2's are where the basis points are stored // 0x11111111111111111111111111111111111111111111111111111111112222 _incrementWithdrawn(gmd, amount); (bool success, ) = payable(recipient).call{value: amount}(''); if (!success) { revert InvalidRecipient(); } } function updateGenesisAddress(address current, address next) external onlyOwner { if (_genesisMembers[next] != 0) { revert InvalidRecipient(); } _genesisMembers[next] = _genesisMembers[current]; _genesisMembers[current] = 0; } function genesisSettings(address member) external view returns (GenesisMemberData memory) { return _genesisSettings(member); } function accumulated() external view returns (uint256) { return _accumulated; } } contract BuyAndBurn is SignatureVerification, GenesisAmount { // emitted whenever addToBurnPool is called event AddToBurnPool(address indexed caller, uint256 toBurn); // emitted whenever commitBurn is called event CommitBurn( address indexed caller, uint256 reward, uint256 wethAmountSwapped, uint256 titanxAmountSwapped, uint256 pulsarAmountBurned ); // last time a burn was committed uint256 public lastBurnTime; // the max amount of WETH that can be burned per burn uint256 public burnLimitWeth = 1 ether; // the max amount of TITANX that can be burned per burn uint256 public burnLimitTitanx = 1 ether; // the minumim amount of time (in seconds) between calls to commitBurn uint256 public burnInterval; // slippage (not sure what the units, maybe raw percents) uint256 public maxSlippage; // how much ETH you get relative to the amount of WETH being swapped and burned (in basis points) uint256 public burnCommitRewardRatio = 60; // 0.6% // address of the WETH-PULSAR uniswap pool address public wethPulsarPool; // address of the TITANX-PULSAR uniswap pool address public titanxPulsarPool; // the pool fee for the uniswap pools uint24 internal constant poolFee = 10_000; // 1% in hundreds of a basis point // address of PULSAR address public pulsarAddress; IWeth private immutable weth; IERC20 private immutable titanx; IUniswapV3Factory private immutable uniswapV3Factory; uint160 private constant MIN_SQRT_RATIO = 4295128739; uint160 private constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; // at 1 block ever 12 seconds, 25 blocks is 5 minutes uint16 private constant UNISWAP_OBSERVATION_CARDINALITY = 25; // beginning of the twap window (relative to current block) int56 private constant UNISWAP_TWAP_START_SECONDS_AGO = 313; // end of the twap window (relative to current block) int56 private constant UNISWAP_TWAP_END_SECONDS_AGO = 13; // stop the window more than 12 seconds ago to ensure sampling does not include current block // these numbers are sqrt(1.01) and sqrt(0.99) scaled by 2^96 uint256 private uniswapSlippageSqrtX96Lower = 78431879364700595886224713518; uint256 private uniswapSlippageSqrtX96Upper = 80016521857016594389520272648; // burn signature parameters / storage bytes32 private constant _BURN_TYPE_HASH = keccak256('Burn(uint256 minBurn,uint256 nonce,uint256 deadline)'); address private _burnOperator; error InitStateMismatch(); error BurnIntervalNotPassed(); error InvalidToken(); error InvalidSender(); error MoreBurn(); constructor( address _titanx, address _weth, address _uniswapV3Factory, GenesisAmount.GenesisMember[] memory genesisMembers ) payable GenesisAmount(genesisMembers) SignatureVerification('Pulsar Buy And Burn', '1.0.0') { _burnOperator = msg.sender; titanx = IERC20(_titanx); weth = IWeth(_weth); uniswapV3Factory = IUniswapV3Factory(_uniswapV3Factory); } /** * @dev We have a two phase initialization process because of the circular dependency between Pulsar and BuyAndBurn. * @param _pulsarAddress the address of the main PULSAR contract */ function init(address _pulsarAddress, uint160 initialPulsarTitanxSqrtPriceX96) external onlyOwner { if (pulsarAddress != address(0)) { revert InitStateMismatch(); } pulsarAddress = _pulsarAddress; titanxPulsarPool = uniswapV3Factory.createPool(address(titanx), _pulsarAddress, poolFee); IUniswapV3Pool(titanxPulsarPool).initialize(initialPulsarTitanxSqrtPriceX96); IUniswapV3Pool(titanxPulsarPool).increaseObservationCardinalityNext(UNISWAP_OBSERVATION_CARDINALITY); } /** * @notice Adds WETH and/or native currency to the burn pool. * The caller can also send ETH in this call, it will just get wrapped to WETH. * @param wethAmount The amount of WETH to add to the burn pool. */ function addToBurnPool(uint256 wethAmount) external payable { (uint256 wethToBurn, uint256 wethFees) = _hoistWrapped(wethAmount); (uint256 nativeToBurn, uint256 nativeFees) = _hoistNative(msg.value); _incrementAccumulated(wethFees + nativeFees); emit AddToBurnPool(msg.sender, wethToBurn + nativeToBurn); } function _hoistWrapped(uint256 amount) internal returns (uint256 toBurn, uint256 fees) { if (amount > 0) { weth.transferFrom(msg.sender, address(this), amount); // we are assuming that weth is not a tax token fees = (amount / 4); weth.withdraw(fees); toBurn = amount - fees; } } function _hoistNative(uint256 amount) internal returns (uint256 toBurn, uint256 fees) { if (amount > 0) { fees = (amount / 4); toBurn = (amount - fees); weth.deposit{value: toBurn}(); } } function setBurnOperator(address burnOperator_) external onlyOwner { _burnOperator = burnOperator_; } function burnOperator() external view returns (address) { return _burnOperator; } function verifyBurnInfo(uint256 minBurn, uint256 nonce, uint256 deadline, bytes calldata signature, address operator) external { _verifyBurnInfo(minBurn, nonce, deadline, signature, operator); } function _verifyBurnInfo(uint256 minBurn, uint256 nonce, uint256 deadline, bytes calldata signature, address expected) internal { _verifyFromOperator(nonce, deadline, abi.encode(_BURN_TYPE_HASH, minBurn, nonce, deadline), signature, expected); } /** * Swaps whatever WETH and TITANX are in this contract for Pulsar, then burns the pulsar. * @notice while this function is payable, it does not use the native token during its operations */ function commitBurn(uint256 minBurn, uint256 nonce, uint256 deadline, bytes calldata signature) external payable { _verifyBurnInfo(minBurn, nonce, deadline, signature, _burnOperator); // burns can only happen at most once per interval if (block.timestamp < lastBurnTime + burnInterval) { revert BurnIntervalNotPassed(); } (uint256 swapAmountWeth, uint256 swapAmountTitanx, uint256 reward) = _getAmounts(); // pay the caller: unwrap WETH and send ETH to caller weth.withdraw(reward); payable(msg.sender).transfer(reward); // swap WETH for Pulsar if needed if (swapAmountWeth > 0) { _swapWethForPulsar(swapAmountWeth); } // swap TITANX for Pulsar if needed if (swapAmountTitanx > 0) { _swapTitanxForPulsar(swapAmountTitanx); } // burn whatever PULSAR is in this contract Pulsar pulsar = Pulsar(pulsarAddress); uint256 pulsarAmount = pulsar.balanceOf(address(this)); if (pulsarAmount == 0) { return; } if (pulsarAmount < minBurn) { revert MoreBurn(); } pulsar.burn(pulsarAmount); // update the timestamp lastBurnTime = block.timestamp; // emit the event emit CommitBurn(msg.sender, reward, swapAmountWeth, swapAmountTitanx, pulsarAmount); } function getCurrentReward() external view returns (uint256) { (, , uint256 reward) = _getAmounts(); return reward; } /** * gets the amount of tokens needed for swapping / buy and burn operations * @return wethRemaining the weth remaining in this contract, to be used for swapping in buy and burn * @return titanxBalance the titanx balance of this contract, to be used for swapping in buy and burn * @return reward the reward for performing a swap (weth*ratio/10k) */ function _getAmounts() internal view returns (uint256 wethRemaining, uint256 titanxBalance, uint256 reward) { // current amount of titanx in this contract titanxBalance = titanx.balanceOf(address(this)); // current amount of WETH in this contract uint256 wethBalance = weth.balanceOf(address(this)); // WETH amount is either the max burn amount or the current balance, whichever is smaller wethRemaining = wethBalance > burnLimitWeth ? burnLimitWeth : wethBalance; // calculate the reward reward = (wethRemaining * burnCommitRewardRatio) / 10_000; // we can't pay out more reward than we have reward = reward > wethRemaining ? wethRemaining : reward; wethRemaining -= reward; // caluculate reward and make sure we can actually pay it out return (wethRemaining, titanxBalance, reward); } function _swapWethForPulsar(uint256 wethAmount) internal { if (wethPulsarPool == address(0)) { wethPulsarPool = uniswapV3Factory.getPool(address(weth), pulsarAddress, poolFee); if (wethPulsarPool == address(0)) { return; } } _swapTokenForPulsar(address(weth), wethAmount); } function _swapTitanxForPulsar(uint256 titanxAmount) internal { _swapTokenForPulsar(address(titanx), titanxAmount); } function _swapTokenForPulsar(address tokenAddress, uint256 tokenAmount) internal { address poolAddress = tokenAddress == address(weth) ? wethPulsarPool : titanxPulsarPool; UniswapCallbackData memory callbackData = tokenAddress < pulsarAddress ? UniswapCallbackData({token0: tokenAddress, token1: pulsarAddress}) : UniswapCallbackData({token0: pulsarAddress, token1: tokenAddress}); uint160 avgSqrtTwapX96 = _getSqrtTwapX96(poolAddress, UNISWAP_TWAP_START_SECONDS_AGO, UNISWAP_TWAP_END_SECONDS_AGO); // multiply by (1-slippage) or (1+slippage) depending on which token we're swapping uint256 slippageMultiplier = tokenAddress < pulsarAddress ? uniswapSlippageSqrtX96Lower : uniswapSlippageSqrtX96Upper; uint160 sqrtPriceLimitX96 = uint160(FullMath.mulDiv(avgSqrtTwapX96, slippageMultiplier, 2 ** 96)); IUniswapV3Pool(poolAddress).swap( address(this), tokenAddress < pulsarAddress, int256(tokenAmount), sqrtPriceLimitX96, abi.encode(callbackData) ); } /* @dev Fetches time weighted price square root (scaled 2 96) from a uniswap v3 pool. * @param uniswapV3Pool Address of the uniswap v3 pool. * @return Time weighted square root token price (scaled 2 ** 96). */ function _getSqrtTwapX96(address uniswapV3Pool, int56 fromSecondsAgo, int56 toSecondsAgo) internal view returns (uint160) { uint32[] memory secondsAgos = new uint32[](2); secondsAgos[0] = uint32(int32(fromSecondsAgo)); // from secondsAgos[1] = uint32(int32(toSecondsAgo)); // to (int56[] memory tickCumulatives, ) = IUniswapV3Pool(uniswapV3Pool).observe(secondsAgos); int56 interval = fromSecondsAgo - toSecondsAgo; int24 avgTick = int24((tickCumulatives[1] - tickCumulatives[0]) / interval); uint160 sqrtPriceX96 = TickMath.getSqrtRatioAtTick(avgTick); return sqrtPriceX96; } /** * responds to a v3 uni pool to verify swap authenticity * @param amount0Delta the amount of token0 to receive * @param amount1Delta the amount of token1 to receive * @param data encoded data for verifying a swap */ function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external { UniswapCallbackData memory decoded = abi.decode(data, (UniswapCallbackData)); if (msg.sender != wethPulsarPool && msg.sender != titanxPulsarPool) { revert InvalidSender(); } if (decoded.token0 != pulsarAddress && decoded.token1 != pulsarAddress) { revert InvalidToken(); } if (msg.sender == wethPulsarPool) { if (decoded.token0 != address(weth) && decoded.token1 != address(weth)) { revert InvalidToken(); } } else { if (decoded.token0 != address(titanx) && decoded.token1 != address(titanx)) { revert InvalidToken(); } } if (amount0Delta > 0) { TransferHelper.safeTransfer(decoded.token0, msg.sender, uint256(amount0Delta)); } else { TransferHelper.safeTransfer(decoded.token1, msg.sender, uint256(amount1Delta)); } } /** * gets the expected amount of tokens out from the weth/pulsar pool * @param amountIn the number of tokens that are to be swapped in */ function getExpectedAmountOut(uint256 amountIn) external view returns (uint256) { uint160 sqrtPriceX96 = _getSqrtTwapX96(wethPulsarPool, UNISWAP_TWAP_START_SECONDS_AGO, UNISWAP_TWAP_END_SECONDS_AGO); uint256 price = (uint256(sqrtPriceX96) * uint256(sqrtPriceX96)) >> 92; return amountIn * price; } /** * update the burn limit in weth (wei) terms * @param newBurnLimit the burn limit to update to */ function setBurnLimitWeth(uint256 newBurnLimit) external payable onlyOwner { burnLimitWeth = newBurnLimit; } /** * update the burn limit for the titanx token * @param newBurnLimit the burn limit to update to */ function setBurnLimitTitanx(uint256 newBurnLimit) external payable onlyOwner { burnLimitTitanx = newBurnLimit; } /** * update the burn interval state var to increase or decrease the time between burns in seconds * @param newBurnInterval the updated burn interval */ function setBurnInterval(uint256 newBurnInterval) external payable onlyOwner { burnInterval = newBurnInterval; } /** * sets the maxSlippage state var * @param newMaxSlippage the amount of slippage to tolerate during a swap */ function setMaxSlippage(uint256 newMaxSlippage) external payable onlyOwner { maxSlippage = newMaxSlippage; } /** * sets the burn commit rewards ratio state var * @param newBurnCommitRewardRatio the ratio of burn to commit to tolerate */ function setBurnCommitRewardRatio(uint256 newBurnCommitRewardRatio) external payable onlyOwner { burnCommitRewardRatio = newBurnCommitRewardRatio; } /** * sets bounds for slippage * @param portionSqrtX96Lower the lower bound of the x96 q number to use for slippage * @param portionSqrtX96Upper the upper bound of the x96 q number to use for slippage */ function setSlippage(uint256 portionSqrtX96Lower, uint256 portionSqrtX96Upper) external payable onlyOwner { uniswapSlippageSqrtX96Lower = portionSqrtX96Lower; uniswapSlippageSqrtX96Upper = portionSqrtX96Upper; } /** * disallow any contract to send native tokens to this contract * unless it is coming from the canonical weth contract */ receive() external payable { if (msg.sender == address(weth)) { // call happened from inside this contract return; } (uint256 nativeToBurn, uint256 nativeFees) = _hoistNative(msg.value); _incrementAccumulated(nativeFees); emit AddToBurnPool(msg.sender, nativeToBurn); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * 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 Ownable is Context { address private _owner; /** * @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. */ constructor(address initialOwner) { 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) { 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 { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * ``` * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.20; import {ERC20} from "../ERC20.sol"; import {Context} from "../../../utils/Context.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20Burnable is Context, ERC20 { /** * @dev Destroys a `value` amount of tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 value) public virtual { _burn(_msgSender(), value); } /** * @dev Destroys a `value` amount of tokens from `account`, deducting from * the caller's allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `value`. */ function burnFrom(address account, uint256 value) public virtual { _spendAllowance(account, _msgSender(), value); _burn(account, value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @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 Context { 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.0.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError, bytes32) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS, s); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "./MessageHashUtils.sol"; import {ShortStrings, ShortString} from "../ShortStrings.sol"; import {IERC5267} from "../../interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * @custom:oz-upgrades-unsafe-allow state-variable-immutable */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {IERC-5267}. */ function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: By default this function reads _name which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Name() internal view returns (string memory) { return _name.toStringWithFallback(_nameFallback); } /** * @dev The version parameter for the EIP712 domain. * * NOTE: By default this function reads _version which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Version() internal view returns (string memory) { return _version.toStringWithFallback(_versionFallback); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) pragma solidity ^0.8.20; import {Strings} from "../Strings.sol"; /** * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. * * The library provides methods for generating a hash of a message that conforms to the * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing a bytes32 `messageHash` with * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with * keccak256, although any bytes32 value can be safely used because the final digest will * be re-hashed. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20) } } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing an arbitrary `message` with * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) { return keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message)); } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x00` (data with intended validator). * * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended * `validator` address. Then hashing the result. * * See {ECDSA-recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked(hex"19_00", validator, data)); } /** * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). * * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with * `\x19\x01` and hashing the result. It corresponds to the hash signed by the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. * * See {ECDSA-recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, hex"19_01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) digest := keccak256(ptr, 0x42) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // 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. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the 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. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; uint256 private _status; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); constructor() { _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 { // 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 { // 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) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ShortStrings.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; // | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | // | length | 0x BB | type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * * Strings of arbitrary length can be optimized using this library if * they are short enough (up to 31 bytes) by packing them with their * length (1 byte) in a single EVM word (32 bytes). Additionally, a * fallback mechanism can be used for every other case. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { // Used as an identifier for strings longer than 31 bytes. bytes32 private constant FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using * {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 ERC1967 implementation slot: * ```solidity * contract ERC1967 { * 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; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 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) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { 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) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { 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) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title The interface for the Uniswap V3 Factory /// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees interface IUniswapV3Factory { /// @notice Emitted when the owner of the factory is changed /// @param oldOwner The owner before the owner was changed /// @param newOwner The owner after the owner was changed event OwnerChanged(address indexed oldOwner, address indexed newOwner); /// @notice Emitted when a pool is created /// @param token0 The first token of the pool by address sort order /// @param token1 The second token of the pool by address sort order /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks /// @param pool The address of the created pool event PoolCreated( address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool ); /// @notice Emitted when a new fee amount is enabled for pool creation via the factory /// @param fee The enabled fee, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing); /// @notice Returns the current owner of the factory /// @dev Can be changed by the current owner via setOwner /// @return The address of the factory owner function owner() external view returns (address); /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee /// @return The tick spacing function feeAmountTickSpacing(uint24 fee) external view returns (int24); /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The pool address function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); /// @notice Creates a pool for the given two tokens and fee /// @param tokenA One of the two tokens in the desired pool /// @param tokenB The other of the two tokens in the desired pool /// @param fee The desired fee for the pool /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments /// are invalid. /// @return pool The address of the newly created pool function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool); /// @notice Updates the owner of the factory /// @dev Must be called by the current owner /// @param _owner The new owner of the factory function setOwner(address _owner) external; /// @notice Enables a fee amount with the given tickSpacing /// @dev Fee amounts may never be removed once enabled /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6) /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount function enableFeeAmount(uint24 fee, int24 tickSpacing) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import {IUniswapV3PoolImmutables} from './pool/IUniswapV3PoolImmutables.sol'; import {IUniswapV3PoolState} from './pool/IUniswapV3PoolState.sol'; import {IUniswapV3PoolDerivedState} from './pool/IUniswapV3PoolDerivedState.sol'; import {IUniswapV3PoolActions} from './pool/IUniswapV3PoolActions.sol'; import {IUniswapV3PoolOwnerActions} from './pool/IUniswapV3PoolOwnerActions.sol'; import {IUniswapV3PoolErrors} from './pool/IUniswapV3PoolErrors.sol'; import {IUniswapV3PoolEvents} from './pool/IUniswapV3PoolEvents.sol'; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolErrors, IUniswapV3PoolEvents { }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Errors emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolErrors { error LOK(); error TLU(); error TLM(); error TUM(); error AI(); error M0(); error M1(); error AS(); error IIA(); error L(); error F0(); error F1(); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// @return observationIndex The index of the last oracle observation that was written, /// @return observationCardinality The current maximum number of observations stored in the pool, /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// @return feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks /// @return The liquidity at the current price of the pool function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper /// @return liquidityNet how much liquidity changes when the pool price crosses the tick, /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// @return secondsOutside the seconds spent on the other side of the tick from the current tick, /// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return liquidity The amount of liquidity in the position, /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// @return initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Contains 512-bit math functions /// @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 { /// @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 result) { unchecked { // 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 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = (0 - denominator) & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // 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 *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } } /// @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 result) { unchecked { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { error T(); error R(); /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { unchecked { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); if (absTick > uint256(int256(MAX_TICK))) revert 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; // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. // we then downcast because we know the result always fits within 160 bits due to our tick input constraint // we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { unchecked { // second inequality must be < because the price can never reach the price at the max tick if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert R(); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; /// @title ERC721 with permit /// @notice Extension to ERC721 that includes a permit function for signature based approvals interface IERC721Permit is IERC721 { /// @notice The permit typehash used in the permit signature /// @return The typehash for the permit function PERMIT_TYPEHASH() external pure returns (bytes32); /// @notice The domain separator used in the permit signature /// @return The domain seperator used in encoding of permit signature function DOMAIN_SEPARATOR() external view returns (bytes32); /// @notice Approve of a specific token ID for spending by spender via signature /// @param spender The account that is being approved /// @param tokenId The ID of the token that is being approved for spending /// @param deadline The deadline timestamp by which the call must be mined for the approve to work /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function permit( address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol'; import './IPoolInitializer.sol'; import './IERC721Permit.sol'; import './IPeripheryPayments.sol'; import './IPeripheryImmutableState.sol'; import '../libraries/PoolAddress.sol'; /// @title Non-fungible token for positions /// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred /// and authorized. interface INonfungiblePositionManager is IPoolInitializer, IPeripheryPayments, IPeripheryImmutableState, IERC721Metadata, IERC721Enumerable, IERC721Permit { /// @notice Emitted when liquidity is increased for a position NFT /// @dev Also emitted when a token is minted /// @param tokenId The ID of the token for which liquidity was increased /// @param liquidity The amount by which liquidity for the NFT position was increased /// @param amount0 The amount of token0 that was paid for the increase in liquidity /// @param amount1 The amount of token1 that was paid for the increase in liquidity event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when liquidity is decreased for a position NFT /// @param tokenId The ID of the token for which liquidity was decreased /// @param liquidity The amount by which liquidity for the NFT position was decreased /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when tokens are collected for a position NFT /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior /// @param tokenId The ID of the token for which underlying tokens were collected /// @param recipient The address of the account that received the collected tokens /// @param amount0 The amount of token0 owed to the position that was collected /// @param amount1 The amount of token1 owed to the position that was collected event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1); /// @notice Returns the position information associated with a given token ID. /// @dev Throws if the token ID is not valid. /// @param tokenId The ID of the token that represents the position /// @return nonce The nonce for permits /// @return operator The address that is approved for spending /// @return token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return fee The fee associated with the pool /// @return tickLower The lower end of the tick range for the position /// @return tickUpper The higher end of the tick range for the position /// @return liquidity The liquidity of the position /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation 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 ); struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } /// @notice Creates a new position wrapped in a NFT /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized /// a method does not exist, i.e. the pool is assumed to be initialized. /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata /// @return tokenId The ID of the token that represents the minted position /// @return liquidity The amount of liquidity for this position /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function mint(MintParams calldata params) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender` /// @param params tokenId The ID of the token for which liquidity is being increased, /// amount0Desired The desired amount of token0 to be spent, /// amount1Desired The desired amount of token1 to be spent, /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check, /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check, /// deadline The time by which the transaction must be included to effect the change /// @return liquidity The new liquidity amount as a result of the increase /// @return amount0 The amount of token0 to acheive resulting liquidity /// @return amount1 The amount of token1 to acheive resulting liquidity function increaseLiquidity(IncreaseLiquidityParams calldata params) external payable returns ( uint128 liquidity, uint256 amount0, uint256 amount1 ); struct DecreaseLiquidityParams { uint256 tokenId; uint128 liquidity; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Decreases the amount of liquidity in a position and accounts it to the position /// @param params tokenId The ID of the token for which liquidity is being decreased, /// amount The amount by which liquidity will be decreased, /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity, /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity, /// deadline The time by which the transaction must be included to effect the change /// @return amount0 The amount of token0 accounted to the position's tokens owed /// @return amount1 The amount of token1 accounted to the position's tokens owed function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1); struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient /// @param params tokenId The ID of the NFT for which tokens are being collected, /// recipient The account that should receive the tokens, /// amount0Max The maximum amount of token0 to collect, /// amount1Max The maximum amount of token1 to collect /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1); /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens /// must be collected first. /// @param tokenId The ID of the token that is being burned function burn(uint256 tokenId) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Immutable state /// @notice Functions that return immutable state of the router interface IPeripheryImmutableState { /// @return Returns the address of the Uniswap V3 factory function factory() external view returns (address); /// @return Returns the address of WETH9 function WETH9() external view returns (address); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; /// @title Periphery Payments /// @notice Functions to ease deposits and withdrawals of ETH interface IPeripheryPayments { /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH. /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users. /// @param amountMinimum The minimum amount of WETH9 to unwrap /// @param recipient The address receiving ETH function unwrapWETH9(uint256 amountMinimum, address recipient) external payable; /// @notice Refunds any ETH balance held by this contract to the `msg.sender` /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps /// that use ether for the input amount function refundETH() external payable; /// @notice Transfers the full amount of a token held by this contract to recipient /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users /// @param token The contract address of the token which will be transferred to `recipient` /// @param amountMinimum The minimum amount of token required for a transfer /// @param recipient The destination address of the token function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; /// @title Creates and initializes V3 Pools /// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that /// require the pool to exist. interface IPoolInitializer { /// @notice Creates a new pool if it does not exist, then initializes if not initialized /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool /// @param token0 The contract address of token0 of the pool /// @param token1 The contract address of token1 of the pool /// @param fee The fee amount of the v3 pool for the specified token pair /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary function createAndInitializePoolIfNecessary( address token0, address token1, uint24 fee, uint160 sqrtPriceX96 ) external payable returns (address pool); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol'; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol'; import './PoolAddress.sol'; /// @notice Provides validation for callbacks from Uniswap V3 Pools library CallbackValidation { /// @notice Returns the address of a valid Uniswap V3 Pool /// @param factory The contract address of the Uniswap V3 factory /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The V3 pool contract address function verifyCallback( address factory, address tokenA, address tokenB, uint24 fee ) internal view returns (IUniswapV3Pool pool) { return verifyCallback(factory, PoolAddress.getPoolKey(tokenA, tokenB, fee)); } /// @notice Returns the address of a valid Uniswap V3 Pool /// @param factory The contract address of the Uniswap V3 factory /// @param poolKey The identifying key of the V3 pool /// @return pool The V3 pool contract address function verifyCallback(address factory, PoolAddress.PoolKey memory poolKey) internal view returns (IUniswapV3Pool pool) { pool = IUniswapV3Pool(PoolAddress.computeAddress(factory, poolKey)); require(msg.sender == address(pool)); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xa598dd2fba360510c5a8f02f44423a4468e902df5857dbce3ca162a43a3a31ff; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address( uint160( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) ) ); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call( abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value) ); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA'); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.22; interface IOmniBridge { /** * @dev Initiate the bridge operation for some amount of tokens from msg.sender. * The user should first call Approve method of the ERC677 token. * @param token bridged token contract address. * @param _receiver address that will receive the native tokens on the other network. * @param _value amount of tokens to be transferred to the other network. * @param _data additional transfer data to be used on the other side. */ function relayTokensAndCall(address token, address _receiver, uint256 _value, bytes memory _data) external; function bridgeContract() external view returns (address); /** * @dev Tells the mediator contract address from the other network. * @return the address of the mediator contract. */ function mediatorContractOnOtherSide() external view returns (address); /** * @dev Tells the default gas limit to be used in the message execution by the AMB bridge on the other network. * @return the gas limit for the message execution. */ function requestGasLimit() external view returns (uint256); /** * @dev Retrieves address of the bridged token contract associated with a specific native token contract on the other side. * @param _nativeToken address of the native token contract on the other side. * @return address of the deployed bridged token contract. */ function bridgedTokenAddress(address _nativeToken) external view returns (address); /** * @dev Retrieves address of the native token contract associated with a specific bridged token contract. * @param _bridgedToken address of the created bridged token contract on this side. * @return address of the native token contract on the other side of the bridge. */ function nativeTokenAddress(address _bridgedToken) external view returns (address); }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.22; interface ITitanOnBurn { function onBurn(address user, uint256 amount) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.22; // https://etherscan.io/address/0xf19308f923582a6f7c465e5ce7a9dc1bec6665b1#code interface ITitanX { /** @notice Burn Titan tokens and creates Proof-Of-Burn record to be used by connected DeFi and fee is paid to specified address * @param user user address * @param amount titan amount * @param userRebatePercentage percentage for user rebate in liquid titan (0 - 8) * @param rewardPaybackPercentage percentage for builder fee in liquid titan (0 - 8) */ function burnTokens(address user, uint256 amount, uint256 userRebatePercentage, uint256 rewardPaybackPercentage) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.22; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; interface IWeth is IERC20 { function deposit() external payable; function withdraw(uint256 wad) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.22; import {ERC20} from '@openzeppelin/contracts/token/ERC20/ERC20.sol'; import {ITitanX} from './external/titanx/ITitanX.sol'; import {IOmniBridge} from './external/omnibridge/IOmniBridge.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {BuyAndBurn} from './BuyAndBurn.sol'; import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; import {ERC20Burnable} from '@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol'; import {ITitanOnBurn} from './external/titanx/ITitanOnBurn.sol'; import {ERC165} from '@openzeppelin/contracts/utils/introspection/ERC165.sol'; import {SignatureVerification} from './SignatureVerification.sol'; interface IVault { function updateVault() external; } contract Pulsar is ERC20, ERC165, Ownable, ITitanOnBurn, SignatureVerification { // address of the PulseChainRouter (us) contract on PulseChain address public immutable pulsarPathway; // address of the Pulsar BuyAndBurn contract address public immutable buyAndBurnAddressV1; // set to the v2 buyAndBurn contract address once it is deployed address public buyAndBurnAddressV2 = address(0); address private immutable weth; // external dependencies address public immutable titanxAddress; address public immutable pulseChainBridgeAddress; address private immutable V0; uint256 private immutable deployTime; bytes32 private constant _PRICE_TYPE_HASH = keccak256('Price(uint256 priceDenominator,uint256 nonce,uint256 deadline)'); address private _priceOperator; uint256 private _titanxToCross; address private helios = 0xA2d21205Aa7273BadDFC8E9551e05E23bB49ce46; address private dragonx = 0x96a5399D07896f757Bd4c6eF56461F58DB951862; uint256 internal toSendToBuyAndBurn; // emitted when the Pulsar minting process is started event Mint(address caller, uint256 titanxAmount, uint256 ethAmount); error IncorrectFee(); error AddressAssigned(); constructor( address _titanx, address _weth, address _buyAndBurnAddressV1, address _pulsarPathway, address _pulseChainBridgeAddress, address _V0, uint256 _initialSupply ) payable ERC20('Pulsar', 'PULSAR') Ownable(msg.sender) SignatureVerification('Pulsar', '1.0.0') { deployTime = block.timestamp; titanxAddress = _titanx; weth = _weth; V0 = _V0; // configure dependencies pulsarPathway = _pulsarPathway; pulseChainBridgeAddress = _pulseChainBridgeAddress; // deploy PulsarBuyAndBurn contract, specifying this contract as the router buyAndBurnAddressV1 = _buyAndBurnAddressV1; // mint initial supply to the owner _mint(address(msg.sender), _initialSupply); IERC20(titanxAddress).approve(pulseChainBridgeAddress, type(uint256).max); _approve(address(this), pulseChainBridgeAddress, type(uint256).max); _priceOperator = msg.sender; // deployer is set to price operator to start } function priceOperator() external view returns (address) { return _priceOperator; } function burn(uint256 amount) external payable { _burn(msg.sender, amount); } function mintFromV0(uint256 amount) external payable { if (deployTime + 1 weeks < block.timestamp) { return; } ERC20Burnable v0 = ERC20Burnable(V0); v0.transferFrom(msg.sender, address(this), amount); v0.burn(amount); _mint(msg.sender, amount); } /** * set the price operator * @param operator the address that can provide signatures to be validated by the contract * this param should only be set to addresses that are trusted by the owner * to provide consistent and correct pricing data */ function setPriceOperator(address operator) external payable onlyOwner { _priceOperator = operator; } /** * verify price information and a provided signature * @param priceDenominator the priceDenominator to use during fee compute * @param deadline the deadline to apply to the priceDenominator. if block.timestamp * is greater than this number, then the signature will be rejected * @param signature the signature from the price operator */ function verifyPriceInfo(uint256 priceDenominator, uint256 nonce, uint256 deadline, bytes calldata signature, address expected) external { _verifyPriceInfo(priceDenominator, nonce, deadline, signature, expected); } function _verifyPriceInfo( uint256 priceDenominator, uint256 nonce, uint256 deadline, bytes calldata signature, address expected ) internal { _verifyFromOperator(nonce, deadline, abi.encode(_PRICE_TYPE_HASH, priceDenominator, nonce, deadline), signature, expected); } function _divvy(uint256 amountIn) internal pure returns (uint256 toBurn, uint256 toDistribute, uint256 toBridge) { toBurn = (amountIn * 4_200) / 10_000; toDistribute = (amountIn * 800) / 10_000; toBridge = amountIn - (toBurn + toDistribute); } /** * @notice do the Pulsar minting process * @param titanxAmount the amount of titanX to burn */ function mint( uint256 titanxAmount, uint256 priceDenominator, uint256 nonce, uint256 deadline, bytes calldata signature ) external payable { _verifyPriceInfo(priceDenominator, nonce, deadline, signature, _priceOperator); // check the fee first // old: 6 transfers // new: 0 transfers - deferred until buy and burn is desired _verifyFee(titanxAmount, priceDenominator); (uint256 toBurn, uint256 toDistribute, uint256 toBridge) = _divvy(titanxAmount); // 1 transfer IERC20(titanxAddress).transferFrom(msg.sender, address(this), toDistribute + toBridge); // accumulating "to distribute" is held implicitly by the balance of the remaining titanx tokens // 1 burn _burnAndEarmarkTitanx(toBurn); // 2 mint _mintPulsar(titanxAmount); // 2 approvals + 2 bridges (transfer with a bunch of operations) // new: 2 bridges _titanxToCross += toBridge; emit Mint(msg.sender, titanxAmount, msg.value); } function _buyAndBurn() internal view returns (address) { return buyAndBurnAddressV2 == address(0) ? buyAndBurnAddressV1 : buyAndBurnAddressV2; } /** * @notice Distribute the fee to the genesis addresses and the buyAndBurn contract */ function distribute() external { IERC20 titanx = IERC20(titanxAddress); address buyNBurn = _buyAndBurn(); titanx.transfer(buyNBurn, toSendToBuyAndBurn); toSendToBuyAndBurn = 0; uint256 distributableTitanxBalance = titanx.balanceOf(address(this)) - _titanxToCross; uint256 halfTitanxBalance = (distributableTitanxBalance * 5_000) / 10_000; if (halfTitanxBalance > 0) { titanx.transfer(helios, halfTitanxBalance); titanx.transfer(dragonx, distributableTitanxBalance - halfTitanxBalance); // try IVault(dragonx).updateVault() {} catch (bytes memory b) {} dragonx.call(abi.encodeWithSelector(IVault.updateVault.selector)); } // calculate fee amount and verify that it was sent BuyAndBurn(payable(buyNBurn)).addToBurnPool{value: address(this).balance}(IERC20(weth).balanceOf(address(this))); } /** * @notice Distribute the fee to the genesis addresses and the buyAndBurn contract */ function _verifyFee(uint256 titanxAmount, uint256 priceDenominator) internal { // calculate fee amount and verify that it was sent if ((titanxAmount / priceDenominator) != msg.value) { revert IncorrectFee(); } } function bridgeToPulsechain() external payable { uint256 titanxToCross = _titanxToCross; _titanxToCross = 0; _bridgeToPulseChain({titanxToBridge: titanxToCross, pulsarToBridge: IERC20(this).balanceOf(address(this))}); } function _bridgeToPulseChain(uint256 titanxToBridge, uint256 pulsarToBridge) internal { // uint256 titanxBridgeAmount = titanxAmount - (titanxAmount / 2); IOmniBridge tokenRelayer = IOmniBridge(pulseChainBridgeAddress); tokenRelayer.relayTokensAndCall(titanxAddress, pulsarPathway, titanxToBridge, ''); tokenRelayer.relayTokensAndCall(address(this), pulsarPathway, pulsarToBridge, ''); } function _mintPulsar(uint256 titanxAmount) internal returns (uint256) { // mint 25% of titanX amount as pulsar to caller and this contract uint256 pulsarAmount = titanxAmount / 4; _mint(msg.sender, pulsarAmount); _mint(address(this), pulsarAmount); return pulsarAmount; } function _burnAndEarmarkTitanx(uint256 toBurn) internal { uint256 balanceBefore = IERC20(titanxAddress).balanceOf(address(this)); ITitanX(titanxAddress).burnTokens(msg.sender, toBurn, 0, 8); // rebate delta + buy and burn earmarkbalanceBefore); toSendToBuyAndBurn += (IERC20(titanxAddress).balanceOf(address(this)) - balanceBefore); } function assignV2Address(address v2address) external onlyOwner { if (buyAndBurnAddressV2 != address(0)) { revert AddressAssigned(); } buyAndBurnAddressV2 = v2address; } function onBurn(address user, uint256 amount) external pure override {} function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { if (interfaceId == type(ITitanOnBurn).interfaceId) { return true; } return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.22; import {EIP712} from '@openzeppelin/contracts/utils/cryptography/EIP712.sol'; import {ECDSA} from '@openzeppelin/contracts/utils/cryptography/ECDSA.sol'; abstract contract SignatureVerification is EIP712 { using ECDSA for bytes32; /** * emitted if the recoverred address is zero */ error InvalidSignature(); error NonceConsumed(); error SignatureExpired(); error OperatorNotProvided(); mapping(uint256 nonce => bool consumed) public consumedNonces; constructor(string memory name, string memory version) EIP712(name, version) {} /** * verify a signature against a struct hash and recover the address * @param _structHash the struct hash of the data to verify against the provided signature * @param signature the signature to recover an address from */ function _verifySignature(bytes32 _structHash, bytes memory signature) internal view returns (address recovered) { bytes32 digest = _hashTypedDataV4(_structHash); recovered = digest.recover(signature); if (recovered == address(0)) { revert InvalidSignature(); } } function _verifyFromOperator( uint256 nonce, uint256 deadline, bytes memory encoded, bytes calldata signature, address expected ) internal returns (address recovered) { if (consumedNonces[nonce]) { revert NonceConsumed(); } consumedNonces[nonce] = true; if (expected == address(0)) { revert OperatorNotProvided(); } bytes32 structHash = keccak256(encoded); recovered = _verifySignature(structHash, signature); if (recovered != expected) { revert InvalidSignature(); } if (deadline < block.timestamp) { revert SignatureExpired(); } } }
{ "evmVersion": "paris", "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_titanx","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_uniswapV3Factory","type":"address"},{"components":[{"internalType":"address","name":"member","type":"address"},{"internalType":"uint16","name":"basisPoints","type":"uint16"}],"internalType":"struct GenesisAmount.GenesisMember[]","name":"genesisMembers","type":"tuple[]"}],"stateMutability":"payable","type":"constructor"},{"inputs":[],"name":"BurnIntervalNotPassed","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"IncorrectFee","type":"error"},{"inputs":[],"name":"InitStateMismatch","type":"error"},{"inputs":[],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[],"name":"InvalidSignature","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"MoreBurn","type":"error"},{"inputs":[],"name":"NonceConsumed","type":"error"},{"inputs":[],"name":"OperatorNotProvided","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":"SignatureExpired","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"T","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"toBurn","type":"uint256"}],"name":"AddToBurnPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"wethAmountSwapped","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"titanxAmountSwapped","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pulsarAmountBurned","type":"uint256"}],"name":"CommitBurn","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","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"},{"inputs":[],"name":"accumulated","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"wethAmount","type":"uint256"}],"name":"addToBurnPool","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"burnCommitRewardRatio","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burnInterval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burnLimitTitanx","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burnLimitWeth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burnOperator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"minBurn","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"commitBurn","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"consumedNonces","outputs":[{"internalType":"bool","name":"consumed","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"distributeFeeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"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":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"member","type":"address"}],"name":"genesisSettings","outputs":[{"components":[{"internalType":"address","name":"member","type":"address"},{"internalType":"uint256","name":"basisPoints","type":"uint256"},{"internalType":"uint256","name":"withdrawn","type":"uint256"},{"internalType":"uint256","name":"available","type":"uint256"}],"internalType":"struct GenesisAmount.GenesisMemberData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"getExpectedAmountOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_pulsarAddress","type":"address"},{"internalType":"uint160","name":"initialPulsarTitanxSqrtPriceX96","type":"uint160"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastBurnTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSlippage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pulsarAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newBurnCommitRewardRatio","type":"uint256"}],"name":"setBurnCommitRewardRatio","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newBurnInterval","type":"uint256"}],"name":"setBurnInterval","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newBurnLimit","type":"uint256"}],"name":"setBurnLimitTitanx","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newBurnLimit","type":"uint256"}],"name":"setBurnLimitWeth","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"burnOperator_","type":"address"}],"name":"setBurnOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMaxSlippage","type":"uint256"}],"name":"setMaxSlippage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"portionSqrtX96Lower","type":"uint256"},{"internalType":"uint256","name":"portionSqrtX96Upper","type":"uint256"}],"name":"setSlippage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"titanxPulsarPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int256","name":"amount0Delta","type":"int256"},{"internalType":"int256","name":"amount1Delta","type":"int256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3SwapCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"current","type":"address"},{"internalType":"address","name":"next","type":"address"}],"name":"updateGenesisAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"minBurn","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"address","name":"operator","type":"address"}],"name":"verifyBurnInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wethPulsarPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6101c0604052670de0b6b3a7640000600755670de0b6b3a7640000600855603c600b556bfd6d547bf76a8cb94a16272e600f556c01028c1d959b061d826602cd0860105560405162005a6938038062005a69833981810160405281019062000068919062000884565b80336040518060400160405280601381526020017f50756c7361722042757920416e64204275726e000000000000000000000000008152506040518060400160405280600581526020017f312e302e300000000000000000000000000000000000000000000000000000008152508181620000ee6000836200040760201b90919060201c565b61012081815250506200010c6001826200040760201b90919060201c565b6101408181525050818051906020012060e08181525050808051906020012061010081815250504660a081815250506200014b6200045f60201b60201c565b608081815250503073ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff168152505050505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603620001ff5760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401620001f6919062000926565b60405180910390fd5b6200021081620004bc60201b60201c565b506000806000835190505b83828151811062000231576200023062000943565b5b60200260200101516020015161ffff16600560008685815181106200025b576200025a62000943565b5b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550838281518110620002bb57620002ba62000943565b5b60200260200101516020015161ffff16830192508160010191508082106200021b57612710831462000319576040517fcd3cb2bb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505033601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508373ffffffffffffffffffffffffffffffffffffffff166101808173ffffffffffffffffffffffffffffffffffffffff16815250508273ffffffffffffffffffffffffffffffffffffffff166101608173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff166101a08173ffffffffffffffffffffffffffffffffffffffff16815250505050505062000e71565b60006020835110156200042d5762000425836200058260201b60201c565b905062000459565b826200043f83620005ef60201b60201c565b600001908162000450919062000bbd565b5060ff60001b90505b92915050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60e051610100514630604051602001620004a195949392919062000cd0565b60405160208183030381529060405280519060200120905090565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080829050601f81511115620005d257826040517f305a27a9000000000000000000000000000000000000000000000000000000008152600401620005c9919062000dab565b60405180910390fd5b805181620005e09062000e01565b60001c1760001b915050919050565b6000819050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006200063a826200060d565b9050919050565b6200064c816200062d565b81146200065857600080fd5b50565b6000815190506200066c8162000641565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620006c28262000677565b810181811067ffffffffffffffff82111715620006e457620006e362000688565b5b80604052505050565b6000620006f9620005f9565b9050620007078282620006b7565b919050565b600067ffffffffffffffff8211156200072a576200072962000688565b5b602082029050602081019050919050565b600080fd5b600080fd5b600061ffff82169050919050565b6200075e8162000745565b81146200076a57600080fd5b50565b6000815190506200077e8162000753565b92915050565b6000604082840312156200079d576200079c62000740565b5b620007a96040620006ed565b90506000620007bb848285016200065b565b6000830152506020620007d1848285016200076d565b60208301525092915050565b6000620007f4620007ee846200070c565b620006ed565b905080838252602082019050604084028301858111156200081a57620008196200073b565b5b835b8181101562000847578062000832888262000784565b8452602084019350506040810190506200081c565b5050509392505050565b600082601f83011262000869576200086862000672565b5b81516200087b848260208601620007dd565b91505092915050565b60008060008060808587031215620008a157620008a062000603565b5b6000620008b1878288016200065b565b9450506020620008c4878288016200065b565b9350506040620008d7878288016200065b565b925050606085015167ffffffffffffffff811115620008fb57620008fa62000608565b5b620009098782880162000851565b91505092959194509250565b62000920816200062d565b82525050565b60006020820190506200093d600083018462000915565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680620009c557607f821691505b602082108103620009db57620009da6200097d565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b60006008830262000a457fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000a06565b62000a51868362000a06565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600062000a9e62000a9862000a928462000a69565b62000a73565b62000a69565b9050919050565b6000819050919050565b62000aba8362000a7d565b62000ad262000ac98262000aa5565b84845462000a13565b825550505050565b600090565b62000ae962000ada565b62000af681848462000aaf565b505050565b5b8181101562000b1e5762000b1260008262000adf565b60018101905062000afc565b5050565b601f82111562000b6d5762000b3781620009e1565b62000b4284620009f6565b8101602085101562000b52578190505b62000b6a62000b6185620009f6565b83018262000afb565b50505b505050565b600082821c905092915050565b600062000b926000198460080262000b72565b1980831691505092915050565b600062000bad838362000b7f565b9150826002028217905092915050565b62000bc88262000972565b67ffffffffffffffff81111562000be45762000be362000688565b5b62000bf08254620009ac565b62000bfd82828562000b22565b600060209050601f83116001811462000c35576000841562000c20578287015190505b62000c2c858262000b9f565b86555062000c9c565b601f19841662000c4586620009e1565b60005b8281101562000c6f5784890151825560018201915060208501945060208101905062000c48565b8683101562000c8f578489015162000c8b601f89168262000b7f565b8355505b6001600288020188555050505b505050505050565b6000819050919050565b62000cb98162000ca4565b82525050565b62000cca8162000a69565b82525050565b600060a08201905062000ce7600083018862000cae565b62000cf6602083018762000cae565b62000d05604083018662000cae565b62000d14606083018562000cbf565b62000d23608083018462000915565b9695505050505050565b600082825260208201905092915050565b60005b8381101562000d5e57808201518184015260208101905062000d41565b60008484015250505050565b600062000d778262000972565b62000d83818562000d2d565b935062000d9581856020860162000d3e565b62000da08162000677565b840191505092915050565b6000602082019050818103600083015262000dc7818462000d6a565b905092915050565b600081519050919050565b6000819050602082019050919050565b600062000df8825162000ca4565b80915050919050565b600062000e0e8262000dcf565b8262000e1a8462000dda565b905062000e278162000dea565b9250602082101562000e6a5762000e657fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8360200360080262000a06565b831692505b5050919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a051614b1362000f56600039600081816112ef015261224401526000818161132b015281816118b8015281816119130152818161205d01526123ef0152600081816101f80152818161081301528181610f62015281816117cc01528181611827015281816119e001528181611a90015281816120fb01528181612280015281816123c10152612c550152600061202401526000611fe9015260006135300152600061350f015260006132360152600061328c015260006132b50152614b136000f3fe6080604052600436106101f15760003560e01c80637a0443231161010d578063bc9ef3e0116100a0578063e75e1f291161006f578063e75e1f2914610735578063eaafef6a14610751578063eb7d4fd81461076d578063f2fde38b14610796578063fa461e33146107bf576102b6565b8063bc9ef3e01461069a578063d03122a8146106b6578063e3067449146106df578063e55a68b31461070a576102b6565b80638aec8542116100dc5780638aec8542146105fd5780638c04166f146106285780638da5cb5b14610653578063b2dd823c1461067e576102b6565b80637a0443231461054b5780637cdcf4bd146105765780638496bc7b146105a157806384b0196e146105cc576102b6565b80634a7c525211610185578063681d167b11610154578063681d167b146104c6578063698ca058146104ef5780636f80790314610518578063715018a614610534576102b6565b80634a7c5252146104175780634b97d2dd14610442578063635ce3ad1461047f578063649736dc1461049b576102b6565b80633807b58a116101c15780633807b58a146103685780633bb39037146103935780633cf1f102146103d057806343f68a49146103fb576102b6565b8062b1e76e146102bb578063174293e1146102f857806322a7aac81461031457806333175c7c1461033f576102b6565b366102b6577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1603156102b457600080610256346107e8565b9150915061026381610898565b3373ffffffffffffffffffffffffffffffffffffffff167fc80bd2abff7085782e6a7bfff1fac71066cbc25766fd8054aa2f4b474cee1f7f836040516102a991906136cb565b60405180910390a250505b005b600080fd5b3480156102c757600080fd5b506102e260048036038101906102dd9190613726565b6108ab565b6040516102ef919061376e565b60405180910390f35b610312600480360381019061030d9190613726565b6108cb565b005b34801561032057600080fd5b5061032961095f565b60405161033691906137ca565b60405180910390f35b34801561034b57600080fd5b5061036660048036038101906103619190613811565b610985565b005b34801561037457600080fd5b5061037d610ad2565b60405161038a91906137ca565b60405180910390f35b34801561039f57600080fd5b506103ba60048036038101906103b59190613726565b610afc565b6040516103c791906136cb565b60405180910390f35b3480156103dc57600080fd5b506103e5610b86565b6040516103f291906137ca565b60405180910390f35b61041560048036038101906104109190613726565b610bac565b005b34801561042357600080fd5b5061042c610bbe565b60405161043991906136cb565b60405180910390f35b34801561044e57600080fd5b5061046960048036038101906104649190613851565b610bc4565b60405161047691906138f1565b60405180910390f35b61049960048036038101906104949190613726565b610bdc565b005b3480156104a757600080fd5b506104b0610bee565b6040516104bd91906136cb565b60405180910390f35b3480156104d257600080fd5b506104ed60048036038101906104e89190613971565b610bf4565b005b3480156104fb57600080fd5b5061051660048036038101906105119190613a0b565b610c0a565b005b610532600480360381019061052d9190613726565b610cf2565b005b34801561054057600080fd5b50610549610d04565b005b34801561055757600080fd5b50610560610d18565b60405161056d91906136cb565b60405180910390f35b34801561058257600080fd5b5061058b610d22565b60405161059891906137ca565b60405180910390f35b3480156105ad57600080fd5b506105b6610d48565b6040516105c391906136cb565b60405180910390f35b3480156105d857600080fd5b506105e1610d4e565b6040516105f49796959493929190613bde565b60405180910390f35b34801561060957600080fd5b50610612610df8565b60405161061f91906136cb565b60405180910390f35b34801561063457600080fd5b5061063d610e0e565b60405161064a91906136cb565b60405180910390f35b34801561065f57600080fd5b50610668610e14565b60405161067591906137ca565b60405180910390f35b61069860048036038101906106939190613726565b610e3e565b005b6106b460048036038101906106af9190613c62565b610e50565b005b3480156106c257600080fd5b506106dd60048036038101906106d89190613851565b610e6a565b005b3480156106eb57600080fd5b506106f4610eb6565b60405161070191906136cb565b60405180910390f35b34801561071657600080fd5b5061071f610ebc565b60405161072c91906136cb565b60405180910390f35b61074f600480360381019061074a9190613726565b610ec2565b005b61076b60048036038101906107669190613ca2565b610ed4565b005b34801561077957600080fd5b50610794600480360381019061078f9190613d56565b61121c565b005b3480156107a257600080fd5b506107bd60048036038101906107b89190613851565b61150e565b005b3480156107cb57600080fd5b506107e660048036038101906107e19190613dcc565b611594565b005b6000806000831115610893576004836108019190613e9e565b9050808361080f9190613ecf565b91507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b15801561087957600080fd5b505af115801561088d573d6000803e3d6000fd5b50505050505b915091565b8060046000828254019250508190555050565b60026020528060005260406000206000915054906101000a900460ff1681565b6000806108d7836119d2565b915091506000806108e7346107e8565b915091506108ff81846108fa9190613f03565b610898565b3373ffffffffffffffffffffffffffffffffffffffff167fc80bd2abff7085782e6a7bfff1fac71066cbc25766fd8054aa2f4b474cee1f7f83866109439190613f03565b60405161095091906136cb565b60405180910390a25050505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61098d611b2d565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610a06576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b6000601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080610b2f600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610139600d611bb4565b90506000605c8273ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16610b6d9190613f37565b901c90508084610b7d9190613f37565b92505050919050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610bb4611b2d565b80600a8190555050565b60075481565b610bcc613674565b610bd582611d62565b9050919050565b610be4611b2d565b8060088190555050565b600b5481565b610c02868686868686611e59565b505050505050565b6000610c1533611d62565b905080606001518211610c285781610c2e565b80606001515b915060008203610c3e5750610cee565b610c488183611eb5565b60008373ffffffffffffffffffffffffffffffffffffffff1683604051610c6e90613faa565b60006040518083038185875af1925050503d8060008114610cab576040519150601f19603f3d011682016040523d82523d6000602084013e610cb0565b606091505b5050905080610ceb576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505b5050565b610cfa611b2d565b80600b8190555050565b610d0c611b2d565b610d166000611f1a565b565b6000600454905090565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60085481565b600060608060008060006060610d62611fe0565b610d6a61201b565b46306000801b600067ffffffffffffffff811115610d8b57610d8a613fbf565b5b604051908082528060200260200182016040528015610db95781602001602082028036833780820191505090505b507f0f00000000000000000000000000000000000000000000000000000000000000959493929190965096509650965096509650965090919293949596565b600080610e03612056565b925050508091505090565b600a5481565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610e46611b2d565b8060098190555050565b610e58611b2d565b81600f81905550806010819055505050565b610e72611b2d565b80601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60065481565b60095481565b610eca611b2d565b8060078190555050565b610f048585858585601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611e59565b600954600654610f149190613f03565b421015610f4d576040517fbcbfd86d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806000610f5a612056565b9250925092507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b8152600401610fb991906136cb565b600060405180830381600087803b158015610fd357600080fd5b505af1158015610fe7573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611031573d6000803e3d6000fd5b50600083111561104557611044836121ec565b5b600082111561105857611057826123ea565b5b6000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016110ba91906137ca565b602060405180830381865afa1580156110d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110fb9190614003565b90506000810361110f575050505050611215565b89811015611149576040517fd431243000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166342966c68826040518263ffffffff1660e01b815260040161118291906136cb565b600060405180830381600087803b15801561119c57600080fd5b505af11580156111b0573d6000803e3d6000fd5b50505050426006819055503373ffffffffffffffffffffffffffffffffffffffff167f20be56edb2a2243a5bf294ac4fce64330b448ea81268de70d1ad5db2e3ba0bea848787856040516112079493929190614030565b60405180910390a250505050505b5050505050565b611224611b2d565b600073ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112ac576040517fc584641000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663a16712957f0000000000000000000000000000000000000000000000000000000000000000846127106040518463ffffffff1660e01b815260040161136c93929190614093565b6020604051808303816000875af115801561138b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113af91906140df565b600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f637731d826040518263ffffffff1660e01b815260040161144a919061411b565b600060405180830381600087803b15801561146457600080fd5b505af1158015611478573d6000803e3d6000fd5b50505050600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166332148f6760196040518263ffffffff1660e01b81526004016114d89190614153565b600060405180830381600087803b1580156114f257600080fd5b505af1158015611506573d6000803e3d6000fd5b505050505050565b611516611b2d565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036115885760006040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161157f91906137ca565b60405180910390fd5b61159181611f1a565b50565b600082828101906115a5919061420f565b9050600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141580156116535750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614155b1561168a576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161415801561173e5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff1614155b15611775576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16036118b6577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161415801561187a57507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff1614155b156118b1576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61199e565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161415801561196657507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff1614155b1561199d576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b60008513156119bb576119b681600001513387612417565b6119cb565b6119ca81602001513386612417565b5b5050505050565b6000806000831115611b28577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff1660e01b8152600401611a3b9392919061423c565b6020604051808303816000875af1158015611a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7e919061429f565b50600483611a8c9190613e9e565b90507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b8152600401611ae791906136cb565b600060405180830381600087803b158015611b0157600080fd5b505af1158015611b15573d6000803e3d6000fd5b505050508083611b259190613ecf565b91505b915091565b611b3561256c565b73ffffffffffffffffffffffffffffffffffffffff16611b53610e14565b73ffffffffffffffffffffffffffffffffffffffff1614611bb257611b7661256c565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401611ba991906137ca565b60405180910390fd5b565b600080600267ffffffffffffffff811115611bd257611bd1613fbf565b5b604051908082528060200260200182016040528015611c005781602001602082028036833780820191505090505b5090508381600081518110611c1857611c176142cc565b5b602002602001019063ffffffff16908163ffffffff16815250508281600181518110611c4757611c466142cc565b5b602002602001019063ffffffff16908163ffffffff168152505060008573ffffffffffffffffffffffffffffffffffffffff1663883bdbfd836040518263ffffffff1660e01b8152600401611c9c91906143c9565b600060405180830381865afa158015611cb9573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611ce291906145bf565b50905060008486611cf39190614637565b905060008183600081518110611d0c57611d0b6142cc565b5b602002602001015184600181518110611d2857611d276142cc565b5b6020026020010151611d3a9190614637565b611d449190614696565b90506000611d5182612574565b905080955050505050509392505050565b611d6a613674565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508061ffff168260200181815250506000826020015103611dce5750611e54565b82826000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601081901c7dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16826040018181525050611e4960045483602001518460400151612980565b826060018181525050505b919050565b611eac85857fe07b316fc052bc85fc67b3281fa5a5183addeb51e33e1637a142517b0c1e4773898989604051602001611e959493929190614700565b6040516020818303038152906040528686866129af565b50505050505050565b81602001516010828460400151611ecc9190613f03565b901b1760056000846000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b606061201660007f0000000000000000000000000000000000000000000000000000000000000000612ba190919063ffffffff16565b905090565b606061205160017f0000000000000000000000000000000000000000000000000000000000000000612ba190919063ffffffff16565b905090565b60008060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016120b491906137ca565b602060405180830381865afa1580156120d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120f59190614003565b915060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161215291906137ca565b602060405180830381865afa15801561216f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121939190614003565b905060075481116121a457806121a8565b6007545b9350612710600b54856121bb9190613f37565b6121c59190613e9e565b91508382116121d457816121d6565b835b915081846121e49190613ecf565b935050909192565b600073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036123bc577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16631698ee827f0000000000000000000000000000000000000000000000000000000000000000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166127106040518463ffffffff1660e01b81526004016122e393929190614093565b602060405180830381865afa158015612300573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061232491906140df565b600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603156123e7575b6123e67f000000000000000000000000000000000000000000000000000000000000000082612c51565b5b50565b6124147f000000000000000000000000000000000000000000000000000000000000000082612c51565b50565b6000808473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b858560405160240161244c929190614745565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516124b691906147aa565b6000604051808303816000865af19150503d80600081146124f3576040519150601f19603f3d011682016040523d82523d6000602084013e6124f8565b606091505b50915091508180156125265750600081511480612525575080806020019051810190612524919061429f565b5b5b612565576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161255c9061480d565b60405180910390fd5b5050505050565b600033905090565b60008060008360020b1261258b578260020b612593565b8260020b6000035b90507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2761860000360020b8111156125f5576040517f2bc80f3a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060018316036126185770010000000000000000000000000000000061262a565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600060028316146126645760806ffff97272373d413259a46990580e213a8202901c90505b600060048316146126895760806ffff2e50f5f656932ef12357cf3c7fdcc8202901c90505b600060088316146126ae5760806fffe5caca7e10e4e61c3624eaa0941cd08202901c90505b600060108316146126d35760806fffcb9843d60f6159c9db58835c9266448202901c90505b600060208316146126f85760806fff973b41fa98c081472e6896dfb254c08202901c90505b6000604083161461271d5760806fff2ea16466c96a3843ec78b326b528618202901c90505b600060808316146127425760806ffe5dee046a99a2a811c461f1969c30538202901c90505b60006101008316146127685760806ffcbe86c7900a88aedcffc83b479aa3a48202901c90505b600061020083161461278e5760806ff987a7253ac413176f2b074cf7815e548202901c90505b60006104008316146127b45760806ff3392b0822b70005940c7a398e4b70f38202901c90505b60006108008316146127da5760806fe7159475a2c29b7443b29c7fa6e889d98202901c90505b60006110008316146128005760806fd097f3bdfd2022b8845ad8f792aa58258202901c90505b60006120008316146128265760806fa9f746462d870fdf8a65dc1f90e061e58202901c90505b600061400083161461284c5760806f70d869a156d2a1b890bb3df62baf32f78202901c90505b60006180008316146128725760806f31be135f97d08fd981231505542fcfa68202901c90505b6000620100008316146128995760806f09aa508b5b7a84e1c677de54f3e99bc98202901c90505b6000620200008316146128bf5760806e5d6af8dedb81196699c329225ee6048202901c90505b6000620400008316146128e45760806d2216e584f5fa1ea926041bedfe988202901c90505b6000620800008316146129075760806b048a170391f7dc42444e8fa28202901c90505b60008460020b131561294757807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8161294357612942613e40565b5b0490505b6000640100000000828161295e5761295d613e40565b5b061461296b57600161296e565b60005b60ff16602082901c0192505050919050565b60008161271084866129929190613f37565b61299c9190613e9e565b6129a69190613ecf565b90509392505050565b60006002600088815260200190815260200160002060009054906101000a900460ff1615612a09576040517f5b80006900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60016002600089815260200190815260200160002060006101000a81548160ff021916908315150217905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612a9b576040517f1decc10200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600085805190602001209050612af58186868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050612fbf565b91508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612b5c576040517f8baa579f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b42871015612b96576040517f0819bdcd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b509695505050505050565b606060ff60001b8314612bbe57612bb78361304f565b9050612c4b565b818054612bca9061485c565b80601f0160208091040260200160405190810160405280929190818152602001828054612bf69061485c565b8015612c435780601f10612c1857610100808354040283529160200191612c43565b820191906000526020600020905b815481529060010190602001808311612c2657829003601f168201915b505050505090505b92915050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612cce57600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16612cf2565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff165b90506000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610612db3576040518060400160405280600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff16815250612e17565b60405180604001604052808573ffffffffffffffffffffffffffffffffffffffff168152602001600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505b90506000612e2983610139600d611bb4565b90506000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1610612e8a57601054612e8e565b600f545b90506000612ec08373ffffffffffffffffffffffffffffffffffffffff16836c010000000000000000000000006130c3565b90508473ffffffffffffffffffffffffffffffffffffffff1663128acb0830600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff1610898589604051602001612f4391906148bc565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401612f72959493929190614930565b60408051808303816000875af1158015612f90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fb4919061499f565b505050505050505050565b600080612fcb8461319c565b9050612fe083826131b690919063ffffffff16565b9150600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613048576040517f8baa579f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5092915050565b6060600061305c836131e2565b90506000602067ffffffffffffffff81111561307b5761307a613fbf565b5b6040519080825280601f01601f1916602001820160405280156130ad5781602001600182028036833780820191505090505b5090508181528360208201528092505050919050565b60008060008019858709858702925082811083820303915050600081036130fd57600084116130f157600080fd5b83820492505050613195565b80841161310957600080fd5b600084868809905082811182039150808303925060008586600003169050808604955080840493506001818260000304019050808302841793506000600287600302189050808702600203810290508087026002038102905080870260020381029050808702600203810290508087026002038102905080870260020381029050808502955050505050505b9392505050565b60006131af6131a9613232565b836132e9565b9050919050565b6000806000806131c6868661332a565b9250925092506131d68282613386565b82935050505092915050565b60008060ff8360001c169050601f811115613229576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80915050919050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161480156132ae57507f000000000000000000000000000000000000000000000000000000000000000046145b156132db577f000000000000000000000000000000000000000000000000000000000000000090506132e6565b6132e36134ea565b90505b90565b60006040517f190100000000000000000000000000000000000000000000000000000000000081528360028201528260228201526042812091505092915050565b6000806000604184510361336f5760008060006020870151925060408701519150606087015160001a905061336188828585613580565b95509550955050505061337f565b60006002855160001b9250925092505b9250925092565b6000600381111561339a576133996149df565b5b8260038111156133ad576133ac6149df565b5b03156134e657600160038111156133c7576133c66149df565b5b8260038111156133da576133d96149df565b5b03613411576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60026003811115613425576134246149df565b5b826003811115613438576134376149df565b5b0361347d578060001c6040517ffce698f700000000000000000000000000000000000000000000000000000000815260040161347491906136cb565b60405180910390fd5b6003808111156134905761348f6149df565b5b8260038111156134a3576134a26149df565b5b036134e557806040517fd78bce0c0000000000000000000000000000000000000000000000000000000081526004016134dc9190614a0e565b60405180910390fd5b5b5050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000004630604051602001613565959493929190614a29565b60405160208183030381529060405280519060200120905090565b60008060007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08460001c11156135c057600060038592509250925061366a565b6000600188888888604051600081526020016040526040516135e59493929190614a98565b6020604051602081039080840390855afa158015613607573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361365b57600060016000801b9350935093505061366a565b8060008060001b935093509350505b9450945094915050565b6040518060800160405280600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001600081525090565b6000819050919050565b6136c5816136b2565b82525050565b60006020820190506136e060008301846136bc565b92915050565b6000604051905090565b600080fd5b600080fd5b613703816136b2565b811461370e57600080fd5b50565b600081359050613720816136fa565b92915050565b60006020828403121561373c5761373b6136f0565b5b600061374a84828501613711565b91505092915050565b60008115159050919050565b61376881613753565b82525050565b6000602082019050613783600083018461375f565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006137b482613789565b9050919050565b6137c4816137a9565b82525050565b60006020820190506137df60008301846137bb565b92915050565b6137ee816137a9565b81146137f957600080fd5b50565b60008135905061380b816137e5565b92915050565b60008060408385031215613828576138276136f0565b5b6000613836858286016137fc565b9250506020613847858286016137fc565b9150509250929050565b600060208284031215613867576138666136f0565b5b6000613875848285016137fc565b91505092915050565b613887816137a9565b82525050565b613896816136b2565b82525050565b6080820160008201516138b2600085018261387e565b5060208201516138c5602085018261388d565b5060408201516138d8604085018261388d565b5060608201516138eb606085018261388d565b50505050565b6000608082019050613906600083018461389c565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f8401126139315761393061390c565b5b8235905067ffffffffffffffff81111561394e5761394d613911565b5b60208301915083600182028301111561396a57613969613916565b5b9250929050565b60008060008060008060a0878903121561398e5761398d6136f0565b5b600061399c89828a01613711565b96505060206139ad89828a01613711565b95505060406139be89828a01613711565b945050606087013567ffffffffffffffff8111156139df576139de6136f5565b5b6139eb89828a0161391b565b935093505060806139fe89828a016137fc565b9150509295509295509295565b60008060408385031215613a2257613a216136f0565b5b6000613a30858286016137fc565b9250506020613a4185828601613711565b9150509250929050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b613a8081613a4b565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015613ac0578082015181840152602081019050613aa5565b60008484015250505050565b6000601f19601f8301169050919050565b6000613ae882613a86565b613af28185613a91565b9350613b02818560208601613aa2565b613b0b81613acc565b840191505092915050565b6000819050919050565b613b2981613b16565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000613b67838361388d565b60208301905092915050565b6000602082019050919050565b6000613b8b82613b2f565b613b958185613b3a565b9350613ba083613b4b565b8060005b83811015613bd1578151613bb88882613b5b565b9750613bc383613b73565b925050600181019050613ba4565b5085935050505092915050565b600060e082019050613bf3600083018a613a77565b8181036020830152613c058189613add565b90508181036040830152613c198188613add565b9050613c2860608301876136bc565b613c3560808301866137bb565b613c4260a0830185613b20565b81810360c0830152613c548184613b80565b905098975050505050505050565b60008060408385031215613c7957613c786136f0565b5b6000613c8785828601613711565b9250506020613c9885828601613711565b9150509250929050565b600080600080600060808688031215613cbe57613cbd6136f0565b5b6000613ccc88828901613711565b9550506020613cdd88828901613711565b9450506040613cee88828901613711565b935050606086013567ffffffffffffffff811115613d0f57613d0e6136f5565b5b613d1b8882890161391b565b92509250509295509295909350565b613d3381613789565b8114613d3e57600080fd5b50565b600081359050613d5081613d2a565b92915050565b60008060408385031215613d6d57613d6c6136f0565b5b6000613d7b858286016137fc565b9250506020613d8c85828601613d41565b9150509250929050565b6000819050919050565b613da981613d96565b8114613db457600080fd5b50565b600081359050613dc681613da0565b92915050565b60008060008060608587031215613de657613de56136f0565b5b6000613df487828801613db7565b9450506020613e0587828801613db7565b935050604085013567ffffffffffffffff811115613e2657613e256136f5565b5b613e328782880161391b565b925092505092959194509250565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613ea9826136b2565b9150613eb4836136b2565b925082613ec457613ec3613e40565b5b828204905092915050565b6000613eda826136b2565b9150613ee5836136b2565b9250828203905081811115613efd57613efc613e6f565b5b92915050565b6000613f0e826136b2565b9150613f19836136b2565b9250828201905080821115613f3157613f30613e6f565b5b92915050565b6000613f42826136b2565b9150613f4d836136b2565b9250828202613f5b816136b2565b91508282048414831517613f7257613f71613e6f565b5b5092915050565b600081905092915050565b50565b6000613f94600083613f79565b9150613f9f82613f84565b600082019050919050565b6000613fb582613f87565b9150819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600081519050613ffd816136fa565b92915050565b600060208284031215614019576140186136f0565b5b600061402784828501613fee565b91505092915050565b600060808201905061404560008301876136bc565b61405260208301866136bc565b61405f60408301856136bc565b61406c60608301846136bc565b95945050505050565b600062ffffff82169050919050565b61408d81614075565b82525050565b60006060820190506140a860008301866137bb565b6140b560208301856137bb565b6140c26040830184614084565b949350505050565b6000815190506140d9816137e5565b92915050565b6000602082840312156140f5576140f46136f0565b5b6000614103848285016140ca565b91505092915050565b61411581613789565b82525050565b6000602082019050614130600083018461410c565b92915050565b600061ffff82169050919050565b61414d81614136565b82525050565b60006020820190506141686000830184614144565b92915050565b600080fd5b61417c82613acc565b810181811067ffffffffffffffff8211171561419b5761419a613fbf565b5b80604052505050565b60006141ae6136e6565b90506141ba8282614173565b919050565b6000604082840312156141d5576141d461416e565b5b6141df60406141a4565b905060006141ef848285016137fc565b6000830152506020614203848285016137fc565b60208301525092915050565b600060408284031215614225576142246136f0565b5b6000614233848285016141bf565b91505092915050565b600060608201905061425160008301866137bb565b61425e60208301856137bb565b61426b60408301846136bc565b949350505050565b61427c81613753565b811461428757600080fd5b50565b60008151905061429981614273565b92915050565b6000602082840312156142b5576142b46136f0565b5b60006142c38482850161428a565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600063ffffffff82169050919050565b61434081614327565b82525050565b60006143528383614337565b60208301905092915050565b6000602082019050919050565b6000614376826142fb565b6143808185614306565b935061438b83614317565b8060005b838110156143bc5781516143a38882614346565b97506143ae8361435e565b92505060018101905061438f565b5085935050505092915050565b600060208201905081810360008301526143e3818461436b565b905092915050565b600067ffffffffffffffff82111561440657614405613fbf565b5b602082029050602081019050919050565b60008160060b9050919050565b61442d81614417565b811461443857600080fd5b50565b60008151905061444a81614424565b92915050565b600061446361445e846143eb565b6141a4565b9050808382526020820190506020840283018581111561448657614485613916565b5b835b818110156144af578061449b888261443b565b845260208401935050602081019050614488565b5050509392505050565b600082601f8301126144ce576144cd61390c565b5b81516144de848260208601614450565b91505092915050565b600067ffffffffffffffff82111561450257614501613fbf565b5b602082029050602081019050919050565b60008151905061452281613d2a565b92915050565b600061453b614536846144e7565b6141a4565b9050808382526020820190506020840283018581111561455e5761455d613916565b5b835b8181101561458757806145738882614513565b845260208401935050602081019050614560565b5050509392505050565b600082601f8301126145a6576145a561390c565b5b81516145b6848260208601614528565b91505092915050565b600080604083850312156145d6576145d56136f0565b5b600083015167ffffffffffffffff8111156145f4576145f36136f5565b5b614600858286016144b9565b925050602083015167ffffffffffffffff811115614621576146206136f5565b5b61462d85828601614591565b9150509250929050565b600061464282614417565b915061464d83614417565b92508282039050667fffffffffffff81137fffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000821217156146905761468f613e6f565b5b92915050565b60006146a182614417565b91506146ac83614417565b9250826146bc576146bb613e40565b5b600160000383147fffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000831416156146f5576146f4613e6f565b5b828205905092915050565b60006080820190506147156000830187613b20565b61472260208301866136bc565b61472f60408301856136bc565b61473c60608301846136bc565b95945050505050565b600060408201905061475a60008301856137bb565b61476760208301846136bc565b9392505050565b600081519050919050565b60006147848261476e565b61478e8185613f79565b935061479e818560208601613aa2565b80840191505092915050565b60006147b68284614779565b915081905092915050565b7f5354000000000000000000000000000000000000000000000000000000000000600082015250565b60006147f7600283613a91565b9150614802826147c1565b602082019050919050565b60006020820190508181036000830152614826816147ea565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061487457607f821691505b6020821081036148875761488661482d565b5b50919050565b6040820160008201516148a3600085018261387e565b5060208201516148b6602085018261387e565b50505050565b60006040820190506148d1600083018461488d565b92915050565b6148e081613d96565b82525050565b600082825260208201905092915050565b60006149028261476e565b61490c81856148e6565b935061491c818560208601613aa2565b61492581613acc565b840191505092915050565b600060a08201905061494560008301886137bb565b614952602083018761375f565b61495f60408301866148d7565b61496c606083018561410c565b818103608083015261497e81846148f7565b90509695505050505050565b60008151905061499981613da0565b92915050565b600080604083850312156149b6576149b56136f0565b5b60006149c48582860161498a565b92505060206149d58582860161498a565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6000602082019050614a236000830184613b20565b92915050565b600060a082019050614a3e6000830188613b20565b614a4b6020830187613b20565b614a586040830186613b20565b614a6560608301856136bc565b614a7260808301846137bb565b9695505050505050565b600060ff82169050919050565b614a9281614a7c565b82525050565b6000608082019050614aad6000830187613b20565b614aba6020830186614a89565b614ac76040830185613b20565b614ad46060830184613b20565b9594505050505056fea26469706673582212207c04fa87601050770eb6ea2db2c6c88d9dc969f2af9c85d03ba3056541819e0b64736f6c63430008160033000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b1000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000040000000000000000000000009e082323f45d2c3f300e3586ce66b453988173310000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000a2a2c5cb7ba6d1a08ae333dc0099b6411d13dd4f00000000000000000000000000000000000000000000000000000000000003200000000000000000000000000e25c4c6735e6553b6b517c3bf268ee968ed109c0000000000000000000000000000000000000000000000000000000000000320000000000000000000000000b6a29917ba8006db3812d8c539bf670b85b2634d0000000000000000000000000000000000000000000000000000000000000190
Deployed Bytecode
0x6080604052600436106101f15760003560e01c80637a0443231161010d578063bc9ef3e0116100a0578063e75e1f291161006f578063e75e1f2914610735578063eaafef6a14610751578063eb7d4fd81461076d578063f2fde38b14610796578063fa461e33146107bf576102b6565b8063bc9ef3e01461069a578063d03122a8146106b6578063e3067449146106df578063e55a68b31461070a576102b6565b80638aec8542116100dc5780638aec8542146105fd5780638c04166f146106285780638da5cb5b14610653578063b2dd823c1461067e576102b6565b80637a0443231461054b5780637cdcf4bd146105765780638496bc7b146105a157806384b0196e146105cc576102b6565b80634a7c525211610185578063681d167b11610154578063681d167b146104c6578063698ca058146104ef5780636f80790314610518578063715018a614610534576102b6565b80634a7c5252146104175780634b97d2dd14610442578063635ce3ad1461047f578063649736dc1461049b576102b6565b80633807b58a116101c15780633807b58a146103685780633bb39037146103935780633cf1f102146103d057806343f68a49146103fb576102b6565b8062b1e76e146102bb578063174293e1146102f857806322a7aac81461031457806333175c7c1461033f576102b6565b366102b6577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1603156102b457600080610256346107e8565b9150915061026381610898565b3373ffffffffffffffffffffffffffffffffffffffff167fc80bd2abff7085782e6a7bfff1fac71066cbc25766fd8054aa2f4b474cee1f7f836040516102a991906136cb565b60405180910390a250505b005b600080fd5b3480156102c757600080fd5b506102e260048036038101906102dd9190613726565b6108ab565b6040516102ef919061376e565b60405180910390f35b610312600480360381019061030d9190613726565b6108cb565b005b34801561032057600080fd5b5061032961095f565b60405161033691906137ca565b60405180910390f35b34801561034b57600080fd5b5061036660048036038101906103619190613811565b610985565b005b34801561037457600080fd5b5061037d610ad2565b60405161038a91906137ca565b60405180910390f35b34801561039f57600080fd5b506103ba60048036038101906103b59190613726565b610afc565b6040516103c791906136cb565b60405180910390f35b3480156103dc57600080fd5b506103e5610b86565b6040516103f291906137ca565b60405180910390f35b61041560048036038101906104109190613726565b610bac565b005b34801561042357600080fd5b5061042c610bbe565b60405161043991906136cb565b60405180910390f35b34801561044e57600080fd5b5061046960048036038101906104649190613851565b610bc4565b60405161047691906138f1565b60405180910390f35b61049960048036038101906104949190613726565b610bdc565b005b3480156104a757600080fd5b506104b0610bee565b6040516104bd91906136cb565b60405180910390f35b3480156104d257600080fd5b506104ed60048036038101906104e89190613971565b610bf4565b005b3480156104fb57600080fd5b5061051660048036038101906105119190613a0b565b610c0a565b005b610532600480360381019061052d9190613726565b610cf2565b005b34801561054057600080fd5b50610549610d04565b005b34801561055757600080fd5b50610560610d18565b60405161056d91906136cb565b60405180910390f35b34801561058257600080fd5b5061058b610d22565b60405161059891906137ca565b60405180910390f35b3480156105ad57600080fd5b506105b6610d48565b6040516105c391906136cb565b60405180910390f35b3480156105d857600080fd5b506105e1610d4e565b6040516105f49796959493929190613bde565b60405180910390f35b34801561060957600080fd5b50610612610df8565b60405161061f91906136cb565b60405180910390f35b34801561063457600080fd5b5061063d610e0e565b60405161064a91906136cb565b60405180910390f35b34801561065f57600080fd5b50610668610e14565b60405161067591906137ca565b60405180910390f35b61069860048036038101906106939190613726565b610e3e565b005b6106b460048036038101906106af9190613c62565b610e50565b005b3480156106c257600080fd5b506106dd60048036038101906106d89190613851565b610e6a565b005b3480156106eb57600080fd5b506106f4610eb6565b60405161070191906136cb565b60405180910390f35b34801561071657600080fd5b5061071f610ebc565b60405161072c91906136cb565b60405180910390f35b61074f600480360381019061074a9190613726565b610ec2565b005b61076b60048036038101906107669190613ca2565b610ed4565b005b34801561077957600080fd5b50610794600480360381019061078f9190613d56565b61121c565b005b3480156107a257600080fd5b506107bd60048036038101906107b89190613851565b61150e565b005b3480156107cb57600080fd5b506107e660048036038101906107e19190613dcc565b611594565b005b6000806000831115610893576004836108019190613e9e565b9050808361080f9190613ecf565b91507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b15801561087957600080fd5b505af115801561088d573d6000803e3d6000fd5b50505050505b915091565b8060046000828254019250508190555050565b60026020528060005260406000206000915054906101000a900460ff1681565b6000806108d7836119d2565b915091506000806108e7346107e8565b915091506108ff81846108fa9190613f03565b610898565b3373ffffffffffffffffffffffffffffffffffffffff167fc80bd2abff7085782e6a7bfff1fac71066cbc25766fd8054aa2f4b474cee1f7f83866109439190613f03565b60405161095091906136cb565b60405180910390a25050505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61098d611b2d565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610a06576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b6000601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600080610b2f600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610139600d611bb4565b90506000605c8273ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16610b6d9190613f37565b901c90508084610b7d9190613f37565b92505050919050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610bb4611b2d565b80600a8190555050565b60075481565b610bcc613674565b610bd582611d62565b9050919050565b610be4611b2d565b8060088190555050565b600b5481565b610c02868686868686611e59565b505050505050565b6000610c1533611d62565b905080606001518211610c285781610c2e565b80606001515b915060008203610c3e5750610cee565b610c488183611eb5565b60008373ffffffffffffffffffffffffffffffffffffffff1683604051610c6e90613faa565b60006040518083038185875af1925050503d8060008114610cab576040519150601f19603f3d011682016040523d82523d6000602084013e610cb0565b606091505b5050905080610ceb576040517f9c8d2cd200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505b5050565b610cfa611b2d565b80600b8190555050565b610d0c611b2d565b610d166000611f1a565b565b6000600454905090565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60085481565b600060608060008060006060610d62611fe0565b610d6a61201b565b46306000801b600067ffffffffffffffff811115610d8b57610d8a613fbf565b5b604051908082528060200260200182016040528015610db95781602001602082028036833780820191505090505b507f0f00000000000000000000000000000000000000000000000000000000000000959493929190965096509650965096509650965090919293949596565b600080610e03612056565b925050508091505090565b600a5481565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610e46611b2d565b8060098190555050565b610e58611b2d565b81600f81905550806010819055505050565b610e72611b2d565b80601160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60065481565b60095481565b610eca611b2d565b8060078190555050565b610f048585858585601160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16611e59565b600954600654610f149190613f03565b421015610f4d576040517fbcbfd86d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000806000610f5a612056565b9250925092507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b8152600401610fb991906136cb565b600060405180830381600087803b158015610fd357600080fd5b505af1158015610fe7573d6000803e3d6000fd5b505050503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611031573d6000803e3d6000fd5b50600083111561104557611044836121ec565b5b600082111561105857611057826123ea565b5b6000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016110ba91906137ca565b602060405180830381865afa1580156110d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110fb9190614003565b90506000810361110f575050505050611215565b89811015611149576040517fd431243000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff166342966c68826040518263ffffffff1660e01b815260040161118291906136cb565b600060405180830381600087803b15801561119c57600080fd5b505af11580156111b0573d6000803e3d6000fd5b50505050426006819055503373ffffffffffffffffffffffffffffffffffffffff167f20be56edb2a2243a5bf294ac4fce64330b448ea81268de70d1ad5db2e3ba0bea848787856040516112079493929190614030565b60405180910390a250505050505b5050505050565b611224611b2d565b600073ffffffffffffffffffffffffffffffffffffffff16600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146112ac576040517fc584641000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81600e60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98473ffffffffffffffffffffffffffffffffffffffff1663a16712957f000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b1846127106040518463ffffffff1660e01b815260040161136c93929190614093565b6020604051808303816000875af115801561138b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113af91906140df565b600d60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f637731d826040518263ffffffff1660e01b815260040161144a919061411b565b600060405180830381600087803b15801561146457600080fd5b505af1158015611478573d6000803e3d6000fd5b50505050600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166332148f6760196040518263ffffffff1660e01b81526004016114d89190614153565b600060405180830381600087803b1580156114f257600080fd5b505af1158015611506573d6000803e3d6000fd5b505050505050565b611516611b2d565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036115885760006040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161157f91906137ca565b60405180910390fd5b61159181611f1a565b50565b600082828101906115a5919061420f565b9050600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141580156116535750600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614155b1561168a576040517fddb5de5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161415801561173e5750600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff1614155b15611775576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16036118b6577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161415801561187a57507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff1614155b156118b1576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61199e565b7f000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b173ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff161415801561196657507f000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b173ffffffffffffffffffffffffffffffffffffffff16816020015173ffffffffffffffffffffffffffffffffffffffff1614155b1561199d576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5b60008513156119bb576119b681600001513387612417565b6119cb565b6119ca81602001513386612417565b5b5050505050565b6000806000831115611b28577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff1660e01b8152600401611a3b9392919061423c565b6020604051808303816000875af1158015611a5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7e919061429f565b50600483611a8c9190613e9e565b90507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff16632e1a7d4d826040518263ffffffff1660e01b8152600401611ae791906136cb565b600060405180830381600087803b158015611b0157600080fd5b505af1158015611b15573d6000803e3d6000fd5b505050508083611b259190613ecf565b91505b915091565b611b3561256c565b73ffffffffffffffffffffffffffffffffffffffff16611b53610e14565b73ffffffffffffffffffffffffffffffffffffffff1614611bb257611b7661256c565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401611ba991906137ca565b60405180910390fd5b565b600080600267ffffffffffffffff811115611bd257611bd1613fbf565b5b604051908082528060200260200182016040528015611c005781602001602082028036833780820191505090505b5090508381600081518110611c1857611c176142cc565b5b602002602001019063ffffffff16908163ffffffff16815250508281600181518110611c4757611c466142cc565b5b602002602001019063ffffffff16908163ffffffff168152505060008573ffffffffffffffffffffffffffffffffffffffff1663883bdbfd836040518263ffffffff1660e01b8152600401611c9c91906143c9565b600060405180830381865afa158015611cb9573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611ce291906145bf565b50905060008486611cf39190614637565b905060008183600081518110611d0c57611d0b6142cc565b5b602002602001015184600181518110611d2857611d276142cc565b5b6020026020010151611d3a9190614637565b611d449190614696565b90506000611d5182612574565b905080955050505050509392505050565b611d6a613674565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508061ffff168260200181815250506000826020015103611dce5750611e54565b82826000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601081901c7dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16826040018181525050611e4960045483602001518460400151612980565b826060018181525050505b919050565b611eac85857fe07b316fc052bc85fc67b3281fa5a5183addeb51e33e1637a142517b0c1e4773898989604051602001611e959493929190614700565b6040516020818303038152906040528686866129af565b50505050505050565b81602001516010828460400151611ecc9190613f03565b901b1760056000846000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b606061201660007f50756c7361722042757920416e64204275726e00000000000000000000000013612ba190919063ffffffff16565b905090565b606061205160017f312e302e30000000000000000000000000000000000000000000000000000005612ba190919063ffffffff16565b905090565b60008060007f000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016120b491906137ca565b602060405180830381865afa1580156120d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120f59190614003565b915060007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161215291906137ca565b602060405180830381865afa15801561216f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121939190614003565b905060075481116121a457806121a8565b6007545b9350612710600b54856121bb9190613f37565b6121c59190613e9e565b91508382116121d457816121d6565b835b915081846121e49190613ecf565b935050909192565b600073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036123bc577f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98473ffffffffffffffffffffffffffffffffffffffff16631698ee827f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166127106040518463ffffffff1660e01b81526004016122e393929190614093565b602060405180830381865afa158015612300573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061232491906140df565b600c60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff16600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603156123e7575b6123e67f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc282612c51565b5b50565b6124147f000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b182612c51565b50565b6000808473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60e01b858560405160240161244c929190614745565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516124b691906147aa565b6000604051808303816000865af19150503d80600081146124f3576040519150601f19603f3d011682016040523d82523d6000602084013e6124f8565b606091505b50915091508180156125265750600081511480612525575080806020019051810190612524919061429f565b5b5b612565576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161255c9061480d565b60405180910390fd5b5050505050565b600033905090565b60008060008360020b1261258b578260020b612593565b8260020b6000035b90507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2761860000360020b8111156125f5576040517f2bc80f3a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008060018316036126185770010000000000000000000000000000000061262a565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600060028316146126645760806ffff97272373d413259a46990580e213a8202901c90505b600060048316146126895760806ffff2e50f5f656932ef12357cf3c7fdcc8202901c90505b600060088316146126ae5760806fffe5caca7e10e4e61c3624eaa0941cd08202901c90505b600060108316146126d35760806fffcb9843d60f6159c9db58835c9266448202901c90505b600060208316146126f85760806fff973b41fa98c081472e6896dfb254c08202901c90505b6000604083161461271d5760806fff2ea16466c96a3843ec78b326b528618202901c90505b600060808316146127425760806ffe5dee046a99a2a811c461f1969c30538202901c90505b60006101008316146127685760806ffcbe86c7900a88aedcffc83b479aa3a48202901c90505b600061020083161461278e5760806ff987a7253ac413176f2b074cf7815e548202901c90505b60006104008316146127b45760806ff3392b0822b70005940c7a398e4b70f38202901c90505b60006108008316146127da5760806fe7159475a2c29b7443b29c7fa6e889d98202901c90505b60006110008316146128005760806fd097f3bdfd2022b8845ad8f792aa58258202901c90505b60006120008316146128265760806fa9f746462d870fdf8a65dc1f90e061e58202901c90505b600061400083161461284c5760806f70d869a156d2a1b890bb3df62baf32f78202901c90505b60006180008316146128725760806f31be135f97d08fd981231505542fcfa68202901c90505b6000620100008316146128995760806f09aa508b5b7a84e1c677de54f3e99bc98202901c90505b6000620200008316146128bf5760806e5d6af8dedb81196699c329225ee6048202901c90505b6000620400008316146128e45760806d2216e584f5fa1ea926041bedfe988202901c90505b6000620800008316146129075760806b048a170391f7dc42444e8fa28202901c90505b60008460020b131561294757807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8161294357612942613e40565b5b0490505b6000640100000000828161295e5761295d613e40565b5b061461296b57600161296e565b60005b60ff16602082901c0192505050919050565b60008161271084866129929190613f37565b61299c9190613e9e565b6129a69190613ecf565b90509392505050565b60006002600088815260200190815260200160002060009054906101000a900460ff1615612a09576040517f5b80006900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60016002600089815260200190815260200160002060006101000a81548160ff021916908315150217905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612a9b576040517f1decc10200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600085805190602001209050612af58186868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050612fbf565b91508273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612b5c576040517f8baa579f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b42871015612b96576040517f0819bdcd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b509695505050505050565b606060ff60001b8314612bbe57612bb78361304f565b9050612c4b565b818054612bca9061485c565b80601f0160208091040260200160405190810160405280929190818152602001828054612bf69061485c565b8015612c435780601f10612c1857610100808354040283529160200191612c43565b820191906000526020600020905b815481529060010190602001808311612c2657829003601f168201915b505050505090505b92915050565b60007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612cce57600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16612cf2565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff165b90506000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610612db3576040518060400160405280600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff16815250612e17565b60405180604001604052808573ffffffffffffffffffffffffffffffffffffffff168152602001600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152505b90506000612e2983610139600d611bb4565b90506000600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1610612e8a57601054612e8e565b600f545b90506000612ec08373ffffffffffffffffffffffffffffffffffffffff16836c010000000000000000000000006130c3565b90508473ffffffffffffffffffffffffffffffffffffffff1663128acb0830600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff1610898589604051602001612f4391906148bc565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401612f72959493929190614930565b60408051808303816000875af1158015612f90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fb4919061499f565b505050505050505050565b600080612fcb8461319c565b9050612fe083826131b690919063ffffffff16565b9150600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613048576040517f8baa579f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5092915050565b6060600061305c836131e2565b90506000602067ffffffffffffffff81111561307b5761307a613fbf565b5b6040519080825280601f01601f1916602001820160405280156130ad5781602001600182028036833780820191505090505b5090508181528360208201528092505050919050565b60008060008019858709858702925082811083820303915050600081036130fd57600084116130f157600080fd5b83820492505050613195565b80841161310957600080fd5b600084868809905082811182039150808303925060008586600003169050808604955080840493506001818260000304019050808302841793506000600287600302189050808702600203810290508087026002038102905080870260020381029050808702600203810290508087026002038102905080870260020381029050808502955050505050505b9392505050565b60006131af6131a9613232565b836132e9565b9050919050565b6000806000806131c6868661332a565b9250925092506131d68282613386565b82935050505092915050565b60008060ff8360001c169050601f811115613229576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80915050919050565b60007f00000000000000000000000010c5dd8b9d15f8295888c57af3602f4a3ef61d7973ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161480156132ae57507f000000000000000000000000000000000000000000000000000000000000000146145b156132db577f2c90e69c424c945253cec718caf3078643b7edcafbaa8209a38079dd57479d1a90506132e6565b6132e36134ea565b90505b90565b60006040517f190100000000000000000000000000000000000000000000000000000000000081528360028201528260228201526042812091505092915050565b6000806000604184510361336f5760008060006020870151925060408701519150606087015160001a905061336188828585613580565b95509550955050505061337f565b60006002855160001b9250925092505b9250925092565b6000600381111561339a576133996149df565b5b8260038111156133ad576133ac6149df565b5b03156134e657600160038111156133c7576133c66149df565b5b8260038111156133da576133d96149df565b5b03613411576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60026003811115613425576134246149df565b5b826003811115613438576134376149df565b5b0361347d578060001c6040517ffce698f700000000000000000000000000000000000000000000000000000000815260040161347491906136cb565b60405180910390fd5b6003808111156134905761348f6149df565b5b8260038111156134a3576134a26149df565b5b036134e557806040517fd78bce0c0000000000000000000000000000000000000000000000000000000081526004016134dc9190614a0e565b60405180910390fd5b5b5050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f7ca1c0e0f21df8a8deacbb6d800e0695ad2f4437cf8fa1e6140f7bcf4e1706ea7f06c015bd22b4c69690933c1058878ebdfef31f9aaae40bbe86d8a09fe1b2972c4630604051602001613565959493929190614a29565b60405160208183030381529060405280519060200120905090565b60008060007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08460001c11156135c057600060038592509250925061366a565b6000600188888888604051600081526020016040526040516135e59493929190614a98565b6020604051602081039080840390855afa158015613607573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361365b57600060016000801b9350935093505061366a565b8060008060001b935093509350505b9450945094915050565b6040518060800160405280600073ffffffffffffffffffffffffffffffffffffffff1681526020016000815260200160008152602001600081525090565b6000819050919050565b6136c5816136b2565b82525050565b60006020820190506136e060008301846136bc565b92915050565b6000604051905090565b600080fd5b600080fd5b613703816136b2565b811461370e57600080fd5b50565b600081359050613720816136fa565b92915050565b60006020828403121561373c5761373b6136f0565b5b600061374a84828501613711565b91505092915050565b60008115159050919050565b61376881613753565b82525050565b6000602082019050613783600083018461375f565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006137b482613789565b9050919050565b6137c4816137a9565b82525050565b60006020820190506137df60008301846137bb565b92915050565b6137ee816137a9565b81146137f957600080fd5b50565b60008135905061380b816137e5565b92915050565b60008060408385031215613828576138276136f0565b5b6000613836858286016137fc565b9250506020613847858286016137fc565b9150509250929050565b600060208284031215613867576138666136f0565b5b6000613875848285016137fc565b91505092915050565b613887816137a9565b82525050565b613896816136b2565b82525050565b6080820160008201516138b2600085018261387e565b5060208201516138c5602085018261388d565b5060408201516138d8604085018261388d565b5060608201516138eb606085018261388d565b50505050565b6000608082019050613906600083018461389c565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f8401126139315761393061390c565b5b8235905067ffffffffffffffff81111561394e5761394d613911565b5b60208301915083600182028301111561396a57613969613916565b5b9250929050565b60008060008060008060a0878903121561398e5761398d6136f0565b5b600061399c89828a01613711565b96505060206139ad89828a01613711565b95505060406139be89828a01613711565b945050606087013567ffffffffffffffff8111156139df576139de6136f5565b5b6139eb89828a0161391b565b935093505060806139fe89828a016137fc565b9150509295509295509295565b60008060408385031215613a2257613a216136f0565b5b6000613a30858286016137fc565b9250506020613a4185828601613711565b9150509250929050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b613a8081613a4b565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015613ac0578082015181840152602081019050613aa5565b60008484015250505050565b6000601f19601f8301169050919050565b6000613ae882613a86565b613af28185613a91565b9350613b02818560208601613aa2565b613b0b81613acc565b840191505092915050565b6000819050919050565b613b2981613b16565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000613b67838361388d565b60208301905092915050565b6000602082019050919050565b6000613b8b82613b2f565b613b958185613b3a565b9350613ba083613b4b565b8060005b83811015613bd1578151613bb88882613b5b565b9750613bc383613b73565b925050600181019050613ba4565b5085935050505092915050565b600060e082019050613bf3600083018a613a77565b8181036020830152613c058189613add565b90508181036040830152613c198188613add565b9050613c2860608301876136bc565b613c3560808301866137bb565b613c4260a0830185613b20565b81810360c0830152613c548184613b80565b905098975050505050505050565b60008060408385031215613c7957613c786136f0565b5b6000613c8785828601613711565b9250506020613c9885828601613711565b9150509250929050565b600080600080600060808688031215613cbe57613cbd6136f0565b5b6000613ccc88828901613711565b9550506020613cdd88828901613711565b9450506040613cee88828901613711565b935050606086013567ffffffffffffffff811115613d0f57613d0e6136f5565b5b613d1b8882890161391b565b92509250509295509295909350565b613d3381613789565b8114613d3e57600080fd5b50565b600081359050613d5081613d2a565b92915050565b60008060408385031215613d6d57613d6c6136f0565b5b6000613d7b858286016137fc565b9250506020613d8c85828601613d41565b9150509250929050565b6000819050919050565b613da981613d96565b8114613db457600080fd5b50565b600081359050613dc681613da0565b92915050565b60008060008060608587031215613de657613de56136f0565b5b6000613df487828801613db7565b9450506020613e0587828801613db7565b935050604085013567ffffffffffffffff811115613e2657613e256136f5565b5b613e328782880161391b565b925092505092959194509250565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613ea9826136b2565b9150613eb4836136b2565b925082613ec457613ec3613e40565b5b828204905092915050565b6000613eda826136b2565b9150613ee5836136b2565b9250828203905081811115613efd57613efc613e6f565b5b92915050565b6000613f0e826136b2565b9150613f19836136b2565b9250828201905080821115613f3157613f30613e6f565b5b92915050565b6000613f42826136b2565b9150613f4d836136b2565b9250828202613f5b816136b2565b91508282048414831517613f7257613f71613e6f565b5b5092915050565b600081905092915050565b50565b6000613f94600083613f79565b9150613f9f82613f84565b600082019050919050565b6000613fb582613f87565b9150819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600081519050613ffd816136fa565b92915050565b600060208284031215614019576140186136f0565b5b600061402784828501613fee565b91505092915050565b600060808201905061404560008301876136bc565b61405260208301866136bc565b61405f60408301856136bc565b61406c60608301846136bc565b95945050505050565b600062ffffff82169050919050565b61408d81614075565b82525050565b60006060820190506140a860008301866137bb565b6140b560208301856137bb565b6140c26040830184614084565b949350505050565b6000815190506140d9816137e5565b92915050565b6000602082840312156140f5576140f46136f0565b5b6000614103848285016140ca565b91505092915050565b61411581613789565b82525050565b6000602082019050614130600083018461410c565b92915050565b600061ffff82169050919050565b61414d81614136565b82525050565b60006020820190506141686000830184614144565b92915050565b600080fd5b61417c82613acc565b810181811067ffffffffffffffff8211171561419b5761419a613fbf565b5b80604052505050565b60006141ae6136e6565b90506141ba8282614173565b919050565b6000604082840312156141d5576141d461416e565b5b6141df60406141a4565b905060006141ef848285016137fc565b6000830152506020614203848285016137fc565b60208301525092915050565b600060408284031215614225576142246136f0565b5b6000614233848285016141bf565b91505092915050565b600060608201905061425160008301866137bb565b61425e60208301856137bb565b61426b60408301846136bc565b949350505050565b61427c81613753565b811461428757600080fd5b50565b60008151905061429981614273565b92915050565b6000602082840312156142b5576142b46136f0565b5b60006142c38482850161428a565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b600063ffffffff82169050919050565b61434081614327565b82525050565b60006143528383614337565b60208301905092915050565b6000602082019050919050565b6000614376826142fb565b6143808185614306565b935061438b83614317565b8060005b838110156143bc5781516143a38882614346565b97506143ae8361435e565b92505060018101905061438f565b5085935050505092915050565b600060208201905081810360008301526143e3818461436b565b905092915050565b600067ffffffffffffffff82111561440657614405613fbf565b5b602082029050602081019050919050565b60008160060b9050919050565b61442d81614417565b811461443857600080fd5b50565b60008151905061444a81614424565b92915050565b600061446361445e846143eb565b6141a4565b9050808382526020820190506020840283018581111561448657614485613916565b5b835b818110156144af578061449b888261443b565b845260208401935050602081019050614488565b5050509392505050565b600082601f8301126144ce576144cd61390c565b5b81516144de848260208601614450565b91505092915050565b600067ffffffffffffffff82111561450257614501613fbf565b5b602082029050602081019050919050565b60008151905061452281613d2a565b92915050565b600061453b614536846144e7565b6141a4565b9050808382526020820190506020840283018581111561455e5761455d613916565b5b835b8181101561458757806145738882614513565b845260208401935050602081019050614560565b5050509392505050565b600082601f8301126145a6576145a561390c565b5b81516145b6848260208601614528565b91505092915050565b600080604083850312156145d6576145d56136f0565b5b600083015167ffffffffffffffff8111156145f4576145f36136f5565b5b614600858286016144b9565b925050602083015167ffffffffffffffff811115614621576146206136f5565b5b61462d85828601614591565b9150509250929050565b600061464282614417565b915061464d83614417565b92508282039050667fffffffffffff81137fffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000821217156146905761468f613e6f565b5b92915050565b60006146a182614417565b91506146ac83614417565b9250826146bc576146bb613e40565b5b600160000383147fffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000831416156146f5576146f4613e6f565b5b828205905092915050565b60006080820190506147156000830187613b20565b61472260208301866136bc565b61472f60408301856136bc565b61473c60608301846136bc565b95945050505050565b600060408201905061475a60008301856137bb565b61476760208301846136bc565b9392505050565b600081519050919050565b60006147848261476e565b61478e8185613f79565b935061479e818560208601613aa2565b80840191505092915050565b60006147b68284614779565b915081905092915050565b7f5354000000000000000000000000000000000000000000000000000000000000600082015250565b60006147f7600283613a91565b9150614802826147c1565b602082019050919050565b60006020820190508181036000830152614826816147ea565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061487457607f821691505b6020821081036148875761488661482d565b5b50919050565b6040820160008201516148a3600085018261387e565b5060208201516148b6602085018261387e565b50505050565b60006040820190506148d1600083018461488d565b92915050565b6148e081613d96565b82525050565b600082825260208201905092915050565b60006149028261476e565b61490c81856148e6565b935061491c818560208601613aa2565b61492581613acc565b840191505092915050565b600060a08201905061494560008301886137bb565b614952602083018761375f565b61495f60408301866148d7565b61496c606083018561410c565b818103608083015261497e81846148f7565b90509695505050505050565b60008151905061499981613da0565b92915050565b600080604083850312156149b6576149b56136f0565b5b60006149c48582860161498a565b92505060206149d58582860161498a565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6000602082019050614a236000830184613b20565b92915050565b600060a082019050614a3e6000830188613b20565b614a4b6020830187613b20565b614a586040830186613b20565b614a6560608301856136bc565b614a7260808301846137bb565b9695505050505050565b600060ff82169050919050565b614a9281614a7c565b82525050565b6000608082019050614aad6000830187613b20565b614aba6020830186614a89565b614ac76040830185613b20565b614ad46060830184613b20565b9594505050505056fea26469706673582212207c04fa87601050770eb6ea2db2c6c88d9dc969f2af9c85d03ba3056541819e0b64736f6c63430008160033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b1000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000040000000000000000000000009e082323f45d2c3f300e3586ce66b453988173310000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000a2a2c5cb7ba6d1a08ae333dc0099b6411d13dd4f00000000000000000000000000000000000000000000000000000000000003200000000000000000000000000e25c4c6735e6553b6b517c3bf268ee968ed109c0000000000000000000000000000000000000000000000000000000000000320000000000000000000000000b6a29917ba8006db3812d8c539bf670b85b2634d0000000000000000000000000000000000000000000000000000000000000190
-----Decoded View---------------
Arg [0] : _titanx (address): 0xF19308F923582A6f7c465e5CE7a9Dc1BEC6665B1
Arg [1] : _weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [2] : _uniswapV3Factory (address): 0x1F98431c8aD98523631AE4a59f267346ea31F984
Arg [3] : genesisMembers (tuple[]): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput],System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput],System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput],System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]
-----Encoded View---------------
13 Constructor Arguments found :
Arg [0] : 000000000000000000000000f19308f923582a6f7c465e5ce7a9dc1bec6665b1
Arg [1] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [2] : 0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f984
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [5] : 0000000000000000000000009e082323f45d2c3f300e3586ce66b45398817331
Arg [6] : 0000000000000000000000000000000000000000000000000000000000001f40
Arg [7] : 000000000000000000000000a2a2c5cb7ba6d1a08ae333dc0099b6411d13dd4f
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000320
Arg [9] : 0000000000000000000000000e25c4c6735e6553b6b517c3bf268ee968ed109c
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000320
Arg [11] : 000000000000000000000000b6a29917ba8006db3812d8c539bf670b85b2634d
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000190
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
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.