Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x1d624C56...F4d800fef The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
SonicPad
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
No with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.13; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; import {BaseSonicPool} from "./BaseSonicPool.sol"; import {BaseSonicToken} from "./BaseSonicToken.sol"; contract Ownable { address private _owner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); constructor() { address msgSender = msg.sender; _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == msg.sender, "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require( newOwner != address(0), "Ownable: new owner is the zero address" ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract SonicPad is Ownable, Initializable, PausableUpgradeable { using Address for address payable; struct Token { address instance; address sonicPool; address owner; uint32 poolType; uint32 tokenType; uint32 dexHandler; string name; string symbol; uint256 maxSupply; } // templates for each pool type address[] public tokenImplementations; address[] public sonicPoolImplementations; address[] public dexHandlers; Token[] internal tokens; mapping(address => uint256) public tokenIndexes; // uniswap compatibility mapping(address => mapping(address => address)) public getPair; address[] public allPairs; address public feeTo; uint256 public LAUNCH_FEE = 0.0001 ether; uint256 public MAX_SUPPLY = 1000000000 ether; error BadUpgrade(); error UnknownPoolType(); error InvalidParams(); error OwnershipTransferFailed(); error FeeMismatch(); error UnauthorizedClaim(); event Launched( address owner, string name, string symbol, uint256 maxSupply, address token, address pool, address dexHandler ); event PairCreated( address token0, address token1, address pair, uint256 tokenId ); constructor() { _disableInitializers(); } receive() external payable {} function initialize( address[] memory _tokenImpls, address[] memory _poolImpls, address[] memory _dexHandlers, address _feeTo ) public onlyOwner { // Initialize contract tokenImplementations = _tokenImpls; sonicPoolImplementations = _poolImpls; dexHandlers = _dexHandlers; feeTo = _feeTo; } // token creator functions function launch( address tokenOwner, string memory name, string memory symbol, bytes memory poolParams, address rewardReceiver, uint32 poolType, uint32 tokenType, uint32 dexHandler ) external payable whenNotPaused { if (msg.value != LAUNCH_FEE) revert FeeMismatch(); address instance; address sonicPool; address dexHandlerAddress = dexHandlers[dexHandler]; { // avoid stack too deep address tokenImpl = tokenImplementations[tokenType]; address poolImpl = sonicPoolImplementations[poolType]; if ( tokenImpl == address(0) || poolImpl == address(0) || dexHandlerAddress == address(0) ) revert InvalidParams(); // Launch token instance = Clones.clone(tokenImpl); sonicPool = Clones.clone(poolImpl); } BaseSonicToken(instance).initialize( name, symbol, sonicPool, dexHandlerAddress, MAX_SUPPLY, rewardReceiver ); tokens.push( Token({ instance: instance, sonicPool: sonicPool, owner: tokenOwner, poolType: poolType, tokenType: tokenType, dexHandler: dexHandler, name: name, symbol: symbol, maxSupply: MAX_SUPPLY }) ); tokenIndexes[instance] = tokens.length - 1; address baseToken = BaseSonicPool(sonicPool).token0(); // uniswap compatibility getPair[baseToken][address(instance)] = sonicPool; getPair[address(instance)][baseToken] = sonicPool; allPairs.push(sonicPool); // Initialize sonic pool BaseSonicPool(sonicPool).initialize( instance, feeTo, dexHandlerAddress, poolParams ); emit Launched( tokenOwner, name, symbol, MAX_SUPPLY, instance, sonicPool, dexHandlerAddress ); // uniswap compatibility emit PairCreated( baseToken, address(instance), sonicPool, tokens.length - 1 ); } function launchPermissioned( address tokenOwner, address token, address pool ) external onlyOwner { // Launch token tokens.push( Token({ instance: token, sonicPool: pool, owner: tokenOwner, poolType: type(uint32).max, tokenType: type(uint32).max, dexHandler: type(uint32).max, name: BaseSonicToken(token).name(), symbol: BaseSonicToken(token).symbol(), maxSupply: BaseSonicToken(token).totalSupply() }) ); address baseToken = BaseSonicPool(pool).token0(); tokenIndexes[token] = tokens.length - 1; // uniswap compatibility getPair[baseToken][token] = pool; getPair[token][baseToken] = pool; allPairs.push(pool); emit Launched( tokenOwner, BaseSonicToken(token).name(), BaseSonicToken(token).symbol(), BaseSonicToken(token).totalSupply(), token, pool, address(0) ); // uniswap compatibility emit PairCreated(baseToken, token, pool, tokens.length - 1); } function transferTokenOwnership(uint256 id, address newOwner) external { if (id >= tokens.length) revert OwnershipTransferFailed(); if (tokens[id].owner != msg.sender) revert OwnershipTransferFailed(); Token storage token = tokens[id]; token.owner = newOwner; } // admin functions function setLaunchFee(uint256 _fee) external onlyOwner { if (_fee > 100 ether) revert("fee too high"); LAUNCH_FEE = _fee; } function claimLaunchTaxes() external onlyOwner { payable(owner()).sendValue(address(this).balance); } function togglePause() external onlyOwner { if (paused()) _unpause(); else _pause(); } function updateMaxSupply(uint256 _maxSupply) external onlyOwner { MAX_SUPPLY = _maxSupply; } // view functions function getToken(uint256 id) external view returns (Token memory) { if (id >= tokens.length) return Token(address(0), address(0), address(0), 0, 0, 0, "", "", 0); return tokens[id]; } function allPairsLength() external view returns (uint256) { return tokens.length; } function feeToSetter() external view returns (address) { return owner(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @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 Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 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 in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._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 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._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() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @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 { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol"; import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC-20 * applications. */ abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors { /// @custom:storage-location erc7201:openzeppelin.storage.ERC20 struct ERC20Storage { mapping(address account => uint256) _balances; mapping(address account => mapping(address spender => uint256)) _allowances; uint256 _totalSupply; string _name; string _symbol; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00; function _getERC20Storage() private pure returns (ERC20Storage storage $) { assembly { $.slot := ERC20StorageLocation } } /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { ERC20Storage storage $ = _getERC20Storage(); $._name = name_; $._symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { ERC20Storage storage $ = _getERC20Storage(); return $._symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { ERC20Storage storage $ = _getERC20Storage(); return $._allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Skips emitting an {Approval} event indicating an allowance update. This is not * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve]. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows $._totalSupply += value; } else { uint256 fromBalance = $._balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. $._balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. $._totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. $._balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * * ```solidity * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { ERC20Storage storage $ = _getERC20Storage(); if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } $._allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Burnable.sol) pragma solidity ^0.8.20; import {ERC20Upgradeable} from "../ERC20Upgradeable.sol"; import {ContextUpgradeable} from "../../../utils/ContextUpgradeable.sol"; import {Initializable} from "../../../proxy/utils/Initializable.sol"; /** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */ abstract contract ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable { function __ERC20Burnable_init() internal onlyInitializing { } function __ERC20Burnable_init_unchained() internal onlyInitializing { } /** * @dev Destroys a `value` amount of tokens from the caller. * * See {ERC20-_burn}. */ function burn(uint256 value) public virtual { _burn(_msgSender(), value); } /** * @dev Destroys a `value` amount of tokens from `account`, deducting from * the caller's allowance. * * See {ERC20-_burn} and {ERC20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `value`. */ function burnFrom(address account, uint256 value) public virtual { _spendAllowance(account, _msgSender(), value); _burn(account, value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; 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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Pausable struct PausableStorage { bool _paused; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300; function _getPausableStorage() private pure returns (PausableStorage storage $) { assembly { $.slot := PausableStorageLocation } } /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { PausableStorage storage $ = _getPausableStorage(); $._paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { PausableStorage storage $ = _getPausableStorage(); return $._paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { PausableStorage storage $ = _getPausableStorage(); $._paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; 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 EIP-1153 (transient storage) is available on the chain you're deploying at, * consider using {ReentrancyGuardTransient} instead. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract 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; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._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 { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // 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) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC-20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC-721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC-1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC165} from "./IERC165.sol"; /** * @title IERC1363 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363]. * * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction. */ interface IERC1363 is IERC20, IERC165 { /* * Note: the ERC-165 identifier for this interface is 0xb0202a11. * 0xb0202a11 === * bytes4(keccak256('transferAndCall(address,uint256)')) ^ * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^ * bytes4(keccak256('approveAndCall(address,uint256)')) ^ * bytes4(keccak256('approveAndCall(address,uint256,bytes)')) */ /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @param data Additional data with no specified format, sent in call to `spender`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (proxy/Clones.sol) pragma solidity ^0.8.20; import {Errors} from "../utils/Errors.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[ERC-1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. */ library Clones { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create opcode, which should never revert. */ function clone(address implementation) internal returns (address instance) { return clone(implementation, 0); } /** * @dev Same as {xref-Clones-clone-address-}[clone], but with a `value` parameter to send native currency * to the new contract. * * NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory) * to always have enough balance for new deployments. Consider exposing this function under a payable method. */ function clone(address implementation, uint256 value) internal returns (address instance) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } assembly ("memory-safe") { // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes // of the `implementation` address with the bytecode before the address. mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) // Packs the remaining 17 bytes of `implementation` with the bytecode after the address. mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3)) instance := create(value, 0x09, 0x37) } if (instance == address(0)) { revert Errors.FailedDeployment(); } } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `implementation` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) { return cloneDeterministic(implementation, salt, 0); } /** * @dev Same as {xref-Clones-cloneDeterministic-address-bytes32-}[cloneDeterministic], but with * a `value` parameter to send native currency to the new contract. * * NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory) * to always have enough balance for new deployments. Consider exposing this function under a payable method. */ function cloneDeterministic( address implementation, bytes32 salt, uint256 value ) internal returns (address instance) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } assembly ("memory-safe") { // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes // of the `implementation` address with the bytecode before the address. mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000)) // Packs the remaining 17 bytes of `implementation` with the bytecode after the address. mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3)) instance := create2(value, 0x09, 0x37, salt) } if (instance == address(0)) { revert Errors.FailedDeployment(); } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt, address deployer ) internal pure returns (address predicted) { assembly ("memory-safe") { let ptr := mload(0x40) mstore(add(ptr, 0x38), deployer) mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff) mstore(add(ptr, 0x14), implementation) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73) mstore(add(ptr, 0x58), salt) mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37)) predicted := and(keccak256(add(ptr, 0x43), 0x55), 0xffffffffffffffffffffffffffffffffffffffff) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress( address implementation, bytes32 salt ) internal view returns (address predicted) { return predictDeterministicAddress(implementation, salt, address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC-20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC1363} from "../../../interfaces/IERC1363.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC-20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { /** * @dev An operation with an ERC-20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. * * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being * set here. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { safeTransfer(token, to, value); } else if (!token.transferAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferFromAndCallRelaxed( IERC1363 token, address from, address to, uint256 value, bytes memory data ) internal { if (to.code.length == 0) { safeTransferFrom(token, from, to, value); } else if (!token.transferFromAndCall(from, to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}. * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall} * once without retrying, and relies on the returned value to be true. * * Reverts if the returned value is other than `true`. */ function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { forceApprove(token, to, value); } else if (!token.approveAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements. */ function _callOptionalReturn(IERC20 token, bytes memory data) private { uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) // bubble errors if iszero(success) { let ptr := mload(0x40) returndatacopy(ptr, 0, returndatasize()) revert(ptr, returndatasize()) } returnSize := returndatasize() returnValue := mload(0) } if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { bool success; uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) returnSize := returndatasize() returnValue := mload(0) } return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert Errors.FailedCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.13; import {SonicPad} from "./SonicPad.sol"; import {BondingCurve} from "./BondingCurve.sol"; import {BaseSonicToken} from "./BaseSonicToken.sol"; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import {IDexHandler} from "./interfaces/IDexHandler.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract BaseSonicPool is Initializable, ReentrancyGuardUpgradeable { using SafeERC20 for IERC20; using Address for address payable; uint256 public constant BPS = 10000; uint256 public constant FEE_BPS = 50; // 0.5% fee address public constant WETH = address(0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd); BondingCurve.Liquidity internal liq; IERC20 public token; SonicPad public factory; IDexHandler public dexHandler; address payable public feeReceiver; bool public locked; uint32 public lastUpdateTime; error Pool_SlippageError(); error Pool_PoolLocked(); event Bought( uint256 ethAmount, uint256 tokenAmount, uint256 reserveEth, uint256 reserveToken ); event Sold( uint256 tokenAmount, uint256 ethAmount, uint256 reserveEth, uint256 reserveToken ); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); event Locked(); enum Style { Moon, Balanced, Steady } constructor() { _disableInitializers(); } modifier lockLiquidity() { if (locked) revert Pool_PoolLocked(); _; lastUpdateTime = uint32(block.timestamp); if (liq.reserveEth >= liq.maxEth) _lockLiquidity(); } function initialize( address _token, address _feeReceiver, address _dexHandler, bytes memory _poolParams ) public initializer { factory = SonicPad(payable(msg.sender)); dexHandler = IDexHandler(_dexHandler); feeReceiver = payable(_feeReceiver); token = IERC20(_token); lastUpdateTime = uint32(block.timestamp); uint256 _tokenSupply = IERC20(_token).balanceOf(address(this)); Style style = abi.decode(_poolParams, (Style)); (uint256 virtualEth, uint256 maxEth) = _paramsForStyle(style); uint256 _inflatedTokenSupply = BondingCurve._getInflatedTokenSupply( _tokenSupply, virtualEth, maxEth ); liq = BondingCurve.Liquidity({ reserveToken: _inflatedTokenSupply, reserveEth: virtualEth, initialRealToken: _tokenSupply, initialInflatedToken: _inflatedTokenSupply, virtualEth: virtualEth, maxEth: maxEth, k: _inflatedTokenSupply * virtualEth }); } function buy( uint256 minOut ) external payable nonReentrant lockLiquidity returns (uint256 tokenAmount) { uint256 value = _takeEthFee(msg.value); tokenAmount = BondingCurve.getTokenOut(value, liq); if (tokenAmount < minOut) revert Pool_SlippageError(); liq.reserveEth += value; liq.reserveToken -= tokenAmount; IERC20(token).safeTransfer(msg.sender, tokenAmount); emit Bought(msg.value, tokenAmount, liq.reserveEth, liq.reserveToken); emit Sync(uint112(liq.reserveEth), uint112(liq.reserveToken)); emit Swap(msg.sender, msg.value, 0, 0, tokenAmount, msg.sender); } function buyTokenAmount( uint256 tokenAmount ) external payable nonReentrant lockLiquidity returns (uint256 ethAmount) { uint256 value = _takeEthFee(msg.value); ethAmount = BondingCurve.getEthIn(tokenAmount, liq); if (ethAmount > value) revert Pool_SlippageError(); liq.reserveEth += ethAmount; liq.reserveToken -= tokenAmount; IERC20(token).safeTransfer(msg.sender, tokenAmount); if (ethAmount < value) { payable(msg.sender).sendValue(value - ethAmount); } emit Bought(ethAmount, tokenAmount, liq.reserveEth, liq.reserveToken); emit Sync(uint112(liq.reserveEth), uint112(liq.reserveToken)); emit Swap(msg.sender, ethAmount, 0, 0, tokenAmount, msg.sender); } function sellTokenAmount( uint256 tokenAmount, uint256 minEth ) external nonReentrant lockLiquidity returns (uint256 ethAmount) { tokenAmount = _takeTokenFee(tokenAmount); ethAmount = BondingCurve.getEthOut(tokenAmount, liq); if (ethAmount < minEth) revert Pool_SlippageError(); liq.reserveEth -= ethAmount; liq.reserveToken += tokenAmount; IERC20(token).safeTransferFrom(msg.sender, address(this), tokenAmount); payable(msg.sender).sendValue(ethAmount); emit Sold(tokenAmount, ethAmount, liq.reserveEth, liq.reserveToken); emit Sync(uint112(liq.reserveEth), uint112(liq.reserveToken)); emit Swap(msg.sender, 0, tokenAmount, ethAmount, 0, msg.sender); } function sellEthAmount( uint256 ethAmount, uint256 maxToken ) external nonReentrant lockLiquidity returns (uint256 tokenAmount) { tokenAmount = BondingCurve.getTokenIn(ethAmount, liq); // add fee uint256 tokenAmountPlusFee = ((tokenAmount * BPS) / (BPS - FEE_BPS)) + 1; // 0.04% fee, rounding error if (tokenAmountPlusFee > maxToken) revert Pool_SlippageError(); tokenAmount = _takeTokenFee(tokenAmountPlusFee); liq.reserveEth -= ethAmount; liq.reserveToken += tokenAmount; IERC20(token).safeTransferFrom(msg.sender, address(this), tokenAmount); payable(msg.sender).sendValue(ethAmount); emit Sold(tokenAmount, ethAmount, liq.reserveEth, liq.reserveToken); emit Sync(uint112(liq.reserveEth), uint112(liq.reserveToken)); emit Swap(msg.sender, 0, tokenAmount, ethAmount, 0, msg.sender); } function _lockLiquidity() internal { // lock liquidity locked = true; payable(address(dexHandler)).sendValue(address(this).balance); IERC20(address(token)).safeTransfer( address(dexHandler), token.balanceOf(address(this)) ); BaseSonicToken(address(token)).onSaleEnd(); // allow adding liquidity dexHandler.handleLiquidity(address(token)); emit Locked(); } function getLiquidity() external view returns (BondingCurve.Liquidity memory) { return liq; } function _takeTokenFee( uint256 amount ) internal returns (uint256 amountWithFee) { uint256 fee = (amount * FEE_BPS) / BPS; token.safeTransferFrom(msg.sender, feeReceiver, fee); return amount - fee; } function _takeEthFee( uint256 amount ) internal returns (uint256 amountWithFee) { uint256 fee = (amount * FEE_BPS) / BPS; feeReceiver.sendValue(fee); return amount - fee; } function _paramsForStyle( Style style ) internal pure returns (uint256 virtualEth, uint256 maxEth) { if (style == Style.Moon) return (2500 ether, 10000 ether); if (style == Style.Balanced) return (7000 ether, 15000 ether); return (30000 ether, 50000 ether); } // uniswap compatibility function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) { return ( uint112(liq.reserveEth), uint112(liq.reserveToken), lastUpdateTime ); } function token0() external pure returns (address) { return WETH; } function token1() external view returns (address) { return address(token); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.13; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import {ERC20BurnableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol"; import {IDexHandler} from "./interfaces/IDexHandler.sol"; contract BaseSonicToken is Initializable, ERC20Upgradeable, ERC20BurnableUpgradeable // not upgradeable, just cloneable { address public WETH; enum DexType { UniV2, Solidly } error PoolingNotAllowed(); error Bad_Supply(); error Unauthorized(); address public pair; address public sonicPool; bool public allowAddLiquidity; constructor() { _disableInitializers(); } function initialize( string memory _name, string memory _decimals, address _sonicPool, address _dexHandler, uint256 _initialSupply, address rewardReceiver ) external initializer returns (uint256 reward) { if ( _initialSupply < 1e18 || _initialSupply > 100_000_000_000_000_000_000 ether ) revert Bad_Supply(); __ERC20_init(_name, _decimals); sonicPool = _sonicPool; pair = IDexHandler(_dexHandler).createPair(address(this)); // 1% vested to creator reward = _initialSupply / 100; _mint(rewardReceiver, reward); // creator fee _mint(_sonicPool, _initialSupply - reward); } function _update( address from, address to, uint256 value ) internal virtual override { if (!allowAddLiquidity && to == pair && from != sonicPool) revert PoolingNotAllowed(); super._update(from, to, value); } function onSaleEnd() external virtual { if (msg.sender != sonicPool) revert Unauthorized(); allowAddLiquidity = true; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.13; library BondingCurve { struct Liquidity { uint256 reserveEth; uint256 reserveToken; // inflated current reserve uint256 virtualEth; uint256 initialRealToken; // real reserve at the creation of the pool uint256 initialInflatedToken; // inflated reserve at the creation of the pool uint256 maxEth; uint256 k; } function _getAmountOut( uint256 amountIn, uint256 reserveIn, uint256 reserveOut, uint256 k ) internal pure returns (uint256) { uint256 newReserveOut = k / (reserveIn + amountIn); return reserveOut - newReserveOut; } function _getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut, uint256 k ) internal pure returns (uint256) { uint256 newReserveIn = k / (reserveOut - amountOut); return reserveIn - newReserveIn; } function getTokenOut( uint ethIn, Liquidity memory liq ) internal pure returns (uint256 tokenOut) { if (liq.reserveEth + ethIn > liq.maxEth) { // calculate amount out with inflated reserve up to maxEth uint256 ethInInflated = liq.maxEth - liq.reserveEth; uint256 curveOut = _getAmountOut( ethInInflated, liq.reserveEth, liq.reserveToken, liq.k ); // calculate remaining amount out with final reserves uint256 realEthLeft = liq.maxEth - liq.virtualEth; uint256 realTokenLeft = _getRealTokenLeft( liq.initialRealToken, liq.initialInflatedToken, liq.reserveToken - curveOut ); uint256 remainingOut = _getAmountOut( ethIn - ethInInflated, realEthLeft, realTokenLeft, realEthLeft * realTokenLeft ); tokenOut = curveOut + remainingOut; } else { tokenOut = _getAmountOut( ethIn, liq.reserveEth, liq.reserveToken, liq.k ); } } function getTokenIn( uint ethOut, Liquidity memory liq ) internal pure returns (uint256 tokenIn) { tokenIn = _getAmountIn(ethOut, liq.reserveToken, liq.reserveEth, liq.k); } function getEthOut( uint tokenIn, Liquidity memory liq ) internal pure returns (uint256 ethOut) { ethOut = _getAmountOut( tokenIn, liq.reserveToken, liq.reserveEth, liq.k ); } function getEthIn( uint tokenOut, Liquidity memory liq ) internal pure returns (uint256 ethIn) { ethIn = _getAmountIn(tokenOut, liq.reserveEth, liq.reserveToken, liq.k); if (ethIn + liq.reserveEth > liq.maxEth) { // calculate amount in with inflated reserve up to maxEth uint256 ethInInflated = liq.maxEth - liq.reserveEth; // get the tokenOut that can be bought with the inflated ethIn uint256 curveOut = _getAmountOut( ethInInflated, liq.reserveEth, liq.reserveToken, liq.k ); // calculate remaining amount in with final reserves uint256 realEthLeft = liq.maxEth - liq.virtualEth; uint256 realTokenLeft = _getRealTokenLeft( liq.initialRealToken, liq.initialInflatedToken, liq.reserveToken - curveOut ); uint256 remainingIn = _getAmountIn( tokenOut - curveOut, realEthLeft, realTokenLeft, realEthLeft * realTokenLeft ); ethIn = ethInInflated + remainingIn; } } function _getInflatedTokenSupply( uint256 tokenSupply, uint256 virtualEth, uint256 maxEth ) internal pure returns (uint256) { uint256 a = (maxEth * tokenSupply) / (2 * (maxEth + virtualEth)); uint256 b = (maxEth * tokenSupply) / (2 * (maxEth - virtualEth)); return a + b; } function _getRealTokenLeft( uint256 _initialRealToken, uint256 _initialInflatedToken, uint256 _reserveToken ) internal pure returns (uint256) { return _initialRealToken - (_initialInflatedToken - _reserveToken); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; interface IDexHandler { function handleLiquidity(address token) external; function createPair(address token) external returns (address); }
{ "evmVersion": "paris", "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BadUpgrade","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"FailedDeployment","type":"error"},{"inputs":[],"name":"FeeMismatch","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidParams","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OwnershipTransferFailed","type":"error"},{"inputs":[],"name":"UnauthorizedClaim","type":"error"},{"inputs":[],"name":"UnknownPoolType","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"maxSupply","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"pool","type":"address"},{"indexed":false,"internalType":"address","name":"dexHandler","type":"address"}],"name":"Launched","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":false,"internalType":"address","name":"token0","type":"address"},{"indexed":false,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"PairCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"LAUNCH_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allPairs","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allPairsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimLaunchTaxes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"dexHandlers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeToSetter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"getPair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getToken","outputs":[{"components":[{"internalType":"address","name":"instance","type":"address"},{"internalType":"address","name":"sonicPool","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint32","name":"poolType","type":"uint32"},{"internalType":"uint32","name":"tokenType","type":"uint32"},{"internalType":"uint32","name":"dexHandler","type":"uint32"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"maxSupply","type":"uint256"}],"internalType":"struct SonicPad.Token","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokenImpls","type":"address[]"},{"internalType":"address[]","name":"_poolImpls","type":"address[]"},{"internalType":"address[]","name":"_dexHandlers","type":"address[]"},{"internalType":"address","name":"_feeTo","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"bytes","name":"poolParams","type":"bytes"},{"internalType":"address","name":"rewardReceiver","type":"address"},{"internalType":"uint32","name":"poolType","type":"uint32"},{"internalType":"uint32","name":"tokenType","type":"uint32"},{"internalType":"uint32","name":"dexHandler","type":"uint32"}],"name":"launch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"pool","type":"address"}],"name":"launchPermissioned","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setLaunchFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"sonicPoolImplementations","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"togglePause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenImplementations","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenIndexes","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":"id","type":"uint256"},{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferTokenOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxSupply","type":"uint256"}],"name":"updateMaxSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Deployed Bytecode
0x60806040526004361061014f5760003560e01c806359ee64b8116100b6578063e4b50cb81161006f578063e4b50cb81461047e578063e6a43905146104bb578063e9048361146104f8578063e9cf64e61461050f578063f103b43314610538578063f2fde38b1461056157610156565b806359ee64b8146103805780635b76c04f146103bd5780635c975abb146103fa578063715018a6146104255780638da5cb5b1461043c578063c4ae31681461046757610156565b80631e3dd18b116101085780631e3dd18b1461026b57806321cfb0a3146102a857806332cb6b0c146102e557806350075654146103105780635313be2c1461032c578063574f2ba31461035557610156565b8063017e7e581461015b5780630434b9bf1461018657806304bc3b1c146101af57806309197a81146101ec578063094b7415146102175780631c1c30871461024257610156565b3661015657005b600080fd5b34801561016757600080fd5b5061017061058a565b60405161017d9190612a06565b60405180910390f35b34801561019257600080fd5b506101ad60048036038101906101a89190612bba565b6105b0565b005b3480156101bb57600080fd5b506101d660048036038101906101d19190612c75565b6106ca565b6040516101e39190612cbb565b60405180910390f35b3480156101f857600080fd5b506102016106e2565b60405161020e9190612cbb565b60405180910390f35b34801561022357600080fd5b5061022c6106e8565b6040516102399190612a06565b60405180910390f35b34801561024e57600080fd5b5061026960048036038101906102649190612cd6565b6106f7565b005b34801561027757600080fd5b50610292600480360381019061028d9190612d55565b610fa8565b60405161029f9190612a06565b60405180910390f35b3480156102b457600080fd5b506102cf60048036038101906102ca9190612d55565b610fe7565b6040516102dc9190612a06565b60405180910390f35b3480156102f157600080fd5b506102fa611026565b6040516103079190612cbb565b60405180910390f35b61032a60048036038101906103259190612f14565b61102c565b005b34801561033857600080fd5b50610353600480360381019061034e9190612d55565b6118dc565b005b34801561036157600080fd5b5061036a6119c0565b6040516103779190612cbb565b60405180910390f35b34801561038c57600080fd5b506103a760048036038101906103a29190612d55565b6119cd565b6040516103b49190612a06565b60405180910390f35b3480156103c957600080fd5b506103e460048036038101906103df9190612d55565b611a0c565b6040516103f19190612a06565b60405180910390f35b34801561040657600080fd5b5061040f611a4b565b60405161041c9190613039565b60405180910390f35b34801561043157600080fd5b5061043a611a70565b005b34801561044857600080fd5b50610451611bbc565b60405161045e9190612a06565b60405180910390f35b34801561047357600080fd5b5061047c611be5565b005b34801561048a57600080fd5b506104a560048036038101906104a09190612d55565b611c98565b6040516104b291906131cc565b60405180910390f35b3480156104c757600080fd5b506104e260048036038101906104dd91906131ee565b612044565b6040516104ef9190612a06565b60405180910390f35b34801561050457600080fd5b5061050d612086565b005b34801561051b57600080fd5b506105366004803603810190610531919061322e565b612146565b005b34801561054457600080fd5b5061055f600480360381019061055a9190612d55565b61229c565b005b34801561056d57600080fd5b5061058860048036038101906105839190612c75565b612334565b005b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461063e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610635906132cb565b60405180910390fd5b836001908051906020019061065492919061287e565b50826002908051906020019061066b92919061287e565b50816003908051906020019061068292919061287e565b5080600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050565b60056020528060005260406000206000915090505481565b60095481565b60006106f2611bbc565b905090565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610785576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077c906132cb565b60405180910390fd5b60046040518061012001604052808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff16815260200163ffffffff8016815260200163ffffffff8016815260200163ffffffff801681526020018473ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610856573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061087f919061335b565b81526020018473ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa1580156108cf573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906108f8919061335b565b81526020018473ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610948573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096c91906133b9565b815250908060018154018082558091505060019003906000526020600020906006020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060608201518160020160146101000a81548163ffffffff021916908363ffffffff16021790555060808201518160020160186101000a81548163ffffffff021916908363ffffffff16021790555060a082015181600201601c6101000a81548163ffffffff021916908363ffffffff16021790555060c0820151816003019081610af791906135f2565b5060e0820151816004019081610b0d91906135f2565b506101008201518160050155505060008173ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8c91906136d9565b90506001600480549050610ba09190613735565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506007829080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f823340a73ec9d52ba559acff3e287f7bf5e403bd11064fcf22e27921ba72dc53848473ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b8152600401600060405180830381865afa158015610e29573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610e52919061335b565b8573ffffffffffffffffffffffffffffffffffffffff166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610e9d573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610ec6919061335b565b8673ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f11573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3591906133b9565b87876000604051610f4c97969594939291906137a2565b60405180910390a17f0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e98184846001600480549050610f8a9190613735565b604051610f9a949392919061381f565b60405180910390a150505050565b60078181548110610fb857600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028181548110610ff757600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600a5481565b6110346124ee565b600954341461106f576040517f36a9d01100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080600060038463ffffffff168154811061108e5761108d613864565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600060018663ffffffff16815481106110d7576110d6613864565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600060028863ffffffff16815481106111205761111f613864565b5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614806111b45750600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b806111eb5750600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611222576040517fa86b651200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61122b8261252f565b94506112368161252f565b935050508273ffffffffffffffffffffffffffffffffffffffff1663db0e45448b8b8585600a548d6040518763ffffffff1660e01b815260040161127f96959493929190613893565b6020604051808303816000875af115801561129e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c291906133b9565b5060046040518061012001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1681526020018d73ffffffffffffffffffffffffffffffffffffffff1681526020018863ffffffff1681526020018763ffffffff1681526020018663ffffffff1681526020018c81526020018b8152602001600a54815250908060018154018082558091505060019003906000526020600020906006020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060608201518160020160146101000a81548163ffffffff021916908363ffffffff16021790555060808201518160020160186101000a81548163ffffffff021916908363ffffffff16021790555060a082015181600201601c6101000a81548163ffffffff021916908363ffffffff16021790555060c08201518160030190816114e391906135f2565b5060e08201518160040190816114f991906135f2565b506101008201518160050155505060016004805490506115199190613735565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008273ffffffffffffffffffffffffffffffffffffffff16630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115cd91906136d9565b905082600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506007839080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508273ffffffffffffffffffffffffffffffffffffffff1663246581f785600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16858d6040518563ffffffff1660e01b81526004016118099493929190613957565b600060405180830381600087803b15801561182357600080fd5b505af1158015611837573d6000803e3d6000fd5b505050507f823340a73ec9d52ba559acff3e287f7bf5e403bd11064fcf22e27921ba72dc538c8c8c600a5488888860405161187897969594939291906137a2565b60405180910390a17f0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e981858560016004805490506118b69190613735565b6040516118c6949392919061381f565b60405180910390a1505050505050505050505050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461196a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611961906132cb565b60405180910390fd5b68056bc75e2d631000008111156119b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119ad906139ef565b60405180910390fd5b8060098190555050565b6000600480549050905090565b600381815481106119dd57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60018181548110611a1c57600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080611a56612543565b90508060000160009054906101000a900460ff1691505090565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611afe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611af5906132cb565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611c73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c6a906132cb565b60405180910390fd5b611c7b611a4b565b15611c8d57611c8861256b565b611c96565b611c956125dd565b5b565b611ca0612908565b6004805490508210611d6c57604051806101200160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff1681526020016040518060200160405280600081525081526020016040518060200160405280600081525081526020016000815250905061203f565b60048281548110611d8057611d7f613864565b5b9060005260206000209060060201604051806101200160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820160149054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016002820160189054906101000a900463ffffffff1663ffffffff1663ffffffff16815260200160028201601c9054906101000a900463ffffffff1663ffffffff1663ffffffff168152602001600382018054611f1e90613415565b80601f0160208091040260200160405190810160405280929190818152602001828054611f4a90613415565b8015611f975780601f10611f6c57610100808354040283529160200191611f97565b820191906000526020600020905b815481529060010190602001808311611f7a57829003601f168201915b50505050508152602001600482018054611fb090613415565b80601f0160208091040260200160405190810160405280929190818152602001828054611fdc90613415565b80156120295780601f10611ffe57610100808354040283529160200191612029565b820191906000526020600020905b81548152906001019060200180831161200c57829003601f168201915b5050505050815260200160058201548152505090505b919050565b60066020528160005260406000206020528060005260406000206000915091509054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612114576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161210b906132cb565b60405180910390fd5b61214447612120611bbc565b73ffffffffffffffffffffffffffffffffffffffff1661264f90919063ffffffff16565b565b6004805490508210612184576040517f65cca54900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16600483815481106121af576121ae613864565b5b906000526020600020906006020160020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461222e576040517f65cca54900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006004838154811061224457612243613864565b5b90600052602060002090600602019050818160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461232a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612321906132cb565b60405180910390fd5b80600a8190555050565b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146123c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123b9906132cb565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612431576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161242890613a81565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6124f6611a4b565b1561252d576040517fd93c066500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b600061253c82600061273e565b9050919050565b60007fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300905090565b612573612836565b600061257d612543565b905060008160000160006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6125c5612876565b6040516125d29190612a06565b60405180910390a150565b6125e56124ee565b60006125ef612543565b905060018160000160006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612637612876565b6040516126449190612a06565b60405180910390a150565b804710156126965747816040517fcf47918100000000000000000000000000000000000000000000000000000000815260040161268d929190613aa1565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff16826040516126bc90613afb565b60006040518083038185875af1925050503d80600081146126f9576040519150601f19603f3d011682016040523d82523d6000602084013e6126fe565b606091505b5050905080612739576040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050565b6000814710156127875747826040517fcf47918100000000000000000000000000000000000000000000000000000000815260040161277e929190613aa1565b60405180910390fd5b763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b176020526037600983f09050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603612830576040517fb06ebf3d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b92915050565b61283e611a4b565b612874576040517f8dfc202b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b565b600033905090565b8280548282559060005260206000209081019282156128f7579160200282015b828111156128f65782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509160200191906001019061289e565b5b50905061290491906129a8565b5090565b604051806101200160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600063ffffffff168152602001600063ffffffff168152602001600063ffffffff1681526020016060815260200160608152602001600081525090565b5b808211156129c15760008160009055506001016129a9565b5090565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006129f0826129c5565b9050919050565b612a00816129e5565b82525050565b6000602082019050612a1b60008301846129f7565b92915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612a8382612a3a565b810181811067ffffffffffffffff82111715612aa257612aa1612a4b565b5b80604052505050565b6000612ab5612a21565b9050612ac18282612a7a565b919050565b600067ffffffffffffffff821115612ae157612ae0612a4b565b5b602082029050602081019050919050565b600080fd5b612b00816129e5565b8114612b0b57600080fd5b50565b600081359050612b1d81612af7565b92915050565b6000612b36612b3184612ac6565b612aab565b90508083825260208201905060208402830185811115612b5957612b58612af2565b5b835b81811015612b825780612b6e8882612b0e565b845260208401935050602081019050612b5b565b5050509392505050565b600082601f830112612ba157612ba0612a35565b5b8135612bb1848260208601612b23565b91505092915050565b60008060008060808587031215612bd457612bd3612a2b565b5b600085013567ffffffffffffffff811115612bf257612bf1612a30565b5b612bfe87828801612b8c565b945050602085013567ffffffffffffffff811115612c1f57612c1e612a30565b5b612c2b87828801612b8c565b935050604085013567ffffffffffffffff811115612c4c57612c4b612a30565b5b612c5887828801612b8c565b9250506060612c6987828801612b0e565b91505092959194509250565b600060208284031215612c8b57612c8a612a2b565b5b6000612c9984828501612b0e565b91505092915050565b6000819050919050565b612cb581612ca2565b82525050565b6000602082019050612cd06000830184612cac565b92915050565b600080600060608486031215612cef57612cee612a2b565b5b6000612cfd86828701612b0e565b9350506020612d0e86828701612b0e565b9250506040612d1f86828701612b0e565b9150509250925092565b612d3281612ca2565b8114612d3d57600080fd5b50565b600081359050612d4f81612d29565b92915050565b600060208284031215612d6b57612d6a612a2b565b5b6000612d7984828501612d40565b91505092915050565b600080fd5b600067ffffffffffffffff821115612da257612da1612a4b565b5b612dab82612a3a565b9050602081019050919050565b82818337600083830152505050565b6000612dda612dd584612d87565b612aab565b905082815260208101848484011115612df657612df5612d82565b5b612e01848285612db8565b509392505050565b600082601f830112612e1e57612e1d612a35565b5b8135612e2e848260208601612dc7565b91505092915050565b600067ffffffffffffffff821115612e5257612e51612a4b565b5b612e5b82612a3a565b9050602081019050919050565b6000612e7b612e7684612e37565b612aab565b905082815260208101848484011115612e9757612e96612d82565b5b612ea2848285612db8565b509392505050565b600082601f830112612ebf57612ebe612a35565b5b8135612ecf848260208601612e68565b91505092915050565b600063ffffffff82169050919050565b612ef181612ed8565b8114612efc57600080fd5b50565b600081359050612f0e81612ee8565b92915050565b600080600080600080600080610100898b031215612f3557612f34612a2b565b5b6000612f438b828c01612b0e565b985050602089013567ffffffffffffffff811115612f6457612f63612a30565b5b612f708b828c01612e09565b975050604089013567ffffffffffffffff811115612f9157612f90612a30565b5b612f9d8b828c01612e09565b965050606089013567ffffffffffffffff811115612fbe57612fbd612a30565b5b612fca8b828c01612eaa565b9550506080612fdb8b828c01612b0e565b94505060a0612fec8b828c01612eff565b93505060c0612ffd8b828c01612eff565b92505060e061300e8b828c01612eff565b9150509295985092959890939650565b60008115159050919050565b6130338161301e565b82525050565b600060208201905061304e600083018461302a565b92915050565b61305d816129e5565b82525050565b61306c81612ed8565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b838110156130ac578082015181840152602081019050613091565b60008484015250505050565b60006130c382613072565b6130cd818561307d565b93506130dd81856020860161308e565b6130e681612a3a565b840191505092915050565b6130fa81612ca2565b82525050565b6000610120830160008301516131196000860182613054565b50602083015161312c6020860182613054565b50604083015161313f6040860182613054565b5060608301516131526060860182613063565b5060808301516131656080860182613063565b5060a083015161317860a0860182613063565b5060c083015184820360c086015261319082826130b8565b91505060e083015184820360e08601526131aa82826130b8565b9150506101008301516131c16101008601826130f1565b508091505092915050565b600060208201905081810360008301526131e68184613100565b905092915050565b6000806040838503121561320557613204612a2b565b5b600061321385828601612b0e565b925050602061322485828601612b0e565b9150509250929050565b6000806040838503121561324557613244612a2b565b5b600061325385828601612d40565b925050602061326485828601612b0e565b9150509250929050565b600082825260208201905092915050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b60006132b560208361326e565b91506132c08261327f565b602082019050919050565b600060208201905081810360008301526132e4816132a8565b9050919050565b60006132fe6132f984612d87565b612aab565b90508281526020810184848401111561331a57613319612d82565b5b61332584828561308e565b509392505050565b600082601f83011261334257613341612a35565b5b81516133528482602086016132eb565b91505092915050565b60006020828403121561337157613370612a2b565b5b600082015167ffffffffffffffff81111561338f5761338e612a30565b5b61339b8482850161332d565b91505092915050565b6000815190506133b381612d29565b92915050565b6000602082840312156133cf576133ce612a2b565b5b60006133dd848285016133a4565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061342d57607f821691505b6020821081036134405761343f6133e6565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026134a87fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261346b565b6134b2868361346b565b95508019841693508086168417925050509392505050565b6000819050919050565b60006134ef6134ea6134e584612ca2565b6134ca565b612ca2565b9050919050565b6000819050919050565b613509836134d4565b61351d613515826134f6565b848454613478565b825550505050565b600090565b613532613525565b61353d818484613500565b505050565b5b818110156135615761355660008261352a565b600181019050613543565b5050565b601f8211156135a65761357781613446565b6135808461345b565b8101602085101561358f578190505b6135a361359b8561345b565b830182613542565b50505b505050565b600082821c905092915050565b60006135c9600019846008026135ab565b1980831691505092915050565b60006135e283836135b8565b9150826002028217905092915050565b6135fb82613072565b67ffffffffffffffff81111561361457613613612a4b565b5b61361e8254613415565b613629828285613565565b600060209050601f83116001811461365c576000841561364a578287015190505b61365485826135d6565b8655506136bc565b601f19841661366a86613446565b60005b828110156136925784890151825560018201915060208501945060208101905061366d565b868310156136af57848901516136ab601f8916826135b8565b8355505b6001600288020188555050505b505050505050565b6000815190506136d381612af7565b92915050565b6000602082840312156136ef576136ee612a2b565b5b60006136fd848285016136c4565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061374082612ca2565b915061374b83612ca2565b925082820390508181111561376357613762613706565b5b92915050565b600061377482613072565b61377e818561326e565b935061378e81856020860161308e565b61379781612a3a565b840191505092915050565b600060e0820190506137b7600083018a6129f7565b81810360208301526137c98189613769565b905081810360408301526137dd8188613769565b90506137ec6060830187612cac565b6137f960808301866129f7565b61380660a08301856129f7565b61381360c08301846129f7565b98975050505050505050565b600060808201905061383460008301876129f7565b61384160208301866129f7565b61384e60408301856129f7565b61385b6060830184612cac565b95945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060c08201905081810360008301526138ad8189613769565b905081810360208301526138c18188613769565b90506138d060408301876129f7565b6138dd60608301866129f7565b6138ea6080830185612cac565b6138f760a08301846129f7565b979650505050505050565b600081519050919050565b600082825260208201905092915050565b600061392982613902565b613933818561390d565b935061394381856020860161308e565b61394c81612a3a565b840191505092915050565b600060808201905061396c60008301876129f7565b61397960208301866129f7565b61398660408301856129f7565b8181036060830152613998818461391e565b905095945050505050565b7f66656520746f6f20686967680000000000000000000000000000000000000000600082015250565b60006139d9600c8361326e565b91506139e4826139a3565b602082019050919050565b60006020820190508181036000830152613a08816139cc565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000613a6b60268361326e565b9150613a7682613a0f565b604082019050919050565b60006020820190508181036000830152613a9a81613a5e565b9050919050565b6000604082019050613ab66000830185612cac565b613ac36020830184612cac565b9392505050565b600081905092915050565b50565b6000613ae5600083613aca565b9150613af082613ad5565b600082019050919050565b6000613b0682613ad8565b915081905091905056fea2646970667358221220637c903dc329ddd63747f3b8fac2f79ecab39ecc08771a93e3cfdb8e80d0fde364736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.