ERC-721
Overview
Max Total Supply
232 BitSwap-LIQUIDITY-NFT
Holders
80
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Balance
1 BitSwap-LIQUIDITY-NFTLoading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
LiquidityManager
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 100 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./core/interfaces/IBitSwapCallback.sol"; import "./core/interfaces/IBitSwapFactory.sol"; import "./core/interfaces/IBitSwapPool.sol"; import "./libraries/MintMath.sol"; import "./libraries/TwoPower.sol"; import "./base/base.sol"; contract LiquidityManager is Ownable, Base, ERC721Enumerable, IBitSwapMintCallback { /// @notice Emitted when miner successfully add liquidity on an existing liquidity-nft /// @param nftId id of minted liquidity nft /// @param pool address of swap pool /// @param liquidityDelta the amount of liquidity added /// @param amountX amount of tokenX deposit /// @param amountY amount of tokenY deposit event AddLiquidity( uint256 indexed nftId, address pool, uint128 liquidityDelta, uint256 amountX, uint256 amountY ); /// @notice Emitted when miner successfully add decrease liquidity on an existing liquidity-nft /// @param nftId id of minted liquidity nft /// @param pool address of swap pool /// @param liquidityDelta the amount of liquidity decreased /// @param amountX amount of tokenX withdrawed /// @param amountY amount of tokenY withdrawed event DecLiquidity( uint256 indexed nftId, address pool, uint128 liquidityDelta, uint256 amountX, uint256 amountY ); // callback data passed through BitSwapPool#mint to the callback struct MintCallbackData { // tokenX of swap address tokenX; // tokenY of swap address tokenY; // fee amount of swap uint24 fee; // address to pay tokenX and tokenY to BitSwapPool address payer; } // max-poolId in poolIds, poolId starts from 1 uint128 private maxPoolId = 1; // infomation of liquidity provided by miner struct Liquidity { // left point of liquidity-token, the range is [leftPt, rightPt) int24 leftPt; // right point of liquidity-token, the range is [leftPt, rightPt) int24 rightPt; // amount of liquidity on each point in [leftPt, rightPt) uint128 liquidity; // a 128-fixpoint number, as integral of { fee(pt, t)/L(pt, t) }. // here fee(pt, t) denotes fee generated on point pt at time t // L(pt, t) denotes liquidity on point pt at time t // pt varies in [leftPt, rightPt) // t moves from pool created until miner last modify this liquidity-token (mint/addLiquidity/decreaseLiquidity/create) uint256 lastFeeScaleX_128; uint256 lastFeeScaleY_128; // remained tokenX miner can collect, including fee and withdrawed token uint256 remainTokenX; uint256 remainTokenY; // id of pool in which this liquidity is added uint128 poolId; } /// @notice mapping from nftId to Liquidity info mapping(uint256 =>Liquidity) public liquidities; /// @notice num of liquidity token uint256 public liquidityNum = 0; struct PoolMeta { // tokenX of pool address tokenX; // tokenY of pool address tokenY; // fee amount of pool uint24 fee; } /// @notice mapping from poolId to meta info of pool mapping(uint128 =>PoolMeta) public poolMetas; /// @notice mapping from address to poolId within this contract mapping(address =>uint128) public poolIds; modifier checkAuth(uint256 lid) { require(_isApprovedOrOwner(msg.sender, lid), 'Not approved'); _; } string public baseURI; function _baseURI() internal view override returns (string memory) { return baseURI; } function setBaseURI(string calldata newBaseURI) external onlyOwner { baseURI = newBaseURI; } /// @notice Constructor to create this contract. /// @param factory address of BitSwapFactory /// @param weth address of WETH token constructor( address factory, address weth ) ERC721("BitSwap Liquidity NFT", "BitSwap-LIQUIDITY-NFT") Base(factory, weth) { } /// @notice Callback for mining, in order to deposit tokens. /// @param x amount of tokenX pay from miner /// @param y amount of tokenY pay from miner /// @param data encoded MintCallbackData function mintDepositCallback( uint256 x, uint256 y, bytes calldata data ) external override { MintCallbackData memory dt = abi.decode(data, (MintCallbackData)); verify(dt.tokenX, dt.tokenY, dt.fee); if (x > 0) { pay(dt.tokenX, dt.payer, msg.sender, x); } if (y > 0) { pay(dt.tokenY, dt.payer, msg.sender, y); } } /// @notice Get or create a pool for (tokenX/tokenY/fee) if not exists. /// @param tokenX tokenX of swap pool /// @param tokenY tokenY of swap pool /// @param fee fee amount of swap pool /// @param initialPoint initial point if need to create a new pool /// @return corresponding pool address function createPool(address tokenX, address tokenY, uint24 fee, int24 initialPoint) external returns (address) { require(tokenX < tokenY, "x<y"); address pool = IBitSwapFactory(factory).pool(tokenX, tokenY, fee); if (pool == address(0)) { pool = IBitSwapFactory(factory).newPool(tokenX, tokenY, fee, initialPoint); return pool; } return pool; } function liquidityKey(address miner, int24 pl, int24 pr) internal pure returns(bytes32) { return keccak256(abi.encodePacked(miner, pl, pr)); } function cachePoolKey(address pool, PoolMeta memory meta) private returns (uint128 poolId) { poolId = poolIds[pool]; if (poolId == 0) { poolIds[pool] = (poolId = maxPoolId++); poolMetas[poolId] = meta; } } function getLastFeeScale(address pool, bytes32 key) private view returns(uint256, uint256) { (, uint256 lastFeeScaleX_128, uint256 lastFeeScaleY_128, , ) = IBitSwapPool(pool).liquidity( key ); return (lastFeeScaleX_128, lastFeeScaleY_128); } function getPoolPrice(address pool) private view returns (uint160, int24) { ( uint160 sqrtPrice_96, int24 currPt, , , , , , ) = IBitSwapPool(pool).state(); return (sqrtPrice_96, currPt); } /// parameters when calling mint, grouped together to avoid stake too deep struct MintParam { // miner address address miner; // tokenX of swap pool address tokenX; // tokenY of swap pool address tokenY; // fee amount of swap pool uint24 fee; // left point of added liquidity int24 pl; // right point of added liquidity int24 pr; // amount limit of tokenX miner willing to deposit uint128 xLim; // amount limit tokenY miner willing to deposit uint128 yLim; // minimum amount of tokenX miner willing to deposit uint128 amountXMin; // minimum amount of tokenY miner willing to deposit uint128 amountYMin; uint256 deadline; } function _addLiquidity(MintParam memory mp) private returns( uint128 liquidity, uint256 amountX, uint256 amountY, address pool ) { int24 currPt; uint160 sqrtPrice_96; pool = IBitSwapFactory(factory).pool(mp.tokenX, mp.tokenY, mp.fee); uint160 sqrtRate_96 = IBitSwapPool(pool).sqrtRate_96(); require(pool != address(0), "P0"); (sqrtPrice_96, currPt) = getPoolPrice(pool); liquidity = MintMath.computeLiquidity( MintMath.MintMathParam({ pl: mp.pl, pr: mp.pr, xLim: mp.xLim, yLim: mp.yLim }), currPt, sqrtPrice_96, sqrtRate_96 ); (amountX, amountY) = IBitSwapPool(pool).mint(address(this), mp.pl, mp.pr, liquidity, abi.encode(MintCallbackData({tokenX: mp.tokenX, tokenY: mp.tokenY, fee: mp.fee, payer: msg.sender}))); } /// @notice Add a new liquidity and generate a nft. /// @param mintParam params, see MintParam for more /// @return lid id of nft /// @return liquidity amount of liquidity added /// @return amountX amount of tokenX deposited /// @return amountY amount of tokenY depsoited function mint(MintParam calldata mintParam) external payable checkDeadline(mintParam.deadline) returns( uint256 lid, uint128 liquidity, uint256 amountX, uint256 amountY ) { require(mintParam.tokenX < mintParam.tokenY, "x<y"); address pool; (liquidity, amountX, amountY, pool) = _addLiquidity(mintParam); require(amountX >= mintParam.amountXMin, "XMIN"); require(amountY >= mintParam.amountYMin, "YMIN"); lid = liquidityNum ++; (uint256 lastFeeScaleX_128, uint256 lastFeeScaleY_128) = getLastFeeScale( pool, liquidityKey(address(this), mintParam.pl, mintParam.pr) ); uint128 poolId = cachePoolKey(pool, PoolMeta({tokenX: mintParam.tokenX, tokenY: mintParam.tokenY, fee: mintParam.fee})); liquidities[lid] = Liquidity({ leftPt: mintParam.pl, rightPt: mintParam.pr, liquidity: liquidity, lastFeeScaleX_128: lastFeeScaleX_128, lastFeeScaleY_128: lastFeeScaleY_128, remainTokenX: 0, remainTokenY: 0, poolId: poolId }); _mint(mintParam.miner, lid); emit AddLiquidity(lid, pool, liquidity, amountX, amountY); } /// @notice Burn a generated nft. /// @param lid nft (liquidity) id /// @return success successfully burn or not function burn(uint256 lid) external checkAuth(lid) returns (bool success) { Liquidity storage liquid = liquidities[lid]; require(liquid.liquidity == 0 && liquid.remainTokenX == 0 && liquid.remainTokenY == 0, 'NC'); delete liquidities[lid]; _burn(lid); return true; } /// parameters when calling addLiquidity, grouped together to avoid stake too deep struct AddLiquidityParam { // id of nft uint256 lid; // amount limit of tokenX user willing to deposit uint128 xLim; // amount limit of tokenY user willing to deposit uint128 yLim; // min amount of tokenX user willing to deposit uint128 amountXMin; // min amount of tokenY user willing to deposit uint128 amountYMin; uint256 deadline; } function updateLiquidity( Liquidity storage liquid, address pool, uint128 newLiquidity, uint256 amountX, uint256 amountY ) private { (uint256 lastFeeScaleX_128, uint256 lastFeeScaleY_128) = getLastFeeScale( pool, liquidityKey(address(this), liquid.leftPt, liquid.rightPt) ); (uint256 deltaScaleX, uint256 deltaScaleY) = (liquid.lastFeeScaleX_128, liquid.lastFeeScaleY_128); assembly { deltaScaleX := sub(lastFeeScaleX_128, deltaScaleX) deltaScaleY := sub(lastFeeScaleY_128, deltaScaleY) } liquid.remainTokenX += amountX + MulDivMath.mulDivFloor(deltaScaleX, liquid.liquidity, TwoPower.pow128); liquid.remainTokenY += amountY + MulDivMath.mulDivFloor(deltaScaleY, liquid.liquidity, TwoPower.pow128); liquid.lastFeeScaleX_128 = lastFeeScaleX_128; liquid.lastFeeScaleY_128 = lastFeeScaleY_128; liquid.liquidity = newLiquidity; } /// @notice Add liquidity to a existing nft. /// @param addLiquidityParam see AddLiquidityParam for more /// @return liquidityDelta amount of added liquidity /// @return amountX amount of tokenX deposited /// @return amountY amonut of tokenY deposited function addLiquidity( AddLiquidityParam calldata addLiquidityParam ) external payable checkAuth(addLiquidityParam.lid) checkDeadline(addLiquidityParam.deadline) returns ( uint128 liquidityDelta, uint256 amountX, uint256 amountY ) { require(addLiquidityParam.lid < liquidityNum, "LN"); Liquidity storage liquid = liquidities[addLiquidityParam.lid]; PoolMeta memory poolMeta = poolMetas[liquid.poolId]; int24 currPt; uint160 sqrtPrice_96; address pool = IBitSwapFactory(factory).pool(poolMeta.tokenX, poolMeta.tokenY, poolMeta.fee); // uint160 sqrtRate_96 = IBitSwapPool(pool).sqrtRate_96(); require(pool != address(0), "P0"); (sqrtPrice_96, currPt) = getPoolPrice(pool); liquidityDelta = MintMath.computeLiquidity( MintMath.MintMathParam({ pl: liquid.leftPt, pr: liquid.rightPt, xLim: addLiquidityParam.xLim, yLim: addLiquidityParam.yLim }), currPt, sqrtPrice_96, // sqrtRate_96 IBitSwapPool(pool).sqrtRate_96() ); require(int128(liquid.liquidity) == int256(uint256(liquid.liquidity)), "LO"); uint128 newLiquidity = liquidityDelta + liquid.liquidity; (amountX, amountY) = IBitSwapPool(pool).mint(address(this), liquid.leftPt, liquid.rightPt, liquidityDelta, abi.encode(MintCallbackData({tokenX: poolMeta.tokenX, tokenY: poolMeta.tokenY, fee: poolMeta.fee, payer: msg.sender}))); require(amountX >= addLiquidityParam.amountXMin, "XMIN"); require(amountY >= addLiquidityParam.amountYMin, "YMIN"); updateLiquidity(liquid, pool, newLiquidity, 0, 0); emit AddLiquidity(addLiquidityParam.lid, pool, liquidityDelta, amountX, amountY); } /// @notice Decrease liquidity from a nft. /// @param lid id of nft /// @param liquidDelta amount of liqudity to decrease /// @param amountXMin min amount of tokenX user want to withdraw /// @param amountYMin min amount of tokenY user want to withdraw /// @param deadline deadline timestamp of transaction /// @return amountX amount of tokenX refund to user /// @return amountY amount of tokenY refund to user function decLiquidity( uint256 lid, uint128 liquidDelta, uint256 amountXMin, uint256 amountYMin, uint256 deadline ) external checkAuth(lid) checkDeadline(deadline) returns ( uint256 amountX, uint256 amountY ) { require(lid < liquidityNum, "LN"); Liquidity storage liquidity = liquidities[lid]; if (liquidity.liquidity == 0) { // no need to call core to update fee return (0, 0); } if (liquidDelta > liquidity.liquidity) { liquidDelta = liquidity.liquidity; } PoolMeta memory poolMeta = poolMetas[liquidity.poolId]; address pool = IBitSwapFactory(factory).pool(poolMeta.tokenX, poolMeta.tokenY, poolMeta.fee); require(pool != address(0), "P0"); uint128 newLiquidity = liquidity.liquidity - liquidDelta; (amountX, amountY) = IBitSwapPool(pool).burn(liquidity.leftPt, liquidity.rightPt, liquidDelta); require(amountX >= amountXMin, "XMIN"); require(amountY >= amountYMin, "YMIN"); updateLiquidity(liquidity, pool, newLiquidity, amountX, amountY); emit DecLiquidity(lid, pool, liquidDelta, amountX, amountY); } /// @notice Collect fee gained of token withdrawed from nft. /// @param recipient address to receive token /// @param lid id of nft /// @param amountXLim amount limit of tokenX to collect /// @param amountYLim amount limit of tokenY to collect /// @return amountX amount of tokenX actually collect /// @return amountY amount of tokenY actually collect function collect( address recipient, uint256 lid, uint128 amountXLim, uint128 amountYLim ) external payable checkAuth(lid) returns ( uint256 amountX, uint256 amountY ) { if (recipient == address(0)) { recipient = address(this); } require(lid < liquidityNum, "LN"); Liquidity storage liquidity = liquidities[lid]; PoolMeta memory poolMeta = poolMetas[liquidity.poolId]; address pool = IBitSwapFactory(factory).pool(poolMeta.tokenX, poolMeta.tokenY, poolMeta.fee); require(pool != address(0), "P0"); if (liquidity.liquidity > 0) { IBitSwapPool(pool).burn(liquidity.leftPt, liquidity.rightPt, 0); updateLiquidity(liquidity, pool, liquidity.liquidity, 0, 0); } if (amountXLim > liquidity.remainTokenX) { amountXLim = uint128(liquidity.remainTokenX); } if (amountYLim > liquidity.remainTokenY) { amountYLim = uint128(liquidity.remainTokenY); } (amountX, amountY) = IBitSwapPool(pool).collect(recipient, liquidity.leftPt, liquidity.rightPt, amountXLim, amountYLim); // amountX(Y)Lim may be a little greater than actual value liquidity.remainTokenX -= amountXLim; liquidity.remainTokenY -= amountYLim; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated 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/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev See {ERC721-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual override { super._beforeTokenTransfer(from, to, firstTokenId, batchSize); if (batchSize > 1) { // Will only trigger during construction. Batch transferring (minting) is not available afterwards. revert("ERC721Enumerable: consecutive transfers not supported"); } uint256 tokenId = firstTokenId; if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated 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 (last updated v4.9.4) (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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 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 pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../core/interfaces/IBitSwapFactory.sol"; /// @title Interface for WETH9 interface IWETH9 is IERC20 { /// @notice Deposit ether to get wrapped ether function deposit() external payable; /// @notice Withdraw wrapped ether to get ether function withdraw(uint256) external; } abstract contract Base { /// @notice address of BitSwapFactory address public immutable factory; /// @notice address of weth9 token address public immutable WETH9; modifier checkDeadline(uint256 deadline) { require(block.timestamp <= deadline, 'Out of time'); _; } receive() external payable {} /// @notice Constructor of base. /// @param _factory address of BitSwapFactory /// @param _WETH9 address of weth9 token constructor(address _factory, address _WETH9) { factory = _factory; WETH9 = _WETH9; } /// @notice Make multiple function calls in this contract in a single transaction /// and return the data for each function call, revert if any function call fails /// @param data The encoded function data for each function call /// @return results result of each function call function multicall(bytes[] calldata data) external payable returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { (bool success, bytes memory result) = address(this).delegatecall(data[i]); if (!success) { if (result.length < 68) revert(); assembly { result := add(result, 0x04) } revert(abi.decode(result, (string))); } results[i] = result; } } /// @notice Transfer tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfer tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Approve the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA'); } /// @notice Transfer ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } /// @notice Withdraw all weth9 token of this contract and send the withdrawed eth to recipient /// usually used in multicall when mint/swap/update limitorder with eth /// normally this contract has no any erc20 token or eth after or before a transaction /// we donot need to worry that some one can steal eth from this contract /// @param minAmount The minimum amount of WETH9 to withdraw /// @param recipient The address to receive all withdrawed eth from this contract function unwrapWETH9(uint256 minAmount, address recipient) external payable { uint256 all = IWETH9(WETH9).balanceOf(address(this)); require(all >= minAmount, 'WETH9 Not Enough'); if (all > 0) { IWETH9(WETH9).withdraw(all); safeTransferETH(recipient, all); } } /// @notice Send all balance of specified token in this contract to recipient /// usually used in multicall when mint/swap/update limitorder with eth /// normally this contract has no any erc20 token or eth after or before a transaction /// we donot need to worry that some one can steal some token from this contract /// @param token address of the token /// @param minAmount balance should >= minAmount /// @param recipient the address to receive specified token from this contract function sweepToken( address token, uint256 minAmount, address recipient ) external payable { uint256 all = IERC20(token).balanceOf(address(this)); require(all >= minAmount, 'WETH9 Not Enough'); if (all > 0) { safeTransfer(token, recipient, all); } } /// @notice Send all balance of eth in this contract to msg.sender /// usually used in multicall when mint/swap/update limitorder with eth /// normally this contract has no any erc20 token or eth after or before a transaction /// we donot need to worry that some one can steal some token from this contract function refundETH() external payable { if (address(this).balance > 0) safeTransferETH(msg.sender, address(this).balance); } /// @param token The token to pay /// @param payer The entity that must pay /// @param recipient The entity that will receive payment /// @param value The amount to pay function pay( address token, address payer, address recipient, uint256 value ) internal { if (token == WETH9 && address(this).balance >= value) { // pay with WETH9 IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay IWETH9(WETH9).transfer(recipient, value); } else if (payer == address(this)) { // pay with tokens already in the contract (for the exact input multihop case) safeTransfer(token, recipient, value); } else { // pull payment safeTransferFrom(token, payer, recipient, value); } } /// @notice Query pool address from factory by (tokenX, tokenY, fee). /// @param tokenX tokenX of swap pool /// @param tokenY tokenY of swap pool /// @param fee fee amount of swap pool function pool(address tokenX, address tokenY, uint24 fee) public view returns(address) { return IBitSwapFactory(factory).pool(tokenX, tokenY, fee); } function verify(address tokenX, address tokenY, uint24 fee) internal view { require (msg.sender == pool(tokenX, tokenY, fee), "sp"); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.4; interface IBitSwapMintCallback { /// @notice Called to msg.sender in BitSwapPool#mint call /// @param x Amount of tokenX need to pay from miner /// @param y Amount of tokenY need to pay from miner /// @param data Any data passed through by the msg.sender via the BitSwapPool#mint call function mintDepositCallback( uint256 x, uint256 y, bytes calldata data ) external; } interface IBitSwapCallback { /// @notice Called to msg.sender in BitSwapPool#swapY2X(DesireX) call /// @param x Amount of tokenX trader will acquire /// @param y Amount of tokenY trader will pay /// @param data Any dadta passed though by the msg.sender via the BitSwapPool#swapY2X(DesireX) call function swapY2XCallback( uint256 x, uint256 y, bytes calldata data ) external; /// @notice Called to msg.sender in BitSwapPool#swapX2Y(DesireY) call /// @param x Amount of tokenX trader will pay /// @param y Amount of tokenY trader will require /// @param data Any dadta passed though by the msg.sender via the BitSwapPool#swapX2Y(DesireY) call function swapX2YCallback( uint256 x, uint256 y, bytes calldata data ) external; } interface IBitSwapAddLimOrderCallback { /// @notice Called to msg.sender in BitSwapPool#addLimOrderWithX(Y) call /// @param x Amount of tokenX seller will pay /// @param y Amount of tokenY seller will pay /// @param data Any dadta passed though by the msg.sender via the BitSwapPool#addLimOrderWithX(Y) call function payCallback( uint256 x, uint256 y, bytes calldata data ) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.4; interface IBitSwapFactory { /// @notice emit when successfuly create a new pool (calling BitSwapFactory#newPool) /// @param tokenX address of erc-20 tokenX /// @param tokenY address of erc-20 tokenY /// @param fee fee amount of swap (3000 means 0.3%) /// @param pointDelta minimum number of distance between initialized or limitorder points /// @param pool address of swap pool event NewPool( address indexed tokenX, address indexed tokenY, uint24 indexed fee, uint24 pointDelta, address pool ); /// @notice module to support swap from tokenX to tokenY /// @return swapX2YModule address function swapX2YModule() external returns (address); /// @notice module to support swap from tokenY to tokenX /// @return swapY2XModule address function swapY2XModule() external returns (address); /// @notice module to support mint/burn/collect function of pool /// @return liquidityModule address function liquidityModule() external returns (address); /// @notice address of module for user to manage limit orders /// @return limitOrderModule address function limitOrderModule() external returns (address); /// @notice address of module for flash loan /// @return flashModule address function flashModule() external returns (address); /// @notice default fee rate from miner's fee gain /// @return defaultFeeChargePercent default fee rate * 100 function defaultFeeChargePercent() external returns (uint24); /// @notice Enables a fee amount with the given pointDelta /// @dev Fee amounts may never be removed once enabled /// @param fee fee amount (3000 means 0.3%) /// @param pointDelta The spacing between points to be enforced for all pools created with the given fee amount function enableFeeAmount(uint24 fee, uint24 pointDelta) external; /// @notice Create a new pool which not exists. /// @param tokenX address of tokenX /// @param tokenY address of tokenY /// @param fee fee amount /// @param currentPoint initial point (log 1.0001 of price) /// @return address of newly created pool function newPool( address tokenX, address tokenY, uint24 fee, int24 currentPoint ) external returns (address); /// @notice Charge receiver of all pools. /// @return address of charge receiver function chargeReceiver() external view returns(address); /// @notice Get pool of (tokenX, tokenY, fee), address(0) for not exists. /// @param tokenX address of tokenX /// @param tokenY address of tokenY /// @param fee fee amount /// @return address of pool function pool( address tokenX, address tokenY, uint24 fee ) external view returns(address); /// @notice Get point delta of a given fee amount. /// @param fee fee amount /// @return pointDelta the point delta function fee2pointDelta(uint24 fee) external view returns (int24 pointDelta); /// @notice Change charge receiver, only owner of factory can call. /// @param _chargeReceiver address of new receiver function modifyChargeReceiver(address _chargeReceiver) external; /// @notice Change defaultFeeChargePercent /// @param _defaultFeeChargePercent new charge percent function modifyDefaultFeeChargePercent(uint24 _defaultFeeChargePercent) external; function deployPoolParams() external view returns( address tokenX, address tokenY, uint24 fee, int24 currentPoint, int24 pointDelta, uint24 feeChargePercent ); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.4; interface IBitSwapPool { /// @notice Emitted when miner successfully add liquidity (mint). /// @param sender the address that minted the liquidity /// @param owner the owner who will benefit from this liquidity /// @param leftPoint left endpoint of the liquidity /// @param rightPoint right endpoint of the liquidity /// @param liquidity the amount of liquidity minted to the range [leftPoint, rightPoint) /// @param amountX amount of tokenX deposit /// @param amountY amount of tokenY deposit event Mint( address sender, address indexed owner, int24 indexed leftPoint, int24 indexed rightPoint, uint128 liquidity, uint256 amountX, uint256 amountY ); /// @notice Emitted when miner successfully decrease liquidity (withdraw). /// @param owner owner address of liquidity /// @param leftPoint left endpoint of liquidity /// @param rightPoint right endpoint of liquidity /// @param liquidity amount of liquidity decreased /// @param amountX amount of tokenX withdrawed /// @param amountY amount of tokenY withdrawed event Burn( address indexed owner, int24 indexed leftPoint, int24 indexed rightPoint, uint128 liquidity, uint256 amountX, uint256 amountY ); /// @notice Emitted when fees and withdrawed liquidity are collected /// @param owner The owner of the Liquidity /// @param recipient recipient of those token /// @param leftPoint The left point of the liquidity /// @param rightPoint The right point of the liquidity /// @param amountX The amount of tokenX (fees and withdrawed tokenX from liquidity) /// @param amountY The amount of tokenY (fees and withdrawed tokenY from liquidity) event CollectLiquidity( address indexed owner, address recipient, int24 indexed leftPoint, int24 indexed rightPoint, uint256 amountX, uint256 amountY ); /// @notice Emitted when a trader successfully exchange. /// @param tokenX tokenX of pool /// @param tokenY tokenY of pool /// @param fee fee amount of pool /// @param sellXEarnY true for selling tokenX, false for buying tokenX /// @param amountX amount of tokenX in this exchange /// @param amountY amount of tokenY in this exchange event Swap( address indexed tokenX, address indexed tokenY, uint24 indexed fee, bool sellXEarnY, uint256 amountX, uint256 amountY ); /// @notice Emitted by the pool for any flashes of tokenX/tokenY. /// @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 amountX the amount of tokenX that was flashed /// @param amountY the amount of tokenY that was flashed /// @param paidX the amount of tokenX paid for the flash, which can exceed the amountX plus the fee /// @param paidY the amount of tokenY paid for the flash, which can exceed the amountY plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amountX, uint256 amountY, uint256 paidX, uint256 paidY ); /// @notice Emitted when a seller successfully add a limit order. /// @param owner owner of limit order /// @param addAmount amount of token to sell the seller added /// @param acquireAmount amount of earn-token acquired, if there exists some opposite order before /// @param point point of limit order /// @param claimSold claimed sold sell-token, if this owner has order with same direction on this point before /// @param claimEarn claimed earned earn-token, if this owner has order with same direction on this point before /// @param sellXEarnY direction of limit order, etc. sell tokenX or sell tokenY event AddLimitOrder( address indexed owner, uint128 addAmount, uint128 acquireAmount, int24 indexed point, uint128 claimSold, uint128 claimEarn, bool sellXEarnY ); /// @notice Emitted when a seller successfully decrease a limit order. /// @param owner owner of limit order /// @param decreaseAmount amount of token to sell the seller decreased /// @param point point of limit order /// @param claimSold claimed sold sell-token /// @param claimEarn claimed earned earn-token /// @param sellXEarnY direction of limit order, etc. sell tokenX or sell tokenY event DecLimitOrder( address indexed owner, uint128 decreaseAmount, int24 indexed point, uint128 claimSold, uint128 claimEarn, bool sellXEarnY ); /// @notice Emitted when collect from a limit order /// @param owner The owner of the Liquidity /// @param recipient recipient of those token /// @param point The point of the limit order /// @param collectDec The amount of decreased sell token collected /// @param collectEarn The amount of earn token collected /// @param sellXEarnY direction of limit order, etc. sell tokenX or sell tokenY event CollectLimitOrder( address indexed owner, address recipient, int24 indexed point, uint128 collectDec, uint128 collectEarn, bool sellXEarnY ); /// @notice Returns the information about a liquidity by the liquidity's key. /// @param key the liquidity's key is a hash of a preimage composed by the miner(owner), pointLeft and pointRight /// @return liquidity the amount of liquidity, /// @return lastFeeScaleX_128 fee growth of tokenX inside the range as of the last mint/burn/collect, /// @return lastFeeScaleY_128 fee growth of tokenY inside the range as of the last mint/burn/collect, /// @return tokenOwedX the computed amount of tokenX miner can collect as of the last mint/burn/collect, /// @return tokenOwedY the computed amount of tokenY miner can collect as of the last mint/burn/collect function liquidity(bytes32 key) external view returns ( uint128 liquidity, uint256 lastFeeScaleX_128, uint256 lastFeeScaleY_128, uint256 tokenOwedX, uint256 tokenOwedY ); /// @notice Returns the information about a user's limit order (sell tokenY and earn tokenX). /// @param key the limit order's key is a hash of a preimage composed by the seller, point /// @return lastAccEarn total amount of tokenX earned by all users at this point as of the last add/dec/collect /// @return sellingRemain amount of tokenY not selled in this limit order /// @return sellingDec amount of tokenY decreased by seller from this limit order /// @return earn amount of unlegacy earned tokenX in this limit order not assigned /// @return legacyEarn amount of legacy earned tokenX in this limit order not assgined /// @return earnAssign assigned amount of tokenX earned (both legacy and unlegacy) in this limit order function userEarnX(bytes32 key) external view returns ( uint256 lastAccEarn, uint128 sellingRemain, uint128 sellingDec, uint128 earn, uint128 legacyEarn, uint128 earnAssign ); /// @notice Returns the information about a user's limit order (sell tokenX and earn tokenY). /// @param key the limit order's key is a hash of a preimage composed by the seller, point /// @return lastAccEarn total amount of tokenY earned by all users at this point as of the last add/dec/collect /// @return sellingRemain amount of tokenX not selled in this limit order /// @return sellingDec amount of tokenX decreased by seller from this limit order /// @return earn amount of unlegacy earned tokenY in this limit order not assigned /// @return legacyEarn amount of legacy earned tokenY in this limit order not assgined /// @return earnAssign assigned amount of tokenY earned (both legacy and unlegacy) in this limit order function userEarnY(bytes32 key) external view returns ( uint256 lastAccEarn, uint128 sellingRemain, uint128 sellingDec, uint128 earn, uint128 legacyEarn, uint128 earnAssign ); /// @notice Mark a given amount of tokenY in a limitorder(sellx and earn y) as assigned. /// @param point point (log Price) of seller's limit order,be sure to be times of pointDelta /// @param assignY max amount of tokenY to mark assigned /// @param fromLegacy true for assigning earned token from legacyEarnY /// @return actualAssignY actual amount of tokenY marked function assignLimOrderEarnY( int24 point, uint128 assignY, bool fromLegacy ) external returns(uint128 actualAssignY); /// @notice Mark a given amount of tokenX in a limitorder(selly and earn x) as assigned. /// @param point point (log Price) of seller's limit order,be sure to be times of pointDelta /// @param assignX max amount of tokenX to mark assigned /// @param fromLegacy true for assigning earned token from legacyEarnX /// @return actualAssignX actual amount of tokenX marked function assignLimOrderEarnX( int24 point, uint128 assignX, bool fromLegacy ) external returns(uint128 actualAssignX); /// @notice Decrease limitorder of selling X. /// @param point point of seller's limit order, be sure to be times of pointDelta /// @param deltaX max amount of tokenX seller wants to decrease /// @return actualDeltaX actual amount of tokenX decreased /// @return legacyAccEarn legacyAccEarnY of pointOrder at point when calling this interface function decLimOrderWithX( int24 point, uint128 deltaX ) external returns (uint128 actualDeltaX, uint256 legacyAccEarn); /// @notice Decrease limitorder of selling Y. /// @param point point of seller's limit order, be sure to be times of pointDelta /// @param deltaY max amount of tokenY seller wants to decrease /// @return actualDeltaY actual amount of tokenY decreased /// @return legacyAccEarn legacyAccEarnX of pointOrder at point when calling this interface function decLimOrderWithY( int24 point, uint128 deltaY ) external returns (uint128 actualDeltaY, uint256 legacyAccEarn); /// @notice Add a limit order (selling x) in the pool. /// @param recipient owner of the limit order /// @param point point of the order, be sure to be times of pointDelta /// @param amountX amount of tokenX to sell /// @param data any data that should be passed through to the callback /// @return orderX actual added amount of tokenX /// @return acquireY amount of tokenY acquired if there is a limit order to sell y before adding function addLimOrderWithX( address recipient, int24 point, uint128 amountX, bytes calldata data ) external returns (uint128 orderX, uint128 acquireY); /// @notice Add a limit order (selling y) in the pool. /// @param recipient owner of the limit order /// @param point point of the order, be sure to be times of pointDelta /// @param amountY amount of tokenY to sell /// @param data any data that should be passed through to the callback /// @return orderY actual added amount of tokenY /// @return acquireX amount of tokenX acquired if there exists a limit order to sell x before adding function addLimOrderWithY( address recipient, int24 point, uint128 amountY, bytes calldata data ) external returns (uint128 orderY, uint128 acquireX); /// @notice Collect earned or decreased token from limit order. /// @param recipient address to benefit /// @param point point of limit order, be sure to be times of pointDelta /// @param collectDec max amount of decreased selling token to collect /// @param collectEarn max amount of earned token to collect /// @param isEarnY direction of this limit order, true for sell y, false for sell x /// @return actualCollectDec actual amount of decresed selling token collected /// @return actualCollectEarn actual amount of earned token collected function collectLimOrder( address recipient, int24 point, uint128 collectDec, uint128 collectEarn, bool isEarnY ) external returns(uint128 actualCollectDec, uint128 actualCollectEarn); /// @notice Add liquidity to the pool. /// @param recipient newly created liquidity will belong to this address /// @param leftPt left endpoint of the liquidity, be sure to be times of pointDelta /// @param rightPt right endpoint of the liquidity, be sure to be times of pointDelta /// @param liquidDelta amount of liquidity to add /// @param data any data that should be passed through to the callback /// @return amountX The amount of tokenX that was paid for the liquidity. Matches the value in the callback /// @return amountY The amount of tokenY that was paid for the liquidity. Matches the value in the callback function mint( address recipient, int24 leftPt, int24 rightPt, uint128 liquidDelta, bytes calldata data ) external returns (uint256 amountX, uint256 amountY); /// @notice Decrease a given amount of liquidity from msg.sender's liquidities. /// @param leftPt left endpoint of the liquidity /// @param rightPt right endpoint of the liquidity /// @param liquidDelta amount of liquidity to burn /// @return amountX The amount of tokenX should be refund after burn /// @return amountY The amount of tokenY should be refund after burn function burn( int24 leftPt, int24 rightPt, uint128 liquidDelta ) external returns (uint256 amountX, uint256 amountY); /// @notice Collect tokens (fee or refunded after burn) from a liquidity. /// @param recipient the address which should receive the collected tokens /// @param leftPt left endpoint of the liquidity /// @param rightPt right endpoint of the liquidity /// @param amountXLim max amount of tokenX the owner wants to collect /// @param amountYLim max amount of tokenY the owner wants to collect /// @return actualAmountX the amount tokenX collected /// @return actualAmountY the amount tokenY collected function collect( address recipient, int24 leftPt, int24 rightPt, uint256 amountXLim, uint256 amountYLim ) external returns (uint256 actualAmountX, uint256 actualAmountY); /// @notice Swap tokenY for tokenX, given max amount of tokenY user willing to pay. /// @param recipient the address to receive tokenX /// @param amount the max amount of tokenY user willing to pay /// @param highPt the highest point(price) of x/y during swap /// @param data any data to be passed through to the callback /// @return amountX amount of tokenX payed /// @return amountY amount of tokenY acquired function swapY2X( address recipient, uint128 amount, int24 highPt, bytes calldata data ) external returns (uint256 amountX, uint256 amountY); /// @notice Swap tokenY for tokenX, given amount of tokenX user desires. /// @param recipient the address to receive tokenX /// @param desireX the amount of tokenX user desires /// @param highPt the highest point(price) of x/y during swap /// @param data any data to be passed through to the callback /// @return amountX amount of tokenX payed /// @return amountY amount of tokenY acquired function swapY2XDesireX( address recipient, uint128 desireX, int24 highPt, bytes calldata data ) external returns (uint256 amountX, uint256 amountY); /// @notice Swap tokenX for tokenY, given max amount of tokenX user willing to pay. /// @param recipient the address to receive tokenY /// @param amount the max amount of tokenX user willing to pay /// @param lowPt the lowest point(price) of x/y during swap /// @param data any data to be passed through to the callback /// @return amountX amount of tokenX acquired /// @return amountY amount of tokenY payed function swapX2Y( address recipient, uint128 amount, int24 lowPt, bytes calldata data ) external returns (uint256 amountX, uint256 amountY); /// @notice Swap tokenX for tokenY, given amount of tokenY user desires. /// @param recipient the address to receive tokenY /// @param desireY the amount of tokenY user desires /// @param lowPt the lowest point(price) of x/y during swap /// @param data any data to be passed through to the callback /// @return amountX amount of tokenX acquired /// @return amountY amount of tokenY payed function swapX2YDesireY( address recipient, uint128 desireY, int24 lowPt, bytes calldata data ) external returns (uint256 amountX, uint256 amountY); /// @notice Returns sqrt(1.0001), in 96 bit fixpoint number. function sqrtRate_96() external view returns(uint160); /// @notice State values of pool. /// @return sqrtPrice_96 a 96 fixpoing number describe the sqrt value of current price(tokenX/tokenY) /// @return currentPoint the current point of the pool, 1.0001 ^ currentPoint = price /// @return observationCurrentIndex the index of the last oracle observation that was written, /// @return observationQueueLen the current maximum number of observations stored in the pool, /// @return observationNextQueueLen the next maximum number of observations, to be updated when the observation. /// @return locked whether the pool is locked (only used for checking reentrance) /// @return liquidity liquidity on the currentPoint (currX * sqrtPrice + currY / sqrtPrice) /// @return liquidityX liquidity of tokenX function state() external view returns( uint160 sqrtPrice_96, int24 currentPoint, uint16 observationCurrentIndex, uint16 observationQueueLen, uint16 observationNextQueueLen, bool locked, uint128 liquidity, uint128 liquidityX ); /// @notice LimitOrder info on a given point. /// @param point the given point /// @return sellingX total amount of tokenX selling on the point /// @return earnY total amount of unclaimed earned tokenY for unlegacy sellingX /// @return accEarnY total amount of earned tokenY(via selling tokenX) by all users at this point as of the last swap /// @return legacyAccEarnY latest recorded 'accEarnY' value when sellingX is clear (legacy) /// @return legacyEarnY total amount of unclaimed earned tokenY for legacy (cleared during swap) sellingX /// @return sellingY total amount of tokenYselling on the point /// @return earnX total amount of unclaimed earned tokenX for unlegacy sellingY /// @return legacyEarnX total amount of unclaimed earned tokenX for legacy (cleared during swap) sellingY /// @return accEarnX total amount of earned tokenX(via selling tokenY) by all users at this point as of the last swap /// @return legacyAccEarnX latest recorded 'accEarnX' value when sellingY is clear (legacy) function limitOrderData(int24 point) external view returns( uint128 sellingX, uint128 earnY, uint256 accEarnY, uint256 legacyAccEarnY, uint128 legacyEarnY, uint128 sellingY, uint128 earnX, uint128 legacyEarnX, uint256 accEarnX, uint256 legacyAccEarnX ); /// @notice Query infomation about a point whether has limit order or is an liquidity's endpoint. /// @param point point to query /// @return val endpoint for val&1>0 and has limit order for val&2 > 0 function orderOrEndpoint(int24 point) external returns(int24 val); /// @notice Returns observation data about a specific index. /// @param index the index of observation array /// @return timestamp the timestamp of the observation, /// @return accPoint the point multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// @return init whether the observation has been initialized and the above values are safe to use function observations(uint256 index) external view returns ( uint32 timestamp, int56 accPoint, bool init ); /// @notice Point status in the pool. /// @param point the point /// @return liquidSum the total amount of liquidity that uses the point either as left endpoint or right endpoint /// @return liquidDelta how much liquidity changes when the pool price crosses the point from left to right /// @return accFeeXOut_128 the fee growth on the other side of the point from the current point in tokenX /// @return accFeeYOut_128 the fee growth on the other side of the point from the current point in tokenY /// @return isEndpt whether the point is an endpoint of a some miner's liquidity, true if liquidSum > 0 function points(int24 point) external view returns ( uint128 liquidSum, int128 liquidDelta, uint256 accFeeXOut_128, uint256 accFeeYOut_128, bool isEndpt ); /// @notice Returns 256 packed point (statusVal>0) boolean values. See PointBitmap for more information. function pointBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the integral value of point(time) and integral value of 1/liquidity(time) /// at some target timestamps (block.timestamp - secondsAgo[i]) /// @dev Reverts if target timestamp is early than oldest observation in the queue /// @dev If you call this method with secondsAgos = [3600, 0]. the average point of this pool during recent hour is /// (accPoints[1] - accPoints[0]) / 3600 /// @param secondsAgos describe the target timestamp , targetTimestimp[i] = block.timestamp - secondsAgo[i] /// @return accPoints integral value of point(time) from 0 to each target timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory accPoints); /// @notice Expand max-length of observation queue. /// @param newNextQueueLen new value of observationNextQueueLen, which should be greater than current observationNextQueueLen function expandObservationQueue(uint16 newNextQueueLen) external; /// @notice Borrow tokenX and/or tokenY and pay it back within a block. /// @dev The caller needs to implement a IBitSwapPool#flashCallback callback function /// @param recipient the address which will receive the tokenY and/or tokenX /// @param amountX the amount of tokenX to borrow /// @param amountY the amount of tokenY to borrow /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amountX, uint256 amountY, bytes calldata data ) external; /// @notice Returns a snapshot infomation of Liquidity in [leftPoint, rightPoint). /// @param leftPoint left endpoint of range, should be times of pointDelta /// @param rightPoint right endpoint of range, should be times of pointDelta /// @return deltaLiquidities an array of delta liquidity for points in the range /// note 1. delta liquidity here is amount of liquidity changed when cross a point from left to right /// note 2. deltaLiquidities only contains points which are times of pointDelta /// note 3. this function may cost a ENORMOUS amount of gas, be careful to call function liquiditySnapshot(int24 leftPoint, int24 rightPoint) external view returns(int128[] memory deltaLiquidities); struct LimitOrderStruct { uint128 sellingX; uint128 earnY; uint256 accEarnY; uint128 sellingY; uint128 earnX; uint256 accEarnX; } /// @notice Returns a snapshot infomation of Limit Order in [leftPoint, rightPoint). /// @param leftPoint left endpoint of range, should be times of pointDelta /// @param rightPoint right endpoint of range, should be times of pointDelta /// @return limitOrders an array of Limit Orders for points in the range /// note 1. this function may cost a HUGE amount of gas, be careful to call function limitOrderSnapshot(int24 leftPoint, int24 rightPoint) external view returns(LimitOrderStruct[] memory limitOrders); /// @notice Amount of charged fee on tokenX. function totalFeeXCharged() external view returns(uint256); /// @notice Amount of charged fee on tokenY. function totalFeeYCharged() external view returns(uint256); /// @notice Percent to charge from miner's fee. function feeChargePercent() external view returns(uint24); /// @notice Collect charged fee, only factory's chargeReceiver can call. function collectFeeCharged() external; /// @notice modify 'feeChargePercent', only owner has authority. /// @param newFeeChargePercent new value of feeChargePercent, a nature number range in [0, 100], function modifyFeeChargePercent(uint24 newFeeChargePercent) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.4; import "./MulDivMath.sol"; import "./TwoPower.sol"; import "./LogPowMath.sol"; library AmountMath { function getAmountYUnitLiquidity_96( uint160 sqrtPriceL_96, uint160 sqrtPriceR_96, uint160 sqrtRate_96 ) internal pure returns (uint256 amount_96) { uint160 numerator = sqrtPriceR_96 - sqrtPriceL_96; uint160 denominator = sqrtRate_96 - uint160(TwoPower.pow96); amount_96 = MulDivMath.mulDivCeil(TwoPower.pow96, numerator, denominator); } function getAmountXUnitLiquidity_96( int24 leftPt, int24 rightPt, uint160 sqrtPriceR_96, uint160 sqrtRate_96 ) internal pure returns (uint256 amount_96) { // rightPt - (leftPt - 1), pc = leftPt - 1 uint160 sqrtPricePrPc_96 = LogPowMath.getSqrtPrice(rightPt - leftPt + 1); uint160 sqrtPricePrPd_96 = LogPowMath.getSqrtPrice(rightPt + 1); uint160 numerator = sqrtPricePrPc_96 - sqrtRate_96; uint160 denominator = sqrtPricePrPd_96 - sqrtPriceR_96; amount_96 = MulDivMath.mulDivCeil(TwoPower.pow96, numerator, denominator); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; library LogPowMath { int24 internal constant MIN_POINT = -887272; int24 internal constant MAX_POINT = -MIN_POINT; uint160 internal constant MIN_SQRT_PRICE = 4295128739; uint160 internal constant MAX_SQRT_PRICE = 1461446703485210103287273052203988822378723970342; /// @notice sqrt(1.0001^point) in form oy 96-bit fix point num function getSqrtPrice(int24 point) internal pure returns (uint160 sqrtPrice_96) { uint256 absIdx = point < 0 ? uint256(-int256(point)) : uint256(int256(point)); require(absIdx <= uint256(int256(MAX_POINT)), 'T'); uint256 value = absIdx & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absIdx & 0x2 != 0) value = (value * 0xfff97272373d413259a46990580e213a) >> 128; if (absIdx & 0x4 != 0) value = (value * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absIdx & 0x8 != 0) value = (value * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absIdx & 0x10 != 0) value = (value * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absIdx & 0x20 != 0) value = (value * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absIdx & 0x40 != 0) value = (value * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absIdx & 0x80 != 0) value = (value * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absIdx & 0x100 != 0) value = (value * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absIdx & 0x200 != 0) value = (value * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absIdx & 0x400 != 0) value = (value * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absIdx & 0x800 != 0) value = (value * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absIdx & 0x1000 != 0) value = (value * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absIdx & 0x2000 != 0) value = (value * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absIdx & 0x4000 != 0) value = (value * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absIdx & 0x8000 != 0) value = (value * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absIdx & 0x10000 != 0) value = (value * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absIdx & 0x20000 != 0) value = (value * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absIdx & 0x40000 != 0) value = (value * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absIdx & 0x80000 != 0) value = (value * 0x48a170391f7dc42444e8fa2) >> 128; if (point > 0) value = type(uint256).max / value; sqrtPrice_96 = uint160((value >> 32) + (value % (1 << 32) == 0 ? 0 : 1)); } // floor(log1.0001(sqrtPrice_96)) function getLogSqrtPriceFloor(uint160 sqrtPrice_96) internal pure returns (int24 logValue) { // second inequality must be < because the price can nevex reach the price at the max tick require(sqrtPrice_96 >= MIN_SQRT_PRICE && sqrtPrice_96 < MAX_SQRT_PRICE, 'R'); uint256 sqrtPrice_128 = uint256(sqrtPrice_96) << 32; uint256 x = sqrtPrice_128; uint256 m = 0; assembly { let y := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(5, gt(x, 0xFFFFFFFF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(4, gt(x, 0xFFFF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(3, gt(x, 0xFF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(2, gt(x, 0xF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(1, gt(x, 0x3)) m := or(m, y) x := shr(y, x) } assembly { let y := gt(x, 0x1) m := or(m, y) } if (m >= 128) x = sqrtPrice_128 >> (m - 127); else x = sqrtPrice_128 << (127 - m); int256 l2 = (int256(m) - 128) << 64; assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(63, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(62, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(61, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(60, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(59, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(58, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(57, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(56, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(55, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(54, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(53, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(52, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(51, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(50, y)) } int256 ls10001 = l2 * 255738958999603826347141; int24 logFloor = int24((ls10001 - 3402992956809132418596140100660247210) >> 128); int24 logUpper = int24((ls10001 + 291339464771989622907027621153398088495) >> 128); logValue = logFloor == logUpper ? logFloor : getSqrtPrice(logUpper) <= sqrtPrice_96 ? logUpper : logFloor; } function getLogSqrtPriceFU(uint160 sqrtPrice_96) internal pure returns (int24 logFloor, int24 logUpper) { // second inequality must be < because the price can nevex reach the price at the max tick require(sqrtPrice_96 >= MIN_SQRT_PRICE && sqrtPrice_96 < MAX_SQRT_PRICE, 'R'); uint256 sqrtPrice_128 = uint256(sqrtPrice_96) << 32; uint256 x = sqrtPrice_128; uint256 m = 0; assembly { let y := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(5, gt(x, 0xFFFFFFFF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(4, gt(x, 0xFFFF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(3, gt(x, 0xFF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(2, gt(x, 0xF)) m := or(m, y) x := shr(y, x) } assembly { let y := shl(1, gt(x, 0x3)) m := or(m, y) x := shr(y, x) } assembly { let y := gt(x, 0x1) m := or(m, y) } if (m >= 128) x = sqrtPrice_128 >> (m - 127); else x = sqrtPrice_128 << (127 - m); int256 l2 = (int256(m) - 128) << 64; assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(63, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(62, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(61, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(60, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(59, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(58, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(57, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(56, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(55, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(54, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(53, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(52, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(51, y)) x := shr(y, x) } assembly { x := shr(127, mul(x, x)) let y := shr(128, x) l2 := or(l2, shl(50, y)) } int256 ls10001 = l2 * 255738958999603826347141; logFloor = int24((ls10001 - 3402992956809132418596140100660247210) >> 128); logUpper = int24((ls10001 + 291339464771989622907027621153398088495) >> 128); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.4; import "./TwoPower.sol"; import "./AmountMath.sol"; library MintMath { struct MintMathParam { int24 pl; int24 pr; uint128 xLim; uint128 yLim; } /// @dev [pl, pr) function _computeDepositXYPerUnit( int24 pl, int24 pr, int24 pc, uint160 sqrtPrice_96, uint160 sqrtRate_96 ) private pure returns (uint256 x, uint256 y) { x = 0; y = 0; uint160 sqrtPriceR_96 = LogPowMath.getSqrtPrice(pr); if (pl < pc) { uint160 sqrtPriceL_96 = LogPowMath.getSqrtPrice(pl); if (pr < pc) { y += AmountMath.getAmountYUnitLiquidity_96(sqrtPriceL_96, sqrtPriceR_96, sqrtRate_96); } else { y += AmountMath.getAmountYUnitLiquidity_96(sqrtPriceL_96, sqrtPrice_96, sqrtRate_96); } } if (pr > pc) { // we need compute XR int24 xrLeft = (pl > pc) ? pl : pc + 1; x = AmountMath.getAmountXUnitLiquidity_96( xrLeft, pr, sqrtPriceR_96, sqrtRate_96 ); } if (pl <= pc && pr > pc) { // we nned compute yc at point of current price y += sqrtPrice_96; } } function computeLiquidity( MintMathParam memory mp, int24 currPt, uint160 sqrtPrice_96, uint160 sqrtRate_96 ) internal pure returns(uint128 liquidity) { liquidity = type(uint128).max / 2; (uint256 x, uint256 y) = _computeDepositXYPerUnit(mp.pl, mp.pr, currPt, sqrtPrice_96, sqrtRate_96); if (x > 0) { uint256 xl = uint256(mp.xLim) * TwoPower.pow96 / x; if (liquidity > xl) { liquidity = uint128(xl); } } if (y > 0) { // we take yLim - 1, because in the core, the amountY to deposit is // calculated by range [left, pc) and point at pc respectively uint256 yl = uint256(mp.yLim - 1) * TwoPower.pow96 / y; if (liquidity > yl) { liquidity = uint128(yl); } } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.4; library MulDivMath { // compute res = floor(a * b / c), assuming res < 2^256 function mulDivFloor( uint256 a, uint256 b, uint256 c ) internal pure returns (uint256 res) { // let prodMod2_256 = a * b % 2^256 uint256 prodMod2_256; // let prodDiv2_256 = a * b / 2^256 uint256 prodDiv2_256; assembly { let prodModM1 := mulmod(a, b, not(0)) prodMod2_256 := mul(a, b) prodDiv2_256 := sub(sub(prodModM1, prodMod2_256), lt(prodModM1, prodMod2_256)) } if (prodDiv2_256 == 0) { require(c > 0); assembly { res := div(prodMod2_256, c) } return res; } // we should ensure that a * b /c < 2^256 before calling require(c > prodDiv2_256); uint256 resMod; assembly { resMod := mulmod(a, b, c) // a * b - resMod prodDiv2_256 := sub(prodDiv2_256, gt(resMod, prodMod2_256)) prodMod2_256 := sub(prodMod2_256, resMod) // compute lowbit of c let lowbit := not(c) lowbit := add(lowbit, 1) lowbit := and(lowbit, c) // c / lowbit c := div(c, lowbit) // a * b / lowbit prodMod2_256 := div(prodMod2_256, lowbit) lowbit := add(div(sub(0, lowbit), lowbit), 1) prodDiv2_256 := mul(prodDiv2_256, lowbit) prodMod2_256 := or(prodMod2_256, prodDiv2_256) // get inv of c // cInv * c = 1 (mod 2^4) let cInv := xor(mul(3, c), 2) cInv := mul(cInv, sub(2, mul(c, cInv))) // shift to 2^8 cInv := mul(cInv, sub(2, mul(c, cInv))) // shift to 2^16 cInv := mul(cInv, sub(2, mul(c, cInv))) // shift to 2^32 cInv := mul(cInv, sub(2, mul(c, cInv))) // shift to 2^64 cInv := mul(cInv, sub(2, mul(c, cInv))) // shift to 2^128 cInv := mul(cInv, sub(2, mul(c, cInv))) // shift to 2^256 // a * b / c = prodMod2_256 * cInv (mod 2^256) res := mul(prodMod2_256, cInv) } } // compute res = ceil(a * b / c), assuming res < 2^256 function mulDivCeil( uint256 a, uint256 b, uint256 c ) internal pure returns (uint256 res) { res = mulDivFloor(a, b, c); if (mulmod(a, b, c) > 0) { require(res < type(uint256).max); res++; } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.4; /// @title FixedPoint128 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) library TwoPower { uint256 internal constant pow96 = 0x1000000000000000000000000; uint256 internal constant pow128 = 0x100000000000000000000000000000000; uint8 internal constant RESOLUTION = 96; }
{ "optimizer": { "enabled": true, "runs": 100 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"factory","type":"address"},{"internalType":"address","name":"weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nftId","type":"uint256"},{"indexed":false,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"uint128","name":"liquidityDelta","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amountX","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountY","type":"uint256"}],"name":"AddLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nftId","type":"uint256"},{"indexed":false,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"uint128","name":"liquidityDelta","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amountX","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountY","type":"uint256"}],"name":"DecLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"lid","type":"uint256"},{"internalType":"uint128","name":"xLim","type":"uint128"},{"internalType":"uint128","name":"yLim","type":"uint128"},{"internalType":"uint128","name":"amountXMin","type":"uint128"},{"internalType":"uint128","name":"amountYMin","type":"uint128"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct LiquidityManager.AddLiquidityParam","name":"addLiquidityParam","type":"tuple"}],"name":"addLiquidity","outputs":[{"internalType":"uint128","name":"liquidityDelta","type":"uint128"},{"internalType":"uint256","name":"amountX","type":"uint256"},{"internalType":"uint256","name":"amountY","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"lid","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"lid","type":"uint256"},{"internalType":"uint128","name":"amountXLim","type":"uint128"},{"internalType":"uint128","name":"amountYLim","type":"uint128"}],"name":"collect","outputs":[{"internalType":"uint256","name":"amountX","type":"uint256"},{"internalType":"uint256","name":"amountY","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenX","type":"address"},{"internalType":"address","name":"tokenY","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"initialPoint","type":"int24"}],"name":"createPool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"lid","type":"uint256"},{"internalType":"uint128","name":"liquidDelta","type":"uint128"},{"internalType":"uint256","name":"amountXMin","type":"uint256"},{"internalType":"uint256","name":"amountYMin","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"decLiquidity","outputs":[{"internalType":"uint256","name":"amountX","type":"uint256"},{"internalType":"uint256","name":"amountY","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"liquidities","outputs":[{"internalType":"int24","name":"leftPt","type":"int24"},{"internalType":"int24","name":"rightPt","type":"int24"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"lastFeeScaleX_128","type":"uint256"},{"internalType":"uint256","name":"lastFeeScaleY_128","type":"uint256"},{"internalType":"uint256","name":"remainTokenX","type":"uint256"},{"internalType":"uint256","name":"remainTokenY","type":"uint256"},{"internalType":"uint128","name":"poolId","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidityNum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"miner","type":"address"},{"internalType":"address","name":"tokenX","type":"address"},{"internalType":"address","name":"tokenY","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"},{"internalType":"int24","name":"pl","type":"int24"},{"internalType":"int24","name":"pr","type":"int24"},{"internalType":"uint128","name":"xLim","type":"uint128"},{"internalType":"uint128","name":"yLim","type":"uint128"},{"internalType":"uint128","name":"amountXMin","type":"uint128"},{"internalType":"uint128","name":"amountYMin","type":"uint128"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct LiquidityManager.MintParam","name":"mintParam","type":"tuple"}],"name":"mint","outputs":[{"internalType":"uint256","name":"lid","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amountX","type":"uint256"},{"internalType":"uint256","name":"amountY","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mintDepositCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenX","type":"address"},{"internalType":"address","name":"tokenY","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"}],"name":"pool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"poolIds","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"","type":"uint128"}],"name":"poolMetas","outputs":[{"internalType":"address","name":"tokenX","type":"address"},{"internalType":"address","name":"tokenY","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refundETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newBaseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","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":"minAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"unwrapWETH9","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60c0604052600b80546001600160801b03191660011790556000600d553480156200002957600080fd5b506040516200584f3803806200584f8339810160408190526200004c916200023a565b6040518060400160405280601581526020017f42697453776170204c6971756964697479204e465400000000000000000000008152506040518060400160405280601581526020017f426974537761702d4c49515549444954592d4e465400000000000000000000008152508383620000d4620000ce6200012360201b60201c565b62000127565b6001600160601b0319606092831b8116608052911b1660a05281516200010290600190602085019062000177565b5080516200011890600290602084019062000177565b5050505050620002ae565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b828054620001859062000271565b90600052602060002090601f016020900481019282620001a95760008555620001f4565b82601f10620001c457805160ff1916838001178555620001f4565b82800160010185558215620001f4579182015b82811115620001f4578251825591602001919060010190620001d7565b506200020292915062000206565b5090565b5b8082111562000202576000815560010162000207565b80516001600160a01b03811681146200023557600080fd5b919050565b600080604083850312156200024d578182fd5b62000258836200021d565b915062000268602084016200021d565b90509250929050565b600181811c908216806200028657607f821691505b60208210811415620002a857634e487b7160e01b600052602260045260246000fd5b50919050565b60805160601c60a05160601c6155216200032e6000396000818161049601528181610f960152818161105901528181612b2f01528181612b750152612c0a01526000818161069501528181610b8d015281816117b501528181611c5d01528181611e44015281816123f7015281816124cc0152612cc801526155216000f3fe6080604052600436106102245760003560e01c8063715018a61161012e578063c45a0155116100ab578063df2ab5bb1161006f578063df2ab5bb14610773578063e985e9c514610786578063f2fde38b146107a6578063f425a3ce146107c6578063f655dbc1146107e657600080fd5b8063c45a015514610683578063c87b56dd146106b7578063cbd89416146106d7578063d4175be21461070f578063dca87bec1461075d57600080fd5b8063a0e4eb3c116100f2578063a0e4eb3c146105f0578063a22cb46514610603578063ac9650d814610623578063b88d4fde14610643578063becbcc6a1461066357600080fd5b8063715018a61461054d57806384fe2b3d146105625780638da5cb5b1461058257806395d89b41146105a057806396f639ed146105b557600080fd5b80632f745c59116101bc5780634f6ccce7116101805780634f6ccce7146104b857806355f804b3146104d85780636352211e146104f85780636c0360eb1461051857806370a082311461052d57600080fd5b80632f745c591461041157806342842e0e1461043157806342966c681461045157806349404b7c146104715780634aa4a4fc1461048457600080fd5b806301ffc9a71461023057806306fdde03146102655780630713051d14610287578063081812fc14610346578063095ea7b31461037357806312210e8a1461039557806315feae511461039d57806318160ddd146103d257806323b872dd146103f157600080fd5b3661022b57005b600080fd5b34801561023c57600080fd5b5061025061024b3660046147b2565b610844565b60405190151581526020015b60405180910390f35b34801561027157600080fd5b5061027a61086f565b60405161025c9190614e53565b34801561029357600080fd5b506102f56102a2366004614b49565b600c602052600090815260409020805460018201546002808401546003850154600486015460059096015485840b966301000000870490940b956001600160801b03600160301b90910481169594911688565b604080516002998a0b81529790980b60208801526001600160801b03958616978701979097526060860193909352608085019190915260a084015260c083015290911660e08201526101000161025c565b34801561035257600080fd5b50610366610361366004614b49565b610901565b60405161025c9190614cde565b34801561037f57600080fd5b5061039361038e366004614674565b610928565b005b610393610a43565b3480156103a957600080fd5b506103bd6103b8366004614b9d565b610a55565b6040805192835260208301919091520161025c565b3480156103de57600080fd5b506009545b60405190815260200161025c565b3480156103fd57600080fd5b5061039361040c366004614561565b610da4565b34801561041d57600080fd5b506103e361042c366004614674565b610dd5565b34801561043d57600080fd5b5061039361044c366004614561565b610e6b565b34801561045d57600080fd5b5061025061046c366004614b49565b610e86565b61039361047f366004614b79565b610f7c565b34801561049057600080fd5b506103667f000000000000000000000000000000000000000000000000000000000000000081565b3480156104c457600080fd5b506103e36104d3366004614b49565b6110c7565b3480156104e457600080fd5b506103936104f3366004614806565b611168565b34801561050457600080fd5b50610366610513366004614b49565b61117c565b34801561052457600080fd5b5061027a6111b1565b34801561053957600080fd5b506103e3610548366004614452565b61123f565b34801561055957600080fd5b506103936112c5565b34801561056e57600080fd5b5061039361057d366004614c07565b6112d7565b34801561058e57600080fd5b506000546001600160a01b0316610366565b3480156105ac57600080fd5b5061027a611339565b6105c86105c3366004614940565b611348565b604080519485526001600160801b03909316602085015291830152606082015260800161025c565b6103bd6105fe3660046146e0565b6116e3565b34801561060f57600080fd5b5061039361061e366004614647565b611a7b565b610636610631366004614727565b611a8a565b60405161025c9190614dcc565b34801561064f57600080fd5b5061039361065e3660046145a1565b611c0b565b34801561066f57600080fd5b5061036661067e3660046144c2565b611c43565b34801561068f57600080fd5b506103667f000000000000000000000000000000000000000000000000000000000000000081565b3480156106c357600080fd5b5061027a6106d2366004614b49565b611cf0565b6106ea6106e53660046148ae565b611d56565b604080516001600160801b03909416845260208401929092529082015260600161025c565b34801561071b57600080fd5b5061074561072a366004614452565b600f602052600090815260409020546001600160801b031681565b6040516001600160801b03909116815260200161025c565b34801561076957600080fd5b506103e3600d5481565b61039361078136600461469f565b612251565b34801561079257600080fd5b506102506107a136600461448a565b612303565b3480156107b257600080fd5b506103936107c1366004614452565b612331565b3480156107d257600080fd5b506103666107e1366004614508565b6123aa565b3480156107f257600080fd5b50610835610801366004614a26565b600e60205260009081526040902080546001909101546001600160a01b0391821691811690600160a01b900462ffffff1683565b60405161025c93929190614cf2565b60006001600160e01b0319821663780e9d6360e01b148061086957506108698261255c565b92915050565b60606001805461087e90615366565b80601f01602080910402602001604051908101604052809291908181526020018280546108aa90615366565b80156108f75780601f106108cc576101008083540402835291602001916108f7565b820191906000526020600020905b8154815290600101906020018083116108da57829003601f168201915b5050505050905090565b600061090c826125ac565b506000908152600560205260409020546001600160a01b031690565b60006109338261117c565b9050806001600160a01b0316836001600160a01b031614156109a65760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b03821614806109c257506109c28133612303565b610a345760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c000000606482015260840161099d565b610a3e83836125d1565b505050565b4715610a5357610a53334761263f565b565b60008086610a6333826126e2565b610a7f5760405162461bcd60e51b815260040161099d90614ff4565b8380421115610aa05760405162461bcd60e51b815260040161099d90615094565b600d548910610ac15760405162461bcd60e51b815260040161099d90614f22565b6000898152600c602052604090208054600160301b90046001600160801b0316610af2576000809450945050610d98565b80546001600160801b03600160301b9091048116908a161115610b24578054600160301b90046001600160801b031698505b60058101546001600160801b03166000908152600e60209081526040808320815160608101835281546001600160a01b03908116808352600190930154808216958301869052600160a01b900462ffffff168285018190529351635f65e63560e11b81529195947f00000000000000000000000000000000000000000000000000000000000000009091169363becbcc6a93610bc69390929190600401614cf2565b60206040518083038186803b158015610bde57600080fd5b505afa158015610bf2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c16919061446e565b90506001600160a01b038116610c3e5760405162461bcd60e51b815260040161099d90614fd8565b8254600090610c5e908d90600160301b90046001600160801b03166152db565b9050816001600160a01b031663a34123a78560000160009054906101000a900460020b8660000160039054906101000a900460020b8f6040518463ffffffff1660e01b8152600401610cb293929190614e2d565b6040805180830381600087803b158015610ccb57600080fd5b505af1158015610cdf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d039190614be4565b90985096508a881015610d285760405162461bcd60e51b815260040161099d90615044565b89871015610d485760405162461bcd60e51b815260040161099d90614fba565b610d558483838b8b612740565b8c7f24f4b91fa7871755148bc2a9e01f85d6fd73ec2a0e6bd9a5717c0d7f5be8c2c3838e8b8b604051610d8b9493929190614d9d565b60405180910390a2505050505b50509550959350505050565b610dae33826126e2565b610dca5760405162461bcd60e51b815260040161099d90614e83565b610a3e838383612843565b6000610de08361123f565b8210610e425760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161099d565b506001600160a01b03919091166000908152600760209081526040808320938352929052205490565b610a3e83838360405180602001604052806000815250611c0b565b600081610e9333826126e2565b610eaf5760405162461bcd60e51b815260040161099d90614ff4565b6000838152600c602052604090208054600160301b90046001600160801b0316158015610ede57506003810154155b8015610eec57506004810154155b610f1d5760405162461bcd60e51b81526020600482015260026024820152614e4360f01b604482015260640161099d565b6000848152600c6020526040812080546001600160b01b0319168155600181018290556002810182905560038101829055600481019190915560050180546001600160801b0319169055610f70846129a2565b60019250505b50919050565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190610fcb903090600401614cde565b60206040518083038186803b158015610fe357600080fd5b505afa158015610ff7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101b9190614b61565b90508281101561103d5760405162461bcd60e51b815260040161099d9061501a565b8015610a3e57604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156110a557600080fd5b505af11580156110b9573d6000803e3d6000fd5b50505050610a3e828261263f565b60006110d260095490565b82106111355760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161099d565b6009828154811061115657634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b611170612a33565b610a3e6010838361432f565b6000818152600360205260408120546001600160a01b0316806108695760405162461bcd60e51b815260040161099d90615062565b601080546111be90615366565b80601f01602080910402602001604051908101604052809291908181526020018280546111ea90615366565b80156112375780601f1061120c57610100808354040283529160200191611237565b820191906000526020600020905b81548152906001019060200180831161121a57829003601f168201915b505050505081565b60006001600160a01b0382166112a95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b606482015260840161099d565b506001600160a01b031660009081526004602052604090205490565b6112cd612a33565b610a536000612a8d565b60006112e5828401846148bf565b90506112fe816000015182602001518360400151612add565b841561131857611318816000015182606001513388612b2d565b831561133257611332816020015182606001513387612b2d565b5050505050565b60606002805461087e90615366565b600080600080846101400135804211156113745760405162461bcd60e51b815260040161099d90615094565b6113846060870160408801614452565b6001600160a01b031661139d6040880160208901614452565b6001600160a01b0316106113c35760405162461bcd60e51b815260040161099d90614e66565b60006113dc6113d736899003890189614952565b612cbd565b929750909550935090506113f861012088016101008901614a26565b6001600160801b03168410156114205760405162461bcd60e51b815260040161099d90615044565b61143261014088016101208901614a26565b6001600160801b031683101561145a5760405162461bcd60e51b815260040161099d90614fba565b600d805490600061146a836153c2565b9091555095506000806114a8836114a33061148b60a08e0160808f016147ea565b8d60a001602081019061149e91906147ea565b612f7e565b612fd4565b91509150600061151e8460405180606001604052808d60200160208101906114d09190614452565b6001600160a01b031681526020018d60400160208101906114f19190614452565b6001600160a01b031681526020018d60600160208101906115129190614b2f565b62ffffff16905261306a565b90506040518061010001604052808b608001602081019061153f91906147ea565b60020b815260200161155760c08d0160a08e016147ea565b60020b8152602001896001600160801b031681526020018481526020018381526020016000815260200160008152602001826001600160801b0316815250600c60008b815260200190815260200160002060008201518160000160006101000a81548162ffffff021916908360020b62ffffff16021790555060208201518160000160036101000a81548162ffffff021916908360020b62ffffff16021790555060408201518160000160066101000a8154816001600160801b0302191690836001600160801b03160217905550606082015181600101556080820151816002015560a0820151816003015560c0820151816004015560e08201518160050160006101000a8154816001600160801b0302191690836001600160801b031602179055509050506116998a60000160208101906116939190614452565b8a613157565b887ff565fdd70b3936f0ae8efc41c2e0822f9de5ecb4dc162b153b129ec4bb9cd93c858a8a8a6040516116cf9493929190614d9d565b60405180910390a250505050509193509193565b600080846116f133826126e2565b61170d5760405162461bcd60e51b815260040161099d90614ff4565b6001600160a01b03871661171f573096505b600d5486106117405760405162461bcd60e51b815260040161099d90614f22565b6000868152600c6020908152604080832060058101546001600160801b03168452600e8352818420825160608101845281546001600160a01b03908116808352600190930154808216968301879052600160a01b900462ffffff168286018190529451635f65e63560e11b81529396919591947f00000000000000000000000000000000000000000000000000000000000000009091169363becbcc6a936117ee9390929091600401614cf2565b60206040518083038186803b15801561180657600080fd5b505afa15801561181a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183e919061446e565b90506001600160a01b0381166118665760405162461bcd60e51b815260040161099d90614fd8565b8254600160301b90046001600160801b03161561193257825460405163a34123a760e01b81526001600160a01b0383169163a34123a7916118bd91600281810b926301000000909204900b90600090600401614e2d565b6040805180830381600087803b1580156118d657600080fd5b505af11580156118ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190e9190614be4565b505082546119329084908390600160301b90046001600160801b0316600080612740565b8260030154886001600160801b0316111561194f57826003015497505b8260040154876001600160801b0316111561196c57826004015496505b825460405163872d1f1560e01b81526001600160a01b038c81166004830152600283810b810b60248401526301000000909304830b90920b60448201526001600160801b03808b166064830152891660848201529082169063872d1f159060a4016040805180830381600087803b1580156119e657600080fd5b505af11580156119fa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1e9190614be4565b8096508197505050876001600160801b0316836003016000828254611a439190615323565b92505081905550866001600160801b0316836004016000828254611a679190615323565b925050819055505050505094509492505050565b611a86338383613260565b5050565b6060816001600160401b03811115611ab257634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611ae557816020015b6060815260200190600190039081611ad05790505b50905060005b82811015611c045760008030868685818110611b1757634e487b7160e01b600052603260045260246000fd5b9050602002810190611b2991906150f7565b604051611b37929190614c83565b600060405180830381855af49150503d8060008114611b72576040519150601f19603f3d011682016040523d82523d6000602084013e611b77565b606091505b509150915081611bc357604481511015611b9057600080fd5b60048101905080806020019051810190611baa9190614845565b60405162461bcd60e51b815260040161099d9190614e53565b80848481518110611be457634e487b7160e01b600052603260045260246000fd5b602002602001018190525050508080611bfc906153c2565b915050611aeb565b5092915050565b611c1533836126e2565b611c315760405162461bcd60e51b815260040161099d90614e83565b611c3d8484848461332b565b50505050565b604051635f65e63560e11b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063becbcc6a90611c9690879087908790600401614cf2565b60206040518083038186803b158015611cae57600080fd5b505afa158015611cc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce6919061446e565b90505b9392505050565b6060611cfb826125ac565b6000611d0561335e565b90506000815111611d255760405180602001604052806000815250611ce9565b80611d2f8461336d565b604051602001611d40929190614caf565b6040516020818303038152906040529392505050565b600080808335611d6633826126e2565b611d825760405162461bcd60e51b815260040161099d90614ff4565b8460a0013580421115611da75760405162461bcd60e51b815260040161099d90615094565b600d54863510611dc95760405162461bcd60e51b815260040161099d90614f22565b85356000908152600c6020908152604080832060058101546001600160801b03168452600e8352818420825160608101845281546001600160a01b03908116808352600190930154808216968301879052600160a01b900462ffffff168286018190529451635f65e63560e11b8152939691959194859485947f00000000000000000000000000000000000000000000000000000000000000009093169363becbcc6a93611e7b939092600401614cf2565b60206040518083038186803b158015611e9357600080fd5b505afa158015611ea7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecb919061446e565b90506001600160a01b038116611ef35760405162461bcd60e51b815260040161099d90614fd8565b611efc81613417565b8094508193505050611ffe60405180608001604052808760000160009054906101000a900460020b60020b81526020018760000160039054906101000a900460020b60020b81526020018d6020016020810190611f599190614a26565b6001600160801b031681526020018d6040016020810190611f7a9190614a26565b6001600160801b03168152508484846001600160a01b03166309beabc16040518163ffffffff1660e01b815260040160206040518083038186803b158015611fc157600080fd5b505afa158015611fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ff9919061446e565b6134a2565b8554909a50600160301b90046001600160801b0316600f81900b1461204a5760405162461bcd60e51b81526020600482015260026024820152614c4f60f01b604482015260640161099d565b845460009061206990600160301b90046001600160801b03168c615201565b9050816001600160a01b0316633c8a7d8d308860000160009054906101000a900460020b8960000160039054906101000a900460020b8f60405180608001604052808c600001516001600160a01b031681526020018c602001516001600160a01b031681526020018c6040015162ffffff168152602001336001600160a01b03168152506040516020016120fd91906150b9565b6040516020818303038152906040526040518663ffffffff1660e01b815260040161212c959493929190614d4d565b6040805180830381600087803b15801561214557600080fd5b505af1158015612159573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061217d9190614be4565b909a50985061219260808d0160608e01614a26565b6001600160801b03168a10156121ba5760405162461bcd60e51b815260040161099d90615044565b6121ca60a08d0160808e01614a26565b6001600160801b03168910156121f25760405162461bcd60e51b815260040161099d90614fba565b612200868383600080612740565b8b600001357ff565fdd70b3936f0ae8efc41c2e0822f9de5ecb4dc162b153b129ec4bb9cd93c838d8d8d60405161223a9493929190614d9d565b60405180910390a250505050505050509193909250565b6040516370a0823160e01b81526000906001600160a01b038516906370a0823190612280903090600401614cde565b60206040518083038186803b15801561229857600080fd5b505afa1580156122ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d09190614b61565b9050828110156122f25760405162461bcd60e51b815260040161099d9061501a565b8015611c3d57611c3d84838361357d565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b612339612a33565b6001600160a01b03811661239e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161099d565b6123a781612a8d565b50565b6000836001600160a01b0316856001600160a01b0316106123dd5760405162461bcd60e51b815260040161099d90614e66565b604051635f65e63560e11b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063becbcc6a9061243090899089908990600401614cf2565b60206040518083038186803b15801561244857600080fd5b505afa15801561245c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612480919061446e565b90506001600160a01b038116612551576040516378eda67b60e01b81526001600160a01b038781166004830152868116602483015262ffffff86166044830152600285900b60648301527f000000000000000000000000000000000000000000000000000000000000000016906378eda67b90608401602060405180830381600087803b15801561251057600080fd5b505af1158015612524573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612548919061446e565b91506125549050565b90505b949350505050565b60006001600160e01b031982166380ac58cd60e01b148061258d57506001600160e01b03198216635b5e139f60e01b145b8061086957506301ffc9a760e01b6001600160e01b0319831614610869565b6125b581613676565b6123a75760405162461bcd60e51b815260040161099d90615062565b600081815260056020526040902080546001600160a01b0319166001600160a01b03841690811790915581906126068261117c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b604080516000808252602082019092526001600160a01b0384169083906040516126699190614c93565b60006040518083038185875af1925050503d80600081146126a6576040519150601f19603f3d011682016040523d82523d6000602084013e6126ab565b606091505b5050905080610a3e5760405162461bcd60e51b815260206004820152600360248201526253544560e81b604482015260640161099d565b6000806126ee8361117c565b9050806001600160a01b0316846001600160a01b0316148061271557506127158185612303565b806125545750836001600160a01b031661272e84610901565b6001600160a01b031614949350505050565b845460009081906127679087906114a3903090600281810b9163010000009004900b612f7e565b600189015460028a01548a54939550919350840391908303906127a0908390600160301b90046001600160801b0316600160801b613693565b6127aa9087615223565b8960030160008282546127bd9190615223565b909155505088546127e4908290600160301b90046001600160801b0316600160801b613693565b6127ee9086615223565b8960040160008282546128019190615223565b9091555050505060018701919091556002860155505082546001600160801b03909116600160301b026601000000000000600160b01b03199091161790915550565b826001600160a01b03166128568261117c565b6001600160a01b03161461287c5760405162461bcd60e51b815260040161099d90614f3e565b6001600160a01b0382166128de5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161099d565b6128eb8383836001613740565b826001600160a01b03166128fe8261117c565b6001600160a01b0316146129245760405162461bcd60e51b815260040161099d90614f3e565b600081815260056020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260048552838620805460001901905590871680865283862080546001019055868652600390945282852080549092168417909155905184936000805160206154cc83398151915291a4505050565b60006129ad8261117c565b90506129bd816000846001613740565b6129c68261117c565b600083815260056020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526004845282852080546000190190558785526003909352818420805490911690555192935084926000805160206154cc833981519152908390a45050565b6000546001600160a01b03163314610a535760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161099d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b612ae8838383611c43565b6001600160a01b0316336001600160a01b031614610a3e5760405162461bcd60e51b8152602060048201526002602482015261073760f41b604482015260640161099d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b0316148015612b6e5750804710155b15612c90577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612bce57600080fd5b505af1158015612be2573d6000803e3d6000fd5b505060405163a9059cbb60e01b81526001600160a01b038681166004830152602482018690527f000000000000000000000000000000000000000000000000000000000000000016935063a9059cbb92506044019050602060405180830381600087803b158015612c5257600080fd5b505af1158015612c66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c8a9190614796565b50611c3d565b6001600160a01b038316301415612cb157612cac84838361357d565b611c3d565b611c3d8484848461386d565b6000806000806000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663becbcc6a886020015189604001518a606001516040518463ffffffff1660e01b8152600401612d2293929190614cf2565b60206040518083038186803b158015612d3a57600080fd5b505afa158015612d4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d72919061446e565b92506000836001600160a01b03166309beabc16040518163ffffffff1660e01b815260040160206040518083038186803b158015612daf57600080fd5b505afa158015612dc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de7919061446e565b90506001600160a01b038416612e0f5760405162461bcd60e51b815260040161099d90614fd8565b612e1884613417565b8094508193505050612e7460405180608001604052808a6080015160020b81526020018a60a0015160020b81526020018a60c001516001600160801b031681526020018a60e001516001600160801b03168152508484846134a2565b9650836001600160a01b0316633c8a7d8d308a608001518b60a001518b60405180608001604052808f602001516001600160a01b031681526020018f604001516001600160a01b031681526020018f6060015162ffffff168152602001336001600160a01b0316815250604051602001612eee91906150b9565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401612f1d959493929190614d4d565b6040805180830381600087803b158015612f3657600080fd5b505af1158015612f4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f6e9190614be4565b9799909850939550929350505050565b6040805160609490941b6bffffffffffffffffffffffff1916602080860191909152600293840b60e890811b60348701529290930b90911b60378401528051601a818503018152603a9093019052815191012090565b600080600080856001600160a01b031663b0f59257866040518263ffffffff1660e01b815260040161300891815260200190565b60a06040518083038186803b15801561302057600080fd5b505afa158015613034573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130589190614a42565b509196509450505050505b9250929050565b6001600160a01b0382166000908152600f60205260409020546001600160801b03168061086957600b80546001600160801b03169060006130aa8361539b565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b039485166000908152600f6020908152604080832080546001600160801b0319169486169485179055928252600e815290829020855181546001600160a01b031916908816178155908501516001919091018054959092015195166001600160b81b031990941693909317600160a01b62ffffff90951694909402939093179091555090565b6001600160a01b0382166131ad5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161099d565b6131b681613676565b156131d35760405162461bcd60e51b815260040161099d90614f83565b6131e1600083836001613740565b6131ea81613676565b156132075760405162461bcd60e51b815260040161099d90614f83565b6001600160a01b038216600081815260046020908152604080832080546001019055848352600390915280822080546001600160a01b0319168417905551839291906000805160206154cc833981519152908290a45050565b816001600160a01b0316836001600160a01b031614156132be5760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b604482015260640161099d565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b613336848484612843565b61334284848484613977565b611c3d5760405162461bcd60e51b815260040161099d90614ed0565b60606010805461087e90615366565b6060600061337a83613a81565b60010190506000816001600160401b038111156133a757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156133d1576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461340a5761340f565b6133db565b509392505050565b600080600080846001600160a01b031663c19d93fb6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561345757600080fd5b505afa15801561346b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061348f9190614a8a565b50959b949a509398505050505050505050565b60006134b660026001600160801b0361523b565b90506000806134d087600001518860200151888888613b59565b9092509050811561351e57600082600160601b89604001516001600160801b03166134fb9190615275565b6135059190615261565b905080846001600160801b0316111561351c578093505b505b801561357357600081600160601b60018a6060015161353d91906152db565b6001600160801b03166135509190615275565b61355a9190615261565b905080846001600160801b03161115613571578093505b505b5050949350505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916135d99190614c93565b6000604051808303816000865af19150503d8060008114613616576040519150601f19603f3d011682016040523d82523d6000602084013e61361b565b606091505b50915091508180156136455750805115806136455750808060200190518101906136459190614796565b6113325760405162461bcd60e51b815260206004820152600260248201526114d560f21b604482015260640161099d565b6000908152600360205260409020546001600160a01b0316151590565b6000808060001985870985870292508281108382030391505080600014156136cd57600084116136c257600080fd5b508290049050611ce9565b8084116136d957600080fd5b6000848688096001861981018716968790046003810260029081188083028203028083028203028083028203028083028203028083028203029182029003026000889003889004909101858311909403939093029303949094049190911702949350505050565b60018111156137af5760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b606482015260840161099d565b816001600160a01b03851661380b5761380681600980546000838152600a60205260408120829055600182018355919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0155565b61382e565b836001600160a01b0316856001600160a01b03161461382e5761382e8582613c49565b6001600160a01b03841661384a5761384581613ce6565b611332565b846001600160a01b0316846001600160a01b031614611332576113328482613dbf565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291516000928392908816916138d19190614c93565b6000604051808303816000865af19150503d806000811461390e576040519150601f19603f3d011682016040523d82523d6000602084013e613913565b606091505b509150915081801561393d57508051158061393d57508080602001905181019061393d9190614796565b61396f5760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161099d565b505050505050565b60006001600160a01b0384163b15613a7957604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906139bb903390899088908890600401614d1a565b602060405180830381600087803b1580156139d557600080fd5b505af1925050508015613a05575060408051601f3d908101601f19168201909252613a02918101906147ce565b60015b613a5f573d808015613a33576040519150601f19603f3d011682016040523d82523d6000602084013e613a38565b606091505b508051613a575760405162461bcd60e51b815260040161099d90614ed0565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612554565b506001612554565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310613ac05772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310613aec576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310613b0a57662386f26fc10000830492506010015b6305f5e1008310613b22576305f5e100830492506008015b6127108310613b3657612710830492506004015b60648310613b48576064830492506002015b600a83106108695760010192915050565b60008080613b6687613e03565b90508560020b8860020b1215613bc7576000613b8189613e03565b90508660020b8860020b1215613bad57613b9c81838761420e565b613ba69084615223565b9250613bc5565b613bb881878761420e565b613bc29084615223565b92505b505b8560020b8760020b1315613c085760008660020b8960020b13613bf457613bef8760016151bb565b613bf6565b885b9050613c048189848861425a565b9350505b8560020b8860020b13158015613c2357508560020b8760020b135b15613c3e57613c3b6001600160a01b03861683615223565b91505b509550959350505050565b60006001613c568461123f565b613c609190615323565b600083815260086020526040902054909150808214613cb3576001600160a01b03841660009081526007602090815260408083208584528252808320548484528184208190558352600890915290208190555b5060009182526008602090815260408084208490556001600160a01b039094168352600781528383209183525290812055565b600954600090613cf890600190615323565b6000838152600a602052604081205460098054939450909284908110613d2e57634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060098381548110613d5d57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152600a90915260408082208490558582528120556009805480613da357634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000613dca8361123f565b6001600160a01b039093166000908152600760209081526040808320868452825280832085905593825260089052919091209190915550565b60008060008360020b12613e1a578260020b613e27565b8260020b613e2790615412565b9050613e36620d89e7196153f1565b60020b811115613e6c5760405162461bcd60e51b81526020600482015260016024820152601560fa1b604482015260640161099d565b600060018216613e8057600160801b613e92565b6ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b031690506002821615613ec7576080613ec2826ffff97272373d413259a46990580e213a615275565b901c90505b6004821615613ef1576080613eec826ffff2e50f5f656932ef12357cf3c7fdcc615275565b901c90505b6008821615613f1b576080613f16826fffe5caca7e10e4e61c3624eaa0941cd0615275565b901c90505b6010821615613f45576080613f40826fffcb9843d60f6159c9db58835c926644615275565b901c90505b6020821615613f6f576080613f6a826fff973b41fa98c081472e6896dfb254c0615275565b901c90505b6040821615613f99576080613f94826fff2ea16466c96a3843ec78b326b52861615275565b901c90505b6080821615613fc3576080613fbe826ffe5dee046a99a2a811c461f1969c3053615275565b901c90505b610100821615613fee576080613fe9826ffcbe86c7900a88aedcffc83b479aa3a4615275565b901c90505b610200821615614019576080614014826ff987a7253ac413176f2b074cf7815e54615275565b901c90505b61040082161561404457608061403f826ff3392b0822b70005940c7a398e4b70f3615275565b901c90505b61080082161561406f57608061406a826fe7159475a2c29b7443b29c7fa6e889d9615275565b901c90505b61100082161561409a576080614095826fd097f3bdfd2022b8845ad8f792aa5825615275565b901c90505b6120008216156140c55760806140c0826fa9f746462d870fdf8a65dc1f90e061e5615275565b901c90505b6140008216156140f05760806140eb826f70d869a156d2a1b890bb3df62baf32f7615275565b901c90505b61800082161561411b576080614116826f31be135f97d08fd981231505542fcfa6615275565b901c90505b62010000821615614147576080614142826f09aa508b5b7a84e1c677de54f3e99bc9615275565b901c90505b6202000082161561417257608061416d826e5d6af8dedb81196699c329225ee604615275565b901c90505b6204000082161561419c576080614197826d2216e584f5fa1ea926041bedfe98615275565b901c90505b620800008216156141c45760806141bf826b048a170391f7dc42444e8fa2615275565b901c90505b60008460020b13156141df576141dc81600019615261565b90505b6141ee640100000000826153dd565b156141fa5760016141fd565b60005b6125549060ff16602083901c615223565b60008061421b8585615303565b9050600061422d600160601b85615303565b9050614250600160601b836001600160a01b0316836001600160a01b03166142d8565b9695505050505050565b60008061427a61426a8787615294565b6142759060016151bb565b613e03565b9050600061428c6142758760016151bb565b9050600061429a8584615303565b905060006142a88784615303565b90506142cb600160601b836001600160a01b0316836001600160a01b03166142d8565b9998505050505050505050565b60006142e5848484613693565b90506000828061430557634e487b7160e01b600052601260045260246000fd5b8486091115611ce957600019811061431c57600080fd5b80614326816153c2565b95945050505050565b82805461433b90615366565b90600052602060002090601f01602090048101928261435d57600085556143a3565b82601f106143765782800160ff198235161785556143a3565b828001600101855582156143a3579182015b828111156143a3578235825591602001919060010190614388565b506143af9291506143b3565b5090565b5b808211156143af57600081556001016143b4565b80356143d38161546e565b919050565b60008083601f8401126143e9578182fd5b5081356001600160401b038111156143ff578182fd5b60208301915083602082850101111561306357600080fd5b80356143d3816154a7565b80356143d3816154b6565b805161ffff811681146143d357600080fd5b803562ffffff811681146143d357600080fd5b600060208284031215614463578081fd5b8135611ce98161546e565b60006020828403121561447f578081fd5b8151611ce98161546e565b6000806040838503121561449c578081fd5b82356144a78161546e565b915060208301356144b78161546e565b809150509250929050565b6000806000606084860312156144d6578081fd5b83356144e18161546e565b925060208401356144f18161546e565b91506144ff6040850161443f565b90509250925092565b6000806000806080858703121561451d578182fd5b84356145288161546e565b935060208501356145388161546e565b92506145466040860161443f565b91506060850135614556816154a7565b939692955090935050565b600080600060608486031215614575578081fd5b83356145808161546e565b925060208401356145908161546e565b929592945050506040919091013590565b600080600080608085870312156145b6578182fd5b84356145c18161546e565b935060208501356145d18161546e565b92506040850135915060608501356001600160401b038111156145f2578182fd5b8501601f81018713614602578182fd5b803561461561461082615194565b615164565b818152886020838501011115614629578384fd5b81602084016020830137908101602001929092525092959194509250565b60008060408385031215614659578182fd5b82356146648161546e565b915060208301356144b781615483565b60008060408385031215614686578182fd5b82356146918161546e565b946020939093013593505050565b6000806000606084860312156146b3578081fd5b83356146be8161546e565b92506020840135915060408401356146d58161546e565b809150509250925092565b600080600080608085870312156146f5578182fd5b84356147008161546e565b9350602085013592506040850135614717816154b6565b91506060850135614556816154b6565b60008060208385031215614739578182fd5b82356001600160401b038082111561474f578384fd5b818501915085601f830112614762578384fd5b813581811115614770578485fd5b8660208260051b8501011115614784578485fd5b60209290920196919550909350505050565b6000602082840312156147a7578081fd5b8151611ce981615483565b6000602082840312156147c3578081fd5b8135611ce981615491565b6000602082840312156147df578081fd5b8151611ce981615491565b6000602082840312156147fb578081fd5b8135611ce9816154a7565b60008060208385031215614818578182fd5b82356001600160401b0381111561482d578283fd5b614839858286016143d8565b90969095509350505050565b600060208284031215614856578081fd5b81516001600160401b0381111561486b578182fd5b8201601f8101841361487b578182fd5b805161488961461082615194565b81815285602083850101111561489d578384fd5b61432682602083016020860161533a565b600060c08284031215610f76578081fd5b6000608082840312156148d0578081fd5b604051608081018181106001600160401b03821117156148f2576148f2615458565b60405282356149008161546e565b815260208301356149108161546e565b60208201526149216040840161443f565b604082015260608301356149348161546e565b60608201529392505050565b60006101608284031215610f76578081fd5b60006101608284031215614964578081fd5b61496c61513b565b614975836143c8565b8152614983602084016143c8565b6020820152614994604084016143c8565b60408201526149a56060840161443f565b60608201526149b660808401614417565b60808201526149c760a08401614417565b60a08201526149d860c08401614422565b60c08201526149e960e08401614422565b60e08201526101006149fc818501614422565b90820152610120614a0e848201614422565b90820152610140928301359281019290925250919050565b600060208284031215614a37578081fd5b8135611ce9816154b6565b600080600080600060a08688031215614a59578283fd5b8551614a64816154b6565b602087015160408801516060890151608090990151929a91995097965090945092505050565b600080600080600080600080610100898b031215614aa6578586fd5b8851614ab18161546e565b60208a0151909850614ac2816154a7565b9650614ad060408a0161442d565b9550614ade60608a0161442d565b9450614aec60808a0161442d565b935060a0890151614afc81615483565b60c08a0151909350614b0d816154b6565b60e08a0151909250614b1e816154b6565b809150509295985092959890939650565b600060208284031215614b40578081fd5b611ce98261443f565b600060208284031215614b5a578081fd5b5035919050565b600060208284031215614b72578081fd5b5051919050565b60008060408385031215614b8b578182fd5b8235915060208301356144b78161546e565b600080600080600060a08688031215614bb4578283fd5b853594506020860135614bc6816154b6565b94979496505050506040830135926060810135926080909101359150565b60008060408385031215614bf6578182fd5b505080516020909101519092909150565b60008060008060608587031215614c1c578182fd5b843593506020850135925060408501356001600160401b03811115614c3f578283fd5b614c4b878288016143d8565b95989497509550505050565b60008151808452614c6f81602086016020860161533a565b601f01601f19169290920160200192915050565b8183823760009101908152919050565b60008251614ca581846020870161533a565b9190910192915050565b60008351614cc181846020880161533a565b835190830190614cd581836020880161533a565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b03938416815291909216602082015262ffffff909116604082015260600190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061425090830184614c57565b6001600160a01b0386168152600285810b602083015284900b60408201526001600160801b038316606082015260a060808201819052600090614d9290830184614c57565b979650505050505050565b6001600160a01b039490941684526001600160801b039290921660208401526040830152606082015260800190565b6000602080830181845280855180835260408601915060408160051b8701019250838701855b82811015614e2057603f19888603018452614e0e858351614c57565b94509285019290850190600101614df2565b5092979650505050505050565b600293840b81529190920b60208201526001600160801b03909116604082015260600190565b602081526000611ce96020830184614c57565b602080825260039082015262783c7960e81b604082015260600190565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b602080825260029082015261262760f11b604082015260600190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6020808252600490820152632ca6a4a760e11b604082015260600190565b602080825260029082015261050360f41b604082015260600190565b6020808252600c908201526b139bdd08185c1c1c9bdd995960a21b604082015260600190565b60208082526010908201526f0ae8aa89072409cdee8408adcdeeaced60831b604082015260600190565b6020808252600490820152632c26a4a760e11b604082015260600190565b602080825260189082015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604082015260600190565b6020808252600b908201526a4f7574206f662074696d6560a81b604082015260600190565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff1690830152606092830151169181019190915260800190565b6000808335601e1984360301811261510d578283fd5b8301803591506001600160401b03821115615126578283fd5b60200191503681900382131561306357600080fd5b60405161016081016001600160401b038111828210171561515e5761515e615458565b60405290565b604051601f8201601f191681016001600160401b038111828210171561518c5761518c615458565b604052919050565b60006001600160401b038211156151ad576151ad615458565b50601f01601f191660200190565b60008160020b8360020b82821282627fffff038213811516156151e0576151e061542c565b82627fffff190382128116156151f8576151f861542c565b50019392505050565b60006001600160801b03828116848216808303821115614cd557614cd561542c565b600082198211156152365761523661542c565b500190565b60006001600160801b038381168061525557615255615442565b92169190910492915050565b60008261527057615270615442565b500490565b600081600019048311821515161561528f5761528f61542c565b500290565b60008160020b8360020b82811281627fffff19018312811516156152ba576152ba61542c565b81627fffff0183138116156152d1576152d161542c565b5090039392505050565b60006001600160801b03838116908316818110156152fb576152fb61542c565b039392505050565b60006001600160a01b03838116908316818110156152fb576152fb61542c565b6000828210156153355761533561542c565b500390565b60005b8381101561535557818101518382015260200161533d565b83811115611c3d5750506000910152565b600181811c9082168061537a57607f821691505b60208210811415610f7657634e487b7160e01b600052602260045260246000fd5b60006001600160801b03828116808214156153b8576153b861542c565b6001019392505050565b60006000198214156153d6576153d661542c565b5060010190565b6000826153ec576153ec615442565b500690565b60008160020b627fffff1981141561540b5761540b61542c565b9003919050565b6000600160ff1b8214156154285761542861542c565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146123a757600080fd5b80151581146123a757600080fd5b6001600160e01b0319811681146123a757600080fd5b8060020b81146123a757600080fd5b6001600160801b03811681146123a757600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220821891a2d1a4a49cd228ad217a041cc33292966a30637784cf13ceb7400c11fa64736f6c63430008040033000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Deployed Bytecode
0x6080604052600436106102245760003560e01c8063715018a61161012e578063c45a0155116100ab578063df2ab5bb1161006f578063df2ab5bb14610773578063e985e9c514610786578063f2fde38b146107a6578063f425a3ce146107c6578063f655dbc1146107e657600080fd5b8063c45a015514610683578063c87b56dd146106b7578063cbd89416146106d7578063d4175be21461070f578063dca87bec1461075d57600080fd5b8063a0e4eb3c116100f2578063a0e4eb3c146105f0578063a22cb46514610603578063ac9650d814610623578063b88d4fde14610643578063becbcc6a1461066357600080fd5b8063715018a61461054d57806384fe2b3d146105625780638da5cb5b1461058257806395d89b41146105a057806396f639ed146105b557600080fd5b80632f745c59116101bc5780634f6ccce7116101805780634f6ccce7146104b857806355f804b3146104d85780636352211e146104f85780636c0360eb1461051857806370a082311461052d57600080fd5b80632f745c591461041157806342842e0e1461043157806342966c681461045157806349404b7c146104715780634aa4a4fc1461048457600080fd5b806301ffc9a71461023057806306fdde03146102655780630713051d14610287578063081812fc14610346578063095ea7b31461037357806312210e8a1461039557806315feae511461039d57806318160ddd146103d257806323b872dd146103f157600080fd5b3661022b57005b600080fd5b34801561023c57600080fd5b5061025061024b3660046147b2565b610844565b60405190151581526020015b60405180910390f35b34801561027157600080fd5b5061027a61086f565b60405161025c9190614e53565b34801561029357600080fd5b506102f56102a2366004614b49565b600c602052600090815260409020805460018201546002808401546003850154600486015460059096015485840b966301000000870490940b956001600160801b03600160301b90910481169594911688565b604080516002998a0b81529790980b60208801526001600160801b03958616978701979097526060860193909352608085019190915260a084015260c083015290911660e08201526101000161025c565b34801561035257600080fd5b50610366610361366004614b49565b610901565b60405161025c9190614cde565b34801561037f57600080fd5b5061039361038e366004614674565b610928565b005b610393610a43565b3480156103a957600080fd5b506103bd6103b8366004614b9d565b610a55565b6040805192835260208301919091520161025c565b3480156103de57600080fd5b506009545b60405190815260200161025c565b3480156103fd57600080fd5b5061039361040c366004614561565b610da4565b34801561041d57600080fd5b506103e361042c366004614674565b610dd5565b34801561043d57600080fd5b5061039361044c366004614561565b610e6b565b34801561045d57600080fd5b5061025061046c366004614b49565b610e86565b61039361047f366004614b79565b610f7c565b34801561049057600080fd5b506103667f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b3480156104c457600080fd5b506103e36104d3366004614b49565b6110c7565b3480156104e457600080fd5b506103936104f3366004614806565b611168565b34801561050457600080fd5b50610366610513366004614b49565b61117c565b34801561052457600080fd5b5061027a6111b1565b34801561053957600080fd5b506103e3610548366004614452565b61123f565b34801561055957600080fd5b506103936112c5565b34801561056e57600080fd5b5061039361057d366004614c07565b6112d7565b34801561058e57600080fd5b506000546001600160a01b0316610366565b3480156105ac57600080fd5b5061027a611339565b6105c86105c3366004614940565b611348565b604080519485526001600160801b03909316602085015291830152606082015260800161025c565b6103bd6105fe3660046146e0565b6116e3565b34801561060f57600080fd5b5061039361061e366004614647565b611a7b565b610636610631366004614727565b611a8a565b60405161025c9190614dcc565b34801561064f57600080fd5b5061039361065e3660046145a1565b611c0b565b34801561066f57600080fd5b5061036661067e3660046144c2565b611c43565b34801561068f57600080fd5b506103667f000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c81565b3480156106c357600080fd5b5061027a6106d2366004614b49565b611cf0565b6106ea6106e53660046148ae565b611d56565b604080516001600160801b03909416845260208401929092529082015260600161025c565b34801561071b57600080fd5b5061074561072a366004614452565b600f602052600090815260409020546001600160801b031681565b6040516001600160801b03909116815260200161025c565b34801561076957600080fd5b506103e3600d5481565b61039361078136600461469f565b612251565b34801561079257600080fd5b506102506107a136600461448a565b612303565b3480156107b257600080fd5b506103936107c1366004614452565b612331565b3480156107d257600080fd5b506103666107e1366004614508565b6123aa565b3480156107f257600080fd5b50610835610801366004614a26565b600e60205260009081526040902080546001909101546001600160a01b0391821691811690600160a01b900462ffffff1683565b60405161025c93929190614cf2565b60006001600160e01b0319821663780e9d6360e01b148061086957506108698261255c565b92915050565b60606001805461087e90615366565b80601f01602080910402602001604051908101604052809291908181526020018280546108aa90615366565b80156108f75780601f106108cc576101008083540402835291602001916108f7565b820191906000526020600020905b8154815290600101906020018083116108da57829003601f168201915b5050505050905090565b600061090c826125ac565b506000908152600560205260409020546001600160a01b031690565b60006109338261117c565b9050806001600160a01b0316836001600160a01b031614156109a65760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b03821614806109c257506109c28133612303565b610a345760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c000000606482015260840161099d565b610a3e83836125d1565b505050565b4715610a5357610a53334761263f565b565b60008086610a6333826126e2565b610a7f5760405162461bcd60e51b815260040161099d90614ff4565b8380421115610aa05760405162461bcd60e51b815260040161099d90615094565b600d548910610ac15760405162461bcd60e51b815260040161099d90614f22565b6000898152600c602052604090208054600160301b90046001600160801b0316610af2576000809450945050610d98565b80546001600160801b03600160301b9091048116908a161115610b24578054600160301b90046001600160801b031698505b60058101546001600160801b03166000908152600e60209081526040808320815160608101835281546001600160a01b03908116808352600190930154808216958301869052600160a01b900462ffffff168285018190529351635f65e63560e11b81529195947f000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c9091169363becbcc6a93610bc69390929190600401614cf2565b60206040518083038186803b158015610bde57600080fd5b505afa158015610bf2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c16919061446e565b90506001600160a01b038116610c3e5760405162461bcd60e51b815260040161099d90614fd8565b8254600090610c5e908d90600160301b90046001600160801b03166152db565b9050816001600160a01b031663a34123a78560000160009054906101000a900460020b8660000160039054906101000a900460020b8f6040518463ffffffff1660e01b8152600401610cb293929190614e2d565b6040805180830381600087803b158015610ccb57600080fd5b505af1158015610cdf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d039190614be4565b90985096508a881015610d285760405162461bcd60e51b815260040161099d90615044565b89871015610d485760405162461bcd60e51b815260040161099d90614fba565b610d558483838b8b612740565b8c7f24f4b91fa7871755148bc2a9e01f85d6fd73ec2a0e6bd9a5717c0d7f5be8c2c3838e8b8b604051610d8b9493929190614d9d565b60405180910390a2505050505b50509550959350505050565b610dae33826126e2565b610dca5760405162461bcd60e51b815260040161099d90614e83565b610a3e838383612843565b6000610de08361123f565b8210610e425760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161099d565b506001600160a01b03919091166000908152600760209081526040808320938352929052205490565b610a3e83838360405180602001604052806000815250611c0b565b600081610e9333826126e2565b610eaf5760405162461bcd60e51b815260040161099d90614ff4565b6000838152600c602052604090208054600160301b90046001600160801b0316158015610ede57506003810154155b8015610eec57506004810154155b610f1d5760405162461bcd60e51b81526020600482015260026024820152614e4360f01b604482015260640161099d565b6000848152600c6020526040812080546001600160b01b0319168155600181018290556002810182905560038101829055600481019190915560050180546001600160801b0319169055610f70846129a2565b60019250505b50919050565b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216906370a0823190610fcb903090600401614cde565b60206040518083038186803b158015610fe357600080fd5b505afa158015610ff7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101b9190614b61565b90508281101561103d5760405162461bcd60e51b815260040161099d9061501a565b8015610a3e57604051632e1a7d4d60e01b8152600481018290527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b1580156110a557600080fd5b505af11580156110b9573d6000803e3d6000fd5b50505050610a3e828261263f565b60006110d260095490565b82106111355760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161099d565b6009828154811061115657634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b611170612a33565b610a3e6010838361432f565b6000818152600360205260408120546001600160a01b0316806108695760405162461bcd60e51b815260040161099d90615062565b601080546111be90615366565b80601f01602080910402602001604051908101604052809291908181526020018280546111ea90615366565b80156112375780601f1061120c57610100808354040283529160200191611237565b820191906000526020600020905b81548152906001019060200180831161121a57829003601f168201915b505050505081565b60006001600160a01b0382166112a95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b606482015260840161099d565b506001600160a01b031660009081526004602052604090205490565b6112cd612a33565b610a536000612a8d565b60006112e5828401846148bf565b90506112fe816000015182602001518360400151612add565b841561131857611318816000015182606001513388612b2d565b831561133257611332816020015182606001513387612b2d565b5050505050565b60606002805461087e90615366565b600080600080846101400135804211156113745760405162461bcd60e51b815260040161099d90615094565b6113846060870160408801614452565b6001600160a01b031661139d6040880160208901614452565b6001600160a01b0316106113c35760405162461bcd60e51b815260040161099d90614e66565b60006113dc6113d736899003890189614952565b612cbd565b929750909550935090506113f861012088016101008901614a26565b6001600160801b03168410156114205760405162461bcd60e51b815260040161099d90615044565b61143261014088016101208901614a26565b6001600160801b031683101561145a5760405162461bcd60e51b815260040161099d90614fba565b600d805490600061146a836153c2565b9091555095506000806114a8836114a33061148b60a08e0160808f016147ea565b8d60a001602081019061149e91906147ea565b612f7e565b612fd4565b91509150600061151e8460405180606001604052808d60200160208101906114d09190614452565b6001600160a01b031681526020018d60400160208101906114f19190614452565b6001600160a01b031681526020018d60600160208101906115129190614b2f565b62ffffff16905261306a565b90506040518061010001604052808b608001602081019061153f91906147ea565b60020b815260200161155760c08d0160a08e016147ea565b60020b8152602001896001600160801b031681526020018481526020018381526020016000815260200160008152602001826001600160801b0316815250600c60008b815260200190815260200160002060008201518160000160006101000a81548162ffffff021916908360020b62ffffff16021790555060208201518160000160036101000a81548162ffffff021916908360020b62ffffff16021790555060408201518160000160066101000a8154816001600160801b0302191690836001600160801b03160217905550606082015181600101556080820151816002015560a0820151816003015560c0820151816004015560e08201518160050160006101000a8154816001600160801b0302191690836001600160801b031602179055509050506116998a60000160208101906116939190614452565b8a613157565b887ff565fdd70b3936f0ae8efc41c2e0822f9de5ecb4dc162b153b129ec4bb9cd93c858a8a8a6040516116cf9493929190614d9d565b60405180910390a250505050509193509193565b600080846116f133826126e2565b61170d5760405162461bcd60e51b815260040161099d90614ff4565b6001600160a01b03871661171f573096505b600d5486106117405760405162461bcd60e51b815260040161099d90614f22565b6000868152600c6020908152604080832060058101546001600160801b03168452600e8352818420825160608101845281546001600160a01b03908116808352600190930154808216968301879052600160a01b900462ffffff168286018190529451635f65e63560e11b81529396919591947f000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c9091169363becbcc6a936117ee9390929091600401614cf2565b60206040518083038186803b15801561180657600080fd5b505afa15801561181a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183e919061446e565b90506001600160a01b0381166118665760405162461bcd60e51b815260040161099d90614fd8565b8254600160301b90046001600160801b03161561193257825460405163a34123a760e01b81526001600160a01b0383169163a34123a7916118bd91600281810b926301000000909204900b90600090600401614e2d565b6040805180830381600087803b1580156118d657600080fd5b505af11580156118ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190e9190614be4565b505082546119329084908390600160301b90046001600160801b0316600080612740565b8260030154886001600160801b0316111561194f57826003015497505b8260040154876001600160801b0316111561196c57826004015496505b825460405163872d1f1560e01b81526001600160a01b038c81166004830152600283810b810b60248401526301000000909304830b90920b60448201526001600160801b03808b166064830152891660848201529082169063872d1f159060a4016040805180830381600087803b1580156119e657600080fd5b505af11580156119fa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a1e9190614be4565b8096508197505050876001600160801b0316836003016000828254611a439190615323565b92505081905550866001600160801b0316836004016000828254611a679190615323565b925050819055505050505094509492505050565b611a86338383613260565b5050565b6060816001600160401b03811115611ab257634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611ae557816020015b6060815260200190600190039081611ad05790505b50905060005b82811015611c045760008030868685818110611b1757634e487b7160e01b600052603260045260246000fd5b9050602002810190611b2991906150f7565b604051611b37929190614c83565b600060405180830381855af49150503d8060008114611b72576040519150601f19603f3d011682016040523d82523d6000602084013e611b77565b606091505b509150915081611bc357604481511015611b9057600080fd5b60048101905080806020019051810190611baa9190614845565b60405162461bcd60e51b815260040161099d9190614e53565b80848481518110611be457634e487b7160e01b600052603260045260246000fd5b602002602001018190525050508080611bfc906153c2565b915050611aeb565b5092915050565b611c1533836126e2565b611c315760405162461bcd60e51b815260040161099d90614e83565b611c3d8484848461332b565b50505050565b604051635f65e63560e11b81526000906001600160a01b037f000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c169063becbcc6a90611c9690879087908790600401614cf2565b60206040518083038186803b158015611cae57600080fd5b505afa158015611cc2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce6919061446e565b90505b9392505050565b6060611cfb826125ac565b6000611d0561335e565b90506000815111611d255760405180602001604052806000815250611ce9565b80611d2f8461336d565b604051602001611d40929190614caf565b6040516020818303038152906040529392505050565b600080808335611d6633826126e2565b611d825760405162461bcd60e51b815260040161099d90614ff4565b8460a0013580421115611da75760405162461bcd60e51b815260040161099d90615094565b600d54863510611dc95760405162461bcd60e51b815260040161099d90614f22565b85356000908152600c6020908152604080832060058101546001600160801b03168452600e8352818420825160608101845281546001600160a01b03908116808352600190930154808216968301879052600160a01b900462ffffff168286018190529451635f65e63560e11b8152939691959194859485947f000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c9093169363becbcc6a93611e7b939092600401614cf2565b60206040518083038186803b158015611e9357600080fd5b505afa158015611ea7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecb919061446e565b90506001600160a01b038116611ef35760405162461bcd60e51b815260040161099d90614fd8565b611efc81613417565b8094508193505050611ffe60405180608001604052808760000160009054906101000a900460020b60020b81526020018760000160039054906101000a900460020b60020b81526020018d6020016020810190611f599190614a26565b6001600160801b031681526020018d6040016020810190611f7a9190614a26565b6001600160801b03168152508484846001600160a01b03166309beabc16040518163ffffffff1660e01b815260040160206040518083038186803b158015611fc157600080fd5b505afa158015611fd5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ff9919061446e565b6134a2565b8554909a50600160301b90046001600160801b0316600f81900b1461204a5760405162461bcd60e51b81526020600482015260026024820152614c4f60f01b604482015260640161099d565b845460009061206990600160301b90046001600160801b03168c615201565b9050816001600160a01b0316633c8a7d8d308860000160009054906101000a900460020b8960000160039054906101000a900460020b8f60405180608001604052808c600001516001600160a01b031681526020018c602001516001600160a01b031681526020018c6040015162ffffff168152602001336001600160a01b03168152506040516020016120fd91906150b9565b6040516020818303038152906040526040518663ffffffff1660e01b815260040161212c959493929190614d4d565b6040805180830381600087803b15801561214557600080fd5b505af1158015612159573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061217d9190614be4565b909a50985061219260808d0160608e01614a26565b6001600160801b03168a10156121ba5760405162461bcd60e51b815260040161099d90615044565b6121ca60a08d0160808e01614a26565b6001600160801b03168910156121f25760405162461bcd60e51b815260040161099d90614fba565b612200868383600080612740565b8b600001357ff565fdd70b3936f0ae8efc41c2e0822f9de5ecb4dc162b153b129ec4bb9cd93c838d8d8d60405161223a9493929190614d9d565b60405180910390a250505050505050509193909250565b6040516370a0823160e01b81526000906001600160a01b038516906370a0823190612280903090600401614cde565b60206040518083038186803b15801561229857600080fd5b505afa1580156122ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d09190614b61565b9050828110156122f25760405162461bcd60e51b815260040161099d9061501a565b8015611c3d57611c3d84838361357d565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b612339612a33565b6001600160a01b03811661239e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161099d565b6123a781612a8d565b50565b6000836001600160a01b0316856001600160a01b0316106123dd5760405162461bcd60e51b815260040161099d90614e66565b604051635f65e63560e11b81526000906001600160a01b037f000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c169063becbcc6a9061243090899089908990600401614cf2565b60206040518083038186803b15801561244857600080fd5b505afa15801561245c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612480919061446e565b90506001600160a01b038116612551576040516378eda67b60e01b81526001600160a01b038781166004830152868116602483015262ffffff86166044830152600285900b60648301527f000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c16906378eda67b90608401602060405180830381600087803b15801561251057600080fd5b505af1158015612524573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612548919061446e565b91506125549050565b90505b949350505050565b60006001600160e01b031982166380ac58cd60e01b148061258d57506001600160e01b03198216635b5e139f60e01b145b8061086957506301ffc9a760e01b6001600160e01b0319831614610869565b6125b581613676565b6123a75760405162461bcd60e51b815260040161099d90615062565b600081815260056020526040902080546001600160a01b0319166001600160a01b03841690811790915581906126068261117c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b604080516000808252602082019092526001600160a01b0384169083906040516126699190614c93565b60006040518083038185875af1925050503d80600081146126a6576040519150601f19603f3d011682016040523d82523d6000602084013e6126ab565b606091505b5050905080610a3e5760405162461bcd60e51b815260206004820152600360248201526253544560e81b604482015260640161099d565b6000806126ee8361117c565b9050806001600160a01b0316846001600160a01b0316148061271557506127158185612303565b806125545750836001600160a01b031661272e84610901565b6001600160a01b031614949350505050565b845460009081906127679087906114a3903090600281810b9163010000009004900b612f7e565b600189015460028a01548a54939550919350840391908303906127a0908390600160301b90046001600160801b0316600160801b613693565b6127aa9087615223565b8960030160008282546127bd9190615223565b909155505088546127e4908290600160301b90046001600160801b0316600160801b613693565b6127ee9086615223565b8960040160008282546128019190615223565b9091555050505060018701919091556002860155505082546001600160801b03909116600160301b026601000000000000600160b01b03199091161790915550565b826001600160a01b03166128568261117c565b6001600160a01b03161461287c5760405162461bcd60e51b815260040161099d90614f3e565b6001600160a01b0382166128de5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161099d565b6128eb8383836001613740565b826001600160a01b03166128fe8261117c565b6001600160a01b0316146129245760405162461bcd60e51b815260040161099d90614f3e565b600081815260056020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260048552838620805460001901905590871680865283862080546001019055868652600390945282852080549092168417909155905184936000805160206154cc83398151915291a4505050565b60006129ad8261117c565b90506129bd816000846001613740565b6129c68261117c565b600083815260056020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526004845282852080546000190190558785526003909352818420805490911690555192935084926000805160206154cc833981519152908390a45050565b6000546001600160a01b03163314610a535760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161099d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b612ae8838383611c43565b6001600160a01b0316336001600160a01b031614610a3e5760405162461bcd60e51b8152602060048201526002602482015261073760f41b604482015260640161099d565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316846001600160a01b0316148015612b6e5750804710155b15612c90577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612bce57600080fd5b505af1158015612be2573d6000803e3d6000fd5b505060405163a9059cbb60e01b81526001600160a01b038681166004830152602482018690527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216935063a9059cbb92506044019050602060405180830381600087803b158015612c5257600080fd5b505af1158015612c66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c8a9190614796565b50611c3d565b6001600160a01b038316301415612cb157612cac84838361357d565b611c3d565b611c3d8484848461386d565b6000806000806000807f000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c6001600160a01b031663becbcc6a886020015189604001518a606001516040518463ffffffff1660e01b8152600401612d2293929190614cf2565b60206040518083038186803b158015612d3a57600080fd5b505afa158015612d4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d72919061446e565b92506000836001600160a01b03166309beabc16040518163ffffffff1660e01b815260040160206040518083038186803b158015612daf57600080fd5b505afa158015612dc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de7919061446e565b90506001600160a01b038416612e0f5760405162461bcd60e51b815260040161099d90614fd8565b612e1884613417565b8094508193505050612e7460405180608001604052808a6080015160020b81526020018a60a0015160020b81526020018a60c001516001600160801b031681526020018a60e001516001600160801b03168152508484846134a2565b9650836001600160a01b0316633c8a7d8d308a608001518b60a001518b60405180608001604052808f602001516001600160a01b031681526020018f604001516001600160a01b031681526020018f6060015162ffffff168152602001336001600160a01b0316815250604051602001612eee91906150b9565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401612f1d959493929190614d4d565b6040805180830381600087803b158015612f3657600080fd5b505af1158015612f4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f6e9190614be4565b9799909850939550929350505050565b6040805160609490941b6bffffffffffffffffffffffff1916602080860191909152600293840b60e890811b60348701529290930b90911b60378401528051601a818503018152603a9093019052815191012090565b600080600080856001600160a01b031663b0f59257866040518263ffffffff1660e01b815260040161300891815260200190565b60a06040518083038186803b15801561302057600080fd5b505afa158015613034573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130589190614a42565b509196509450505050505b9250929050565b6001600160a01b0382166000908152600f60205260409020546001600160801b03168061086957600b80546001600160801b03169060006130aa8361539b565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b039485166000908152600f6020908152604080832080546001600160801b0319169486169485179055928252600e815290829020855181546001600160a01b031916908816178155908501516001919091018054959092015195166001600160b81b031990941693909317600160a01b62ffffff90951694909402939093179091555090565b6001600160a01b0382166131ad5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161099d565b6131b681613676565b156131d35760405162461bcd60e51b815260040161099d90614f83565b6131e1600083836001613740565b6131ea81613676565b156132075760405162461bcd60e51b815260040161099d90614f83565b6001600160a01b038216600081815260046020908152604080832080546001019055848352600390915280822080546001600160a01b0319168417905551839291906000805160206154cc833981519152908290a45050565b816001600160a01b0316836001600160a01b031614156132be5760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b604482015260640161099d565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b613336848484612843565b61334284848484613977565b611c3d5760405162461bcd60e51b815260040161099d90614ed0565b60606010805461087e90615366565b6060600061337a83613a81565b60010190506000816001600160401b038111156133a757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156133d1576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461340a5761340f565b6133db565b509392505050565b600080600080846001600160a01b031663c19d93fb6040518163ffffffff1660e01b81526004016101006040518083038186803b15801561345757600080fd5b505afa15801561346b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061348f9190614a8a565b50959b949a509398505050505050505050565b60006134b660026001600160801b0361523b565b90506000806134d087600001518860200151888888613b59565b9092509050811561351e57600082600160601b89604001516001600160801b03166134fb9190615275565b6135059190615261565b905080846001600160801b0316111561351c578093505b505b801561357357600081600160601b60018a6060015161353d91906152db565b6001600160801b03166135509190615275565b61355a9190615261565b905080846001600160801b03161115613571578093505b505b5050949350505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916135d99190614c93565b6000604051808303816000865af19150503d8060008114613616576040519150601f19603f3d011682016040523d82523d6000602084013e61361b565b606091505b50915091508180156136455750805115806136455750808060200190518101906136459190614796565b6113325760405162461bcd60e51b815260206004820152600260248201526114d560f21b604482015260640161099d565b6000908152600360205260409020546001600160a01b0316151590565b6000808060001985870985870292508281108382030391505080600014156136cd57600084116136c257600080fd5b508290049050611ce9565b8084116136d957600080fd5b6000848688096001861981018716968790046003810260029081188083028203028083028203028083028203028083028203028083028203029182029003026000889003889004909101858311909403939093029303949094049190911702949350505050565b60018111156137af5760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b606482015260840161099d565b816001600160a01b03851661380b5761380681600980546000838152600a60205260408120829055600182018355919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0155565b61382e565b836001600160a01b0316856001600160a01b03161461382e5761382e8582613c49565b6001600160a01b03841661384a5761384581613ce6565b611332565b846001600160a01b0316846001600160a01b031614611332576113328482613dbf565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291516000928392908816916138d19190614c93565b6000604051808303816000865af19150503d806000811461390e576040519150601f19603f3d011682016040523d82523d6000602084013e613913565b606091505b509150915081801561393d57508051158061393d57508080602001905181019061393d9190614796565b61396f5760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640161099d565b505050505050565b60006001600160a01b0384163b15613a7957604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906139bb903390899088908890600401614d1a565b602060405180830381600087803b1580156139d557600080fd5b505af1925050508015613a05575060408051601f3d908101601f19168201909252613a02918101906147ce565b60015b613a5f573d808015613a33576040519150601f19603f3d011682016040523d82523d6000602084013e613a38565b606091505b508051613a575760405162461bcd60e51b815260040161099d90614ed0565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612554565b506001612554565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310613ac05772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310613aec576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310613b0a57662386f26fc10000830492506010015b6305f5e1008310613b22576305f5e100830492506008015b6127108310613b3657612710830492506004015b60648310613b48576064830492506002015b600a83106108695760010192915050565b60008080613b6687613e03565b90508560020b8860020b1215613bc7576000613b8189613e03565b90508660020b8860020b1215613bad57613b9c81838761420e565b613ba69084615223565b9250613bc5565b613bb881878761420e565b613bc29084615223565b92505b505b8560020b8760020b1315613c085760008660020b8960020b13613bf457613bef8760016151bb565b613bf6565b885b9050613c048189848861425a565b9350505b8560020b8860020b13158015613c2357508560020b8760020b135b15613c3e57613c3b6001600160a01b03861683615223565b91505b509550959350505050565b60006001613c568461123f565b613c609190615323565b600083815260086020526040902054909150808214613cb3576001600160a01b03841660009081526007602090815260408083208584528252808320548484528184208190558352600890915290208190555b5060009182526008602090815260408084208490556001600160a01b039094168352600781528383209183525290812055565b600954600090613cf890600190615323565b6000838152600a602052604081205460098054939450909284908110613d2e57634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060098381548110613d5d57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152600a90915260408082208490558582528120556009805480613da357634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000613dca8361123f565b6001600160a01b039093166000908152600760209081526040808320868452825280832085905593825260089052919091209190915550565b60008060008360020b12613e1a578260020b613e27565b8260020b613e2790615412565b9050613e36620d89e7196153f1565b60020b811115613e6c5760405162461bcd60e51b81526020600482015260016024820152601560fa1b604482015260640161099d565b600060018216613e8057600160801b613e92565b6ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b031690506002821615613ec7576080613ec2826ffff97272373d413259a46990580e213a615275565b901c90505b6004821615613ef1576080613eec826ffff2e50f5f656932ef12357cf3c7fdcc615275565b901c90505b6008821615613f1b576080613f16826fffe5caca7e10e4e61c3624eaa0941cd0615275565b901c90505b6010821615613f45576080613f40826fffcb9843d60f6159c9db58835c926644615275565b901c90505b6020821615613f6f576080613f6a826fff973b41fa98c081472e6896dfb254c0615275565b901c90505b6040821615613f99576080613f94826fff2ea16466c96a3843ec78b326b52861615275565b901c90505b6080821615613fc3576080613fbe826ffe5dee046a99a2a811c461f1969c3053615275565b901c90505b610100821615613fee576080613fe9826ffcbe86c7900a88aedcffc83b479aa3a4615275565b901c90505b610200821615614019576080614014826ff987a7253ac413176f2b074cf7815e54615275565b901c90505b61040082161561404457608061403f826ff3392b0822b70005940c7a398e4b70f3615275565b901c90505b61080082161561406f57608061406a826fe7159475a2c29b7443b29c7fa6e889d9615275565b901c90505b61100082161561409a576080614095826fd097f3bdfd2022b8845ad8f792aa5825615275565b901c90505b6120008216156140c55760806140c0826fa9f746462d870fdf8a65dc1f90e061e5615275565b901c90505b6140008216156140f05760806140eb826f70d869a156d2a1b890bb3df62baf32f7615275565b901c90505b61800082161561411b576080614116826f31be135f97d08fd981231505542fcfa6615275565b901c90505b62010000821615614147576080614142826f09aa508b5b7a84e1c677de54f3e99bc9615275565b901c90505b6202000082161561417257608061416d826e5d6af8dedb81196699c329225ee604615275565b901c90505b6204000082161561419c576080614197826d2216e584f5fa1ea926041bedfe98615275565b901c90505b620800008216156141c45760806141bf826b048a170391f7dc42444e8fa2615275565b901c90505b60008460020b13156141df576141dc81600019615261565b90505b6141ee640100000000826153dd565b156141fa5760016141fd565b60005b6125549060ff16602083901c615223565b60008061421b8585615303565b9050600061422d600160601b85615303565b9050614250600160601b836001600160a01b0316836001600160a01b03166142d8565b9695505050505050565b60008061427a61426a8787615294565b6142759060016151bb565b613e03565b9050600061428c6142758760016151bb565b9050600061429a8584615303565b905060006142a88784615303565b90506142cb600160601b836001600160a01b0316836001600160a01b03166142d8565b9998505050505050505050565b60006142e5848484613693565b90506000828061430557634e487b7160e01b600052601260045260246000fd5b8486091115611ce957600019811061431c57600080fd5b80614326816153c2565b95945050505050565b82805461433b90615366565b90600052602060002090601f01602090048101928261435d57600085556143a3565b82601f106143765782800160ff198235161785556143a3565b828001600101855582156143a3579182015b828111156143a3578235825591602001919060010190614388565b506143af9291506143b3565b5090565b5b808211156143af57600081556001016143b4565b80356143d38161546e565b919050565b60008083601f8401126143e9578182fd5b5081356001600160401b038111156143ff578182fd5b60208301915083602082850101111561306357600080fd5b80356143d3816154a7565b80356143d3816154b6565b805161ffff811681146143d357600080fd5b803562ffffff811681146143d357600080fd5b600060208284031215614463578081fd5b8135611ce98161546e565b60006020828403121561447f578081fd5b8151611ce98161546e565b6000806040838503121561449c578081fd5b82356144a78161546e565b915060208301356144b78161546e565b809150509250929050565b6000806000606084860312156144d6578081fd5b83356144e18161546e565b925060208401356144f18161546e565b91506144ff6040850161443f565b90509250925092565b6000806000806080858703121561451d578182fd5b84356145288161546e565b935060208501356145388161546e565b92506145466040860161443f565b91506060850135614556816154a7565b939692955090935050565b600080600060608486031215614575578081fd5b83356145808161546e565b925060208401356145908161546e565b929592945050506040919091013590565b600080600080608085870312156145b6578182fd5b84356145c18161546e565b935060208501356145d18161546e565b92506040850135915060608501356001600160401b038111156145f2578182fd5b8501601f81018713614602578182fd5b803561461561461082615194565b615164565b818152886020838501011115614629578384fd5b81602084016020830137908101602001929092525092959194509250565b60008060408385031215614659578182fd5b82356146648161546e565b915060208301356144b781615483565b60008060408385031215614686578182fd5b82356146918161546e565b946020939093013593505050565b6000806000606084860312156146b3578081fd5b83356146be8161546e565b92506020840135915060408401356146d58161546e565b809150509250925092565b600080600080608085870312156146f5578182fd5b84356147008161546e565b9350602085013592506040850135614717816154b6565b91506060850135614556816154b6565b60008060208385031215614739578182fd5b82356001600160401b038082111561474f578384fd5b818501915085601f830112614762578384fd5b813581811115614770578485fd5b8660208260051b8501011115614784578485fd5b60209290920196919550909350505050565b6000602082840312156147a7578081fd5b8151611ce981615483565b6000602082840312156147c3578081fd5b8135611ce981615491565b6000602082840312156147df578081fd5b8151611ce981615491565b6000602082840312156147fb578081fd5b8135611ce9816154a7565b60008060208385031215614818578182fd5b82356001600160401b0381111561482d578283fd5b614839858286016143d8565b90969095509350505050565b600060208284031215614856578081fd5b81516001600160401b0381111561486b578182fd5b8201601f8101841361487b578182fd5b805161488961461082615194565b81815285602083850101111561489d578384fd5b61432682602083016020860161533a565b600060c08284031215610f76578081fd5b6000608082840312156148d0578081fd5b604051608081018181106001600160401b03821117156148f2576148f2615458565b60405282356149008161546e565b815260208301356149108161546e565b60208201526149216040840161443f565b604082015260608301356149348161546e565b60608201529392505050565b60006101608284031215610f76578081fd5b60006101608284031215614964578081fd5b61496c61513b565b614975836143c8565b8152614983602084016143c8565b6020820152614994604084016143c8565b60408201526149a56060840161443f565b60608201526149b660808401614417565b60808201526149c760a08401614417565b60a08201526149d860c08401614422565b60c08201526149e960e08401614422565b60e08201526101006149fc818501614422565b90820152610120614a0e848201614422565b90820152610140928301359281019290925250919050565b600060208284031215614a37578081fd5b8135611ce9816154b6565b600080600080600060a08688031215614a59578283fd5b8551614a64816154b6565b602087015160408801516060890151608090990151929a91995097965090945092505050565b600080600080600080600080610100898b031215614aa6578586fd5b8851614ab18161546e565b60208a0151909850614ac2816154a7565b9650614ad060408a0161442d565b9550614ade60608a0161442d565b9450614aec60808a0161442d565b935060a0890151614afc81615483565b60c08a0151909350614b0d816154b6565b60e08a0151909250614b1e816154b6565b809150509295985092959890939650565b600060208284031215614b40578081fd5b611ce98261443f565b600060208284031215614b5a578081fd5b5035919050565b600060208284031215614b72578081fd5b5051919050565b60008060408385031215614b8b578182fd5b8235915060208301356144b78161546e565b600080600080600060a08688031215614bb4578283fd5b853594506020860135614bc6816154b6565b94979496505050506040830135926060810135926080909101359150565b60008060408385031215614bf6578182fd5b505080516020909101519092909150565b60008060008060608587031215614c1c578182fd5b843593506020850135925060408501356001600160401b03811115614c3f578283fd5b614c4b878288016143d8565b95989497509550505050565b60008151808452614c6f81602086016020860161533a565b601f01601f19169290920160200192915050565b8183823760009101908152919050565b60008251614ca581846020870161533a565b9190910192915050565b60008351614cc181846020880161533a565b835190830190614cd581836020880161533a565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b03938416815291909216602082015262ffffff909116604082015260600190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061425090830184614c57565b6001600160a01b0386168152600285810b602083015284900b60408201526001600160801b038316606082015260a060808201819052600090614d9290830184614c57565b979650505050505050565b6001600160a01b039490941684526001600160801b039290921660208401526040830152606082015260800190565b6000602080830181845280855180835260408601915060408160051b8701019250838701855b82811015614e2057603f19888603018452614e0e858351614c57565b94509285019290850190600101614df2565b5092979650505050505050565b600293840b81529190920b60208201526001600160801b03909116604082015260600190565b602081526000611ce96020830184614c57565b602080825260039082015262783c7960e81b604082015260600190565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b602080825260029082015261262760f11b604082015260600190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6020808252600490820152632ca6a4a760e11b604082015260600190565b602080825260029082015261050360f41b604082015260600190565b6020808252600c908201526b139bdd08185c1c1c9bdd995960a21b604082015260600190565b60208082526010908201526f0ae8aa89072409cdee8408adcdeeaced60831b604082015260600190565b6020808252600490820152632c26a4a760e11b604082015260600190565b602080825260189082015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604082015260600190565b6020808252600b908201526a4f7574206f662074696d6560a81b604082015260600190565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff1690830152606092830151169181019190915260800190565b6000808335601e1984360301811261510d578283fd5b8301803591506001600160401b03821115615126578283fd5b60200191503681900382131561306357600080fd5b60405161016081016001600160401b038111828210171561515e5761515e615458565b60405290565b604051601f8201601f191681016001600160401b038111828210171561518c5761518c615458565b604052919050565b60006001600160401b038211156151ad576151ad615458565b50601f01601f191660200190565b60008160020b8360020b82821282627fffff038213811516156151e0576151e061542c565b82627fffff190382128116156151f8576151f861542c565b50019392505050565b60006001600160801b03828116848216808303821115614cd557614cd561542c565b600082198211156152365761523661542c565b500190565b60006001600160801b038381168061525557615255615442565b92169190910492915050565b60008261527057615270615442565b500490565b600081600019048311821515161561528f5761528f61542c565b500290565b60008160020b8360020b82811281627fffff19018312811516156152ba576152ba61542c565b81627fffff0183138116156152d1576152d161542c565b5090039392505050565b60006001600160801b03838116908316818110156152fb576152fb61542c565b039392505050565b60006001600160a01b03838116908316818110156152fb576152fb61542c565b6000828210156153355761533561542c565b500390565b60005b8381101561535557818101518382015260200161533d565b83811115611c3d5750506000910152565b600181811c9082168061537a57607f821691505b60208210811415610f7657634e487b7160e01b600052602260045260246000fd5b60006001600160801b03828116808214156153b8576153b861542c565b6001019392505050565b60006000198214156153d6576153d661542c565b5060010190565b6000826153ec576153ec615442565b500690565b60008160020b627fffff1981141561540b5761540b61542c565b9003919050565b6000600160ff1b8214156154285761542861542c565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146123a757600080fd5b80151581146123a757600080fd5b6001600160e01b0319811681146123a757600080fd5b8060020b81146123a757600080fd5b6001600160801b03811681146123a757600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220821891a2d1a4a49cd228ad217a041cc33292966a30637784cf13ceb7400c11fa64736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
-----Decoded View---------------
Arg [0] : factory (address): 0xc78fd8021FB191501E6BE7C1Da4bEafB1B81cF8C
Arg [1] : weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000c78fd8021fb191501e6be7c1da4beafb1b81cf8c
Arg [1] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.