More Info
Private Name Tags
ContractCreator
Latest 13 from a total of 13 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Swap To Native | 5046720 | 2 days ago | IN | 0 S | 0.00363929 | ||||
Swap To Native | 5035467 | 2 days ago | IN | 0 S | 0.00412547 | ||||
Swap To Native | 4730123 | 4 days ago | IN | 0 S | 0.00363929 | ||||
Swap To Native | 4680234 | 5 days ago | IN | 0 S | 0.00412481 | ||||
Swap To Native | 4677929 | 5 days ago | IN | 0 S | 0.00457979 | ||||
Swap To Native | 4677323 | 5 days ago | IN | 0 S | 0.00279153 | ||||
Swap To Native | 4563787 | 6 days ago | IN | 0 S | 0.00484825 | ||||
Swap To Native | 4377682 | 7 days ago | IN | 0 S | 0.00386142 | ||||
Swap To Native | 2950947 | 17 days ago | IN | 0 S | 0.00084296 | ||||
Renounce Role | 2949076 | 17 days ago | IN | 0 S | 0.00024585 | ||||
Grant Role | 2949030 | 17 days ago | IN | 0 S | 0.00055528 | ||||
Grant Role | 2948905 | 17 days ago | IN | 0 S | 0.00065144 | ||||
Deposit | 2862127 | 18 days ago | IN | 0 S | 0.00018075 |
Loading...
Loading
Contract Name:
Gateway
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol"; import "@openzeppelin/contracts/utils/Pausable.sol"; /// @title Gateway /// @notice This contract allows users to swap mb tokens to native tokens and vice versa. contract Gateway is ReentrancyGuard, AccessControlEnumerable, Pausable { using SafeERC20 for IERC20; enum SwapType { TO_NATIVE, TO_MBTOKEN } bytes32 public constant DEPOSITOR_ROLE = keccak256("DEPOSITOR_ROLE"); bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); bytes32 public constant UNPAUSER_ROLE = keccak256("UNPAUSER_ROLE"); address public nativeToken; address public mbToken; mapping(address => uint256) public deposits; /// @notice Event to log the successful token swap. /// @param from The address that initiated the swap. /// @param to The address that received the swapped tokens. /// @param fromToken The address of the token that was swapped. /// @param toToken The address of the token that was received. /// @param amount The amount of tokens swapped. event TokenSwapped( address indexed from, address to, address indexed fromToken, address indexed toToken, uint256 amount ); /// @notice Event to log the successful deposit of tokens. /// @param user The address of the user who deposited. /// @param nativeTokenAmount The amount of native tokens deposited. event Deposited(address indexed user, uint256 nativeTokenAmount); /// @notice Event to log the successful withdrawal of tokens. /// @param user The address of the user who withdrew. /// @param nativeTokenAmount The amount of native tokens withdrawn. /// @param mbTokenAmount The amount of mb tokens withdrawn. event Withdrawn( address indexed user, uint256 nativeTokenAmount, uint256 mbTokenAmount ); /// @notice Constructs a new Gateway contract. constructor(address _admin, address _nativeToken, address _mbToken) { require( _admin != address(0), "Gateway: ADMIN_ADDRESS_MUST_BE_NON-ZERO" ); _grantRole(DEFAULT_ADMIN_ROLE, _admin); nativeToken = _nativeToken; mbToken = _mbToken; } /// @notice Swaps a specified amount of mb tokens to native tokens. /// @param amount The amount of mb tokens to swap. function swapToNative(uint256 amount) external nonReentrant whenNotPaused { _swap(amount, msg.sender, SwapType.TO_NATIVE); } /// @notice Swaps a specified amount of native tokens to mb tokens. /// @param amount The amount of native tokens to swap. function swapToMBToken(uint256 amount) external nonReentrant whenNotPaused { _swap(amount, msg.sender, SwapType.TO_MBTOKEN); } /// @notice Swaps a specified amount of mb tokens to native tokens. /// @param amount The amount of mb tokens to swap. /// @param to The recipient address of the native tokens. function swapToNativeTo( uint256 amount, address to ) external nonReentrant whenNotPaused { _swap(amount, to, SwapType.TO_NATIVE); } /// @notice Swaps a specified amount of native tokens to mb tokens. /// @param amount The amount of native tokens to swap. /// @param to The recipient address of the mb tokens. function swapToMBTokenTo( uint256 amount, address to ) external nonReentrant whenNotPaused { _swap(amount, to, SwapType.TO_MBTOKEN); } /// @notice Allows users to deposit native tokens. /// @param nativeTokenAmount The amount of native tokens to deposit. function deposit( uint256 nativeTokenAmount ) external nonReentrant whenNotPaused onlyRole(DEPOSITOR_ROLE) { require( nativeTokenAmount > 0, "Gateway: TOTAL_DEPOSIT_MUST_BE_GREATER_THAN_0" ); uint256 balance = IERC20(nativeToken).balanceOf(address(this)); IERC20(nativeToken).safeTransferFrom( msg.sender, address(this), nativeTokenAmount ); uint256 receivedAmount = IERC20(nativeToken).balanceOf(address(this)) - balance; require( nativeTokenAmount == receivedAmount, "Gateway: INVALID_RECEIVED_AMOUNT" ); deposits[msg.sender] += nativeTokenAmount; emit Deposited(msg.sender, nativeTokenAmount); } /// @notice Allows users to withdraw both native tokens and mb tokens. /// @param nativeTokenAmount The amount of native tokens to withdraw. /// @param mbTokenAmount The amount of mb tokens to withdraw. function withdraw( uint256 nativeTokenAmount, uint256 mbTokenAmount ) external nonReentrant whenNotPaused { uint256 totalWithdrawal = nativeTokenAmount + mbTokenAmount; require( totalWithdrawal > 0, "Gateway: TOTAL_WITHDRAWAL_MUST_BE_GREATER_THAN_0" ); require( deposits[msg.sender] >= totalWithdrawal, "Gateway: INSUFFICIENT_USER_BALANCE" ); deposits[msg.sender] -= totalWithdrawal; if (nativeTokenAmount > 0) { IERC20(nativeToken).safeTransfer(msg.sender, nativeTokenAmount); } if (mbTokenAmount > 0) { IERC20(mbToken).safeTransfer(msg.sender, mbTokenAmount); } emit Withdrawn(msg.sender, nativeTokenAmount, mbTokenAmount); } /// @notice Pauses the contract. function pause() external onlyRole(PAUSER_ROLE) { _pause(); } /// @notice Unpauses the contract. function unpause() external onlyRole(UNPAUSER_ROLE) { _unpause(); } /// @dev Internal function to handle the token swap. /// @param amount_ The amount of tokens to swap. /// @param to_ The recipient address of the swapped tokens. /// @param type_ The swap type (TO_NATIVE or TO_MBTOKEN). function _swap(uint256 amount_, address to_, SwapType type_) internal { require(amount_ > 0, "Gateway: AMOUNT_MUST_BE_GREATER_THAN_0"); require( to_ != address(0), "Gateway: RECIPIENT_ADDRESS_MUST_BE_NON-ZERO" ); address fromToken; address toToken; if (type_ == SwapType.TO_MBTOKEN) { fromToken = nativeToken; toToken = mbToken; } else if (type_ == SwapType.TO_NATIVE) { fromToken = mbToken; toToken = nativeToken; } else { revert("Invalid SwapType"); } uint256 balance = IERC20(fromToken).balanceOf(address(this)); IERC20(fromToken).safeTransferFrom(msg.sender, address(this), amount_); uint256 receivedAmount = IERC20(fromToken).balanceOf(address(this)) - balance; require(amount_ == receivedAmount, "Gateway: INVALID_RECEIVED_AMOUNT"); IERC20(toToken).safeTransfer(to_, amount_); emit TokenSwapped(msg.sender, to_, fromToken, toToken, amount_); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "./IAccessControl.sol"; import {Context} from "../utils/Context.sol"; import {ERC165} from "../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 account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ 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 returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @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 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 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 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 `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @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 Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (access/extensions/AccessControlEnumerable.sol) pragma solidity ^0.8.20; import {IAccessControlEnumerable} from "./IAccessControlEnumerable.sol"; import {AccessControl} from "../AccessControl.sol"; import {EnumerableSet} from "../../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 role => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) { return _roleMembers[role].length(); } /** * @dev Return all accounts that have `role` * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function getRoleMembers(bytes32 role) public view virtual returns (address[] memory) { return _roleMembers[role].values(); } /** * @dev Overload {AccessControl-_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override returns (bool) { bool granted = super._grantRole(role, account); if (granted) { _roleMembers[role].add(account); } return granted; } /** * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) { bool revoked = super._revokeRole(role, account); if (revoked) { _roleMembers[role].remove(account); } return revoked; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (access/extensions/IAccessControlEnumerable.sol) pragma solidity ^0.8.20; import {IAccessControl} from "../IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC-165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC-165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @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. */ 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. This account bears the admin role (for the granted role). * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}. */ 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 `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC165} from "./IERC165.sol"; /** * @title IERC1363 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363]. * * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction. */ interface IERC1363 is IERC20, IERC165 { /* * Note: the ERC-165 identifier for this interface is 0xb0202a11. * 0xb0202a11 === * bytes4(keccak256('transferAndCall(address,uint256)')) ^ * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^ * bytes4(keccak256('approveAndCall(address,uint256)')) ^ * bytes4(keccak256('approveAndCall(address,uint256,bytes)')) */ /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @param data Additional data with no specified format, sent in call to `spender`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ 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 value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` 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 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC1363} from "../../../interfaces/IERC1363.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC-20 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 { /** * @dev An operation with an ERC-20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. * * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being * set here. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { safeTransfer(token, to, value); } else if (!token.transferAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferFromAndCallRelaxed( IERC1363 token, address from, address to, uint256 value, bytes memory data ) internal { if (to.code.length == 0) { safeTransferFrom(token, from, to, value); } else if (!token.transferFromAndCall(from, to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}. * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall} * once without retrying, and relies on the returned value to be true. * * Reverts if the returned value is other than `true`. */ function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { forceApprove(token, to, value); } else if (!token.approveAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements. */ function _callOptionalReturn(IERC20 token, bytes memory data) private { uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) // bubble errors if iszero(success) { let ptr := mload(0x40) returndatacopy(ptr, 0, returndatasize()) revert(ptr, returndatasize()) } returnSize := returndatasize() returnValue := mload(0) } if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { bool success; uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) returnSize := returndatasize() returnValue := mload(0) } return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert Errors.FailedCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC-165 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); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * 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[ERC section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { bool private _paused; /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @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 EIP-1153 (transient storage) is available on the chain you're deploying at, * consider using {ReentrancyGuardTransient} instead. * * 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; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); 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 if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; assembly ("memory-safe") { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly ("memory-safe") { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly ("memory-safe") { result := store } return result; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_admin","type":"address"},{"internalType":"address","name":"_nativeToken","type":"address"},{"internalType":"address","name":"_mbToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"nativeTokenAmount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"fromToken","type":"address"},{"indexed":true,"internalType":"address","name":"toToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenSwapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"nativeTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mbTokenAmount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSITOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNPAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nativeTokenAmount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"deposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mbToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nativeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"swapToMBToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"swapToMBTokenTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"swapToNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"swapToNativeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nativeTokenAmount","type":"uint256"},{"internalType":"uint256","name":"mbTokenAmount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506040516200177b3803806200177b833981016040819052620000349162000243565b60016000556003805460ff191690556001600160a01b038316620000ae5760405162461bcd60e51b815260206004820152602760248201527f476174657761793a2041444d494e5f414444524553535f4d5553545f42455f4e6044820152664f4e2d5a45524f60c81b606482015260840160405180910390fd5b620000bb600084620000f9565b5060038054610100600160a81b0319166101006001600160a01b0394851602179055600480546001600160a01b03191691909216179055506200028d565b60008062000108848462000136565b905080156200012d5760008481526002602052604090206200012b9084620001cc565b505b90505b92915050565b60008281526001602090815260408083206001600160a01b038516845290915281205460ff16620001c35760008381526001602081815260408084206001600160a01b0387168086529252808420805460ff19169093179092559051339286917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a450600162000130565b50600062000130565b60006200012d836001600160a01b0384166000818152600183016020526040812054620001c35750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000130565b80516001600160a01b03811681146200023e57600080fd5b919050565b6000806000606084860312156200025957600080fd5b620002648462000226565b9250620002746020850162000226565b9150620002846040850162000226565b90509250925092565b6114de806200029d6000396000f3fe608060405234801561001057600080fd5b50600436106101725760003560e01c806391d14854116100de578063c6f4f17311610097578063e1758bd811610071578063e1758bd81461034c578063e63ab1e914610364578063fb1bb9de1461038b578063fc7e286d146103b257600080fd5b8063c6f4f17314610313578063ca15c87314610326578063d547741f1461033957600080fd5b806391d148541461028b57806399a7e2211461029e578063a217fddf146102b1578063a3246ad3146102b9578063a3b0b5a3146102d9578063b6b55f251461030057600080fd5b80633f4ba83a116101305780633f4ba83a1461021f578063441a3e70146102275780635c975abb1461023a57806367c1bb12146102455780638456cb59146102585780639010d07c1461026057600080fd5b8062f4cafa1461017757806301ffc9a71461018c5780631ce9f1ef146101b4578063248a9ca3146101c75780632f2ff15d146101f957806336568abe1461020c575b600080fd5b61018a610185366004611318565b6103d2565b005b61019f61019a366004611344565b6103fc565b60405190151581526020015b60405180910390f35b61018a6101c2366004611318565b610427565b6101eb6101d536600461136e565b6000908152600160208190526040909120015490565b6040519081526020016101ab565b61018a610207366004611318565b610443565b61018a61021a366004611318565b61046f565b61018a6104a7565b61018a610235366004611387565b6104dc565b60035460ff1661019f565b61018a61025336600461136e565b61067b565b61018a6106a1565b61027361026e366004611387565b6106d3565b6040516001600160a01b0390911681526020016101ab565b61019f610299366004611318565b6106f2565b61018a6102ac36600461136e565b61071d565b6101eb600081565b6102cc6102c736600461136e565b610739565b6040516101ab91906113a9565b6101eb7f8f4f2da22e8ac8f11e15f9fc141cddbb5deea8800186560abb6e68c5496619a981565b61018a61030e36600461136e565b610753565b600454610273906001600160a01b031681565b6101eb61033436600461136e565b6109bb565b61018a610347366004611318565b6109d2565b6003546102739061010090046001600160a01b031681565b6101eb7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b6101eb7f427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a81565b6101eb6103c03660046113f6565b60056020526000908152604090205481565b6103da6109f8565b6103e2610a22565b6103ee82826001610a48565b6103f86001600055565b5050565b60006001600160e01b03198216635a05180f60e01b1480610421575061042182610d74565b92915050565b61042f6109f8565b610437610a22565b6103ee82826000610a48565b6000828152600160208190526040909120015461045f81610da9565b6104698383610db3565b50505050565b6001600160a01b03811633146104985760405163334bd91960e11b815260040160405180910390fd5b6104a28282610de8565b505050565b7f427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a6104d181610da9565b6104d9610e15565b50565b6104e46109f8565b6104ec610a22565b60006104f88284611427565b9050600081116105685760405162461bcd60e51b815260206004820152603060248201527f476174657761793a20544f54414c5f5749544844524157414c5f4d5553545f4260448201526f0455f475245415445525f5448414e5f360841b60648201526084015b60405180910390fd5b336000908152600560205260409020548111156105d25760405162461bcd60e51b815260206004820152602260248201527f476174657761793a20494e53554646494349454e545f555345525f42414c414e604482015261434560f01b606482015260840161055f565b33600090815260056020526040812080548392906105f190849061143a565b90915550508215610618576003546106189061010090046001600160a01b03163385610e67565b811561063557600454610635906001600160a01b03163384610e67565b604080518481526020810184905233917f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6910160405180910390a2506103f86001600055565b6106836109f8565b61068b610a22565b61069781336000610a48565b6104d96001600055565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a6106cb81610da9565b6104d9610ec6565b60008281526002602052604081206106eb9083610f03565b9392505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6107256109f8565b61072d610a22565b61069781336001610a48565b600081815260026020526040902060609061042190610f0f565b61075b6109f8565b610763610a22565b7f8f4f2da22e8ac8f11e15f9fc141cddbb5deea8800186560abb6e68c5496619a961078d81610da9565b600082116107f35760405162461bcd60e51b815260206004820152602d60248201527f476174657761793a20544f54414c5f4445504f5349545f4d5553545f42455f4760448201526c05245415445525f5448414e5f3609c1b606482015260840161055f565b6003546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015610841573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610865919061144d565b6003549091506108859061010090046001600160a01b0316333086610f1c565b6003546040516370a0823160e01b815230600482015260009183916101009091046001600160a01b0316906370a0823190602401602060405180830381865afa1580156108d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fa919061144d565b610904919061143a565b90508084146109555760405162461bcd60e51b815260206004820181905260248201527f476174657761793a20494e56414c49445f52454345495645445f414d4f554e54604482015260640161055f565b3360009081526005602052604081208054869290610974908490611427565b909155505060405184815233907f2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c49060200160405180910390a25050506104d96001600055565b600081815260026020526040812061042190610f55565b600082815260016020819052604090912001546109ee81610da9565b6104698383610de8565b600260005403610a1b57604051633ee5aeb560e01b815260040160405180910390fd5b6002600055565b60035460ff1615610a465760405163d93c066560e01b815260040160405180910390fd5b565b60008311610aa75760405162461bcd60e51b815260206004820152602660248201527f476174657761793a20414d4f554e545f4d5553545f42455f475245415445525f60448201526505448414e5f360d41b606482015260840161055f565b6001600160a01b038216610b115760405162461bcd60e51b815260206004820152602b60248201527f476174657761793a20524543495049454e545f414444524553535f4d5553545f60448201526a42455f4e4f4e2d5a45524f60a81b606482015260840161055f565b6000806001836001811115610b2857610b28611466565b03610b4c5750506003546004546001600160a01b0361010090920482169116610bc0565b6000836001811115610b6057610b60611466565b03610b855750506004546003546001600160a01b039182169161010090910416610bc0565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c696420537761705479706560801b604482015260640161055f565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa158015610c07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2b919061144d565b9050610c426001600160a01b038416333089610f1c565b6040516370a0823160e01b815230600482015260009082906001600160a01b038616906370a0823190602401602060405180830381865afa158015610c8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caf919061144d565b610cb9919061143a565b9050808714610d0a5760405162461bcd60e51b815260206004820181905260248201527f476174657761793a20494e56414c49445f52454345495645445f414d4f554e54604482015260640161055f565b610d1e6001600160a01b0384168789610e67565b604080516001600160a01b038881168252602082018a9052808616929087169133917fcb803386226022c424543f38623c830b1a56b16f37e100fe5f2aa460054746fd910160405180910390a450505050505050565b60006001600160e01b03198216637965db0b60e01b148061042157506301ffc9a760e01b6001600160e01b0319831614610421565b6104d98133610f5f565b600080610dc08484610f98565b905080156106eb576000848152600260205260409020610de09084611011565b509392505050565b600080610df58484611026565b905080156106eb576000848152600260205260409020610de09084611093565b610e1d6110a8565b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516001600160a01b038381166024830152604482018390526104a291859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506110cb565b610ece610a22565b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610e4a3390565b60006106eb838361113c565b606060006106eb83611166565b6040516001600160a01b0384811660248301528381166044830152606482018390526104699186918216906323b872dd90608401610e94565b6000610421825490565b610f6982826106f2565b6103f85760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161055f565b6000610fa483836106f2565b6110095760008381526001602081815260408084206001600160a01b0387168086529252808420805460ff19169093179092559051339286917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a4506001610421565b506000610421565b60006106eb836001600160a01b0384166111c2565b600061103283836106f2565b156110095760008381526001602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610421565b60006106eb836001600160a01b038416611209565b60035460ff16610a4657604051638dfc202b60e01b815260040160405180910390fd5b600080602060008451602086016000885af1806110ee576040513d6000823e3d81fd5b50506000513d91508115611106578060011415611113565b6001600160a01b0384163b155b1561046957604051635274afe760e01b81526001600160a01b038516600482015260240161055f565b60008260000182815481106111535761115361147c565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156111b657602002820191906000526020600020905b8154815260200190600101908083116111a2575b50505050509050919050565b600081815260018301602052604081205461100957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610421565b600081815260018301602052604081205480156112f257600061122d60018361143a565b85549091506000906112419060019061143a565b90508082146112a65760008660000182815481106112615761126161147c565b90600052602060002001549050808760000184815481106112845761128461147c565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806112b7576112b7611492565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610421565b6000915050610421565b80356001600160a01b038116811461131357600080fd5b919050565b6000806040838503121561132b57600080fd5b8235915061133b602084016112fc565b90509250929050565b60006020828403121561135657600080fd5b81356001600160e01b0319811681146106eb57600080fd5b60006020828403121561138057600080fd5b5035919050565b6000806040838503121561139a57600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b818110156113ea5783516001600160a01b0316835292840192918401916001016113c5565b50909695505050505050565b60006020828403121561140857600080fd5b6106eb826112fc565b634e487b7160e01b600052601160045260246000fd5b8082018082111561042157610421611411565b8181038181111561042157610421611411565b60006020828403121561145f57600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fdfea26469706673582212202e4d18c3964fd66c0b7d333e6ce0114d848c9eb48df860a162de293e12f6e95a64736f6c634300081400330000000000000000000000001c5214269feba6656f558fb08a75a6190be796d3000000000000000000000000de55b113a27cc0c5893caa6ee1c020b6b46650c0000000000000000000000000f9a9340a638674778c2c8cb3402bebb17b8eb4d0
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101725760003560e01c806391d14854116100de578063c6f4f17311610097578063e1758bd811610071578063e1758bd81461034c578063e63ab1e914610364578063fb1bb9de1461038b578063fc7e286d146103b257600080fd5b8063c6f4f17314610313578063ca15c87314610326578063d547741f1461033957600080fd5b806391d148541461028b57806399a7e2211461029e578063a217fddf146102b1578063a3246ad3146102b9578063a3b0b5a3146102d9578063b6b55f251461030057600080fd5b80633f4ba83a116101305780633f4ba83a1461021f578063441a3e70146102275780635c975abb1461023a57806367c1bb12146102455780638456cb59146102585780639010d07c1461026057600080fd5b8062f4cafa1461017757806301ffc9a71461018c5780631ce9f1ef146101b4578063248a9ca3146101c75780632f2ff15d146101f957806336568abe1461020c575b600080fd5b61018a610185366004611318565b6103d2565b005b61019f61019a366004611344565b6103fc565b60405190151581526020015b60405180910390f35b61018a6101c2366004611318565b610427565b6101eb6101d536600461136e565b6000908152600160208190526040909120015490565b6040519081526020016101ab565b61018a610207366004611318565b610443565b61018a61021a366004611318565b61046f565b61018a6104a7565b61018a610235366004611387565b6104dc565b60035460ff1661019f565b61018a61025336600461136e565b61067b565b61018a6106a1565b61027361026e366004611387565b6106d3565b6040516001600160a01b0390911681526020016101ab565b61019f610299366004611318565b6106f2565b61018a6102ac36600461136e565b61071d565b6101eb600081565b6102cc6102c736600461136e565b610739565b6040516101ab91906113a9565b6101eb7f8f4f2da22e8ac8f11e15f9fc141cddbb5deea8800186560abb6e68c5496619a981565b61018a61030e36600461136e565b610753565b600454610273906001600160a01b031681565b6101eb61033436600461136e565b6109bb565b61018a610347366004611318565b6109d2565b6003546102739061010090046001600160a01b031681565b6101eb7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b6101eb7f427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a81565b6101eb6103c03660046113f6565b60056020526000908152604090205481565b6103da6109f8565b6103e2610a22565b6103ee82826001610a48565b6103f86001600055565b5050565b60006001600160e01b03198216635a05180f60e01b1480610421575061042182610d74565b92915050565b61042f6109f8565b610437610a22565b6103ee82826000610a48565b6000828152600160208190526040909120015461045f81610da9565b6104698383610db3565b50505050565b6001600160a01b03811633146104985760405163334bd91960e11b815260040160405180910390fd5b6104a28282610de8565b505050565b7f427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a6104d181610da9565b6104d9610e15565b50565b6104e46109f8565b6104ec610a22565b60006104f88284611427565b9050600081116105685760405162461bcd60e51b815260206004820152603060248201527f476174657761793a20544f54414c5f5749544844524157414c5f4d5553545f4260448201526f0455f475245415445525f5448414e5f360841b60648201526084015b60405180910390fd5b336000908152600560205260409020548111156105d25760405162461bcd60e51b815260206004820152602260248201527f476174657761793a20494e53554646494349454e545f555345525f42414c414e604482015261434560f01b606482015260840161055f565b33600090815260056020526040812080548392906105f190849061143a565b90915550508215610618576003546106189061010090046001600160a01b03163385610e67565b811561063557600454610635906001600160a01b03163384610e67565b604080518481526020810184905233917f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6910160405180910390a2506103f86001600055565b6106836109f8565b61068b610a22565b61069781336000610a48565b6104d96001600055565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a6106cb81610da9565b6104d9610ec6565b60008281526002602052604081206106eb9083610f03565b9392505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6107256109f8565b61072d610a22565b61069781336001610a48565b600081815260026020526040902060609061042190610f0f565b61075b6109f8565b610763610a22565b7f8f4f2da22e8ac8f11e15f9fc141cddbb5deea8800186560abb6e68c5496619a961078d81610da9565b600082116107f35760405162461bcd60e51b815260206004820152602d60248201527f476174657761793a20544f54414c5f4445504f5349545f4d5553545f42455f4760448201526c05245415445525f5448414e5f3609c1b606482015260840161055f565b6003546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015610841573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610865919061144d565b6003549091506108859061010090046001600160a01b0316333086610f1c565b6003546040516370a0823160e01b815230600482015260009183916101009091046001600160a01b0316906370a0823190602401602060405180830381865afa1580156108d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fa919061144d565b610904919061143a565b90508084146109555760405162461bcd60e51b815260206004820181905260248201527f476174657761793a20494e56414c49445f52454345495645445f414d4f554e54604482015260640161055f565b3360009081526005602052604081208054869290610974908490611427565b909155505060405184815233907f2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c49060200160405180910390a25050506104d96001600055565b600081815260026020526040812061042190610f55565b600082815260016020819052604090912001546109ee81610da9565b6104698383610de8565b600260005403610a1b57604051633ee5aeb560e01b815260040160405180910390fd5b6002600055565b60035460ff1615610a465760405163d93c066560e01b815260040160405180910390fd5b565b60008311610aa75760405162461bcd60e51b815260206004820152602660248201527f476174657761793a20414d4f554e545f4d5553545f42455f475245415445525f60448201526505448414e5f360d41b606482015260840161055f565b6001600160a01b038216610b115760405162461bcd60e51b815260206004820152602b60248201527f476174657761793a20524543495049454e545f414444524553535f4d5553545f60448201526a42455f4e4f4e2d5a45524f60a81b606482015260840161055f565b6000806001836001811115610b2857610b28611466565b03610b4c5750506003546004546001600160a01b0361010090920482169116610bc0565b6000836001811115610b6057610b60611466565b03610b855750506004546003546001600160a01b039182169161010090910416610bc0565b60405162461bcd60e51b815260206004820152601060248201526f496e76616c696420537761705479706560801b604482015260640161055f565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa158015610c07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2b919061144d565b9050610c426001600160a01b038416333089610f1c565b6040516370a0823160e01b815230600482015260009082906001600160a01b038616906370a0823190602401602060405180830381865afa158015610c8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caf919061144d565b610cb9919061143a565b9050808714610d0a5760405162461bcd60e51b815260206004820181905260248201527f476174657761793a20494e56414c49445f52454345495645445f414d4f554e54604482015260640161055f565b610d1e6001600160a01b0384168789610e67565b604080516001600160a01b038881168252602082018a9052808616929087169133917fcb803386226022c424543f38623c830b1a56b16f37e100fe5f2aa460054746fd910160405180910390a450505050505050565b60006001600160e01b03198216637965db0b60e01b148061042157506301ffc9a760e01b6001600160e01b0319831614610421565b6104d98133610f5f565b600080610dc08484610f98565b905080156106eb576000848152600260205260409020610de09084611011565b509392505050565b600080610df58484611026565b905080156106eb576000848152600260205260409020610de09084611093565b610e1d6110a8565b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040516001600160a01b038381166024830152604482018390526104a291859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506110cb565b610ece610a22565b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610e4a3390565b60006106eb838361113c565b606060006106eb83611166565b6040516001600160a01b0384811660248301528381166044830152606482018390526104699186918216906323b872dd90608401610e94565b6000610421825490565b610f6982826106f2565b6103f85760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161055f565b6000610fa483836106f2565b6110095760008381526001602081815260408084206001600160a01b0387168086529252808420805460ff19169093179092559051339286917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a4506001610421565b506000610421565b60006106eb836001600160a01b0384166111c2565b600061103283836106f2565b156110095760008381526001602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610421565b60006106eb836001600160a01b038416611209565b60035460ff16610a4657604051638dfc202b60e01b815260040160405180910390fd5b600080602060008451602086016000885af1806110ee576040513d6000823e3d81fd5b50506000513d91508115611106578060011415611113565b6001600160a01b0384163b155b1561046957604051635274afe760e01b81526001600160a01b038516600482015260240161055f565b60008260000182815481106111535761115361147c565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156111b657602002820191906000526020600020905b8154815260200190600101908083116111a2575b50505050509050919050565b600081815260018301602052604081205461100957508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610421565b600081815260018301602052604081205480156112f257600061122d60018361143a565b85549091506000906112419060019061143a565b90508082146112a65760008660000182815481106112615761126161147c565b90600052602060002001549050808760000184815481106112845761128461147c565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806112b7576112b7611492565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610421565b6000915050610421565b80356001600160a01b038116811461131357600080fd5b919050565b6000806040838503121561132b57600080fd5b8235915061133b602084016112fc565b90509250929050565b60006020828403121561135657600080fd5b81356001600160e01b0319811681146106eb57600080fd5b60006020828403121561138057600080fd5b5035919050565b6000806040838503121561139a57600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b818110156113ea5783516001600160a01b0316835292840192918401916001016113c5565b50909695505050505050565b60006020828403121561140857600080fd5b6106eb826112fc565b634e487b7160e01b600052601160045260246000fd5b8082018082111561042157610421611411565b8181038181111561042157610421611411565b60006020828403121561145f57600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fdfea26469706673582212202e4d18c3964fd66c0b7d333e6ce0114d848c9eb48df860a162de293e12f6e95a64736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001c5214269feba6656f558fb08a75a6190be796d3000000000000000000000000de55b113a27cc0c5893caa6ee1c020b6b46650c0000000000000000000000000f9a9340a638674778c2c8cb3402bebb17b8eb4d0
-----Decoded View---------------
Arg [0] : _admin (address): 0x1c5214269FEbA6656f558fB08a75A6190Be796d3
Arg [1] : _nativeToken (address): 0xDE55B113A27Cc0c5893CAa6Ee1C020b6B46650C0
Arg [2] : _mbToken (address): 0xF9a9340A638674778c2c8cB3402bEbB17B8EB4D0
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000001c5214269feba6656f558fb08a75a6190be796d3
Arg [1] : 000000000000000000000000de55b113a27cc0c5893caa6ee1c020b6b46650c0
Arg [2] : 000000000000000000000000f9a9340a638674778c2c8cb3402bebb17b8eb4d0
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ 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.