Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- UniswapV2DirectPairAdapter
- Optimization enabled
- true
- Compiler version
- v0.8.20+commit.a1b79de6
- Optimization runs
- 999
- EVM Version
- shanghai
- Verified at
- 2026-02-17T14:09:18.011200Z
Constructor Arguments
0x0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000556f4c3aaa6c6b76e1bba0409d99d4a483b29997000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000000000000000000000000000000000000000000f446578746f705632416461707465720000000000000000000000000000000000
Arg [0] (string) : DextopV2Adapter
Arg [1] (address) : 0x556f4c3aaa6c6b76e1bba0409d99d4a483b29997
Arg [2] (uint256) : 30
Arg [3] (uint256) : 1000000
src/adapters/UniswapV2DirectPairAdapter.sol
// SPDX-License-Identifier: GPL-3.0-only
/*
++++++++++++++++++
+++++++++++++++++++++++++
++++++++++++++++++++++++++++++ +++++++++
+=++++++++++++++++++++++++++++++=++ ++=+++++===++++++++
+++++++++++++++++++++++++++++++++++++++ ++++=++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++==
+=+++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++=++
+++++++++++++++ ++=+++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++ +++++++++++++++++++++++++ ++++++++++++++++++
++++++++++++++ ++++++++++++++++++++ =++++++++++++++++
+++++++++++++++ ++++++++++++++++++ ++++++++++++++++
+++++++++++++++ ++++++++++++++ +++++++++++++=++
+++++++++++++++ +++++++++++ ++++++++++++++++
++++++++++++++ ++++++++ +++++++++++++++
+++++++++++++++ ++++++ ++=++++++++++++
+++++++++++++++ ++++ +++++++++++++++
++++++++++++++++ += +++++++++++++++
+++++++++++++++ ++++++++++++++++
++++++++++++++++ ++++++++++++++++++++
++++++++++++++++ ++++++++++++++++++++++++
++++++++++++++++ +++++++++++++++++++++++++++
+=++++++++++++++ ++++++++++++++++++++++++++++
+=++++++++++++++ +++++++++++++++++++++++++++++++
+++++++++++++++++ ++++++++++++++++++++++++++++++++
+++++++++++++++++ +++++++++++++++++++++++++++++++++
+++++++++++++++++ ++++++++++++++++++++
++=++++++++++++++ =++++++++++++++++
+++++++++++++++++ ++++++++++++++++
++++++++++++++++++ +++++++++++++++
++++++++++++++++++ ++++++++++++++
+++++++++++++++++++ ++++++++++++++
+++++++++++++++==+ ++++++++++++++
+++++++++++++++++++ .. ++++++++++++++
++++++++++++++++++ ......... ++++++++++++++
++=+++++++++++++ ....... ++++++++++++++
+==+++++++++++++ ....... ++++++++++++++
++=+++++++++++++ ....... ++++++++++++++
++=+++++++++++++ ... ++++++++++++++
++++++++++++++++ .. ++++++++++++++
++++++++++++++++ ++++++++++++++
++++++++++++++++ ++++++++++++++
++++++++++++++++ ++++++++++++++
++++++++++++++++ ++++++++++++++
++++++++++++++++ ++++++++++++++
++++++++++++++++ ++++++++++++++
*++**++*******++ ++++++++++++++
*++************* ++++++++++++++
**+************* **************
**************** **************
*************** ***************
**************** ***************
*****************# *****************
******************* ******************
*****************************************************************************
***************************************************************************
*************************************************************************
#################*****************************************************
##########################################################***#####*
###############################################################
###*######################################################
###################################################
Switch.win
https://Switch.win
Built by: BuildTheTech.com
*/
pragma solidity ^0.8.0;
import "../interface/IUniswapFactory.sol";
import "../interface/IUniswapPair.sol";
import "../interface/IERC20.sol";
import "../lib/SafeERC20.sol";
import "../SwitchAdapter.sol";
import "../interface/IDirectPairAdapter.sol";
// This adapter is like UniswapV2Adapter but intended for direct-pair routing:
// - Router can transfer input tokens directly from user to pair (for tax tokens)
// - swap() will only emit the pair swap, with receiver set to the provided _to
contract UniswapV2DirectPairAdapter is SwitchAdapter, IDirectPairAdapter {
using SafeERC20 for IERC20;
uint256 internal constant FEE_DENOMINATOR = 1e4;
uint256 public immutable feeCompliment;
address public immutable factory;
constructor(
string memory _name,
address _factory,
uint256 _fee,
uint256 _swapGasEstimate
) SwitchAdapter(_name, _swapGasEstimate) {
feeCompliment = FEE_DENOMINATOR - _fee;
factory = _factory;
}
// Override to avoid strict min-out requirement; fee-on-transfer tokens may reduce output unpredictably.
function swap(
uint256 _amountIn,
uint256 _amountOut,
address _fromToken,
address _toToken,
address _to
) external override {
uint256 toBal0 = IERC20(_toToken).balanceOf(_to);
_swap(_amountIn, _amountOut, _fromToken, _toToken, _to);
uint256 diff = IERC20(_toToken).balanceOf(_to) - toBal0;
emit SwitchAdapterSwap(_fromToken, _toToken, _amountIn, diff);
}
function getPair(address tokenIn, address tokenOut) external view override returns (address) {
return IUniswapFactory(factory).getPair(tokenIn, tokenOut);
}
function _getAmountOut(
uint256 _amountIn,
uint256 _reserveIn,
uint256 _reserveOut
) internal view returns (uint256 amountOut) {
uint256 amountInWithFee = _amountIn * feeCompliment;
uint256 numerator = amountInWithFee * _reserveOut;
uint256 denominator = _reserveIn * FEE_DENOMINATOR + amountInWithFee;
amountOut = numerator / denominator;
}
function _query(
uint256 _amountIn,
address _tokenIn,
address _tokenOut
) internal view override returns (uint256 amountOut) {
if (_tokenIn == _tokenOut || _amountIn == 0) {
return 0;
}
address pair = IUniswapFactory(factory).getPair(_tokenIn, _tokenOut);
if (pair == address(0)) {
return 0;
}
(uint256 r0, uint256 r1, ) = IUniswapPair(pair).getReserves();
(uint256 reserveIn, uint256 reserveOut) = _tokenIn < _tokenOut ? (r0, r1) : (r1, r0);
if (reserveIn > 0 && reserveOut > 0) {
amountOut = _getAmountOut(_amountIn, reserveIn, reserveOut);
}
}
function _swap(
uint256 _amountIn,
uint256 _amountOut,
address _tokenIn,
address _tokenOut,
address to
) internal override {
address pair = IUniswapFactory(factory).getPair(_tokenIn, _tokenOut);
// Assume input may already be at pair (first hop or pair->pair chaining). For intermediate hops where
// tokens are at this adapter, transfer them to the pair now.
uint256 bal = IERC20(_tokenIn).balanceOf(address(this));
if (bal >= _amountIn) {
IERC20(_tokenIn).safeTransfer(pair, _amountIn);
}
// Compute actual output using current reserves and actual input that arrived at pair
(uint256 r0, uint256 r1, ) = IUniswapPair(pair).getReserves();
(uint256 reserveIn, uint256 reserveOut) = _tokenIn < _tokenOut ? (r0, r1) : (r1, r0);
uint256 balIn = IERC20(_tokenIn).balanceOf(pair);
// Underflow safe since balIn should be >= reserveIn after transfer
uint256 amountInActual = balIn - reserveIn;
uint256 amountOutActual = _getAmountOut(amountInActual, reserveIn, reserveOut);
(uint256 amount0Out, uint256 amount1Out) = (_tokenIn < _tokenOut)
? (uint256(0), amountOutActual)
: (amountOutActual, uint256(0));
IUniswapPair(pair).swap(amount0Out, amount1Out, to, new bytes(0));
}
}
dependencies/openzeppelin-contracts/contracts/access/AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(account),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
dependencies/openzeppelin-contracts/contracts/access/IAccessControl.sol
// 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;
}
dependencies/openzeppelin-contracts/contracts/security/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
dependencies/openzeppelin-contracts/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
dependencies/openzeppelin-contracts/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
dependencies/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol
// 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;
}
}
dependencies/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol
// 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);
}
dependencies/openzeppelin-contracts/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}
dependencies/openzeppelin-contracts/contracts/utils/math/SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}
src/SwitchAdapter.sol
// SPDX-License-Identifier: GPL-3.0-only
/*
++++++++++++++++++
+++++++++++++++++++++++++
++++++++++++++++++++++++++++++ +++++++++
+=++++++++++++++++++++++++++++++=++ ++=+++++===++++++++
+++++++++++++++++++++++++++++++++++++++ ++++=++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+=+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++==
+=+++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++=++
+++++++++++++++ ++=+++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++ +++++++++++++++++++++++++ ++++++++++++++++++
++++++++++++++ ++++++++++++++++++++ =++++++++++++++++
+++++++++++++++ ++++++++++++++++++ ++++++++++++++++
+++++++++++++++ ++++++++++++++ +++++++++++++=++
+++++++++++++++ +++++++++++ ++++++++++++++++
++++++++++++++ ++++++++ +++++++++++++++
+++++++++++++++ ++++++ ++=++++++++++++
+++++++++++++++ ++++ +++++++++++++++
++++++++++++++++ += +++++++++++++++
+++++++++++++++ ++++++++++++++++
++++++++++++++++ ++++++++++++++++++++
++++++++++++++++ ++++++++++++++++++++++++
++++++++++++++++ +++++++++++++++++++++++++++
+=++++++++++++++ ++++++++++++++++++++++++++++
+=++++++++++++++ +++++++++++++++++++++++++++++++
+++++++++++++++++ ++++++++++++++++++++++++++++++++
+++++++++++++++++ +++++++++++++++++++++++++++++++++
+++++++++++++++++ ++++++++++++++++++++
++=++++++++++++++ =++++++++++++++++
+++++++++++++++++ ++++++++++++++++
++++++++++++++++++ +++++++++++++++
++++++++++++++++++ ++++++++++++++
+++++++++++++++++++ ++++++++++++++
+++++++++++++++==+ ++++++++++++++
+++++++++++++++++++ .. ++++++++++++++
++++++++++++++++++ ......... ++++++++++++++
++=+++++++++++++ ....... ++++++++++++++
+==+++++++++++++ ....... ++++++++++++++
++=+++++++++++++ ....... ++++++++++++++
++=+++++++++++++ ... ++++++++++++++
++++++++++++++++ .. ++++++++++++++
++++++++++++++++ ++++++++++++++
++++++++++++++++ ++++++++++++++
++++++++++++++++ ++++++++++++++
++++++++++++++++ ++++++++++++++
++++++++++++++++ ++++++++++++++
++++++++++++++++ ++++++++++++++
*++**++*******++ ++++++++++++++
*++************* ++++++++++++++
**+************* **************
**************** **************
*************** ***************
**************** ***************
*****************# *****************
******************* ******************
*****************************************************************************
***************************************************************************
*************************************************************************
#################*****************************************************
##########################################################***#####*
###############################################################
###*######################################################
###################################################
Switch.win
https://Switch.win
Built by: BuildTheTech.com
*/
pragma solidity ^0.8.0;
import "./interface/IERC20.sol";
import "./lib/SafeERC20.sol";
import "./lib/Maintainable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
abstract contract SwitchAdapter is Maintainable, ReentrancyGuard {
using SafeERC20 for IERC20;
event SwitchAdapterSwap(address indexed _tokenFrom, address indexed _tokenTo, uint256 _amountIn, uint256 _amountOut);
event UpdatedGasEstimate(address indexed _adapter, uint256 _newEstimate);
event Recovered(address indexed _asset, uint256 amount);
uint256 internal constant UINT_MAX = type(uint256).max;
uint256 public swapGasEstimate;
string public name;
constructor(string memory _name, uint256 _gasEstimate) {
setName(_name);
setSwapGasEstimate(_gasEstimate);
}
function setName(string memory _name) internal {
require(bytes(_name).length != 0, "Invalid adapter name");
name = _name;
}
function setSwapGasEstimate(uint256 _estimate) public onlyMaintainer {
require(_estimate != 0, "Invalid gas-estimate");
swapGasEstimate = _estimate;
emit UpdatedGasEstimate(address(this), _estimate);
}
function revokeAllowance(address _token, address _spender) external onlyMaintainer {
IERC20(_token).safeApprove(_spender, 0);
}
function recoverERC20(address _tokenAddress, uint256 _tokenAmount) external onlyMaintainer {
require(_tokenAmount > 0, "SwitchAdapter: Nothing to recover");
IERC20(_tokenAddress).safeTransfer(msg.sender, _tokenAmount);
emit Recovered(_tokenAddress, _tokenAmount);
}
function recoverPLS(uint256 _amount) external onlyMaintainer {
require(_amount > 0, "SwitchAdapter: Nothing to recover");
(bool ok, ) = payable(msg.sender).call{value: _amount}("");
require(ok, "SwitchAdapter: PLS transfer failed");
emit Recovered(address(0), _amount);
}
function query(
uint256 _amountIn,
address _tokenIn,
address _tokenOut
) external view returns (uint256) {
return _query(_amountIn, _tokenIn, _tokenOut);
}
function swap(
uint256 _amountIn,
uint256 _amountOut,
address _fromToken,
address _toToken,
address _to
) external virtual nonReentrant {
uint256 toBal0 = IERC20(_toToken).balanceOf(_to);
_swap(_amountIn, _amountOut, _fromToken, _toToken, _to);
uint256 diff = IERC20(_toToken).balanceOf(_to) - toBal0;
require(diff >= _amountOut, "Insufficient amount-out");
emit SwitchAdapterSwap(_fromToken, _toToken, _amountIn, _amountOut);
}
function _returnTo(
address _token,
uint256 _amount,
address _to
) internal {
if (address(this) != _to) IERC20(_token).safeTransfer(_to, _amount);
}
function _swap(
uint256 _amountIn,
uint256 _amountOut,
address _fromToken,
address _toToken,
address _to
) internal virtual;
function _query(
uint256 _amountIn,
address _tokenIn,
address _tokenOut
) internal view virtual returns (uint256);
receive() external payable {}
}
src/interface/IDirectPairAdapter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Interface that adapters can implement to indicate that the router
// should transfer input tokens directly to the underlying pair/pool for the
// first hop (to avoid double-transfer for fee-on-transfer/tax tokens).
interface IDirectPairAdapter {
// Return the underlying pair/pool address that will receive the input tokens
// for a swap between tokenIn and tokenOut. Return address(0) if not supported.
function getPair(address tokenIn, address tokenOut) external view returns (address);
}
src/interface/IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
event Approval(address, address, uint256);
event Transfer(address, address, uint256);
function name() external view returns (string memory);
function decimals() external view returns (uint8);
function transferFrom(
address,
address,
uint256
) external returns (bool);
function allowance(address, address) external view returns (uint256);
function approve(address, uint256) external returns (bool);
function transfer(address, uint256) external returns (bool);
function balanceOf(address) external view returns (uint256);
function nonces(address) external view returns (uint256); // Only tokens that support permit
function permit(
address,
address,
uint256,
uint256,
uint8,
bytes32,
bytes32
) external; // Only tokens that support permit
function swap(address, uint256) external; // Only Avalanche bridge tokens
function swapSupply(address) external view returns (uint256); // Only Avalanche bridge tokens
function totalSupply() external view returns (uint256);
}
src/interface/IUniswapFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IUniswapFactory {
function getPair(address tokenA, address tokenB) external view returns (address pair);
}
src/interface/IUniswapPair.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IUniswapPair {
event Swap(
address indexed sender,
uint256 amount0In,
uint256 amount1In,
uint256 amount0Out,
uint256 amount1Out,
address indexed to
);
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 swap(
uint256 amount0Out,
uint256 amount1Out,
address to,
bytes calldata data
) external;
}
src/lib/Maintainable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/AccessControl.sol";
/**
* @dev Contract module which extends the basic access control mechanism of Ownable
* to include many maintainers, whom only the owner (DEFAULT_ADMIN_ROLE) may add and
* remove.
*
* By default, the owner account will be the one that deploys the contract. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available this modifier:
* `onlyMaintainer`, which can be applied to your functions to restrict their use to
* the accounts with the role of maintainer.
*/
abstract contract Maintainable is Context, AccessControl {
bytes32 public constant MAINTAINER_ROLE = keccak256("MAINTAINER_ROLE");
constructor() {
address msgSender = _msgSender();
// members of the DEFAULT_ADMIN_ROLE alone may revoke and grant role membership
_setupRole(DEFAULT_ADMIN_ROLE, msgSender);
_setupRole(MAINTAINER_ROLE, msgSender);
}
function addMaintainer(address addedMaintainer) public virtual {
grantRole(MAINTAINER_ROLE, addedMaintainer);
}
function removeMaintainer(address removedMaintainer) public virtual {
revokeRole(MAINTAINER_ROLE, removedMaintainer);
}
function renounceRole(bytes32 role) public virtual {
address msgSender = _msgSender();
renounceRole(role, msgSender);
}
function transferOwnership(address newOwner) public virtual {
address msgSender = _msgSender();
grantRole(DEFAULT_ADMIN_ROLE, newOwner);
renounceRole(DEFAULT_ADMIN_ROLE, msgSender);
}
modifier onlyMaintainer() {
address msgSender = _msgSender();
require(hasRole(MAINTAINER_ROLE, msgSender), "Maintainable: Caller is not a maintainer");
_;
}
}
src/lib/SafeERC20.sol
// This is a simplified version of OpenZepplin's SafeERC20 library
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;
import "../interface/IERC20.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 ERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
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));
}
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'
// solhint-disable-next-line max-line-length
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev 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.
// A Solidity high level call has three parts:
// 1. The target address is checked to verify it contains contract code
// 2. The call itself is made, and success asserted
// 3. The return value is decoded, which in turn checks the size of the returned data.
// solhint-disable-next-line max-line-length
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
Compiler Settings
{"viaIR":false,"remappings":["@openzeppelin/contracts/=dependencies/openzeppelin-contracts/contracts/","forge-std/=dependencies/forge-std/src/","ds-test/=dependencies/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/","erc4626-tests/=dependencies/openzeppelin-contracts/lib/erc4626-tests/","openzeppelin-contracts/=dependencies/openzeppelin-contracts/","openzeppelin/=dependencies/openzeppelin-contracts/contracts/"],"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":999,"enabled":true},"metadata":{"useLiteralContent":false,"bytecodeHash":"ipfs","appendCBOR":true},"libraries":{},"evmVersion":"shanghai"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"string","name":"_name","internalType":"string"},{"type":"address","name":"_factory","internalType":"address"},{"type":"uint256","name":"_fee","internalType":"uint256"},{"type":"uint256","name":"_swapGasEstimate","internalType":"uint256"}]},{"type":"event","name":"Recovered","inputs":[{"type":"address","name":"_asset","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SwitchAdapterSwap","inputs":[{"type":"address","name":"_tokenFrom","internalType":"address","indexed":true},{"type":"address","name":"_tokenTo","internalType":"address","indexed":true},{"type":"uint256","name":"_amountIn","internalType":"uint256","indexed":false},{"type":"uint256","name":"_amountOut","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"UpdatedGasEstimate","inputs":[{"type":"address","name":"_adapter","internalType":"address","indexed":true},{"type":"uint256","name":"_newEstimate","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"MAINTAINER_ROLE","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addMaintainer","inputs":[{"type":"address","name":"addedMaintainer","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"factory","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"feeCompliment","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getPair","inputs":[{"type":"address","name":"tokenIn","internalType":"address"},{"type":"address","name":"tokenOut","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"query","inputs":[{"type":"uint256","name":"_amountIn","internalType":"uint256"},{"type":"address","name":"_tokenIn","internalType":"address"},{"type":"address","name":"_tokenOut","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"recoverERC20","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_tokenAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"recoverPLS","inputs":[{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeMaintainer","inputs":[{"type":"address","name":"removedMaintainer","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeAllowance","inputs":[{"type":"address","name":"_token","internalType":"address"},{"type":"address","name":"_spender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSwapGasEstimate","inputs":[{"type":"uint256","name":"_estimate","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"swap","inputs":[{"type":"uint256","name":"_amountIn","internalType":"uint256"},{"type":"uint256","name":"_amountOut","internalType":"uint256"},{"type":"address","name":"_fromToken","internalType":"address"},{"type":"address","name":"_toToken","internalType":"address"},{"type":"address","name":"_to","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"swapGasEstimate","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"receive","stateMutability":"payable"}]
Contract Creation Code
0x60c060405234801562000010575f80fd5b5060405162002424380380620024248339810160408190526200003391620002fe565b838133620000425f82620000a0565b6200005c5f805160206200240483398151915282620000a0565b50600180556200006c82620000b0565b620000778162000114565b5062000088905082612710620003ee565b60805250506001600160a01b031660a0525062000562565b620000ac82826200021d565b5050565b80515f03620001065760405162461bcd60e51b815260206004820152601460248201527f496e76616c69642061646170746572206e616d6500000000000000000000000060448201526064015b60405180910390fd5b6003620000ac82826200049a565b336200012f5f805160206200240483398151915282620002a4565b6200018e5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b6064820152608401620000fd565b815f03620001df5760405162461bcd60e51b815260206004820152601460248201527f496e76616c6964206761732d657374696d6174650000000000000000000000006044820152606401620000fd565b600282905560405182815230907ff43f23b7a28e6f8ce6843a21bd7b48bce778aa913b8c8cf459edf7d770e8d38a9060200160405180910390a25050565b620002298282620002a4565b620000ac575f828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620002603390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f828152602081815260408083206001600160a01b038516845290915290205460ff165b92915050565b634e487b7160e01b5f52604160045260245ffd5b80516001600160a01b0381168114620002f9575f80fd5b919050565b5f805f806080858703121562000312575f80fd5b84516001600160401b038082111562000329575f80fd5b818701915087601f8301126200033d575f80fd5b815181811115620003525762000352620002ce565b604051601f8201601f19908116603f011681019083821181831017156200037d576200037d620002ce565b81604052828152602093508a8484870101111562000399575f80fd5b5f91505b82821015620003bc57848201840151818301850152908301906200039d565b5f848483010152809850505050620003d6818801620002e2565b60408801516060909801519699909850945050505050565b81810381811115620002c857634e487b7160e01b5f52601160045260245ffd5b600181811c908216806200042357607f821691505b6020821081036200044257634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111562000495575f81815260208120601f850160051c81016020861015620004705750805b601f850160051c820191505b8181101562000491578281556001016200047c565b5050505b505050565b81516001600160401b03811115620004b657620004b6620002ce565b620004ce81620004c784546200040e565b8462000448565b602080601f83116001811462000504575f8415620004ec5750858301515b5f19600386901b1c1916600185901b17855562000491565b5f85815260208120601f198616915b82811015620005345788860151825594840194600190910190840162000513565b50858210156200055257878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a051611e64620005a05f395f81816103a001528181610c170152818161112c015261147201525f818161026801526117890152611e645ff3fe60806040526004361061017b575f3560e01c80638bb9c5bf116100d1578063d8baf7cf1161007c578063ef99893a11610057578063ef99893a14610475578063f2fde38b14610494578063f8742254146104b3575f80fd5b8063d8baf7cf14610418578063e6a4390514610437578063eab90da614610456575f80fd5b8063c45a0155116100ac578063c45a01551461038f578063d3a43ac3146103da578063d547741f146103f9575f80fd5b80638bb9c5bf1461031b57806391d148541461033a578063a217fddf1461037c575f80fd5b80633b720fca116101315780637ae267731161010c5780637ae26773146102be57806384a33e63146102dd5780638980f11f146102fc575f80fd5b80633b720fca1461025757806369cff80d1461028a5780636b453c1f1461029f575f80fd5b8063248a9ca311610161578063248a9ca3146101db5780632f2ff15d1461021757806336568abe14610238575f80fd5b806301ffc9a71461018657806306fdde03146101ba575f80fd5b3661018257005b5f80fd5b348015610191575f80fd5b506101a56101a03660046119d9565b6104e6565b60405190151581526020015b60405180910390f35b3480156101c5575f80fd5b506101ce61054e565b6040516101b19190611a4d565b3480156101e6575f80fd5b506102096101f5366004611a5f565b5f9081526020819052604090206001015490565b6040519081526020016101b1565b348015610222575f80fd5b50610236610231366004611a8a565b6105da565b005b348015610243575f80fd5b50610236610252366004611a8a565b610603565b348015610262575f80fd5b506102097f000000000000000000000000000000000000000000000000000000000000000081565b348015610295575f80fd5b5061020960025481565b3480156102aa575f80fd5b506102366102b9366004611ab8565b610694565b3480156102c9575f80fd5b506102366102d8366004611ad3565b6106c1565b3480156102e8575f80fd5b506102366102f7366004611a5f565b610763565b348015610307575f80fd5b50610236610316366004611aff565b61087e565b348015610326575f80fd5b50610236610335366004611a5f565b6109c1565b348015610345575f80fd5b506101a5610354366004611a8a565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b348015610387575f80fd5b506102095f81565b34801561039a575f80fd5b506103c27f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101b1565b3480156103e5575f80fd5b506102366103f4366004611a5f565b6109cc565b348015610404575f80fd5b50610236610413366004611a8a565b610ba0565b348015610423575f80fd5b50610236610432366004611ab8565b610bc4565b348015610442575f80fd5b506103c2610451366004611ad3565b610bee565b348015610461575f80fd5b50610236610470366004611b29565b610c89565b348015610480575f80fd5b5061020961048f366004611b84565b610dda565b34801561049f575f80fd5b506102366104ae366004611ab8565b610dee565b3480156104be575f80fd5b506102097f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab9581565b5f6001600160e01b031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061054857507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b6003805461055b90611bc3565b80601f016020809104026020016040519081016040528092919081815260200182805461058790611bc3565b80156105d25780601f106105a9576101008083540402835291602001916105d2565b820191905f5260205f20905b8154815290600101906020018083116105b557829003601f168201915b505050505081565b5f828152602081905260409020600101546105f481610e03565b6105fe8383610e0d565b505050565b6001600160a01b03811633146106865760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6106908282610ea9565b5050565b6106be7f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab95826105da565b50565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff1661074f5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b606482015260840161067d565b6105fe6001600160a01b038416835f610f26565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff166107f15760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b606482015260840161067d565b815f036108405760405162461bcd60e51b815260206004820152601460248201527f496e76616c6964206761732d657374696d617465000000000000000000000000604482015260640161067d565b600282905560405182815230907ff43f23b7a28e6f8ce6843a21bd7b48bce778aa913b8c8cf459edf7d770e8d38a9060200160405180910390a25050565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff1661090c5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b606482015260840161067d565b5f82116109655760405162461bcd60e51b815260206004820152602160248201527f537769746368416461707465723a204e6f7468696e6720746f207265636f76656044820152603960f91b606482015260840161067d565b6109796001600160a01b03841633846110ba565b826001600160a01b03167f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28836040516109b491815260200190565b60405180910390a2505050565b336106908282610603565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff16610a5a5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b606482015260840161067d565b5f8211610ab35760405162461bcd60e51b815260206004820152602160248201527f537769746368416461707465723a204e6f7468696e6720746f207265636f76656044820152603960f91b606482015260840161067d565b6040515f90339084908381818185875af1925050503d805f8114610af2576040519150601f19603f3d011682016040523d82523d5f602084013e610af7565b606091505b5050905080610b6e5760405162461bcd60e51b815260206004820152602260248201527f537769746368416461707465723a20504c53207472616e73666572206661696c60448201527f6564000000000000000000000000000000000000000000000000000000000000606482015260840161067d565b6040518381525f907f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28906020016109b4565b5f82815260208190526040902060010154610bba81610e03565b6105fe8383610ea9565b6106be7f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab9582610ba0565b60405163e6a4390560e01b81526001600160a01b03838116600483015282811660248301525f917f00000000000000000000000000000000000000000000000000000000000000009091169063e6a4390590604401602060405180830381865afa158015610c5e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c829190611bfb565b9392505050565b6040516370a0823160e01b81526001600160a01b0382811660048301525f91908416906370a0823190602401602060405180830381865afa158015610cd0573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cf49190611c16565b9050610d038686868686611103565b6040516370a0823160e01b81526001600160a01b0383811660048301525f9183918616906370a0823190602401602060405180830381865afa158015610d4b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d6f9190611c16565b610d799190611c41565b9050836001600160a01b0316856001600160a01b03167f6be2041a75d9463d869b72bbf3525008cdb98c69774b368f54504594fe722f138984604051610dc9929190918252602082015260400190565b60405180910390a350505050505050565b5f610de684848461141e565b949350505050565b33610df95f836105da565b6106905f82610603565b6106be81336115d3565b5f828152602081815260408083206001600160a01b038516845290915290205460ff16610690575f828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610e653390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f828152602081815260408083206001600160a01b038516845290915290205460ff1615610690575f828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b801580610fb757506040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610f91573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fb59190611c16565b155b6110295760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606482015260840161067d565b6040516001600160a01b0383166024820152604481018290526105fe9084907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152611645565b6040516001600160a01b0383166024820152604481018290526105fe9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161106e565b60405163e6a4390560e01b81526001600160a01b03848116600483015283811660248301525f917f00000000000000000000000000000000000000000000000000000000000000009091169063e6a4390590604401602060405180830381865afa158015611173573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111979190611bfb565b6040516370a0823160e01b81523060048201529091505f906001600160a01b038616906370a0823190602401602060405180830381865afa1580156111de573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112029190611c16565b905086811061121f5761121f6001600160a01b03861683896110ba565b5f80836001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561125d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112819190611c76565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff1691505f80876001600160a01b0316896001600160a01b0316106112c85782846112cb565b83835b6040516370a0823160e01b81526001600160a01b0389811660048301529294509092505f918b16906370a0823190602401602060405180830381865afa158015611317573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061133b9190611c16565b90505f6113488483611c41565b90505f611356828686611782565b90505f808c6001600160a01b03168e6001600160a01b03161061137a57825f61137d565b5f835b90925090506001600160a01b038b1663022c0d9f83838f5f6040519080825280601f01601f1916602001820160405280156113bf576020820181803683370190505b506040518563ffffffff1660e01b81526004016113df9493929190611ccb565b5f604051808303815f87803b1580156113f6575f80fd5b505af1158015611408573d5f803e3d5ffd5b5050505050505050505050505050505050505050565b5f816001600160a01b0316836001600160a01b0316148061143d575083155b1561144957505f610c82565b60405163e6a4390560e01b81526001600160a01b03848116600483015283811660248301525f917f00000000000000000000000000000000000000000000000000000000000000009091169063e6a4390590604401602060405180830381865afa1580156114b9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114dd9190611bfb565b90506001600160a01b0381166114f6575f915050610c82565b5f80826001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611534573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115589190611c76565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff1691505f80866001600160a01b0316886001600160a01b03161061159f5782846115a2565b83835b915091505f821180156115b457505f81115b156115c7576115c4898383611782565b95505b50505050509392505050565b5f828152602081815260408083206001600160a01b038516845290915290205460ff1661069057611603816117ec565b61160e8360206117fe565b60405160200161161f929190611d02565b60408051601f198184030181529082905262461bcd60e51b825261067d91600401611a4d565b5f80836001600160a01b03168360405161165f9190611d82565b5f604051808303815f865af19150503d805f8114611698576040519150601f19603f3d011682016040523d82523d5f602084013e61169d565b606091505b5091509150816116ef5760405162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015260640161067d565b80511561177c578080602001905181019061170a9190611d9d565b61177c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161067d565b50505050565b5f806117ae7f000000000000000000000000000000000000000000000000000000000000000086611dbc565b90505f6117bb8483611dbc565b90505f826117cb61271088611dbc565b6117d59190611dd3565b90506117e18183611de6565b979650505050505050565b60606105486001600160a01b03831660145b60605f61180c836002611dbc565b611817906002611dd3565b67ffffffffffffffff81111561182f5761182f611cb7565b6040519080825280601f01601f191660200182016040528015611859576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000815f8151811061188f5761188f611e05565b60200101906001600160f81b03191690815f1a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106118d9576118d9611e05565b60200101906001600160f81b03191690815f1a9053505f6118fb846002611dbc565b611906906001611dd3565b90505b600181111561198a577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061194757611947611e05565b1a60f81b82828151811061195d5761195d611e05565b60200101906001600160f81b03191690815f1a90535060049490941c9361198381611e19565b9050611909565b508315610c825760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161067d565b5f602082840312156119e9575f80fd5b81356001600160e01b031981168114610c82575f80fd5b5f5b83811015611a1a578181015183820152602001611a02565b50505f910152565b5f8151808452611a39816020860160208601611a00565b601f01601f19169290920160200192915050565b602081525f610c826020830184611a22565b5f60208284031215611a6f575f80fd5b5035919050565b6001600160a01b03811681146106be575f80fd5b5f8060408385031215611a9b575f80fd5b823591506020830135611aad81611a76565b809150509250929050565b5f60208284031215611ac8575f80fd5b8135610c8281611a76565b5f8060408385031215611ae4575f80fd5b8235611aef81611a76565b91506020830135611aad81611a76565b5f8060408385031215611b10575f80fd5b8235611b1b81611a76565b946020939093013593505050565b5f805f805f60a08688031215611b3d575f80fd5b85359450602086013593506040860135611b5681611a76565b92506060860135611b6681611a76565b91506080860135611b7681611a76565b809150509295509295909350565b5f805f60608486031215611b96575f80fd5b833592506020840135611ba881611a76565b91506040840135611bb881611a76565b809150509250925092565b600181811c90821680611bd757607f821691505b602082108103611bf557634e487b7160e01b5f52602260045260245ffd5b50919050565b5f60208284031215611c0b575f80fd5b8151610c8281611a76565b5f60208284031215611c26575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561054857610548611c2d565b80516dffffffffffffffffffffffffffff81168114611c71575f80fd5b919050565b5f805f60608486031215611c88575f80fd5b611c9184611c54565b9250611c9f60208501611c54565b9150604084015163ffffffff81168114611bb8575f80fd5b634e487b7160e01b5f52604160045260245ffd5b8481528360208201526001600160a01b0383166040820152608060608201525f611cf86080830184611a22565b9695505050505050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f8351611d39816017850160208801611a00565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611d76816028840160208801611a00565b01602801949350505050565b5f8251611d93818460208701611a00565b9190910192915050565b5f60208284031215611dad575f80fd5b81518015158114610c82575f80fd5b808202811582820484141761054857610548611c2d565b8082018082111561054857610548611c2d565b5f82611e0057634e487b7160e01b5f52601260045260245ffd5b500490565b634e487b7160e01b5f52603260045260245ffd5b5f81611e2757611e27611c2d565b505f19019056fea2646970667358221220bad7ea31509cea2e4a5b4ee5c26063d940c4e7725efaadebbcaa48ce3d78175864736f6c63430008140033339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab950000000000000000000000000000000000000000000000000000000000000080000000000000000000000000556f4c3aaa6c6b76e1bba0409d99d4a483b29997000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000000000000000000000000000000000000000000f446578746f705632416461707465720000000000000000000000000000000000
Deployed ByteCode
0x60806040526004361061017b575f3560e01c80638bb9c5bf116100d1578063d8baf7cf1161007c578063ef99893a11610057578063ef99893a14610475578063f2fde38b14610494578063f8742254146104b3575f80fd5b8063d8baf7cf14610418578063e6a4390514610437578063eab90da614610456575f80fd5b8063c45a0155116100ac578063c45a01551461038f578063d3a43ac3146103da578063d547741f146103f9575f80fd5b80638bb9c5bf1461031b57806391d148541461033a578063a217fddf1461037c575f80fd5b80633b720fca116101315780637ae267731161010c5780637ae26773146102be57806384a33e63146102dd5780638980f11f146102fc575f80fd5b80633b720fca1461025757806369cff80d1461028a5780636b453c1f1461029f575f80fd5b8063248a9ca311610161578063248a9ca3146101db5780632f2ff15d1461021757806336568abe14610238575f80fd5b806301ffc9a71461018657806306fdde03146101ba575f80fd5b3661018257005b5f80fd5b348015610191575f80fd5b506101a56101a03660046119d9565b6104e6565b60405190151581526020015b60405180910390f35b3480156101c5575f80fd5b506101ce61054e565b6040516101b19190611a4d565b3480156101e6575f80fd5b506102096101f5366004611a5f565b5f9081526020819052604090206001015490565b6040519081526020016101b1565b348015610222575f80fd5b50610236610231366004611a8a565b6105da565b005b348015610243575f80fd5b50610236610252366004611a8a565b610603565b348015610262575f80fd5b506102097f00000000000000000000000000000000000000000000000000000000000026f281565b348015610295575f80fd5b5061020960025481565b3480156102aa575f80fd5b506102366102b9366004611ab8565b610694565b3480156102c9575f80fd5b506102366102d8366004611ad3565b6106c1565b3480156102e8575f80fd5b506102366102f7366004611a5f565b610763565b348015610307575f80fd5b50610236610316366004611aff565b61087e565b348015610326575f80fd5b50610236610335366004611a5f565b6109c1565b348015610345575f80fd5b506101a5610354366004611a8a565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b348015610387575f80fd5b506102095f81565b34801561039a575f80fd5b506103c27f000000000000000000000000556f4c3aaa6c6b76e1bba0409d99d4a483b2999781565b6040516001600160a01b0390911681526020016101b1565b3480156103e5575f80fd5b506102366103f4366004611a5f565b6109cc565b348015610404575f80fd5b50610236610413366004611a8a565b610ba0565b348015610423575f80fd5b50610236610432366004611ab8565b610bc4565b348015610442575f80fd5b506103c2610451366004611ad3565b610bee565b348015610461575f80fd5b50610236610470366004611b29565b610c89565b348015610480575f80fd5b5061020961048f366004611b84565b610dda565b34801561049f575f80fd5b506102366104ae366004611ab8565b610dee565b3480156104be575f80fd5b506102097f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab9581565b5f6001600160e01b031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061054857507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b6003805461055b90611bc3565b80601f016020809104026020016040519081016040528092919081815260200182805461058790611bc3565b80156105d25780601f106105a9576101008083540402835291602001916105d2565b820191905f5260205f20905b8154815290600101906020018083116105b557829003601f168201915b505050505081565b5f828152602081905260409020600101546105f481610e03565b6105fe8383610e0d565b505050565b6001600160a01b03811633146106865760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084015b60405180910390fd5b6106908282610ea9565b5050565b6106be7f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab95826105da565b50565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff1661074f5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b606482015260840161067d565b6105fe6001600160a01b038416835f610f26565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff166107f15760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b606482015260840161067d565b815f036108405760405162461bcd60e51b815260206004820152601460248201527f496e76616c6964206761732d657374696d617465000000000000000000000000604482015260640161067d565b600282905560405182815230907ff43f23b7a28e6f8ce6843a21bd7b48bce778aa913b8c8cf459edf7d770e8d38a9060200160405180910390a25050565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff1661090c5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b606482015260840161067d565b5f82116109655760405162461bcd60e51b815260206004820152602160248201527f537769746368416461707465723a204e6f7468696e6720746f207265636f76656044820152603960f91b606482015260840161067d565b6109796001600160a01b03841633846110ba565b826001600160a01b03167f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28836040516109b491815260200190565b60405180910390a2505050565b336106908282610603565b335f8181527fa54247010af6b3693b80aceddfad12e077c5de3571e6243fada502635f0d7d39602052604090205460ff16610a5a5760405162461bcd60e51b815260206004820152602860248201527f4d61696e7461696e61626c653a2043616c6c6572206973206e6f742061206d6160448201526734b73a30b4b732b960c11b606482015260840161067d565b5f8211610ab35760405162461bcd60e51b815260206004820152602160248201527f537769746368416461707465723a204e6f7468696e6720746f207265636f76656044820152603960f91b606482015260840161067d565b6040515f90339084908381818185875af1925050503d805f8114610af2576040519150601f19603f3d011682016040523d82523d5f602084013e610af7565b606091505b5050905080610b6e5760405162461bcd60e51b815260206004820152602260248201527f537769746368416461707465723a20504c53207472616e73666572206661696c60448201527f6564000000000000000000000000000000000000000000000000000000000000606482015260840161067d565b6040518381525f907f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa28906020016109b4565b5f82815260208190526040902060010154610bba81610e03565b6105fe8383610ea9565b6106be7f339759585899103d2ace64958e37e18ccb0504652c81d4a1b8aa80fe2126ab9582610ba0565b60405163e6a4390560e01b81526001600160a01b03838116600483015282811660248301525f917f000000000000000000000000556f4c3aaa6c6b76e1bba0409d99d4a483b299979091169063e6a4390590604401602060405180830381865afa158015610c5e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c829190611bfb565b9392505050565b6040516370a0823160e01b81526001600160a01b0382811660048301525f91908416906370a0823190602401602060405180830381865afa158015610cd0573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cf49190611c16565b9050610d038686868686611103565b6040516370a0823160e01b81526001600160a01b0383811660048301525f9183918616906370a0823190602401602060405180830381865afa158015610d4b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d6f9190611c16565b610d799190611c41565b9050836001600160a01b0316856001600160a01b03167f6be2041a75d9463d869b72bbf3525008cdb98c69774b368f54504594fe722f138984604051610dc9929190918252602082015260400190565b60405180910390a350505050505050565b5f610de684848461141e565b949350505050565b33610df95f836105da565b6106905f82610603565b6106be81336115d3565b5f828152602081815260408083206001600160a01b038516845290915290205460ff16610690575f828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610e653390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b5f828152602081815260408083206001600160a01b038516845290915290205460ff1615610690575f828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b801580610fb757506040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015610f91573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fb59190611c16565b155b6110295760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e636500000000000000000000606482015260840161067d565b6040516001600160a01b0383166024820152604481018290526105fe9084907f095ea7b300000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b031990931692909217909152611645565b6040516001600160a01b0383166024820152604481018290526105fe9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161106e565b60405163e6a4390560e01b81526001600160a01b03848116600483015283811660248301525f917f000000000000000000000000556f4c3aaa6c6b76e1bba0409d99d4a483b299979091169063e6a4390590604401602060405180830381865afa158015611173573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111979190611bfb565b6040516370a0823160e01b81523060048201529091505f906001600160a01b038616906370a0823190602401602060405180830381865afa1580156111de573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112029190611c16565b905086811061121f5761121f6001600160a01b03861683896110ba565b5f80836001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa15801561125d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112819190611c76565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff1691505f80876001600160a01b0316896001600160a01b0316106112c85782846112cb565b83835b6040516370a0823160e01b81526001600160a01b0389811660048301529294509092505f918b16906370a0823190602401602060405180830381865afa158015611317573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061133b9190611c16565b90505f6113488483611c41565b90505f611356828686611782565b90505f808c6001600160a01b03168e6001600160a01b03161061137a57825f61137d565b5f835b90925090506001600160a01b038b1663022c0d9f83838f5f6040519080825280601f01601f1916602001820160405280156113bf576020820181803683370190505b506040518563ffffffff1660e01b81526004016113df9493929190611ccb565b5f604051808303815f87803b1580156113f6575f80fd5b505af1158015611408573d5f803e3d5ffd5b5050505050505050505050505050505050505050565b5f816001600160a01b0316836001600160a01b0316148061143d575083155b1561144957505f610c82565b60405163e6a4390560e01b81526001600160a01b03848116600483015283811660248301525f917f000000000000000000000000556f4c3aaa6c6b76e1bba0409d99d4a483b299979091169063e6a4390590604401602060405180830381865afa1580156114b9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114dd9190611bfb565b90506001600160a01b0381166114f6575f915050610c82565b5f80826001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015611534573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115589190611c76565b506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff1691505f80866001600160a01b0316886001600160a01b03161061159f5782846115a2565b83835b915091505f821180156115b457505f81115b156115c7576115c4898383611782565b95505b50505050509392505050565b5f828152602081815260408083206001600160a01b038516845290915290205460ff1661069057611603816117ec565b61160e8360206117fe565b60405160200161161f929190611d02565b60408051601f198184030181529082905262461bcd60e51b825261067d91600401611a4d565b5f80836001600160a01b03168360405161165f9190611d82565b5f604051808303815f865af19150503d805f8114611698576040519150601f19603f3d011682016040523d82523d5f602084013e61169d565b606091505b5091509150816116ef5760405162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015260640161067d565b80511561177c578080602001905181019061170a9190611d9d565b61177c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161067d565b50505050565b5f806117ae7f00000000000000000000000000000000000000000000000000000000000026f286611dbc565b90505f6117bb8483611dbc565b90505f826117cb61271088611dbc565b6117d59190611dd3565b90506117e18183611de6565b979650505050505050565b60606105486001600160a01b03831660145b60605f61180c836002611dbc565b611817906002611dd3565b67ffffffffffffffff81111561182f5761182f611cb7565b6040519080825280601f01601f191660200182016040528015611859576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000815f8151811061188f5761188f611e05565b60200101906001600160f81b03191690815f1a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106118d9576118d9611e05565b60200101906001600160f81b03191690815f1a9053505f6118fb846002611dbc565b611906906001611dd3565b90505b600181111561198a577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061194757611947611e05565b1a60f81b82828151811061195d5761195d611e05565b60200101906001600160f81b03191690815f1a90535060049490941c9361198381611e19565b9050611909565b508315610c825760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161067d565b5f602082840312156119e9575f80fd5b81356001600160e01b031981168114610c82575f80fd5b5f5b83811015611a1a578181015183820152602001611a02565b50505f910152565b5f8151808452611a39816020860160208601611a00565b601f01601f19169290920160200192915050565b602081525f610c826020830184611a22565b5f60208284031215611a6f575f80fd5b5035919050565b6001600160a01b03811681146106be575f80fd5b5f8060408385031215611a9b575f80fd5b823591506020830135611aad81611a76565b809150509250929050565b5f60208284031215611ac8575f80fd5b8135610c8281611a76565b5f8060408385031215611ae4575f80fd5b8235611aef81611a76565b91506020830135611aad81611a76565b5f8060408385031215611b10575f80fd5b8235611b1b81611a76565b946020939093013593505050565b5f805f805f60a08688031215611b3d575f80fd5b85359450602086013593506040860135611b5681611a76565b92506060860135611b6681611a76565b91506080860135611b7681611a76565b809150509295509295909350565b5f805f60608486031215611b96575f80fd5b833592506020840135611ba881611a76565b91506040840135611bb881611a76565b809150509250925092565b600181811c90821680611bd757607f821691505b602082108103611bf557634e487b7160e01b5f52602260045260245ffd5b50919050565b5f60208284031215611c0b575f80fd5b8151610c8281611a76565b5f60208284031215611c26575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561054857610548611c2d565b80516dffffffffffffffffffffffffffff81168114611c71575f80fd5b919050565b5f805f60608486031215611c88575f80fd5b611c9184611c54565b9250611c9f60208501611c54565b9150604084015163ffffffff81168114611bb8575f80fd5b634e487b7160e01b5f52604160045260245ffd5b8481528360208201526001600160a01b0383166040820152608060608201525f611cf86080830184611a22565b9695505050505050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081525f8351611d39816017850160208801611a00565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611d76816028840160208801611a00565b01602801949350505050565b5f8251611d93818460208701611a00565b9190910192915050565b5f60208284031215611dad575f80fd5b81518015158114610c82575f80fd5b808202811582820484141761054857610548611c2d565b8082018082111561054857610548611c2d565b5f82611e0057634e487b7160e01b5f52601260045260245ffd5b500490565b634e487b7160e01b5f52603260045260245ffd5b5f81611e2757611e27611c2d565b505f19019056fea2646970667358221220bad7ea31509cea2e4a5b4ee5c26063d940c4e7725efaadebbcaa48ce3d78175864736f6c63430008140033