Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
PreMiningWithMerklClaim
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import {IMerklDistributor} from "./external/IMerklDistributor.sol";
import {PreMining, IERC20} from "./PreMining.sol";
import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
/**
* @title PreMiningWithMerklClaimProxy
* @notice Helps with onchain usability by providing a name for the proxy
*/
contract PreMiningWithMerklClaimProxy is TransparentUpgradeableProxy {
/// @dev Prevent bytecode collisions
string public constant NAME = "PreMiningWithMerklClaimProxy";
constructor(
address logic_,
address admin_,
bytes memory data_
) TransparentUpgradeableProxy(logic_, admin_, data_) {}
}
contract PreMiningWithMerklClaim is PreMining {
/// -----------------------------------------------------------------------
/// Storage variables
/// -----------------------------------------------------------------------
IMerklDistributor public merklDistributor;
/// @dev Gap to provide storage for future variables
uint256[50] private __gap;
event MerklDistributorSet(address indexed oldMerklDistributor, address indexed newMerklDistributor);
/// -----------------------------------------------------------------------
/// Data structures
/// -----------------------------------------------------------------------
struct MerklClaimData {
address[] users;
address[] tokens;
uint256[] amounts;
bytes32[][] proofs;
address[] recipients;
bytes[] datas;
}
/// -----------------------------------------------------------------------
/// Constructor
/// -----------------------------------------------------------------------
constructor() {
_disableInitializers();
}
function initialize(
IERC20 _reward,
address _feeAddress,
uint256 _rewardPerSecond,
uint256 _startTime,
uint256 _endTime,
address _merklDistributor
) external initializer {
__PreMining_init(_reward, _feeAddress, _rewardPerSecond, _startTime, _endTime);
require(_merklDistributor != address(0), "PreMiningWithMerklClaim: merklDistributor is zero address");
merklDistributor = IMerklDistributor(_merklDistributor);
}
/// -----------------------------------------------------------------------
/// Functions
/// -----------------------------------------------------------------------
function setMerklDistributor(address _merklDistributor) external onlyOwner {
require(_merklDistributor != address(0), "PreMiningWithMerklClaim: merklDistributor is zero address");
emit MerklDistributorSet(address(merklDistributor), _merklDistributor);
merklDistributor = IMerklDistributor(_merklDistributor);
}
function claimMerklRewards(
address[] calldata users,
address[] calldata tokens,
uint256[] calldata amounts,
bytes32[][] calldata proofs
) external onlyOwner {
merklDistributor.claim(users, tokens, amounts, proofs);
}
// NOTE: Stack too deep
// function claimMerklRewardsWithRecipient(MerklClaimData calldata claimData) external onlyOwner {
// merklDistributor.claimWithRecipient(
// claimData.users,
// claimData.tokens,
// claimData.amounts,
// claimData.proofs,
// claimData.recipients,
// claimData.datas
// );
// }
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*
* _Available since v4.8.3._
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)
pragma solidity ^0.8.0;
import "../Proxy.sol";
import "./ERC1967Upgrade.sol";
/**
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
* implementation address that can be changed. This address is stored in storage in the location specified by
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
* implementation behind the proxy.
*/
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
* function call, and allows initializing the storage of the proxy like a Solidity constructor.
*/
constructor(address _logic, bytes memory _data) payable {
_upgradeToAndCall(_logic, _data, false);
}
/**
* @dev Returns the current implementation address.
*/
function _implementation() internal view virtual override returns (address impl) {
return ERC1967Upgrade._getImplementation();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeacon.sol";
import "../../interfaces/IERC1967.sol";
import "../../interfaces/draft-IERC1822.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*/
abstract contract ERC1967Upgrade is IERC1967 {
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
Address.isContract(IBeacon(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overridden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/transparent/TransparentUpgradeableProxy.sol)
pragma solidity ^0.8.0;
import "../ERC1967/ERC1967Proxy.sol";
/**
* @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}
* does not implement this interface directly, and some of its functions are implemented by an internal dispatch
* mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not
* include them in the ABI so this interface must be used to interact with it.
*/
interface ITransparentUpgradeableProxy is IERC1967 {
function admin() external view returns (address);
function implementation() external view returns (address);
function changeAdmin(address) external;
function upgradeTo(address) external;
function upgradeToAndCall(address, bytes memory) external payable;
}
/**
* @dev This contract implements a proxy that is upgradeable by an admin.
*
* To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
* clashing], which can potentially be used in an attack, this contract uses the
* https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
* things that go hand in hand:
*
* 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
* that call matches one of the admin functions exposed by the proxy itself.
* 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
* implementation. If the admin tries to call a function on the implementation it will fail with an error that says
* "admin cannot fallback to proxy target".
*
* These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
* the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
* to sudden errors when trying to call a function from the proxy implementation.
*
* Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
* you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
*
* NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not
* inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch
* mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to
* fully implement transparency without decoding reverts caused by selector clashes between the proxy and the
* implementation.
*
* WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler
* will not check that there are no selector conflicts, due to the note above. A selector clash between any new function
* and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could
* render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.
*/
contract TransparentUpgradeableProxy is ERC1967Proxy {
/**
* @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
* optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
*/
constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
_changeAdmin(admin_);
}
/**
* @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
*
* CAUTION: This modifier is deprecated, as it could cause issues if the modified function has arguments, and the
* implementation provides a function with the same selector.
*/
modifier ifAdmin() {
if (msg.sender == _getAdmin()) {
_;
} else {
_fallback();
}
}
/**
* @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior
*/
function _fallback() internal virtual override {
if (msg.sender == _getAdmin()) {
bytes memory ret;
bytes4 selector = msg.sig;
if (selector == ITransparentUpgradeableProxy.upgradeTo.selector) {
ret = _dispatchUpgradeTo();
} else if (selector == ITransparentUpgradeableProxy.upgradeToAndCall.selector) {
ret = _dispatchUpgradeToAndCall();
} else if (selector == ITransparentUpgradeableProxy.changeAdmin.selector) {
ret = _dispatchChangeAdmin();
} else if (selector == ITransparentUpgradeableProxy.admin.selector) {
ret = _dispatchAdmin();
} else if (selector == ITransparentUpgradeableProxy.implementation.selector) {
ret = _dispatchImplementation();
} else {
revert("TransparentUpgradeableProxy: admin cannot fallback to proxy target");
}
assembly {
return(add(ret, 0x20), mload(ret))
}
} else {
super._fallback();
}
}
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function _dispatchAdmin() private returns (bytes memory) {
_requireZeroValue();
address admin = _getAdmin();
return abi.encode(admin);
}
/**
* @dev Returns the current implementation.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function _dispatchImplementation() private returns (bytes memory) {
_requireZeroValue();
address implementation = _implementation();
return abi.encode(implementation);
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _dispatchChangeAdmin() private returns (bytes memory) {
_requireZeroValue();
address newAdmin = abi.decode(msg.data[4:], (address));
_changeAdmin(newAdmin);
return "";
}
/**
* @dev Upgrade the implementation of the proxy.
*/
function _dispatchUpgradeTo() private returns (bytes memory) {
_requireZeroValue();
address newImplementation = abi.decode(msg.data[4:], (address));
_upgradeToAndCall(newImplementation, bytes(""), false);
return "";
}
/**
* @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
* by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
* proxied contract.
*/
function _dispatchUpgradeToAndCall() private returns (bytes memory) {
(address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));
_upgradeToAndCall(newImplementation, data, true);
return "";
}
/**
* @dev Returns the current admin.
*
* CAUTION: This function is deprecated. Use {ERC1967Upgrade-_getAdmin} instead.
*/
function _admin() internal view virtual returns (address) {
return _getAdmin();
}
/**
* @dev To keep this contract fully transparent, all `ifAdmin` functions must be payable. This helper is here to
* emulate some proxy functions being non-payable while still allowing value to pass through.
*/
function _requireZeroValue() private {
require(msg.value == 0);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== 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 v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @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);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @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.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* 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.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
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.
*
* _Available since v3.4._
*/
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.
*
* _Available since v3.4._
*/
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.
*
* _Available since v3.4._
*/
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.
*
* _Available since v3.4._
*/
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 addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
* _Available since v4.9 for `string`, `bytes`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
/**
* @title IMerklDistributor
* @author Angle Labs. Inc
* @notice Interface for the MerklDistributor contract
* https://app.merkl.xyz/status
*/
interface IMerklDistributor {
function claim(address[] calldata users, address[] calldata tokens, uint256[] calldata amounts, bytes32[][] calldata proofs) external;
function claimWithRecipient(address[] calldata users, address[] calldata tokens, uint256[] calldata amounts, bytes32[][] calldata proofs, address[] calldata recipients, bytes[] memory datas) external;
function getMerkleRoot() external view returns (bytes32);
function getEpochDuration() external view returns (uint32);
function disputeTree(string memory reason) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IDibs {
function reward(address user,bytes32 parentCode,
uint256 totalFees,uint256 totalVolume,
address token) external returns(uint256 referralFee);
function findTotalRewardFor(address _user, uint _totalFees) external view returns(uint256 _referralFeeAmount);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IERC20 {
function totalSupply() external view returns (uint256);
function transfer(address recipient, uint amount) external returns (bool);
function decimals() external view returns (uint8);
function symbol() external view returns (string memory);
function balanceOf(address) external view returns (uint);
function transferFrom(address sender, address recipient, uint amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IPair {
function metadata() external view returns (uint dec0, uint dec1, uint r0, uint r1, bool st, address t0, address t1);
function claimFees() external returns (uint, uint);
function tokens() external view returns (address, address);
function token0() external view returns (address);
function token1() external view returns (address);
function fees() external view returns (address);
function transferFrom(address src, address dst, uint amount) external returns (bool);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function burn(address to) external returns (uint amount0, uint amount1);
function mint(address to) external returns (uint liquidity);
function getReserves() external view returns (uint _reserve0, uint _reserve1, uint _blockTimestampLast);
function getAmountOut(uint amountIn, address tokenIn) external view returns (uint);
function name() external view returns(string memory);
function symbol() external view returns(string memory);
function totalSupply() external view returns (uint);
function decimals() external view returns (uint8);
function claimable0(address _user) external view returns (uint);
function claimable1(address _user) external view returns (uint);
function isStable() external view returns(bool);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IPairCallee {
function hook(address sender, uint amount0, uint amount1, bytes calldata data) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IPairFactory {
function allPairsLength() external view returns (uint);
function isPair(address pair) external view returns (bool);
function getFee(bool) external view returns (uint);
function allPairs(uint index) external view returns (address);
function feeManager() external view returns (address);
function pairCodeHash() external pure returns (bytes32);
function getPair(address tokenA, address token, bool stable) external view returns (address);
function createPair(address tokenA, address tokenB, bool stable) external returns (address pair);
function getInitializable() external view returns (address, address, bool);
function MAX_REFERRAL_FEE() external view returns(uint);
function dibs() external view returns(address);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
library Math {
function max(uint a, uint b) internal pure returns (uint) {
return a >= b ? a : b;
}
function min(uint a, uint b) internal pure returns (uint) {
return a < b ? a : b;
}
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
function cbrt(uint256 n) internal pure returns (uint256) { unchecked {
uint256 x = 0;
for (uint256 y = 1 << 255; y > 0; y >>= 3) {
x <<= 1;
uint256 z = 3 * x * (x + 1) + 1;
if (n / y >= z) {
n -= y * z;
x += 1;
}
}
return x;
}}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'Math: Sub-underflow');
}
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import "./libraries/Math.sol";
import "./interfaces/IERC20.sol";
import "./interfaces/IPair.sol";
import "./interfaces/IDibs.sol";
import "./interfaces/IPairCallee.sol";
import "./interfaces/IPairFactory.sol";
import "./PairFees.sol";
/// @notice The base pair of pools, either stable or volatile
/// @dev 2024-10 immutable declaration was removed from various state variables to allow for deterministic deployment
contract Pair is IPair {
string public name;
string public symbol;
uint8 public constant decimals = 18;
uint256 private fee = 0;
// Used to denote stable or volatile pair, not immutable since construction happens in the initialize method for CREATE2 deterministic addresses
bool public stable;
uint public totalSupply = 0;
mapping(address => mapping (address => uint)) public allowance;
mapping(address => uint) public balanceOf;
bytes32 internal DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 internal constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
uint internal constant MINIMUM_LIQUIDITY = 10**3;
address public token0;
address public token1;
address public fees;
address factory;
// Structure to capture time period obervations every 30 minutes, used for local oracles
struct Observation {
uint timestamp;
uint reserve0Cumulative;
uint reserve1Cumulative;
}
// Capture oracle reading every 30 minutes
uint constant periodSize = 1800;
Observation[] public observations;
uint internal decimals0;
uint internal decimals1;
uint public reserve0;
uint public reserve1;
uint public blockTimestampLast;
uint public reserve0CumulativeLast;
uint public reserve1CumulativeLast;
// index0 and index1 are used to accumulate fees, this is split out from normal trades to keep the swap "clean"
// this further allows LP holders to easily claim fees for tokens they have/staked
uint public index0 = 0;
uint public index1 = 0;
// position assigned to each LP to track their current index0 & index1 vs the global position
mapping(address => uint) public supplyIndex0;
mapping(address => uint) public supplyIndex1;
// tracks the amount of unclaimed, but claimable tokens off of fees for token0 and token1
mapping(address => uint) public claimable0;
mapping(address => uint) public claimable1;
event Fees(address indexed sender, uint amount0, uint amount1);
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint reserve0, uint reserve1);
event Claim(address indexed sender, address indexed recipient, uint amount0, uint amount1);
event Transfer(address indexed from, address indexed to, uint amount);
event Approval(address indexed owner, address indexed spender, uint amount);
constructor() {
factory = msg.sender;
(address _token0, address _token1, bool _stable) = IPairFactory(msg.sender).getInitializable();
(token0, token1, stable) = (_token0, _token1, _stable);
fees = address(new PairFees(_token0, _token1));
if (_stable) {
name = string(abi.encodePacked("StableV1 AMM - ", IERC20(_token0).symbol(), "/", IERC20(_token1).symbol()));
symbol = string(abi.encodePacked("sAMM-", IERC20(_token0).symbol(), "/", IERC20(_token1).symbol()));
} else {
name = string(abi.encodePacked("VolatileV1 AMM - ", IERC20(_token0).symbol(), "/", IERC20(_token1).symbol()));
symbol = string(abi.encodePacked("vAMM-", IERC20(_token0).symbol(), "/", IERC20(_token1).symbol()));
}
decimals0 = 10**IERC20(_token0).decimals();
decimals1 = 10**IERC20(_token1).decimals();
observations.push(Observation(block.timestamp, 0, 0));
}
// simple re-entrancy check
uint internal _unlocked = 1;
modifier lock() {
require(_unlocked == 1);
_unlocked = 2;
_;
_unlocked = 1;
}
function observationLength() external view returns (uint) {
return observations.length;
}
function lastObservation() public view returns (Observation memory) {
return observations[observations.length-1];
}
function metadata() external view returns (uint dec0, uint dec1, uint r0, uint r1, bool st, address t0, address t1) {
return (decimals0, decimals1, reserve0, reserve1, stable, token0, token1);
}
function tokens() external view returns (address, address) {
return (token0, token1);
}
function isStable() external view returns(bool) {
return stable;
}
function setFee(uint256 _fee) external {
require(msg.sender == IPairFactory(factory).feeManager(), 'Pair: NOT_MANAGER');
fee = _fee;
}
// claim accumulated but unclaimed fees (viewable via claimable0 and claimable1)
function claimFees() external returns (uint claimed0, uint claimed1) {
_updateFor(msg.sender);
claimed0 = claimable0[msg.sender];
claimed1 = claimable1[msg.sender];
if (claimed0 > 0 || claimed1 > 0) {
claimable0[msg.sender] = 0;
claimable1[msg.sender] = 0;
PairFees(fees).claimFeesFor(msg.sender, claimed0, claimed1);
emit Claim(msg.sender, msg.sender, claimed0, claimed1);
}
}
// Accrue fees on token0
function _update0(uint amount) internal {
_safeTransfer(token0, fees, amount); // transfer the fees out to PairFees
uint256 _ratio = amount * 1e18 / totalSupply; // 1e18 adjustment is removed during claim
if (_ratio > 0) {
index0 += _ratio;
}
emit Fees(msg.sender, amount, 0);
}
// Accrue fees on token1
function _update1(uint amount) internal {
_safeTransfer(token1, fees, amount); // transfer the fees out to PairFees
uint256 _ratio = amount * 1e18 / totalSupply;
if (_ratio > 0) {
index1 += _ratio;
}
emit Fees(msg.sender, 0, amount);
}
// this function MUST be called on any balance changes, otherwise can be used to infinitely claim fees
// Fees are segregated from core funds, so fees can never put liquidity at risk
function _updateFor(address recipient) internal {
uint _supplied = balanceOf[recipient]; // get LP balance of `recipient`
if (_supplied > 0) {
uint _supplyIndex0 = supplyIndex0[recipient]; // get last adjusted index0 for recipient
uint _supplyIndex1 = supplyIndex1[recipient];
uint _index0 = index0; // get global index0 for accumulated fees
uint _index1 = index1;
supplyIndex0[recipient] = _index0; // update user current position to global position
supplyIndex1[recipient] = _index1;
uint _delta0 = _index0 - _supplyIndex0; // see if there is any difference that need to be accrued
uint _delta1 = _index1 - _supplyIndex1;
if (_delta0 > 0) {
uint _share = _supplied * _delta0 / 1e18; // add accrued difference for each supplied token
claimable0[recipient] += _share;
}
if (_delta1 > 0) {
uint _share = _supplied * _delta1 / 1e18;
claimable1[recipient] += _share;
}
} else {
supplyIndex0[recipient] = index0; // new users are set to the default global state
supplyIndex1[recipient] = index1;
}
}
function getReserves() public view returns (uint _reserve0, uint _reserve1, uint _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint _reserve0, uint _reserve1) internal {
uint blockTimestamp = block.timestamp;
uint timeElapsed;
unchecked {
timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
reserve0CumulativeLast += _reserve0 * timeElapsed;
reserve1CumulativeLast += _reserve1 * timeElapsed;
}
}
Observation memory _point = lastObservation();
timeElapsed = blockTimestamp - _point.timestamp; // compare the last observation with current timestamp, if greater than 30 minutes, record a new event
if (timeElapsed > periodSize) {
observations.push(Observation(blockTimestamp, reserve0CumulativeLast, reserve1CumulativeLast));
}
reserve0 = balance0;
reserve1 = balance1;
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// produces the cumulative price using counterfactuals to save gas and avoid a call to sync.
function currentCumulativePrices() public view returns (uint reserve0Cumulative, uint reserve1Cumulative, uint blockTimestamp) {
blockTimestamp = block.timestamp;
reserve0Cumulative = reserve0CumulativeLast;
reserve1Cumulative = reserve1CumulativeLast;
// if time has elapsed since the last update on the pair, mock the accumulated price values
(uint _reserve0, uint _reserve1, uint _blockTimestampLast) = getReserves();
if (_blockTimestampLast != blockTimestamp) {
unchecked {
// subtraction overflow is desired
uint timeElapsed = blockTimestamp - _blockTimestampLast;
reserve0Cumulative += _reserve0 * timeElapsed;
reserve1Cumulative += _reserve1 * timeElapsed;
}
}
}
// gives the current twap price measured from amountIn * tokenIn gives amountOut
function current(address tokenIn, uint amountIn) external view returns (uint amountOut) {
Observation memory _observation = lastObservation();
(uint reserve0Cumulative, uint reserve1Cumulative,) = currentCumulativePrices();
if (block.timestamp == _observation.timestamp) {
_observation = observations[observations.length-2];
}
uint timeElapsed = block.timestamp - _observation.timestamp;
uint _reserve0 = (reserve0Cumulative - _observation.reserve0Cumulative) / timeElapsed;
uint _reserve1 = (reserve1Cumulative - _observation.reserve1Cumulative) / timeElapsed;
amountOut = _getAmountOut(amountIn, tokenIn, _reserve0, _reserve1);
}
// as per `current`, however allows user configured granularity, up to the full window size
function quote(address tokenIn, uint amountIn, uint granularity) external view returns (uint amountOut) {
uint [] memory _prices = sample(tokenIn, amountIn, granularity, 1);
uint priceAverageCumulative;
for (uint i = 0; i < _prices.length; i++) {
priceAverageCumulative += _prices[i];
}
return priceAverageCumulative / granularity;
}
// returns a memory set of twap prices
function prices(address tokenIn, uint amountIn, uint points) external view returns (uint[] memory) {
return sample(tokenIn, amountIn, points, 1);
}
function sample(address tokenIn, uint amountIn, uint points, uint window) public view returns (uint[] memory) {
uint[] memory _prices = new uint[](points);
uint length = observations.length-1;
uint i = length - (points * window);
uint nextIndex = 0;
uint index = 0;
for (; i < length; i+=window) {
nextIndex = i + window;
uint timeElapsed = observations[nextIndex].timestamp - observations[i].timestamp;
uint _reserve0 = (observations[nextIndex].reserve0Cumulative - observations[i].reserve0Cumulative) / timeElapsed;
uint _reserve1 = (observations[nextIndex].reserve1Cumulative - observations[i].reserve1Cumulative) / timeElapsed;
_prices[index] = _getAmountOut(amountIn, tokenIn, _reserve0, _reserve1);
// index < length; length cannot overflow
unchecked {
index = index + 1;
}
}
return _prices;
}
// this low-level function should be called by addLiquidity functions in Router.sol, which performs important safety checks
// standard uniswap v2 implementation
function mint(address to) external lock returns (uint liquidity) {
(uint _reserve0, uint _reserve1) = (reserve0, reserve1);
uint _balance0 = IERC20(token0).balanceOf(address(this));
uint _balance1 = IERC20(token1).balanceOf(address(this));
uint _amount0 = _balance0 - _reserve0;
uint _amount1 = _balance1 - _reserve1;
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(_amount0 * _amount1) - MINIMUM_LIQUIDITY;
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(_amount0 * _totalSupply / _reserve0, _amount1 * _totalSupply / _reserve1);
}
require(liquidity > 0, 'ILM'); // Pair: INSUFFICIENT_LIQUIDITY_MINTED
_mint(to, liquidity);
_update(_balance0, _balance1, _reserve0, _reserve1);
emit Mint(msg.sender, _amount0, _amount1);
}
// this low-level function should be called from a contract which performs important safety checks
// standard uniswap v2 implementation
function burn(address to) external lock returns (uint amount0, uint amount1) {
(uint _reserve0, uint _reserve1) = (reserve0, reserve1);
(address _token0, address _token1) = (token0, token1);
uint _balance0 = IERC20(_token0).balanceOf(address(this));
uint _balance1 = IERC20(_token1).balanceOf(address(this));
uint _liquidity = balanceOf[address(this)];
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = _liquidity * _balance0 / _totalSupply; // using balances ensures pro-rata distribution
amount1 = _liquidity * _balance1 / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'ILB'); // Pair: INSUFFICIENT_LIQUIDITY_BURNED
_burn(address(this), _liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
_balance0 = IERC20(_token0).balanceOf(address(this));
_balance1 = IERC20(_token1).balanceOf(address(this));
_update(_balance0, _balance1, _reserve0, _reserve1);
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
require(amount0Out > 0 || amount1Out > 0, 'IOA'); // Pair: INSUFFICIENT_OUTPUT_AMOUNT
(uint _reserve0, uint _reserve1) = (reserve0, reserve1);
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'IL'); // Pair: INSUFFICIENT_LIQUIDITY
uint _balance0;
uint _balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
(address _token0, address _token1) = (token0, token1);
require(to != _token0 && to != _token1, 'IT'); // Pair: INVALID_TO
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IPairCallee(to).hook(msg.sender, amount0Out, amount1Out, data); // callback, used for flash loans
_balance0 = IERC20(_token0).balanceOf(address(this));
_balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = _balance0 > _reserve0 - amount0Out ? _balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = _balance1 > _reserve1 - amount1Out ? _balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'IIA'); // Pair: INSUFFICIENT_INPUT_AMOUNT
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
(address _token0, address _token1) = (token0, token1);
if (amount0In > 0) _update0(amount0In * getFee() / 100000); // accrue fees for token0 and move them out of pool
if (amount1In > 0) _update1(amount1In * getFee() / 100000); // accrue fees for token1 and move them out of pool
_balance0 = IERC20(_token0).balanceOf(address(this)); // since we removed tokens, we need to reconfirm balances, can also simply use previous balance - amountIn/ 10000, but doing balanceOf again as safety check
_balance1 = IERC20(_token1).balanceOf(address(this));
// The curve, either x3y+y3x for stable pools, or x*y for volatile pools
require(_k(_balance0, _balance1) >= _k(_reserve0, _reserve1), 'K'); // Pair: K
}
_update(_balance0, _balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external lock {
(address _token0, address _token1) = (token0, token1);
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)) - (reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)) - (reserve1));
}
// force reserves to match balances
function sync() external lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
function _f(uint x0, uint y) internal pure returns (uint) {
return x0*(y*y/1e18*y/1e18)/1e18+(x0*x0/1e18*x0/1e18)*y/1e18;
}
function _d(uint x0, uint y) internal pure returns (uint) {
return 3*x0*(y*y/1e18)/1e18+(x0*x0/1e18*x0/1e18);
}
function _get_y(uint x0, uint xy, uint y) internal pure returns (uint) {
// Iterate to find the value of y that satisfies the equation _f(x0, y) = xy
for (uint i = 0; i < 255; i++) {
uint y_prev = y;
uint k = _f(x0, y);
if (k < xy) {
// Calculate the change in y based on the difference between k and xy
uint dy = ((xy - k) * 1e18) / _d(x0, y);
y = y + dy;
} else {
// Calculate the change in y based on the difference between k and xy
uint dy = ((k - xy) * 1e18) / _d(x0, y);
y = y - dy;
}
// Check if the change in y is within a tolerance of 1
if (y > y_prev) {
if (y - y_prev <= 1) {
return y;
}
} else {
if (y_prev - y <= 1) {
return y;
}
}
}
return y;
}
function getFee() public view returns(uint) {
return fee != 0 ? fee : IPairFactory(factory).getFee(stable);
}
function getAmountOut(uint amountIn, address tokenIn) external view returns (uint) {
(uint _reserve0, uint _reserve1) = (reserve0, reserve1);
amountIn -= amountIn * getFee() / 100000; // remove fee from amount received
return _getAmountOut(amountIn, tokenIn, _reserve0, _reserve1);
}
function _getAmountOut(uint amountIn, address tokenIn, uint _reserve0, uint _reserve1) internal view returns (uint) {
if (stable) {
// Calculate the product of reserves
uint xy = _k(_reserve0, _reserve1);
// Adjust the reserves based on decimals
_reserve0 = (_reserve0 * 1e18) / decimals0;
_reserve1 = (_reserve1 * 1e18) / decimals1;
// Determine the order of reserves based on the token being swapped
(uint reserveA, uint reserveB) = tokenIn == token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0);
// Adjust the input amount based on decimals
amountIn = tokenIn == token0 ? (amountIn * 1e18) / decimals0 : (amountIn * 1e18) / decimals1;
// Calculate the output amount using the formula y = reserveB - _get_y(amountIn+reserveA, xy, reserveB)
uint y = reserveB - _get_y(amountIn + reserveA, xy, reserveB);
// Adjust the output amount based on decimals and return it
return (y * (tokenIn == token0 ? decimals1 : decimals0)) / 1e18;
} else {
// Determine the order of reserves based on the token being swapped
(uint reserveA, uint reserveB) = tokenIn == token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0);
// Calculate the output amount using the formula amountIn * reserveB / (reserveA + amountIn)
return (amountIn * reserveB) / (reserveA + amountIn);
}
}
function _k(uint x, uint y) internal view returns (uint) {
// Check if the pool is stable or volatile
if (stable) {
// Adjust the reserves based on decimals
uint _x = (x * 1e18) / decimals0;
uint _y = (y * 1e18) / decimals1;
// Calculate the product of adjusted reserves
uint _a = (_x * _y) / 1e18;
// Calculate the sum of squares of adjusted reserves
uint _b = ((_x * _x) / 1e18 + (_y * _y) / 1e18);
// Calculate the product of adjusted reserves and sum of squares of adjusted reserves
return (_a * _b) / 1e18; // x3y+y3x >= k
} else {
// Calculate the product of reserves
return x * y; // xy >= k
}
}
function _mint(address dst, uint amount) internal {
_updateFor(dst); // balances must be updated on mint/burn/transfer
totalSupply += amount;
balanceOf[dst] += amount;
emit Transfer(address(0), dst, amount);
}
function _burn(address dst, uint amount) internal {
_updateFor(dst);
totalSupply -= amount;
balanceOf[dst] -= amount;
emit Transfer(dst, address(0), amount);
}
function approve(address spender, uint amount) external returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'Pair: EXPIRED');
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
block.chainid,
address(this)
)
);
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'Pair: INVALID_SIGNATURE');
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function transfer(address dst, uint amount) external returns (bool) {
_transferTokens(msg.sender, dst, amount);
return true;
}
function transferFrom(address src, address dst, uint amount) external returns (bool) {
address spender = msg.sender;
uint spenderAllowance = allowance[src][spender];
if (spender != src && spenderAllowance != type(uint).max) {
uint newAllowance = spenderAllowance - amount;
allowance[src][spender] = newAllowance;
emit Approval(src, spender, newAllowance);
}
_transferTokens(src, dst, amount);
return true;
}
function _transferTokens(address src, address dst, uint amount) internal {
_updateFor(src); // update fee position for src
_updateFor(dst); // update fee position for dst
balanceOf[src] -= amount;
balanceOf[dst] += amount;
emit Transfer(src, dst, amount);
}
function _safeTransfer(address token,address to,uint256 value) internal {
require(token.code.length > 0);
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))));
}
function _safeApprove(address token,address spender,uint256 value) internal {
require(token.code.length > 0);
require((value == 0) || (IERC20(token).allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, spender, value));
require(success && (data.length == 0 || abi.decode(data, (bool))));
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import './interfaces/IERC20.sol';
// Pair Fees contract is used as a 1:1 pair relationship to split out fees, this ensures that the curve does not need to be modified for LP shares
contract PairFees {
address internal immutable pair; // The pair it is bonded to
address internal immutable token0; // token0 of pair, saved localy and statically for gas optimization
address internal immutable token1; // Token1 of pair, saved localy and statically for gas optimization
uint256 public toStake0;
uint256 public toStake1;
constructor(address _token0, address _token1) {
pair = msg.sender;
token0 = _token0;
token1 = _token1;
}
function _safeTransfer(address token,address to,uint256 value) internal {
require(token.code.length > 0);
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))));
}
// Allow the pair to transfer fees to users
function claimFeesFor(address recipient, uint amount0, uint amount1) external {
require(msg.sender == pair);
if (amount0 > 0) _safeTransfer(token0, recipient, amount0);
if (amount1 > 0) _safeTransfer(token1, recipient, amount1);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import {IPair} from "./Pair.sol";
// Have fun reading it. Hopefully it's bug-free. God bless.
contract PreMining is OwnableUpgradeable, ReentrancyGuardUpgradeable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
uint256 pendingReward; // Undistributed rewards.
//
// We do some fancy math here. Basically, any point in time, the amount of rewards
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accRewardPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws tokens to a pool. Here's what happens:
// 1. The pool's `accRewardPerShare` (and `lastRewardTime`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 stakeToken; // Address of stake token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. Reward to distribute per block.
uint256 totalStaked; // Amount of tokens staked in given pool
uint256 lastRewardTime; // Last timestamp rewards distribution occurs.
uint256 accRewardPerShare; // Accumulated rewards per share, times 1e30. See below.
uint16 depositFeeBP; // Deposit fee in basis points
}
/// -----------------------------------------------------------------------
/// State variables
/// -----------------------------------------------------------------------
// Max emission rate
uint256 public constant MAX_EMISSION_RATE = 50 ether;
// The reward TOKEN!
IERC20 public reward;
// Reward tokens distributed per second.
uint256 public rewardPerSecond;
// Deposit Fee address
address public feeAddress;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes tokens.
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint;
// The timestamp when rewards start.
uint256 public startTime;
// The timestamp when rewards end.
uint256 public endTime;
// Are rewards harvestable.
bool public harvestEnable = false;
// Keep track of number of reward tokens paid to find remaining reward balance
uint256 public totalRewardsAllocated = 0;
// Keep track of pool existence
mapping(IERC20 => bool) public poolExistence;
/// @dev Gap to provide storage for future variables
uint256[50] private __gap;
/// -----------------------------------------------------------------------
/// Events
/// -----------------------------------------------------------------------
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
);
event SetFeeAddress(address indexed user, address indexed newAddress);
event SetDevAddress(address indexed user, address indexed newAddress);
event UpdateEmissionRate(address indexed user, uint256 rewardPerSecond);
event UpdateDevFee(address indexed user, uint256 newFee);
event SetStartTime(address indexed user, uint256 startTime);
event SetEndTime(address indexed user, uint256 endTime);
event ClaimFees(address indexed user, uint256 indexed pid, uint256 amount0, uint256 amount1);
event HarvestEnabled(address indexed user);
event SweepToken(IERC20 indexed token, uint256 amount, address to);
event LogPoolAddition(
uint256 indexed pid,
uint256 allocPoint,
IERC20 indexed stakeToken,
uint16 depositFee
);
event LogSetPool(
uint256 indexed pid,
uint256 allocPoint,
uint16 depositFee
);
event LogUpdatePool(
uint256 indexed pid,
uint256 lastRewardTime,
uint256 stakeSupply,
uint256 accRewardPerShare
);
/// -----------------------------------------------------------------------
/// Constructor
/// -----------------------------------------------------------------------
constructor() {
_disableInitializers();
}
function initialize(
IERC20 _reward,
address _feeAddress,
uint256 _rewardPerSecond,
uint256 _startTime,
uint256 _endTime
) external initializer {
__PreMining_init(_reward, _feeAddress, _rewardPerSecond, _startTime, _endTime);
}
function __PreMining_init(
IERC20 _reward,
address _feeAddress,
uint256 _rewardPerSecond,
uint256 _startTime,
uint256 _endTime
) internal onlyInitializing {
__Ownable_init();
__ReentrancyGuard_init();
reward = _reward;
feeAddress = _feeAddress;
rewardPerSecond = _rewardPerSecond;
startTime = _startTime;
endTime = _endTime;
}
/// -----------------------------------------------------------------------
/// Functions
/// -----------------------------------------------------------------------
modifier nonDuplicated(IERC20 _stakeToken) {
require(
poolExistence[_stakeToken] == false,
"nonDuplicated: duplicated"
);
_;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new token to the pool. Can only be called by the owner.
function add(
uint256 _allocPoint,
IERC20 _stakeToken,
uint16 _depositFeeBP,
bool _withUpdate
) public onlyOwner nonDuplicated(_stakeToken) {
require(_depositFeeBP <= 1000, "add: invalid deposit fee basis points");
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardTime = block.timestamp > startTime
? block.timestamp
: startTime;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolExistence[_stakeToken] = true;
poolInfo.push(
PoolInfo({
stakeToken: _stakeToken,
allocPoint: _allocPoint,
lastRewardTime: lastRewardTime,
accRewardPerShare: 0,
totalStaked: 0,
depositFeeBP: _depositFeeBP
})
);
emit LogPoolAddition(
poolInfo.length.sub(1),
_allocPoint,
_stakeToken,
_depositFeeBP
);
}
// Update the given pool's allocation point and deposit fee. Can only be called by the owner.
function set(
uint256 _pid,
uint256 _allocPoint,
uint16 _depositFeeBP,
bool _withUpdate
) public onlyOwner {
require(_depositFeeBP <= 1000, "set: invalid deposit fee basis points");
if (_withUpdate) {
massUpdatePools();
} else {
updatePool(_pid);
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(
_allocPoint
);
poolInfo[_pid].allocPoint = _allocPoint;
poolInfo[_pid].depositFeeBP = _depositFeeBP;
emit LogSetPool(_pid, _allocPoint, _depositFeeBP);
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to)
public
view
returns (uint256)
{
if (_to <= endTime) {
return _to - _from;
} else if (_from >= endTime) {
return 0;
} else {
return endTime - _from;
}
}
// View function to see pending rewards on frontend.
function pendingRewards(uint256 _pid, address _user)
external
view
returns (uint256 pending)
{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accRewardPerShare = pool.accRewardPerShare;
uint256 stakeSupply = pool.totalStaked;
if (block.timestamp > pool.lastRewardTime && stakeSupply != 0) {
uint256 multiplier = getMultiplier(
pool.lastRewardTime,
block.timestamp
);
uint256 tokenReward = (multiplier *
rewardPerSecond *
pool.allocPoint) / totalAllocPoint;
accRewardPerShare =
accRewardPerShare +
((tokenReward * 1e30) / stakeSupply);
}
pending =
((user.amount * accRewardPerShare) /
1e30 -
user.rewardDebt) + user.pendingReward;
}
// Update reward variables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.timestamp <= pool.lastRewardTime) {
return;
}
uint256 stakeSupply = pool.totalStaked;
if (stakeSupply == 0 || pool.allocPoint == 0) {
pool.lastRewardTime = block.timestamp;
return;
}
uint256 multiplier = getMultiplier(
pool.lastRewardTime,
block.timestamp
);
uint256 totalRewards = multiplier
.mul(rewardPerSecond)
.mul(pool.allocPoint)
.div(totalAllocPoint);
if (totalRewards == 0) return;
totalRewardsAllocated += totalRewards;
pool.accRewardPerShare = pool.accRewardPerShare.add(
totalRewards.mul(1e30).div(stakeSupply)
);
pool.lastRewardTime = block.timestamp;
emit LogUpdatePool(
_pid,
pool.lastRewardTime,
stakeSupply,
pool.accRewardPerShare
);
}
// Deposit tokens to PreMining for reward allocation.
function deposit(uint256 _pid, uint256 _amount)
external
nonReentrant
{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 finalDepositAmount;
updatePool(_pid);
if (user.amount > 0) {
_harvest(_pid, msg.sender);
}
if (_amount > 0) {
// Prefetch balance to account for transfer fees
uint256 preStakeBalance = pool.stakeToken.balanceOf(address(this));
pool.stakeToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
finalDepositAmount =
pool.stakeToken.balanceOf(address(this)) -
preStakeBalance;
if (pool.depositFeeBP > 0) {
uint256 depositFee = finalDepositAmount
.mul(pool.depositFeeBP)
.div(10000);
pool.stakeToken.safeTransfer(feeAddress, depositFee);
finalDepositAmount = finalDepositAmount.sub(depositFee);
}
user.amount = user.amount.add(finalDepositAmount);
pool.totalStaked = pool.totalStaked.add(finalDepositAmount);
}
user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e30);
emit Deposit(msg.sender, _pid, finalDepositAmount);
}
// Withdraw tokens from PreMining.
function withdraw(uint256 _pid, uint256 _amount)
external
nonReentrant
{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
_harvest(_pid, msg.sender);
if (_amount > 0) {
user.amount = user.amount.sub(_amount);
pool.totalStaked = pool.totalStaked.sub(_amount);
pool.stakeToken.safeTransfer(address(msg.sender), _amount);
}
user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e30);
emit Withdraw(msg.sender, _pid, _amount);
}
function _harvest(uint _pid, address _user) internal {
UserInfo storage user = userInfo[_pid][_user];
uint256 userPendingReward = user.pendingReward;
uint256 pending = ((user.amount * poolInfo[_pid].accRewardPerShare) /
1e30 -
user.rewardDebt) + userPendingReward;
if (harvestEnable) {
if (pending > 0) {
uint256 rewardBal = rewardBalance();
if (pending > rewardBal) {
user.pendingReward = pending - rewardBal;
_safeRewardTransfer(_user, rewardBal);
} else {
if(userPendingReward != 0) { user.pendingReward = 0; }
_safeRewardTransfer(_user, pending);
}
}
} else {
user.pendingReward = pending;
}
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) external nonReentrant {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 amount = user.amount;
user.amount = 0;
user.rewardDebt = 0;
user.pendingReward = 0;
pool.totalStaked = pool.totalStaked.sub(amount);
pool.stakeToken.safeTransfer(address(msg.sender), amount);
emit EmergencyWithdraw(msg.sender, _pid, amount);
}
/// Obtain the reward balance of this contract
/// @return wei balance of contract
function rewardBalance() public view returns (uint256) {
return reward.balanceOf(address(this));
}
// Safe reward transfer function, just in case if rounding error causes pool to not have enough rewards.
function _safeRewardTransfer(address _to, uint256 _amount) internal {
uint256 rewardBal = reward.balanceOf(address(this));
bool transferSuccess = false;
if (_amount > rewardBal) {
transferSuccess = reward.transfer(_to, rewardBal);
} else {
transferSuccess = reward.transfer(_to, _amount);
}
require(transferSuccess, "safeRewardTransfer: transfer failed");
}
/// -----------------------------------------------------------------------
///
/// onlyOwner functions
///
/// -----------------------------------------------------------------------
/// @param _startTime The block to start mining
/// @notice can only be changed if mining has not started already
function setStartTime(uint256 _startTime) external onlyOwner {
require(startTime > block.timestamp, "Mining started");
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
PoolInfo storage pool = poolInfo[pid];
pool.lastRewardTime = _startTime;
}
startTime = _startTime;
emit SetStartTime(msg.sender, _startTime);
}
/// @param _endTime The block to end mining
/// @notice can only be changed for future endTime
function setEndTime(uint256 _endTime) external onlyOwner {
require(_endTime > endTime, "End Time cannot be before current one");
endTime = _endTime;
emit SetEndTime(msg.sender, _endTime);
}
/// @param _pid The block to end mining
/// @notice can only be changed for future endTime
function claimFees(uint256 _pid) external onlyOwner {
PoolInfo memory pool = poolInfo[_pid];
(uint256 amount0, uint256 amount1) = IPair(address(pool.stakeToken)).claimFees();
address token0 = IPair(address(pool.stakeToken)).token0();
address token1 = IPair(address(pool.stakeToken)).token1();
if (amount0 > 0) {
IERC20(token0).safeTransfer(feeAddress, amount0);
}
if (amount1 > 0) {
IERC20(token1).safeTransfer(feeAddress, amount1);
}
emit ClaimFees(msg.sender, _pid, amount0, amount1);
}
function setFeeAddress(address _feeAddress) external {
require(msg.sender == feeAddress, "setFeeAddress: FORBIDDEN");
feeAddress = _feeAddress;
emit SetFeeAddress(msg.sender, _feeAddress);
}
function _updateEmissionRate(uint256 _rewardPerSecond) internal {
require(
_rewardPerSecond <= MAX_EMISSION_RATE,
"Updated emissions are more than maximum rate"
);
rewardPerSecond = _rewardPerSecond;
emit UpdateEmissionRate(msg.sender, _rewardPerSecond);
}
function updateEmissionRate(uint256 _rewardPerSecond) external onlyOwner {
_updateEmissionRate(_rewardPerSecond);
massUpdatePools();
}
function enableHarvest() external onlyOwner {
harvestEnable = true;
emit HarvestEnabled(msg.sender);
}
/// @notice Allows owner to sweep any ERC20 tokens accidentally sent to this contract
/// @dev Cannot sweep tokens that are used as stake tokens in any pool to prevent theft
/// @dev If requested amount is greater than balance, will transfer full balance instead
/// @param _token The ERC20 token contract address to sweep
/// @param _amount The amount of tokens to sweep, capped at contract balance
/// @param _to The address to send the swept tokens to
function sweepToken(IERC20 _token, uint256 _amount, address _to) external onlyOwner {
for(uint256 pid = 0; pid < poolInfo.length; pid++) {
require(poolInfo[pid].stakeToken != _token, "Cannot sweep stake token");
}
uint256 balance = _token.balanceOf(address(this));
_amount = _amount > balance ? balance : _amount;
_token.safeTransfer(_to, _amount);
emit SweepToken(_token, _amount, _to);
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"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":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"ClaimFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"HarvestEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"allocPoint","type":"uint256"},{"indexed":true,"internalType":"contract IERC20","name":"stakeToken","type":"address"},{"indexed":false,"internalType":"uint16","name":"depositFee","type":"uint16"}],"name":"LogPoolAddition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"allocPoint","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"depositFee","type":"uint16"}],"name":"LogSetPool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"lastRewardTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stakeSupply","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accRewardPerShare","type":"uint256"}],"name":"LogUpdatePool","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldMerklDistributor","type":"address"},{"indexed":true,"internalType":"address","name":"newMerklDistributor","type":"address"}],"name":"MerklDistributorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"newAddress","type":"address"}],"name":"SetDevAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"endTime","type":"uint256"}],"name":"SetEndTime","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"newAddress","type":"address"}],"name":"SetFeeAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"}],"name":"SetStartTime","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"}],"name":"SweepToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"newFee","type":"uint256"}],"name":"UpdateDevFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewardPerSecond","type":"uint256"}],"name":"UpdateEmissionRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"MAX_EMISSION_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"contract IERC20","name":"_stakeToken","type":"address"},{"internalType":"uint16","name":"_depositFeeBP","type":"uint16"},{"internalType":"bool","name":"_withUpdate","type":"bool"}],"name":"add","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"claimFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes32[][]","name":"proofs","type":"bytes32[][]"}],"name":"claimMerklRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableHarvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_from","type":"uint256"},{"internalType":"uint256","name":"_to","type":"uint256"}],"name":"getMultiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"harvestEnable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_reward","type":"address"},{"internalType":"address","name":"_feeAddress","type":"address"},{"internalType":"uint256","name":"_rewardPerSecond","type":"uint256"},{"internalType":"uint256","name":"_startTime","type":"uint256"},{"internalType":"uint256","name":"_endTime","type":"uint256"},{"internalType":"address","name":"_merklDistributor","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_reward","type":"address"},{"internalType":"address","name":"_feeAddress","type":"address"},{"internalType":"uint256","name":"_rewardPerSecond","type":"uint256"},{"internalType":"uint256","name":"_startTime","type":"uint256"},{"internalType":"uint256","name":"_endTime","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"massUpdatePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"merklDistributor","outputs":[{"internalType":"contract IMerklDistributor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"pendingRewards","outputs":[{"internalType":"uint256","name":"pending","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"name":"poolExistence","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolInfo","outputs":[{"internalType":"contract IERC20","name":"stakeToken","type":"address"},{"internalType":"uint256","name":"allocPoint","type":"uint256"},{"internalType":"uint256","name":"totalStaked","type":"uint256"},{"internalType":"uint256","name":"lastRewardTime","type":"uint256"},{"internalType":"uint256","name":"accRewardPerShare","type":"uint256"},{"internalType":"uint16","name":"depositFeeBP","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reward","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"uint16","name":"_depositFeeBP","type":"uint16"},{"internalType":"bool","name":"_withUpdate","type":"bool"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_endTime","type":"uint256"}],"name":"setEndTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeAddress","type":"address"}],"name":"setFeeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_merklDistributor","type":"address"}],"name":"setMerklDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_startTime","type":"uint256"}],"name":"setStartTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalAllocPoint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRewardsAllocated","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardPerSecond","type":"uint256"}],"name":"updateEmissionRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"},{"internalType":"uint256","name":"pendingReward","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6080604052609f805460ff19169055600060a0553480156200002057600080fd5b506200002b6200003b565b620000356200003b565b620000fc565b600054610100900460ff1615620000a85760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000fa576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b612bb7806200010c6000396000f3fe608060405234801561001057600080fd5b50600436106102325760003560e01c806384e82a3311610130578063cbd258b5116100b8578063dbce9e531161007c578063dbce9e53146104fc578063dbfba9591461050f578063df2ab5bb14610522578063e2bbb15814610535578063f2fde38b1461054857600080fd5b8063cbd258b51461048d578063ccb98ffc146104b0578063d13f90b4146104c3578063d18df53c146104d6578063d9638422146104e957600080fd5b80638f10369a116100ff5780638f10369a1461040157806393f1a40b1461040a578063aa5c3ab41461045f578063ac68a74814610467578063b1a5d12d1461047a57600080fd5b806384e82a33146103b75780638705fcd4146103ca5780638da5cb5b146103dd5780638dbb1e3a146103ee57600080fd5b806340ef1e04116101be57806351eb05a61161018257806351eb05a6146103785780635312ea8e1461038b578063630b5ba11461039e578063715018a6146103a657806378e97925146103ae57600080fd5b806340ef1e0414610331578063412753581461033957806341744f7b1461034c578063436cc3d614610355578063441a3e701461036557600080fd5b806317caf6f11161020557806317caf6f1146102ce578063228cb733146102d75780632fa4abea146103025780633197cbb6146103155780633e0a322d1461031e57600080fd5b80630777637a14610237578063081e3eda146102595780630ba84cd21461026b5780631526fe2714610280575b600080fd5b609f546102449060ff1681565b60405190151581526020015b60405180910390f35b609a545b604051908152602001610250565b61027e61027936600461243b565b61055b565b005b61029361028e36600461243b565b610577565b604080516001600160a01b0390971687526020870195909552938501929092526060840152608083015261ffff1660a082015260c001610250565b61025d609c5481565b6097546102ea906001600160a01b031681565b6040516001600160a01b039091168152602001610250565b60d4546102ea906001600160a01b031681565b61025d609e5481565b61027e61032c36600461243b565b6105cb565b61027e6106a3565b6099546102ea906001600160a01b031681565b61025d60a05481565b61025d6802b5e3af16b188000081565b61027e610373366004612454565b6106e5565b61027e61038636600461243b565b610836565b61027e61039936600461243b565b610976565b61027e610a40565b61027e610a67565b61025d609d5481565b61027e6103c53660046124b0565b610a7b565b61027e6103d8366004612501565b610d51565b6033546001600160a01b03166102ea565b61025d6103fc366004612454565b610df7565b61025d60985481565b61044461041836600461251e565b609b60209081526000928352604080842090915290825290208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610250565b61025d610e38565b61027e61047536600461243b565b610eaa565b61027e61048836600461254e565b6110d9565b61024461049b366004612501565b60a16020526000908152604090205460ff1681565b61027e6104be36600461243b565b6111ef565b61027e6104d13660046125b5565b611294565b61025d6104e436600461251e565b611368565b61027e6104f7366004612606565b611494565b61027e61050a36600461267f565b61160c565b61027e61051d366004612501565b61168e565b61027e610530366004612743565b611718565b61027e610543366004612454565b611898565b61027e610556366004612501565b611ae5565b610563611b5b565b61056c81611bb5565b610574610a40565b50565b609a818154811061058757600080fd5b60009182526020909120600690910201805460018201546002830154600384015460048501546005909501546001600160a01b0390941695509193909261ffff1686565b6105d3611b5b565b42609d541161061a5760405162461bcd60e51b815260206004820152600e60248201526d135a5b9a5b99c81cdd185c9d195960921b60448201526064015b60405180910390fd5b609a5460005b81811015610664576000609a828154811061063d5761063d612785565b600091825260209091206003600690920201018490555061065d816127b1565b9050610620565b50609d82905560405182815233907f8da5af0cb50a5743c77f99eeeb6f24c1836f9632035e083c916b2875f6165ce39060200160405180910390a25050565b6106ab611b5b565b609f805460ff1916600117905560405133907f5b3c50b793f29bcb049fd68982abad1256ca14b8ca36c82f9eb5da83e15d561c90600090a2565b6106ed611c5a565b6000609a838154811061070257610702612785565b60009182526020808320868452609b8252604080852033865290925292208054600690920290920192508311156107705760405162461bcd60e51b81526020600482015260126024820152711dda5d1a191c985dce881b9bdd0819dbdbd960721b6044820152606401610611565b61077984610836565b6107838433611cb3565b82156107c15780546107959084611dbc565b815560028201546107a69084611dbc565b600283015581546107c1906001600160a01b03163385611dcf565b600482015481546107ea916c0c9f2c9cd04674edea40000000916107e491611e37565b90611e43565b6001820155604051838152849033907ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689060200160405180910390a350506108326001606555565b5050565b6000609a828154811061084b5761084b612785565b906000526020600020906006020190508060030154421161086a575050565b600281015480158061087e57506001820154155b1561088e57504260039091015550565b600061089e836003015442610df7565b905060006108cb609c546107e486600101546108c560985487611e3790919063ffffffff16565b90611e37565b9050806000036108dc575050505050565b8060a060008282546108ee91906127ca565b9091555061091d9050610912846107e4846c0c9f2c9cd04674edea40000000611e37565b600486015490611e56565b600485018190554260038601819055604080519182526020820186905281019190915285907fcb7325664a4a3b7c7223eefc492a97ca4fdf94d46884621e5a8fae5a04b2b9d29060600160405180910390a25050505050565b61097e611c5a565b6000609a828154811061099357610993612785565b60009182526020808320858452609b82526040808520338652909252908320805484825560018201859055600280830195909555600690930290910192830154929350916109e19082611dbc565b600284015582546109fc906001600160a01b03163383611dcf565b604051818152849033907fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959060200160405180910390a35050506105746001606555565b609a5460005b8181101561083257610a5781610836565b610a60816127b1565b9050610a46565b610a6f611b5b565b610a796000611e62565b565b610a83611b5b565b6001600160a01b038316600090815260a16020526040902054839060ff1615610aee5760405162461bcd60e51b815260206004820152601960248201527f6e6f6e4475706c6963617465643a206475706c696361746564000000000000006044820152606401610611565b6103e88361ffff161115610b525760405162461bcd60e51b815260206004820152602560248201527f6164643a20696e76616c6964206465706f7369742066656520626173697320706044820152646f696e747360d81b6064820152608401610611565b8115610b6057610b60610a40565b6000609d544211610b7357609d54610b75565b425b609c54909150610b859087611e56565b609c556001600160a01b03858116600081815260a1602090815260408083208054600160ff199091168117909155815160c0810183528581529283018c8152918301848152606084018881526080850186815261ffff8d811660a08801908152609a805480880182559981905297517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be46006909a02998a0180546001600160a01b03191691909c1617909a5594517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be588015591517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be6870155517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be7860155517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be885015594517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be9909301805461ffff19169390911692909217909155549091610d0c9190611dbc565b6040805189815261ffff881660208201527f0da207787394e659464c7834efba4883ed37810ccb54514238779c1556071c3891015b60405180910390a3505050505050565b6099546001600160a01b03163314610dab5760405162461bcd60e51b815260206004820152601860248201527f736574466565416464726573733a20464f5242494444454e00000000000000006044820152606401610611565b609980546001600160a01b0319166001600160a01b03831690811790915560405133907fd44190acf9d04bdb5d3a1aafff7e6dee8b40b93dfb8c5d3f0eea4b9f4539c3f790600090a350565b6000609e548211610e1357610e0c83836127e2565b9050610e32565b609e548310610e2457506000610e32565b82609e54610e0c91906127e2565b92915050565b6097546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610e81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea591906127f9565b905090565b610eb2611b5b565b6000609a8281548110610ec757610ec7612785565b600091825260208083206040805160c081018252600690940290910180546001600160a01b031680855260018201549385019390935260028101548483015260038101546060850152600480820154608086015260059091015461ffff1660a0850152815163d294f09360e01b81528251949650859463d294f09393828401939092829003018187875af1158015610f63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f879190612812565b91509150600083600001516001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff39190612836565b9050600084600001516001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611039573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061105d9190612836565b9050831561107f5760995461107f906001600160a01b03848116911686611dcf565b821561109f5760995461109f906001600160a01b03838116911685611dcf565b6040805185815260208101859052879133917fd2e6085315c6e1c1c7406a47c7d006a8c1f931396d868c16046dea71365ff0319101610d41565b600054610100900460ff16158080156110f95750600054600160ff909116105b806111135750303b158015611113575060005460ff166001145b61112f5760405162461bcd60e51b815260040161061190612853565b6000805460ff191660011790558015611152576000805461ff0019166101001790555b61115f8787878787611eb4565b6001600160a01b0382166111855760405162461bcd60e51b8152600401610611906128a1565b60d480546001600160a01b0319166001600160a01b03841617905580156111e6576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6111f7611b5b565b609e5481116112565760405162461bcd60e51b815260206004820152602560248201527f456e642054696d652063616e6e6f74206265206265666f72652063757272656e60448201526474206f6e6560d81b6064820152608401610611565b609e81905560405181815233907f4100552e0c7d7733b482a8b5b352d5cf64221041a5cb5ad4f57474178741b69a906020015b60405180910390a250565b600054610100900460ff16158080156112b45750600054600160ff909116105b806112ce5750303b1580156112ce575060005460ff166001145b6112ea5760405162461bcd60e51b815260040161061190612853565b6000805460ff19166001179055801561130d576000805461ff0019166101001790555b61131a8686868686611eb4565b8015611360576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050565b600080609a848154811061137e5761137e612785565b60009182526020808320878452609b825260408085206001600160a01b038916865290925292206004600690920290920190810154600282015460038301549294509091421180156113cf57508015155b156114455760006113e4856003015442610df7565b90506000609c548660010154609854846113fe91906128fe565b61140891906128fe565b611412919061291d565b90508261142c826c0c9f2c9cd04674edea400000006128fe565b611436919061291d565b61144090856127ca565b935050505b6002830154600184015484546c0c9f2c9cd04674edea400000009061146b9086906128fe565b611475919061291d565b61147f91906127e2565b61148991906127ca565b979650505050505050565b61149c611b5b565b6103e88261ffff1611156115005760405162461bcd60e51b815260206004820152602560248201527f7365743a20696e76616c6964206465706f7369742066656520626173697320706044820152646f696e747360d81b6064820152608401610611565b80156115135761150e610a40565b61151c565b61151c84610836565b61155f83611559609a878154811061153657611536612785565b906000526020600020906006020160010154609c54611dbc90919063ffffffff16565b90611e56565b609c8190555082609a858154811061157957611579612785565b90600052602060002090600602016001018190555081609a85815481106115a2576115a2612785565b600091825260209182902060069190910201600501805461ffff191661ffff938416179055604080518681529285169183019190915285917facc273f60709dde93c418270e227d3f00d8fa8b088eef4f66327bafc072b972d91015b60405180910390a250505050565b611614611b5b565b60d4546040516301c7ba5760e61b81526001600160a01b03909116906371ee95c090611652908b908b908b908b908b908b908b908b906004016129be565b600060405180830381600087803b15801561166c57600080fd5b505af1158015611680573d6000803e3d6000fd5b505050505050505050505050565b611696611b5b565b6001600160a01b0381166116bc5760405162461bcd60e51b8152600401610611906128a1565b60d4546040516001600160a01b038084169216907fa581ced3b135b56987ab9afccc3307b0ed8921005c5bf9ccbf67b4ed8031721a90600090a360d480546001600160a01b0319166001600160a01b0392909216919091179055565b611720611b5b565b60005b609a548110156117c357836001600160a01b0316609a828154811061174a5761174a612785565b60009182526020909120600690910201546001600160a01b0316036117b15760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f74207377656570207374616b6520746f6b656e00000000000000006044820152606401610611565b806117bb816127b1565b915050611723565b506040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561180b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182f91906127f9565b905080831161183e5782611840565b805b92506118566001600160a01b0385168385611dcf565b604080518481526001600160a01b0384811660208301528616917f694df00d9871e790c610e85af10d95a026a1b5d1684bea3618e90df2ba1813a991016115fe565b6118a0611c5a565b6000609a83815481106118b5576118b5612785565b60009182526020808320868452609b825260408085203386529092529083206006909202019250906118e685610836565b8154156118f7576118f78533611cb3565b8315611a795782546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611945573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196991906127f9565b8454909150611983906001600160a01b0316333088611f29565b83546040516370a0823160e01b815230600482015282916001600160a01b0316906370a0823190602401602060405180830381865afa1580156119ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ee91906127f9565b6119f891906127e2565b600585015490925061ffff1615611a55576005840154600090611a2890612710906107e490869061ffff16611e37565b6099548654919250611a47916001600160a01b03908116911683611dcf565b611a518382611dbc565b9250505b8254611a619083611e56565b83556002840154611a729083611e56565b6002850155505b60048301548254611a9c916c0c9f2c9cd04674edea40000000916107e491611e37565b6001830155604051818152859033907f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159060200160405180910390a35050506108326001606555565b611aed611b5b565b6001600160a01b038116611b525760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610611565b61057481611e62565b6033546001600160a01b03163314610a795760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610611565b6802b5e3af16b1880000811115611c235760405162461bcd60e51b815260206004820152602c60248201527f5570646174656420656d697373696f6e7320617265206d6f7265207468616e2060448201526b6d6178696d756d207261746560a01b6064820152608401610611565b609881905560405181815233907fe2492e003bbe8afa53088b406f0c1cb5d9e280370fc72a74cf116ffd343c405390602001611289565b600260655403611cac5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610611565b6002606555565b6000828152609b602090815260408083206001600160a01b0385168452909152812060028101546001820154609a8054939492938492916c0c9f2c9cd04674edea400000009189908110611d0957611d09612785565b9060005260206000209060060201600401548660000154611d2a91906128fe565b611d34919061291d565b611d3e91906127e2565b611d4891906127ca565b609f5490915060ff1615611dad578015611da8576000611d66610e38565b905080821115611d8e57611d7a81836127e2565b6002850155611d898582611f67565b611da6565b8215611d9c57600060028501555b611da68583611f67565b505b611db5565b600283018190555b5050505050565b6000611dc882846127e2565b9392505050565b6040516001600160a01b038316602482015260448101829052611e3290849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612131565b505050565b6000611dc882846128fe565b6000611dc8828461291d565b6001606555565b6000611dc882846127ca565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16611edb5760405162461bcd60e51b815260040161061190612a9e565b611ee3612206565b611eeb612235565b609780546001600160a01b039687166001600160a01b0319918216179091556099805495909616941693909317909355609855609d91909155609e55565b6040516001600160a01b0380851660248301528316604482015260648101829052611f619085906323b872dd60e01b90608401611dfb565b50505050565b6097546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611fb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd491906127f9565b905060008183111561205e5760975460405163a9059cbb60e01b81526001600160a01b038681166004830152602482018590529091169063a9059cbb906044016020604051808303816000875af1158015612033573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120579190612ae9565b90506120d8565b60975460405163a9059cbb60e01b81526001600160a01b038681166004830152602482018690529091169063a9059cbb906044016020604051808303816000875af11580156120b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d59190612ae9565b90505b80611f615760405162461bcd60e51b815260206004820152602360248201527f736166655265776172645472616e736665723a207472616e73666572206661696044820152621b195960ea1b6064820152608401610611565b6000612186826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166122649092919063ffffffff16565b90508051600014806121a75750808060200190518101906121a79190612ae9565b611e325760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610611565b600054610100900460ff1661222d5760405162461bcd60e51b815260040161061190612a9e565b610a7961227b565b600054610100900460ff1661225c5760405162461bcd60e51b815260040161061190612a9e565b610a796122ab565b606061227384846000856122d2565b949350505050565b600054610100900460ff166122a25760405162461bcd60e51b815260040161061190612a9e565b610a7933611e62565b600054610100900460ff16611e4f5760405162461bcd60e51b815260040161061190612a9e565b6060824710156123335760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610611565b600080866001600160a01b0316858760405161234f9190612b32565b60006040518083038185875af1925050503d806000811461238c576040519150601f19603f3d011682016040523d82523d6000602084013e612391565b606091505b5091509150611489878383876060831561240c578251600003612405576001600160a01b0385163b6124055760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610611565b5081612273565b61227383838151156124215781518083602001fd5b8060405162461bcd60e51b81526004016106119190612b4e565b60006020828403121561244d57600080fd5b5035919050565b6000806040838503121561246757600080fd5b50508035926020909101359150565b6001600160a01b038116811461057457600080fd5b803561ffff8116811461249d57600080fd5b919050565b801515811461057457600080fd5b600080600080608085870312156124c657600080fd5b8435935060208501356124d881612476565b92506124e66040860161248b565b915060608501356124f6816124a2565b939692955090935050565b60006020828403121561251357600080fd5b8135611dc881612476565b6000806040838503121561253157600080fd5b82359150602083013561254381612476565b809150509250929050565b60008060008060008060c0878903121561256757600080fd5b863561257281612476565b9550602087013561258281612476565b945060408701359350606087013592506080870135915060a08701356125a781612476565b809150509295509295509295565b600080600080600060a086880312156125cd57600080fd5b85356125d881612476565b945060208601356125e881612476565b94979496505050506040830135926060810135926080909101359150565b6000806000806080858703121561261c57600080fd5b84359350602085013592506124e66040860161248b565b60008083601f84011261264557600080fd5b50813567ffffffffffffffff81111561265d57600080fd5b6020830191508360208260051b850101111561267857600080fd5b9250929050565b6000806000806000806000806080898b03121561269b57600080fd5b883567ffffffffffffffff808211156126b357600080fd5b6126bf8c838d01612633565b909a50985060208b01359150808211156126d857600080fd5b6126e48c838d01612633565b909850965060408b01359150808211156126fd57600080fd5b6127098c838d01612633565b909650945060608b013591508082111561272257600080fd5b5061272f8b828c01612633565b999c989b5096995094979396929594505050565b60008060006060848603121561275857600080fd5b833561276381612476565b925060208401359150604084013561277a81612476565b809150509250925092565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016127c3576127c361279b565b5060010190565b600082198211156127dd576127dd61279b565b500190565b6000828210156127f4576127f461279b565b500390565b60006020828403121561280b57600080fd5b5051919050565b6000806040838503121561282557600080fd5b505080516020909101519092909150565b60006020828403121561284857600080fd5b8151611dc881612476565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526039908201527f5072654d696e696e67576974684d65726b6c436c61696d3a206d65726b6c446960408201527f737472696275746f72206973207a65726f206164647265737300000000000000606082015260800190565b60008160001904831182151516156129185761291861279b565b500290565b60008261293a57634e487b7160e01b600052601260045260246000fd5b500490565b8183526000602080850194508260005b8581101561297d57813561296281612476565b6001600160a01b03168752958201959082019060010161294f565b509495945050505050565b81835260006001600160fb1b038311156129a157600080fd5b8260051b8083602087013760009401602001938452509192915050565b6080815260006129d2608083018a8c61293f565b6020838203818501526129e6828a8c61293f565b915083820360408501526129fb82888a612988565b84810360608601528581529150808201600586811b840183018860005b89811015612a8957868303601f190185528135368c9003601e19018112612a3e57600080fd5b8b01803567ffffffffffffffff811115612a5757600080fd5b80861b36038d1315612a6857600080fd5b612a7585828a8501612988565b968801969450505090850190600101612a18565b50909f9e505050505050505050505050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600060208284031215612afb57600080fd5b8151611dc8816124a2565b60005b83811015612b21578181015183820152602001612b09565b83811115611f615750506000910152565b60008251612b44818460208701612b06565b9190910192915050565b6020815260008251806020840152612b6d816040850160208701612b06565b601f01601f1916919091016040019291505056fea2646970667358221220aca2f541b5326e52aa770c6fb92c9657e9feedcf277b3abf9605eb8f9358c7f464736f6c634300080d0033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102325760003560e01c806384e82a3311610130578063cbd258b5116100b8578063dbce9e531161007c578063dbce9e53146104fc578063dbfba9591461050f578063df2ab5bb14610522578063e2bbb15814610535578063f2fde38b1461054857600080fd5b8063cbd258b51461048d578063ccb98ffc146104b0578063d13f90b4146104c3578063d18df53c146104d6578063d9638422146104e957600080fd5b80638f10369a116100ff5780638f10369a1461040157806393f1a40b1461040a578063aa5c3ab41461045f578063ac68a74814610467578063b1a5d12d1461047a57600080fd5b806384e82a33146103b75780638705fcd4146103ca5780638da5cb5b146103dd5780638dbb1e3a146103ee57600080fd5b806340ef1e04116101be57806351eb05a61161018257806351eb05a6146103785780635312ea8e1461038b578063630b5ba11461039e578063715018a6146103a657806378e97925146103ae57600080fd5b806340ef1e0414610331578063412753581461033957806341744f7b1461034c578063436cc3d614610355578063441a3e701461036557600080fd5b806317caf6f11161020557806317caf6f1146102ce578063228cb733146102d75780632fa4abea146103025780633197cbb6146103155780633e0a322d1461031e57600080fd5b80630777637a14610237578063081e3eda146102595780630ba84cd21461026b5780631526fe2714610280575b600080fd5b609f546102449060ff1681565b60405190151581526020015b60405180910390f35b609a545b604051908152602001610250565b61027e61027936600461243b565b61055b565b005b61029361028e36600461243b565b610577565b604080516001600160a01b0390971687526020870195909552938501929092526060840152608083015261ffff1660a082015260c001610250565b61025d609c5481565b6097546102ea906001600160a01b031681565b6040516001600160a01b039091168152602001610250565b60d4546102ea906001600160a01b031681565b61025d609e5481565b61027e61032c36600461243b565b6105cb565b61027e6106a3565b6099546102ea906001600160a01b031681565b61025d60a05481565b61025d6802b5e3af16b188000081565b61027e610373366004612454565b6106e5565b61027e61038636600461243b565b610836565b61027e61039936600461243b565b610976565b61027e610a40565b61027e610a67565b61025d609d5481565b61027e6103c53660046124b0565b610a7b565b61027e6103d8366004612501565b610d51565b6033546001600160a01b03166102ea565b61025d6103fc366004612454565b610df7565b61025d60985481565b61044461041836600461251e565b609b60209081526000928352604080842090915290825290208054600182015460029092015490919083565b60408051938452602084019290925290820152606001610250565b61025d610e38565b61027e61047536600461243b565b610eaa565b61027e61048836600461254e565b6110d9565b61024461049b366004612501565b60a16020526000908152604090205460ff1681565b61027e6104be36600461243b565b6111ef565b61027e6104d13660046125b5565b611294565b61025d6104e436600461251e565b611368565b61027e6104f7366004612606565b611494565b61027e61050a36600461267f565b61160c565b61027e61051d366004612501565b61168e565b61027e610530366004612743565b611718565b61027e610543366004612454565b611898565b61027e610556366004612501565b611ae5565b610563611b5b565b61056c81611bb5565b610574610a40565b50565b609a818154811061058757600080fd5b60009182526020909120600690910201805460018201546002830154600384015460048501546005909501546001600160a01b0390941695509193909261ffff1686565b6105d3611b5b565b42609d541161061a5760405162461bcd60e51b815260206004820152600e60248201526d135a5b9a5b99c81cdd185c9d195960921b60448201526064015b60405180910390fd5b609a5460005b81811015610664576000609a828154811061063d5761063d612785565b600091825260209091206003600690920201018490555061065d816127b1565b9050610620565b50609d82905560405182815233907f8da5af0cb50a5743c77f99eeeb6f24c1836f9632035e083c916b2875f6165ce39060200160405180910390a25050565b6106ab611b5b565b609f805460ff1916600117905560405133907f5b3c50b793f29bcb049fd68982abad1256ca14b8ca36c82f9eb5da83e15d561c90600090a2565b6106ed611c5a565b6000609a838154811061070257610702612785565b60009182526020808320868452609b8252604080852033865290925292208054600690920290920192508311156107705760405162461bcd60e51b81526020600482015260126024820152711dda5d1a191c985dce881b9bdd0819dbdbd960721b6044820152606401610611565b61077984610836565b6107838433611cb3565b82156107c15780546107959084611dbc565b815560028201546107a69084611dbc565b600283015581546107c1906001600160a01b03163385611dcf565b600482015481546107ea916c0c9f2c9cd04674edea40000000916107e491611e37565b90611e43565b6001820155604051838152849033907ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689060200160405180910390a350506108326001606555565b5050565b6000609a828154811061084b5761084b612785565b906000526020600020906006020190508060030154421161086a575050565b600281015480158061087e57506001820154155b1561088e57504260039091015550565b600061089e836003015442610df7565b905060006108cb609c546107e486600101546108c560985487611e3790919063ffffffff16565b90611e37565b9050806000036108dc575050505050565b8060a060008282546108ee91906127ca565b9091555061091d9050610912846107e4846c0c9f2c9cd04674edea40000000611e37565b600486015490611e56565b600485018190554260038601819055604080519182526020820186905281019190915285907fcb7325664a4a3b7c7223eefc492a97ca4fdf94d46884621e5a8fae5a04b2b9d29060600160405180910390a25050505050565b61097e611c5a565b6000609a828154811061099357610993612785565b60009182526020808320858452609b82526040808520338652909252908320805484825560018201859055600280830195909555600690930290910192830154929350916109e19082611dbc565b600284015582546109fc906001600160a01b03163383611dcf565b604051818152849033907fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959060200160405180910390a35050506105746001606555565b609a5460005b8181101561083257610a5781610836565b610a60816127b1565b9050610a46565b610a6f611b5b565b610a796000611e62565b565b610a83611b5b565b6001600160a01b038316600090815260a16020526040902054839060ff1615610aee5760405162461bcd60e51b815260206004820152601960248201527f6e6f6e4475706c6963617465643a206475706c696361746564000000000000006044820152606401610611565b6103e88361ffff161115610b525760405162461bcd60e51b815260206004820152602560248201527f6164643a20696e76616c6964206465706f7369742066656520626173697320706044820152646f696e747360d81b6064820152608401610611565b8115610b6057610b60610a40565b6000609d544211610b7357609d54610b75565b425b609c54909150610b859087611e56565b609c556001600160a01b03858116600081815260a1602090815260408083208054600160ff199091168117909155815160c0810183528581529283018c8152918301848152606084018881526080850186815261ffff8d811660a08801908152609a805480880182559981905297517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be46006909a02998a0180546001600160a01b03191691909c1617909a5594517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be588015591517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be6870155517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be7860155517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be885015594517f44da158ba27f9252712a74ff6a55c5d531f69609f1f6e7f17c4443a8e2089be9909301805461ffff19169390911692909217909155549091610d0c9190611dbc565b6040805189815261ffff881660208201527f0da207787394e659464c7834efba4883ed37810ccb54514238779c1556071c3891015b60405180910390a3505050505050565b6099546001600160a01b03163314610dab5760405162461bcd60e51b815260206004820152601860248201527f736574466565416464726573733a20464f5242494444454e00000000000000006044820152606401610611565b609980546001600160a01b0319166001600160a01b03831690811790915560405133907fd44190acf9d04bdb5d3a1aafff7e6dee8b40b93dfb8c5d3f0eea4b9f4539c3f790600090a350565b6000609e548211610e1357610e0c83836127e2565b9050610e32565b609e548310610e2457506000610e32565b82609e54610e0c91906127e2565b92915050565b6097546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015610e81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ea591906127f9565b905090565b610eb2611b5b565b6000609a8281548110610ec757610ec7612785565b600091825260208083206040805160c081018252600690940290910180546001600160a01b031680855260018201549385019390935260028101548483015260038101546060850152600480820154608086015260059091015461ffff1660a0850152815163d294f09360e01b81528251949650859463d294f09393828401939092829003018187875af1158015610f63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f879190612812565b91509150600083600001516001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff39190612836565b9050600084600001516001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611039573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061105d9190612836565b9050831561107f5760995461107f906001600160a01b03848116911686611dcf565b821561109f5760995461109f906001600160a01b03838116911685611dcf565b6040805185815260208101859052879133917fd2e6085315c6e1c1c7406a47c7d006a8c1f931396d868c16046dea71365ff0319101610d41565b600054610100900460ff16158080156110f95750600054600160ff909116105b806111135750303b158015611113575060005460ff166001145b61112f5760405162461bcd60e51b815260040161061190612853565b6000805460ff191660011790558015611152576000805461ff0019166101001790555b61115f8787878787611eb4565b6001600160a01b0382166111855760405162461bcd60e51b8152600401610611906128a1565b60d480546001600160a01b0319166001600160a01b03841617905580156111e6576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050565b6111f7611b5b565b609e5481116112565760405162461bcd60e51b815260206004820152602560248201527f456e642054696d652063616e6e6f74206265206265666f72652063757272656e60448201526474206f6e6560d81b6064820152608401610611565b609e81905560405181815233907f4100552e0c7d7733b482a8b5b352d5cf64221041a5cb5ad4f57474178741b69a906020015b60405180910390a250565b600054610100900460ff16158080156112b45750600054600160ff909116105b806112ce5750303b1580156112ce575060005460ff166001145b6112ea5760405162461bcd60e51b815260040161061190612853565b6000805460ff19166001179055801561130d576000805461ff0019166101001790555b61131a8686868686611eb4565b8015611360576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050565b600080609a848154811061137e5761137e612785565b60009182526020808320878452609b825260408085206001600160a01b038916865290925292206004600690920290920190810154600282015460038301549294509091421180156113cf57508015155b156114455760006113e4856003015442610df7565b90506000609c548660010154609854846113fe91906128fe565b61140891906128fe565b611412919061291d565b90508261142c826c0c9f2c9cd04674edea400000006128fe565b611436919061291d565b61144090856127ca565b935050505b6002830154600184015484546c0c9f2c9cd04674edea400000009061146b9086906128fe565b611475919061291d565b61147f91906127e2565b61148991906127ca565b979650505050505050565b61149c611b5b565b6103e88261ffff1611156115005760405162461bcd60e51b815260206004820152602560248201527f7365743a20696e76616c6964206465706f7369742066656520626173697320706044820152646f696e747360d81b6064820152608401610611565b80156115135761150e610a40565b61151c565b61151c84610836565b61155f83611559609a878154811061153657611536612785565b906000526020600020906006020160010154609c54611dbc90919063ffffffff16565b90611e56565b609c8190555082609a858154811061157957611579612785565b90600052602060002090600602016001018190555081609a85815481106115a2576115a2612785565b600091825260209182902060069190910201600501805461ffff191661ffff938416179055604080518681529285169183019190915285917facc273f60709dde93c418270e227d3f00d8fa8b088eef4f66327bafc072b972d91015b60405180910390a250505050565b611614611b5b565b60d4546040516301c7ba5760e61b81526001600160a01b03909116906371ee95c090611652908b908b908b908b908b908b908b908b906004016129be565b600060405180830381600087803b15801561166c57600080fd5b505af1158015611680573d6000803e3d6000fd5b505050505050505050505050565b611696611b5b565b6001600160a01b0381166116bc5760405162461bcd60e51b8152600401610611906128a1565b60d4546040516001600160a01b038084169216907fa581ced3b135b56987ab9afccc3307b0ed8921005c5bf9ccbf67b4ed8031721a90600090a360d480546001600160a01b0319166001600160a01b0392909216919091179055565b611720611b5b565b60005b609a548110156117c357836001600160a01b0316609a828154811061174a5761174a612785565b60009182526020909120600690910201546001600160a01b0316036117b15760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f74207377656570207374616b6520746f6b656e00000000000000006044820152606401610611565b806117bb816127b1565b915050611723565b506040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561180b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182f91906127f9565b905080831161183e5782611840565b805b92506118566001600160a01b0385168385611dcf565b604080518481526001600160a01b0384811660208301528616917f694df00d9871e790c610e85af10d95a026a1b5d1684bea3618e90df2ba1813a991016115fe565b6118a0611c5a565b6000609a83815481106118b5576118b5612785565b60009182526020808320868452609b825260408085203386529092529083206006909202019250906118e685610836565b8154156118f7576118f78533611cb3565b8315611a795782546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611945573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061196991906127f9565b8454909150611983906001600160a01b0316333088611f29565b83546040516370a0823160e01b815230600482015282916001600160a01b0316906370a0823190602401602060405180830381865afa1580156119ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ee91906127f9565b6119f891906127e2565b600585015490925061ffff1615611a55576005840154600090611a2890612710906107e490869061ffff16611e37565b6099548654919250611a47916001600160a01b03908116911683611dcf565b611a518382611dbc565b9250505b8254611a619083611e56565b83556002840154611a729083611e56565b6002850155505b60048301548254611a9c916c0c9f2c9cd04674edea40000000916107e491611e37565b6001830155604051818152859033907f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159060200160405180910390a35050506108326001606555565b611aed611b5b565b6001600160a01b038116611b525760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610611565b61057481611e62565b6033546001600160a01b03163314610a795760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610611565b6802b5e3af16b1880000811115611c235760405162461bcd60e51b815260206004820152602c60248201527f5570646174656420656d697373696f6e7320617265206d6f7265207468616e2060448201526b6d6178696d756d207261746560a01b6064820152608401610611565b609881905560405181815233907fe2492e003bbe8afa53088b406f0c1cb5d9e280370fc72a74cf116ffd343c405390602001611289565b600260655403611cac5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610611565b6002606555565b6000828152609b602090815260408083206001600160a01b0385168452909152812060028101546001820154609a8054939492938492916c0c9f2c9cd04674edea400000009189908110611d0957611d09612785565b9060005260206000209060060201600401548660000154611d2a91906128fe565b611d34919061291d565b611d3e91906127e2565b611d4891906127ca565b609f5490915060ff1615611dad578015611da8576000611d66610e38565b905080821115611d8e57611d7a81836127e2565b6002850155611d898582611f67565b611da6565b8215611d9c57600060028501555b611da68583611f67565b505b611db5565b600283018190555b5050505050565b6000611dc882846127e2565b9392505050565b6040516001600160a01b038316602482015260448101829052611e3290849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612131565b505050565b6000611dc882846128fe565b6000611dc8828461291d565b6001606555565b6000611dc882846127ca565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16611edb5760405162461bcd60e51b815260040161061190612a9e565b611ee3612206565b611eeb612235565b609780546001600160a01b039687166001600160a01b0319918216179091556099805495909616941693909317909355609855609d91909155609e55565b6040516001600160a01b0380851660248301528316604482015260648101829052611f619085906323b872dd60e01b90608401611dfb565b50505050565b6097546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611fb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd491906127f9565b905060008183111561205e5760975460405163a9059cbb60e01b81526001600160a01b038681166004830152602482018590529091169063a9059cbb906044016020604051808303816000875af1158015612033573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120579190612ae9565b90506120d8565b60975460405163a9059cbb60e01b81526001600160a01b038681166004830152602482018690529091169063a9059cbb906044016020604051808303816000875af11580156120b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d59190612ae9565b90505b80611f615760405162461bcd60e51b815260206004820152602360248201527f736166655265776172645472616e736665723a207472616e73666572206661696044820152621b195960ea1b6064820152608401610611565b6000612186826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166122649092919063ffffffff16565b90508051600014806121a75750808060200190518101906121a79190612ae9565b611e325760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610611565b600054610100900460ff1661222d5760405162461bcd60e51b815260040161061190612a9e565b610a7961227b565b600054610100900460ff1661225c5760405162461bcd60e51b815260040161061190612a9e565b610a796122ab565b606061227384846000856122d2565b949350505050565b600054610100900460ff166122a25760405162461bcd60e51b815260040161061190612a9e565b610a7933611e62565b600054610100900460ff16611e4f5760405162461bcd60e51b815260040161061190612a9e565b6060824710156123335760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610611565b600080866001600160a01b0316858760405161234f9190612b32565b60006040518083038185875af1925050503d806000811461238c576040519150601f19603f3d011682016040523d82523d6000602084013e612391565b606091505b5091509150611489878383876060831561240c578251600003612405576001600160a01b0385163b6124055760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610611565b5081612273565b61227383838151156124215781518083602001fd5b8060405162461bcd60e51b81526004016106119190612b4e565b60006020828403121561244d57600080fd5b5035919050565b6000806040838503121561246757600080fd5b50508035926020909101359150565b6001600160a01b038116811461057457600080fd5b803561ffff8116811461249d57600080fd5b919050565b801515811461057457600080fd5b600080600080608085870312156124c657600080fd5b8435935060208501356124d881612476565b92506124e66040860161248b565b915060608501356124f6816124a2565b939692955090935050565b60006020828403121561251357600080fd5b8135611dc881612476565b6000806040838503121561253157600080fd5b82359150602083013561254381612476565b809150509250929050565b60008060008060008060c0878903121561256757600080fd5b863561257281612476565b9550602087013561258281612476565b945060408701359350606087013592506080870135915060a08701356125a781612476565b809150509295509295509295565b600080600080600060a086880312156125cd57600080fd5b85356125d881612476565b945060208601356125e881612476565b94979496505050506040830135926060810135926080909101359150565b6000806000806080858703121561261c57600080fd5b84359350602085013592506124e66040860161248b565b60008083601f84011261264557600080fd5b50813567ffffffffffffffff81111561265d57600080fd5b6020830191508360208260051b850101111561267857600080fd5b9250929050565b6000806000806000806000806080898b03121561269b57600080fd5b883567ffffffffffffffff808211156126b357600080fd5b6126bf8c838d01612633565b909a50985060208b01359150808211156126d857600080fd5b6126e48c838d01612633565b909850965060408b01359150808211156126fd57600080fd5b6127098c838d01612633565b909650945060608b013591508082111561272257600080fd5b5061272f8b828c01612633565b999c989b5096995094979396929594505050565b60008060006060848603121561275857600080fd5b833561276381612476565b925060208401359150604084013561277a81612476565b809150509250925092565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016127c3576127c361279b565b5060010190565b600082198211156127dd576127dd61279b565b500190565b6000828210156127f4576127f461279b565b500390565b60006020828403121561280b57600080fd5b5051919050565b6000806040838503121561282557600080fd5b505080516020909101519092909150565b60006020828403121561284857600080fd5b8151611dc881612476565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526039908201527f5072654d696e696e67576974684d65726b6c436c61696d3a206d65726b6c446960408201527f737472696275746f72206973207a65726f206164647265737300000000000000606082015260800190565b60008160001904831182151516156129185761291861279b565b500290565b60008261293a57634e487b7160e01b600052601260045260246000fd5b500490565b8183526000602080850194508260005b8581101561297d57813561296281612476565b6001600160a01b03168752958201959082019060010161294f565b509495945050505050565b81835260006001600160fb1b038311156129a157600080fd5b8260051b8083602087013760009401602001938452509192915050565b6080815260006129d2608083018a8c61293f565b6020838203818501526129e6828a8c61293f565b915083820360408501526129fb82888a612988565b84810360608601528581529150808201600586811b840183018860005b89811015612a8957868303601f190185528135368c9003601e19018112612a3e57600080fd5b8b01803567ffffffffffffffff811115612a5757600080fd5b80861b36038d1315612a6857600080fd5b612a7585828a8501612988565b968801969450505090850190600101612a18565b50909f9e505050505050505050505050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600060208284031215612afb57600080fd5b8151611dc8816124a2565b60005b83811015612b21578181015183820152602001612b09565b83811115611f615750506000910152565b60008251612b44818460208701612b06565b9190910192915050565b6020815260008251806020840152612b6d816040850160208701612b06565b601f01601f1916919091016040019291505056fea2646970667358221220aca2f541b5326e52aa770c6fb92c9657e9feedcf277b3abf9605eb8f9358c7f464736f6c634300080d0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.