Source Code
Overview
ETH Balance
0 ETH
Token Holdings
More Info
ContractCreator
Multi Chain
Multichain Addresses
0 address found via
Latest 22 from a total of 22 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
Create Order | 9209970 | 168 days 17 hrs ago | IN | 0 ETH | 0.00049525 | ||||
Create Order | 9209966 | 168 days 17 hrs ago | IN | 0 ETH | 0.00052439 | ||||
Cancel Orders | 9168221 | 176 days 8 hrs ago | IN | 0 ETH | 0.00110002 | ||||
Create Order | 9168220 | 176 days 8 hrs ago | IN | 0 ETH | 0.0049545 | ||||
Cancel Orders | 9168216 | 176 days 8 hrs ago | IN | 0 ETH | 0.00103678 | ||||
Create Order | 9168216 | 176 days 8 hrs ago | IN | 0 ETH | 0.00472011 | ||||
Create Order | 9154763 | 178 days 17 hrs ago | IN | 0 ETH | 0.00048723 | ||||
Create Order | 9154683 | 178 days 18 hrs ago | IN | 0 ETH | 0.00052438 | ||||
Create Order | 9154680 | 178 days 18 hrs ago | IN | 0 ETH | 0.0005244 | ||||
Create Order | 9150438 | 179 days 12 hrs ago | IN | 0 ETH | 0.00052438 | ||||
Create Order | 9150429 | 179 days 12 hrs ago | IN | 0 ETH | 0.00052438 | ||||
Create Order | 9149507 | 179 days 16 hrs ago | IN | 0 ETH | 0.00048979 | ||||
Create Order | 9149506 | 179 days 16 hrs ago | IN | 0 ETH | 0.00058777 | ||||
Create Order | 9149503 | 179 days 16 hrs ago | IN | 0 ETH | 0.00046002 | ||||
Create Order | 9149499 | 179 days 16 hrs ago | IN | 0 ETH | 0.00055268 | ||||
Create Order | 9149442 | 179 days 16 hrs ago | IN | 0 ETH | 0.00055262 | ||||
Cancel Orders | 9148973 | 179 days 18 hrs ago | IN | 0 ETH | 0.00013146 | ||||
Create Order | 9148963 | 179 days 18 hrs ago | IN | 0 ETH | 0.00058064 | ||||
Create Order | 9148934 | 179 days 18 hrs ago | IN | 0 ETH | 0.00045275 | ||||
Create Order | 9148921 | 179 days 18 hrs ago | IN | 0 ETH | 0.00058515 | ||||
Add Tokens To Wh... | 9144750 | 180 days 12 hrs ago | IN | 0 ETH | 0.00021122 | ||||
0x60806040 | 9144749 | 180 days 12 hrs ago | IN | Create: TradingPlatform | 0 ETH | 0.00663885 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Txn Hash | Block | From | To | Value | ||
---|---|---|---|---|---|---|
10013864 | 26 days 14 hrs ago | 0 ETH | ||||
10013864 | 26 days 14 hrs ago | 0 ETH | ||||
10013864 | 26 days 14 hrs ago | 0 ETH | ||||
10013850 | 26 days 14 hrs ago | 0 ETH | ||||
10013850 | 26 days 14 hrs ago | 0 ETH | ||||
10013850 | 26 days 14 hrs ago | 0 ETH | ||||
10013850 | 26 days 14 hrs ago | 0 ETH | ||||
10013850 | 26 days 14 hrs ago | 0 ETH | ||||
10013702 | 26 days 15 hrs ago | 0 ETH | ||||
10013702 | 26 days 15 hrs ago | 0 ETH | ||||
10013702 | 26 days 15 hrs ago | 0 ETH | ||||
10013690 | 26 days 15 hrs ago | 0 ETH | ||||
10013690 | 26 days 15 hrs ago | 0 ETH | ||||
10013690 | 26 days 15 hrs ago | 0 ETH | ||||
10013674 | 26 days 15 hrs ago | 0 ETH | ||||
10013674 | 26 days 15 hrs ago | 0 ETH | ||||
10013674 | 26 days 15 hrs ago | 0 ETH | ||||
10013674 | 26 days 15 hrs ago | 0 ETH | ||||
10013674 | 26 days 15 hrs ago | 0 ETH | ||||
10013639 | 26 days 15 hrs ago | 0 ETH | ||||
10013639 | 26 days 15 hrs ago | 0 ETH | ||||
10013639 | 26 days 15 hrs ago | 0 ETH | ||||
10013613 | 26 days 15 hrs ago | 0 ETH | ||||
10013613 | 26 days 15 hrs ago | 0 ETH | ||||
10013613 | 26 days 15 hrs ago | 0 ETH |
Loading...
Loading
Contract Name:
TradingPlatform
Compiler Version
v0.8.12+commit.f00d7308
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.12; import {ITradingPlatform} from "./interfaces/ITradingPlatform.sol"; import {IERC20WithDecimals} from "./interfaces/IERC20WithDecimals.sol"; import {ISwapHelperUniswapV3} from "./interfaces/ISwapHelperUniswapV3.sol"; import {Counters} from "@openzeppelin/contractsV4/utils/Counters.sol"; import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol"; import {SafeERC20, IERC20} from "@openzeppelin/contractsV4/token/ERC20/utils/SafeERC20.sol"; import {AccessControlEnumerable, EnumerableSet} from "@openzeppelin/contractsV4/access/AccessControlEnumerable.sol"; import {ReentrancyGuard} from "@openzeppelin/contractsV4/security/ReentrancyGuard.sol"; /** * @title The contract implements the token trading platform with different trading tools */ contract TradingPlatform is ITradingPlatform, AccessControlEnumerable, ReentrancyGuard { using SafeERC20 for IERC20; using Counters for Counters.Counter; using EnumerableSet for EnumerableSet.UintSet; using EnumerableSet for EnumerableSet.AddressSet; bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE"); // Representing the admin role. uint32 public constant PRECISION = 1000000; // Precision constant used for percentage calculations. Represents the decimal precision up to six decimal places. uint32 private secondsAgoDefault = 30; // Default value for the number of seconds ago used in average price calculations. uint32 private protocolFee; // Protocol fee applied to certain operations in the contract. Represents the fee percentage applied to specific operations within the contract. address private uniswapHelperV3; // Address of the Uniswap helper contract (version 3) used for swaps. address private feeRecipient; // Address of the recipient of protocol fees. Represents the address where the protocol fees are sent to. mapping(uint256 => uint256) private additionalInformation; // Mapping to store additional information related to orders. Used to store the last execution time for DCA orders or the last execution price for trailing orders. mapping(uint256 => uint256) private resultTokenOut; // Mapping to store the result token output for orders. aps the order ID to the amount of token received as a result of executing the order. mapping(uint256 => Order) private orderInfo; // Mapping to store order information. Maps the order ID to the order struct, containing detailed order information. mapping(address => uint256[]) private userOrders; // Mapping to store user orders. Maps the user's address to an array of order IDs representing all the orders associated with the user. mapping(address => mapping(address => uint256)) private balances; // Maps the user's address to a mapping of token addresses and their corresponding balances. Counters.Counter private orderCounter; // Counter to keep track of the number of orders. sed to count the total number of orders in the contract. EnumerableSet.AddressSet private tokensWhiteList; // Set of tokens in the whitelist. Contains the addresses of tokens that are allowed within the contract. EnumerableSet.UintSet private activeOrders; // Set of active orders. Contains the IDs of the currently active orders within the contract. /** * @dev See {ITradingPlatform} */ function activeOrdersLength() external view returns (uint256) { return activeOrders.length(); } /** * @dev See {ITradingPlatform} */ function activeOrderId(uint256 itemId) external view returns (uint256) { require(itemId < activeOrders.length(), "Invalid token id"); return activeOrders.at(itemId); } /** * @dev See {ITradingPlatform} */ function activeOrdersIds(uint256 offset, uint256 limit) external view returns (uint256[] memory ordersIds) { uint256 ordersCount = activeOrders.length(); if (offset >= ordersCount) return new uint256[](0); uint256 to = offset + limit; if (ordersCount < to) to = ordersCount; ordersIds = new uint256[](to - offset); for (uint256 i = 0; i < ordersIds.length; i++) ordersIds[i] = activeOrders.at(offset + i); } /** * @dev See {ITradingPlatform} */ function checkUpkeep(bytes calldata checkData) external view returns (bool upkeepNeeded, bytes memory performData) { (uint128 performOffset, uint128 performLimit) = abi.decode(checkData, (uint128, uint128)); uint256[] memory ordersIds = shouldRebalance(); // control perform part hire for gas saving if (performOffset >= ordersIds.length) return (upkeepNeeded, abi.encode(new uint256[](0))); uint256 performTo = (performOffset + performLimit) > ordersIds.length ? ordersIds.length : performOffset + performLimit; uint256[] memory checkArray = new uint256[](performTo - performOffset); for (uint256 i = 0; i < checkArray.length; i++) { checkArray[i] = ordersIds[performOffset + i]; } upkeepNeeded = ordersIds.length > 0; performData = abi.encode(checkArray); } /** * @dev See {ITradingPlatform} */ function getFeeRecipient() external view returns (address) { return feeRecipient; } /** * @dev See {ITradingPlatform} */ function getOrderCounter() external view returns (uint256) { return orderCounter.current(); } /** * @dev See {ITradingPlatform} */ function getProtocolFee() external view returns (uint32) { return protocolFee; } /** * @dev See {ITradingPlatform} */ function getResultTokenOut(uint256 orderId) external view returns (uint256) { return resultTokenOut[orderId]; } /** * @dev See {ITradingPlatform} */ function getSwapHelper() external view returns (address) { return uniswapHelperV3; } /** * @dev See {ITradingPlatform} */ function getTokenStatus(address token) external view returns (bool) { return tokensWhiteList.contains(token); } /** * @dev See {ITradingPlatform} */ function getUserBalance(address user, address token) external view returns (uint256) { return balances[user][token]; } /** * @dev See {ITradingPlatform} */ function getUserOrdersIds(address userAddress) external view returns (uint256[] memory) { return userOrders[userAddress]; } /** * @dev See {ITradingPlatform} */ function getUserOrdersInfo(address userAddress) external view returns (OrderInfo[] memory) { uint256[] memory userOrdersIds = userOrders[userAddress]; return getOrdersInfo(userOrdersIds); } /** * @dev See {ITradingPlatform} */ function isActiveOrderExist(uint256 orderId) external view returns (bool) { return activeOrders.contains(orderId); } /** * @dev See {ITradingPlatform} */ function checkOrder(uint256 orderId) public view returns (bool) { if (!activeOrders.contains(orderId)) return false; // Not active Order memory order = orderInfo[orderId]; if ((order.action == Action.PROFIT || order.action == Action.LOSS) && order.expiration < block.timestamp) { return false; } if (order.action == Action.DCA) { DCAOrderData memory decodedData = abi.decode(order.data, (DCAOrderData)); if (block.timestamp >= decodedData.period + additionalInformation[orderId]) return true; return false; } if (order.action == Action.TRAILING) { TrailingOrderData memory decodedData = abi.decode(order.data, (TrailingOrderData)); uint256 expectedAmountOutForTrailing = ISwapHelperUniswapV3(uniswapHelperV3).getAmountOut( order.baseToken, order.targetToken, decodedData.baseAmount, order.pairFee, secondsAgoDefault ); uint256 lastBuyingAmountOut = additionalInformation[orderId]; if ( (lastBuyingAmountOut == 0 && expectedAmountOutForTrailing >= order.aimTargetTokenAmount) || (lastBuyingAmountOut != 0 && // true (expectedAmountOutForTrailing >= lastBuyingAmountOut + getPercent(lastBuyingAmountOut, decodedData.step) || expectedAmountOutForTrailing < lastBuyingAmountOut - getPercent(lastBuyingAmountOut, decodedData.step))) ) return true; } uint256 expectedAmountOut = ISwapHelperUniswapV3(uniswapHelperV3).getAmountOut( order.baseToken, order.targetToken, order.baseAmount, order.pairFee, secondsAgoDefault ); if ( order.action == Action.LOSS && expectedAmountOut <= order.aimTargetTokenAmount && expectedAmountOut > order.minTargetTokenAmount ) return true; if (order.action == Action.PROFIT && expectedAmountOut >= order.aimTargetTokenAmount) { return true; } return false; } /** * @dev See {ITradingPlatform} */ function getOrdersInfo(uint256[] memory ordersIds) public view returns (OrderInfo[] memory orders) { orders = new OrderInfo[](ordersIds.length); for (uint256 i = 0; i < ordersIds.length; i++) { orders[i] = OrderInfo( ordersIds[i], orderInfo[ordersIds[i]], additionalInformation[ordersIds[i]], resultTokenOut[ordersIds[i]], activeOrders.contains(ordersIds[i]) ); } return orders; } /** * @dev See {ITradingPlatform} */ function shouldRebalance() public view returns (uint256[] memory) { //get Active Orders uint256 ordersCount = activeOrders.length(); uint256[] memory ordersIds = new uint256[](ordersCount); uint256 skipped = 0; for (uint256 i = 0; i < ordersCount; i++) { uint256 orderId = activeOrders.at(i); if (checkOrder(orderId)) { ordersIds[i - skipped] = orderId; } else { skipped++; } } if (skipped > 0) { uint256 newLength = ordersCount - skipped; assembly { mstore(ordersIds, newLength) } } return ordersIds; } /** * @notice Initializes the TradingPlatform contract with the specified parameters. * @param uniswapHelperV3_ The address of the UniswapHelperV3 contract. * @param admin The address of the contract admin. * @param protocolFee_ The protocol fee percentage, represented as a decimal with 6 digits precision. * @param feeRecipient_ The address where the protocol fees will be sent to. * @dev The UniswapHelperV3 address, admin address, and fee recipient address must not be zero addresses. * @dev The protocol fee must be less than 100% (represented as 1,000,000 in 6 digits precision). * @dev Sets the DEFAULT_ADMIN_ROLE and ADMIN_ROLE roles to the admin address. */ constructor(address uniswapHelperV3_, address admin, uint32 protocolFee_, address feeRecipient_) { require(uniswapHelperV3_ != address(0), "UniswapHelperV3 zero address"); require(admin != address(0), "Admin zero address"); require(feeRecipient_ != address(0), "Fee recipient zero address"); require(protocolFee_ < PRECISION, "Fee is 100% or greater"); _setupRole(DEFAULT_ADMIN_ROLE, admin); _setupRole(ADMIN_ROLE, admin); uniswapHelperV3 = uniswapHelperV3_; protocolFee = protocolFee_; feeRecipient = feeRecipient_; } /** * @dev See {ITradingPlatform} */ function addTokensToWhitelist(address[] memory tokens) external onlyRole(ADMIN_ROLE) { for (uint256 i = 0; i < tokens.length; i++) { require(tokens[i] != address(0), "Token zero address check"); if (tokensWhiteList.contains(tokens[i])) continue; tokensWhiteList.add(tokens[i]); emit TokenAdded(tokens[i]); } } /** * @dev See {ITradingPlatform} */ function boundOrders(uint256 leftOrderId, uint256 rightOrderId) external nonReentrant { require(leftOrderId != 0 && rightOrderId != 0 && leftOrderId != rightOrderId, "Non-compatible orders"); require( orderInfo[leftOrderId].userAddress == msg.sender && orderInfo[rightOrderId].userAddress == msg.sender, "Not your order" ); require( orderInfo[leftOrderId].action != Action.DCA && orderInfo[rightOrderId].action != Action.DCA, "Can't bound DCA" ); require( orderInfo[leftOrderId].boundOrder == 0 && orderInfo[rightOrderId].boundOrder == 0, "Orders already bounded" ); orderInfo[leftOrderId].boundOrder = rightOrderId; orderInfo[rightOrderId].boundOrder = leftOrderId; emit OrdersBounded(leftOrderId, rightOrderId); } /** * @dev See {ITradingPlatform} */ function cancelOrders(uint256[] memory ordersIds) external nonReentrant { for (uint256 i = 0; i < ordersIds.length; i++) { if (!activeOrders.contains(ordersIds[i])) continue; Order memory order = orderInfo[ordersIds[i]]; require(order.userAddress == msg.sender, "Not your order"); activeOrders.remove(ordersIds[i]); balances[order.userAddress][order.baseToken] += order.baseAmount; emit OrderCanceled(ordersIds[i]); } } /** * @dev See {ITradingPlatform} */ function createOrder(Order memory order) external nonReentrant returns (uint256) { require(order.userAddress == msg.sender, "Wrong user address"); require(order.baseToken != address(0), "Zero address check"); require(order.targetToken != address(0), "Zero address check"); require(order.baseToken != order.targetToken, "Tokens must be different"); require(order.baseAmount > 0, "Amount in must be gt 0"); require(order.slippage > 0 && order.slippage < 50000, "Unsafe slippage"); if (order.action != Action.DCA) require(order.aimTargetTokenAmount > 0, "Aim amount must be gt 0"); if (order.action == Action.PROFIT || order.action == Action.LOSS) { require(order.expiration > block.timestamp, "Wrong expiration date"); } require( tokensWhiteList.contains(order.baseToken) && tokensWhiteList.contains(order.targetToken), "Token not allowed" ); orderCounter.increment(); uint256 orderId = orderCounter.current(); if (order.action == Action.DCA) { DCAOrderData memory decodedData = abi.decode(order.data, (DCAOrderData)); require(decodedData.amountPerPeriod > 0, "Zero amount to swap"); additionalInformation[orderId] = block.timestamp; } else if (order.action == Action.TRAILING) { TrailingOrderData memory decodedData = abi.decode(order.data, (TrailingOrderData)); require(decodedData.fixingPerStep > 0, "Zero amount to swap"); require(decodedData.baseAmount == order.baseAmount, "Wrong base amount"); require(decodedData.step > 0, "Wrong step amount"); } if (order.boundOrder != 0) { Order memory boundOrder = orderInfo[order.boundOrder]; require(order.action != Action.DCA && boundOrder.action != Action.DCA, "Can't bound DCA order"); require(boundOrder.userAddress == msg.sender, "Bound order is not yours"); require(activeOrders.contains(order.boundOrder), "Bound order is not active"); require(boundOrder.boundOrder == 0, "Bound order already bounded"); orderInfo[order.boundOrder].boundOrder = orderId; } activeOrders.add(orderId); userOrders[msg.sender].push(orderId); orderInfo[orderId] = order; uint256 baseTokenUserBalance = balances[msg.sender][order.baseToken]; if (baseTokenUserBalance < order.baseAmount) { uint256 neededAmount = order.baseAmount - baseTokenUserBalance; if (baseTokenUserBalance != 0) balances[msg.sender][order.baseToken] = 0; IERC20(order.baseToken).safeTransferFrom(msg.sender, address(this), neededAmount); } else { balances[msg.sender][order.baseToken] -= order.baseAmount; } emit OrderCreated(orderId, msg.sender); return orderId; } /** * @dev See {ITradingPlatform} */ function deposit(address token, uint256 amount) external nonReentrant returns (bool) { require(tokensWhiteList.contains(token), "Token not allowed"); IERC20(token).safeTransferFrom(msg.sender, address(this), amount); balances[msg.sender][token] += amount; emit Deposited(msg.sender, token, amount); return true; } /** * @dev See {ITradingPlatform} */ function executeOrders(uint256[] memory ordersIds) public nonReentrant returns (bool) { for (uint256 i = 0; i < ordersIds.length; i++) { if (!checkOrder(ordersIds[i])) { continue; } executeOrder(ordersIds[i]); } return true; } /** * @dev See {ITradingPlatform} */ function performUpkeep(bytes calldata performData) external { uint256[] memory ordersIds = abi.decode(performData, (uint256[])); require(ordersIds.length > 0, "Nothing for execution"); executeOrders(ordersIds); } /** * @dev See {ITradingPlatform} */ function removeTokensFromWhitelist(address[] memory tokens) external onlyRole(ADMIN_ROLE) { for (uint256 i = 0; i < tokens.length; i++) { if (!tokensWhiteList.contains(tokens[i])) continue; tokensWhiteList.remove(tokens[i]); emit TokenRemoved(tokens[i]); } } /** * @dev See {ITradingPlatform} */ function setProtocolFee(uint32 newProtocolFee) external onlyRole(ADMIN_ROLE) { require(newProtocolFee < PRECISION, "newProtocolFee can't be gt 100%"); protocolFee = newProtocolFee; } /** * @dev See {ITradingPlatform} */ function withdraw(address token, uint256 amount) external nonReentrant returns (bool) { require(balances[msg.sender][token] >= amount, "Amount exceed balance"); balances[msg.sender][token] -= amount; IERC20(token).safeTransfer(msg.sender, amount); emit Withdrawed(msg.sender, token, amount); return true; } /** * @notice Executes an individual order based on the provided order ID. * @param orderId ID of the order to be executed. * @dev This function is internal and should not be called directly from outside the contract. * @dev Emits a {OrderExecuted} event. */ function executeOrder(uint256 orderId) internal { Order memory order = orderInfo[orderId]; uint128 amountToSwap = order.baseAmount; if (order.action == Action.TRAILING) { TrailingOrderData memory decodedData = abi.decode(order.data, (TrailingOrderData)); uint256 expectedAmountOut = ISwapHelperUniswapV3(uniswapHelperV3).getAmountOut( order.baseToken, order.targetToken, decodedData.baseAmount, order.pairFee, secondsAgoDefault ); uint256 lastBuyingAmountOut = additionalInformation[orderId]; if ( lastBuyingAmountOut == 0 || expectedAmountOut >= lastBuyingAmountOut + getPercent(lastBuyingAmountOut, decodedData.step) ) { if (decodedData.fixingPerStep >= order.baseAmount) { activeOrders.remove(orderId); //update active orders set } else { amountToSwap = decodedData.fixingPerStep; } } else if (expectedAmountOut < lastBuyingAmountOut - getPercent(lastBuyingAmountOut, decodedData.step)) { amountToSwap = order.baseAmount; activeOrders.remove(orderId); //update active orders set } additionalInformation[orderId] = expectedAmountOut; orderInfo[orderId].baseAmount -= amountToSwap; } else if (order.action == Action.DCA) { DCAOrderData memory decodedData = abi.decode(order.data, (DCAOrderData)); amountToSwap = decodedData.amountPerPeriod; if (decodedData.amountPerPeriod >= order.baseAmount) { amountToSwap = order.baseAmount; activeOrders.remove(orderId); //update active orders set } // update storage additionalInformation[orderId] = block.timestamp; orderInfo[orderId].baseAmount -= amountToSwap; } else if (order.action == Action.LOSS || order.action == Action.PROFIT) { activeOrders.remove(orderId); //update active orders set if (order.boundOrder != 0) { if (activeOrders.contains(order.boundOrder)) { Order memory boundOrder = orderInfo[order.boundOrder]; activeOrders.remove(order.boundOrder); balances[boundOrder.userAddress][boundOrder.baseToken] += boundOrder.baseAmount; emit OrderCanceled(order.boundOrder); } // remove bound orders and refund tokens to user balance } } IERC20(order.baseToken).approve(uniswapHelperV3, amountToSwap); uint256 amountOut = ISwapHelperUniswapV3(uniswapHelperV3).swapWithCustomSlippage( address(this), order.baseToken, order.targetToken, amountToSwap, order.pairFee, order.slippage ); uint256 feeAmount = calculateFee(amountOut, protocolFee); if (order.action == Action.LOSS || order.action == Action.PROFIT) require(order.minTargetTokenAmount < amountOut - feeAmount, "Unfair exchange"); balances[feeRecipient][order.targetToken] += feeAmount; // update fee balance balances[order.userAddress][order.targetToken] += amountOut - feeAmount; // update user balance resultTokenOut[orderId] += amountOut - feeAmount; // save amount that we get from this order execution emit OrderExecuted(orderId, msg.sender); } /** * @notice Calculates the fee amount based on the given token amount. * @param amount The token amount for which the fee is calculated. * @return uint256 The calculated fee amount. */ function calculateFee(uint256 amount, uint32 protocolFeePercent) internal pure returns (uint256) { return (amount * protocolFeePercent) / PRECISION; } /** * @notice Calculates the percentage of an amount. * @param amount The base amount. * @param percent The percentage value, represented as a decimal with 6 digits precision. * @return uint256 The calculated percentage amount. */ function getPercent(uint256 amount, uint24 percent) internal pure returns (uint256) { return (amount * percent) / PRECISION; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface AutomationCompatibleInterface { /** * @notice method that is simulated by the keepers to see if any work actually * needs to be performed. This method does does not actually need to be * executable, and since it is only ever simulated it can consume lots of gas. * @dev To ensure that it is never called, you may want to add the * cannotExecute modifier from KeeperBase to your implementation of this * method. * @param checkData specified in the upkeep registration so it is always the * same for a registered upkeep. This can easily be broken down into specific * arguments using `abi.decode`, so multiple upkeeps can be registered on the * same contract and easily differentiated by the contract. * @return upkeepNeeded boolean to indicate whether the keeper should call * performUpkeep or not. * @return performData bytes that the keeper should call performUpkeep with, if * upkeep is needed. If you would like to encode data to decode later, try * `abi.encode`. */ function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData); /** * @notice method that is actually executed by the keepers, via the registry. * The data returned by the checkUpkeep simulation will be passed into * this method to actually be executed. * @dev The input to this method should not be trusted, and the caller of the * method should not even be restricted to any single registry. Anyone should * be able call it, and the input should be validated, there is no guarantee * that the data passed in is the performData returned from checkUpkeep. This * could happen due to malicious keepers, racing keepers, or simply a state * change while the performUpkeep transaction is waiting for confirmation. * Always validate the data passed in. * @param performData is the data which was passed back from the checkData * simulation. If it is encoded, it can easily be decoded into other types by * calling `abi.decode`. This data should not be trusted, and should be * validated against the contract's current state. */ function performUpkeep(bytes calldata performData) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(account), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerable.sol"; import "./AccessControl.sol"; import "../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); _roleMembers[role].remove(account); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be 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; 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 require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // 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 v4.9.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @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 amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to * 0 before setting it to a non-zero value. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./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); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @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 v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 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; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) 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. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 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. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); 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 (rounding == Rounding.Up && 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 down. * * 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * 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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @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 v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @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), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(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) { 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] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); 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 keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import './pool/IUniswapV3PoolImmutables.sol'; import './pool/IUniswapV3PoolState.sol'; import './pool/IUniswapV3PoolDerivedState.sol'; import './pool/IUniswapV3PoolActions.sol'; import './pool/IUniswapV3PoolOwnerActions.sol'; import './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, 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 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 /// 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. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// 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 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, /// liquidityNet how much liquidity changes when the pool price crosses the tick, /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// secondsOutside the seconds spent on the other side of the tick from the current tick, /// 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, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns 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, /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// Returns 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.12; import {IERC20} from "@openzeppelin/contractsV4/token/ERC20/IERC20.sol"; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20WithDecimals is IERC20 { function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity >=0.7.6; interface ISwapHelperUniswapV3 { /** * @notice Emitted when seconds ago default updated * @param value The new param secondsAgoDefault */ event SecondsAgoDefaultUpdated(uint32 value); /** * @notice Emitted when slippage updated * @param value The new slippage value, where 100% = 1000000 */ event SlippageUpdated(uint256 value); /** * @notice Emitted when swap confirmed * @param beneficiary Beneficiary output tokens after swap * @param tokenIn Exchangeable token * @param tokenOut The other of the two tokens in the desired pool * @param amountIn The desired number of tokens for the exchange * @param amountOut Average number of tokens `amountOut` in the selected * time interval from the current moment and the pool */ event Swapped( address indexed beneficiary, address indexed tokenIn, address indexed tokenOut, uint128 amountIn, uint256 amountOut ); /** * @notice Get the minimum number of tokens for a subsequent swap, taking into account slippage * @param tokenIn One of the two tokens in the desired pool * @param tokenOut The other of the two tokens in the desired pool * @param amountIn The desired number of tokens for the exchange * @param fee The desired fee for the pool * @param secondsAgo The number of seconds from the current moment to calculate the average price * @dev tokenIn and tokenOut may be passed in either order: token0/token1 or token1/token0. * The call will revert if the pool not already exists, the fee is invalid, or the token arguments * are invalid. The minimum price is determined by a globally set parameter `_slippage` * @return amountOut Average number of tokens `amountOut` in the selected time interval from the current * moment and the pool */ function getAmountOut( address tokenIn, address tokenOut, uint128 amountIn, uint24 fee, uint32 secondsAgo ) external view returns (uint256 amountOut); /** * @notice Swaps `amountIn` of one token for as much as possible of another along the specified path * @param beneficiary Beneficiary `amountOut` after swap * @param tokenIn Exchangeable token * @param tokenOut Output token during the exchange * @param amountIn The desired number of tokens for the exchange * @param fee The desired fee for the pool * @dev tokenIn and tokenOut may be passed in either order: token0/token1 or token1/token0. * The call will revert if the pool not already exists, the fee is invalid, or the token arguments * are invalid. The minimum price is determined by a globally set parameter `_slippage` * @return amountOut The number of tokens at the exit after the swap */ function swap( address beneficiary, address tokenIn, address tokenOut, uint128 amountIn, uint24 fee ) external returns (uint256 amountOut); /** * @notice Swaps `amountIn` of one token for as much as possible of another along the specified path * @param beneficiary Beneficiary `amountOut` after swap * @param tokenIn Exchangeable token * @param tokenOut Output token during the exchange * @param amountIn The desired number of tokens for the exchange * @param fee The desired fee for the pool * @param slippageForSwap slippage for swap * @dev tokenIn and tokenOut may be passed in either order: token0/token1 or token1/token0. * The call will revert if the pool not already exists, the fee is invalid, or the token arguments * are invalid. The minimum price is determined by a globally set parameter `_slippage` * @return amountOut The number of tokens at the exit after the swap */ function swapWithCustomSlippage( address beneficiary, address tokenIn, address tokenOut, uint128 amountIn, uint24 fee, uint256 slippageForSwap ) external returns (uint256 amountOut); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.12; import {AutomationCompatibleInterface} from "@chainlink/contracts/src/v0.8/interfaces/AutomationCompatibleInterface.sol"; interface ITradingPlatform is AutomationCompatibleInterface { /** * @notice Represents an order created by a user. * @param userAddress The address of the user who created the order. * @param baseToken The address of the token to be swapped from. * @param targetToken The address of the token to be swapped to. * @param pairFee The fee percentage applied to the swap pair. * @param slippage The maximum acceptable slippage percentage for the swap. * @param baseAmount The amount of base tokens to be swapped. * @param aimTargetTokenAmount The target amount of target tokens to be obtained from the swap. * @param minTargetTokenAmount The minimum acceptable amount of target tokens to be obtained from the swap. * @param expiration The expiration timestamp of the order. * @param boundOrder The ID of the bound order, if any. * @param action The type of the order (DCA, TRAILING, LOSS, or PROFIT). * @param data Additional data associated with the order. */ struct Order { address userAddress; // The address of the user who created the order. address baseToken; // The address of the token to be swapped from. address targetToken; // The address of the token to be swapped to. uint24 pairFee; // The fee percentage applied to the UniSwap V3 pair. uint24 slippage; // The maximum acceptable slippage percentage for the swap. uint128 baseAmount; // The amount of base tokens to be swapped. uint128 aimTargetTokenAmount; // The target amount of target tokens to be obtained from the swap. uint128 minTargetTokenAmount; // The minimum acceptable amount of target tokens to be obtained from the swap. uint256 expiration; // The expiration timestamp of the order. uint256 boundOrder; // The ID of the bound order, if any. Action action; // The type of the order (DCA, TRAILING, LOSS, or PROFIT). bytes data; // Additional data associated with the order for different orders types. } /** * @notice Represents the information related to an order in the smart contract. * @param id The unique identifier of the order. * @param order The order details, including user address, token addresses, amounts, fees, and more. * @param additionalInformation Additional information associated with the order, * such as the last execution time for DCA or the last execution price for trailing orders. * @param resultTokenOut The amount of target tokens obtained from executing the order. * @param status The status of the order, indicating whether it is active or not. */ struct OrderInfo { uint256 id; // The unique identifier of the order. Order order; // The order details, {Order} struct. uint256 additionalInformation; // Additional information associated with the order, such as the last execution time for DCA or the last execution price for trailing orders. uint256 resultTokenOut; // The amount of target tokens obtained from executing the order. bool status; // The status of the order, indicating whether it is active or not. } /** * @notice Represents the additional data specific to a trailing order. * @param baseAmount The base amount of the order, duplicated for calculation purposes. * @param fixingPerStep The amount of the base token to fix on each step of the trailing order. * @param step The step in percentages for adjusting the trailing order. */ struct TrailingOrderData { uint128 baseAmount; // The base amount of the order, duplicated for calculation purposes. uint128 fixingPerStep; // The amount of the base token to fix on each step of the trailing order. uint24 step; // The step in percentages for adjusting the trailing order. } /** * @notice Represents the additional data specific to a Dollar-Cost Averaging (DCA) order. * @param period The period of buying, indicating the time interval between each purchase. * @param amountPerPeriod The amount of the base token to spend per period in the DCA strategy. */ struct DCAOrderData { uint128 period; // The period of buying, indicating the time interval between each purchase. uint128 amountPerPeriod; // The amount of the base token to spend per period in the DCA strategy. } /** * @notice This enum representing the actions that can be associated with an order. * @dev The actions include LOSS, PROFIT, DCA (Dollar-Cost Averaging), and TRAILING. * @dev LOSS: Specifies an order aiming to sell the base token when the target token's value falls below a certain threshold. * @dev PROFIT: Specifies an order aiming to sell the base token when the target token's value exceeds a certain threshold. * @dev DCA: Specifies an order using the Dollar-Cost Averaging strategy, where a fixed amount of the base token is periodically bought. * @dev TRAILING: Specifies an order using the trailing stop strategy, where the order adjusts its target based on the price movement. */ enum Action { LOSS, PROFIT, DCA, TRAILING } /** * @notice Emitted when tokens are deposited into the contract. * @param operator The address of the operator performing the deposit. * @param token The address of the deposited token. * @param amount The amount of tokens deposited. */ event Deposited(address operator, address token, uint256 amount); /** * @notice Emitted when two orders are bound together. * @param leftOrderId The ID of the left order in the binding. * @param rightOrderId The ID of the right order in the binding. */ event OrdersBounded(uint256 leftOrderId, uint256 rightOrderId); /** * @notice Emitted when an order is canceled. * @param orderId The ID of the canceled order. */ event OrderCanceled(uint256 orderId); /** * @notice Emitted when a new order is created. * @param orderId The ID of the newly created order. * @param userAddress The address of the user creating the order. */ event OrderCreated(uint256 orderId, address userAddress); /** * @notice Emitted when an order is executed. * @param orderId The ID of the executed order. * @param validator The address of the validator who executed the order. */ event OrderExecuted(uint256 orderId, address validator); /** * @notice Emitted when a new token is added to the contract. * @param token The address of the added token. */ event TokenAdded(address token); /** * @notice Emitted when a token is removed from the contract. * @param token The address of the removed token. */ event TokenRemoved(address token); /** * @notice Emitted when tokens are withdrawn from the contract. * @param operator The address of the operator performing the withdrawal. * @param token The address of the withdrawn token. * @param amount The amount of tokens withdrawn. */ event Withdrawed(address operator, address token, uint256 amount); /** * @notice Retrieves the number of active orders. * @return The count of active orders. * @dev This function is read-only and can be called by anyone. */ function activeOrdersLength() external view returns (uint256); /** * @notice Retrieves the active order ID at the specified index. * @param itemId The index of the active order in the active orders list. * @return The ID of the active order at the specified index. * @dev This function is read-only and can be called by anyone. * @dev Requires the itemId to be within the valid range of activeOrders length. */ function activeOrderId(uint256 itemId) external view returns (uint256); /** * @notice Retrieves an array of active order IDs based on pagination parameters. * @param offset The number of skipped elements. * @param limit The number of items requested. * @return ordersIds An array of active order IDs. * @dev This function is read-only and can be called by anyone. */ function activeOrdersIds(uint256 offset, uint256 limit) external view returns (uint256[] memory ordersIds); /** * @notice Checks the upkeep status and provides the necessary data for performing upkeep. * @param checkData Additional data for the upkeep check. * @return upkeepNeeded A boolean indicating whether upkeep is needed or not. * @return performData Encoded data containing the order IDs that require rebalance. * @dev This function is external and view-only. * @dev It calls the shouldRebalance function to retrieve the list of order IDs that need to be rebalanced. * @dev It sets upkeepNeeded to true if there are any orders that need to be rebalanced, and false otherwise. * @dev It encodes the list of order IDs into performData using the abi.encode function. * @dev Finally, it returns upkeepNeeded and performData. */ function checkUpkeep(bytes calldata checkData) external view returns (bool upkeepNeeded, bytes memory performData); /** * @notice Returns the address of the fee recipient. * @return The address of the fee recipient. * @dev This function is read-only and can be called by anyone. */ function getFeeRecipient() external view returns (address); /** * @notice Retrieves the current order counter. * @return The current order counter value. * @dev This function is read-only and can be called by anyone. */ function getOrderCounter() external view returns (uint256); /** * @notice Returns the current protocol fee percentage. * @return The current protocol fee percentage. * @dev This function is read-only and can be called by anyone. */ function getProtocolFee() external view returns (uint32); /** * @notice Retrieves the result token out value for a specific order ID. * @param orderId The ID of the order. * @return The result token out value for the order. * @dev This function is read-only and can be called by anyone. */ function getResultTokenOut(uint256 orderId) external view returns (uint256); /** * @notice Returns the address of the UniswapHelperV3 contract. * @return The address of the UniswapHelperV3 contract. * @dev This function is read-only and can be called by anyone. */ function getSwapHelper() external view returns (address); /** * @notice Checks if a token is whitelisted. * @param token The address of the token to check. * @return A boolean indicating whether the token is whitelisted or not. * @dev This function is read-only and can be called by anyone. */ function getTokenStatus(address token) external view returns (bool); /** * @notice Retrieves the balance of a specific token for a user. * @param user The address of the user. * @param token The address of the token. * @return The balance of the token for the user. * @dev This function is read-only and can be called by anyone. */ function getUserBalance(address user, address token) external view returns (uint256); /** * @notice Retrieves the array of order IDs associated with a user address. * @param userAddress The address of the user. * @return An array of order IDs associated with the user address. * @dev This function is read-only and can be called by anyone. */ function getUserOrdersIds(address userAddress) external view returns (uint256[] memory); /** * @notice Retrieves detailed information about the user's orders. * @param userAddress The address of the user. * @return An array of OrderInfo structs containing detailed information about the user's orders. * @dev This function is read-only and can be called by anyone. */ function getUserOrdersInfo(address userAddress) external view returns (OrderInfo[] memory); /** * @notice Checks if an active order with the given ID exists. * @param orderId The ID of the order. * @return A boolean indicating whether an active order with the given ID exists or not. * @dev This function is read-only and can be called by anyone. */ function isActiveOrderExist(uint256 orderId) external view returns (bool); /** * @notice Checks if an order is valid and can be executed. * @param orderId The ID of the order to be checked. * @return bool True if the order is valid and can be executed, false otherwise. */ function checkOrder(uint256 orderId) external view returns (bool); /** * @notice Retrieves detailed information about multiple orders. * @param ordersIds An array of order IDs. * @return orders An array of OrderInfo structs containing detailed information about the orders. * @dev This function is read-only and can be called by anyone. */ function getOrdersInfo(uint256[] memory ordersIds) external view returns (OrderInfo[] memory orders); /** * @notice Retrieves the list of order IDs that need to be rebalanced. * @return An array of order IDs that require rebalance. * @dev Initializes an array of order IDs with the size of the active orders count. * @dev Iterates over the active orders and checks each order using the checkOrder function. * @dev If an order needs to be rebalanced, it adds the order ID to the ordersIds array. * @dev If an order does not need to be rebalanced, it increments the skipped counter. * @dev If any orders were skipped, it adjusts the length of the ordersIds array accordingly. * @dev Finally, it returns the array of order IDs that need to be rebalanced. */ function shouldRebalance() external view returns (uint256[] memory); /** * @notice Adds multiple tokens to the whitelist. * @param tokens An array of token addresses to add. * @dev Only callable by an address with the ADMIN_ROLE. * @dev Requires each token address to be non-zero and not already in the whitelist. * @dev Emits a {TokenAdded} event for each token added to the whitelist. */ function addTokensToWhitelist(address[] memory tokens) external; /** * @notice Binds two orders together. * @param leftOrderId The ID of the left order to bind. * @param rightOrderId The ID of the right order to bind. * @dev Requires both orders to belong to the calling user and not be DCA orders. * @dev Requires both orders to not be already bound with other orders. * @dev Updates the boundOrder field of each order to bind them together. * @dev Emits a {OrdersBounded} event upon successful binding of the orders. */ function boundOrders(uint256 leftOrderId, uint256 rightOrderId) external; /** * @notice Cancels the specified orders. * @param ordersIds Array of order IDs to be canceled. * @dev Requires the orders to be active and belong to the calling user. * @dev Refunds the base tokens to the user balance. * @dev Emits a {OrderCanceled} event for each canceled order. */ function cancelOrders(uint256[] memory ordersIds) external; /** * @notice Creates a new order. * @param order The order to create. * @return The ID of the created order. * @dev Requires various checks for the validity of the order. * @dev Transfers base tokens from the user to this contract if user balance on contract is insufficient. * @dev Adds the order to the active orders list and associates it with the user. * @dev Emits a {OrderCreated} event upon successful creation of the order. */ function createOrder(Order memory order) external returns (uint256); /** * @notice Deposits an amount of tokens into the contract for a specific user. * @param token The address of the token to deposit. * @param amount The amount of tokens to deposit. * @return A boolean indicating the success of the deposit. * @dev Requires the token to be allowed in the whitelist. * @dev Transfers the specified amount of tokens from the user to this contract. * @dev Updates the user's token balance in the contract. * @dev Emits a {Deposited} event upon successful deposit. */ function deposit(address token, uint256 amount) external returns (bool); /** * @notice Executes the orders specified by the given order IDs. * @param ordersIds An array of order IDs to be executed. * @return A boolean value indicating the success of the execution. * @dev Emits a {OrderExecuted} event for each executed order. */ function executeOrders(uint256[] memory ordersIds) external returns (bool); /** * @notice Performs the upkeep based on the provided performData. * @param performData Encoded data containing the order IDs to be executed. * @dev This function is external and non-reentrant. * @dev Requires at least one order ID to be provided for execution. * @dev It decodes the performData to retrieve the order IDs. * @dev Calls the executeOrders function to execute the specified orders. * @dev Emits a {OrderExecuted} event for each executed order. */ function performUpkeep(bytes calldata performData) external; /** * @notice Removes multiple tokens from the whitelist. * @param tokens An array of token addresses to remove. * @dev Only callable by an address with the ADMIN_ROLE. * @dev Removes each token address from the whitelist if it exists. * @dev Emits a {TokenRemoved} event for each token removed from the whitelist. */ function removeTokensFromWhitelist(address[] memory tokens) external; /** * @notice Sets a new protocol fee percentage. * @param newProtocolFee The new protocol fee percentage to be set, represented as a decimal with 6 digits precision. * @dev Only the specified role can call this function. * @dev The new protocol fee must be less than 100% (represented as 1,000,000 in 6 digits precision). * @dev Emits a {ProtocolFeeSet} event. */ function setProtocolFee(uint32 newProtocolFee) external; /** * @notice Withdraws an amount of tokens from the contract for a specific user. * @param token The address of the token to withdraw. * @param amount The amount of tokens to withdraw. * @return A boolean indicating the success of the withdrawal. * @dev Requires the user to have a sufficient balance of the specified token. * @dev Transfers the specified amount of tokens from the contract to the user. * @dev Updates the user's token balance in the contract. * @dev Emits a {Withdrawed} event upon successful withdrawal. */ function withdraw(address token, uint256 amount) external returns (bool); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"uniswapHelperV3_","type":"address"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"uint32","name":"protocolFee_","type":"uint32"},{"internalType":"address","name":"feeRecipient_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"}],"name":"OrderCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":false,"internalType":"address","name":"userAddress","type":"address"}],"name":"OrderCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":false,"internalType":"address","name":"validator","type":"address"}],"name":"OrderExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"leftOrderId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rightOrderId","type":"uint256"}],"name":"OrdersBounded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"TokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"TokenRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawed","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRECISION","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"itemId","type":"uint256"}],"name":"activeOrderId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"offset","type":"uint256"},{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"activeOrdersIds","outputs":[{"internalType":"uint256[]","name":"ordersIds","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"activeOrdersLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"addTokensToWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"leftOrderId","type":"uint256"},{"internalType":"uint256","name":"rightOrderId","type":"uint256"}],"name":"boundOrders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ordersIds","type":"uint256[]"}],"name":"cancelOrders","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"orderId","type":"uint256"}],"name":"checkOrder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"checkData","type":"bytes"}],"name":"checkUpkeep","outputs":[{"internalType":"bool","name":"upkeepNeeded","type":"bool"},{"internalType":"bytes","name":"performData","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"baseToken","type":"address"},{"internalType":"address","name":"targetToken","type":"address"},{"internalType":"uint24","name":"pairFee","type":"uint24"},{"internalType":"uint24","name":"slippage","type":"uint24"},{"internalType":"uint128","name":"baseAmount","type":"uint128"},{"internalType":"uint128","name":"aimTargetTokenAmount","type":"uint128"},{"internalType":"uint128","name":"minTargetTokenAmount","type":"uint128"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"boundOrder","type":"uint256"},{"internalType":"enum ITradingPlatform.Action","name":"action","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct ITradingPlatform.Order","name":"order","type":"tuple"}],"name":"createOrder","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ordersIds","type":"uint256[]"}],"name":"executeOrders","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getFeeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOrderCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ordersIds","type":"uint256[]"}],"name":"getOrdersInfo","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"components":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"baseToken","type":"address"},{"internalType":"address","name":"targetToken","type":"address"},{"internalType":"uint24","name":"pairFee","type":"uint24"},{"internalType":"uint24","name":"slippage","type":"uint24"},{"internalType":"uint128","name":"baseAmount","type":"uint128"},{"internalType":"uint128","name":"aimTargetTokenAmount","type":"uint128"},{"internalType":"uint128","name":"minTargetTokenAmount","type":"uint128"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"boundOrder","type":"uint256"},{"internalType":"enum ITradingPlatform.Action","name":"action","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct ITradingPlatform.Order","name":"order","type":"tuple"},{"internalType":"uint256","name":"additionalInformation","type":"uint256"},{"internalType":"uint256","name":"resultTokenOut","type":"uint256"},{"internalType":"bool","name":"status","type":"bool"}],"internalType":"struct ITradingPlatform.OrderInfo[]","name":"orders","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProtocolFee","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"orderId","type":"uint256"}],"name":"getResultTokenOut","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSwapHelper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getTokenStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"getUserBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserOrdersIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"}],"name":"getUserOrdersInfo","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"components":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"baseToken","type":"address"},{"internalType":"address","name":"targetToken","type":"address"},{"internalType":"uint24","name":"pairFee","type":"uint24"},{"internalType":"uint24","name":"slippage","type":"uint24"},{"internalType":"uint128","name":"baseAmount","type":"uint128"},{"internalType":"uint128","name":"aimTargetTokenAmount","type":"uint128"},{"internalType":"uint128","name":"minTargetTokenAmount","type":"uint128"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"boundOrder","type":"uint256"},{"internalType":"enum ITradingPlatform.Action","name":"action","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct ITradingPlatform.Order","name":"order","type":"tuple"},{"internalType":"uint256","name":"additionalInformation","type":"uint256"},{"internalType":"uint256","name":"resultTokenOut","type":"uint256"},{"internalType":"bool","name":"status","type":"bool"}],"internalType":"struct ITradingPlatform.OrderInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"orderId","type":"uint256"}],"name":"isActiveOrderExist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"performData","type":"bytes"}],"name":"performUpkeep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"removeTokensFromWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"newProtocolFee","type":"uint32"}],"name":"setProtocolFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shouldRebalance","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040526003805463ffffffff1916601e1790553480156200002157600080fd5b5060405162004e7938038062004e798339810160408190526200004491620003c8565b60016002556001600160a01b038416620000a55760405162461bcd60e51b815260206004820152601c60248201527f556e697377617048656c7065725633207a65726f20616464726573730000000060448201526064015b60405180910390fd5b6001600160a01b038316620000f25760405162461bcd60e51b815260206004820152601260248201527141646d696e207a65726f206164647265737360701b60448201526064016200009c565b6001600160a01b0381166200014a5760405162461bcd60e51b815260206004820152601a60248201527f46656520726563697069656e74207a65726f206164647265737300000000000060448201526064016200009c565b620f424063ffffffff831610620001a45760405162461bcd60e51b815260206004820152601660248201527f4665652069732031303025206f7220677265617465720000000000000000000060448201526064016200009c565b620001b160008462000246565b620001dd7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217758462000246565b60038054600160201b600160e01b031916680100000000000000006001600160a01b039687160263ffffffff60201b19161764010000000063ffffffff949094169390930292909217909155600480546001600160a01b0319169190931617909155506200042f565b62000252828262000256565b5050565b6200026d82826200029960201b62002a8b1760201c565b60008281526001602090815260409091206200029491839062002b0f62000339821b17901c565b505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000252576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620002f53390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600062000350836001600160a01b03841662000359565b90505b92915050565b6000818152600183016020526040812054620003a25750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000353565b50600062000353565b80516001600160a01b0381168114620003c357600080fd5b919050565b60008060008060808587031215620003df57600080fd5b620003ea85620003ab565b9350620003fa60208601620003ab565b9250604085015163ffffffff811681146200041457600080fd5b91506200042460608601620003ab565b905092959194509250565b614a3a806200043f6000396000f3fe608060405234801561001057600080fd5b50600436106102325760003560e01c806391d1485411610130578063b36bb0e3116100b8578063cd5933ee1161007c578063cd5933ee14610532578063d547741f14610545578063e246023f14610558578063f3fef3a31461056b578063f9b56b331461057e57600080fd5b8063b36bb0e3146104de578063b55fb574146104f1578063b629a26a14610504578063ca15c8731461050c578063ca733b801461051f57600080fd5b8063a3ff31b5116100ff578063a3ff31b51461047f578063a5a4103114610492578063aa9f7628146104b9578063aaf5eb68146104cc578063ae2c1d5f146104d657600080fd5b806391d148541461043c578063989881b31461044f5780639c0651ea1461046f578063a217fddf1461047757600080fd5b806347e7ef24116101be5780636cb3da6e116101825780636cb3da6e146103c05780636e04ff0d146103e057806375b238fc1461040157806380cfdfc2146104165780639010d07c1461042957600080fd5b806347e7ef241461033d57806348efc672146103505780634ccb20c0146103635780636535c91d146103745780636805d6ad1461038757600080fd5b8063248a9ca311610205578063248a9ca3146102c05780632f2ff15d146102f157806336568abe146103045780633b8424b2146103175780634585e33b1461032a57600080fd5b806301ffc9a7146102375780630a1f64961461025f578063143ba5fb14610274578063215aeeee14610294575b600080fd5b61024a610245366004613e83565b610591565b60405190151581526020015b60405180910390f35b61027261026d366004613ead565b6105bc565b005b610287610282366004613ee6565b610819565b6040516102569190613f01565b600354600160401b90046001600160a01b03165b6040516001600160a01b039091168152602001610256565b6102e36102ce366004613f45565b60009081526020819052604090206001015490565b604051908152602001610256565b6102726102ff366004613f5e565b610885565b610272610312366004613f5e565b6108af565b61024a61032536600461401c565b610929565b6102726103383660046140a6565b6109b2565b61024a61034b366004614117565b610a1a565b61024a61035e366004613f45565b610b13565b6004546001600160a01b03166102a8565b6102e36103823660046141fb565b611020565b6102e361039536600461431c565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205490565b6102e36103ce366004613f45565b60009081526006602052604090205490565b6103f36103ee3660046140a6565b611b94565b60405161025692919061439e565b6102e36000805160206149e583398151915281565b6102726104243660046143b9565b611d2e565b6102a8610437366004613ead565b611ea5565b61024a61044a366004613f5e565b611ec4565b61046261045d366004613ee6565b611eed565b604051610256919061447d565b6102e3611f5c565b6102e3600081565b61024a61048d366004613ee6565b611f6d565b600354640100000000900463ffffffff165b60405163ffffffff9091168152602001610256565b6102726104c7366004614627565b611f7a565b6104a4620f424081565b610287612013565b6102726104ec3660046143b9565b6120fe565b6102726104ff36600461401c565b6121e0565b6102e361250b565b6102e361051a366004613f45565b612516565b61046261052d36600461401c565b61252d565b6102e3610540366004613f45565b61280d565b610272610553366004613f5e565b612865565b61024a610566366004613f45565b61288a565b61024a610579366004614117565b612897565b61028761058c366004613ead565b61299f565b60006001600160e01b03198216635a05180f60e01b14806105b657506105b682612b24565b92915050565b6105c4612b59565b81158015906105d257508015155b80156105de5750808214155b6106275760405162461bcd60e51b81526020600482015260156024820152744e6f6e2d636f6d70617469626c65206f726465727360581b60448201526064015b60405180910390fd5b6000828152600760205260409020546001600160a01b03163314801561066357506000818152600760205260409020546001600160a01b031633145b6106a05760405162461bcd60e51b815260206004820152600e60248201526d2737ba103cb7bab91037b93232b960911b604482015260640161061e565b60026000838152600760208190526040909120015460ff1660038111156106c9576106c9614445565b141580156106fe575060026000828152600760208190526040909120015460ff1660038111156106fb576106fb614445565b14155b61073c5760405162461bcd60e51b815260206004820152600f60248201526e43616e277420626f756e642044434160881b604482015260640161061e565b60008281526007602052604090206006015415801561076a5750600081815260076020526040902060060154155b6107af5760405162461bcd60e51b815260206004820152601660248201527513dc99195c9cc8185b1c9958591e48189bdd5b99195960521b604482015260640161061e565b600082815260076020908152604080832060069081018590558484529281902090920184905581518481529081018390527f8121c3ada975e5c8c13b1ea5c01638605c5bb5b14c8081213e3db773a9f0c150910160405180910390a16108156001600255565b5050565b6001600160a01b03811660009081526008602090815260409182902080548351818402810184019094528084526060939283018282801561087957602002820191906000526020600020905b815481526020019060010190808311610865575b50505050509050919050565b6000828152602081905260409020600101546108a081612bb1565b6108aa8383612bbb565b505050565b6001600160a01b038116331461091f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161061e565b6108158282612bdd565b6000610933612b59565b60005b825181101561099e576109618382815181106109545761095461464d565b6020026020010151610b13565b61096a5761098c565b61098c83828151811061097f5761097f61464d565b6020026020010151612bff565b8061099681614679565b915050610936565b50600190506109ad6001600255565b919050565b60006109c08284018461401c565b90506000815111610a0b5760405162461bcd60e51b81526020600482015260156024820152742737ba3434b733903337b91032bc32b1baba34b7b760591b604482015260640161061e565b610a1481610929565b50505050565b6000610a24612b59565b610a2f600b846135ce565b610a6f5760405162461bcd60e51b8152602060048201526011602482015270151bdad95b881b9bdd08185b1b1bddd959607a1b604482015260640161061e565b610a846001600160a01b0384163330856135f0565b3360009081526009602090815260408083206001600160a01b038716845290915281208054849290610ab7908490614694565b9091555050604080513381526001600160a01b03851660208201529081018390527f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a7906060015b60405180910390a15060016105b66001600255565b6000610b20600d8361365b565b610b2c57506000919050565b600082815260076020818152604080842081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e08301526005830154610100830152600683015461012083015292820154909261014084019160ff1690811115610bf957610bf9614445565b6003811115610c0a57610c0a614445565b8152602001600882018054610c1e906146ac565b80601f0160208091040260200160405190810160405280929190818152602001828054610c4a906146ac565b8015610c975780601f10610c6c57610100808354040283529160200191610c97565b820191906000526020600020905b815481529060010190602001808311610c7a57829003601f168201915b505050505081525050905060016003811115610cb557610cb5614445565b8161014001516003811115610ccc57610ccc614445565b1480610cee575060008161014001516003811115610cec57610cec614445565b145b8015610cfe575042816101000151105b15610d0c5750600092915050565b60028161014001516003811115610d2557610d25614445565b1415610d86576000816101600151806020019051810190610d4691906146e1565b6000858152600560205260409020548151919250610d6c916001600160801b0316614694565b4210610d7c575060019392505050565b5060009392505050565b60038161014001516003811115610d9f57610d9f614445565b1415610ee6576000816101600151806020019051810190610dc0919061473f565b600354602084015160408086015184516060880151925163d92cec1b60e01b81529596506000956001600160a01b03600160401b8704169563d92cec1b95610e179590949392909163ffffffff16906004016147b0565b602060405180830381865afa158015610e34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5891906147f4565b60008681526005602052604090205490915080158015610e8557508360c001516001600160801b03168210155b80610ed157508015801590610ed15750610ea3818460400151613673565b610ead9082614694565b82101580610ed15750610ec4818460400151613673565b610ece908261480d565b82105b15610ee25750600195945050505050565b5050505b600354602082015160408084015160a08501516060860151925163d92cec1b60e01b81526000956001600160a01b03600160401b8204169563d92cec1b95610f4195919491939192909163ffffffff909116906004016147b0565b602060405180830381865afa158015610f5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8291906147f4565b905060008261014001516003811115610f9d57610f9d614445565b148015610fb757508160c001516001600160801b03168111155b8015610fcf57508160e001516001600160801b031681115b15610fde575060019392505050565b60018261014001516003811115610ff757610ff7614445565b14801561101157508160c001516001600160801b03168110155b15610d7c575060019392505050565b600061102a612b59565b81516001600160a01b031633146110785760405162461bcd60e51b815260206004820152601260248201527157726f6e672075736572206164647265737360701b604482015260640161061e565b60208201516001600160a01b03166110c75760405162461bcd60e51b81526020600482015260126024820152715a65726f206164647265737320636865636b60701b604482015260640161061e565b60408201516001600160a01b03166111165760405162461bcd60e51b81526020600482015260126024820152715a65726f206164647265737320636865636b60701b604482015260640161061e565b81604001516001600160a01b031682602001516001600160a01b031614156111805760405162461bcd60e51b815260206004820152601860248201527f546f6b656e73206d75737420626520646966666572656e740000000000000000604482015260640161061e565b60008260a001516001600160801b0316116111d65760405162461bcd60e51b81526020600482015260166024820152750416d6f756e7420696e206d75737420626520677420360541b604482015260640161061e565b6000826080015162ffffff161180156111f9575061c350826080015162ffffff16105b6112375760405162461bcd60e51b815260206004820152600f60248201526e556e7361666520736c69707061676560881b604482015260640161061e565b6002826101400151600381111561125057611250614445565b146112b25760008260c001516001600160801b0316116112b25760405162461bcd60e51b815260206004820152601760248201527f41696d20616d6f756e74206d7573742062652067742030000000000000000000604482015260640161061e565b600182610140015160038111156112cb576112cb614445565b14806112ed5750600082610140015160038111156112eb576112eb614445565b145b1561133e57428261010001511161133e5760405162461bcd60e51b815260206004820152601560248201527457726f6e672065787069726174696f6e206461746560581b604482015260640161061e565b602082015161134f90600b906135ce565b80156113675750604082015161136790600b906135ce565b6113a75760405162461bcd60e51b8152602060048201526011602482015270151bdad95b881b9bdd08185b1b1bddd959607a1b604482015260640161061e565b6113b5600a80546001019055565b60006113c0600a5490565b9050600283610140015160038111156113db576113db614445565b14156114685760008361016001518060200190518101906113fc91906146e1565b9050600081602001516001600160801b0316116114515760405162461bcd60e51b815260206004820152601360248201527205a65726f20616d6f756e7420746f207377617606c1b604482015260640161061e565b5060008181526005602052604090204290556115a3565b6003836101400151600381111561148157611481614445565b14156115a35760008361016001518060200190518101906114a2919061473f565b9050600081602001516001600160801b0316116114f75760405162461bcd60e51b815260206004820152601360248201527205a65726f20616d6f756e7420746f207377617606c1b604482015260640161061e565b8360a001516001600160801b031681600001516001600160801b0316146115545760405162461bcd60e51b815260206004820152601160248201527015dc9bdb99c818985cd948185b5bdd5b9d607a1b604482015260640161061e565b6000816040015162ffffff16116115a15760405162461bcd60e51b815260206004820152601160248201527015dc9bdb99c81cdd195c08185b5bdd5b9d607a1b604482015260640161061e565b505b610120830151156118e95761012080840151600090815260076020818152604080842081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e083015260058301546101008301526006830154958201959095529181015492939192909161014084019160ff169081111561168757611687614445565b600381111561169857611698614445565b81526020016008820180546116ac906146ac565b80601f01602080910402602001604051908101604052809291908181526020018280546116d8906146ac565b80156117255780601f106116fa57610100808354040283529160200191611725565b820191906000526020600020905b81548152906001019060200180831161170857829003601f168201915b50505050508152505090506002600381111561174357611743614445565b846101400151600381111561175a5761175a614445565b1415801561177f57506002816101400151600381111561177c5761177c614445565b14155b6117c35760405162461bcd60e51b815260206004820152601560248201527421b0b713ba103137bab732102221a09037b93232b960591b604482015260640161061e565b80516001600160a01b0316331461181c5760405162461bcd60e51b815260206004820152601860248201527f426f756e64206f72646572206973206e6f7420796f7572730000000000000000604482015260640161061e565b61012084015161182e90600d9061365b565b61187a5760405162461bcd60e51b815260206004820152601960248201527f426f756e64206f72646572206973206e6f742061637469766500000000000000604482015260640161061e565b610120810151156118cd5760405162461bcd60e51b815260206004820152601b60248201527f426f756e64206f7264657220616c726561647920626f756e6465640000000000604482015260640161061e565b5061012083015160009081526007602052604090206006018190555b6118f4600d82613692565b5033600090815260086020908152604080832080546001808201835591855283852001859055848452600780845293829020875181546001600160a01b03199081166001600160a01b03928316178355948901518284018054909616908216179094559187015160028301805460608a015160808b0151939096166001600160b81b031990911617600160a01b62ffffff968716021762ffffff60b81b1916600160b81b95909216949094021790925560a086015160c08701516001600160801b03918216600160801b918316919091021760038084019190915560e08801516004840180546fffffffffffffffffffffffffffffffff1916919093161790915561010087015160058301556101208701516006830155610140870151938201805488959394919260ff1990911691908490811115611a3557611a35614445565b02179055506101608201518051611a56916008840191602090910190613d54565b5050336000908152600960209081526040808320878301516001600160a01b0316845290915290205460a08501519091506001600160801b0316811015611b02576000818560a001516001600160801b0316611ab2919061480d565b90508115611ae257336000908152600960209081526040808320888301516001600160a01b031684529091528120555b6020850151611afc906001600160a01b03163330846135f0565b50611b4f565b60a0840151336000908152600960209081526040808320828901516001600160a01b03168452909152812080546001600160801b0390931692909190611b4990849061480d565b90915550505b604080518381523360208201527f4ceaea0569072c9203c8c195ffccdbca9851b9d0410f577878a6792f12ec9b52910160405180910390a15090506109ad6001600255565b600060608180611ba685870187614824565b915091506000611bb4612013565b90508051836001600160801b031610611bfe5760408051600081526020810182528691611be391908101613f01565b60405160208183030381529060405294509450505050611d27565b8051600090611c0d848661485d565b6001600160801b031611611c3357611c25838561485d565b6001600160801b0316611c36565b81515b90506000611c4d6001600160801b0386168361480d565b6001600160401b03811115611c6457611c64613f8a565b604051908082528060200260200182016040528015611c8d578160200160208202803683370190505b50905060005b8151811015611cf75783611cb0826001600160801b038916614694565b81518110611cc057611cc061464d565b6020026020010151828281518110611cda57611cda61464d565b602090810291909101015280611cef81614679565b915050611c93565b506000835111965080604051602001611d109190613f01565b604051602081830303815290604052955050505050505b9250929050565b6000805160206149e5833981519152611d4681612bb1565b60005b82518110156108aa5760006001600160a01b0316838281518110611d6f57611d6f61464d565b60200260200101516001600160a01b03161415611dce5760405162461bcd60e51b815260206004820152601860248201527f546f6b656e207a65726f206164647265737320636865636b0000000000000000604482015260640161061e565b611dfb838281518110611de357611de361464d565b6020026020010151600b6135ce90919063ffffffff16565b15611e0557611e93565b611e32838281518110611e1a57611e1a61464d565b6020026020010151600b612b0f90919063ffffffff16565b507f784c8f4dbf0ffedd6e72c76501c545a70f8b203b30a26ce542bf92ba87c248a4838281518110611e6657611e6661464d565b6020026020010151604051611e8a91906001600160a01b0391909116815260200190565b60405180910390a15b80611e9d81614679565b915050611d49565b6000828152600160205260408120611ebd908361369e565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6001600160a01b0381166000908152600860209081526040808320805482518185028101850190935280835260609493830182828015611f4c57602002820191906000526020600020905b815481526020019060010190808311611f38575b50505050509050611ebd8161252d565b6000611f68600d6136aa565b905090565b60006105b6600b836135ce565b6000805160206149e5833981519152611f9281612bb1565b620f424063ffffffff831610611fea5760405162461bcd60e51b815260206004820152601f60248201527f6e657750726f746f636f6c4665652063616e2774206265206774203130302500604482015260640161061e565b506003805463ffffffff9092166401000000000267ffffffff0000000019909216919091179055565b60606000612021600d6136aa565b90506000816001600160401b0381111561203d5761203d613f8a565b604051908082528060200260200182016040528015612066578160200160208202803683370190505b5090506000805b838110156120e0576000612082600d8361369e565b905061208d81610b13565b156120bf57808461209e858561480d565b815181106120ae576120ae61464d565b6020026020010181815250506120cd565b826120c981614679565b9350505b50806120d881614679565b91505061206d565b5080156120f75760006120f3828561480d565b8352505b5092915050565b6000805160206149e583398151915261211681612bb1565b60005b82518110156108aa57612137838281518110611de357611de361464d565b612140576121ce565b61216d8382815181106121555761215561464d565b6020026020010151600b6136b490919063ffffffff16565b507f4c910b69fe65a61f7531b9c5042b2329ca7179c77290aa7e2eb3afa3c8511fd38382815181106121a1576121a161464d565b60200260200101516040516121c591906001600160a01b0391909116815260200190565b60405180910390a15b806121d881614679565b915050612119565b6121e8612b59565b60005b81518110156124fd576122218282815181106122095761220961464d565b6020026020010151600d61365b90919063ffffffff16565b61222a576124eb565b6000600760008484815181106122425761224261464d565b602090810291909101810151825281810192909252604090810160002081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e083015260058301546101008301526006830154610120830152600783015491929161014084019160ff9091169081111561231f5761231f614445565b600381111561233057612330614445565b8152602001600882018054612344906146ac565b80601f0160208091040260200160405190810160405280929190818152602001828054612370906146ac565b80156123bd5780601f10612392576101008083540402835291602001916123bd565b820191906000526020600020905b8154815290600101906020018083116123a057829003601f168201915b5050509190925250508151919250506001600160a01b031633146124145760405162461bcd60e51b815260206004820152600e60248201526d2737ba103cb7bab91037b93232b960911b604482015260640161061e565b6124418383815181106124295761242961464d565b6020026020010151600d6136c990919063ffffffff16565b5060a081015181516001600160a01b03908116600090815260096020908152604080832082870151909416835292905290812080546001600160801b0390931692909190612490908490614694565b925050819055507fc41f4ceb2938876c35e61b705e9d2f18a02c4a26ce5e049a6308a943d46851b38383815181106124ca576124ca61464d565b60200260200101516040516124e191815260200190565b60405180910390a1505b806124f581614679565b9150506121eb565b506125086001600255565b50565b6000611f68600a5490565b60008181526001602052604081206105b6906136aa565b606081516001600160401b0381111561254857612548613f8a565b60405190808252806020026020018201604052801561258157816020015b61256e613dd8565b8152602001906001900390816125665790505b50905060005b8251811015612807576040518060a001604052808483815181106125ad576125ad61464d565b60200260200101518152602001600760008685815181106125d0576125d061464d565b602090810291909101810151825281810192909252604090810160002081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e083015260058301546101008301526006830154610120830152600783015491929161014084019160ff909116908111156126ad576126ad614445565b60038111156126be576126be614445565b81526020016008820180546126d2906146ac565b80601f01602080910402602001604051908101604052809291908181526020018280546126fe906146ac565b801561274b5780601f106127205761010080835404028352916020019161274b565b820191906000526020600020905b81548152906001019060200180831161272e57829003601f168201915b50505050508152505081526020016005600086858151811061276f5761276f61464d565b60200260200101518152602001908152602001600020548152602001600660008685815181106127a1576127a161464d565b602002602001015181526020019081526020016000205481526020016127d28584815181106122095761220961464d565b15158152508282815181106127e9576127e961464d565b602002602001018190525080806127ff90614679565b915050612587565b50919050565b6000612819600d6136aa565b821061285a5760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59081d1bdad95b881a5960821b604482015260640161061e565b6105b6600d8361369e565b60008281526020819052604090206001015461288081612bb1565b6108aa8383612bdd565b60006105b6600d8361365b565b60006128a1612b59565b3360009081526009602090815260408083206001600160a01b038716845290915290205482111561290c5760405162461bcd60e51b8152602060048201526015602482015274416d6f756e74206578636565642062616c616e636560581b604482015260640161061e565b3360009081526009602090815260408083206001600160a01b03871684529091528120805484929061293f90849061480d565b9091555061295990506001600160a01b03841633846136d5565b604080513381526001600160a01b03851660208201529081018390527ff10eae2de0b095be715d0a32380cea8e913ae297b48430b5397024146ce9036590606001610afe565b606060006129ad600d6136aa565b90508084106129cc5750506040805160008152602081019091526105b6565b60006129d88486614694565b9050808210156129e55750805b6129ef858261480d565b6001600160401b03811115612a0657612a06613f8a565b604051908082528060200260200182016040528015612a2f578160200160208202803683370190505b50925060005b8351811015612a8257612a53612a4b8288614694565b600d9061369e565b848281518110612a6557612a6561464d565b602090810291909101015280612a7a81614679565b915050612a35565b50505092915050565b612a958282611ec4565b610815576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055612acb3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000611ebd836001600160a01b038416613705565b60006001600160e01b03198216637965db0b60e01b14806105b657506301ffc9a760e01b6001600160e01b03198316146105b6565b600280541415612bab5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161061e565b60028055565b6125088133613754565b612bc58282612a8b565b60008281526001602052604090206108aa9082612b0f565b612be782826137ad565b60008281526001602052604090206108aa90826136b4565b600081815260076020818152604080842081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e08301526005830154610100830152600683015461012083015292820154909261014084019160ff1690811115612ccc57612ccc614445565b6003811115612cdd57612cdd614445565b8152602001600882018054612cf1906146ac565b80601f0160208091040260200160405190810160405280929190818152602001828054612d1d906146ac565b8015612d6a5780601f10612d3f57610100808354040283529160200191612d6a565b820191906000526020600020905b815481529060010190602001808311612d4d57829003601f168201915b5050509190925250505060a081015190915060038261014001516003811115612d9557612d95614445565b1415612f5d576000826101600151806020019051810190612db6919061473f565b600354602085015160408087015184516060890151925163d92cec1b60e01b81529596506000956001600160a01b03600160401b8704169563d92cec1b95612e0d9590949392909163ffffffff16906004016147b0565b602060405180830381865afa158015612e2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e4e91906147f4565b600086815260056020526040902054909150801580612e845750612e76818460400151613673565b612e809082614694565b8210155b15612ec7578460a001516001600160801b031683602001516001600160801b031610612ebb57612eb5600d876136c9565b50612efa565b82602001519350612efa565b612ed5818460400151613673565b612edf908261480d565b821015612efa5760a08501519350612ef8600d876136c9565b505b6000868152600560209081526040808320859055600790915281206003018054869290612f319084906001600160801b0316614888565b92506101000a8154816001600160801b0302191690836001600160801b031602179055505050506132ce565b60028261014001516003811115612f7657612f76614445565b1415613036576000826101600151806020019051810190612f9791906146e1565b9050806020015191508260a001516001600160801b031681602001516001600160801b031610612fd55760a08301519150612fd3600d856136c9565b505b600084815260056020908152604080832042905560079091528120600301805484929061300c9084906001600160801b0316614888565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550506132ce565b6000826101400151600381111561304f5761304f614445565b148061307157506001826101400151600381111561306f5761306f614445565b145b156132ce57613081600d846136c9565b50610120820151156132ce5761012082015161309f90600d9061365b565b156132ce5761012080830151600090815260076020818152604080842081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e083015260058301546101008301526006830154958201959095529181015492939192909161014084019160ff169081111561317d5761317d614445565b600381111561318e5761318e614445565b81526020016008820180546131a2906146ac565b80601f01602080910402602001604051908101604052809291908181526020018280546131ce906146ac565b801561321b5780601f106131f05761010080835404028352916020019161321b565b820191906000526020600020905b8154815290600101906020018083116131fe57829003601f168201915b505050505081525050905061323f836101200151600d6136c990919063ffffffff16565b5060a081015181516001600160a01b03908116600090815260096020908152604080832082870151909416835292905290812080546001600160801b039093169290919061328e908490614694565b90915550506101208301516040519081527fc41f4ceb2938876c35e61b705e9d2f18a02c4a26ce5e049a6308a943d46851b39060200160405180910390a1505b602082015160035460405163095ea7b360e01b81526001600160a01b03600160401b909204821660048201526001600160801b038416602482015291169063095ea7b3906044016020604051808303816000875af1158015613334573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061335891906148b0565b50600354602083015160408085015160608601516080870151925163a7ce47c560e01b81523060048201526001600160a01b03948516602482015291841660448301526001600160801b038616606483015262ffffff908116608483015290911660a4820152600092600160401b90049091169063a7ce47c59060c4016020604051808303816000875af11580156133f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341891906147f4565b9050600061343882600360049054906101000a900463ffffffff16613812565b90506000846101400151600381111561345357613453614445565b148061347557506001846101400151600381111561347357613473614445565b145b156134d157613484818361480d565b8460e001516001600160801b0316106134d15760405162461bcd60e51b815260206004820152600f60248201526e556e666169722065786368616e676560881b604482015260640161061e565b6004546001600160a01b039081166000908152600960209081526040808320888201519094168352929052908120805483929061350f908490614694565b9091555061351f9050818361480d565b84516001600160a01b039081166000908152600960209081526040808320818a01519094168352929052908120805490919061355c908490614694565b9091555061356c9050818361480d565b6000868152600660205260408120805490919061358a908490614694565b9091555050604080518681523360208201527f7dcea57e3cdcea187cf2d57047e2b9260a274caa69cb5fe9525d123ef6c12a17910160405180910390a15050505050565b6001600160a01b03811660009081526001830160205260408120541515611ebd565b6040516001600160a01b0380851660248301528316604482015260648101829052610a149085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613828565b60008181526001830160205260408120541515611ebd565b6000620f424061368862ffffff8416856148d2565b611ebd91906148f1565b6000611ebd8383613705565b6000611ebd83836138fd565b60006105b6825490565b6000611ebd836001600160a01b038416613927565b6000611ebd8383613927565b6040516001600160a01b0383166024820152604481018290526108aa90849063a9059cbb60e01b90606401613624565b600081815260018301602052604081205461374c575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105b6565b5060006105b6565b61375e8282611ec4565b6108155761376b81613a1a565b613776836020613a2c565b604051602001613787929190614913565b60408051601f198184030181529082905262461bcd60e51b825261061e91600401614988565b6137b78282611ec4565b15610815576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000620f424061368863ffffffff8416856148d2565b600061387d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613bc79092919063ffffffff16565b905080516000148061389e57508080602001905181019061389e91906148b0565b6108aa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161061e565b60008260000182815481106139145761391461464d565b9060005260206000200154905092915050565b60008181526001830160205260408120548015613a1057600061394b60018361480d565b855490915060009061395f9060019061480d565b90508181146139c457600086600001828154811061397f5761397f61464d565b90600052602060002001549050808760000184815481106139a2576139a261464d565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806139d5576139d561499b565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105b6565b60009150506105b6565b60606105b66001600160a01b03831660145b60606000613a3b8360026148d2565b613a46906002614694565b6001600160401b03811115613a5d57613a5d613f8a565b6040519080825280601f01601f191660200182016040528015613a87576020820181803683370190505b509050600360fc1b81600081518110613aa257613aa261464d565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613ad157613ad161464d565b60200101906001600160f81b031916908160001a9053506000613af58460026148d2565b613b00906001614694565b90505b6001811115613b78576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613b3457613b3461464d565b1a60f81b828281518110613b4a57613b4a61464d565b60200101906001600160f81b031916908160001a90535060049490941c93613b71816149b1565b9050613b03565b508315611ebd5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161061e565b6060613bd68484600085613bde565b949350505050565b606082471015613c3f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161061e565b600080866001600160a01b03168587604051613c5b91906149c8565b60006040518083038185875af1925050503d8060008114613c98576040519150601f19603f3d011682016040523d82523d6000602084013e613c9d565b606091505b5091509150613cae87838387613cb9565b979650505050505050565b60608315613d25578251613d1e576001600160a01b0385163b613d1e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161061e565b5081613bd6565b613bd68383815115613d3a5781518083602001fd5b8060405162461bcd60e51b815260040161061e9190614988565b828054613d60906146ac565b90600052602060002090601f016020900481019282613d825760008555613dc8565b82601f10613d9b57805160ff1916838001178555613dc8565b82800160010185558215613dc8579182015b82811115613dc8578251825591602001919060010190613dad565b50613dd4929150613e6e565b5090565b6040518060a0016040528060008152602001613e516040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052906101408201908152602001606081525090565b815260200160008152602001600081526020016000151581525090565b5b80821115613dd45760008155600101613e6f565b600060208284031215613e9557600080fd5b81356001600160e01b031981168114611ebd57600080fd5b60008060408385031215613ec057600080fd5b50508035926020909101359150565b80356001600160a01b03811681146109ad57600080fd5b600060208284031215613ef857600080fd5b611ebd82613ecf565b6020808252825182820181905260009190848201906040850190845b81811015613f3957835183529284019291840191600101613f1d565b50909695505050505050565b600060208284031215613f5757600080fd5b5035919050565b60008060408385031215613f7157600080fd5b82359150613f8160208401613ecf565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b60405161018081016001600160401b0381118282101715613fc357613fc3613f8a565b60405290565b604051601f8201601f191681016001600160401b0381118282101715613ff157613ff1613f8a565b604052919050565b60006001600160401b0382111561401257614012613f8a565b5060051b60200190565b6000602080838503121561402f57600080fd5b82356001600160401b0381111561404557600080fd5b8301601f8101851361405657600080fd5b803561406961406482613ff9565b613fc9565b81815260059190911b8201830190838101908783111561408857600080fd5b928401925b82841015613cae5783358252928401929084019061408d565b600080602083850312156140b957600080fd5b82356001600160401b03808211156140d057600080fd5b818501915085601f8301126140e457600080fd5b8135818111156140f357600080fd5b86602082850101111561410557600080fd5b60209290920196919550909350505050565b6000806040838503121561412a57600080fd5b61413383613ecf565b946020939093013593505050565b62ffffff8116811461250857600080fd5b80356109ad81614141565b6001600160801b038116811461250857600080fd5b80356109ad8161415d565b8035600481106109ad57600080fd5b600082601f83011261419d57600080fd5b81356001600160401b038111156141b6576141b6613f8a565b6141c9601f8201601f1916602001613fc9565b8181528460208386010111156141de57600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561420d57600080fd5b81356001600160401b038082111561422457600080fd5b90830190610180828603121561423957600080fd5b614241613fa0565b61424a83613ecf565b815261425860208401613ecf565b602082015261426960408401613ecf565b604082015261427a60608401614152565b606082015261428b60808401614152565b608082015261429c60a08401614172565b60a08201526142ad60c08401614172565b60c08201526142be60e08401614172565b60e0820152610100838101359082015261012080840135908201526101406142e781850161417d565b9082015261016083810135838111156142ff57600080fd5b61430b8882870161418c565b918301919091525095945050505050565b6000806040838503121561432f57600080fd5b61433883613ecf565b9150613f8160208401613ecf565b60005b83811015614361578181015183820152602001614349565b83811115610a145750506000910152565b6000815180845261438a816020860160208601614346565b601f01601f19169290920160200192915050565b8215158152604060208201526000613bd66040830184614372565b600060208083850312156143cc57600080fd5b82356001600160401b038111156143e257600080fd5b8301601f810185136143f357600080fd5b803561440161406482613ff9565b81815260059190911b8201830190838101908783111561442057600080fd5b928401925b82841015613cae5761443684613ecf565b82529284019290840190614425565b634e487b7160e01b600052602160045260246000fd5b6004811061447957634e487b7160e01b600052602160045260246000fd5b9052565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b8381101561461957603f19898403018552815160a08151855288820151818a8701526144db82870182516001600160a01b03169052565b8981015160c06144f5818901836001600160a01b03169052565b8a830151915060e0614511818a01846001600160a01b03169052565b606092508284015161010061452c818c018362ffffff169052565b6080915081860151610120614547818e018362ffffff169052565b978701519761014091506145658d83018a6001600160801b03169052565b948701519750610160946145838d87018a6001600160801b03169052565b938701519750610180936145a18d86018a6001600160801b03169052565b918701516101a08d0152908601516101c08c015285015195506145c86101e08b018761445b565b828501519550816102008b01526145e36102208b0187614372565b878e01518b8f015284880151948b01949094529586015115159590980194909452978a01979550505091870191506001016144a4565b509098975050505050505050565b60006020828403121561463957600080fd5b813563ffffffff81168114611ebd57600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561468d5761468d614663565b5060010190565b600082198211156146a7576146a7614663565b500190565b600181811c908216806146c057607f821691505b6020821081141561280757634e487b7160e01b600052602260045260246000fd5b6000604082840312156146f357600080fd5b604051604081018181106001600160401b038211171561471557614715613f8a565b60405282516147238161415d565b815260208301516147338161415d565b60208201529392505050565b60006060828403121561475157600080fd5b604051606081018181106001600160401b038211171561477357614773613f8a565b60405282516147818161415d565b815260208301516147918161415d565b602082015260408301516147a481614141565b60408201529392505050565b6001600160a01b0395861681529390941660208401526001600160801b0391909116604083015262ffffff16606082015263ffffffff909116608082015260a00190565b60006020828403121561480657600080fd5b5051919050565b60008282101561481f5761481f614663565b500390565b6000806040838503121561483757600080fd5b82356148428161415d565b915060208301356148528161415d565b809150509250929050565b60006001600160801b0380831681851680830382111561487f5761487f614663565b01949350505050565b60006001600160801b03838116908316818110156148a8576148a8614663565b039392505050565b6000602082840312156148c257600080fd5b81518015158114611ebd57600080fd5b60008160001904831182151516156148ec576148ec614663565b500290565b60008261490e57634e487b7160e01b600052601260045260246000fd5b500490565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161494b816017850160208801614346565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161497c816028840160208801614346565b01602801949350505050565b602081526000611ebd6020830184614372565b634e487b7160e01b600052603160045260246000fd5b6000816149c0576149c0614663565b506000190190565b600082516149da818460208701614346565b919091019291505056fea49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a264697066735822122042f56d61454e53e2f070fa78f7109cc5f1e9ce59b2f6b7c83de06681757e82f064736f6c634300080c003300000000000000000000000099cb3439f88dfd1d9c6c4b7141a0696ecea96ff3000000000000000000000000b984f9f42d405a37f7f3903c73cbf7112dcc859b0000000000000000000000000000000000000000000000000000000000002710000000000000000000000000b984f9f42d405a37f7f3903c73cbf7112dcc859b
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102325760003560e01c806391d1485411610130578063b36bb0e3116100b8578063cd5933ee1161007c578063cd5933ee14610532578063d547741f14610545578063e246023f14610558578063f3fef3a31461056b578063f9b56b331461057e57600080fd5b8063b36bb0e3146104de578063b55fb574146104f1578063b629a26a14610504578063ca15c8731461050c578063ca733b801461051f57600080fd5b8063a3ff31b5116100ff578063a3ff31b51461047f578063a5a4103114610492578063aa9f7628146104b9578063aaf5eb68146104cc578063ae2c1d5f146104d657600080fd5b806391d148541461043c578063989881b31461044f5780639c0651ea1461046f578063a217fddf1461047757600080fd5b806347e7ef24116101be5780636cb3da6e116101825780636cb3da6e146103c05780636e04ff0d146103e057806375b238fc1461040157806380cfdfc2146104165780639010d07c1461042957600080fd5b806347e7ef241461033d57806348efc672146103505780634ccb20c0146103635780636535c91d146103745780636805d6ad1461038757600080fd5b8063248a9ca311610205578063248a9ca3146102c05780632f2ff15d146102f157806336568abe146103045780633b8424b2146103175780634585e33b1461032a57600080fd5b806301ffc9a7146102375780630a1f64961461025f578063143ba5fb14610274578063215aeeee14610294575b600080fd5b61024a610245366004613e83565b610591565b60405190151581526020015b60405180910390f35b61027261026d366004613ead565b6105bc565b005b610287610282366004613ee6565b610819565b6040516102569190613f01565b600354600160401b90046001600160a01b03165b6040516001600160a01b039091168152602001610256565b6102e36102ce366004613f45565b60009081526020819052604090206001015490565b604051908152602001610256565b6102726102ff366004613f5e565b610885565b610272610312366004613f5e565b6108af565b61024a61032536600461401c565b610929565b6102726103383660046140a6565b6109b2565b61024a61034b366004614117565b610a1a565b61024a61035e366004613f45565b610b13565b6004546001600160a01b03166102a8565b6102e36103823660046141fb565b611020565b6102e361039536600461431c565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205490565b6102e36103ce366004613f45565b60009081526006602052604090205490565b6103f36103ee3660046140a6565b611b94565b60405161025692919061439e565b6102e36000805160206149e583398151915281565b6102726104243660046143b9565b611d2e565b6102a8610437366004613ead565b611ea5565b61024a61044a366004613f5e565b611ec4565b61046261045d366004613ee6565b611eed565b604051610256919061447d565b6102e3611f5c565b6102e3600081565b61024a61048d366004613ee6565b611f6d565b600354640100000000900463ffffffff165b60405163ffffffff9091168152602001610256565b6102726104c7366004614627565b611f7a565b6104a4620f424081565b610287612013565b6102726104ec3660046143b9565b6120fe565b6102726104ff36600461401c565b6121e0565b6102e361250b565b6102e361051a366004613f45565b612516565b61046261052d36600461401c565b61252d565b6102e3610540366004613f45565b61280d565b610272610553366004613f5e565b612865565b61024a610566366004613f45565b61288a565b61024a610579366004614117565b612897565b61028761058c366004613ead565b61299f565b60006001600160e01b03198216635a05180f60e01b14806105b657506105b682612b24565b92915050565b6105c4612b59565b81158015906105d257508015155b80156105de5750808214155b6106275760405162461bcd60e51b81526020600482015260156024820152744e6f6e2d636f6d70617469626c65206f726465727360581b60448201526064015b60405180910390fd5b6000828152600760205260409020546001600160a01b03163314801561066357506000818152600760205260409020546001600160a01b031633145b6106a05760405162461bcd60e51b815260206004820152600e60248201526d2737ba103cb7bab91037b93232b960911b604482015260640161061e565b60026000838152600760208190526040909120015460ff1660038111156106c9576106c9614445565b141580156106fe575060026000828152600760208190526040909120015460ff1660038111156106fb576106fb614445565b14155b61073c5760405162461bcd60e51b815260206004820152600f60248201526e43616e277420626f756e642044434160881b604482015260640161061e565b60008281526007602052604090206006015415801561076a5750600081815260076020526040902060060154155b6107af5760405162461bcd60e51b815260206004820152601660248201527513dc99195c9cc8185b1c9958591e48189bdd5b99195960521b604482015260640161061e565b600082815260076020908152604080832060069081018590558484529281902090920184905581518481529081018390527f8121c3ada975e5c8c13b1ea5c01638605c5bb5b14c8081213e3db773a9f0c150910160405180910390a16108156001600255565b5050565b6001600160a01b03811660009081526008602090815260409182902080548351818402810184019094528084526060939283018282801561087957602002820191906000526020600020905b815481526020019060010190808311610865575b50505050509050919050565b6000828152602081905260409020600101546108a081612bb1565b6108aa8383612bbb565b505050565b6001600160a01b038116331461091f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161061e565b6108158282612bdd565b6000610933612b59565b60005b825181101561099e576109618382815181106109545761095461464d565b6020026020010151610b13565b61096a5761098c565b61098c83828151811061097f5761097f61464d565b6020026020010151612bff565b8061099681614679565b915050610936565b50600190506109ad6001600255565b919050565b60006109c08284018461401c565b90506000815111610a0b5760405162461bcd60e51b81526020600482015260156024820152742737ba3434b733903337b91032bc32b1baba34b7b760591b604482015260640161061e565b610a1481610929565b50505050565b6000610a24612b59565b610a2f600b846135ce565b610a6f5760405162461bcd60e51b8152602060048201526011602482015270151bdad95b881b9bdd08185b1b1bddd959607a1b604482015260640161061e565b610a846001600160a01b0384163330856135f0565b3360009081526009602090815260408083206001600160a01b038716845290915281208054849290610ab7908490614694565b9091555050604080513381526001600160a01b03851660208201529081018390527f8752a472e571a816aea92eec8dae9baf628e840f4929fbcc2d155e6233ff68a7906060015b60405180910390a15060016105b66001600255565b6000610b20600d8361365b565b610b2c57506000919050565b600082815260076020818152604080842081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e08301526005830154610100830152600683015461012083015292820154909261014084019160ff1690811115610bf957610bf9614445565b6003811115610c0a57610c0a614445565b8152602001600882018054610c1e906146ac565b80601f0160208091040260200160405190810160405280929190818152602001828054610c4a906146ac565b8015610c975780601f10610c6c57610100808354040283529160200191610c97565b820191906000526020600020905b815481529060010190602001808311610c7a57829003601f168201915b505050505081525050905060016003811115610cb557610cb5614445565b8161014001516003811115610ccc57610ccc614445565b1480610cee575060008161014001516003811115610cec57610cec614445565b145b8015610cfe575042816101000151105b15610d0c5750600092915050565b60028161014001516003811115610d2557610d25614445565b1415610d86576000816101600151806020019051810190610d4691906146e1565b6000858152600560205260409020548151919250610d6c916001600160801b0316614694565b4210610d7c575060019392505050565b5060009392505050565b60038161014001516003811115610d9f57610d9f614445565b1415610ee6576000816101600151806020019051810190610dc0919061473f565b600354602084015160408086015184516060880151925163d92cec1b60e01b81529596506000956001600160a01b03600160401b8704169563d92cec1b95610e179590949392909163ffffffff16906004016147b0565b602060405180830381865afa158015610e34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5891906147f4565b60008681526005602052604090205490915080158015610e8557508360c001516001600160801b03168210155b80610ed157508015801590610ed15750610ea3818460400151613673565b610ead9082614694565b82101580610ed15750610ec4818460400151613673565b610ece908261480d565b82105b15610ee25750600195945050505050565b5050505b600354602082015160408084015160a08501516060860151925163d92cec1b60e01b81526000956001600160a01b03600160401b8204169563d92cec1b95610f4195919491939192909163ffffffff909116906004016147b0565b602060405180830381865afa158015610f5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8291906147f4565b905060008261014001516003811115610f9d57610f9d614445565b148015610fb757508160c001516001600160801b03168111155b8015610fcf57508160e001516001600160801b031681115b15610fde575060019392505050565b60018261014001516003811115610ff757610ff7614445565b14801561101157508160c001516001600160801b03168110155b15610d7c575060019392505050565b600061102a612b59565b81516001600160a01b031633146110785760405162461bcd60e51b815260206004820152601260248201527157726f6e672075736572206164647265737360701b604482015260640161061e565b60208201516001600160a01b03166110c75760405162461bcd60e51b81526020600482015260126024820152715a65726f206164647265737320636865636b60701b604482015260640161061e565b60408201516001600160a01b03166111165760405162461bcd60e51b81526020600482015260126024820152715a65726f206164647265737320636865636b60701b604482015260640161061e565b81604001516001600160a01b031682602001516001600160a01b031614156111805760405162461bcd60e51b815260206004820152601860248201527f546f6b656e73206d75737420626520646966666572656e740000000000000000604482015260640161061e565b60008260a001516001600160801b0316116111d65760405162461bcd60e51b81526020600482015260166024820152750416d6f756e7420696e206d75737420626520677420360541b604482015260640161061e565b6000826080015162ffffff161180156111f9575061c350826080015162ffffff16105b6112375760405162461bcd60e51b815260206004820152600f60248201526e556e7361666520736c69707061676560881b604482015260640161061e565b6002826101400151600381111561125057611250614445565b146112b25760008260c001516001600160801b0316116112b25760405162461bcd60e51b815260206004820152601760248201527f41696d20616d6f756e74206d7573742062652067742030000000000000000000604482015260640161061e565b600182610140015160038111156112cb576112cb614445565b14806112ed5750600082610140015160038111156112eb576112eb614445565b145b1561133e57428261010001511161133e5760405162461bcd60e51b815260206004820152601560248201527457726f6e672065787069726174696f6e206461746560581b604482015260640161061e565b602082015161134f90600b906135ce565b80156113675750604082015161136790600b906135ce565b6113a75760405162461bcd60e51b8152602060048201526011602482015270151bdad95b881b9bdd08185b1b1bddd959607a1b604482015260640161061e565b6113b5600a80546001019055565b60006113c0600a5490565b9050600283610140015160038111156113db576113db614445565b14156114685760008361016001518060200190518101906113fc91906146e1565b9050600081602001516001600160801b0316116114515760405162461bcd60e51b815260206004820152601360248201527205a65726f20616d6f756e7420746f207377617606c1b604482015260640161061e565b5060008181526005602052604090204290556115a3565b6003836101400151600381111561148157611481614445565b14156115a35760008361016001518060200190518101906114a2919061473f565b9050600081602001516001600160801b0316116114f75760405162461bcd60e51b815260206004820152601360248201527205a65726f20616d6f756e7420746f207377617606c1b604482015260640161061e565b8360a001516001600160801b031681600001516001600160801b0316146115545760405162461bcd60e51b815260206004820152601160248201527015dc9bdb99c818985cd948185b5bdd5b9d607a1b604482015260640161061e565b6000816040015162ffffff16116115a15760405162461bcd60e51b815260206004820152601160248201527015dc9bdb99c81cdd195c08185b5bdd5b9d607a1b604482015260640161061e565b505b610120830151156118e95761012080840151600090815260076020818152604080842081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e083015260058301546101008301526006830154958201959095529181015492939192909161014084019160ff169081111561168757611687614445565b600381111561169857611698614445565b81526020016008820180546116ac906146ac565b80601f01602080910402602001604051908101604052809291908181526020018280546116d8906146ac565b80156117255780601f106116fa57610100808354040283529160200191611725565b820191906000526020600020905b81548152906001019060200180831161170857829003601f168201915b50505050508152505090506002600381111561174357611743614445565b846101400151600381111561175a5761175a614445565b1415801561177f57506002816101400151600381111561177c5761177c614445565b14155b6117c35760405162461bcd60e51b815260206004820152601560248201527421b0b713ba103137bab732102221a09037b93232b960591b604482015260640161061e565b80516001600160a01b0316331461181c5760405162461bcd60e51b815260206004820152601860248201527f426f756e64206f72646572206973206e6f7420796f7572730000000000000000604482015260640161061e565b61012084015161182e90600d9061365b565b61187a5760405162461bcd60e51b815260206004820152601960248201527f426f756e64206f72646572206973206e6f742061637469766500000000000000604482015260640161061e565b610120810151156118cd5760405162461bcd60e51b815260206004820152601b60248201527f426f756e64206f7264657220616c726561647920626f756e6465640000000000604482015260640161061e565b5061012083015160009081526007602052604090206006018190555b6118f4600d82613692565b5033600090815260086020908152604080832080546001808201835591855283852001859055848452600780845293829020875181546001600160a01b03199081166001600160a01b03928316178355948901518284018054909616908216179094559187015160028301805460608a015160808b0151939096166001600160b81b031990911617600160a01b62ffffff968716021762ffffff60b81b1916600160b81b95909216949094021790925560a086015160c08701516001600160801b03918216600160801b918316919091021760038084019190915560e08801516004840180546fffffffffffffffffffffffffffffffff1916919093161790915561010087015160058301556101208701516006830155610140870151938201805488959394919260ff1990911691908490811115611a3557611a35614445565b02179055506101608201518051611a56916008840191602090910190613d54565b5050336000908152600960209081526040808320878301516001600160a01b0316845290915290205460a08501519091506001600160801b0316811015611b02576000818560a001516001600160801b0316611ab2919061480d565b90508115611ae257336000908152600960209081526040808320888301516001600160a01b031684529091528120555b6020850151611afc906001600160a01b03163330846135f0565b50611b4f565b60a0840151336000908152600960209081526040808320828901516001600160a01b03168452909152812080546001600160801b0390931692909190611b4990849061480d565b90915550505b604080518381523360208201527f4ceaea0569072c9203c8c195ffccdbca9851b9d0410f577878a6792f12ec9b52910160405180910390a15090506109ad6001600255565b600060608180611ba685870187614824565b915091506000611bb4612013565b90508051836001600160801b031610611bfe5760408051600081526020810182528691611be391908101613f01565b60405160208183030381529060405294509450505050611d27565b8051600090611c0d848661485d565b6001600160801b031611611c3357611c25838561485d565b6001600160801b0316611c36565b81515b90506000611c4d6001600160801b0386168361480d565b6001600160401b03811115611c6457611c64613f8a565b604051908082528060200260200182016040528015611c8d578160200160208202803683370190505b50905060005b8151811015611cf75783611cb0826001600160801b038916614694565b81518110611cc057611cc061464d565b6020026020010151828281518110611cda57611cda61464d565b602090810291909101015280611cef81614679565b915050611c93565b506000835111965080604051602001611d109190613f01565b604051602081830303815290604052955050505050505b9250929050565b6000805160206149e5833981519152611d4681612bb1565b60005b82518110156108aa5760006001600160a01b0316838281518110611d6f57611d6f61464d565b60200260200101516001600160a01b03161415611dce5760405162461bcd60e51b815260206004820152601860248201527f546f6b656e207a65726f206164647265737320636865636b0000000000000000604482015260640161061e565b611dfb838281518110611de357611de361464d565b6020026020010151600b6135ce90919063ffffffff16565b15611e0557611e93565b611e32838281518110611e1a57611e1a61464d565b6020026020010151600b612b0f90919063ffffffff16565b507f784c8f4dbf0ffedd6e72c76501c545a70f8b203b30a26ce542bf92ba87c248a4838281518110611e6657611e6661464d565b6020026020010151604051611e8a91906001600160a01b0391909116815260200190565b60405180910390a15b80611e9d81614679565b915050611d49565b6000828152600160205260408120611ebd908361369e565b9392505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6001600160a01b0381166000908152600860209081526040808320805482518185028101850190935280835260609493830182828015611f4c57602002820191906000526020600020905b815481526020019060010190808311611f38575b50505050509050611ebd8161252d565b6000611f68600d6136aa565b905090565b60006105b6600b836135ce565b6000805160206149e5833981519152611f9281612bb1565b620f424063ffffffff831610611fea5760405162461bcd60e51b815260206004820152601f60248201527f6e657750726f746f636f6c4665652063616e2774206265206774203130302500604482015260640161061e565b506003805463ffffffff9092166401000000000267ffffffff0000000019909216919091179055565b60606000612021600d6136aa565b90506000816001600160401b0381111561203d5761203d613f8a565b604051908082528060200260200182016040528015612066578160200160208202803683370190505b5090506000805b838110156120e0576000612082600d8361369e565b905061208d81610b13565b156120bf57808461209e858561480d565b815181106120ae576120ae61464d565b6020026020010181815250506120cd565b826120c981614679565b9350505b50806120d881614679565b91505061206d565b5080156120f75760006120f3828561480d565b8352505b5092915050565b6000805160206149e583398151915261211681612bb1565b60005b82518110156108aa57612137838281518110611de357611de361464d565b612140576121ce565b61216d8382815181106121555761215561464d565b6020026020010151600b6136b490919063ffffffff16565b507f4c910b69fe65a61f7531b9c5042b2329ca7179c77290aa7e2eb3afa3c8511fd38382815181106121a1576121a161464d565b60200260200101516040516121c591906001600160a01b0391909116815260200190565b60405180910390a15b806121d881614679565b915050612119565b6121e8612b59565b60005b81518110156124fd576122218282815181106122095761220961464d565b6020026020010151600d61365b90919063ffffffff16565b61222a576124eb565b6000600760008484815181106122425761224261464d565b602090810291909101810151825281810192909252604090810160002081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e083015260058301546101008301526006830154610120830152600783015491929161014084019160ff9091169081111561231f5761231f614445565b600381111561233057612330614445565b8152602001600882018054612344906146ac565b80601f0160208091040260200160405190810160405280929190818152602001828054612370906146ac565b80156123bd5780601f10612392576101008083540402835291602001916123bd565b820191906000526020600020905b8154815290600101906020018083116123a057829003601f168201915b5050509190925250508151919250506001600160a01b031633146124145760405162461bcd60e51b815260206004820152600e60248201526d2737ba103cb7bab91037b93232b960911b604482015260640161061e565b6124418383815181106124295761242961464d565b6020026020010151600d6136c990919063ffffffff16565b5060a081015181516001600160a01b03908116600090815260096020908152604080832082870151909416835292905290812080546001600160801b0390931692909190612490908490614694565b925050819055507fc41f4ceb2938876c35e61b705e9d2f18a02c4a26ce5e049a6308a943d46851b38383815181106124ca576124ca61464d565b60200260200101516040516124e191815260200190565b60405180910390a1505b806124f581614679565b9150506121eb565b506125086001600255565b50565b6000611f68600a5490565b60008181526001602052604081206105b6906136aa565b606081516001600160401b0381111561254857612548613f8a565b60405190808252806020026020018201604052801561258157816020015b61256e613dd8565b8152602001906001900390816125665790505b50905060005b8251811015612807576040518060a001604052808483815181106125ad576125ad61464d565b60200260200101518152602001600760008685815181106125d0576125d061464d565b602090810291909101810151825281810192909252604090810160002081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e083015260058301546101008301526006830154610120830152600783015491929161014084019160ff909116908111156126ad576126ad614445565b60038111156126be576126be614445565b81526020016008820180546126d2906146ac565b80601f01602080910402602001604051908101604052809291908181526020018280546126fe906146ac565b801561274b5780601f106127205761010080835404028352916020019161274b565b820191906000526020600020905b81548152906001019060200180831161272e57829003601f168201915b50505050508152505081526020016005600086858151811061276f5761276f61464d565b60200260200101518152602001908152602001600020548152602001600660008685815181106127a1576127a161464d565b602002602001015181526020019081526020016000205481526020016127d28584815181106122095761220961464d565b15158152508282815181106127e9576127e961464d565b602002602001018190525080806127ff90614679565b915050612587565b50919050565b6000612819600d6136aa565b821061285a5760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59081d1bdad95b881a5960821b604482015260640161061e565b6105b6600d8361369e565b60008281526020819052604090206001015461288081612bb1565b6108aa8383612bdd565b60006105b6600d8361365b565b60006128a1612b59565b3360009081526009602090815260408083206001600160a01b038716845290915290205482111561290c5760405162461bcd60e51b8152602060048201526015602482015274416d6f756e74206578636565642062616c616e636560581b604482015260640161061e565b3360009081526009602090815260408083206001600160a01b03871684529091528120805484929061293f90849061480d565b9091555061295990506001600160a01b03841633846136d5565b604080513381526001600160a01b03851660208201529081018390527ff10eae2de0b095be715d0a32380cea8e913ae297b48430b5397024146ce9036590606001610afe565b606060006129ad600d6136aa565b90508084106129cc5750506040805160008152602081019091526105b6565b60006129d88486614694565b9050808210156129e55750805b6129ef858261480d565b6001600160401b03811115612a0657612a06613f8a565b604051908082528060200260200182016040528015612a2f578160200160208202803683370190505b50925060005b8351811015612a8257612a53612a4b8288614694565b600d9061369e565b848281518110612a6557612a6561464d565b602090810291909101015280612a7a81614679565b915050612a35565b50505092915050565b612a958282611ec4565b610815576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055612acb3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000611ebd836001600160a01b038416613705565b60006001600160e01b03198216637965db0b60e01b14806105b657506301ffc9a760e01b6001600160e01b03198316146105b6565b600280541415612bab5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161061e565b60028055565b6125088133613754565b612bc58282612a8b565b60008281526001602052604090206108aa9082612b0f565b612be782826137ad565b60008281526001602052604090206108aa90826136b4565b600081815260076020818152604080842081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e08301526005830154610100830152600683015461012083015292820154909261014084019160ff1690811115612ccc57612ccc614445565b6003811115612cdd57612cdd614445565b8152602001600882018054612cf1906146ac565b80601f0160208091040260200160405190810160405280929190818152602001828054612d1d906146ac565b8015612d6a5780601f10612d3f57610100808354040283529160200191612d6a565b820191906000526020600020905b815481529060010190602001808311612d4d57829003601f168201915b5050509190925250505060a081015190915060038261014001516003811115612d9557612d95614445565b1415612f5d576000826101600151806020019051810190612db6919061473f565b600354602085015160408087015184516060890151925163d92cec1b60e01b81529596506000956001600160a01b03600160401b8704169563d92cec1b95612e0d9590949392909163ffffffff16906004016147b0565b602060405180830381865afa158015612e2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e4e91906147f4565b600086815260056020526040902054909150801580612e845750612e76818460400151613673565b612e809082614694565b8210155b15612ec7578460a001516001600160801b031683602001516001600160801b031610612ebb57612eb5600d876136c9565b50612efa565b82602001519350612efa565b612ed5818460400151613673565b612edf908261480d565b821015612efa5760a08501519350612ef8600d876136c9565b505b6000868152600560209081526040808320859055600790915281206003018054869290612f319084906001600160801b0316614888565b92506101000a8154816001600160801b0302191690836001600160801b031602179055505050506132ce565b60028261014001516003811115612f7657612f76614445565b1415613036576000826101600151806020019051810190612f9791906146e1565b9050806020015191508260a001516001600160801b031681602001516001600160801b031610612fd55760a08301519150612fd3600d856136c9565b505b600084815260056020908152604080832042905560079091528120600301805484929061300c9084906001600160801b0316614888565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550506132ce565b6000826101400151600381111561304f5761304f614445565b148061307157506001826101400151600381111561306f5761306f614445565b145b156132ce57613081600d846136c9565b50610120820151156132ce5761012082015161309f90600d9061365b565b156132ce5761012080830151600090815260076020818152604080842081516101808101835281546001600160a01b039081168252600183015481169482019490945260028201549384169281019290925262ffffff600160a01b840481166060840152600160b81b90930490921660808201526003808301546001600160801b0380821660a0850152600160801b909104811660c084015260048401541660e083015260058301546101008301526006830154958201959095529181015492939192909161014084019160ff169081111561317d5761317d614445565b600381111561318e5761318e614445565b81526020016008820180546131a2906146ac565b80601f01602080910402602001604051908101604052809291908181526020018280546131ce906146ac565b801561321b5780601f106131f05761010080835404028352916020019161321b565b820191906000526020600020905b8154815290600101906020018083116131fe57829003601f168201915b505050505081525050905061323f836101200151600d6136c990919063ffffffff16565b5060a081015181516001600160a01b03908116600090815260096020908152604080832082870151909416835292905290812080546001600160801b039093169290919061328e908490614694565b90915550506101208301516040519081527fc41f4ceb2938876c35e61b705e9d2f18a02c4a26ce5e049a6308a943d46851b39060200160405180910390a1505b602082015160035460405163095ea7b360e01b81526001600160a01b03600160401b909204821660048201526001600160801b038416602482015291169063095ea7b3906044016020604051808303816000875af1158015613334573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061335891906148b0565b50600354602083015160408085015160608601516080870151925163a7ce47c560e01b81523060048201526001600160a01b03948516602482015291841660448301526001600160801b038616606483015262ffffff908116608483015290911660a4820152600092600160401b90049091169063a7ce47c59060c4016020604051808303816000875af11580156133f4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341891906147f4565b9050600061343882600360049054906101000a900463ffffffff16613812565b90506000846101400151600381111561345357613453614445565b148061347557506001846101400151600381111561347357613473614445565b145b156134d157613484818361480d565b8460e001516001600160801b0316106134d15760405162461bcd60e51b815260206004820152600f60248201526e556e666169722065786368616e676560881b604482015260640161061e565b6004546001600160a01b039081166000908152600960209081526040808320888201519094168352929052908120805483929061350f908490614694565b9091555061351f9050818361480d565b84516001600160a01b039081166000908152600960209081526040808320818a01519094168352929052908120805490919061355c908490614694565b9091555061356c9050818361480d565b6000868152600660205260408120805490919061358a908490614694565b9091555050604080518681523360208201527f7dcea57e3cdcea187cf2d57047e2b9260a274caa69cb5fe9525d123ef6c12a17910160405180910390a15050505050565b6001600160a01b03811660009081526001830160205260408120541515611ebd565b6040516001600160a01b0380851660248301528316604482015260648101829052610a149085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613828565b60008181526001830160205260408120541515611ebd565b6000620f424061368862ffffff8416856148d2565b611ebd91906148f1565b6000611ebd8383613705565b6000611ebd83836138fd565b60006105b6825490565b6000611ebd836001600160a01b038416613927565b6000611ebd8383613927565b6040516001600160a01b0383166024820152604481018290526108aa90849063a9059cbb60e01b90606401613624565b600081815260018301602052604081205461374c575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105b6565b5060006105b6565b61375e8282611ec4565b6108155761376b81613a1a565b613776836020613a2c565b604051602001613787929190614913565b60408051601f198184030181529082905262461bcd60e51b825261061e91600401614988565b6137b78282611ec4565b15610815576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000620f424061368863ffffffff8416856148d2565b600061387d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613bc79092919063ffffffff16565b905080516000148061389e57508080602001905181019061389e91906148b0565b6108aa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161061e565b60008260000182815481106139145761391461464d565b9060005260206000200154905092915050565b60008181526001830160205260408120548015613a1057600061394b60018361480d565b855490915060009061395f9060019061480d565b90508181146139c457600086600001828154811061397f5761397f61464d565b90600052602060002001549050808760000184815481106139a2576139a261464d565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806139d5576139d561499b565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105b6565b60009150506105b6565b60606105b66001600160a01b03831660145b60606000613a3b8360026148d2565b613a46906002614694565b6001600160401b03811115613a5d57613a5d613f8a565b6040519080825280601f01601f191660200182016040528015613a87576020820181803683370190505b509050600360fc1b81600081518110613aa257613aa261464d565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613ad157613ad161464d565b60200101906001600160f81b031916908160001a9053506000613af58460026148d2565b613b00906001614694565b90505b6001811115613b78576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613b3457613b3461464d565b1a60f81b828281518110613b4a57613b4a61464d565b60200101906001600160f81b031916908160001a90535060049490941c93613b71816149b1565b9050613b03565b508315611ebd5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161061e565b6060613bd68484600085613bde565b949350505050565b606082471015613c3f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161061e565b600080866001600160a01b03168587604051613c5b91906149c8565b60006040518083038185875af1925050503d8060008114613c98576040519150601f19603f3d011682016040523d82523d6000602084013e613c9d565b606091505b5091509150613cae87838387613cb9565b979650505050505050565b60608315613d25578251613d1e576001600160a01b0385163b613d1e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161061e565b5081613bd6565b613bd68383815115613d3a5781518083602001fd5b8060405162461bcd60e51b815260040161061e9190614988565b828054613d60906146ac565b90600052602060002090601f016020900481019282613d825760008555613dc8565b82601f10613d9b57805160ff1916838001178555613dc8565b82800160010185558215613dc8579182015b82811115613dc8578251825591602001919060010190613dad565b50613dd4929150613e6e565b5090565b6040518060a0016040528060008152602001613e516040805161018081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052906101408201908152602001606081525090565b815260200160008152602001600081526020016000151581525090565b5b80821115613dd45760008155600101613e6f565b600060208284031215613e9557600080fd5b81356001600160e01b031981168114611ebd57600080fd5b60008060408385031215613ec057600080fd5b50508035926020909101359150565b80356001600160a01b03811681146109ad57600080fd5b600060208284031215613ef857600080fd5b611ebd82613ecf565b6020808252825182820181905260009190848201906040850190845b81811015613f3957835183529284019291840191600101613f1d565b50909695505050505050565b600060208284031215613f5757600080fd5b5035919050565b60008060408385031215613f7157600080fd5b82359150613f8160208401613ecf565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b60405161018081016001600160401b0381118282101715613fc357613fc3613f8a565b60405290565b604051601f8201601f191681016001600160401b0381118282101715613ff157613ff1613f8a565b604052919050565b60006001600160401b0382111561401257614012613f8a565b5060051b60200190565b6000602080838503121561402f57600080fd5b82356001600160401b0381111561404557600080fd5b8301601f8101851361405657600080fd5b803561406961406482613ff9565b613fc9565b81815260059190911b8201830190838101908783111561408857600080fd5b928401925b82841015613cae5783358252928401929084019061408d565b600080602083850312156140b957600080fd5b82356001600160401b03808211156140d057600080fd5b818501915085601f8301126140e457600080fd5b8135818111156140f357600080fd5b86602082850101111561410557600080fd5b60209290920196919550909350505050565b6000806040838503121561412a57600080fd5b61413383613ecf565b946020939093013593505050565b62ffffff8116811461250857600080fd5b80356109ad81614141565b6001600160801b038116811461250857600080fd5b80356109ad8161415d565b8035600481106109ad57600080fd5b600082601f83011261419d57600080fd5b81356001600160401b038111156141b6576141b6613f8a565b6141c9601f8201601f1916602001613fc9565b8181528460208386010111156141de57600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561420d57600080fd5b81356001600160401b038082111561422457600080fd5b90830190610180828603121561423957600080fd5b614241613fa0565b61424a83613ecf565b815261425860208401613ecf565b602082015261426960408401613ecf565b604082015261427a60608401614152565b606082015261428b60808401614152565b608082015261429c60a08401614172565b60a08201526142ad60c08401614172565b60c08201526142be60e08401614172565b60e0820152610100838101359082015261012080840135908201526101406142e781850161417d565b9082015261016083810135838111156142ff57600080fd5b61430b8882870161418c565b918301919091525095945050505050565b6000806040838503121561432f57600080fd5b61433883613ecf565b9150613f8160208401613ecf565b60005b83811015614361578181015183820152602001614349565b83811115610a145750506000910152565b6000815180845261438a816020860160208601614346565b601f01601f19169290920160200192915050565b8215158152604060208201526000613bd66040830184614372565b600060208083850312156143cc57600080fd5b82356001600160401b038111156143e257600080fd5b8301601f810185136143f357600080fd5b803561440161406482613ff9565b81815260059190911b8201830190838101908783111561442057600080fd5b928401925b82841015613cae5761443684613ecf565b82529284019290840190614425565b634e487b7160e01b600052602160045260246000fd5b6004811061447957634e487b7160e01b600052602160045260246000fd5b9052565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b8381101561461957603f19898403018552815160a08151855288820151818a8701526144db82870182516001600160a01b03169052565b8981015160c06144f5818901836001600160a01b03169052565b8a830151915060e0614511818a01846001600160a01b03169052565b606092508284015161010061452c818c018362ffffff169052565b6080915081860151610120614547818e018362ffffff169052565b978701519761014091506145658d83018a6001600160801b03169052565b948701519750610160946145838d87018a6001600160801b03169052565b938701519750610180936145a18d86018a6001600160801b03169052565b918701516101a08d0152908601516101c08c015285015195506145c86101e08b018761445b565b828501519550816102008b01526145e36102208b0187614372565b878e01518b8f015284880151948b01949094529586015115159590980194909452978a01979550505091870191506001016144a4565b509098975050505050505050565b60006020828403121561463957600080fd5b813563ffffffff81168114611ebd57600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561468d5761468d614663565b5060010190565b600082198211156146a7576146a7614663565b500190565b600181811c908216806146c057607f821691505b6020821081141561280757634e487b7160e01b600052602260045260246000fd5b6000604082840312156146f357600080fd5b604051604081018181106001600160401b038211171561471557614715613f8a565b60405282516147238161415d565b815260208301516147338161415d565b60208201529392505050565b60006060828403121561475157600080fd5b604051606081018181106001600160401b038211171561477357614773613f8a565b60405282516147818161415d565b815260208301516147918161415d565b602082015260408301516147a481614141565b60408201529392505050565b6001600160a01b0395861681529390941660208401526001600160801b0391909116604083015262ffffff16606082015263ffffffff909116608082015260a00190565b60006020828403121561480657600080fd5b5051919050565b60008282101561481f5761481f614663565b500390565b6000806040838503121561483757600080fd5b82356148428161415d565b915060208301356148528161415d565b809150509250929050565b60006001600160801b0380831681851680830382111561487f5761487f614663565b01949350505050565b60006001600160801b03838116908316818110156148a8576148a8614663565b039392505050565b6000602082840312156148c257600080fd5b81518015158114611ebd57600080fd5b60008160001904831182151516156148ec576148ec614663565b500290565b60008261490e57634e487b7160e01b600052601260045260246000fd5b500490565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161494b816017850160208801614346565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161497c816028840160208801614346565b01602801949350505050565b602081526000611ebd6020830184614372565b634e487b7160e01b600052603160045260246000fd5b6000816149c0576149c0614663565b506000190190565b600082516149da818460208701614346565b919091019291505056fea49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775a264697066735822122042f56d61454e53e2f070fa78f7109cc5f1e9ce59b2f6b7c83de06681757e82f064736f6c634300080c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000099cb3439f88dfd1d9c6c4b7141a0696ecea96ff3000000000000000000000000b984f9f42d405a37f7f3903c73cbf7112dcc859b0000000000000000000000000000000000000000000000000000000000002710000000000000000000000000b984f9f42d405a37f7f3903c73cbf7112dcc859b
-----Decoded View---------------
Arg [0] : uniswapHelperV3_ (address): 0x99CB3439F88dFD1D9c6C4B7141a0696EcEa96ff3
Arg [1] : admin (address): 0xB984f9F42d405A37F7f3903C73cbF7112DCc859b
Arg [2] : protocolFee_ (uint32): 10000
Arg [3] : feeRecipient_ (address): 0xB984f9F42d405A37F7f3903C73cbF7112DCc859b
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000099cb3439f88dfd1d9c6c4b7141a0696ecea96ff3
Arg [1] : 000000000000000000000000b984f9f42d405a37f7f3903c73cbf7112dcc859b
Arg [2] : 0000000000000000000000000000000000000000000000000000000000002710
Arg [3] : 000000000000000000000000b984f9f42d405a37f7f3903c73cbf7112dcc859b
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.