Feature Tip: Add private address tag to any address under My Name Tag !
Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Latest 25 from a total of 651 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Remove Liquidity... | 17637572 | 899 days ago | IN | 0 ETH | 0.00528267 | ||||
| Remove Liquidity... | 17588833 | 905 days ago | IN | 0 ETH | 0.00374958 | ||||
| Remove Liquidity... | 17585818 | 906 days ago | IN | 0 ETH | 0.00995887 | ||||
| Remove Liquidity... | 17585802 | 906 days ago | IN | 0 ETH | 0.01092593 | ||||
| Remove Liquidity... | 17585790 | 906 days ago | IN | 0 ETH | 0.01162528 | ||||
| Remove Liquidity... | 17585778 | 906 days ago | IN | 0 ETH | 0.01159213 | ||||
| Remove Liquidity... | 17585765 | 906 days ago | IN | 0 ETH | 0.01148065 | ||||
| Remove Liquidity... | 17585747 | 906 days ago | IN | 0 ETH | 0.01231015 | ||||
| Remove Liquidity... | 17585732 | 906 days ago | IN | 0 ETH | 0.01234837 | ||||
| Remove Liquidity... | 17585699 | 906 days ago | IN | 0 ETH | 0.00841314 | ||||
| Remove Liquidity... | 17585678 | 906 days ago | IN | 0 ETH | 0.00816867 | ||||
| Remove Liquidity... | 17585593 | 906 days ago | IN | 0 ETH | 0.01092959 | ||||
| Swap Exact Token... | 17499245 | 918 days ago | IN | 0 ETH | 0.00211809 | ||||
| Swap Exact Token... | 17499242 | 918 days ago | IN | 0 ETH | 0.00203855 | ||||
| Swap Exact Token... | 17472860 | 922 days ago | IN | 0 ETH | 0.00210557 | ||||
| Remove Liquidity... | 17420311 | 929 days ago | IN | 0 ETH | 0.00243173 | ||||
| Swap Exact Token... | 17407477 | 931 days ago | IN | 0 ETH | 0.00283481 | ||||
| Swap Exact Token... | 17314684 | 944 days ago | IN | 0 ETH | 0.00433227 | ||||
| Swap Exact Token... | 17314669 | 944 days ago | IN | 0 ETH | 0.00440933 | ||||
| Swap Exact Token... | 17314666 | 944 days ago | IN | 0 ETH | 0.00371864 | ||||
| Add Liquidity | 17308710 | 945 days ago | IN | 0 ETH | 0.00703924 | ||||
| Swap Exact Token... | 17308703 | 945 days ago | IN | 0 ETH | 0.00480014 | ||||
| Swap Exact Token... | 17158317 | 966 days ago | IN | 0 ETH | 0.0041198 | ||||
| Swap Exact Token... | 17113028 | 972 days ago | IN | 0 ETH | 0.00541748 | ||||
| Swap Exact Token... | 17109600 | 973 days ago | IN | 0 ETH | 0.00653162 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
UniswapV2Router02
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 999 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol"; import "../../env/IWETH.sol"; import "./libraries/UniswapV2Library.sol"; /// @custom:security-contact [email protected] contract UniswapV2Router02 { address public immutable factory; address public immutable WETH; modifier ensure(uint deadline) { require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED'); _; } constructor(address _factory, address _WETH) { factory = _factory; WETH = _WETH; } receive() external payable { assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract } // **** ADD LIQUIDITY **** function _addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin ) internal virtual returns (uint amountA, uint amountB) { // create the pair if it doesn't exist yet if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) { IUniswapV2Factory(factory).createPair(tokenA, tokenB); } (uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB); if (reserveA == 0 && reserveB == 0) { (amountA, amountB) = (amountADesired, amountBDesired); } else { uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB); if (amountBOptimal <= amountBDesired) { require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT'); (amountA, amountB) = (amountADesired, amountBOptimal); } else { uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA); assert(amountAOptimal <= amountADesired); require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT'); (amountA, amountB) = (amountAOptimal, amountBDesired); } } } function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external virtual ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) { (amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin); address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); SafeERC20.safeTransferFrom(IERC20(tokenA), msg.sender, pair, amountA); SafeERC20.safeTransferFrom(IERC20(tokenB), msg.sender, pair, amountB); liquidity = IUniswapV2Pair(pair).mint(to); } function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external virtual payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) { (amountToken, amountETH) = _addLiquidity( token, WETH, amountTokenDesired, msg.value, amountTokenMin, amountETHMin ); address pair = UniswapV2Library.pairFor(factory, token, WETH); SafeERC20.safeTransferFrom(IERC20(token), msg.sender, pair, amountToken); IWETH(WETH).deposit{value: amountETH}(); SafeERC20.safeTransfer(IERC20(WETH), pair, amountETH); liquidity = IUniswapV2Pair(pair).mint(to); // refund dust eth, if any if (msg.value > amountETH) Address.sendValue(payable(msg.sender), msg.value - amountETH); } // **** REMOVE LIQUIDITY **** function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) public virtual ensure(deadline) returns (uint amountA, uint amountB) { address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to); (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT'); require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT'); } function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual ensure(deadline) returns (uint amountToken, uint amountETH) { (amountToken, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); SafeERC20.safeTransfer(IERC20(token), to, amountToken); IWETH(WETH).withdraw(amountETH); Address.sendValue(payable(to), amountETH); } function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual returns (uint amountA, uint amountB) { address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); uint value = approveMax ? type(uint256).max : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline); } function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual returns (uint amountToken, uint amountETH) { address pair = UniswapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? type(uint256).max : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline); } // **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) **** function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual ensure(deadline) returns (uint amountETH) { (, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); SafeERC20.safeTransfer(IERC20(token), to, IERC20(token).balanceOf(address(this))); IWETH(WETH).withdraw(amountETH); Address.sendValue(payable(to), amountETH); } function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual returns (uint amountETH) { address pair = UniswapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? type(uint256).max : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); amountETH = removeLiquidityETHSupportingFeeOnTransferTokens( token, liquidity, amountTokenMin, amountETHMin, to, deadline ); } // **** SWAP **** // requires the initial amount to have already been sent to the first pair function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = UniswapV2Library.sortTokens(input, output); uint amountOut = amounts[i + 1]; (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0)); address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to; IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap( amount0Out, amount1Out, to, new bytes(0) ); } } function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual ensure(deadline) returns (uint[] memory amounts) { amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); SafeERC20.safeTransferFrom( IERC20(path[0]), msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external virtual ensure(deadline) returns (uint[] memory amounts) { amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); SafeERC20.safeTransferFrom( IERC20(path[0]), msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); SafeERC20.safeTransfer(IERC20(WETH), UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]); _swap(amounts, path, to); } function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external virtual ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); SafeERC20.safeTransferFrom( IERC20(path[0]), msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); Address.sendValue(payable(to), amounts[amounts.length - 1]); } function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); SafeERC20.safeTransferFrom( IERC20(path[0]), msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); Address.sendValue(payable(to), amounts[amounts.length - 1]); } function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external virtual payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); SafeERC20.safeTransfer(IERC20(WETH), UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]); _swap(amounts, path, to); // refund dust eth, if any if (msg.value > amounts[0]) Address.sendValue(payable(msg.sender), msg.value - amounts[0]); } // **** SWAP (supporting fee-on-transfer tokens) **** // requires the initial amount to have already been sent to the first pair function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = UniswapV2Library.sortTokens(input, output); IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)); uint amountInput; uint amountOutput; { // scope to avoid stack too deep errors (uint reserve0, uint reserve1,) = pair.getReserves(); (uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0); amountInput = IERC20(input).balanceOf(address(pair)) - reserveInput; amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput); } (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0)); address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to; pair.swap(amount0Out, amount1Out, to, new bytes(0)); } } function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual ensure(deadline) { SafeERC20.safeTransferFrom( IERC20(path[0]), msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn ); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20(path[path.length - 1]).balanceOf(to) - balanceBefore >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual payable ensure(deadline) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); uint amountIn = msg.value; IWETH(WETH).deposit{value: amountIn}(); SafeERC20.safeTransfer(IERC20(WETH), UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn); uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20(path[path.length - 1]).balanceOf(to) - balanceBefore >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual ensure(deadline) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); SafeERC20.safeTransferFrom( IERC20(path[0]), msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn ); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20(WETH).balanceOf(address(this)); require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).withdraw(amountOut); Address.sendValue(payable(to), amountOut); } // **** LIBRARY FUNCTIONS **** function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual returns (uint amountB) { return UniswapV2Library.quote(amountA, reserveA, reserveB); } function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) public pure virtual returns (uint amountOut) { return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut); } function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) public pure virtual returns (uint amountIn) { return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut); } function getAmountsOut(uint amountIn, address[] memory path) public view virtual returns (uint[] memory amounts) { return UniswapV2Library.getAmountsOut(factory, amountIn, path); } function getAmountsIn(uint amountOut, address[] memory path) public view virtual returns (uint[] memory amounts) { return UniswapV2Library.getAmountsIn(factory, amountOut, path); } }
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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.7.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 functionCall(target, data, "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");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(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) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(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) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason 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 {
// 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);
}
}
}
}pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IWETH is IERC20 {
function deposit() external payable;
function withdraw(uint256) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/proxy/Clones.sol";
import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
import '../UniswapV2Factory.sol';
library UniswapV2Library {
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal view returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
return Clones.predictDeterministicAddress(
UniswapV2Factory(factory).template(),
keccak256(abi.encodePacked(token0, token1)),
factory
);
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA * reserveB / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn * 995; // FORKED: take .5% instead of .3%
uint numerator = amountInWithFee * reserveOut;
uint denominator = reserveIn * 1000 + amountInWithFee;
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn * amountOut * 1000;
uint denominator = (reserveOut - amountOut) * 995; // FORKED: take .5% instead of .3%
amountIn = (numerator / denominator) + 1;
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
}// 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 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 (last updated v4.7.0) (proxy/Clones.sol)
pragma solidity ^0.8.0;
/**
* @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
* deploying minimal proxy contracts, also known as "clones".
*
* > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
* > a minimal bytecode implementation that delegates all calls to a known, fixed address.
*
* The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
* (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
* deterministic method.
*
* _Available since v3.4._
*/
library Clones {
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
*
* This function uses the create opcode, which should never revert.
*/
function clone(address implementation) internal returns (address instance) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create(0, ptr, 0x37)
}
require(instance != address(0), "ERC1167: create failed");
}
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
*
* This function uses the create2 opcode and a `salt` to deterministically deploy
* the clone. Using the same `implementation` and `salt` multiple time will revert, since
* the clones cannot be deployed twice at the same address.
*/
function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create2(0, ptr, 0x37, salt)
}
require(instance != address(0), "ERC1167: create2 failed");
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(
address implementation,
bytes32 salt,
address deployer
) internal pure returns (address predicted) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
mstore(add(ptr, 0x38), shl(0x60, deployer))
mstore(add(ptr, 0x4c), salt)
mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
predicted := keccak256(add(ptr, 0x37), 0x55)
}
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(address implementation, bytes32 salt)
internal
view
returns (address predicted)
{
return predictDeterministicAddress(implementation, salt, address(this));
}
}pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/proxy/Clones.sol"; import "./libraries/UniswapV2Library.sol"; import './UniswapV2Pair.sol'; /// @custom:security-contact [email protected] contract UniswapV2Factory is AccessControl { bytes32 public constant PAIR_CREATOR_ROLE = keccak256("PAIR_CREATOR_ROLE"); address public immutable template = address(new UniswapV2Pair()); address public feeTo; address[] public allPairs; event PairCreated(address indexed token0, address indexed token1, address pair, uint); modifier onlyRoleOrOpenRole(bytes32 role) { if (!hasRole(role, address(0))) { _checkRole(role, _msgSender()); } _; } constructor(address admin) { _grantRole(DEFAULT_ADMIN_ROLE, admin); } function allPairsLength() external view returns (uint) { return allPairs.length; } function getPair(address tokenA, address tokenB) public view returns (address) { address pair = UniswapV2Library.pairFor(address(this), tokenA, tokenB); return pair.code.length > 0 ? pair : address(0); } function createPair(address tokenA, address tokenB) external onlyRoleOrOpenRole(PAIR_CREATOR_ROLE) returns (address pair) { (address token0, address token1) = UniswapV2Library.sortTokens(tokenA, tokenB); pair = Clones.cloneDeterministic(template, keccak256(abi.encodePacked(token0, token1))); UniswapV2Pair(pair).initialize(token0, token1); allPairs.push(pair); emit PairCreated(token0, token1, pair, allPairs.length); } function setFeeTo(address _feeTo) external onlyRole(DEFAULT_ADMIN_ROLE) { feeTo = _feeTo; } }
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/interfaces/IERC20Metadata.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Callee.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import "./libraries/UniswapV2Math.sol";
import "./libraries/UQ112x112.sol";
import "./../../tokens/extensions/ERC1363Upgradeable.sol";
function getSymbol(address token) view returns (string memory) {
try IERC20Metadata(token).symbol() returns (string memory symbol) {
return symbol;
} catch {
return "unknown";
}
}
/// @custom:security-contact [email protected]
contract UniswapV2Pair is ERC20PermitUpgradeable, ERC1363Upgradeable, ReentrancyGuardUpgradeable {
using UQ112x112 for uint224;
uint public constant MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public immutable factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor() initializer() {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) public virtual initializer() {
__ERC20_init('00 DEX LP Token', string.concat(getSymbol(_token0), "/", getSymbol(_token1), " LP"));
__ERC20Permit_init('00 DEX LP Token');
__ReentrancyGuard_init();
token0 = _token0;
token1 = _token1;
}
function getReserves() public view virtual returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= type(uint112).max && balance1 <= type(uint112).max, 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IUniswapV2Factory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = UniswapV2Math.sqrt(uint(_reserve0) * uint(_reserve1));
uint rootKLast = UniswapV2Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply() * (rootK - rootKLast);
// FORKED: vanilla is `rootK * 5 + rootKLast;`
// In this version:
// - 50% of the fees go to the liquidity provider (liquidity increass)
// - 50% of the fees go to `feeTo`
uint denominator = rootK + rootKLast;
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) public virtual nonReentrant() returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0 - _reserve0;
uint amount1 = balance1 - _reserve1;
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply();
if (_totalSupply == 0) {
liquidity = UniswapV2Math.sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY;
_mint(address(0xdead), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = UniswapV2Math.min(amount0 * _totalSupply / _reserve0, amount1 * _totalSupply / _reserve1);
}
require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0) * uint(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) public virtual nonReentrant() returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf(address(this));
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply();
amount0 = liquidity * balance0 / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity * balance1 / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
SafeERC20.safeTransfer(IERC20(_token0), to, amount0);
SafeERC20.safeTransfer(IERC20(_token1), to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0) * uint(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) public virtual nonReentrant() {
require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
if (amount0Out > 0) SafeERC20.safeTransfer(IERC20(_token0), to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) SafeERC20.safeTransfer(IERC20(_token1), to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = (balance0 * 1000) - (amount0In * 5); // FORKED: take .5% instead of .3%
uint balance1Adjusted = (balance1 * 1000) - (amount1In * 5); // FORKED: take .5% instead of .3%
require(balance0Adjusted * balance1Adjusted >= uint(_reserve0) * uint(_reserve1) * 1000**2, 'UniswapV2: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) public virtual nonReentrant() {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
SafeERC20.safeTransfer(IERC20(_token0), to, IERC20(_token0).balanceOf(address(this)) - reserve0);
SafeERC20.safeTransfer(IERC20(_token1), to, IERC20(_token1).balanceOf(address(this)) - reserve1);
}
// force reserves to match balances
function sync() public virtual nonReentrant() {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_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) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @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] = _HEX_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 v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../token/ERC20/extensions/IERC20Metadata.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_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() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)
pragma solidity ^0.8.0;
import "./draft-IERC20PermitUpgradeable.sol";
import "../ERC20Upgradeable.sol";
import "../../../utils/cryptography/draft-EIP712Upgradeable.sol";
import "../../../utils/cryptography/ECDSAUpgradeable.sol";
import "../../../utils/CountersUpgradeable.sol";
import "../../../proxy/utils/Initializable.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._
*
* @custom:storage-size 51
*/
abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {
using CountersUpgradeable for CountersUpgradeable.Counter;
mapping(address => CountersUpgradeable.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.
*/
function __ERC20Permit_init(string memory name) internal onlyInitializing {
__EIP712_init_unchained(name, "1");
}
function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {}
/**
* @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 = ECDSAUpgradeable.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) {
CountersUpgradeable.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}pragma solidity >=0.5.0;
interface IUniswapV2Callee {
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}pragma solidity ^0.8.0;
// a library for performing various math operations
library UniswapV2Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
z = x > y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
library UQ112x112 {
uint224 constant Q112 = 2**112;
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / uint224(y);
}
}// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import "./IERC1363.sol"; /// @custom:security-contact [email protected] abstract contract ERC1363Upgradeable is IERC1363, ERC20Upgradeable { function transferAndCall(address to, uint256 value) public override returns (bool) { return transferAndCall(to, value, bytes("")); } function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) { require(transfer(to, value)); try IERC1363Receiver(to).onTransferReceived(_msgSender(), _msgSender(), value, data) returns (bytes4 selector) { require(selector == IERC1363Receiver(to).onTransferReceived.selector, "ERC1363: onTransferReceived invalid result"); } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1363: onTransferReceived reverted without reason"); } return true; } function transferFromAndCall(address from, address to, uint256 value) public override returns (bool) { return transferFromAndCall(from, to, value, bytes("")); } function transferFromAndCall(address from, address to, uint256 value, bytes memory data) public override returns (bool) { require(transferFrom(from, to, value)); try IERC1363Receiver(to).onTransferReceived(_msgSender(), from, value, data) returns (bytes4 selector) { require(selector == IERC1363Receiver(to).onTransferReceived.selector, "ERC1363: onTransferReceived invalid result"); } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1363: onTransferReceived reverted without reason"); } return true; } function approveAndCall(address spender, uint256 value) public override returns (bool) { return approveAndCall(spender, value, bytes("")); } function approveAndCall(address spender, uint256 value, bytes memory data) public override returns (bool) { require(approve(spender, value)); try IERC1363Spender(spender).onApprovalReceived(_msgSender(), value, data) returns (bytes4 selector) { require(selector == IERC1363Spender(spender).onApprovalReceived.selector, "ERC1363: onApprovalReceived invalid result"); } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1363: onApprovalReceived reverted without reason"); } return true; } }
// 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.7.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
* initialization step. This is essential to configure modules that are added through upgrades and that require
* initialization.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @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 functionCall(target, data, "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");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(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) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason 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 {
// 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 (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 IERC20PermitUpgradeable {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.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.zeppelin.solutions/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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
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.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
_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;
}
_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;
_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;
}
_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 {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[45] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)
pragma solidity ^0.8.0;
import "./ECDSAUpgradeable.sol";
import "../../proxy/utils/Initializable.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._
*
* @custom:storage-size 52
*/
abstract contract EIP712Upgradeable is Initializable {
/* solhint-disable var-name-mixedcase */
bytes32 private _HASHED_NAME;
bytes32 private _HASHED_VERSION;
bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
/* 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].
*/
function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
__EIP712_init_unchained(name, version);
}
function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());
}
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 ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev The hash of the name parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712NameHash() internal virtual view returns (bytes32) {
return _HASHED_NAME;
}
/**
* @dev The hash of the version parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712VersionHash() internal virtual view returns (bytes32) {
return _HASHED_VERSION;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../StringsUpgradeable.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 ECDSAUpgradeable {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
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");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' 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) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
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 if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// 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))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} 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 (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// 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", StringsUpgradeable.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 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 CountersUpgradeable {
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.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @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 v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
/**
* @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 v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _HEX_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) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @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] = _HEX_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
pragma solidity ^0.8.0;
interface IERC1363 {
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
/**
* @title ERC1363Spender interface
* @dev Interface for any contract that wants to support `approveAndCall`
* from ERC1363 token contracts.
*/
interface IERC1363Spender {
/*
* Note: the ERC-165 identifier for this interface is 0x7b04a2d0.
* 0x7b04a2d0 === bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))
*/
/**
* @notice Handle the approval of ERC1363 tokens
* @dev Any ERC1363 smart contract calls this function on the recipient
* after an `approve`. This function MAY throw to revert and reject the
* approval. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param owner address The address which called `approveAndCall` function
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
* unless throwing
*/
function onApprovalReceived(address owner, uint256 value, bytes calldata data) external returns (bytes4);
}
/**
* @title ERC1363Receiver interface
* @dev Interface for any contract that wants to support `transferAndCall` or `transferFromAndCall`
* from ERC1363 token contracts.
*/
interface IERC1363Receiver {
/*
* Note: the ERC-165 identifier for this interface is 0x88a7ca5c.
* 0x88a7ca5c === bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))
*/
/**
* @notice Handle the receipt of ERC1363 tokens
* @dev Any ERC1363 smart contract calls this function on the recipient
* after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the
* transfer. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the token contract address is always the message sender.
* @param operator address The address which called `transferAndCall` or `transferFromAndCall` function
* @param from address The address which are token transferred from
* @param value uint256 The amount of tokens transferred
* @param data bytes Additional data with no specified format
* @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
* unless throwing
*/
function onTransferReceived(address operator, address from, uint256 value, bytes calldata data) external returns (bytes4);
}{
"optimizer": {
"enabled": true,
"runs": 999
},
"viaIR": true,
"debug": {
"revertStrings": "strip"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_factory","type":"address"},{"internalType":"address","name":"_WETH","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"amountADesired","type":"uint256"},{"internalType":"uint256","name":"amountBDesired","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidity","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountTokenDesired","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"addLiquidityETH","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"},{"internalType":"uint256","name":"liquidity","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"reserveIn","type":"uint256"},{"internalType":"uint256","name":"reserveOut","type":"uint256"}],"name":"getAmountIn","outputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"reserveIn","type":"uint256"},{"internalType":"uint256","name":"reserveOut","type":"uint256"}],"name":"getAmountOut","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsIn","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsOut","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"reserveA","type":"uint256"},{"internalType":"uint256","name":"reserveB","type":"uint256"}],"name":"quote","outputs":[{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidity","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityETH","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"removeLiquidityETHSupportingFeeOnTransferTokens","outputs":[{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bool","name":"approveMax","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"removeLiquidityETHWithPermit","outputs":[{"internalType":"uint256","name":"amountToken","type":"uint256"},{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountTokenMin","type":"uint256"},{"internalType":"uint256","name":"amountETHMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bool","name":"approveMax","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"removeLiquidityETHWithPermitSupportingFeeOnTransferTokens","outputs":[{"internalType":"uint256","name":"amountETH","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"amountAMin","type":"uint256"},{"internalType":"uint256","name":"amountBMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bool","name":"approveMax","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"removeLiquidityWithPermit","outputs":[{"internalType":"uint256","name":"amountA","type":"uint256"},{"internalType":"uint256","name":"amountB","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapETHForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactETHForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactETHForTokensSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForETHSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMin","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactTokensForTokensSupportingFeeOnTransferTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapTokensForExactETH","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapTokensForExactTokens","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60c0346200017e57601f6200307c38819003918201601f19168301916001600160401b03831184841017620001835780849260409485528339810103126200017e576200005a6020620000528362000199565b920162000199565b9060805260a052604051612ecd9081620001af82396080518181816101c10152818161037c015281816105490152818161063d0152818161071701528181610973015281816109b701528181610a1801528181610c1a01528181610e5e01528181610f810152818161130001528181611447015281816115da01528181611696015281816117c901528181611861015281816119d10152818161204a015281816122aa01528181612583015261274e015260a051818181602801528181610193015281816103490152818161061b015281816106f5015281816107ca0152818161081e01528181610b9801528181610e1801528181610f56015281816110be015281816112de0152818161141601528181611830015281816119aa01526122840152f35b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036200017e5756fe6080604052600480361015610051575b50361561001b57600080fd5b61004f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163314611e74565b005b6000803560e01c806302751cec1461198d578063054d50d41461197357806318cbafe5146117ed5780631f00ca74146117b15780632195995c1461164257806338ed1739146115b85780634a25d94a146113d35780635b0d5984146112bb5780635c11d79514611234578063791ac9471461107c5780637ff36ab514610f2657806385f8c25914610f0c5780638803dbee14610e3c578063ad5c464814610df8578063ad615dec14610dde578063af2979eb14610db6578063b6f9de9514610b67578063baa2abde146109db578063c45a015514610997578063d06ca61f1461095b578063ded9382a146105fd578063e8e33700146104cf578063f305d7191461032a5763fb3bdb4114610165575061000f565b61016e36611e28565b939093421161032657811561031357610186836124f8565b906001600160a01b0391827f000000000000000000000000000000000000000000000000000000000000000016928391160361030f576101f37f0000000000000000000000000000000000000000000000000000000000000000916101ec368688611d20565b9083612dd4565b956101fd876124b1565b5134106102fd5761020d876124b1565b51833b1561030b5781899160405192838092630d0e30db60e41b8252885af18015610300579082916102e9575b5050610245856124f8565b9084600110156102d6576102b1886102948961028e8a8a6102878b6102778c8c610271602088016124f8565b91612a03565b610280896124b1565b51916121e3565b3691611d20565b83612581565b61029d816124b1565b5134116102b5575b60405191829182611c81565b0390f35b6102d16102cb6102c4836124b1565b51346121c0565b33612249565b6102a5565b8060328a634e487b7160e01b6024945252fd5b6102f290611cbc565b6102fd57803861023a565b80fd5b6040513d84823e3d90fd5b5080fd5b8580fd5b602485603288634e487b7160e01b835252fd5b8480fd5b5061033436611ba7565b969492909695939542116104cb5790610372917f00000000000000000000000000000000000000000000000000000000000000009634908886612004565b9590946103a081847f0000000000000000000000000000000000000000000000000000000000000000612a03565b9283916103bb886001600160a01b0396879485339116611e91565b16803b1561032657604051630d0e30db60e41b8152858188818c865af180156104c0579189918794936104a5575b5094826103fe602495938397956020996121e3565b60405198899687956335313c2160e11b87521690850152165af19081156104995790610461575b6102b1915083341161044f575b604051938493846040919493926060820195825260208201520152565b61045c6102cb85346121c0565b610432565b506020813d8211610491575b8161047a60209383611ce6565b8101031261048c576102b19051610425565b600080fd5b3d915061046d565b604051903d90823e3d90fd5b6104b29193949250611cbc565b6103265790878592386103e9565b6040513d88823e3d90fd5b8380fd5b50903461030b5761010036600319011261030b576104eb611b65565b906104f4611b7b565b9060c435906001600160a01b0380831680930361048c574260e4351061030f579160246020928761058397989561053860a4356084356064358d8c60443591612004565b8b8a61057a61056d849f9d869f969e7f0000000000000000000000000000000000000000000000000000000000000000612a03565b9c8d809488339116611e91565b84339116611e91565b60405197889586946335313c2160e11b8652850152165af190811561049957906105ca575b6102b19150604051938493846040919493926060820195825260208201520152565b506020813d82116105f5575b816105e360209383611ce6565b8101031261048c576102b190516105a8565b3d91506105d6565b50346102fd5761060c36611dc2565b6106619b98959b9997999392937f0000000000000000000000000000000000000000000000000000000000000000897f0000000000000000000000000000000000000000000000000000000000000000612a03565b921561095457600019915b6001600160a01b0384163b15610950576040805163d505accf60e01b815233818d01908152306020820152918201949094526060810187905260ff909516608086015260a085015260c08401529189918391829084906001600160a01b0390839060e0010393165af180156109455790889161092d575b5050421161030f57610777602061073b7f0000000000000000000000000000000000000000000000000000000000000000867f0000000000000000000000000000000000000000000000000000000000000000612a03565b604080516323b872dd60e01b8152338982019081526001600160a01b039093166020840181905291830195909552939283918291606090910190565b03818a865af18015610922579160409188969594936108f4575b50602482518099819363226bf2d160e21b835230898401525af19586156108e957849085976108af575b506001600160a01b03806107ef7f0000000000000000000000000000000000000000000000000000000000000000866129d4565b509416931683036108a95795945b86106104cb5784106108a5578486610814926121e3565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690813b156108a5578360248492836040519586948593632e1a7d4d60e01b85528401525af1801561030057610891575b5050610885816001600160a01b0360409516612249565b82519182526020820152f35b61089b8291611cbc565b6102fd578061086e565b8280fd5b946107fd565b9650506040863d6040116108e1575b816108cb60409383611ce6565b810103126104cb576020865196015195386107bb565b3d91506108be565b6040513d86823e3d90fd5b6109149060203d811161091b575b61090c8183611ce6565b810190611edc565b5038610791565b503d610902565b6040513d89823e3d90fd5b61093690611cbc565b6109415786386106e3565b8680fd5b6040513d8a823e3d90fd5b8b80fd5b859161066c565b50346102fd576102b16102a561097036611d7e565b907f0000000000000000000000000000000000000000000000000000000000000000612d2d565b50346102fd57806003193601126102fd5760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b50903461030b5760e036600319011261030b576109f6611b65565b906109ff611b7b565b91610a08611b91565b4260c4351061032657610a3c84837f0000000000000000000000000000000000000000000000000000000000000000612a03565b604080516323b872dd60e01b8152338682019081526001600160a01b039384166020828101829052604435948301949094529394919290839081906060015b03818b875af190888215610499576040948694602494610b49575b508551988995869463226bf2d160e21b865216908401525af1938415610b3e5785938695610b00575b50610acb8291846129d4565b5016911614600014610afb57905b60643582106108a55760843581106108a5576040809350519182526020820152f35b610ad9565b935093506040833d604011610b36575b81610b1d60409383611ce6565b8101031261032657825160209093015193610acb610abf565b3d9150610b10565b6040513d87823e3d90fd5b610b609060203d811161091b5761090c8183611ce6565b5038610a96565b5090610b7236611e28565b949092919394421161030f578315610da357610b8d826124f8565b6001600160a01b03937f0000000000000000000000000000000000000000000000000000000000000000851692918516839003610d9f57823b15610d9f5787604051630d0e30db60e41b81528181858134895af1801561030057610d8b575b5050610bf7846124f8565b8660011015610d7857610c4490602094610c3e3492610c17888a016124f8565b907f0000000000000000000000000000000000000000000000000000000000000000612a03565b906121e3565b6000198601868111610d655785610c64610c5f838a896124e8565b6124f8565b1696604051956370a0823160e01b9384885286886024818c85169d8e8b8301525afa978815610d5a578c98610d1e575b506024949387989993610cbd93610cb8610c5f94610cb3368585611d20565b612749565b6124e8565b16604051978894859384528301525afa908115610b3e578591610cee575b50610ce692506121c0565b106102fd5780f35b905082813d8311610d17575b610d048183611ce6565b8101031261048c57610ce6915138610cdb565b503d610cfa565b90989294939680985081813d8311610d53575b610d3b8183611ce6565b8101031261048c575191979196959293916024610c94565b503d610d31565b6040513d8e823e3d90fd5b602489601185634e487b7160e01b835252fd5b602489603285634e487b7160e01b835252fd5b610d9490611cbc565b610d9f578738610bec565b8780fd5b856032602492634e487b7160e01b835252fd5b50346102fd576020610dd6610dca36611ba7565b94939093929192612276565b604051908152f35b50346102fd576020610dd6610df236611be7565b91612c00565b50346102fd57806003193601126102fd5760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346102fd57610e4b36611c32565b9591929395949094421161030b57610e897f0000000000000000000000000000000000000000000000000000000000000000916101ec368688611d20565b95610e93876124b1565b511161030b578215610ef9576001600160a01b03610eb0856124f8565b1691610ebb856124f8565b9084600110156102d6576102b1886102a58961028e8a8a6102878b610ee78c8c610271602088016124f8565b610ef0896124b1565b51913390611e91565b602482603289634e487b7160e01b835252fd5b50346102fd576020610dd6610f2036611be7565b91612c89565b50610f3036611e28565b9490939442116102fd57811561106957610f49836124f8565b906001600160a01b0391827f00000000000000000000000000000000000000000000000000000000000000001692839116036102fd577f000000000000000000000000000000000000000000000000000000000000000090610fb6610faf368688611d20565b3484612d2d565b968751600019810190811161105657610fcf90896124d4565b51106102fd57610fde876124b1565b51833b1561030b5781899160405192838092630d0e30db60e41b8252885af1801561030057908291611042575b5050611016856124f8565b9084600110156102d6576102b1886102a58961028e8a8a6102878b6102778c8c610271602088016124f8565b61104b90611cbc565b6102fd57803861100b565b60248360118c634e487b7160e01b835252fd5b80603287634e487b7160e01b6024945252fd5b50903461030b5761108c36611c32565b95919095949394421161094157600019810181811161122157610c5f6110b39183866124e8565b6001600160a01b03947f000000000000000000000000000000000000000000000000000000000000000086169491861685900361121d57821561120a57856110fa836124f8565b16611104836124f8565b84600110156111f757926111358b97969593610cb39361112d61113e97610c17602087016124f8565b903390611e91565b30923691611d20565b604051946370a0823160e01b86523082870152602086602481865afa9586156108e95784966111c1575b5085106108a557813b156108a5578460248492836040519586948593632e1a7d4d60e01b85528401525af18015610300576111ad575b50506111aa9216612249565b80f35b6111b690611cbc565b6104cb57833861119e565b935094506020833d82116111ef575b816111dd60209383611ce6565b8101031261048c578692519438611168565b3d91506111d0565b60248b603288634e487b7160e01b835252fd5b602489603286634e487b7160e01b835252fd5b8880fd5b602488601185634e487b7160e01b835252fd5b50903461030b5761124436611c32565b9590939594919442116109415784156112a8576001600160a01b03938461126a856124f8565b1692611275856124f8565b9387600110156112955790610c449161112d602096610c17888a016124f8565b60248a603286634e487b7160e01b835252fd5b866032602492634e487b7160e01b835252fd5b50903461030b576112cb36611dc2565b6113249b959a919392949b9996999897987f0000000000000000000000000000000000000000000000000000000000000000887f0000000000000000000000000000000000000000000000000000000000000000612a03565b92156113c4576001600160a01b03600019935b1693843b15610941576040805163d505accf60e01b81523394810194855230602086015290840194909452606083018d905260ff909516608083015260a082019490945260c0810193909352918391839182908490829060e00103925af18015610300576113b0575b6020610dd6898989898989612276565b6113ba8291611cbc565b6102fd57806113a0565b6001600160a01b038893611337565b50346102fd576113e236611c32565b95919290949395421161030b57600019928084018181116115a557610c5f61140b9183856124e8565b6001600160a01b03957f0000000000000000000000000000000000000000000000000000000000000000871693918716849003610326576114727f0000000000000000000000000000000000000000000000000000000000000000916101ec368686611d20565b9861147c8a6124b1565b51116103265782156115925786611492836124f8565b169061149d836124f8565b846001101561157f576114cc926114c385936111359361027160206114d29a99016124f8565b610ef08d6124b1565b88612581565b855183810190811161156c576114e890876124d4565b51813b156108a5578291602483926040519485938492632e1a7d4d60e01b84528d8401525af1801561030057908291611558575b50508451918201918211611545576102b1856102a5868661153d87856124d4565b519116612249565b80601187634e487b7160e01b6024945252fd5b61156190611cbc565b6102fd57803861151c565b60248360118a634e487b7160e01b835252fd5b60248760328e634e487b7160e01b835252fd5b60248560328c634e487b7160e01b835252fd5b60248460118b634e487b7160e01b835252fd5b50346102fd576115c736611c32565b9591929395949094421161030b5761160c7f000000000000000000000000000000000000000000000000000000000000000091611605368688611d20565b9083612d2d565b95865160001981019081116115a55761162590886124d4565b511061030b578215610ef9576001600160a01b03610eb0856124f8565b50903461030b5761016036600319011261030b5761165e611b65565b90611667611b7b565b91604435611673611b91565b9060c43560e43592831515840361048c57610104359160ff8316830361048c57887f0000000000000000000000000000000000000000000000000000000000000000936116c18a8987612a03565b96156117aa57600019905b6001600160a01b0380981691823b156104cb576040805163d505accf60e01b815233818e01908152306020820152918201929092526060810186905260ff90921660808301526101243560a08301526101443560c083015291839183919082908490829060e00103925af1801561030057611796575b50504211610d9f57602061175a8887610a7b95612a03565b604080516323b872dd60e01b8152338a82019081526001600160a01b038416602082015291820196909652908616949384918291606090910190565b61179f90611cbc565b61121d578838611742565b85906116cc565b50346102fd576102b16102a56117c636611d7e565b907f0000000000000000000000000000000000000000000000000000000000000000612dd4565b50346102fd576117fc36611c32565b95919290949395421161030b57600019928084018181116115a557610c5f6118259183856124e8565b6001600160a01b03957f00000000000000000000000000000000000000000000000000000000000000008716939187168490036103265761188c7f000000000000000000000000000000000000000000000000000000000000000091611605368686611d20565b988951878101908111611960576118a3908b6124d4565b511061032657821561159257866118b9836124f8565b16906118c4836124f8565b846001101561157f576114cc926114c385936111359361027160206118ea9a99016124f8565b855183810190811161156c5761190090876124d4565b51813b156108a5578291602483926040519485938492632e1a7d4d60e01b84528d8401525af1801561030057611951575b508451918201918211611545576102b1856102a5868661153d87856124d4565b61195a90611cbc565b38611931565b60248760118e634e487b7160e01b835252fd5b50346102fd576020610dd661198736611be7565b91612c2f565b50346102fd5761199c36611ba7565b969294909396421161030f577f0000000000000000000000000000000000000000000000000000000000000000916119f583837f0000000000000000000000000000000000000000000000000000000000000000612a03565b604080516323b872dd60e01b8152338782019081526001600160a01b0393841660208281018290529382019c909c52929a929091908290819060600103818c865af18015611b5a57916040918a96959493611b3c575b5060248251809b819363226bf2d160e21b8352308b8401525af19788156108e95784908599611b02575b508980611a8286866129d4565b50941693168303611afc5797965b88106104cb5786106108a55790611aa987868a946121e3565b1691823b1561030b578460248392836040519687948593632e1a7d4d60e01b85528401525af1908115610499575094610885928492604097611aed575b5016612249565b611af690611cbc565b38611ae6565b96611a90565b9850506040883d604011611b34575b81611b1e60409383611ce6565b810103126104cb57602088519801519738611a75565b3d9150611b11565b611b539060203d811161091b5761090c8183611ce6565b5038611a4b565b6040513d8b823e3d90fd5b600435906001600160a01b038216820361048c57565b602435906001600160a01b038216820361048c57565b60a435906001600160a01b038216820361048c57565b60c090600319011261048c576001600160a01b03600435818116810361048c5791602435916044359160643591608435908116810361048c579060a43590565b606090600319011261048c57600435906024359060443590565b9181601f8401121561048c5782359167ffffffffffffffff831161048c576020808501948460051b01011161048c57565b60a060031982011261048c5760043591602435916044359067ffffffffffffffff821161048c57611c6591600401611c01565b90916064356001600160a01b038116810361048c579060843590565b6020908160408183019282815285518094520193019160005b828110611ca8575050505090565b835185529381019392810192600101611c9a565b67ffffffffffffffff8111611cd057604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff821117611cd057604052565b67ffffffffffffffff8111611cd05760051b60200190565b9291611d2b82611d08565b91611d396040519384611ce6565b829481845260208094019160051b810192831161048c57905b828210611d5f5750505050565b81356001600160a01b038116810361048c578152908301908301611d52565b90604060031983011261048c57600435916024359067ffffffffffffffff821161048c578060238301121561048c57816024611dbf93600401359101611d20565b90565b61014090600319011261048c576001600160a01b03600435818116810361048c5791602435916044359160643591608435908116810361048c579060a4359060c435801515810361048c579060e43560ff8116810361048c579061010435906101243590565b90608060031983011261048c57600435916024359067ffffffffffffffff821161048c57611e5891600401611c01565b90916044356001600160a01b038116810361048c579060643590565b15611e7b57565b634e487b7160e01b600052600160045260246000fd5b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152611eda91611ed5608483611ce6565b611ef4565b565b9081602091031261048c5751801515810361048c5790565b6001600160a01b0316906040516040810181811067ffffffffffffffff821117611cd05760405260208082527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564910152813b1561048c57600081611f6b938260208195519301915af1611f65611f8f565b90611fcf565b80519081611f77575050565b602080611f88938301019101611edc565b1561048c57565b3d15611fca573d9067ffffffffffffffff8211611cd05760405191611fbe601f8201601f191660200184611ce6565b82523d6000602084013e565b606090565b15611fd75790565b805190811561048c57602001fd5b9081602091031261048c57516001600160a01b038116810361048c5790565b6040517fe6a439050000000000000000000000000000000000000000000000000000000081526001600160a01b03828116600483015283811660248301529396949594937f0000000000000000000000000000000000000000000000000000000000000000808216949392909160209182816044818a5afa908115612197576000916121a3575b501615612107575b5061209e9350612b36565b92908015806120ff575b156120b557505050509091565b6120c484828897959697612c00565b948386116120da5750505050811061048c579091565b836120f59496506120ec939550612c00565b93841115611e74565b821061048c579091565b5083156120a8565b6040517fc9c653960000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015285166024820152948190869060449082906000905af19485156121975761209e95612169575b50612093565b8161218892903d10612190575b6121808183611ce6565b810190611fe5565b503880612163565b503d612176565b6040513d6000823e3d90fd5b6121ba9150833d8511612190576121808183611ce6565b3861208b565b919082039182116121cd57565b634e487b7160e01b600052601160045260246000fd5b916001600160a01b03604051927fa9059cbb000000000000000000000000000000000000000000000000000000006020850152166024830152604482015260448152608081019181831067ffffffffffffffff841117611cd057611eda92604052611ef4565b81471061048c576001600160a01b0390600080809481948294165af161226d611f8f565b50156102fd5750565b929594939193421161048c577f00000000000000000000000000000000000000000000000000000000000000006122ce81857f0000000000000000000000000000000000000000000000000000000000000000612a03565b604080516323b872dd60e01b81523360048201526001600160a01b039283166024820181905260448201959095529398899792969194602093908481806064810103816000809e5af180156124a7579b87918b9c9d9b999a9b61248a575b5060248251809d819363226bf2d160e21b83523060048401525af1998a15612480578790889b61244b575b50898061236488876129d4565b50951694168403612445575b1061030f5788106103265783516370a0823160e01b81523060048201528281602481855afa92831561243b57918791899594938894612402575b5050906123b792916121e3565b16803b156108a5578280916024845180968193632e1a7d4d60e01b83528b60048401525af19182156123f857505091611dbf93918593611aed575016612249565b51903d90823e3d90fd5b9250925092935081813d8311612434575b61241d8183611ce6565b81010312610326575186929186906123b7386123aa565b503d612413565b85513d88823e3d90fd5b99612370565b809b50878092503d8311612479575b6124648183611ce6565b8101031261094157838a519a01519938612357565b503d61245a565b86513d89823e3d90fd5b6124a090873d891161091b5761090c8183611ce6565b503861232c565b87513d8c823e3d90fd5b8051156124be5760200190565b634e487b7160e01b600052603260045260246000fd5b80518210156124be5760209160051b010190565b91908110156124be5760051b0190565b356001600160a01b038116810361048c5790565b60001981146121cd5760010190565b926001600160a01b0391959492958452602095868501521660408301526080606083015280519081608084015260005b82811061256d57505060a09293506000838284010152601f8019910116010190565b81810186015184820160a00152850161254b565b7f000000000000000000000000000000000000000000000000000000000000000093929160005b815160001981019081116121cd578110156126f0576001600160a01b03806125d083856124d4565b5116600183018084116121cd57826125e882876124d4565b511692806126016125f986866129d4565b5093896124d4565b51921683036126e857600091935b865160011981019081116121cd578610156126dd5760028601908187116121cd5761264b8c8285612643612653968d6124d4565b511691612a03565b945b8c612a03565b16916040928351946020860186811067ffffffffffffffff821117611cd057855260008652813b1561048c57600080946126a287519889968795869463022c0d9f60e01b86526004860161251b565b03925af19081156126d35750906126bf92916126c4575b5061250c565b6125a8565b6126cd90611cbc565b386126b9565b513d6000823e3d90fd5b61265390899461264d565b60009361260f565b505050509050565b51906dffffffffffffffffffffffffffff8216820361048c57565b9081606091031261048c57612727816126f8565b916040612736602084016126f8565b92015163ffffffff8116810361048c5790565b9091907f00000000000000000000000000000000000000000000000000000000000000009060005b815160001981019081116121cd578110156129cd576001600160a01b038061279983856124d4565b5116600183018084116121cd576127b18391866124d4565b51166127bd81836129d4565b5092806127cb83858a612a03565b16604093845190630240bc6b60e21b825260609460049580848881885afa9384156129c257908691600091829661298d575b50506dffffffffffffffffffffffffffff809116941698168214928360001461298857975b8751988980946370a0823160e01b8252878a830152602095869160249d8e915afa90811561297d5760009161294e575b50906128628161286794936121c0565b612c2f565b921561294657600092945b8a516001198101908111612929578a101561293d5760028a01808b1161292957906128a16128aa93928d6124d4565b5116908c612a03565b965b86519182019082821067ffffffffffffffff8311176129165750865260008152823b1561048c576000946128f586928851998a978896879563022c0d9f60e01b8752860161251b565b03925af19081156126d357509061291192916126c4575061250c565b612771565b604187634e487b7160e01b600052526000fd5b89601189634e487b7160e01b600052526000fd5b50508b966128ac565b600094612872565b908582813d8311612976575b6129648183611ce6565b810103126102fd575051612862612852565b503d61295a565b8a513d6000823e3d90fd5b612822565b6129b193965080919250903d106129bb575b6129a98183611ce6565b810190612713565b50939038806127fd565b503d61299f565b88513d6000823e3d90fd5b5050509050565b90916001600160a01b039182841683821681811461048c5710156129fe57925b9183161561048c57565b6129f4565b91612a0d916129d4565b9190604051927f6f2ddd930000000000000000000000000000000000000000000000000000000084526020846004816001600160a01b0387165afa93841561219757600094612b16575b506040519160208301916bffffffffffffffffffffffff19809260601b16835260601b166034830152602882526060820182811067ffffffffffffffff821117611cd0576055946097946037938360405285519020917f3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000845260601b60748601527f5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000608886015260601b609885015260ac8401522060cc820152012090565b612b2f91945060203d8111612190576121808183611ce6565b9238612a57565b90806060600493612b5c612b4a87856129d4565b50966001600160a01b03948593612a03565b1660405194858092630240bc6b60e21b82525afa928315612197576000908194612bab575b5081906dffffffffffffffffffffffffffff80911694169416911614600014612ba75791565b9091565b829450612bc6915060603d81116129bb576129a98183611ce6565b5093612b81565b818102929181159184041417156121cd57565b8115612bea570490565b634e487b7160e01b600052601260045260246000fd5b801561048c5781151580612c26575b1561048c57611dbf92612c2191612bcd565b612be0565b50821515612c0f565b801561048c57811592831580612c80575b1561048c576103e3808302928304036121cd57612c5d9082612bcd565b926103e88084029384041417156121cd5781018091116121cd57611dbf91612be0565b50801515612c40565b9190821561048c5780151580612cf2575b1561048c5782612ca991612bcd565b916103e8928381029381850414901517156121cd57612cc7916121c0565b6103e3908181029181830414901517156121cd57612ce491612be0565b600181018091116121cd5790565b50811515612c9a565b90612d0582611d08565b612d126040519182611ce6565b8281528092612d23601f1991611d08565b0190602036910137565b929180516002811061048c57612d4290612cfb565b918251156124be57602083015260005b815160001981019081116121cd57811015612dce576001600160a01b039081612d7b82856124d4565b51169160018201908183116121cd57612dbc612dab612dc995612dc393612da2868a6124d4565b5116908b612b36565b90612db6868a6124d4565b51612c2f565b91866124d4565b5261250c565b612d52565b50509150565b92919283516002811061048c57612dea90612cfb565b93845192600019938481019081116121cd57612e0690876124d4565b5280518381019081116121cd57805b612e1f5750505050565b838101818111612e8257612e73612e6c612e5b6001600160a01b0380612e4586896124d4565b511690612e5287896124d4565b51169088612b36565b90612e66868c6124d4565b51612c89565b91886124d4565b528015612e8257830180612e15565b60246000634e487b7160e01b81526011600452fdfea2646970667358221220677d35228e5ba0aeea862faeacb9d61fa248871f27be27fff3bd3370acdbba8564736f6c6343000811003300000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Deployed Bytecode
0x6080604052600480361015610051575b50361561001b57600080fd5b61004f6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2163314611e74565b005b6000803560e01c806302751cec1461198d578063054d50d41461197357806318cbafe5146117ed5780631f00ca74146117b15780632195995c1461164257806338ed1739146115b85780634a25d94a146113d35780635b0d5984146112bb5780635c11d79514611234578063791ac9471461107c5780637ff36ab514610f2657806385f8c25914610f0c5780638803dbee14610e3c578063ad5c464814610df8578063ad615dec14610dde578063af2979eb14610db6578063b6f9de9514610b67578063baa2abde146109db578063c45a015514610997578063d06ca61f1461095b578063ded9382a146105fd578063e8e33700146104cf578063f305d7191461032a5763fb3bdb4114610165575061000f565b61016e36611e28565b939093421161032657811561031357610186836124f8565b906001600160a01b0391827f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216928391160361030f576101f37f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080916101ec368688611d20565b9083612dd4565b956101fd876124b1565b5134106102fd5761020d876124b1565b51833b1561030b5781899160405192838092630d0e30db60e41b8252885af18015610300579082916102e9575b5050610245856124f8565b9084600110156102d6576102b1886102948961028e8a8a6102878b6102778c8c610271602088016124f8565b91612a03565b610280896124b1565b51916121e3565b3691611d20565b83612581565b61029d816124b1565b5134116102b5575b60405191829182611c81565b0390f35b6102d16102cb6102c4836124b1565b51346121c0565b33612249565b6102a5565b8060328a634e487b7160e01b6024945252fd5b6102f290611cbc565b6102fd57803861023a565b80fd5b6040513d84823e3d90fd5b5080fd5b8580fd5b602485603288634e487b7160e01b835252fd5b8480fd5b5061033436611ba7565b969492909695939542116104cb5790610372917f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29634908886612004565b9590946103a081847f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612a03565b9283916103bb886001600160a01b0396879485339116611e91565b16803b1561032657604051630d0e30db60e41b8152858188818c865af180156104c0579189918794936104a5575b5094826103fe602495938397956020996121e3565b60405198899687956335313c2160e11b87521690850152165af19081156104995790610461575b6102b1915083341161044f575b604051938493846040919493926060820195825260208201520152565b61045c6102cb85346121c0565b610432565b506020813d8211610491575b8161047a60209383611ce6565b8101031261048c576102b19051610425565b600080fd5b3d915061046d565b604051903d90823e3d90fd5b6104b29193949250611cbc565b6103265790878592386103e9565b6040513d88823e3d90fd5b8380fd5b50903461030b5761010036600319011261030b576104eb611b65565b906104f4611b7b565b9060c435906001600160a01b0380831680930361048c574260e4351061030f579160246020928761058397989561053860a4356084356064358d8c60443591612004565b8b8a61057a61056d849f9d869f969e7f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612a03565b9c8d809488339116611e91565b84339116611e91565b60405197889586946335313c2160e11b8652850152165af190811561049957906105ca575b6102b19150604051938493846040919493926060820195825260208201520152565b506020813d82116105f5575b816105e360209383611ce6565b8101031261048c576102b190516105a8565b3d91506105d6565b50346102fd5761060c36611dc2565b6106619b98959b9997999392937f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2897f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612a03565b921561095457600019915b6001600160a01b0384163b15610950576040805163d505accf60e01b815233818d01908152306020820152918201949094526060810187905260ff909516608086015260a085015260c08401529189918391829084906001600160a01b0390839060e0010393165af180156109455790889161092d575b5050421161030f57610777602061073b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2867f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612a03565b604080516323b872dd60e01b8152338982019081526001600160a01b039093166020840181905291830195909552939283918291606090910190565b03818a865af18015610922579160409188969594936108f4575b50602482518099819363226bf2d160e21b835230898401525af19586156108e957849085976108af575b506001600160a01b03806107ef7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2866129d4565b509416931683036108a95795945b86106104cb5784106108a5578486610814926121e3565b6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21690813b156108a5578360248492836040519586948593632e1a7d4d60e01b85528401525af1801561030057610891575b5050610885816001600160a01b0360409516612249565b82519182526020820152f35b61089b8291611cbc565b6102fd578061086e565b8280fd5b946107fd565b9650506040863d6040116108e1575b816108cb60409383611ce6565b810103126104cb576020865196015195386107bb565b3d91506108be565b6040513d86823e3d90fd5b6109149060203d811161091b575b61090c8183611ce6565b810190611edc565b5038610791565b503d610902565b6040513d89823e3d90fd5b61093690611cbc565b6109415786386106e3565b8680fd5b6040513d8a823e3d90fd5b8b80fd5b859161066c565b50346102fd576102b16102a561097036611d7e565b907f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612d2d565b50346102fd57806003193601126102fd5760206040516001600160a01b037f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080168152f35b50903461030b5760e036600319011261030b576109f6611b65565b906109ff611b7b565b91610a08611b91565b4260c4351061032657610a3c84837f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612a03565b604080516323b872dd60e01b8152338682019081526001600160a01b039384166020828101829052604435948301949094529394919290839081906060015b03818b875af190888215610499576040948694602494610b49575b508551988995869463226bf2d160e21b865216908401525af1938415610b3e5785938695610b00575b50610acb8291846129d4565b5016911614600014610afb57905b60643582106108a55760843581106108a5576040809350519182526020820152f35b610ad9565b935093506040833d604011610b36575b81610b1d60409383611ce6565b8101031261032657825160209093015193610acb610abf565b3d9150610b10565b6040513d87823e3d90fd5b610b609060203d811161091b5761090c8183611ce6565b5038610a96565b5090610b7236611e28565b949092919394421161030f578315610da357610b8d826124f8565b6001600160a01b03937f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2851692918516839003610d9f57823b15610d9f5787604051630d0e30db60e41b81528181858134895af1801561030057610d8b575b5050610bf7846124f8565b8660011015610d7857610c4490602094610c3e3492610c17888a016124f8565b907f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612a03565b906121e3565b6000198601868111610d655785610c64610c5f838a896124e8565b6124f8565b1696604051956370a0823160e01b9384885286886024818c85169d8e8b8301525afa978815610d5a578c98610d1e575b506024949387989993610cbd93610cb8610c5f94610cb3368585611d20565b612749565b6124e8565b16604051978894859384528301525afa908115610b3e578591610cee575b50610ce692506121c0565b106102fd5780f35b905082813d8311610d17575b610d048183611ce6565b8101031261048c57610ce6915138610cdb565b503d610cfa565b90989294939680985081813d8311610d53575b610d3b8183611ce6565b8101031261048c575191979196959293916024610c94565b503d610d31565b6040513d8e823e3d90fd5b602489601185634e487b7160e01b835252fd5b602489603285634e487b7160e01b835252fd5b610d9490611cbc565b610d9f578738610bec565b8780fd5b856032602492634e487b7160e01b835252fd5b50346102fd576020610dd6610dca36611ba7565b94939093929192612276565b604051908152f35b50346102fd576020610dd6610df236611be7565b91612c00565b50346102fd57806003193601126102fd5760206040516001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2168152f35b50346102fd57610e4b36611c32565b9591929395949094421161030b57610e897f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080916101ec368688611d20565b95610e93876124b1565b511161030b578215610ef9576001600160a01b03610eb0856124f8565b1691610ebb856124f8565b9084600110156102d6576102b1886102a58961028e8a8a6102878b610ee78c8c610271602088016124f8565b610ef0896124b1565b51913390611e91565b602482603289634e487b7160e01b835252fd5b50346102fd576020610dd6610f2036611be7565b91612c89565b50610f3036611e28565b9490939442116102fd57811561106957610f49836124f8565b906001600160a01b0391827f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21692839116036102fd577f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b52408090610fb6610faf368688611d20565b3484612d2d565b968751600019810190811161105657610fcf90896124d4565b51106102fd57610fde876124b1565b51833b1561030b5781899160405192838092630d0e30db60e41b8252885af1801561030057908291611042575b5050611016856124f8565b9084600110156102d6576102b1886102a58961028e8a8a6102878b6102778c8c610271602088016124f8565b61104b90611cbc565b6102fd57803861100b565b60248360118c634e487b7160e01b835252fd5b80603287634e487b7160e01b6024945252fd5b50903461030b5761108c36611c32565b95919095949394421161094157600019810181811161122157610c5f6110b39183866124e8565b6001600160a01b03947f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc286169491861685900361121d57821561120a57856110fa836124f8565b16611104836124f8565b84600110156111f757926111358b97969593610cb39361112d61113e97610c17602087016124f8565b903390611e91565b30923691611d20565b604051946370a0823160e01b86523082870152602086602481865afa9586156108e95784966111c1575b5085106108a557813b156108a5578460248492836040519586948593632e1a7d4d60e01b85528401525af18015610300576111ad575b50506111aa9216612249565b80f35b6111b690611cbc565b6104cb57833861119e565b935094506020833d82116111ef575b816111dd60209383611ce6565b8101031261048c578692519438611168565b3d91506111d0565b60248b603288634e487b7160e01b835252fd5b602489603286634e487b7160e01b835252fd5b8880fd5b602488601185634e487b7160e01b835252fd5b50903461030b5761124436611c32565b9590939594919442116109415784156112a8576001600160a01b03938461126a856124f8565b1692611275856124f8565b9387600110156112955790610c449161112d602096610c17888a016124f8565b60248a603286634e487b7160e01b835252fd5b866032602492634e487b7160e01b835252fd5b50903461030b576112cb36611dc2565b6113249b959a919392949b9996999897987f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2887f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612a03565b92156113c4576001600160a01b03600019935b1693843b15610941576040805163d505accf60e01b81523394810194855230602086015290840194909452606083018d905260ff909516608083015260a082019490945260c0810193909352918391839182908490829060e00103925af18015610300576113b0575b6020610dd6898989898989612276565b6113ba8291611cbc565b6102fd57806113a0565b6001600160a01b038893611337565b50346102fd576113e236611c32565b95919290949395421161030b57600019928084018181116115a557610c5f61140b9183856124e8565b6001600160a01b03957f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2871693918716849003610326576114727f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080916101ec368686611d20565b9861147c8a6124b1565b51116103265782156115925786611492836124f8565b169061149d836124f8565b846001101561157f576114cc926114c385936111359361027160206114d29a99016124f8565b610ef08d6124b1565b88612581565b855183810190811161156c576114e890876124d4565b51813b156108a5578291602483926040519485938492632e1a7d4d60e01b84528d8401525af1801561030057908291611558575b50508451918201918211611545576102b1856102a5868661153d87856124d4565b519116612249565b80601187634e487b7160e01b6024945252fd5b61156190611cbc565b6102fd57803861151c565b60248360118a634e487b7160e01b835252fd5b60248760328e634e487b7160e01b835252fd5b60248560328c634e487b7160e01b835252fd5b60248460118b634e487b7160e01b835252fd5b50346102fd576115c736611c32565b9591929395949094421161030b5761160c7f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b52408091611605368688611d20565b9083612d2d565b95865160001981019081116115a55761162590886124d4565b511061030b578215610ef9576001600160a01b03610eb0856124f8565b50903461030b5761016036600319011261030b5761165e611b65565b90611667611b7b565b91604435611673611b91565b9060c43560e43592831515840361048c57610104359160ff8316830361048c57887f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080936116c18a8987612a03565b96156117aa57600019905b6001600160a01b0380981691823b156104cb576040805163d505accf60e01b815233818e01908152306020820152918201929092526060810186905260ff90921660808301526101243560a08301526101443560c083015291839183919082908490829060e00103925af1801561030057611796575b50504211610d9f57602061175a8887610a7b95612a03565b604080516323b872dd60e01b8152338a82019081526001600160a01b038416602082015291820196909652908616949384918291606090910190565b61179f90611cbc565b61121d578838611742565b85906116cc565b50346102fd576102b16102a56117c636611d7e565b907f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612dd4565b50346102fd576117fc36611c32565b95919290949395421161030b57600019928084018181116115a557610c5f6118259183856124e8565b6001600160a01b03957f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28716939187168490036103265761188c7f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b52408091611605368686611d20565b988951878101908111611960576118a3908b6124d4565b511061032657821561159257866118b9836124f8565b16906118c4836124f8565b846001101561157f576114cc926114c385936111359361027160206118ea9a99016124f8565b855183810190811161156c5761190090876124d4565b51813b156108a5578291602483926040519485938492632e1a7d4d60e01b84528d8401525af1801561030057611951575b508451918201918211611545576102b1856102a5868661153d87856124d4565b61195a90611cbc565b38611931565b60248760118e634e487b7160e01b835252fd5b50346102fd576020610dd661198736611be7565b91612c2f565b50346102fd5761199c36611ba7565b969294909396421161030f577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2916119f583837f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612a03565b604080516323b872dd60e01b8152338782019081526001600160a01b0393841660208281018290529382019c909c52929a929091908290819060600103818c865af18015611b5a57916040918a96959493611b3c575b5060248251809b819363226bf2d160e21b8352308b8401525af19788156108e95784908599611b02575b508980611a8286866129d4565b50941693168303611afc5797965b88106104cb5786106108a55790611aa987868a946121e3565b1691823b1561030b578460248392836040519687948593632e1a7d4d60e01b85528401525af1908115610499575094610885928492604097611aed575b5016612249565b611af690611cbc565b38611ae6565b96611a90565b9850506040883d604011611b34575b81611b1e60409383611ce6565b810103126104cb57602088519801519738611a75565b3d9150611b11565b611b539060203d811161091b5761090c8183611ce6565b5038611a4b565b6040513d8b823e3d90fd5b600435906001600160a01b038216820361048c57565b602435906001600160a01b038216820361048c57565b60a435906001600160a01b038216820361048c57565b60c090600319011261048c576001600160a01b03600435818116810361048c5791602435916044359160643591608435908116810361048c579060a43590565b606090600319011261048c57600435906024359060443590565b9181601f8401121561048c5782359167ffffffffffffffff831161048c576020808501948460051b01011161048c57565b60a060031982011261048c5760043591602435916044359067ffffffffffffffff821161048c57611c6591600401611c01565b90916064356001600160a01b038116810361048c579060843590565b6020908160408183019282815285518094520193019160005b828110611ca8575050505090565b835185529381019392810192600101611c9a565b67ffffffffffffffff8111611cd057604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff821117611cd057604052565b67ffffffffffffffff8111611cd05760051b60200190565b9291611d2b82611d08565b91611d396040519384611ce6565b829481845260208094019160051b810192831161048c57905b828210611d5f5750505050565b81356001600160a01b038116810361048c578152908301908301611d52565b90604060031983011261048c57600435916024359067ffffffffffffffff821161048c578060238301121561048c57816024611dbf93600401359101611d20565b90565b61014090600319011261048c576001600160a01b03600435818116810361048c5791602435916044359160643591608435908116810361048c579060a4359060c435801515810361048c579060e43560ff8116810361048c579061010435906101243590565b90608060031983011261048c57600435916024359067ffffffffffffffff821161048c57611e5891600401611c01565b90916044356001600160a01b038116810361048c579060643590565b15611e7b57565b634e487b7160e01b600052600160045260246000fd5b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152611eda91611ed5608483611ce6565b611ef4565b565b9081602091031261048c5751801515810361048c5790565b6001600160a01b0316906040516040810181811067ffffffffffffffff821117611cd05760405260208082527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564910152813b1561048c57600081611f6b938260208195519301915af1611f65611f8f565b90611fcf565b80519081611f77575050565b602080611f88938301019101611edc565b1561048c57565b3d15611fca573d9067ffffffffffffffff8211611cd05760405191611fbe601f8201601f191660200184611ce6565b82523d6000602084013e565b606090565b15611fd75790565b805190811561048c57602001fd5b9081602091031261048c57516001600160a01b038116810361048c5790565b6040517fe6a439050000000000000000000000000000000000000000000000000000000081526001600160a01b03828116600483015283811660248301529396949594937f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080808216949392909160209182816044818a5afa908115612197576000916121a3575b501615612107575b5061209e9350612b36565b92908015806120ff575b156120b557505050509091565b6120c484828897959697612c00565b948386116120da5750505050811061048c579091565b836120f59496506120ec939550612c00565b93841115611e74565b821061048c579091565b5083156120a8565b6040517fc9c653960000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015285166024820152948190869060449082906000905af19485156121975761209e95612169575b50612093565b8161218892903d10612190575b6121808183611ce6565b810190611fe5565b503880612163565b503d612176565b6040513d6000823e3d90fd5b6121ba9150833d8511612190576121808183611ce6565b3861208b565b919082039182116121cd57565b634e487b7160e01b600052601160045260246000fd5b916001600160a01b03604051927fa9059cbb000000000000000000000000000000000000000000000000000000006020850152166024830152604482015260448152608081019181831067ffffffffffffffff841117611cd057611eda92604052611ef4565b81471061048c576001600160a01b0390600080809481948294165af161226d611f8f565b50156102fd5750565b929594939193421161048c577f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26122ce81857f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080612a03565b604080516323b872dd60e01b81523360048201526001600160a01b039283166024820181905260448201959095529398899792969194602093908481806064810103816000809e5af180156124a7579b87918b9c9d9b999a9b61248a575b5060248251809d819363226bf2d160e21b83523060048401525af1998a15612480578790889b61244b575b50898061236488876129d4565b50951694168403612445575b1061030f5788106103265783516370a0823160e01b81523060048201528281602481855afa92831561243b57918791899594938894612402575b5050906123b792916121e3565b16803b156108a5578280916024845180968193632e1a7d4d60e01b83528b60048401525af19182156123f857505091611dbf93918593611aed575016612249565b51903d90823e3d90fd5b9250925092935081813d8311612434575b61241d8183611ce6565b81010312610326575186929186906123b7386123aa565b503d612413565b85513d88823e3d90fd5b99612370565b809b50878092503d8311612479575b6124648183611ce6565b8101031261094157838a519a01519938612357565b503d61245a565b86513d89823e3d90fd5b6124a090873d891161091b5761090c8183611ce6565b503861232c565b87513d8c823e3d90fd5b8051156124be5760200190565b634e487b7160e01b600052603260045260246000fd5b80518210156124be5760209160051b010190565b91908110156124be5760051b0190565b356001600160a01b038116810361048c5790565b60001981146121cd5760010190565b926001600160a01b0391959492958452602095868501521660408301526080606083015280519081608084015260005b82811061256d57505060a09293506000838284010152601f8019910116010190565b81810186015184820160a00152850161254b565b7f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b52408093929160005b815160001981019081116121cd578110156126f0576001600160a01b03806125d083856124d4565b5116600183018084116121cd57826125e882876124d4565b511692806126016125f986866129d4565b5093896124d4565b51921683036126e857600091935b865160011981019081116121cd578610156126dd5760028601908187116121cd5761264b8c8285612643612653968d6124d4565b511691612a03565b945b8c612a03565b16916040928351946020860186811067ffffffffffffffff821117611cd057855260008652813b1561048c57600080946126a287519889968795869463022c0d9f60e01b86526004860161251b565b03925af19081156126d35750906126bf92916126c4575b5061250c565b6125a8565b6126cd90611cbc565b386126b9565b513d6000823e3d90fd5b61265390899461264d565b60009361260f565b505050509050565b51906dffffffffffffffffffffffffffff8216820361048c57565b9081606091031261048c57612727816126f8565b916040612736602084016126f8565b92015163ffffffff8116810361048c5790565b9091907f00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b5240809060005b815160001981019081116121cd578110156129cd576001600160a01b038061279983856124d4565b5116600183018084116121cd576127b18391866124d4565b51166127bd81836129d4565b5092806127cb83858a612a03565b16604093845190630240bc6b60e21b825260609460049580848881885afa9384156129c257908691600091829661298d575b50506dffffffffffffffffffffffffffff809116941698168214928360001461298857975b8751988980946370a0823160e01b8252878a830152602095869160249d8e915afa90811561297d5760009161294e575b50906128628161286794936121c0565b612c2f565b921561294657600092945b8a516001198101908111612929578a101561293d5760028a01808b1161292957906128a16128aa93928d6124d4565b5116908c612a03565b965b86519182019082821067ffffffffffffffff8311176129165750865260008152823b1561048c576000946128f586928851998a978896879563022c0d9f60e01b8752860161251b565b03925af19081156126d357509061291192916126c4575061250c565b612771565b604187634e487b7160e01b600052526000fd5b89601189634e487b7160e01b600052526000fd5b50508b966128ac565b600094612872565b908582813d8311612976575b6129648183611ce6565b810103126102fd575051612862612852565b503d61295a565b8a513d6000823e3d90fd5b612822565b6129b193965080919250903d106129bb575b6129a98183611ce6565b810190612713565b50939038806127fd565b503d61299f565b88513d6000823e3d90fd5b5050509050565b90916001600160a01b039182841683821681811461048c5710156129fe57925b9183161561048c57565b6129f4565b91612a0d916129d4565b9190604051927f6f2ddd930000000000000000000000000000000000000000000000000000000084526020846004816001600160a01b0387165afa93841561219757600094612b16575b506040519160208301916bffffffffffffffffffffffff19809260601b16835260601b166034830152602882526060820182811067ffffffffffffffff821117611cd0576055946097946037938360405285519020917f3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000845260601b60748601527f5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000608886015260601b609885015260ac8401522060cc820152012090565b612b2f91945060203d8111612190576121808183611ce6565b9238612a57565b90806060600493612b5c612b4a87856129d4565b50966001600160a01b03948593612a03565b1660405194858092630240bc6b60e21b82525afa928315612197576000908194612bab575b5081906dffffffffffffffffffffffffffff80911694169416911614600014612ba75791565b9091565b829450612bc6915060603d81116129bb576129a98183611ce6565b5093612b81565b818102929181159184041417156121cd57565b8115612bea570490565b634e487b7160e01b600052601260045260246000fd5b801561048c5781151580612c26575b1561048c57611dbf92612c2191612bcd565b612be0565b50821515612c0f565b801561048c57811592831580612c80575b1561048c576103e3808302928304036121cd57612c5d9082612bcd565b926103e88084029384041417156121cd5781018091116121cd57611dbf91612be0565b50801515612c40565b9190821561048c5780151580612cf2575b1561048c5782612ca991612bcd565b916103e8928381029381850414901517156121cd57612cc7916121c0565b6103e3908181029181830414901517156121cd57612ce491612be0565b600181018091116121cd5790565b50811515612c9a565b90612d0582611d08565b612d126040519182611ce6565b8281528092612d23601f1991611d08565b0190602036910137565b929180516002811061048c57612d4290612cfb565b918251156124be57602083015260005b815160001981019081116121cd57811015612dce576001600160a01b039081612d7b82856124d4565b51169160018201908183116121cd57612dbc612dab612dc995612dc393612da2868a6124d4565b5116908b612b36565b90612db6868a6124d4565b51612c2f565b91866124d4565b5261250c565b612d52565b50509150565b92919283516002811061048c57612dea90612cfb565b93845192600019938481019081116121cd57612e0690876124d4565b5280518381019081116121cd57805b612e1f5750505050565b838101818111612e8257612e73612e6c612e5b6001600160a01b0380612e4586896124d4565b511690612e5287896124d4565b51169088612b36565b90612e66868c6124d4565b51612c89565b91886124d4565b528015612e8257830180612e15565b60246000634e487b7160e01b81526011600452fdfea2646970667358221220677d35228e5ba0aeea862faeacb9d61fa248871f27be27fff3bd3370acdbba8564736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
-----Decoded View---------------
Arg [0] : _factory (address): 0x93F9a2765245fBeF39bC1aE79aCbe0222b524080
Arg [1] : _WETH (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000093f9a2765245fbef39bc1ae79acbe0222b524080
Arg [1] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.