Feature Tip: Add private address tag to any address under My Name Tag !
ERC-20
Overview
Max Total Supply
2,045,109.394741617267115021 ClipperLP
Holders
27
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Balance
0 ClipperLPValue
$0.00Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
ClipperApproximateCaravelExchange
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED // Copyright 2023 Shipyard Software, Inc. pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol"; import "./interfaces/WrapperContractInterface.sol"; import "./interfaces/TriageContractInterface.sol"; import "./ClipperCaravelExchange.sol"; contract ClipperApproximateCaravelExchange is ClipperCaravelExchange, ERC20Permit { using SafeERC20 for IERC20; uint256 constant ONE_IN_SIX_DECIMALS = 1e6; bool private _marketHalted; address public triageRole; error ClipperInvariant(); event TriageAddressChanged(address indexed newAddress); function tokenName() internal pure override returns (string memory) { return "Clipper LP Token"; } function tokenSymbol() internal pure override returns (string memory) { return "ClipperLP"; } constructor(address theSigner, address theWrapper, address[] memory tokens) ClipperCaravelExchange(theSigner, theWrapper, tokens) ERC20Permit(tokenSymbol()) { } /* Triage emergency functionality. owner can set an address that has the ability to halt trade. Only proportional withdrawals are allowed if trade is halted. */ function setTriageRole(address newTriage) external onlyOwner { triageRole = newTriage; emit TriageAddressChanged(newTriage); } function isTradeHalted() public view override returns (bool) { return _marketHalted; } function stopTrade() external { if(msg.sender==triageRole){ _marketHalted = true; } } function resumeTrade() external { if(msg.sender==triageRole){ _marketHalted = false; } } /* SWAP Functionality */ // checks timestamp // return value: qX, qY function unpackAndCheckInvariant(address inputToken, address outputToken, uint256 packedGoodUntil) internal view receivedInTime(uint256(uint32(packedGoodUntil))) returns (uint256 qX, uint256 qY) { (uint256 offchainX, uint256 offchainY, uint256 maximumX, uint256 minimumY) = unpackGoodUntil(packedGoodUntil); qX = getLastBalance(inputToken); qY = getLastBalance(outputToken); if(!checkInvariant(qX, qY, offchainX, offchainY, maximumX, minimumY)){ revert ClipperInvariant(); } } function checkInvariant(uint256 qX, uint256 qY, uint256 offchainX, uint256 offchainY, uint256 maximumX, uint256 minimumY) internal pure returns (bool) { /* Nine regions in quantity space: qX: -- A -- offchainX --- B --- maximumX -- C -- qY: -- 1 -- minimumY --- 2 ---- offchainY -- 3 -- C1 -> fail (too much qX AND too little qY) C2,C3 -> fail (too much qX) A1,B1 -> fail (too little qY) A3 -> succeed (no or exclusively beneficial change from offchain state) A2,B3 -> succeed (allowable within slippage) B2 -> complex linear case */ if(qY >= offchainY && qX <= offchainX){ // Region A3 return true; } else if(qY < minimumY || qX > maximumX) { // Regions C1, C2, C3, A1, B1 return false; } else { if(qY >= offchainY){ // Region B3 return true; } else if(qX <= offchainX) { // Region A2 return true; } else { // Region B2, complex linear case // qY is somewhere between minimumY and offchainY // qX is somewhere between offchainX and maximumX // between minimumY and offchainY, we go up maximumX - offchainX uint256 targetDiffX = ((ONE_IN_SIX_DECIMALS*(qY-minimumY)*(maximumX-offchainX))/(offchainY-minimumY))/ONE_IN_SIX_DECIMALS; return qX <= (offchainX + targetDiffX); } } } function unpackGoodUntil(uint256 packedGoodUntil) internal pure returns (uint256 offchainX, uint256 offchainY, uint256 maximumX, uint256 minimumY) { /* * Offchain balance input Token - uint96 * Offchain balance output Token - uint96 * Input multiplier - uint16 * Output multiplier - uint16 * Current good until value - uint32 - can be taken as uint256(uint32(packedGoodUntil)) */ // goodUntil = uint256(uint32(packedGoodUntil)); offchainX = uint256(packedGoodUntil >> 160); offchainY = uint256(uint96(packedGoodUntil >> 64)); uint256 rawMultX = uint256(uint16(packedGoodUntil >> 48)); uint256 rawMultY = uint256(uint16(packedGoodUntil >> 32)); maximumX = ((ONE_IN_SIX_DECIMALS+rawMultX)*offchainX)/ONE_IN_SIX_DECIMALS; minimumY = ((ONE_IN_SIX_DECIMALS-rawMultY)*offchainY)/ONE_IN_SIX_DECIMALS; } // Don't need a separate "transmit" function here since it's already payable // Gas optimized - no balance checks // Don't need fairOutput checks since exactly inputAmount is wrapped function sellEthForToken(address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external override marketIsRunning payable { /* CHECKS */ // Wrap ETH (as balance or value) as input. This will revert if insufficient balance is provided safeEthSend(WRAPPER_CONTRACT, inputAmount); // Revert if it's signed by the wrong address bytes32 digest = createSwapDigest(WRAPPER_CONTRACT, outputToken, inputAmount, outputAmount, goodUntil, destinationAddress); verifyDigestSignature(digest, theSignature); (uint256 qX, uint256 qY) = unpackAndCheckInvariant(WRAPPER_CONTRACT, outputToken, goodUntil); /* EFFECTS */ setBalance(WRAPPER_CONTRACT, qX+inputAmount); setBalance(outputToken, qY-outputAmount); /* INTERACTIONS */ IERC20(outputToken).safeTransfer(destinationAddress, outputAmount); emit Swapped(WRAPPER_CONTRACT, outputToken, destinationAddress, inputAmount, outputAmount, auxiliaryData); } // Mostly copied from gas-optimized swap functionality function sellTokenForEth(address inputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external override marketIsRunning { /* CHECKS */ // Revert if it's signed by the wrong address bytes32 digest = createSwapDigest(inputToken, WRAPPER_CONTRACT, inputAmount, outputAmount, goodUntil, destinationAddress); verifyDigestSignature(digest, theSignature); (uint256 qX, uint256 qY) = unpackAndCheckInvariant(inputToken, WRAPPER_CONTRACT, goodUntil); // Check that enough input token has been transmitted uint256 currentInputBalance = tokenBalance(inputToken); uint256 actualInput = currentInputBalance - qX; uint256 fairOutput = calculateFairOutput(inputAmount, actualInput, outputAmount); /* EFFECTS */ setBalance(inputToken, currentInputBalance); setBalance(WRAPPER_CONTRACT, qY-fairOutput); /* INTERACTIONS */ // Unwrap and forward ETH, without sync WrapperContractInterface(WRAPPER_CONTRACT).withdraw(fairOutput); safeEthSend(destinationAddress, fairOutput); emit Swapped(inputToken, WRAPPER_CONTRACT, destinationAddress, actualInput, fairOutput, auxiliaryData); } // Gas optimized, no balance checks // No need to check fairOutput since the inputToken pull works function transmitAndSellTokenForEth(address inputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external override marketIsRunning { /* CHECKS */ // Will revert if msg.sender has insufficient balance IERC20(inputToken).safeTransferFrom(msg.sender, address(this), inputAmount); // Revert if it's signed by the wrong address bytes32 digest = createSwapDigest(inputToken, WRAPPER_CONTRACT, inputAmount, outputAmount, goodUntil, destinationAddress); verifyDigestSignature(digest, theSignature); (uint256 qX, uint256 qY) = unpackAndCheckInvariant(inputToken, WRAPPER_CONTRACT, goodUntil); /* EFFECTS */ setBalance(inputToken, qX+inputAmount); setBalance(WRAPPER_CONTRACT, qY-outputAmount); /* INTERACTIONS */ // Unwrap and forward ETH, we've already updated the balance WrapperContractInterface(WRAPPER_CONTRACT).withdraw(outputAmount); safeEthSend(destinationAddress, outputAmount); emit Swapped(inputToken, WRAPPER_CONTRACT, destinationAddress, inputAmount, outputAmount, auxiliaryData); } // all-in-one transfer from msg.sender to destinationAddress. // Gas optimized - never checks balances // No need to check fairOutput since the inputToken pull works function transmitAndSwap(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external override marketIsRunning { /* CHECKS */ // Will revert if msg.sender has insufficient balance IERC20(inputToken).safeTransferFrom(msg.sender, address(this), inputAmount); // Revert if it's signed by the wrong address bytes32 digest = createSwapDigest(inputToken, outputToken, inputAmount, outputAmount, goodUntil, destinationAddress); verifyDigestSignature(digest, theSignature); (uint256 qX, uint256 qY) = unpackAndCheckInvariant(inputToken, outputToken, goodUntil); /* EFFECTS */ setBalance(inputToken, qX+inputAmount); setBalance(outputToken, qY-outputAmount); /* INTERACTIONS */ IERC20(outputToken).safeTransfer(destinationAddress, outputAmount); emit Swapped(inputToken, outputToken, destinationAddress, inputAmount, outputAmount, auxiliaryData); } // Gas optimized - single token balance check for input // output is dead-reckoned and scaled back if necessary function swap(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) public override marketIsRunning { /* CHECKS */ { // Avoid stack too deep // Revert if it's signed by the wrong address bytes32 digest = createSwapDigest(inputToken, outputToken, inputAmount, outputAmount, goodUntil, destinationAddress); verifyDigestSignature(digest, theSignature); } (uint256 qX, uint256 qY) = unpackAndCheckInvariant(inputToken, outputToken, goodUntil); // Get fair output value uint256 currentInputBalance = tokenBalance(inputToken); uint256 actualInput = currentInputBalance-qX; uint256 fairOutput = calculateFairOutput(inputAmount, actualInput, outputAmount); /* EFFECTS */ setBalance(inputToken, currentInputBalance); setBalance(outputToken, qY-fairOutput); /* INTERACTIONS */ IERC20(outputToken).safeTransfer(destinationAddress, fairOutput); emit Swapped(inputToken, outputToken, destinationAddress, actualInput, fairOutput, auxiliaryData); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _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.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/extensions/draft-ERC20Permit.sol) pragma solidity ^0.8.0; import "./draft-IERC20Permit.sol"; import "../ERC20.sol"; import "../../../utils/cryptography/ECDSA.sol"; import "../../../utils/cryptography/EIP712.sol"; import "../../../utils/Counters.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private constant _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`. * However, to ensure consistency with the upgradeable transpiler, we will continue * to reserve a slot. * @custom:oz-renamed-from _PERMIT_TYPEHASH */ // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT; /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.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.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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 * ==== * * [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://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; address private immutable _CACHED_THIS; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _CACHED_THIS = address(this); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. 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 10, 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 * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.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 `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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: UNLICENSED // Copyright 2023 Shipyard Software, Inc. pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; import "./interfaces/WrapperContractInterface.sol"; import "./ClipperCommonExchange.sol"; contract ClipperCaravelExchange is ClipperCommonExchange, Ownable { using SafeCast for uint256; using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.AddressSet; // Check for triage on swaps, deposits, and single-asset withdrawals error ClipperTradeHalted(); modifier marketIsRunning { if(isTradeHalted()){ revert ClipperTradeHalted(); } _; } modifier receivedInTime(uint256 goodUntil){ require(block.timestamp <= goodUntil, "Clipper: Expired"); _; } constructor(address theSigner, address theWrapper, address[] memory tokens) ClipperCommonExchange(theSigner, theWrapper, tokens) {} function isTradeHalted() public view virtual returns (bool) { return false; } function addAsset(address token) external onlyOwner { assetSet.add(token); _sync(token); } function tokenBalance(address token) internal view returns (uint256) { (bool success, bytes memory data) = token.staticcall(abi.encodeWithSelector(IERC20.balanceOf.selector, address(this))); require(success && data.length >= 32); return abi.decode(data, (uint256)); } function _sync(address token) internal virtual override { setBalance(token, tokenBalance(token)); } function confirmUnique(address token) internal view returns (uint32 newHash, uint256 currentBalance) { uint256 _current = lastBalances[token]; currentBalance = uint256(uint224(_current)); uint32 lastHash = uint32(_current >> 224); newHash = uint32(block.number+uint256(uint160(tx.origin))); require(newHash != lastHash, "Clipper: Failed tx uniqueness"); } function makeWriteValue(uint32 newHash, uint256 newBalance) internal pure returns (uint256) { return (uint256(newHash) << 224) + uint256(newBalance.toUint224()); } function setBalance(address token, uint256 newBalance) internal virtual { (uint32 newHash, ) = confirmUnique(token); lastBalances[token] = makeWriteValue(newHash, newBalance); } function increaseBalance(address token, uint256 increaseAmount) internal virtual { (uint32 newHash, uint256 curBalance) = confirmUnique(token); lastBalances[token] = makeWriteValue(newHash, curBalance+increaseAmount); } function decreaseBalance(address token, uint256 decreaseAmount) internal virtual { (uint32 newHash, uint256 curBalance) = confirmUnique(token); lastBalances[token] = makeWriteValue(newHash, curBalance-decreaseAmount); } function getLastBalance(address token) public view virtual override returns (uint256) { return uint256(uint224(lastBalances[token])); } // Can deposit raw ETH by attaching as msg.value function deposit(address sender, uint256[] calldata depositAmounts, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) public payable override marketIsRunning receivedInTime(goodUntil){ if(msg.value > 0){ safeEthSend(WRAPPER_CONTRACT, msg.value); } // Make sure the depositor is allowed require(msg.sender==sender, "Listed sender does not match msg.sender"); bytes32 depositDigest = createDepositDigest(sender, depositAmounts, nDays, poolTokens, goodUntil); // Revert if it's signed by the wrong address verifyDigestSignature(depositDigest, theSignature); // Check deposit amounts, syncing as we go uint i=0; uint n = depositAmounts.length; while(i < n){ uint256 allegedDeposit = depositAmounts[i]; if(allegedDeposit > 0){ address _token = tokenAt(i); uint256 currentBalance = tokenBalance(_token); require(currentBalance - getLastBalance(_token) >= allegedDeposit, "Insufficient token deposit"); setBalance(_token, currentBalance); } i++; } // OK now we're good _mintOrVesting(sender, nDays, poolTokens); emit Deposited(sender, poolTokens, nDays); } function depositSingleAsset(address sender, address inputToken, uint256 inputAmount, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) public payable override marketIsRunning receivedInTime(goodUntil){ if(msg.value > 0){ safeEthSend(WRAPPER_CONTRACT, msg.value); } // Make sure the depositor is allowed require(msg.sender==sender && isToken(inputToken), "Invalid input"); // Check the signature bytes32 depositDigest = createSingleDepositDigest(sender, inputToken, inputAmount, nDays, poolTokens, goodUntil); // Revert if it's signed by the wrong address verifyDigestSignature(depositDigest, theSignature); // Check deposit amount and sync balance uint256 currentBalance = tokenBalance(inputToken); require(currentBalance - getLastBalance(inputToken) >= inputAmount, "Insufficient token deposit"); // sync the balance setBalance(inputToken, currentBalance); // OK now we're good _mintOrVesting(sender, nDays, poolTokens); emit Deposited(sender, poolTokens, nDays); } /* WITHDRAWAL FUNCTIONALITY */ /* Single asset withdrawal functionality */ function withdrawSingleAsset(address tokenHolder, uint256 poolTokenAmountToBurn, address assetAddress, uint256 assetAmount, uint256 goodUntil, Signature calldata theSignature) external override marketIsRunning receivedInTime(goodUntil) { /* CHECKS */ require(msg.sender==tokenHolder, "tokenHolder does not match msg.sender"); bool sendEthBack; if(assetAddress == CLIPPER_ETH_SIGIL) { assetAddress = WRAPPER_CONTRACT; sendEthBack = true; } bytes32 withdrawalDigest = createWithdrawalDigest(tokenHolder, poolTokenAmountToBurn, assetAddress, assetAmount, goodUntil); // Reverts if it's signed by the wrong address verifyDigestSignature(withdrawalDigest, theSignature); /* EFFECTS */ // Reverts if pool token balance is insufficient _burn(msg.sender, poolTokenAmountToBurn); // Reverts if the pool's balance of the token is insufficient decreaseBalance(assetAddress, assetAmount); /* INTERACTIONS */ if(sendEthBack) { WrapperContractInterface(WRAPPER_CONTRACT).withdraw(assetAmount); safeEthSend(msg.sender, assetAmount); } else { IERC20(assetAddress).safeTransfer(msg.sender, assetAmount); } emit AssetWithdrawn(tokenHolder, poolTokenAmountToBurn, assetAddress, assetAmount); } /* SWAP Functionality */ // Don't need a separate "transmit" function here since it's already payable // Gas optimized - no balance checks // Don't need fairOutput checks since exactly inputAmount is wrapped function sellEthForToken(address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external virtual override marketIsRunning receivedInTime(goodUntil) payable { /* CHECKS */ require(isToken(outputToken), "Clipper: Invalid token"); // Wrap ETH (as balance or value) as input. This will revert if insufficient balance is provided safeEthSend(WRAPPER_CONTRACT, inputAmount); // Revert if it's signed by the wrong address bytes32 digest = createSwapDigest(WRAPPER_CONTRACT, outputToken, inputAmount, outputAmount, goodUntil, destinationAddress); verifyDigestSignature(digest, theSignature); /* EFFECTS */ increaseBalance(WRAPPER_CONTRACT, inputAmount); decreaseBalance(outputToken, outputAmount); /* INTERACTIONS */ IERC20(outputToken).safeTransfer(destinationAddress, outputAmount); emit Swapped(WRAPPER_CONTRACT, outputToken, destinationAddress, inputAmount, outputAmount, auxiliaryData); } // Mostly copied from gas-optimized swap functionality function sellTokenForEth(address inputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external virtual override marketIsRunning receivedInTime(goodUntil) { /* CHECKS */ require(isToken(inputToken), "Clipper: Invalid token"); // Revert if it's signed by the wrong address bytes32 digest = createSwapDigest(inputToken, WRAPPER_CONTRACT, inputAmount, outputAmount, goodUntil, destinationAddress); verifyDigestSignature(digest, theSignature); // Check that enough input token has been transmitted uint256 currentInputBalance = tokenBalance(inputToken); uint256 actualInput = currentInputBalance - getLastBalance(inputToken); uint256 fairOutput = calculateFairOutput(inputAmount, actualInput, outputAmount); /* EFFECTS */ setBalance(inputToken, currentInputBalance); decreaseBalance(WRAPPER_CONTRACT, fairOutput); /* INTERACTIONS */ // Unwrap and forward ETH, without sync WrapperContractInterface(WRAPPER_CONTRACT).withdraw(fairOutput); safeEthSend(destinationAddress, fairOutput); emit Swapped(inputToken, WRAPPER_CONTRACT, destinationAddress, actualInput, fairOutput, auxiliaryData); } function transmitAndDepositSingleAsset(address inputToken, uint256 inputAmount, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) external virtual override marketIsRunning receivedInTime(goodUntil){ // Make sure the depositor is allowed require(isToken(inputToken), "Invalid input"); // Will revert if msg.sender has insufficient balance IERC20(inputToken).safeTransferFrom(msg.sender, address(this), inputAmount); // Check the signature bytes32 depositDigest = createSingleDepositDigest(msg.sender, inputToken, inputAmount, nDays, poolTokens, goodUntil); // Revert if it's signed by the wrong address verifyDigestSignature(depositDigest, theSignature); // sync the deposited asset increaseBalance(inputToken, inputAmount); // OK now we're good _mintOrVesting(msg.sender, nDays, poolTokens); emit Deposited(msg.sender, poolTokens, nDays); } // Gas optimized, no balance checks // No need to check fairOutput since the inputToken pull works function transmitAndSellTokenForEth(address inputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external virtual override marketIsRunning receivedInTime(goodUntil) { /* CHECKS */ require(isToken(inputToken), "Clipper: Invalid token"); // Will revert if msg.sender has insufficient balance IERC20(inputToken).safeTransferFrom(msg.sender, address(this), inputAmount); // Revert if it's signed by the wrong address bytes32 digest = createSwapDigest(inputToken, WRAPPER_CONTRACT, inputAmount, outputAmount, goodUntil, destinationAddress); verifyDigestSignature(digest, theSignature); /* EFFECTS */ increaseBalance(inputToken, inputAmount); decreaseBalance(WRAPPER_CONTRACT, outputAmount); /* INTERACTIONS */ // Unwrap and forward ETH, we've already updated the balance WrapperContractInterface(WRAPPER_CONTRACT).withdraw(outputAmount); safeEthSend(destinationAddress, outputAmount); emit Swapped(inputToken, WRAPPER_CONTRACT, destinationAddress, inputAmount, outputAmount, auxiliaryData); } // all-in-one transfer from msg.sender to destinationAddress. // Gas optimized - never checks balances // No need to check fairOutput since the inputToken pull works function transmitAndSwap(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external virtual override marketIsRunning receivedInTime(goodUntil) { /* CHECKS */ require(isToken(inputToken) && isToken(outputToken), "Clipper: Invalid tokens"); // Will revert if msg.sender has insufficient balance IERC20(inputToken).safeTransferFrom(msg.sender, address(this), inputAmount); // Revert if it's signed by the wrong address bytes32 digest = createSwapDigest(inputToken, outputToken, inputAmount, outputAmount, goodUntil, destinationAddress); verifyDigestSignature(digest, theSignature); /* EFFECTS */ increaseBalance(inputToken, inputAmount); decreaseBalance(outputToken, outputAmount); /* INTERACTIONS */ IERC20(outputToken).safeTransfer(destinationAddress, outputAmount); emit Swapped(inputToken, outputToken, destinationAddress, inputAmount, outputAmount, auxiliaryData); } // Gas optimized - single token balance check for input // output is dead-reckoned and scaled back if necessary function swap(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) public virtual override marketIsRunning receivedInTime(goodUntil) { /* CHECKS */ require(isToken(inputToken) && isToken(outputToken), "Clipper: Invalid tokens"); { // Avoid stack too deep // Revert if it's signed by the wrong address bytes32 digest = createSwapDigest(inputToken, outputToken, inputAmount, outputAmount, goodUntil, destinationAddress); verifyDigestSignature(digest, theSignature); } // Get fair output value uint256 currentInputBalance = tokenBalance(inputToken); uint256 actualInput = currentInputBalance-getLastBalance(inputToken); uint256 fairOutput = calculateFairOutput(inputAmount, actualInput, outputAmount); /* EFFECTS */ setBalance(inputToken, currentInputBalance); decreaseBalance(outputToken, fairOutput); /* INTERACTIONS */ IERC20(outputToken).safeTransfer(destinationAddress, fairOutput); emit Swapped(inputToken, outputToken, destinationAddress, actualInput, fairOutput, auxiliaryData); } }
// SPDX-License-Identifier: UNLICENSED // Copyright 2023 Shipyard Software, Inc. pragma solidity ^0.8.0; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "./interfaces/WrapperContractInterface.sol"; abstract contract ClipperCommonExchange is ERC20, ReentrancyGuard { using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.AddressSet; struct Signature { uint8 v; bytes32 r; bytes32 s; } struct Deposit { uint lockedUntil; uint256 poolTokenAmount; } uint256 constant ONE_IN_TEN_DECIMALS = 1e10; // Allow for inputs up to 0.5% more than quoted values to have scaled output. // Inputs higher than this value just get 0.5% more. uint256 constant MAX_ALLOWED_OVER_TEN_DECIMALS = ONE_IN_TEN_DECIMALS+50*1e6; // Signer is passed in on construction, hence "immutable" address immutable public DESIGNATED_SIGNER; address immutable public WRAPPER_CONTRACT; // Constant values for EIP-712 signing bytes32 immutable DOMAIN_SEPARATOR; string constant VERSION = "1.0.0"; string constant NAME = "ClipperDirect"; address constant CLIPPER_ETH_SIGIL = address(0); bytes32 constant EIP712DOMAIN_TYPEHASH = keccak256( abi.encodePacked("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)") ); bytes32 constant OFFERSTRUCT_TYPEHASH = keccak256( abi.encodePacked("OfferStruct(address input_token,address output_token,uint256 input_amount,uint256 output_amount,uint256 good_until,address destination_address)") ); bytes32 constant DEPOSITSTRUCT_TYPEHASH = keccak256( abi.encodePacked("DepositStruct(address sender,uint256[] deposit_amounts,uint256 days_locked,uint256 pool_tokens,uint256 good_until)") ); bytes32 constant SINGLEDEPOSITSTRUCT_TYPEHASH = keccak256( abi.encodePacked("SingleDepositStruct(address sender,address token,uint256 amount,uint256 days_locked,uint256 pool_tokens,uint256 good_until)") ); bytes32 constant WITHDRAWALSTRUCT_TYPEHASH = keccak256( abi.encodePacked("WithdrawalStruct(address token_holder,uint256 pool_token_amount_to_burn,address asset_address,uint256 asset_amount,uint256 good_until)") ); // Assets // lastBalances: used for "transmit then swap then sync" modality // assetSet is a set of keys that have lastBalances mapping(address => uint256) public lastBalances; EnumerableSet.AddressSet assetSet; // Allows lookup mapping(address => Deposit) public vestingDeposits; // Events event Swapped( address indexed inAsset, address indexed outAsset, address indexed recipient, uint256 inAmount, uint256 outAmount, bytes auxiliaryData ); event Deposited( address indexed depositor, uint256 poolTokens, uint256 nDays ); event Withdrawn( address indexed withdrawer, uint256 poolTokens, uint256 fractionOfPool ); event AssetWithdrawn( address indexed withdrawer, uint256 poolTokens, address indexed assetAddress, uint256 assetAmount ); error ClipperDataValidation(); function tokenName() internal pure virtual returns (string memory) { return "ClipperDirect Pool Token"; } function tokenSymbol() internal pure virtual returns (string memory) { return "CLPRDRPL"; } // Take in the designated signer address and the token list constructor(address theSigner, address theWrapper, address[] memory tokens) ERC20(tokenName(), tokenSymbol()) { DESIGNATED_SIGNER = theSigner; uint i; uint n = tokens.length; while(i < n) { assetSet.add(tokens[i]); i++; } DOMAIN_SEPARATOR = createDomainSeparator(NAME, VERSION, address(this)); WRAPPER_CONTRACT = theWrapper; } // Allows the receipt of ETH directly receive() external payable { } function safeEthSend(address recipient, uint256 howMuch) internal { (bool success, ) = payable(recipient).call{value: howMuch}(""); require(success, "Call with value failed"); } /* TOKEN AND ASSET FUNCTIONS */ function nTokens() public view returns (uint) { return assetSet.length(); } function tokenAt(uint i) public view returns (address) { return assetSet.at(i); } function isToken(address token) public view returns (bool) { return assetSet.contains(token); } function _sync(address token) internal virtual; // Can be overridden as in Caravel function getLastBalance(address token) public view virtual returns (uint256) { return lastBalances[token]; } function allTokensBalance() external view returns (uint256[] memory, address[] memory, uint256){ uint n = nTokens(); uint256[] memory balances = new uint256[](n); address[] memory tokens = new address[](n); for (uint i = 0; i < n; i++) { address token = tokenAt(i); balances[i] = getLastBalance(token); tokens[i] = token; } return (balances, tokens, totalSupply()); } // nonReentrant asset transfer function transferAsset(address token, address recipient, uint256 amount) internal nonReentrant { IERC20(token).safeTransfer(recipient, amount); // We never want to transfer an asset without sync'ing _sync(token); } function calculateFairOutput(uint256 statedInput, uint256 actualInput, uint256 statedOutput) internal pure returns (uint256) { if(actualInput == statedInput) { return statedOutput; } else { uint256 theFraction = (ONE_IN_TEN_DECIMALS*actualInput)/statedInput; if(theFraction >= MAX_ALLOWED_OVER_TEN_DECIMALS) { return (MAX_ALLOWED_OVER_TEN_DECIMALS*statedOutput)/ONE_IN_TEN_DECIMALS; } else { return (theFraction*statedOutput)/ONE_IN_TEN_DECIMALS; } } } /* DEPOSIT FUNCTIONALITY */ function canUnlockDeposit(address theAddress) public view returns (bool) { Deposit storage myDeposit = vestingDeposits[theAddress]; return (myDeposit.poolTokenAmount > 0) && (myDeposit.lockedUntil <= block.timestamp); } function unlockDeposit() external returns (uint256 poolTokens) { require(canUnlockDeposit(msg.sender), "ClipperDirect: Deposit cannot be unlocked"); poolTokens = vestingDeposits[msg.sender].poolTokenAmount; delete vestingDeposits[msg.sender]; _transfer(address(this), msg.sender, poolTokens); } function _mintOrVesting(address sender, uint256 nDays, uint256 poolTokens) internal { if(nDays==0){ // No vesting period required - mint tokens directly for the user _mint(sender, poolTokens); } else { // Set up a vesting deposit for the sender _createVestingDeposit(sender, nDays, poolTokens); } } // Mints tokens to this contract to hold for vesting function _createVestingDeposit(address theAddress, uint256 nDays, uint256 numPoolTokens) internal { require(nDays > 0, "ClipperDirect: Cannot create vesting deposit without positive vesting period"); require(vestingDeposits[theAddress].poolTokenAmount==0, "ClipperDirect: Depositor already has an active deposit"); Deposit memory myDeposit = Deposit({ lockedUntil: block.timestamp + (nDays * 1 days), poolTokenAmount: numPoolTokens }); vestingDeposits[theAddress] = myDeposit; _mint(address(this), numPoolTokens); } function transmitAndDeposit(uint256[] calldata depositAmounts, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) external { uint i=0; uint n = depositAmounts.length; while(i < n){ uint256 transferAmount = depositAmounts[i]; if(transferAmount > 0){ IERC20(tokenAt(i)).safeTransferFrom(msg.sender, address(this), transferAmount); } i++; } deposit(msg.sender, depositAmounts, nDays, poolTokens, goodUntil, theSignature); } function transmitAndDepositSingleAsset(address inputToken, uint256 inputAmount, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) external virtual; function deposit(address sender, uint256[] calldata depositAmounts, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) public payable virtual; function depositSingleAsset(address sender, address inputToken, uint256 inputAmount, uint256 nDays, uint256 poolTokens, uint256 goodUntil, Signature calldata theSignature) public payable virtual; /* WITHDRAWAL FUNCTIONALITY */ function _proportionalWithdrawal(uint256 myFraction) internal { uint256 toTransfer; uint i; uint n = nTokens(); while(i < n) { address theToken = tokenAt(i); toTransfer = (myFraction*getLastBalance(theToken)) / ONE_IN_TEN_DECIMALS; // syncs done automatically on transfer transferAsset(theToken, msg.sender, toTransfer); i++; } } function burnToWithdraw(uint256 amount) external { // Capture the fraction first, before burning uint256 theFractionBaseTen = (ONE_IN_TEN_DECIMALS*amount)/totalSupply(); // Reverts if balance is insufficient _burn(msg.sender, amount); _proportionalWithdrawal(theFractionBaseTen); emit Withdrawn(msg.sender, amount, theFractionBaseTen); } function withdrawSingleAsset(address tokenHolder, uint256 poolTokenAmountToBurn, address assetAddress, uint256 assetAmount, uint256 goodUntil, Signature calldata theSignature) external virtual; /* SWAP Functionality: Virtual */ function sellEthForToken(address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external payable virtual; function sellTokenForEth(address inputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external virtual; function transmitAndSellTokenForEth(address inputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external virtual; function transmitAndSwap(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) external virtual; function swap(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress, Signature calldata theSignature, bytes calldata auxiliaryData) public virtual; /* SIGNING Functionality */ function createDomainSeparator(string memory name, string memory version, address theSigner) internal view returns (bytes32) { return keccak256(abi.encode( EIP712DOMAIN_TYPEHASH, keccak256(abi.encodePacked(name)), keccak256(abi.encodePacked(version)), uint256(block.chainid), theSigner )); } function hashInputOffer(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress) internal pure returns (bytes32) { return keccak256(abi.encode( OFFERSTRUCT_TYPEHASH, inputToken, outputToken, inputAmount, outputAmount, goodUntil, destinationAddress )); } function hashDeposit(address sender, uint256[] calldata depositAmounts, uint256 daysLocked, uint256 poolTokens, uint256 goodUntil) internal pure returns (bytes32) { bytes32 depositAmountsHash = keccak256(abi.encodePacked(depositAmounts)); return keccak256(abi.encode( DEPOSITSTRUCT_TYPEHASH, sender, depositAmountsHash, daysLocked, poolTokens, goodUntil )); } function hashSingleDeposit(address sender, address inputToken, uint256 inputAmount, uint256 daysLocked, uint256 poolTokens, uint256 goodUntil) internal pure returns (bytes32) { return keccak256(abi.encode( SINGLEDEPOSITSTRUCT_TYPEHASH, sender, inputToken, inputAmount, daysLocked, poolTokens, goodUntil )); } function hashWithdrawal(address tokenHolder, uint256 poolTokenAmountToBurn, address assetAddress, uint256 assetAmount, uint256 goodUntil) internal pure returns (bytes32) { return keccak256(abi.encode( WITHDRAWALSTRUCT_TYPEHASH, tokenHolder, poolTokenAmountToBurn, assetAddress, assetAmount, goodUntil )); } function createSwapDigest(address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 goodUntil, address destinationAddress) internal view returns (bytes32 digest){ bytes32 hashedInput = hashInputOffer(inputToken, outputToken, inputAmount, outputAmount, goodUntil, destinationAddress); digest = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR, hashedInput); } function createDepositDigest(address sender, uint256[] calldata depositAmounts, uint256 nDays, uint256 poolTokens, uint256 goodUntil) internal view returns (bytes32 depositDigest){ bytes32 hashedInput = hashDeposit(sender, depositAmounts, nDays, poolTokens, goodUntil); depositDigest = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR, hashedInput); } function createSingleDepositDigest(address sender, address inputToken, uint256 inputAmount, uint256 nDays, uint256 poolTokens, uint256 goodUntil) internal view returns (bytes32 depositDigest){ bytes32 hashedInput = hashSingleDeposit(sender, inputToken, inputAmount, nDays, poolTokens, goodUntil); depositDigest = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR, hashedInput); } function createWithdrawalDigest(address tokenHolder, uint256 poolTokenAmountToBurn, address assetAddress, uint256 assetAmount, uint256 goodUntil) internal view returns (bytes32 withdrawalDigest){ bytes32 hashedInput = hashWithdrawal(tokenHolder, poolTokenAmountToBurn, assetAddress, assetAmount, goodUntil); withdrawalDigest = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR, hashedInput); } function verifyDigestSignature(bytes32 theDigest, Signature calldata theSignature) internal view { address signingAddress = ECDSA.recover(theDigest, theSignature.v, theSignature.r, theSignature.s); if(signingAddress != DESIGNATED_SIGNER){ // Check for signing with embedded tx.origin signingAddress = ECDSA.recover(keccak256(abi.encodePacked(theDigest, tx.origin)), theSignature.v, theSignature.r, theSignature.s); if(signingAddress != DESIGNATED_SIGNER){ revert ClipperDataValidation(); } } } }
// SPDX-License-Identifier: UNLICENSED // Copyright 2023 Shipyard Software, Inc. pragma solidity ^0.8.0; interface TriageContractInterface { function actionsAllowed() external view returns (bool); }
// SPDX-License-Identifier: UNLICENSED // Copyright 2023 Shipyard Software, Inc. pragma solidity ^0.8.0; interface WrapperContractInterface { function withdraw(uint256 amount) external; }
{ "optimizer": { "enabled": true, "runs": 1000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"theSigner","type":"address"},{"internalType":"address","name":"theWrapper","type":"address"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ClipperDataValidation","type":"error"},{"inputs":[],"name":"ClipperInvariant","type":"error"},{"inputs":[],"name":"ClipperTradeHalted","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolTokens","type":"uint256"},{"indexed":true,"internalType":"address","name":"assetAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"assetAmount","type":"uint256"}],"name":"AssetWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"depositor","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolTokens","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nDays","type":"uint256"}],"name":"Deposited","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":"inAsset","type":"address"},{"indexed":true,"internalType":"address","name":"outAsset","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"inAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"outAmount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"auxiliaryData","type":"bytes"}],"name":"Swapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAddress","type":"address"}],"name":"TriageAddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":false,"internalType":"uint256","name":"poolTokens","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fractionOfPool","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"DESIGNATED_SIGNER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WRAPPER_CONTRACT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"addAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allTokensBalance","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnToWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"theAddress","type":"address"}],"name":"canUnlockDeposit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256[]","name":"depositAmounts","type":"uint256[]"},{"internalType":"uint256","name":"nDays","type":"uint256"},{"internalType":"uint256","name":"poolTokens","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"nDays","type":"uint256"},{"internalType":"uint256","name":"poolTokens","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"}],"name":"depositSingleAsset","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getLastBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isTradeHalted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resumeTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"internalType":"address","name":"destinationAddress","type":"address"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"},{"internalType":"bytes","name":"auxiliaryData","type":"bytes"}],"name":"sellEthForToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"internalType":"address","name":"destinationAddress","type":"address"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"},{"internalType":"bytes","name":"auxiliaryData","type":"bytes"}],"name":"sellTokenForEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTriage","type":"address"}],"name":"setTriageRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stopTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"internalType":"address","name":"destinationAddress","type":"address"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"},{"internalType":"bytes","name":"auxiliaryData","type":"bytes"}],"name":"swap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"i","type":"uint256"}],"name":"tokenAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"depositAmounts","type":"uint256[]"},{"internalType":"uint256","name":"nDays","type":"uint256"},{"internalType":"uint256","name":"poolTokens","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"}],"name":"transmitAndDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"nDays","type":"uint256"},{"internalType":"uint256","name":"poolTokens","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"}],"name":"transmitAndDepositSingleAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"internalType":"address","name":"destinationAddress","type":"address"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"},{"internalType":"bytes","name":"auxiliaryData","type":"bytes"}],"name":"transmitAndSellTokenForEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"internalType":"address","name":"destinationAddress","type":"address"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"},{"internalType":"bytes","name":"auxiliaryData","type":"bytes"}],"name":"transmitAndSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"triageRole","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unlockDeposit","outputs":[{"internalType":"uint256","name":"poolTokens","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"vestingDeposits","outputs":[{"internalType":"uint256","name":"lockedUntil","type":"uint256"},{"internalType":"uint256","name":"poolTokenAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenHolder","type":"address"},{"internalType":"uint256","name":"poolTokenAmountToBurn","type":"uint256"},{"internalType":"address","name":"assetAddress","type":"address"},{"internalType":"uint256","name":"assetAmount","type":"uint256"},{"internalType":"uint256","name":"goodUntil","type":"uint256"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ClipperCommonExchange.Signature","name":"theSignature","type":"tuple"}],"name":"withdrawSingleAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
6101a06040523480156200001257600080fd5b506040516200503e3803806200503e833981016040819052620000359162000487565b6040805180820190915260098152680436c69707065724c560bc1b60208201526040805180820190915260018152603160f81b60208201528190858585828282620000a360408051808201909152601081526f21b634b83832b9102628102a37b5b2b760811b602082015290565b6040805180820190915260098152680436c69707065724c560bc1b60208201526003620000d1838262000610565b506004620000e0828262000610565b50506001600555506001600160a01b03831660805280516000905b808210156200014c57620001368383815181106200011d576200011d620006dc565b602002602001015160076200023260201b90919060201c565b50816200014381620006f2565b925050620000fb565b620001a16040518060400160405280600d81526020016c10db1a5c1c195c911a5c9958dd609a1b815250604051806040016040528060058152602001640312e302e360dc1b815250306200025260201b60201c565b60c0525050506001600160a01b031660a05250620001bf3362000380565b5050825160208085019190912083519184019190912061014082905261016081905246610100529091507f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f62000217818484620003d2565b60e052306101205261018052506200074b9650505050505050565b600062000249836001600160a01b03841662000402565b90505b92915050565b6000604051602001620002c9907f454950373132446f6d61696e28737472696e67206e616d652c737472696e672081527f76657273696f6e2c75696e7432353620636861696e49642c6164647265737320602082015271766572696679696e67436f6e74726163742960701b604082015260520190565b6040516020818303038152906040528051906020012084604051602001620002f291906200071a565b60405160208183030381529060405280519060200120846040516020016200031b91906200071a565b60408051601f1981840301815282825280516020918201209083019490945281019190915260608101919091524660808201526001600160a01b03831660a082015260c0015b6040516020818303038152906040528051906020012090509392505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040805160208101859052908101839052606081018290524660808201523060a082015260009060c00162000361565b60008181526001830160205260408120546200044b575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200024c565b5060006200024c565b80516001600160a01b03811681146200046c57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156200049d57600080fd5b620004a88462000454565b92506020620004b981860162000454565b60408601519093506001600160401b0380821115620004d757600080fd5b818701915087601f830112620004ec57600080fd5b81518181111562000501576200050162000471565b8060051b604051601f19603f8301168101818110858211171562000529576200052962000471565b60405291825284820192508381018501918a8311156200054857600080fd5b938501935b828510156200057157620005618562000454565b845293850193928501926200054d565b8096505050505050509250925092565b600181811c908216806200059657607f821691505b602082108103620005b757634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200060b57600081815260208120601f850160051c81016020861015620005e65750805b601f850160051c820191505b818110156200060757828155600101620005f2565b5050505b505050565b81516001600160401b038111156200062c576200062c62000471565b62000644816200063d845462000581565b84620005bd565b602080601f8311600181146200067c5760008415620006635750858301515b600019600386901b1c1916600185901b17855562000607565b600085815260208120601f198616915b82811015620006ad578886015182559484019460019091019084016200068c565b5085821015620006cc5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052603260045260246000fd5b6000600182016200071357634e487b7160e01b600052601160045260246000fd5b5060010190565b6000825160005b818110156200073d576020818601810151858301520162000721565b506000920191825250919050565b60805160a05160c05160e05161010051610120516101405161016051610180516147e8620008566000396000612baa01526000612bf901526000612bd401526000612b2d01526000612b5701526000612b8101526000818161259c0152612e8a0152600081816105c101528181610b8301528181610baf01528181610bec01528181610c1c01528181610c8201528181611168015281816111a50152818161120701528181611246015281816112c00152818161139a0152818161169b0152818161170a0152818161189501528181611c9f01528181611cdc01528181611d1901528181611d580152611dd20152600081816106de0152818161261201526126a301526147e86000f3fe6080604052600436106102f65760003560e01c80635aecdda51161018f578063a457c2d7116100e1578063d505accf1161008a578063eb1c645311610064578063eb1c6453146108a9578063ecc7633d146108c9578063f2fde38b146108f657600080fd5b8063d505accf1461081e578063da5014c51461083e578063dd62ed3e1461086357600080fd5b8063c325a549116100bb578063c325a54914610795578063c72da66a146107de578063ceaf4339146107fe57600080fd5b8063a457c2d714610735578063a9059cbb14610755578063c0d5ebfd1461077557600080fd5b806387e08c25116101435780638dda8f3f1161011d5780638dda8f3f146106cc57806392a91a3a1461070057806395d89b411461072057600080fd5b806387e08c25146106865780638baeefce146106995780638da5cb5b146106ae57600080fd5b806370a082311161017457806370a082311461061b578063715018a6146106515780637ecebe001461066657600080fd5b80635aecdda5146105af57806362fb4e01146105fb57600080fd5b80632b651a6c11610248578063368dfc18116101fc5780633b26e4eb116101d65780633b26e4eb1461055c5780634cb6864c1461057c5780635250d7301461059c57600080fd5b8063368dfc1814610507578063377a368c14610527578063395093511461053c57600080fd5b8063313ce5671161022d578063313ce5671461049757806334cb3d7f146104b35780633644e515146104f257600080fd5b80632b651a6c146104625780632e7e1bd31461048257600080fd5b80631dc6f5a5116102aa57806327a9b4241161028457806327a9b4241461040d578063298410e51461042257806329d0c8fc1461044257600080fd5b80631dc6f5a5146103b157806323b872dd146103d557806326d9b5b3146103f557600080fd5b806318160ddd116102db57806318160ddd1461035d57806319f373611461037c5780631b6a87591461039c57600080fd5b806306fdde0314610302578063095ea7b31461032d57600080fd5b366102fd57005b600080fd5b34801561030e57600080fd5b50610317610916565b6040516103249190613fc8565b60405180910390f35b34801561033957600080fd5b5061034d610348366004614017565b6109a8565b6040519015158152602001610324565b34801561036957600080fd5b506002545b604051908152602001610324565b34801561038857600080fd5b5061034d610397366004614041565b6109c2565b3480156103a857600080fd5b5061036e6109cf565b3480156103bd57600080fd5b506103c66109e0565b6040516103249392919061405c565b3480156103e157600080fd5b5061034d6103f03660046140e9565b610b34565b34801561040157600080fd5b50600d5460ff1661034d565b61042061041b366004614180565b610b5a565b005b34801561042e57600080fd5b5061042061043d366004614041565b610cf4565b34801561044e57600080fd5b5061042061045d36600461425a565b610d14565b34801561046e57600080fd5b5061042061047d3660046142ca565b610d92565b34801561048e57600080fd5b50610420610ea6565b3480156104a357600080fd5b5060405160128152602001610324565b3480156104bf57600080fd5b5061036e6104ce366004614041565b6001600160a01b03166000908152600660205260409020546001600160e01b031690565b3480156104fe57600080fd5b5061036e610eca565b34801561051357600080fd5b50610420610522366004614372565b610ed4565b34801561053357600080fd5b5061036e610f4c565b34801561054857600080fd5b5061034d610557366004614017565b610ffc565b34801561056857600080fd5b506104206105773660046142ca565b61103b565b34801561058857600080fd5b50610420610597366004614180565b61113c565b6104206105aa36600461438b565b611327565b3480156105bb57600080fd5b506105e37f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610324565b34801561060757600080fd5b5061042061061636600461440e565b6115a2565b34801561062757600080fd5b5061036e610636366004614041565b6001600160a01b031660009081526020819052604090205490565b34801561065d57600080fd5b506104206117f2565b34801561067257600080fd5b5061036e610681366004614041565b611804565b610420610694366004614463565b611822565b3480156106a557600080fd5b50610420611a21565b3480156106ba57600080fd5b50600a546001600160a01b03166105e3565b3480156106d857600080fd5b506105e37f000000000000000000000000000000000000000000000000000000000000000081565b34801561070c57600080fd5b506105e361071b366004614372565b611a47565b34801561072c57600080fd5b50610317611a54565b34801561074157600080fd5b5061034d610750366004614017565b611a63565b34801561076157600080fd5b5061034d610770366004614017565b611b18565b34801561078157600080fd5b506104206107903660046144c1565b611b26565b3480156107a157600080fd5b506107c96107b0366004614041565b6009602052600090815260409020805460019091015482565b60408051928352602083019190915201610324565b3480156107ea57600080fd5b506104206107f9366004614180565b611c5e565b34801561080a57600080fd5b50610420610819366004614041565b611e39565b34801561082a57600080fd5b50610420610839366004614520565b611eaa565b34801561084a57600080fd5b50600d546105e39061010090046001600160a01b031681565b34801561086f57600080fd5b5061036e61087e36600461458a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b3480156108b557600080fd5b5061034d6108c4366004614041565b61200e565b3480156108d557600080fd5b5061036e6108e4366004614041565b60066020526000908152604090205481565b34801561090257600080fd5b50610420610911366004614041565b61203e565b606060038054610925906145bd565b80601f0160208091040260200160405190810160405280929190818152602001828054610951906145bd565b801561099e5780601f106109735761010080835404028352916020019161099e565b820191906000526020600020905b81548152906001019060200180831161098157829003601f168201915b5050505050905090565b6000336109b68185856120cb565b60019150505b92915050565b60006109bc600783612223565b60006109db6007612245565b905090565b6060806000806109ee6109cf565b905060008167ffffffffffffffff811115610a0b57610a0b6145f1565b604051908082528060200260200182016040528015610a34578160200160208202803683370190505b50905060008267ffffffffffffffff811115610a5257610a526145f1565b604051908082528060200260200182016040528015610a7b578160200160208202803683370190505b50905060005b83811015610b1a576000610a9482611a47565b9050610abe816001600160a01b03166000908152600660205260409020546001600160e01b031690565b848381518110610ad057610ad0614607565b60200260200101818152505080838381518110610aef57610aef614607565b6001600160a01b03909216602092830291909101909101525080610b1281614633565b915050610a81565b508181610b2660025490565b955095509550505050909192565b600033610b4285828561224f565b610b4d8585856122e1565b60019150505b9392505050565b600d5460ff1615610b7e576040516340a47f0360e11b815260040160405180910390fd5b610ba87f0000000000000000000000000000000000000000000000000000000000000000886124ce565b6000610bd87f00000000000000000000000000000000000000000000000000000000000000008a8a8a8a8a612576565b9050610be481856125ec565b600080610c127f00000000000000000000000000000000000000000000000000000000000000008c8a61270c565b9092509050610c4a7f0000000000000000000000000000000000000000000000000000000000000000610c458c8561464c565b612815565b610c588b610c458b8461465f565b610c6c6001600160a01b038c16888b61284e565b866001600160a01b03168b6001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03167f4be05c8d54f5e056ab2cfa033e9f582057001268c3e28561bb999d35d2c8f2c88d8d8a8a604051610cdf9493929190614672565b60405180910390a45050505050505050505050565b610cfc6128e2565b610d0760078261293c565b50610d1181612951565b50565b6000855b80821015610d79576000888884818110610d3457610d34614607565b9050602002013590506000811115610d6657610d66333083610d5587611a47565b6001600160a01b031692919061295e565b82610d7081614633565b93505050610d18565b610d8833898989898989611327565b5050505050505050565b600d5460ff1615610db6576040516340a47f0360e11b815260040160405180910390fd5b6000610dc68a8a8a8a8a8a612576565b9050610dd281856125ec565b50600080610de18b8b8961270c565b915091506000610df08c6129af565b90506000610dfe848361465f565b90506000610e0d8c838d612a98565b9050610e198e84612815565b610e278d610c45838761465f565b610e3b6001600160a01b038e168a8361284e565b886001600160a01b03168d6001600160a01b03168f6001600160a01b03167f4be05c8d54f5e056ab2cfa033e9f582057001268c3e28561bb999d35d2c8f2c885858c8c604051610e8e9493929190614672565b60405180910390a45050505050505050505050505050565b600d5461010090046001600160a01b03163303610ec857600d805460ff191690555b565b60006109db612b20565b6000610edf60025490565b610eee836402540be4006146af565b610ef891906146c6565b9050610f043383612c47565b610f0d81612db0565b604080518381526020810183905233917f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6910160405180910390a25050565b6000610f573361200e565b610fce5760405162461bcd60e51b815260206004820152602960248201527f436c69707065724469726563743a204465706f7369742063616e6e6f7420626560448201527f20756e6c6f636b6564000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b50336000818152600960205260408120600181018054918390559190915590610ff9903090836122e1565b90565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906109b6908290869061103690879061464c565b6120cb565b600d5460ff161561105f576040516340a47f0360e11b815260040160405180910390fd5b6110746001600160a01b038a1633308a61295e565b60006110848a8a8a8a8a8a612576565b905061109081856125ec565b60008061109e8c8c8a61270c565b90925090506110b18c610c458c8561464c565b6110bf8b610c458b8461465f565b6110d36001600160a01b038c16888b61284e565b866001600160a01b03168b6001600160a01b03168d6001600160a01b03167f4be05c8d54f5e056ab2cfa033e9f582057001268c3e28561bb999d35d2c8f2c88d8d8a8a6040516111269493929190614672565b60405180910390a4505050505050505050505050565b600d5460ff1615611160576040516340a47f0360e11b815260040160405180910390fd5b6000611190897f00000000000000000000000000000000000000000000000000000000000000008a8a8a8a612576565b905061119c81856125ec565b6000806111ca8b7f00000000000000000000000000000000000000000000000000000000000000008a61270c565b9150915060006111d98c6129af565b905060006111e7848361465f565b905060006111f68d838e612a98565b90506112028e84612815565b6112307f0000000000000000000000000000000000000000000000000000000000000000610c45838761465f565b604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561129257600080fd5b505af11580156112a6573d6000803e3d6000fd5b505050506112b48a826124ce565b896001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168f6001600160a01b03167f4be05c8d54f5e056ab2cfa033e9f582057001268c3e28561bb999d35d2c8f2c885858d8d604051610e8e9493929190614672565b600d5460ff161561134b576040516340a47f0360e11b815260040160405180910390fd5b818042111561138f5760405162461bcd60e51b815260206004820152601060248201526f10db1a5c1c195c8e88115e1c1a5c995960821b6044820152606401610fc5565b34156113bf576113bf7f0000000000000000000000000000000000000000000000000000000000000000346124ce565b336001600160a01b0389161461143d5760405162461bcd60e51b815260206004820152602760248201527f4c69737465642073656e64657220646f6573206e6f74206d61746368206d736760448201527f2e73656e646572000000000000000000000000000000000000000000000000006064820152608401610fc5565b600061144d898989898989612e37565b905061145981846125ec565b6000875b808210156115465760008a8a8481811061147957611479614607565b905060200201359050600081111561153357600061149684611a47565b905060006114a3826129af565b9050826114ce836001600160a01b03166000908152600660205260409020546001600160e01b031690565b6114d8908361465f565b10156115265760405162461bcd60e51b815260206004820152601a60248201527f496e73756666696369656e7420746f6b656e206465706f7369740000000000006044820152606401610fc5565b6115308282612815565b50505b8261153d81614633565b9350505061145d565b6115518b8989612e48565b60408051888152602081018a90526001600160a01b038d16917f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca910160405180910390a25050505050505050505050565b600d5460ff16156115c6576040516340a47f0360e11b815260040160405180910390fd5b818042111561160a5760405162461bcd60e51b815260206004820152601060248201526f10db1a5c1c195c8e88115e1c1a5c995960821b6044820152606401610fc5565b336001600160a01b038816146116885760405162461bcd60e51b815260206004820152602560248201527f746f6b656e486f6c64657220646f6573206e6f74206d61746368206d73672e7360448201527f656e6465720000000000000000000000000000000000000000000000000000006064820152608401610fc5565b60006001600160a01b0386166116bf57507f0000000000000000000000000000000000000000000000000000000000000000945060015b60006116ce8989898989612e65565b90506116da81856125ec565b6116e43389612c47565b6116ee8787612edc565b811561177d57604051632e1a7d4d60e01b8152600481018790527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561175657600080fd5b505af115801561176a573d6000803e3d6000fd5b5050505061177833876124ce565b611791565b6117916001600160a01b038816338861284e565b866001600160a01b0316896001600160a01b03167f41e79959bad1d45680578f8a544fb5af76d72b04090e65a51b4d0eaab959a9ab8a896040516117df929190918252602082015260400190565b60405180910390a3505050505050505050565b6117fa6128e2565b610ec86000612f22565b6001600160a01b0381166000908152600b60205260408120546109bc565b600d5460ff1615611846576040516340a47f0360e11b815260040160405180910390fd5b818042111561188a5760405162461bcd60e51b815260206004820152601060248201526f10db1a5c1c195c8e88115e1c1a5c995960821b6044820152606401610fc5565b34156118ba576118ba7f0000000000000000000000000000000000000000000000000000000000000000346124ce565b336001600160a01b0389161480156118d657506118d6876109c2565b6119125760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b6044820152606401610fc5565b6000611922898989898989612f8c565b905061192e81846125ec565b6000611939896129af565b9050876119648a6001600160a01b03166000908152600660205260409020546001600160e01b031690565b61196e908361465f565b10156119bc5760405162461bcd60e51b815260206004820152601a60248201527f496e73756666696369656e7420746f6b656e206465706f7369740000000000006044820152606401610fc5565b6119c68982612815565b6119d18a8888612e48565b60408051878152602081018990526001600160a01b038c16917f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca910160405180910390a250505050505050505050565b600d5461010090046001600160a01b03163303610ec857600d805460ff19166001179055565b60006109bc600783612f9d565b606060048054610925906145bd565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919083811015611b005760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610fc5565b611b0d82868684036120cb565b506001949350505050565b6000336109b68185856122e1565b600d5460ff1615611b4a576040516340a47f0360e11b815260040160405180910390fd5b8180421115611b8e5760405162461bcd60e51b815260206004820152601060248201526f10db1a5c1c195c8e88115e1c1a5c995960821b6044820152606401610fc5565b611b97876109c2565b611bd35760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b6044820152606401610fc5565b611be86001600160a01b03881633308961295e565b6000611bf8338989898989612f8c565b9050611c0481846125ec565b611c0e8888612fa9565b611c19338787612e48565b604080518681526020810188905233917f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca910160405180910390a25050505050505050565b600d5460ff1615611c82576040516340a47f0360e11b815260040160405180910390fd5b611c976001600160a01b03891633308a61295e565b6000611cc7897f00000000000000000000000000000000000000000000000000000000000000008a8a8a8a612576565b9050611cd381856125ec565b600080611d018b7f00000000000000000000000000000000000000000000000000000000000000008a61270c565b9092509050611d148b610c458c8561464c565b611d427f0000000000000000000000000000000000000000000000000000000000000000610c458b8461465f565b604051632e1a7d4d60e01b8152600481018a90527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015611da457600080fd5b505af1158015611db8573d6000803e3d6000fd5b50505050611dc6878a6124ce565b866001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168c6001600160a01b03167f4be05c8d54f5e056ab2cfa033e9f582057001268c3e28561bb999d35d2c8f2c88d8d8a8a604051610cdf9493929190614672565b611e416128e2565b600d80547fffffffffffffffffffffff0000000000000000000000000000000000000000ff166101006001600160a01b038416908102919091179091556040517f7fb818801719b0f482b3e69a97fd8c5a1bddd186808ae2a83bdf1dac62c550ec90600090a250565b83421115611efa5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610fc5565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611f298c612fc8565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000611f8482612ff0565b90506000611f948287878761303e565b9050896001600160a01b0316816001600160a01b031614611ff75760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610fc5565b6120028a8a8a6120cb565b50505050505050505050565b6001600160a01b0381166000908152600960205260408120600181015415801590610b5357505442101592915050565b6120466128e2565b6001600160a01b0381166120c25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610fc5565b610d1181612f22565b6001600160a01b0383166121465760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b0382166121c25760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03811660009081526001830160205260408120541515610b53565b60006109bc825490565b6001600160a01b0383811660009081526001602090815260408083209386168352929052205460001981146122db57818110156122ce5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610fc5565b6122db84848484036120cb565b50505050565b6001600160a01b03831661235d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b0382166123d95760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b038316600090815260208190526040902054818110156124685760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36122db565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461251b576040519150601f19603f3d011682016040523d82523d6000602084013e612520565b606091505b50509050806125715760405162461bcd60e51b815260206004820152601660248201527f43616c6c20776974682076616c7565206661696c6564000000000000000000006044820152606401610fc5565b505050565b600080612587888888888888613066565b6040805161190160f01b6020808301919091527f00000000000000000000000000000000000000000000000000000000000000006022830152604280830194909452825180830390940184526062909101909152815191012098975050505050505050565b600061260e836125ff60208501856146e8565b8460200135856040013561303e565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316146125715761269f833260405160200161267a92919091825260601b6bffffffffffffffffffffffff1916602082015260340190565b60408051601f198184030181529190528051602091820120906125ff908501856146e8565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031614612571576040517f616876a500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808263ffffffff16804211156127595760405162461bcd60e51b815260206004820152601060248201526f10db1a5c1c195c8e88115e1c1a5c995960821b6044820152606401610fc5565b600080600080612768886131ad565b93509350935093506127988a6001600160a01b03166000908152600660205260409020546001600160e01b031690565b96506127c2896001600160a01b03166000908152600660205260409020546001600160e01b031690565b95506127d287878686868661322c565b612808576040517fa899aa1300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050935093915050565b6000612820836132e9565b50905061282d8183613380565b6001600160a01b039093166000908152600660205260409020929092555050565b6040516001600160a01b0383166024820152604481018290526125719084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180516001600160e01b03167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526133c4565b600a546001600160a01b03163314610ec85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610fc5565b6000610b53836001600160a01b0384166134a9565b610d1181610c45836129af565b6040516001600160a01b03808516602483015283166044820152606481018290526122db9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612893565b604080513060248083019190915282518083039091018152604490910182526020810180516001600160e01b03167f70a08231000000000000000000000000000000000000000000000000000000001790529051600091829182916001600160a01b03861691612a1f9190614703565b600060405180830381855afa9150503d8060008114612a5a576040519150601f19603f3d011682016040523d82523d6000602084013e612a5f565b606091505b5091509150818015612a7357506020815110155b612a7c57600080fd5b80806020019051810190612a90919061471f565b949350505050565b6000838303612aa8575080610b53565b600084612aba856402540be4006146af565b612ac491906146c6565b9050612ad96402540be4006302faf08061464c565b8110612b10576402540be40083612af4826302faf08061464c565b612afe91906146af565b612b0891906146c6565b915050610b53565b6402540be400612afe84836146af565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148015612b7957507f000000000000000000000000000000000000000000000000000000000000000046145b15612ba357507f000000000000000000000000000000000000000000000000000000000000000090565b50604080517f00000000000000000000000000000000000000000000000000000000000000006020808301919091527f0000000000000000000000000000000000000000000000000000000000000000828401527f000000000000000000000000000000000000000000000000000000000000000060608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6001600160a01b038216612cc35760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b03821660009081526020819052604090205481811015612d525760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6000806000612dbd6109cf565b90505b808210156122db576000612dd383611a47565b90506402540be400612e03826001600160a01b03166000908152600660205260409020546001600160e01b031690565b612e0d90876146af565b612e1791906146c6565b9350612e248133866134f8565b82612e2e81614633565b93505050612dc0565b600080612587888888888888613527565b81600003612e5a576125718382613666565b612571838383613725565b600080612e7587878787876138b1565b6040805161190160f01b6020808301919091527f00000000000000000000000000000000000000000000000000000000000000006022830152604280830185905283518084039091018152606290920190925280519101209091505b979650505050505050565b600080612ee8846132e9565b9092509050612f0082612efb858461465f565b613380565b6001600160a01b03909416600090815260066020526040902093909355505050565b600a80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806125878888888888886139e5565b6000610b538383613ae6565b600080612fb5846132e9565b9092509050612f0082612efb858461464c565b6001600160a01b0381166000908152600b602052604090208054600181018255905b50919050565b60006109bc612ffd612b20565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061304f87878787613b10565b9150915061305c81613bd4565b5095945050505050565b6000604051602001613133907f4f66666572537472756374286164647265737320696e7075745f746f6b656e2c81527f61646472657373206f75747075745f746f6b656e2c75696e7432353620696e7060208201527f75745f616d6f756e742c75696e74323536206f75747075745f616d6f756e742c60408201527f75696e7432353620676f6f645f756e74696c2c6164647265737320646573746960608201527f6e6174696f6e5f616464726573732900000000000000000000000000000000006080820152608f0190565b60408051601f198184030181528282528051602091820120908301526001600160a01b03808a169183019190915280881660608301526080820187905260a0820186905260c08201859052831660e0820152610100015b6040516020818303038152906040528051906020012090505b9695505050505050565b60a081901c6bffffffffffffffffffffffff604083901c1660008061ffff603086901c811690602087901c16620f4240866131e8848361464c565b6131f291906146af565b6131fc91906146c6565b9350620f42408561320d838361465f565b61321791906146af565b61322191906146c6565b925050509193509193565b600083861015801561323e5750848711155b1561324b575060016131a3565b8186108061325857508287115b15613265575060006131a3565b838610613274575060016131a3565b848711613283575060016131a3565b6000620f4240613293848761465f565b61329d888761465f565b6132a7868b61465f565b6132b490620f42406146af565b6132be91906146af565b6132c891906146c6565b6132d291906146c6565b90506132de818761464c565b8811159150506131a3565b6001600160a01b0381166000908152600660205260408120546001600160e01b0381169060e081901c61331c324361464c565b93508063ffffffff168463ffffffff16036133795760405162461bcd60e51b815260206004820152601d60248201527f436c69707065723a204661696c656420747820756e697175656e6573730000006044820152606401610fc5565b5050915091565b600061338b82613d39565b610b53906001600160e01b03167fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1661464c565b6000613419826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613dbc9092919063ffffffff16565b80519091501561257157808060200190518101906134379190614738565b6125715760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610fc5565b60008181526001830160205260408120546134f0575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556109bc565b5060006109bc565b613500613dcb565b6135146001600160a01b038416838361284e565b61351d83612951565b6125716001600555565b600080868660405160200161353d92919061475a565b6040516020818303038152906040528051906020012090506040516020016135fa907f4465706f73697453747275637428616464726573732073656e6465722c75696e81527f743235365b5d206465706f7369745f616d6f756e74732c75696e74323536206460208201527f6179735f6c6f636b65642c75696e7432353620706f6f6c5f746f6b656e732c7560408201527f696e7432353620676f6f645f756e74696c290000000000000000000000000000606082015260720190565b60408051601f198184030181528282528051602091820120908301526001600160a01b038a1690820152606081018290526080810186905260a0810185905260c0810184905260e001604051602081830303815290604052805190602001209150509695505050505050565b6001600160a01b0382166136bc5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610fc5565b80600260008282546136ce919061464c565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b600082116137c15760405162461bcd60e51b815260206004820152604c60248201527f436c69707065724469726563743a2043616e6e6f74206372656174652076657360448201527f74696e67206465706f73697420776974686f757420706f73697469766520766560648201527f7374696e6720706572696f640000000000000000000000000000000000000000608482015260a401610fc5565b6001600160a01b038316600090815260096020526040902060010154156138505760405162461bcd60e51b815260206004820152603660248201527f436c69707065724469726563743a204465706f7369746f7220616c726561647960448201527f2068617320616e20616374697665206465706f736974000000000000000000006064820152608401610fc5565b60006040518060400160405280846201518061386c91906146af565b613876904261464c565b815260209081018490526001600160a01b03861660009081526009825260409020825181559082015160019091015590506122db3083613666565b600060405160200161397e907f5769746864726177616c537472756374286164647265737320746f6b656e5f6881527f6f6c6465722c75696e7432353620706f6f6c5f746f6b656e5f616d6f756e745f60208201527f746f5f6275726e2c616464726573732061737365745f616464726573732c756960408201527f6e743235362061737365745f616d6f756e742c75696e7432353620676f6f645f60608201527f756e74696c290000000000000000000000000000000000000000000000000000608082015260860190565b60408051808303601f190181528282528051602091820120818401526001600160a01b039889168383015260608301979097529490961660808701525060a085019190915260c0808501919091528151808503909101815260e09093019052815191012090565b6000604051602001613a8c907f53696e676c654465706f73697453747275637428616464726573732073656e6481527f65722c6164647265737320746f6b656e2c75696e7432353620616d6f756e742c60208201527f75696e7432353620646179735f6c6f636b65642c75696e7432353620706f6f6c60408201527f5f746f6b656e732c75696e7432353620676f6f645f756e74696c2900000000006060820152607b0190565b60408051601f198184030181528282528051602091820120908301526001600160a01b03808a1691830191909152871660608201526080810186905260a0810185905260c0810184905260e081018390526101000161318a565b6000826000018281548110613afd57613afd614607565b9060005260206000200154905092915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613b475750600090506003613bcb565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613b9b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613bc457600060019250925050613bcb565b9150600090505b94509492505050565b6000816004811115613be857613be861479c565b03613bf05750565b6001816004811115613c0457613c0461479c565b03613c515760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610fc5565b6002816004811115613c6557613c6561479c565b03613cb25760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610fc5565b6003816004811115613cc657613cc661479c565b03610d115760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b60006001600160e01b03821115613db85760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203260448201527f32342062697473000000000000000000000000000000000000000000000000006064820152608401610fc5565b5090565b6060612a908484600085613e24565b600260055403613e1d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610fc5565b6002600555565b606082471015613e9c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610fc5565b600080866001600160a01b03168587604051613eb89190614703565b60006040518083038185875af1925050503d8060008114613ef5576040519150601f19603f3d011682016040523d82523d6000602084013e613efa565b606091505b5091509150612ed18783838760608315613f75578251600003613f6e576001600160a01b0385163b613f6e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610fc5565b5081612a90565b612a908383815115613f8a5781518083602001fd5b8060405162461bcd60e51b8152600401610fc59190613fc8565b60005b83811015613fbf578181015183820152602001613fa7565b50506000910152565b6020815260008251806020840152613fe7816040850160208701613fa4565b601f01601f19169190910160400192915050565b80356001600160a01b038116811461401257600080fd5b919050565b6000806040838503121561402a57600080fd5b61403383613ffb565b946020939093013593505050565b60006020828403121561405357600080fd5b610b5382613ffb565b606080825284519082018190526000906020906080840190828801845b8281101561409557815184529284019290840190600101614079565b5050508381038285015285518082528683019183019060005b818110156140d35783516001600160a01b0316835292840192918401916001016140ae565b5050809350505050826040830152949350505050565b6000806000606084860312156140fe57600080fd5b61410784613ffb565b925061411560208501613ffb565b9150604084013590509250925092565b600060608284031215612fea57600080fd5b60008083601f84011261414957600080fd5b50813567ffffffffffffffff81111561416157600080fd5b60208301915083602082850101111561417957600080fd5b9250929050565b600080600080600080600080610120898b03121561419d57600080fd5b6141a689613ffb565b97506020890135965060408901359550606089013594506141c960808a01613ffb565b93506141d88a60a08b01614125565b925061010089013567ffffffffffffffff8111156141f557600080fd5b6142018b828c01614137565b999c989b5096995094979396929594505050565b60008083601f84011261422757600080fd5b50813567ffffffffffffffff81111561423f57600080fd5b6020830191508360208260051b850101111561417957600080fd5b60008060008060008060e0878903121561427357600080fd5b863567ffffffffffffffff81111561428a57600080fd5b61429689828a01614215565b9097509550506020870135935060408701359250606087013591506142be8860808901614125565b90509295509295509295565b60008060008060008060008060006101408a8c0312156142e957600080fd5b6142f28a613ffb565b985061430060208b01613ffb565b975060408a0135965060608a0135955060808a0135945061432360a08b01613ffb565b93506143328b60c08c01614125565b92506101208a013567ffffffffffffffff81111561434f57600080fd5b61435b8c828d01614137565b915080935050809150509295985092959850929598565b60006020828403121561438457600080fd5b5035919050565b6000806000806000806000610100888a0312156143a757600080fd5b6143b088613ffb565b9650602088013567ffffffffffffffff8111156143cc57600080fd5b6143d88a828b01614215565b9097509550506040880135935060608801359250608088013591506144008960a08a01614125565b905092959891949750929550565b600080600080600080610100878903121561442857600080fd5b61443187613ffb565b95506020870135945061444660408801613ffb565b935060608701359250608087013591506142be8860a08901614125565b6000806000806000806000610120888a03121561447f57600080fd5b61448888613ffb565b965061449660208901613ffb565b955060408801359450606088013593506080880135925060a088013591506144008960c08a01614125565b60008060008060008061010087890312156144db57600080fd5b6144e487613ffb565b9550602087013594506040870135935060608701359250608087013591506142be8860a08901614125565b803560ff8116811461401257600080fd5b600080600080600080600060e0888a03121561453b57600080fd5b61454488613ffb565b965061455260208901613ffb565b9550604088013594506060880135935061456e6080890161450f565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561459d57600080fd5b6145a683613ffb565b91506145b460208401613ffb565b90509250929050565b600181811c908216806145d157607f821691505b602082108103612fea57634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016146455761464561461d565b5060010190565b808201808211156109bc576109bc61461d565b818103818111156109bc576109bc61461d565b84815283602082015260606040820152816060820152818360808301376000818301608090810191909152601f909201601f191601019392505050565b80820281158282048414176109bc576109bc61461d565b6000826146e357634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156146fa57600080fd5b610b538261450f565b60008251614715818460208701613fa4565b9190910192915050565b60006020828403121561473157600080fd5b5051919050565b60006020828403121561474a57600080fd5b81518015158114610b5357600080fd5b60007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561478957600080fd5b8260051b80858437919091019392505050565b634e487b7160e01b600052602160045260246000fdfea26469706673582212206380f0ef5afa09f3a09a9e770adc2e4f9c3b179f7a64eff11ea7c9ebf93bb60564736f6c6343000813003300000000000000000000000008938a61ba9523298dbcacee0cda5b371fb7f1f8000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000050000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Deployed Bytecode
0x6080604052600436106102f65760003560e01c80635aecdda51161018f578063a457c2d7116100e1578063d505accf1161008a578063eb1c645311610064578063eb1c6453146108a9578063ecc7633d146108c9578063f2fde38b146108f657600080fd5b8063d505accf1461081e578063da5014c51461083e578063dd62ed3e1461086357600080fd5b8063c325a549116100bb578063c325a54914610795578063c72da66a146107de578063ceaf4339146107fe57600080fd5b8063a457c2d714610735578063a9059cbb14610755578063c0d5ebfd1461077557600080fd5b806387e08c25116101435780638dda8f3f1161011d5780638dda8f3f146106cc57806392a91a3a1461070057806395d89b411461072057600080fd5b806387e08c25146106865780638baeefce146106995780638da5cb5b146106ae57600080fd5b806370a082311161017457806370a082311461061b578063715018a6146106515780637ecebe001461066657600080fd5b80635aecdda5146105af57806362fb4e01146105fb57600080fd5b80632b651a6c11610248578063368dfc18116101fc5780633b26e4eb116101d65780633b26e4eb1461055c5780634cb6864c1461057c5780635250d7301461059c57600080fd5b8063368dfc1814610507578063377a368c14610527578063395093511461053c57600080fd5b8063313ce5671161022d578063313ce5671461049757806334cb3d7f146104b35780633644e515146104f257600080fd5b80632b651a6c146104625780632e7e1bd31461048257600080fd5b80631dc6f5a5116102aa57806327a9b4241161028457806327a9b4241461040d578063298410e51461042257806329d0c8fc1461044257600080fd5b80631dc6f5a5146103b157806323b872dd146103d557806326d9b5b3146103f557600080fd5b806318160ddd116102db57806318160ddd1461035d57806319f373611461037c5780631b6a87591461039c57600080fd5b806306fdde0314610302578063095ea7b31461032d57600080fd5b366102fd57005b600080fd5b34801561030e57600080fd5b50610317610916565b6040516103249190613fc8565b60405180910390f35b34801561033957600080fd5b5061034d610348366004614017565b6109a8565b6040519015158152602001610324565b34801561036957600080fd5b506002545b604051908152602001610324565b34801561038857600080fd5b5061034d610397366004614041565b6109c2565b3480156103a857600080fd5b5061036e6109cf565b3480156103bd57600080fd5b506103c66109e0565b6040516103249392919061405c565b3480156103e157600080fd5b5061034d6103f03660046140e9565b610b34565b34801561040157600080fd5b50600d5460ff1661034d565b61042061041b366004614180565b610b5a565b005b34801561042e57600080fd5b5061042061043d366004614041565b610cf4565b34801561044e57600080fd5b5061042061045d36600461425a565b610d14565b34801561046e57600080fd5b5061042061047d3660046142ca565b610d92565b34801561048e57600080fd5b50610420610ea6565b3480156104a357600080fd5b5060405160128152602001610324565b3480156104bf57600080fd5b5061036e6104ce366004614041565b6001600160a01b03166000908152600660205260409020546001600160e01b031690565b3480156104fe57600080fd5b5061036e610eca565b34801561051357600080fd5b50610420610522366004614372565b610ed4565b34801561053357600080fd5b5061036e610f4c565b34801561054857600080fd5b5061034d610557366004614017565b610ffc565b34801561056857600080fd5b506104206105773660046142ca565b61103b565b34801561058857600080fd5b50610420610597366004614180565b61113c565b6104206105aa36600461438b565b611327565b3480156105bb57600080fd5b506105e37f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b039091168152602001610324565b34801561060757600080fd5b5061042061061636600461440e565b6115a2565b34801561062757600080fd5b5061036e610636366004614041565b6001600160a01b031660009081526020819052604090205490565b34801561065d57600080fd5b506104206117f2565b34801561067257600080fd5b5061036e610681366004614041565b611804565b610420610694366004614463565b611822565b3480156106a557600080fd5b50610420611a21565b3480156106ba57600080fd5b50600a546001600160a01b03166105e3565b3480156106d857600080fd5b506105e37f00000000000000000000000008938a61ba9523298dbcacee0cda5b371fb7f1f881565b34801561070c57600080fd5b506105e361071b366004614372565b611a47565b34801561072c57600080fd5b50610317611a54565b34801561074157600080fd5b5061034d610750366004614017565b611a63565b34801561076157600080fd5b5061034d610770366004614017565b611b18565b34801561078157600080fd5b506104206107903660046144c1565b611b26565b3480156107a157600080fd5b506107c96107b0366004614041565b6009602052600090815260409020805460019091015482565b60408051928352602083019190915201610324565b3480156107ea57600080fd5b506104206107f9366004614180565b611c5e565b34801561080a57600080fd5b50610420610819366004614041565b611e39565b34801561082a57600080fd5b50610420610839366004614520565b611eaa565b34801561084a57600080fd5b50600d546105e39061010090046001600160a01b031681565b34801561086f57600080fd5b5061036e61087e36600461458a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b3480156108b557600080fd5b5061034d6108c4366004614041565b61200e565b3480156108d557600080fd5b5061036e6108e4366004614041565b60066020526000908152604090205481565b34801561090257600080fd5b50610420610911366004614041565b61203e565b606060038054610925906145bd565b80601f0160208091040260200160405190810160405280929190818152602001828054610951906145bd565b801561099e5780601f106109735761010080835404028352916020019161099e565b820191906000526020600020905b81548152906001019060200180831161098157829003601f168201915b5050505050905090565b6000336109b68185856120cb565b60019150505b92915050565b60006109bc600783612223565b60006109db6007612245565b905090565b6060806000806109ee6109cf565b905060008167ffffffffffffffff811115610a0b57610a0b6145f1565b604051908082528060200260200182016040528015610a34578160200160208202803683370190505b50905060008267ffffffffffffffff811115610a5257610a526145f1565b604051908082528060200260200182016040528015610a7b578160200160208202803683370190505b50905060005b83811015610b1a576000610a9482611a47565b9050610abe816001600160a01b03166000908152600660205260409020546001600160e01b031690565b848381518110610ad057610ad0614607565b60200260200101818152505080838381518110610aef57610aef614607565b6001600160a01b03909216602092830291909101909101525080610b1281614633565b915050610a81565b508181610b2660025490565b955095509550505050909192565b600033610b4285828561224f565b610b4d8585856122e1565b60019150505b9392505050565b600d5460ff1615610b7e576040516340a47f0360e11b815260040160405180910390fd5b610ba87f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2886124ce565b6000610bd87f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28a8a8a8a8a612576565b9050610be481856125ec565b600080610c127f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28c8a61270c565b9092509050610c4a7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2610c458c8561464c565b612815565b610c588b610c458b8461465f565b610c6c6001600160a01b038c16888b61284e565b866001600160a01b03168b6001600160a01b03167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03167f4be05c8d54f5e056ab2cfa033e9f582057001268c3e28561bb999d35d2c8f2c88d8d8a8a604051610cdf9493929190614672565b60405180910390a45050505050505050505050565b610cfc6128e2565b610d0760078261293c565b50610d1181612951565b50565b6000855b80821015610d79576000888884818110610d3457610d34614607565b9050602002013590506000811115610d6657610d66333083610d5587611a47565b6001600160a01b031692919061295e565b82610d7081614633565b93505050610d18565b610d8833898989898989611327565b5050505050505050565b600d5460ff1615610db6576040516340a47f0360e11b815260040160405180910390fd5b6000610dc68a8a8a8a8a8a612576565b9050610dd281856125ec565b50600080610de18b8b8961270c565b915091506000610df08c6129af565b90506000610dfe848361465f565b90506000610e0d8c838d612a98565b9050610e198e84612815565b610e278d610c45838761465f565b610e3b6001600160a01b038e168a8361284e565b886001600160a01b03168d6001600160a01b03168f6001600160a01b03167f4be05c8d54f5e056ab2cfa033e9f582057001268c3e28561bb999d35d2c8f2c885858c8c604051610e8e9493929190614672565b60405180910390a45050505050505050505050505050565b600d5461010090046001600160a01b03163303610ec857600d805460ff191690555b565b60006109db612b20565b6000610edf60025490565b610eee836402540be4006146af565b610ef891906146c6565b9050610f043383612c47565b610f0d81612db0565b604080518381526020810183905233917f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6910160405180910390a25050565b6000610f573361200e565b610fce5760405162461bcd60e51b815260206004820152602960248201527f436c69707065724469726563743a204465706f7369742063616e6e6f7420626560448201527f20756e6c6f636b6564000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b50336000818152600960205260408120600181018054918390559190915590610ff9903090836122e1565b90565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906109b6908290869061103690879061464c565b6120cb565b600d5460ff161561105f576040516340a47f0360e11b815260040160405180910390fd5b6110746001600160a01b038a1633308a61295e565b60006110848a8a8a8a8a8a612576565b905061109081856125ec565b60008061109e8c8c8a61270c565b90925090506110b18c610c458c8561464c565b6110bf8b610c458b8461465f565b6110d36001600160a01b038c16888b61284e565b866001600160a01b03168b6001600160a01b03168d6001600160a01b03167f4be05c8d54f5e056ab2cfa033e9f582057001268c3e28561bb999d35d2c8f2c88d8d8a8a6040516111269493929190614672565b60405180910390a4505050505050505050505050565b600d5460ff1615611160576040516340a47f0360e11b815260040160405180910390fd5b6000611190897f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28a8a8a8a612576565b905061119c81856125ec565b6000806111ca8b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28a61270c565b9150915060006111d98c6129af565b905060006111e7848361465f565b905060006111f68d838e612a98565b90506112028e84612815565b6112307f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2610c45838761465f565b604051632e1a7d4d60e01b8152600481018290527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561129257600080fd5b505af11580156112a6573d6000803e3d6000fd5b505050506112b48a826124ce565b896001600160a01b03167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03168f6001600160a01b03167f4be05c8d54f5e056ab2cfa033e9f582057001268c3e28561bb999d35d2c8f2c885858d8d604051610e8e9493929190614672565b600d5460ff161561134b576040516340a47f0360e11b815260040160405180910390fd5b818042111561138f5760405162461bcd60e51b815260206004820152601060248201526f10db1a5c1c195c8e88115e1c1a5c995960821b6044820152606401610fc5565b34156113bf576113bf7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2346124ce565b336001600160a01b0389161461143d5760405162461bcd60e51b815260206004820152602760248201527f4c69737465642073656e64657220646f6573206e6f74206d61746368206d736760448201527f2e73656e646572000000000000000000000000000000000000000000000000006064820152608401610fc5565b600061144d898989898989612e37565b905061145981846125ec565b6000875b808210156115465760008a8a8481811061147957611479614607565b905060200201359050600081111561153357600061149684611a47565b905060006114a3826129af565b9050826114ce836001600160a01b03166000908152600660205260409020546001600160e01b031690565b6114d8908361465f565b10156115265760405162461bcd60e51b815260206004820152601a60248201527f496e73756666696369656e7420746f6b656e206465706f7369740000000000006044820152606401610fc5565b6115308282612815565b50505b8261153d81614633565b9350505061145d565b6115518b8989612e48565b60408051888152602081018a90526001600160a01b038d16917f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca910160405180910390a25050505050505050505050565b600d5460ff16156115c6576040516340a47f0360e11b815260040160405180910390fd5b818042111561160a5760405162461bcd60e51b815260206004820152601060248201526f10db1a5c1c195c8e88115e1c1a5c995960821b6044820152606401610fc5565b336001600160a01b038816146116885760405162461bcd60e51b815260206004820152602560248201527f746f6b656e486f6c64657220646f6573206e6f74206d61746368206d73672e7360448201527f656e6465720000000000000000000000000000000000000000000000000000006064820152608401610fc5565b60006001600160a01b0386166116bf57507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2945060015b60006116ce8989898989612e65565b90506116da81856125ec565b6116e43389612c47565b6116ee8787612edc565b811561177d57604051632e1a7d4d60e01b8152600481018790527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b15801561175657600080fd5b505af115801561176a573d6000803e3d6000fd5b5050505061177833876124ce565b611791565b6117916001600160a01b038816338861284e565b866001600160a01b0316896001600160a01b03167f41e79959bad1d45680578f8a544fb5af76d72b04090e65a51b4d0eaab959a9ab8a896040516117df929190918252602082015260400190565b60405180910390a3505050505050505050565b6117fa6128e2565b610ec86000612f22565b6001600160a01b0381166000908152600b60205260408120546109bc565b600d5460ff1615611846576040516340a47f0360e11b815260040160405180910390fd5b818042111561188a5760405162461bcd60e51b815260206004820152601060248201526f10db1a5c1c195c8e88115e1c1a5c995960821b6044820152606401610fc5565b34156118ba576118ba7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2346124ce565b336001600160a01b0389161480156118d657506118d6876109c2565b6119125760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b6044820152606401610fc5565b6000611922898989898989612f8c565b905061192e81846125ec565b6000611939896129af565b9050876119648a6001600160a01b03166000908152600660205260409020546001600160e01b031690565b61196e908361465f565b10156119bc5760405162461bcd60e51b815260206004820152601a60248201527f496e73756666696369656e7420746f6b656e206465706f7369740000000000006044820152606401610fc5565b6119c68982612815565b6119d18a8888612e48565b60408051878152602081018990526001600160a01b038c16917f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca910160405180910390a250505050505050505050565b600d5461010090046001600160a01b03163303610ec857600d805460ff19166001179055565b60006109bc600783612f9d565b606060048054610925906145bd565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919083811015611b005760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610fc5565b611b0d82868684036120cb565b506001949350505050565b6000336109b68185856122e1565b600d5460ff1615611b4a576040516340a47f0360e11b815260040160405180910390fd5b8180421115611b8e5760405162461bcd60e51b815260206004820152601060248201526f10db1a5c1c195c8e88115e1c1a5c995960821b6044820152606401610fc5565b611b97876109c2565b611bd35760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b6044820152606401610fc5565b611be86001600160a01b03881633308961295e565b6000611bf8338989898989612f8c565b9050611c0481846125ec565b611c0e8888612fa9565b611c19338787612e48565b604080518681526020810188905233917f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca910160405180910390a25050505050505050565b600d5460ff1615611c82576040516340a47f0360e11b815260040160405180910390fd5b611c976001600160a01b03891633308a61295e565b6000611cc7897f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28a8a8a8a612576565b9050611cd381856125ec565b600080611d018b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28a61270c565b9092509050611d148b610c458c8561464c565b611d427f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2610c458b8461465f565b604051632e1a7d4d60e01b8152600481018a90527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015611da457600080fd5b505af1158015611db8573d6000803e3d6000fd5b50505050611dc6878a6124ce565b866001600160a01b03167f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b03168c6001600160a01b03167f4be05c8d54f5e056ab2cfa033e9f582057001268c3e28561bb999d35d2c8f2c88d8d8a8a604051610cdf9493929190614672565b611e416128e2565b600d80547fffffffffffffffffffffff0000000000000000000000000000000000000000ff166101006001600160a01b038416908102919091179091556040517f7fb818801719b0f482b3e69a97fd8c5a1bddd186808ae2a83bdf1dac62c550ec90600090a250565b83421115611efa5760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610fc5565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888611f298c612fc8565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000611f8482612ff0565b90506000611f948287878761303e565b9050896001600160a01b0316816001600160a01b031614611ff75760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610fc5565b6120028a8a8a6120cb565b50505050505050505050565b6001600160a01b0381166000908152600960205260408120600181015415801590610b5357505442101592915050565b6120466128e2565b6001600160a01b0381166120c25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610fc5565b610d1181612f22565b6001600160a01b0383166121465760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b0382166121c25760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b03811660009081526001830160205260408120541515610b53565b60006109bc825490565b6001600160a01b0383811660009081526001602090815260408083209386168352929052205460001981146122db57818110156122ce5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610fc5565b6122db84848484036120cb565b50505050565b6001600160a01b03831661235d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b0382166123d95760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b038316600090815260208190526040902054818110156124685760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a36122db565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461251b576040519150601f19603f3d011682016040523d82523d6000602084013e612520565b606091505b50509050806125715760405162461bcd60e51b815260206004820152601660248201527f43616c6c20776974682076616c7565206661696c6564000000000000000000006044820152606401610fc5565b505050565b600080612587888888888888613066565b6040805161190160f01b6020808301919091527f9c375120fd1b2b9e0dd15884920fbd98721138d35a3734a1c079ce8cf5d247626022830152604280830194909452825180830390940184526062909101909152815191012098975050505050505050565b600061260e836125ff60208501856146e8565b8460200135856040013561303e565b90507f00000000000000000000000008938a61ba9523298dbcacee0cda5b371fb7f1f86001600160a01b0316816001600160a01b0316146125715761269f833260405160200161267a92919091825260601b6bffffffffffffffffffffffff1916602082015260340190565b60408051601f198184030181529190528051602091820120906125ff908501856146e8565b90507f00000000000000000000000008938a61ba9523298dbcacee0cda5b371fb7f1f86001600160a01b0316816001600160a01b031614612571576040517f616876a500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000808263ffffffff16804211156127595760405162461bcd60e51b815260206004820152601060248201526f10db1a5c1c195c8e88115e1c1a5c995960821b6044820152606401610fc5565b600080600080612768886131ad565b93509350935093506127988a6001600160a01b03166000908152600660205260409020546001600160e01b031690565b96506127c2896001600160a01b03166000908152600660205260409020546001600160e01b031690565b95506127d287878686868661322c565b612808576040517fa899aa1300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050935093915050565b6000612820836132e9565b50905061282d8183613380565b6001600160a01b039093166000908152600660205260409020929092555050565b6040516001600160a01b0383166024820152604481018290526125719084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180516001600160e01b03167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526133c4565b600a546001600160a01b03163314610ec85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610fc5565b6000610b53836001600160a01b0384166134a9565b610d1181610c45836129af565b6040516001600160a01b03808516602483015283166044820152606481018290526122db9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401612893565b604080513060248083019190915282518083039091018152604490910182526020810180516001600160e01b03167f70a08231000000000000000000000000000000000000000000000000000000001790529051600091829182916001600160a01b03861691612a1f9190614703565b600060405180830381855afa9150503d8060008114612a5a576040519150601f19603f3d011682016040523d82523d6000602084013e612a5f565b606091505b5091509150818015612a7357506020815110155b612a7c57600080fd5b80806020019051810190612a90919061471f565b949350505050565b6000838303612aa8575080610b53565b600084612aba856402540be4006146af565b612ac491906146c6565b9050612ad96402540be4006302faf08061464c565b8110612b10576402540be40083612af4826302faf08061464c565b612afe91906146af565b612b0891906146c6565b915050610b53565b6402540be400612afe84836146af565b6000306001600160a01b037f000000000000000000000000655edce464cc797526600a462a8154650eee4b7716148015612b7957507f000000000000000000000000000000000000000000000000000000000000000146145b15612ba357507ff18ab41bcbc20675c913a88c50731c12607d317d5a9f2854a69051ac5c6d7e6d90565b50604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f9c6cb91ae6995c4f98d5c96a94038cb2c21550a5e2fba91ca66049240423046c828401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6001600160a01b038216612cc35760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b03821660009081526020819052604090205481811015612d525760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6000806000612dbd6109cf565b90505b808210156122db576000612dd383611a47565b90506402540be400612e03826001600160a01b03166000908152600660205260409020546001600160e01b031690565b612e0d90876146af565b612e1791906146c6565b9350612e248133866134f8565b82612e2e81614633565b93505050612dc0565b600080612587888888888888613527565b81600003612e5a576125718382613666565b612571838383613725565b600080612e7587878787876138b1565b6040805161190160f01b6020808301919091527f9c375120fd1b2b9e0dd15884920fbd98721138d35a3734a1c079ce8cf5d247626022830152604280830185905283518084039091018152606290920190925280519101209091505b979650505050505050565b600080612ee8846132e9565b9092509050612f0082612efb858461465f565b613380565b6001600160a01b03909416600090815260066020526040902093909355505050565b600a80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806125878888888888886139e5565b6000610b538383613ae6565b600080612fb5846132e9565b9092509050612f0082612efb858461464c565b6001600160a01b0381166000908152600b602052604090208054600181018255905b50919050565b60006109bc612ffd612b20565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061304f87878787613b10565b9150915061305c81613bd4565b5095945050505050565b6000604051602001613133907f4f66666572537472756374286164647265737320696e7075745f746f6b656e2c81527f61646472657373206f75747075745f746f6b656e2c75696e7432353620696e7060208201527f75745f616d6f756e742c75696e74323536206f75747075745f616d6f756e742c60408201527f75696e7432353620676f6f645f756e74696c2c6164647265737320646573746960608201527f6e6174696f6e5f616464726573732900000000000000000000000000000000006080820152608f0190565b60408051601f198184030181528282528051602091820120908301526001600160a01b03808a169183019190915280881660608301526080820187905260a0820186905260c08201859052831660e0820152610100015b6040516020818303038152906040528051906020012090505b9695505050505050565b60a081901c6bffffffffffffffffffffffff604083901c1660008061ffff603086901c811690602087901c16620f4240866131e8848361464c565b6131f291906146af565b6131fc91906146c6565b9350620f42408561320d838361465f565b61321791906146af565b61322191906146c6565b925050509193509193565b600083861015801561323e5750848711155b1561324b575060016131a3565b8186108061325857508287115b15613265575060006131a3565b838610613274575060016131a3565b848711613283575060016131a3565b6000620f4240613293848761465f565b61329d888761465f565b6132a7868b61465f565b6132b490620f42406146af565b6132be91906146af565b6132c891906146c6565b6132d291906146c6565b90506132de818761464c565b8811159150506131a3565b6001600160a01b0381166000908152600660205260408120546001600160e01b0381169060e081901c61331c324361464c565b93508063ffffffff168463ffffffff16036133795760405162461bcd60e51b815260206004820152601d60248201527f436c69707065723a204661696c656420747820756e697175656e6573730000006044820152606401610fc5565b5050915091565b600061338b82613d39565b610b53906001600160e01b03167fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1661464c565b6000613419826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613dbc9092919063ffffffff16565b80519091501561257157808060200190518101906134379190614738565b6125715760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610fc5565b60008181526001830160205260408120546134f0575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556109bc565b5060006109bc565b613500613dcb565b6135146001600160a01b038416838361284e565b61351d83612951565b6125716001600555565b600080868660405160200161353d92919061475a565b6040516020818303038152906040528051906020012090506040516020016135fa907f4465706f73697453747275637428616464726573732073656e6465722c75696e81527f743235365b5d206465706f7369745f616d6f756e74732c75696e74323536206460208201527f6179735f6c6f636b65642c75696e7432353620706f6f6c5f746f6b656e732c7560408201527f696e7432353620676f6f645f756e74696c290000000000000000000000000000606082015260720190565b60408051601f198184030181528282528051602091820120908301526001600160a01b038a1690820152606081018290526080810186905260a0810185905260c0810184905260e001604051602081830303815290604052805190602001209150509695505050505050565b6001600160a01b0382166136bc5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610fc5565b80600260008282546136ce919061464c565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b600082116137c15760405162461bcd60e51b815260206004820152604c60248201527f436c69707065724469726563743a2043616e6e6f74206372656174652076657360448201527f74696e67206465706f73697420776974686f757420706f73697469766520766560648201527f7374696e6720706572696f640000000000000000000000000000000000000000608482015260a401610fc5565b6001600160a01b038316600090815260096020526040902060010154156138505760405162461bcd60e51b815260206004820152603660248201527f436c69707065724469726563743a204465706f7369746f7220616c726561647960448201527f2068617320616e20616374697665206465706f736974000000000000000000006064820152608401610fc5565b60006040518060400160405280846201518061386c91906146af565b613876904261464c565b815260209081018490526001600160a01b03861660009081526009825260409020825181559082015160019091015590506122db3083613666565b600060405160200161397e907f5769746864726177616c537472756374286164647265737320746f6b656e5f6881527f6f6c6465722c75696e7432353620706f6f6c5f746f6b656e5f616d6f756e745f60208201527f746f5f6275726e2c616464726573732061737365745f616464726573732c756960408201527f6e743235362061737365745f616d6f756e742c75696e7432353620676f6f645f60608201527f756e74696c290000000000000000000000000000000000000000000000000000608082015260860190565b60408051808303601f190181528282528051602091820120818401526001600160a01b039889168383015260608301979097529490961660808701525060a085019190915260c0808501919091528151808503909101815260e09093019052815191012090565b6000604051602001613a8c907f53696e676c654465706f73697453747275637428616464726573732073656e6481527f65722c6164647265737320746f6b656e2c75696e7432353620616d6f756e742c60208201527f75696e7432353620646179735f6c6f636b65642c75696e7432353620706f6f6c60408201527f5f746f6b656e732c75696e7432353620676f6f645f756e74696c2900000000006060820152607b0190565b60408051601f198184030181528282528051602091820120908301526001600160a01b03808a1691830191909152871660608201526080810186905260a0810185905260c0810184905260e081018390526101000161318a565b6000826000018281548110613afd57613afd614607565b9060005260206000200154905092915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613b475750600090506003613bcb565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613b9b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613bc457600060019250925050613bcb565b9150600090505b94509492505050565b6000816004811115613be857613be861479c565b03613bf05750565b6001816004811115613c0457613c0461479c565b03613c515760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610fc5565b6002816004811115613c6557613c6561479c565b03613cb25760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610fc5565b6003816004811115613cc657613cc661479c565b03610d115760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610fc5565b60006001600160e01b03821115613db85760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203260448201527f32342062697473000000000000000000000000000000000000000000000000006064820152608401610fc5565b5090565b6060612a908484600085613e24565b600260055403613e1d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610fc5565b6002600555565b606082471015613e9c5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610fc5565b600080866001600160a01b03168587604051613eb89190614703565b60006040518083038185875af1925050503d8060008114613ef5576040519150601f19603f3d011682016040523d82523d6000602084013e613efa565b606091505b5091509150612ed18783838760608315613f75578251600003613f6e576001600160a01b0385163b613f6e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610fc5565b5081612a90565b612a908383815115613f8a5781518083602001fd5b8060405162461bcd60e51b8152600401610fc59190613fc8565b60005b83811015613fbf578181015183820152602001613fa7565b50506000910152565b6020815260008251806020840152613fe7816040850160208701613fa4565b601f01601f19169190910160400192915050565b80356001600160a01b038116811461401257600080fd5b919050565b6000806040838503121561402a57600080fd5b61403383613ffb565b946020939093013593505050565b60006020828403121561405357600080fd5b610b5382613ffb565b606080825284519082018190526000906020906080840190828801845b8281101561409557815184529284019290840190600101614079565b5050508381038285015285518082528683019183019060005b818110156140d35783516001600160a01b0316835292840192918401916001016140ae565b5050809350505050826040830152949350505050565b6000806000606084860312156140fe57600080fd5b61410784613ffb565b925061411560208501613ffb565b9150604084013590509250925092565b600060608284031215612fea57600080fd5b60008083601f84011261414957600080fd5b50813567ffffffffffffffff81111561416157600080fd5b60208301915083602082850101111561417957600080fd5b9250929050565b600080600080600080600080610120898b03121561419d57600080fd5b6141a689613ffb565b97506020890135965060408901359550606089013594506141c960808a01613ffb565b93506141d88a60a08b01614125565b925061010089013567ffffffffffffffff8111156141f557600080fd5b6142018b828c01614137565b999c989b5096995094979396929594505050565b60008083601f84011261422757600080fd5b50813567ffffffffffffffff81111561423f57600080fd5b6020830191508360208260051b850101111561417957600080fd5b60008060008060008060e0878903121561427357600080fd5b863567ffffffffffffffff81111561428a57600080fd5b61429689828a01614215565b9097509550506020870135935060408701359250606087013591506142be8860808901614125565b90509295509295509295565b60008060008060008060008060006101408a8c0312156142e957600080fd5b6142f28a613ffb565b985061430060208b01613ffb565b975060408a0135965060608a0135955060808a0135945061432360a08b01613ffb565b93506143328b60c08c01614125565b92506101208a013567ffffffffffffffff81111561434f57600080fd5b61435b8c828d01614137565b915080935050809150509295985092959850929598565b60006020828403121561438457600080fd5b5035919050565b6000806000806000806000610100888a0312156143a757600080fd5b6143b088613ffb565b9650602088013567ffffffffffffffff8111156143cc57600080fd5b6143d88a828b01614215565b9097509550506040880135935060608801359250608088013591506144008960a08a01614125565b905092959891949750929550565b600080600080600080610100878903121561442857600080fd5b61443187613ffb565b95506020870135945061444660408801613ffb565b935060608701359250608087013591506142be8860a08901614125565b6000806000806000806000610120888a03121561447f57600080fd5b61448888613ffb565b965061449660208901613ffb565b955060408801359450606088013593506080880135925060a088013591506144008960c08a01614125565b60008060008060008061010087890312156144db57600080fd5b6144e487613ffb565b9550602087013594506040870135935060608701359250608087013591506142be8860a08901614125565b803560ff8116811461401257600080fd5b600080600080600080600060e0888a03121561453b57600080fd5b61454488613ffb565b965061455260208901613ffb565b9550604088013594506060880135935061456e6080890161450f565b925060a0880135915060c0880135905092959891949750929550565b6000806040838503121561459d57600080fd5b6145a683613ffb565b91506145b460208401613ffb565b90509250929050565b600181811c908216806145d157607f821691505b602082108103612fea57634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016146455761464561461d565b5060010190565b808201808211156109bc576109bc61461d565b818103818111156109bc576109bc61461d565b84815283602082015260606040820152816060820152818360808301376000818301608090810191909152601f909201601f191601019392505050565b80820281158282048414176109bc576109bc61461d565b6000826146e357634e487b7160e01b600052601260045260246000fd5b500490565b6000602082840312156146fa57600080fd5b610b538261450f565b60008251614715818460208701613fa4565b9190910192915050565b60006020828403121561473157600080fd5b5051919050565b60006020828403121561474a57600080fd5b81518015158114610b5357600080fd5b60007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561478957600080fd5b8260051b80858437919091019392505050565b634e487b7160e01b600052602160045260246000fdfea26469706673582212206380f0ef5afa09f3a09a9e770adc2e4f9c3b179f7a64eff11ea7c9ebf93bb60564736f6c63430008130033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000008938a61ba9523298dbcacee0cda5b371fb7f1f8000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000050000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
-----Decoded View---------------
Arg [0] : theSigner (address): 0x08938a61BA9523298dbCAceE0cda5B371FB7f1F8
Arg [1] : theWrapper (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
Arg [2] : tokens (address[]): 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,0xdAC17F958D2ee523a2206206994597C13D831ec7,0x6B175474E89094C44Da98b954EedeAC495271d0F,0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 00000000000000000000000008938a61ba9523298dbcacee0cda5b371fb7f1f8
Arg [1] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [4] : 0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599
Arg [5] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Arg [6] : 000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7
Arg [7] : 0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f
Arg [8] : 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.