Feature Tip: Add private address tag to any address under My Name Tag !
Source Code
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| 0x1b83f6f27001f7828a9db6415ccd6bd236569c9835a264111495b80dc2f53dad | Buy | (pending) | 2 days ago | IN | 0.038 ETH | (Pending) | |||
| Buy | 20233555 | 537 days ago | IN | 0.255 ETH | 0.00403528 | ||||
| Buy | 20232889 | 537 days ago | IN | 1.5 ETH | 0.00252718 | ||||
| Buy | 20224316 | 538 days ago | IN | 0.055 ETH | 0.00045058 | ||||
| Buy | 20219457 | 539 days ago | IN | 0.0483 ETH | 0.00131729 | ||||
| Buy | 20219328 | 539 days ago | IN | 0.044 ETH | 0.00141567 | ||||
| Buy | 20217538 | 539 days ago | IN | 0.08 ETH | 0.00127448 | ||||
| Buy | 20212119 | 540 days ago | IN | 0.045 ETH | 0.00159041 | ||||
| Buy | 20207658 | 540 days ago | IN | 0.045 ETH | 0.00081034 | ||||
| Buy | 20204874 | 541 days ago | IN | 0.1 ETH | 0.00078464 | ||||
| Buy | 20202837 | 541 days ago | IN | 0.06 ETH | 0.00041733 | ||||
| Buy | 20202616 | 541 days ago | IN | 0.05 ETH | 0.00046718 | ||||
| Buy | 20198568 | 542 days ago | IN | 0.1183 ETH | 0.00064861 | ||||
| Buy | 20193264 | 542 days ago | IN | 0.7 ETH | 0.00045695 | ||||
| Buy | 20192009 | 543 days ago | IN | 0.1 ETH | 0.0009922 | ||||
| Buy | 20191458 | 543 days ago | IN | 0.042 ETH | 0.00128269 | ||||
| Buy | 20189845 | 543 days ago | IN | 0.14 ETH | 0.00076228 | ||||
| Buy | 20189213 | 543 days ago | IN | 0.1629 ETH | 0.00070573 | ||||
| Buy | 20188324 | 543 days ago | IN | 0.042 ETH | 0.00053772 | ||||
| Buy | 20186572 | 543 days ago | IN | 0.042 ETH | 0.00072749 | ||||
| Buy | 20185770 | 543 days ago | IN | 0.0464 ETH | 0.00108742 | ||||
| Buy | 20184972 | 544 days ago | IN | 0.165 ETH | 0.00144094 | ||||
| Buy | 20182816 | 544 days ago | IN | 0.08 ETH | 0.00100524 | ||||
| Buy | 20181847 | 544 days ago | IN | 0.11 ETH | 0.0008991 | ||||
| Buy | 20180275 | 544 days ago | IN | 0.0541 ETH | 0.00114285 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| Transfer | 20233555 | 537 days ago | 0.04335 ETH | ||||
| Transfer | 20233555 | 537 days ago | 0.21165 ETH | ||||
| Transfer | 20232889 | 537 days ago | 0.255 ETH | ||||
| Transfer | 20232889 | 537 days ago | 1.245 ETH | ||||
| Transfer | 20224316 | 538 days ago | 0.055 ETH | ||||
| Transfer | 20219457 | 539 days ago | 0.0483 ETH | ||||
| Transfer | 20219328 | 539 days ago | 0.044 ETH | ||||
| Transfer | 20217538 | 539 days ago | 0.0136 ETH | ||||
| Transfer | 20217538 | 539 days ago | 0.0664 ETH | ||||
| Transfer | 20212119 | 540 days ago | 0.045 ETH | ||||
| Transfer | 20207658 | 540 days ago | 0.00765 ETH | ||||
| Transfer | 20207658 | 540 days ago | 0.03735 ETH | ||||
| Transfer | 20204874 | 541 days ago | 0.017 ETH | ||||
| Transfer | 20204874 | 541 days ago | 0.083 ETH | ||||
| Transfer | 20202837 | 541 days ago | 0.0102 ETH | ||||
| Transfer | 20202837 | 541 days ago | 0.0498 ETH | ||||
| Transfer | 20202616 | 541 days ago | 0.0085 ETH | ||||
| Transfer | 20202616 | 541 days ago | 0.0415 ETH | ||||
| Transfer | 20198568 | 542 days ago | 0.020111 ETH | ||||
| Transfer | 20198568 | 542 days ago | 0.098189 ETH | ||||
| Transfer | 20193264 | 542 days ago | 0.7 ETH | ||||
| Transfer | 20192009 | 543 days ago | 0.017 ETH | ||||
| Transfer | 20192009 | 543 days ago | 0.083 ETH | ||||
| Transfer | 20191458 | 543 days ago | 0.042 ETH | ||||
| Transfer | 20189845 | 543 days ago | 0.0238 ETH |
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
CoinSale
Compiler Version
v0.8.24+commit.e11b9ed9
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.24;
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '@openzeppelin/contracts/access/AccessControl.sol';
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/Pausable.sol';
import '@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol';
import './Storage.sol';
contract CoinSale is AccessControl, ReentrancyGuard, Pausable {
using SafeERC20 for IERC20;
using Address for address;
bytes32 public constant ONRAMP_ROLE = keccak256('ONRAMP_ROLE');
address internal constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
uint256 public constant DECIMALS = 18;
uint256 public constant UNITS = 1000000000000000000;
uint256 private _total;
Storage private _storage;
AggregatorV3Interface private _priceFeed;
uint256 private _priceThreshold;
event PriceThresholdUpdated(uint256 priceFeedTimeThreshold);
event Erc20Recovered(address token, uint256 amount);
event CoinRecovered(uint256 amount);
event TokensPurchased(address indexed user, address indexed ref, uint256 amount, Storage.Option indexed option, uint256 sold, uint256 round);
error ErrClosed();
error ErrRoundClosed();
error ErrNullAddress();
error ErrInvalidPriceThreshold();
error ErrRoundAllocation();
error ErrPriceThreshold();
error ErrUserNullAddress();
error ErrAmountZero();
error ErrReferral();
error ErrTransfer();
error ErrMin(uint256 amount_, uint256 min_);
error ErrMax(uint256 amount_, uint256 max_);
constructor(address payable storage_, address priceFeed_, uint256 priceThreshold_) {
if (storage_ == address(0) || priceFeed_ == address(0)) {
revert ErrNullAddress();
}
if (priceThreshold_ == 0) {
revert ErrInvalidPriceThreshold();
}
_storage = Storage(storage_);
_priceFeed = AggregatorV3Interface(priceFeed_);
_priceThreshold = priceThreshold_;
_grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
}
function pause()
external onlyRole(DEFAULT_ADMIN_ROLE)
{
_pause();
}
function unpause()
external onlyRole(DEFAULT_ADMIN_ROLE)
{
_unpause();
}
function buy(Storage.Option option_, address ref_)
external payable nonReentrant()
{
_buy(option_, _msgSender(), ref_, false);
}
function buyFor(Storage.Option option_, address user_, address ref_)
external payable onlyRole(ONRAMP_ROLE) nonReentrant()
{
_buy(option_, user_, ref_, true);
}
function setPriceThreshold(uint256 priceThreshold_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
_priceThreshold = priceThreshold_;
emit PriceThresholdUpdated(priceThreshold_);
}
function recoverCoin()
external onlyRole(DEFAULT_ADMIN_ROLE)
{
uint256 balance = address(this).balance;
_msgSender().call{value: balance}('');
emit CoinRecovered(balance);
}
function recoverErc20(address token_, uint256 amount_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
IERC20(token_).safeTransfer(_msgSender(), amount_);
emit Erc20Recovered(token_, amount_);
}
function getStorage()
external view returns (address)
{
return address(_storage);
}
function getTotal()
external view returns (uint256)
{
return _total;
}
function getPriceThreshold()
external view returns (uint256)
{
return _priceThreshold;
}
function _buy(Storage.Option option_, address user_, address ref_, bool max_)
internal whenNotPaused()
{
uint256 amount = msg.value;
if (user_ == address(0)) {
revert ErrUserNullAddress();
}
if (user_ == ref_) {
revert ErrReferral();
}
if (amount == 0) {
revert ErrAmountZero();
}
if (!_storage.isActive()) {
revert ErrClosed();
}
Storage.Round memory round = _storage.getRound(_storage.getCurrentRound());
if (round.state != Storage.State.Opened) {
revert ErrRoundClosed();
}
if (round.supply < round.sold + _getSold(amount, option_)) {
revert ErrRoundAllocation();
}
uint8 decimals = _priceFeed.decimals();
(, int256 price, , uint256 updatedAt,) = _priceFeed.latestRoundData();
if (block.timestamp - updatedAt > _priceThreshold) {
revert ErrPriceThreshold();
}
uint256 funds = (amount * uint256(price) * UNITS) / (10 ** (DECIMALS + decimals));
if (_storage.getMin() > funds) {
revert ErrMin(funds, _storage.getMin());
}
uint256 limit = max_ ? _storage.maxLimitOf(user_) : _storage.limitOf(user_);
if (limit < funds) {
revert ErrMax(funds, limit);
}
(address ref, uint256 coinFunds, uint256 tokenFunds) = _getRef(user_, ref_, option_, amount);
_purchase(amount, coinFunds);
_total = _total + amount;
uint256 sold = _getSold(amount, option_);
uint256 investment = (amount * uint256(price) * UNITS) / (10 ** (DECIMALS + decimals));
_storage.setState(user_, ETH, investment, sold, ref_, coinFunds, tokenFunds);
emit TokensPurchased(user_, ref, amount, option_, sold, _storage.getCurrentRound());
}
function _purchase(uint256 amount_, uint256 reward_)
internal
{
address treasury = _storage.getTreasury();
(bool success, ) = treasury.call{value: amount_ - reward_}('');
if (!success) {
revert ErrTransfer();
}
if (reward_ > 0) {
(bool rSuccess, ) = address(_storage).call{value: reward_}('');
if (!rSuccess) revert ErrTransfer();
}
}
function _getRef(address user_, address ref_, Storage.Option option_, uint256 amount_)
internal view returns (address, uint256, uint256)
{
address ref = _storage.getRef(user_, ref_);
if (ref == address(0)) {
return (ref, 0, 0);
}
(uint256 fRate, uint256 sRate) = _storage.getRefRates(ref);
uint256 coinFunds = amount_ * fRate / 1000;
uint256 tokenFunds = amount_ * sRate / 1000;
uint256 tokenSold = _getSold(tokenFunds, option_);
return (ref, coinFunds, tokenSold);
}
function _getSold(uint256 amount_, Storage.Option option_)
internal view returns (uint256)
{
uint8 decimals = _priceFeed.decimals();
(, int256 price, , uint256 updatedAt,) = _priceFeed.latestRoundData();
if (block.timestamp - updatedAt > _priceThreshold) {
revert ErrPriceThreshold();
}
return (amount_ * uint256(price) * UNITS) / _storage.getPrice(option_) / (10 ** decimals);
}
receive() external payable { }
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function getRoundData(
uint80 _roundId
) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}// 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.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC165 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, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the 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.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 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.
*/
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.
*/
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.
*/
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 Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
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 silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @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 AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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
* {FailedInnerCall} 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 AddressInsufficientBalance(address(this));
}
(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 {FailedInnerCall}) 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 {FailedInnerCall} 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 {FailedInnerCall}.
*/
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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// 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.0.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 ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
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.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// 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.0.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 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
pragma solidity 0.8.24;
import '@openzeppelin/contracts/access/AccessControl.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '@openzeppelin/contracts/utils/ReentrancyGuard.sol';
import '@openzeppelin/contracts/utils/math/Math.sol';
contract Storage is AccessControl, ReentrancyGuard {
using SafeERC20 for IERC20;
enum Option { Short, Long }
enum State { None, Opened, Closed }
struct Round {
bool defined;
State state;
uint256 sPrice;
uint256 lPrice;
uint256 sold;
uint256 supply;
}
struct Referral {
bool defined;
bool enabled;
uint256 firstRefRate;
uint256 secondRefRate;
}
bytes32 public constant OPERATOR_ROLE = keccak256('OPERATOR_ROLE');
address internal constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
address internal constant TOKEN = 0x0000000000000000000000000000000000000001;
uint256 internal constant MAX = 1000000000000000000000000;
uint256 internal constant MIN = 1000000000000000000;
address private _treasury;
State private _state;
Round[] private _rounds;
uint256 private _currentRound;
uint256 private _max;
uint256 private _min;
uint256 private _authLimit;
mapping(address => bool) private _auth;
uint256 private _firstRefRate = 50;
uint256 private _secondRefRate = 50;
uint256 private _totalSold;
mapping(address => uint256) private _funds;
mapping(address => mapping(uint256 => uint256)) private _balances;
mapping(address => Referral) private _refs;
mapping(address => address) private _refsUsers;
mapping(address => mapping(address => uint256)) _refsBalances;
event StateUpdated(State state);
event RoundOpened(uint256 indexed round);
event RoundClosed(uint256 indexed round);
event RoundAdded(uint256 sPrice, uint256 lPrice, uint256 supply);
event RoundPriceUpdated(uint256 indexed round, uint256 sPrice, uint256 lPrice);
event RoundSupplyUpdated(uint256 indexed round, uint256 supply);
event Erc20Recovered(address token, uint256 amount);
event CoinRecovered(uint256 amount);
event AuthLimitUpdated(uint256 limit);
event AuthUserUpdated(address indexed user, bool value);
event MaxUpdated(uint256 amount);
event MinUpdated(uint256 amount);
event TreasuryUpdated(address indexed treasury);
event RefRateSetup(uint256 firstRefRate, uint256 secondRefRate);
event ReferralSetup(address indexed ref, uint256 firstRefRate, uint256 secondRefRate);
event ReferralEnabled(address indexed ref);
event ReferralDisabled(address indexed ref);
event ClaimedFunds(address indexed ref, address indexed token, uint256 amount);
error ErrParamsInvalid();
error ErrStarted();
error ErrClosed();
error ErrNullAddress();
error ErrRoundUndefined(uint256 index_);
error ErrRoundStarted(uint256 index_);
error ErrRoundClosed(uint256 index_);
error ErrRoundSupply(uint256 index_);
error ErrMin(uint256 amount_, uint256 min_);
error ErrMax(uint256 amount_, uint256 max_);
error ErrAuthLimit(uint256 limit_, uint256 min_, uint256 max_);
error ErrFirstRefFunds(uint256 reward_);
error ErrSecondRefFunds(uint256 reward_);
error ErrRefUndefined(address ref_);
error ErrRefEnabled(address ref_);
error ErrRefDisabled(address ref_);
error ErrTokenUndefined();
error ErrTransfer();
constructor(address treasury_) {
if (treasury_ == address(0)) {
revert ErrNullAddress();
}
_treasury = treasury_;
_grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
_grantRole(OPERATOR_ROLE, _msgSender());
}
function open()
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (_state != State.None) {
revert ErrStarted();
}
_state = State.Opened;
emit StateUpdated(_state);
}
function close()
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (!isActive()) {
revert ErrClosed();
}
_state = State.Closed;
emit StateUpdated(_state);
}
function setRound(uint256 sPrice_, uint256 lPrice_, uint256 supply_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (isInactive()) {
revert ErrClosed();
}
_rounds.push(
Round({ defined: true, state: State.None, sPrice: sPrice_, lPrice: lPrice_, sold: 0, supply: supply_})
);
emit RoundAdded(sPrice_, lPrice_, supply_);
}
function setRefRate(uint256 firstRefRate_, uint256 secondRefRate_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (isInactive()) {
revert ErrClosed();
}
if (firstRefRate_ > 1000) {
revert ErrFirstRefFunds(firstRefRate_);
}
if (secondRefRate_ > 1000) {
revert ErrSecondRefFunds(secondRefRate_);
}
_firstRefRate = firstRefRate_;
_secondRefRate = secondRefRate_;
emit RefRateSetup(_firstRefRate, _secondRefRate);
}
function setupReferrals(address[] calldata refs_, uint256[] calldata firstRefRate_, uint256[] calldata secodRefFunds_)
external onlyRole(OPERATOR_ROLE)
{
if (isInactive()) {
revert ErrClosed();
}
if (refs_.length != firstRefRate_.length || refs_.length != secodRefFunds_.length) {
revert ErrParamsInvalid();
}
for (uint256 index = 0; index < refs_.length; index++) {
_refs[refs_[index]] = Referral({
defined: true,
enabled: true,
firstRefRate: firstRefRate_[index],
secondRefRate: secodRefFunds_[index]
});
emit ReferralSetup(refs_[index], firstRefRate_[index], secodRefFunds_[index]);
}
}
function updateRoundPrice(uint256 index_, uint256 sPrice_, uint256 lPrice_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (isInactive()) {
revert ErrClosed();
}
if (!_rounds[index_].defined) {
revert ErrRoundUndefined(index_);
}
if (_rounds[index_].state != State.None) {
revert ErrRoundStarted(index_);
}
_rounds[index_].sPrice = sPrice_;
_rounds[index_].lPrice = lPrice_;
emit RoundPriceUpdated(index_, sPrice_, lPrice_);
}
function updateRoundSupply(uint256 index_, uint256 supply_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (isInactive()) {
revert ErrClosed();
}
if (!_rounds[index_].defined) {
revert ErrRoundUndefined(index_);
}
if (_rounds[index_].state == State.Closed) {
revert ErrRoundClosed(index_);
}
if (_rounds[index_].sold > supply_) {
revert ErrRoundSupply(index_);
}
_rounds[index_].supply = supply_;
emit RoundSupplyUpdated(index_, supply_);
}
function openRound(uint256 index_)
external onlyRole(OPERATOR_ROLE)
{
if (!isActive()) {
revert ErrClosed();
}
if (!_rounds[index_].defined) {
revert ErrRoundUndefined(index_);
}
if (_rounds[index_].state != State.None) {
revert ErrRoundStarted(index_);
}
if (_rounds[_currentRound].state == State.Opened) {
_rounds[_currentRound].state = State.Closed;
}
_rounds[index_].state = State.Opened;
_currentRound = index_;
emit RoundOpened(index_);
}
function closeRound(uint256 index_)
external onlyRole(OPERATOR_ROLE)
{
if (!_rounds[index_].defined) {
revert ErrRoundUndefined(index_);
}
if (_rounds[index_].state != State.Opened) {
revert ErrRoundClosed(index_);
}
_rounds[index_].state = State.Closed;
emit RoundClosed(index_);
}
function setAuth(address user_, bool value_)
external onlyRole(OPERATOR_ROLE)
{
_auth[user_] = value_;
emit AuthUserUpdated(user_, value_);
}
function setAuthBatch(address[] calldata users_, bool[] calldata values_)
external onlyRole(OPERATOR_ROLE)
{
if (users_.length != values_.length) {
revert ErrParamsInvalid();
}
for (uint256 index = 0; index < users_.length; index++) {
_auth[users_[index]] = values_[index];
emit AuthUserUpdated(users_[index], values_[index]);
}
}
function setMax(uint256 amount_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (amount_ > MAX) {
revert ErrMax(amount_, MAX);
}
if (amount_ < _min) {
revert ErrMin(amount_, _min);
}
_max = amount_;
emit MaxUpdated(_max);
}
function setMin(uint256 amount_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (amount_ < MIN) {
revert ErrMin(amount_, MIN);
}
if (amount_ > _max) {
revert ErrMax(amount_, _max);
}
_min = amount_;
emit MinUpdated(_min);
}
function setAuthLimit(uint256 amount_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (_min > amount_ || amount_ > _max) {
revert ErrAuthLimit(amount_, _min, _max);
}
_authLimit = amount_;
emit AuthLimitUpdated(amount_);
}
function setTreasury(address treasury_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (treasury_ == address(0)) {
revert ErrNullAddress();
}
_treasury = treasury_;
emit TreasuryUpdated(_treasury);
}
function setState(address user_, address token_, uint256 amount_, uint256 sold_, address ref_, uint256 fReward_, uint256 sReward_)
external onlyRole(OPERATOR_ROLE)
{
_funds[user_] = _funds[user_] + amount_;
_totalSold = _totalSold + sold_;
_rounds[_currentRound].sold = _rounds[_currentRound].sold + sold_;
_balances[user_][_currentRound] = _balances[user_][_currentRound] + sold_;
if (ref_ != address(0)) {
if (!_refs[ref_].defined) {
_refs[ref_].defined = true;
_refs[ref_].enabled = true;
emit ReferralSetup(ref_, _firstRefRate, _secondRefRate);
}
_refsBalances[ref_][token_] += fReward_;
_refsBalances[ref_][TOKEN] += sReward_;
_refsUsers[user_] = ref_;
}
}
function enableReferral(address ref_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (!_refs[ref_].defined) {
revert ErrRefUndefined(ref_);
}
if (_refs[ref_].enabled) {
revert ErrRefEnabled(ref_);
}
_refs[ref_].enabled = true;
emit ReferralEnabled(ref_);
}
function disableReferral(address ref_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
if (!_refs[ref_].defined) {
revert ErrRefUndefined(ref_);
}
if (!_refs[ref_].enabled) {
revert ErrRefDisabled(ref_);
}
_refs[ref_].enabled = false;
emit ReferralDisabled(ref_);
}
function claimRef(address[] calldata tokens_)
external nonReentrant()
{
address ref_ = _msgSender();
if (tokens_.length == 0) {
revert ErrTokenUndefined();
}
if (!_refs[ref_].defined) {
revert ErrRefUndefined(ref_);
}
if (!_refs[ref_].enabled) {
revert ErrRefDisabled(ref_);
}
for (uint256 i = 0; i < tokens_.length; i++) {
address token = tokens_[i];
uint256 balance = _refsBalances[ref_][token];
if (balance == 0) { continue; }
_refsBalances[ref_][token] = 0;
if (token == ETH) {
(bool success, ) = ref_.call{value: balance}('');
if (!success) revert ErrTransfer();
} else {
IERC20(token).safeTransfer(ref_, balance);
}
emit ClaimedFunds(ref_, token, balance);
}
}
function recoverCoin()
external onlyRole(DEFAULT_ADMIN_ROLE)
{
uint256 balance = address(this).balance;
_msgSender().call{value: balance}('');
emit CoinRecovered(balance);
}
function recoverErc20(address token_, uint256 amount_)
external onlyRole(DEFAULT_ADMIN_ROLE)
{
IERC20(token_).safeTransfer(_msgSender(), amount_);
emit Erc20Recovered(token_, amount_);
}
function getTreasury() external view returns (address) {
return _treasury;
}
function getMax() external view returns (uint256) {
return _max;
}
function getMin() external view returns (uint256) {
return _min;
}
function getRoundsCount() external view returns (uint256) {
return _rounds.length;
}
function getCurrentRound() external view returns (uint256) {
return _currentRound;
}
function getRound(uint256 index_) external view returns (Round memory) {
return _rounds[index_];
}
function getTotalSold() external view returns (uint256) {
return _totalSold;
}
function balanceOf(uint256 round_, address user_) external view returns (uint256) {
return _balances[user_][round_];
}
function refBalanceOf(address token_, address user_) external view returns (uint256) {
return _refsBalances[user_][token_];
}
function limitOf(address user_) external view returns (uint256) {
uint256 amount = _funds[user_];
uint256 limit = _authLimit;
if (isAuth(user_)) {
limit = _max;
}
return amount < limit ? limit - amount : 0;
}
function maxLimitOf(address user_) external view returns (uint256) {
uint256 amount = _funds[user_];
return amount < _max ? _max - amount : 0;
}
function getAuthLimit() external view returns (uint256) {
return _authLimit;
}
function getRefRates() external view returns (uint256, uint256) {
return (_firstRefRate, _secondRefRate);
}
function getRef(address user_, address ref_) external view returns (address) {
Referral memory ref = _refs[_refsUsers[user_]];
if (ref.defined && ref.enabled) {
return _refsUsers[user_];
}
ref = _refs[ref_];
if (!ref.defined || ref.enabled) {
return ref_;
}
return address(0);
}
function getRefRates(address ref_) external view returns (uint256, uint256) {
Referral memory ref = _refs[ref_];
if (ref.defined) {
return (Math.max(ref.firstRefRate, _firstRefRate), Math.max(ref.secondRefRate, _secondRefRate));
}
return (_firstRefRate, _secondRefRate);
}
function isActive() public view returns (bool) {
return _state == State.Opened;
}
function isInactive() public view returns (bool) {
return _state == State.Closed;
}
function getPrice(Option option_) public view returns (uint256) {
if (_rounds[_currentRound].state == State.Opened) {
return option_ == Option.Short ? _rounds[_currentRound].sPrice : _rounds[_currentRound].lPrice;
}
return 0;
}
function isAuth(address user_) public view returns (bool) {
return _auth[user_];
}
receive() external payable { }
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address payable","name":"storage_","type":"address"},{"internalType":"address","name":"priceFeed_","type":"address"},{"internalType":"uint256","name":"priceThreshold_","type":"uint256"}],"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":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ErrAmountZero","type":"error"},{"inputs":[],"name":"ErrClosed","type":"error"},{"inputs":[],"name":"ErrInvalidPriceThreshold","type":"error"},{"inputs":[{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"uint256","name":"max_","type":"uint256"}],"name":"ErrMax","type":"error"},{"inputs":[{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"uint256","name":"min_","type":"uint256"}],"name":"ErrMin","type":"error"},{"inputs":[],"name":"ErrNullAddress","type":"error"},{"inputs":[],"name":"ErrPriceThreshold","type":"error"},{"inputs":[],"name":"ErrReferral","type":"error"},{"inputs":[],"name":"ErrRoundAllocation","type":"error"},{"inputs":[],"name":"ErrRoundClosed","type":"error"},{"inputs":[],"name":"ErrTransfer","type":"error"},{"inputs":[],"name":"ErrUserNullAddress","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CoinRecovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Erc20Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"priceFeedTimeThreshold","type":"uint256"}],"name":"PriceThresholdUpdated","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":"user","type":"address"},{"indexed":true,"internalType":"address","name":"ref","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"enum Storage.Option","name":"option","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"sold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"}],"name":"TokensPurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DECIMALS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONRAMP_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNITS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum Storage.Option","name":"option_","type":"uint8"},{"internalType":"address","name":"ref_","type":"address"}],"name":"buy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"enum Storage.Option","name":"option_","type":"uint8"},{"internalType":"address","name":"user_","type":"address"},{"internalType":"address","name":"ref_","type":"address"}],"name":"buyFor","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getPriceThreshold","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":[],"name":"getStorage","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"recoverCoin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"recoverErc20","outputs":[],"stateMutability":"nonpayable","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":"uint256","name":"priceThreshold_","type":"uint256"}],"name":"setPriceThreshold","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":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
608034620000f957601f62001e6938819003918201601f19168301916001600160401b03831184841017620000fe57808492606094604052833981010312620000f95780516001600160a01b03808216929091839003620000f9576020810151918216809203620000f95760400151916001805560ff196002541660025580158015620000f0575b620000de578215620000cc5760018060a01b0319908160045416176004556005541617600555600655620000bb3362000114565b50604051611cc39081620001a68239f35b60405163e840a88d60e01b8152600490fd5b604051633eaa20b360e01b8152600490fd5b50811562000087565b600080fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b031660008181527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205490919060ff16620001a157818052816020526040822081835260205260408220600160ff1982541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b509056fe608080604052600436101561001d575b50361561001b57600080fd5b005b600090813560e01c90816301ffc9a71461157b57508063248a9ca31461154f5780632e0f2625146115335780632f2ff15d146114f65780633408f73a146114cd57806336568abe146114855780633f4ba83a1461141a5780634fb52c70146113cc5780635c975abb146113a9578063675751c514610cd157806369a4a7b014610c965780636dcf5ce114610c78578063738a8ce614610b6a578063775a25e314610b4c57806377fe143f14610b295780638456cb5914610ace57806391d1485414610a83578063a217fddf14610a67578063a23b892714610a0e578063a5c6a14c146101505763d547741f0361000f573461014d57604036600319011261014d5761014960043561012c6115d0565b908084528360205261014460016040862001546116c8565b61176c565b5080f35b80fd5b50606036600319011261014d576002600435101561014d576101706115d0565b906044356001600160a01b038116900361060b573360009081527fee5815a2a8750a47adb0b1d3fab329a070c112a92be0a66a52913a21ccb1bb3b60205260409020547f91d96aeb79b06d0c0af435886f825cf637b0bfa9f4681ee079c2a9c6c861185c9060ff16156109f057506101e66117e1565b6101ee6118e7565b6001600160a01b038216156109de576001600160a01b03828116604435909116146109cc5734156109ba5760018060a01b0360045416916040516308bcf8b560e21b8152602081600481875afa908115610931578391610980575b501561096e5760405163a32bf59760e01b8152602081600481875afa90811561093157839161093c575b506040519063023c4c9f60e61b8252600482015260c081602481875afa9081156109315783916108a8575b506020810151600381101561089457600103610882576102d3608060a08301519201516102cd60043534611905565b90611811565b116108705760055460405163313ce56760e01b8152906001600160a01b0316602082600481845afa918215610831579060049291859261083c575b5060a09060405193848092633fabe5a360e21b82525afa801561083157849285916107f7575b5061033f9042611899565b600654106107e55761035182346118a6565b80670de0b6b3a7640000810204670de0b6b3a764000014811517156107d15760ff82166012016012116107d1576103a190670de0b6b3a764000061039a60ff85166012016118b9565b91026118c7565b60405163d6362e9760e01b81526020816004818a5afa90811561070f57908291879161079c575b501161071a57604051632b1d914f60e21b81526001600160a01b03851660048201526020816024818a5afa90811561070f5786916106dd575b508181106106bf575050839460049160209561042234853560443589611b00565b959198909460405192838092631d8cf42560e11b82525afa801561063b578280929181928291610690575b506104588734611899565b905af161046361164e565b501561067e578161065e575b61047b34600354611811565b60035561049461048d60043534611905565b94346118a6565b90670de0b6b3a7640000820291808304670de0b6b3a7640000149015171561064a57879392916104cc60ff6104d293166012016118b9565b906118c7565b6004549091906001600160a01b0316803b156106465784928360e492604051968795869463e8feeaa960e01b865260018060a01b038d16600487015273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee602487015260448601528a606486015260018060a01b0360443516608486015260a485015260c48401525af1801561063b57610623575b50506004805460405163a32bf59760e01b81529160209183919082906001600160a01b03165afa9081156106185785916105e1575b50604080513481526020810193909352820152600435926001600160a01b039081169216907f2e4e81439dee0f29bbe94bdb1614d72eac064c09da72ee416aafa9d2a7a1514290606090a46001805580f35b90506020813d602011610610575b816105fc6020938361162c565b8101031261060b57513861058f565b600080fd5b3d91506105ef565b6040513d87823e3d90fd5b61062c90611618565b61063757833861055a565b8380fd5b6040513d84823e3d90fd5b8480fd5b634e487b7160e01b88526011600452602488fd5b868080808560018060a01b03600454165af161067861164e565b5061046f575b60405163ba83c1af60e01b8152600490fd5b6106b2915060203d6020116106b8575b6106aa818361162c565b810190611ae1565b3861044d565b503d6106a0565b6044925060405191634909fb6f60e11b835260048301526024820152fd5b90506020813d602011610707575b816106f86020938361162c565b8101031261060b575138610401565b3d91506106eb565b6040513d88823e3d90fd5b60405163d6362e9760e01b815290856020836004818b5afa908115610790579061075d575b6044925060405191637932cc9560e01b835260048301526024820152fd5b506020823d602011610788575b816107776020938361162c565b8101031261060b576044915161073f565b3d915061076a565b604051903d90823e3d90fd5b9150506020813d6020116107c9575b816107b86020938361162c565b8101031261060b57819051386103c8565b3d91506107ab565b634e487b7160e01b85526011600452602485fd5b604051634339de0f60e11b8152600490fd5b61033f935061081e915060a03d60a01161082a575b610816818361162c565b810190611864565b50949250509290610334565b503d61080c565b6040513d86823e3d90fd5b60a09192506108629060203d602011610869575b61085a818361162c565b810190611834565b919061030e565b503d610850565b60405163cba58f4560e01b8152600490fd5b604051631879d33d60e01b8152600490fd5b634e487b7160e01b84526021600452602484fd5b905060c0813d60c011610929575b816108c360c0938361162c565b8101031261092557604051906108d8826115e6565b6108e181611804565b825260208101516003811015610646579060a0916020840152604081015160408401526060810151606084015260808101516080840152015160a08201523861029e565b8280fd5b3d91506108b6565b6040513d85823e3d90fd5b90506020813d602011610966575b816109576020938361162c565b8101031261060b575138610273565b3d915061094a565b6040516305e5234560e21b8152600490fd5b90506020813d6020116109b2575b8161099b6020938361162c565b81010312610925576109ac90611804565b38610249565b3d915061098e565b60405163f2f17a2b60e01b8152600490fd5b604051630bb028ab60e11b8152600490fd5b604051632390dddf60e11b8152600490fd5b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b503461014d578060031936011261014d57610a2761168e565b7f997d0c369c0eddd4cd02edbdc0fba7541f175bd55d30f7a94119ebca571a18066020478380808084335af150610a5c61164e565b50604051908152a180f35b503461014d578060031936011261014d57602090604051908152f35b503461014d57604036600319011261014d576040610a9f6115d0565b91600435815280602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b503461014d578060031936011261014d57610ae761168e565b610aef6118e7565b600160ff1960025416176002557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b503461014d578060031936011261014d576020604051670de0b6b3a76400008152f35b503461014d578060031936011261014d576020600354604051908152f35b503461014d57604036600319011261014d576004356001600160a01b038116919082810361060b5760243590610b9e61168e565b60405163a9059cbb60e01b6020820190815233602483015260448083018590528252610be89185918291610bd360648261162c565b519082895af1610be161164e565b9086611c2a565b8051908115159182610c55575b5050610c3c57604080516001600160a01b0392909216825260208201929092527fa75ce34872c395a628c61aff7fee33ef71bed972e3a28c7f63fff0022f629aa99190a180f35b604051635274afe760e01b815260048101859052602490fd5b8192509060209181010312610637576020610c709101611804565b153880610bf5565b503461014d578060031936011261014d576020600654604051908152f35b503461014d578060031936011261014d5760206040517f91d96aeb79b06d0c0af435886f825cf637b0bfa9f4681ee079c2a9c6c861185c8152f35b50604036600319011261014d5760043560028110156113a557610cf26115d0565b610cfa6117e1565b610d026118e7565b33156109de57336001600160a01b038216146109cc5734156109ba5760018060a01b03600454166040516308bcf8b560e21b8152602081600481855afa90811561061857859161136b575b501561096e5760405163a32bf59760e01b8152602081600481855afa908115610618578591611339575b506040519063023c4c9f60e61b8252600482015260c081602481855afa9081156106185785916112b0575b506020810151600381101561129c5760010361088257610dcf608060a08301519201516102cd8634611905565b116108705760055460405163313ce56760e01b815292906001600160a01b0316602084600481845afa90811561070f576004948792611278575b5060a09060405195868092633fabe5a360e21b82525afa801561070f578694879161124e575b50610e3a9042611899565b600654106107e557610e4c84346118a6565b670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561123a5760ff821660120160121161123a57610e8e906104cc60ff84166012016118b9565b60405163d6362e9760e01b8152602081600481885afa801561117f5782918991611205575b501161118a5760405163151a8b2960e21b8152336004820152602081602481885afa90811561117f578891611149575b508181106106bf5750509060046020939287610f0134898633611b00565b604051631d8cf42560e11b8152929891979095839182905afa801561063b57828092918192829161112a575b50610f388934611899565b905af1610f4361164e565b501561067e57836110f9575b610f5b34600354611811565b600355610f72610f6b8834611905565b96346118a6565b90670de0b6b3a7640000820291808304670de0b6b3a764000014901517156110e557889392916104cc60ff610faa93166012016118b9565b6004546001600160a01b031691823b156106465760e4928591604051978896879563e8feeaa960e01b875233600488015273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee602488015260448701528b606487015260018060a01b0316608486015260a485015260c48401525af18015610618576110d2575b506004805460405163a32bf59760e01b81529160209183919082906001600160a01b03165afa9081156106185785916110a0575b50604051923484526020840152604083015260018060a01b0316907f2e4e81439dee0f29bbe94bdb1614d72eac064c09da72ee416aafa9d2a7a1514260603392a46001805580f35b90506020813d6020116110ca575b816110bb6020938361162c565b8101031261060b575138611058565b3d91506110ae565b6110de90949194611618565b9238611024565b634e487b7160e01b89526011600452602489fd5b878080808760018060a01b03600454165af161111361164e565b50610f4f5760405163ba83c1af60e01b8152600490fd5b611143915060203d6020116106b8576106aa818361162c565b38610f2d565b90506020813d602011611177575b816111646020938361162c565b81010312611173575138610ee3565b8780fd5b3d9150611157565b6040513d8a823e3d90fd5b60405163d6362e9760e01b8152879190602081600481895afa9081156109315783916111cf575b6044838360405191637932cc9560e01b835260048301526024820152fd5b90506020813d6020116111fd575b816111ea6020938361162c565b81010312610925576044925051836111b1565b3d91506111dd565b9150506020813d602011611232575b816112216020938361162c565b810103126111735781905138610eb3565b3d9150611214565b634e487b7160e01b87526011600452602487fd5b610e3a955061126c915060a03d60a01161082a57610816818361162c565b50969250509490610e2f565b60a09192506112959060203d6020116108695761085a818361162c565b9190610e09565b634e487b7160e01b86526021600452602486fd5b905060c0813d60c011611331575b816112cb60c0938361162c565b8101031261064657604051906112e0826115e6565b6112e981611804565b8252602081015190600382101561132d5760a0916020840152604081015160408401526060810151606084015260808101516080840152015160a082015238610da2565b8680fd5b3d91506112be565b90506020813d602011611363575b816113546020938361162c565b81010312610646575138610d77565b3d9150611347565b90506020813d60201161139d575b816113866020938361162c565b810103126106465761139790611804565b38610d4d565b3d9150611379565b5080fd5b503461014d578060031936011261014d57602060ff600254166040519015158152f35b503461014d57602036600319011261014d577f6b0695b82961d69699cb7b8438d7eac257041649a2d203c75aa4f54e13d1ecca602060043561140c61168e565b80600655604051908152a180f35b503461014d578060031936011261014d5761143361168e565b60025460ff8116156114735760ff19166002557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a180f35b604051638dfc202b60e01b8152600490fd5b503461014d57604036600319011261014d5761149f6115d0565b336001600160a01b038216036114bb576101499060043561176c565b60405163334bd91960e11b8152600490fd5b503461014d578060031936011261014d576004546040516001600160a01b039091168152602090f35b503461014d57604036600319011261014d576101496004356115166115d0565b908084528360205261152e60016040862001546116c8565b6116ee565b503461014d578060031936011261014d57602060405160128152f35b503461014d57602036600319011261014d57600160406020926004358152808452200154604051908152f35b9050346113a55760203660031901126113a55760043563ffffffff60e01b81168091036109255760209250637965db0b60e01b81149081156115bf575b5015158152f35b6301ffc9a760e01b149050386115b8565b602435906001600160a01b038216820361060b57565b60c0810190811067ffffffffffffffff82111761160257604052565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff811161160257604052565b90601f8019910116810190811067ffffffffffffffff82111761160257604052565b3d15611689573d9067ffffffffffffffff8211611602576040519161167d601f8201601f19166020018461162c565b82523d6000602084013e565b606090565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205460ff16156109f05750565b80600052600060205260406000203360005260205260ff60406000205416156109f05750565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054161560001461176757808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b505090565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054166000146117675780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b6002600154146117f2576002600155565b604051633ee5aeb560e01b8152600490fd5b5190811515820361060b57565b9190820180921161181e57565b634e487b7160e01b600052601160045260246000fd5b9081602091031261060b575160ff8116810361060b5790565b519069ffffffffffffffffffff8216820361060b57565b908160a091031261060b576118788161184d565b9160208201519160408101519161189660806060840151930161184d565b90565b9190820391821161181e57565b8181029291811591840414171561181e57565b604d811161181e57600a0a90565b81156118d1570490565b634e487b7160e01b600052601260045260246000fd5b60ff600254166118f357565b60405163d93c066560e01b8152600490fd5b6005546040805163313ce56760e01b81526004959490936001600160a01b039360209190851682878a81845afa968715611ab45790899291600098611abf575b5060a090865193848092633fabe5a360e21b82525afa8015611ab457600092600091611a8a575b506119779042611899565b60065410611a7a5790611989916118a6565b93670de0b6b3a764000094858102958187041490151715611a6557875416835192631bf8f3f960e11b84526002811015611a5057602484849381938c8301525afa928315611a465750600092611a16575b50506119e89060ff926118c7565b9116604d8111611a0157611896929350600a0a906118c7565b601184634e487b7160e01b6000525260246000fd5b90809250813d8311611a3f575b611a2d818361162c565b8101031261060b5751816119e86119da565b503d611a23565b513d6000823e3d90fd5b602189634e487b7160e01b6000525260246000fd5b601188634e487b7160e01b6000525260246000fd5b8451634339de0f60e11b81528990fd5b6119779350611aa8915060a03d60a01161082a57610816818361162c565b5094925050929061196c565b85513d6000823e3d90fd5b60a0919850611ada90853d87116108695761085a818361162c565b9790611945565b9081602091031261060b57516001600160a01b038116810361060b5790565b92939160018060a01b03918260045416928060409281845198630977471760e31b8a52166004890152166024870152602086604481875afa958615611c1f57600096611bfe575b5085168015611bef5781906024825180968193638f11740b60e01b835260048301525afa928315611be457600091600094611ba9575b5050611b9d611ba393611b96926103e89384918a6118a6565b04976118a6565b04611905565b91929190565b8194508092503d8311611bdd575b611bc1818361162c565b8101031261060b57815160209092015191611b9d611b96611b7d565b503d611bb7565b50513d6000823e3d90fd5b50505050915090600090600090565b611c1891965060203d6020116106b8576106aa818361162c565b9438611b47565b82513d6000823e3d90fd5b90611c515750805115611c3f57805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580611c84575b611c62575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b15611c5a56fea2646970667358221220a30328a2aa9633f5734cf5821687eef21c81177b4b243096ff4f70a76c858a9364736f6c63430008180033000000000000000000000000d505de0c61271c51c8fdbe377557f73d5bce03d00000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b84190000000000000000000000000000000000000000000000000000000000001554
Deployed Bytecode
0x608080604052600436101561001d575b50361561001b57600080fd5b005b600090813560e01c90816301ffc9a71461157b57508063248a9ca31461154f5780632e0f2625146115335780632f2ff15d146114f65780633408f73a146114cd57806336568abe146114855780633f4ba83a1461141a5780634fb52c70146113cc5780635c975abb146113a9578063675751c514610cd157806369a4a7b014610c965780636dcf5ce114610c78578063738a8ce614610b6a578063775a25e314610b4c57806377fe143f14610b295780638456cb5914610ace57806391d1485414610a83578063a217fddf14610a67578063a23b892714610a0e578063a5c6a14c146101505763d547741f0361000f573461014d57604036600319011261014d5761014960043561012c6115d0565b908084528360205261014460016040862001546116c8565b61176c565b5080f35b80fd5b50606036600319011261014d576002600435101561014d576101706115d0565b906044356001600160a01b038116900361060b573360009081527fee5815a2a8750a47adb0b1d3fab329a070c112a92be0a66a52913a21ccb1bb3b60205260409020547f91d96aeb79b06d0c0af435886f825cf637b0bfa9f4681ee079c2a9c6c861185c9060ff16156109f057506101e66117e1565b6101ee6118e7565b6001600160a01b038216156109de576001600160a01b03828116604435909116146109cc5734156109ba5760018060a01b0360045416916040516308bcf8b560e21b8152602081600481875afa908115610931578391610980575b501561096e5760405163a32bf59760e01b8152602081600481875afa90811561093157839161093c575b506040519063023c4c9f60e61b8252600482015260c081602481875afa9081156109315783916108a8575b506020810151600381101561089457600103610882576102d3608060a08301519201516102cd60043534611905565b90611811565b116108705760055460405163313ce56760e01b8152906001600160a01b0316602082600481845afa918215610831579060049291859261083c575b5060a09060405193848092633fabe5a360e21b82525afa801561083157849285916107f7575b5061033f9042611899565b600654106107e55761035182346118a6565b80670de0b6b3a7640000810204670de0b6b3a764000014811517156107d15760ff82166012016012116107d1576103a190670de0b6b3a764000061039a60ff85166012016118b9565b91026118c7565b60405163d6362e9760e01b81526020816004818a5afa90811561070f57908291879161079c575b501161071a57604051632b1d914f60e21b81526001600160a01b03851660048201526020816024818a5afa90811561070f5786916106dd575b508181106106bf575050839460049160209561042234853560443589611b00565b959198909460405192838092631d8cf42560e11b82525afa801561063b578280929181928291610690575b506104588734611899565b905af161046361164e565b501561067e578161065e575b61047b34600354611811565b60035561049461048d60043534611905565b94346118a6565b90670de0b6b3a7640000820291808304670de0b6b3a7640000149015171561064a57879392916104cc60ff6104d293166012016118b9565b906118c7565b6004549091906001600160a01b0316803b156106465784928360e492604051968795869463e8feeaa960e01b865260018060a01b038d16600487015273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee602487015260448601528a606486015260018060a01b0360443516608486015260a485015260c48401525af1801561063b57610623575b50506004805460405163a32bf59760e01b81529160209183919082906001600160a01b03165afa9081156106185785916105e1575b50604080513481526020810193909352820152600435926001600160a01b039081169216907f2e4e81439dee0f29bbe94bdb1614d72eac064c09da72ee416aafa9d2a7a1514290606090a46001805580f35b90506020813d602011610610575b816105fc6020938361162c565b8101031261060b57513861058f565b600080fd5b3d91506105ef565b6040513d87823e3d90fd5b61062c90611618565b61063757833861055a565b8380fd5b6040513d84823e3d90fd5b8480fd5b634e487b7160e01b88526011600452602488fd5b868080808560018060a01b03600454165af161067861164e565b5061046f575b60405163ba83c1af60e01b8152600490fd5b6106b2915060203d6020116106b8575b6106aa818361162c565b810190611ae1565b3861044d565b503d6106a0565b6044925060405191634909fb6f60e11b835260048301526024820152fd5b90506020813d602011610707575b816106f86020938361162c565b8101031261060b575138610401565b3d91506106eb565b6040513d88823e3d90fd5b60405163d6362e9760e01b815290856020836004818b5afa908115610790579061075d575b6044925060405191637932cc9560e01b835260048301526024820152fd5b506020823d602011610788575b816107776020938361162c565b8101031261060b576044915161073f565b3d915061076a565b604051903d90823e3d90fd5b9150506020813d6020116107c9575b816107b86020938361162c565b8101031261060b57819051386103c8565b3d91506107ab565b634e487b7160e01b85526011600452602485fd5b604051634339de0f60e11b8152600490fd5b61033f935061081e915060a03d60a01161082a575b610816818361162c565b810190611864565b50949250509290610334565b503d61080c565b6040513d86823e3d90fd5b60a09192506108629060203d602011610869575b61085a818361162c565b810190611834565b919061030e565b503d610850565b60405163cba58f4560e01b8152600490fd5b604051631879d33d60e01b8152600490fd5b634e487b7160e01b84526021600452602484fd5b905060c0813d60c011610929575b816108c360c0938361162c565b8101031261092557604051906108d8826115e6565b6108e181611804565b825260208101516003811015610646579060a0916020840152604081015160408401526060810151606084015260808101516080840152015160a08201523861029e565b8280fd5b3d91506108b6565b6040513d85823e3d90fd5b90506020813d602011610966575b816109576020938361162c565b8101031261060b575138610273565b3d915061094a565b6040516305e5234560e21b8152600490fd5b90506020813d6020116109b2575b8161099b6020938361162c565b81010312610925576109ac90611804565b38610249565b3d915061098e565b60405163f2f17a2b60e01b8152600490fd5b604051630bb028ab60e11b8152600490fd5b604051632390dddf60e11b8152600490fd5b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b503461014d578060031936011261014d57610a2761168e565b7f997d0c369c0eddd4cd02edbdc0fba7541f175bd55d30f7a94119ebca571a18066020478380808084335af150610a5c61164e565b50604051908152a180f35b503461014d578060031936011261014d57602090604051908152f35b503461014d57604036600319011261014d576040610a9f6115d0565b91600435815280602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b503461014d578060031936011261014d57610ae761168e565b610aef6118e7565b600160ff1960025416176002557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b503461014d578060031936011261014d576020604051670de0b6b3a76400008152f35b503461014d578060031936011261014d576020600354604051908152f35b503461014d57604036600319011261014d576004356001600160a01b038116919082810361060b5760243590610b9e61168e565b60405163a9059cbb60e01b6020820190815233602483015260448083018590528252610be89185918291610bd360648261162c565b519082895af1610be161164e565b9086611c2a565b8051908115159182610c55575b5050610c3c57604080516001600160a01b0392909216825260208201929092527fa75ce34872c395a628c61aff7fee33ef71bed972e3a28c7f63fff0022f629aa99190a180f35b604051635274afe760e01b815260048101859052602490fd5b8192509060209181010312610637576020610c709101611804565b153880610bf5565b503461014d578060031936011261014d576020600654604051908152f35b503461014d578060031936011261014d5760206040517f91d96aeb79b06d0c0af435886f825cf637b0bfa9f4681ee079c2a9c6c861185c8152f35b50604036600319011261014d5760043560028110156113a557610cf26115d0565b610cfa6117e1565b610d026118e7565b33156109de57336001600160a01b038216146109cc5734156109ba5760018060a01b03600454166040516308bcf8b560e21b8152602081600481855afa90811561061857859161136b575b501561096e5760405163a32bf59760e01b8152602081600481855afa908115610618578591611339575b506040519063023c4c9f60e61b8252600482015260c081602481855afa9081156106185785916112b0575b506020810151600381101561129c5760010361088257610dcf608060a08301519201516102cd8634611905565b116108705760055460405163313ce56760e01b815292906001600160a01b0316602084600481845afa90811561070f576004948792611278575b5060a09060405195868092633fabe5a360e21b82525afa801561070f578694879161124e575b50610e3a9042611899565b600654106107e557610e4c84346118a6565b670de0b6b3a7640000810290808204670de0b6b3a7640000149015171561123a5760ff821660120160121161123a57610e8e906104cc60ff84166012016118b9565b60405163d6362e9760e01b8152602081600481885afa801561117f5782918991611205575b501161118a5760405163151a8b2960e21b8152336004820152602081602481885afa90811561117f578891611149575b508181106106bf5750509060046020939287610f0134898633611b00565b604051631d8cf42560e11b8152929891979095839182905afa801561063b57828092918192829161112a575b50610f388934611899565b905af1610f4361164e565b501561067e57836110f9575b610f5b34600354611811565b600355610f72610f6b8834611905565b96346118a6565b90670de0b6b3a7640000820291808304670de0b6b3a764000014901517156110e557889392916104cc60ff610faa93166012016118b9565b6004546001600160a01b031691823b156106465760e4928591604051978896879563e8feeaa960e01b875233600488015273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee602488015260448701528b606487015260018060a01b0316608486015260a485015260c48401525af18015610618576110d2575b506004805460405163a32bf59760e01b81529160209183919082906001600160a01b03165afa9081156106185785916110a0575b50604051923484526020840152604083015260018060a01b0316907f2e4e81439dee0f29bbe94bdb1614d72eac064c09da72ee416aafa9d2a7a1514260603392a46001805580f35b90506020813d6020116110ca575b816110bb6020938361162c565b8101031261060b575138611058565b3d91506110ae565b6110de90949194611618565b9238611024565b634e487b7160e01b89526011600452602489fd5b878080808760018060a01b03600454165af161111361164e565b50610f4f5760405163ba83c1af60e01b8152600490fd5b611143915060203d6020116106b8576106aa818361162c565b38610f2d565b90506020813d602011611177575b816111646020938361162c565b81010312611173575138610ee3565b8780fd5b3d9150611157565b6040513d8a823e3d90fd5b60405163d6362e9760e01b8152879190602081600481895afa9081156109315783916111cf575b6044838360405191637932cc9560e01b835260048301526024820152fd5b90506020813d6020116111fd575b816111ea6020938361162c565b81010312610925576044925051836111b1565b3d91506111dd565b9150506020813d602011611232575b816112216020938361162c565b810103126111735781905138610eb3565b3d9150611214565b634e487b7160e01b87526011600452602487fd5b610e3a955061126c915060a03d60a01161082a57610816818361162c565b50969250509490610e2f565b60a09192506112959060203d6020116108695761085a818361162c565b9190610e09565b634e487b7160e01b86526021600452602486fd5b905060c0813d60c011611331575b816112cb60c0938361162c565b8101031261064657604051906112e0826115e6565b6112e981611804565b8252602081015190600382101561132d5760a0916020840152604081015160408401526060810151606084015260808101516080840152015160a082015238610da2565b8680fd5b3d91506112be565b90506020813d602011611363575b816113546020938361162c565b81010312610646575138610d77565b3d9150611347565b90506020813d60201161139d575b816113866020938361162c565b810103126106465761139790611804565b38610d4d565b3d9150611379565b5080fd5b503461014d578060031936011261014d57602060ff600254166040519015158152f35b503461014d57602036600319011261014d577f6b0695b82961d69699cb7b8438d7eac257041649a2d203c75aa4f54e13d1ecca602060043561140c61168e565b80600655604051908152a180f35b503461014d578060031936011261014d5761143361168e565b60025460ff8116156114735760ff19166002557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a180f35b604051638dfc202b60e01b8152600490fd5b503461014d57604036600319011261014d5761149f6115d0565b336001600160a01b038216036114bb576101499060043561176c565b60405163334bd91960e11b8152600490fd5b503461014d578060031936011261014d576004546040516001600160a01b039091168152602090f35b503461014d57604036600319011261014d576101496004356115166115d0565b908084528360205261152e60016040862001546116c8565b6116ee565b503461014d578060031936011261014d57602060405160128152f35b503461014d57602036600319011261014d57600160406020926004358152808452200154604051908152f35b9050346113a55760203660031901126113a55760043563ffffffff60e01b81168091036109255760209250637965db0b60e01b81149081156115bf575b5015158152f35b6301ffc9a760e01b149050386115b8565b602435906001600160a01b038216820361060b57565b60c0810190811067ffffffffffffffff82111761160257604052565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff811161160257604052565b90601f8019910116810190811067ffffffffffffffff82111761160257604052565b3d15611689573d9067ffffffffffffffff8211611602576040519161167d601f8201601f19166020018461162c565b82523d6000602084013e565b606090565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604081205460ff16156109f05750565b80600052600060205260406000203360005260205260ff60406000205416156109f05750565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054161560001461176757808352826020526040832082845260205260408320600160ff198254161790557f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d339380a4600190565b505090565b9060009180835282602052604083209160018060a01b03169182845260205260ff6040842054166000146117675780835282602052604083208284526020526040832060ff1981541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4600190565b6002600154146117f2576002600155565b604051633ee5aeb560e01b8152600490fd5b5190811515820361060b57565b9190820180921161181e57565b634e487b7160e01b600052601160045260246000fd5b9081602091031261060b575160ff8116810361060b5790565b519069ffffffffffffffffffff8216820361060b57565b908160a091031261060b576118788161184d565b9160208201519160408101519161189660806060840151930161184d565b90565b9190820391821161181e57565b8181029291811591840414171561181e57565b604d811161181e57600a0a90565b81156118d1570490565b634e487b7160e01b600052601260045260246000fd5b60ff600254166118f357565b60405163d93c066560e01b8152600490fd5b6005546040805163313ce56760e01b81526004959490936001600160a01b039360209190851682878a81845afa968715611ab45790899291600098611abf575b5060a090865193848092633fabe5a360e21b82525afa8015611ab457600092600091611a8a575b506119779042611899565b60065410611a7a5790611989916118a6565b93670de0b6b3a764000094858102958187041490151715611a6557875416835192631bf8f3f960e11b84526002811015611a5057602484849381938c8301525afa928315611a465750600092611a16575b50506119e89060ff926118c7565b9116604d8111611a0157611896929350600a0a906118c7565b601184634e487b7160e01b6000525260246000fd5b90809250813d8311611a3f575b611a2d818361162c565b8101031261060b5751816119e86119da565b503d611a23565b513d6000823e3d90fd5b602189634e487b7160e01b6000525260246000fd5b601188634e487b7160e01b6000525260246000fd5b8451634339de0f60e11b81528990fd5b6119779350611aa8915060a03d60a01161082a57610816818361162c565b5094925050929061196c565b85513d6000823e3d90fd5b60a0919850611ada90853d87116108695761085a818361162c565b9790611945565b9081602091031261060b57516001600160a01b038116810361060b5790565b92939160018060a01b03918260045416928060409281845198630977471760e31b8a52166004890152166024870152602086604481875afa958615611c1f57600096611bfe575b5085168015611bef5781906024825180968193638f11740b60e01b835260048301525afa928315611be457600091600094611ba9575b5050611b9d611ba393611b96926103e89384918a6118a6565b04976118a6565b04611905565b91929190565b8194508092503d8311611bdd575b611bc1818361162c565b8101031261060b57815160209092015191611b9d611b96611b7d565b503d611bb7565b50513d6000823e3d90fd5b50505050915090600090600090565b611c1891965060203d6020116106b8576106aa818361162c565b9438611b47565b82513d6000823e3d90fd5b90611c515750805115611c3f57805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580611c84575b611c62575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b15611c5a56fea2646970667358221220a30328a2aa9633f5734cf5821687eef21c81177b4b243096ff4f70a76c858a9364736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d505de0c61271c51c8fdbe377557f73d5bce03d00000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b84190000000000000000000000000000000000000000000000000000000000001554
-----Decoded View---------------
Arg [0] : storage_ (address): 0xD505DE0C61271c51c8fdBE377557F73D5BCe03d0
Arg [1] : priceFeed_ (address): 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419
Arg [2] : priceThreshold_ (uint256): 5460
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000d505de0c61271c51c8fdbe377557f73d5bce03d0
Arg [1] : 0000000000000000000000005f4ec3df9cbd43714fe2740f5e3616155c5b8419
Arg [2] : 0000000000000000000000000000000000000000000000000000000000001554
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.