Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
EqualizerHandler
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 {IDexHandler} from "./interfaces/IDexHandler.sol"; import {ISolidlyRouter} from "./interfaces/ISolidlyRouter.sol"; import {ISolidlyFactory} from "./interfaces/ISolidlyFactory.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {SonicPad} from "./SonicPad.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; struct Referral { address agent; uint percent; } interface ILocker { function createLockWithReferralFor( address _lp, uint _amt, uint _exp, address _to, Referral memory _ref ) external returns (address _locker, uint _ID); } contract EqualizerHandler is IDexHandler, Ownable { using SafeERC20 for IERC20; ISolidlyRouter constant router = ISolidlyRouter(0xcC6169aA1E879d3a4227536671F85afdb2d23fAD); ISolidlyFactory constant factory = ISolidlyFactory(0xDDD9845Ba0D8f38d3045f804f67A1a8B9A528FcC); ILocker constant locker = ILocker(0x4Eb733172B17F0eA9d5620aDAd62B5072eBd739b); address constant WETH = address(0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38); address public referrer; address public sonicCouncil; mapping(address => address) public lockerForToken; mapping(address => uint) public lockerIdForToken; bool public releaseToCouncil = false; SonicPad sonicPad; constructor(SonicPad _sonicPad) Ownable(msg.sender) { sonicPad = _sonicPad; referrer = address(msg.sender); sonicCouncil = address(msg.sender); } receive() external payable {} function handleLiquidity(address token) external { IERC20(token).approve( address(router), IERC20(token).balanceOf(address(this)) ); (, , uint amount) = router.addLiquidityETH{ value: address(this).balance }( address(token), false, IERC20(token).balanceOf(address(this)), 0, 0, address(this), // keep the LP tokens block.timestamp ); uint256 tokenId = sonicPad.tokenIndexes(address(token)); address owner = sonicPad.getToken(tokenId).owner; address lp = factory.getPair(address(token), router.weth(), false); IERC20(lp).approve(address(locker), amount); Referral memory referral = Referral(referrer, 0.1 ether); address lockOwner = releaseToCouncil ? address(sonicCouncil) : owner; uint256 releaseTime = releaseToCouncil ? block.timestamp + 30 days : type(uint256).max; (address _lockerAddress, uint256 _lockerId) = locker .createLockWithReferralFor( lp, amount, releaseTime, lockOwner, referral ); lockerForToken[token] = _lockerAddress; lockerIdForToken[token] = _lockerId; } function createPair(address token) external returns (address) { return factory.createPair(token, WETH, false); } function setReleaseToCouncil(bool _releaseToCouncil) external onlyOwner { releaseToCouncil = _releaseToCouncil; } function updateSonic(SonicPad _sonicPad) external onlyOwner { sonicPad = _sonicPad; } function updateReferrer(address _referrer) external onlyOwner { referrer = _referrer; } function updateSonicCouncil(address _sonicCouncil) external onlyOwner { sonicCouncil = _sonicCouncil; } }
// 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.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// 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.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/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(0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38); 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); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; interface ISolidlyFactory { function createPair( address tokenA, address tokenB, bool stable ) external returns (address pair); function getPair( address tokenA, address tokenB, bool stable ) external view returns (address pair); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; interface ISolidlyRouter { struct Route { address from; address to; bool stable; } function addLiquidityETH( address token, bool stable, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function swapExactTokensForETH( uint amountIn, uint amountOutMin, Route[] calldata routes, address to, uint deadline ) external returns (uint[] memory amounts); function weth() external view returns (address); }
// 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(); } }
{ "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":[{"internalType":"contract SonicPad","name":"_sonicPad","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"createPair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"handleLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lockerForToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lockerIdForToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referrer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"releaseToCouncil","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_releaseToCouncil","type":"bool"}],"name":"setReleaseToCouncil","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sonicCouncil","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_referrer","type":"address"}],"name":"updateReferrer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract SonicPad","name":"_sonicPad","type":"address"}],"name":"updateSonic","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sonicCouncil","type":"address"}],"name":"updateSonicCouncil","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040526000600560006101000a81548160ff02191690831515021790555034801561002b57600080fd5b50604051611b64380380611b64833981810160405281019061004d91906102d2565b33600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036100c05760006040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016100b79190610320565b60405180910390fd5b6100cf8161019960201b60201c565b5080600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555033600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505061033b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061028d82610262565b9050919050565b600061029f82610282565b9050919050565b6102af81610294565b81146102ba57600080fd5b50565b6000815190506102cc816102a6565b92915050565b6000602082840312156102e8576102e761025d565b5b60006102f6848285016102bd565b91505092915050565b600061030a82610262565b9050919050565b61031a816102ff565b82525050565b60006020820190506103356000830184610311565b92915050565b61181a8061034a6000396000f3fe6080604052600436106100e15760003560e01c80637561a46d1161007f5780639ccb0744116100595780639ccb0744146102a5578063e1f3b2e2146102e2578063ebd2c7d91461030b578063f2fde38b14610334576100e8565b80637561a46d146102285780638558510e146102515780638da5cb5b1461027a576100e8565b806350551323116100bb578063505513231461019257806368447c93146101bd578063705e6bc1146101e8578063715018a614610211576100e8565b80631407d18b146100ed5780632e2dde121461012a5780634a7ca0a114610167576100e8565b366100e857005b600080fd5b3480156100f957600080fd5b50610114600480360381019061010f9190610fbe565b61035d565b6040516101219190611004565b60405180910390f35b34801561013657600080fd5b50610151600480360381019061014c9190610fbe565b610375565b60405161015e919061102e565b60405180910390f35b34801561017357600080fd5b5061017c6103a8565b604051610189919061102e565b60405180910390f35b34801561019e57600080fd5b506101a76103ce565b6040516101b49190611064565b60405180910390f35b3480156101c957600080fd5b506101d26103e1565b6040516101df919061102e565b60405180910390f35b3480156101f457600080fd5b5061020f600480360381019061020a91906110cf565b610407565b005b34801561021d57600080fd5b50610226610453565b005b34801561023457600080fd5b5061024f600480360381019061024a9190610fbe565b610467565b005b34801561025d57600080fd5b5061027860048036038101906102739190611128565b610bdb565b005b34801561028657600080fd5b5061028f610c00565b60405161029c919061102e565b60405180910390f35b3480156102b157600080fd5b506102cc60048036038101906102c79190610fbe565b610c29565b6040516102d9919061102e565b60405180910390f35b3480156102ee57600080fd5b5061030960048036038101906103049190610fbe565b610cdb565b005b34801561031757600080fd5b50610332600480360381019061032d9190610fbe565b610d27565b005b34801561034057600080fd5b5061035b60048036038101906103569190610fbe565b610d73565b005b60046020528060005260406000206000915090505481565b60036020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900460ff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61040f610df9565b80600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61045b610df9565b6104656000610e80565b565b8073ffffffffffffffffffffffffffffffffffffffff1663095ea7b373cc6169aa1e879d3a4227536671f85afdb2d23fad8373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016104d1919061102e565b602060405180830381865afa1580156104ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105129190611181565b6040518363ffffffff1660e01b815260040161052f9291906111ae565b6020604051808303816000875af115801561054e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057291906111ec565b50600073cc6169aa1e879d3a4227536671f85afdb2d23fad73ffffffffffffffffffffffffffffffffffffffff1663b7e0d4c0478460008673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016105e2919061102e565b602060405180830381865afa1580156105ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106239190611181565b60008030426040518963ffffffff1660e01b815260040161064a979695949392919061125e565b60606040518083038185885af1158015610668573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061068d91906112cd565b925050506000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166304bc3b1c846040518263ffffffff1660e01b81526004016106ee919061102e565b602060405180830381865afa15801561070b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072f9190611181565b90506000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e4b50cb8836040518263ffffffff1660e01b815260040161078e9190611004565b600060405180830381865afa1580156107ab573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906107d491906115f4565b604001519050600073ddd9845ba0d8f38d3045f804f67a1a8b9a528fcc73ffffffffffffffffffffffffffffffffffffffff16636801cc308673cc6169aa1e879d3a4227536671f85afdb2d23fad73ffffffffffffffffffffffffffffffffffffffff16633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561086c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610890919061163d565b60006040518463ffffffff1660e01b81526004016108b09392919061166a565b602060405180830381865afa1580156108cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f1919061163d565b90508073ffffffffffffffffffffffffffffffffffffffff1663095ea7b3734eb733172b17f0ea9d5620adad62b5072ebd739b866040518363ffffffff1660e01b81526004016109429291906111ae565b6020604051808303816000875af1158015610961573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098591906111ec565b5060006040518060400160405280600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200167016345785d8a000081525090506000600560009054906101000a900460ff166109fb5783610a1f565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff165b90506000600560009054906101000a900460ff16610a5d577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610a6d565b62278d0042610a6c91906116d0565b5b9050600080734eb733172b17f0ea9d5620adad62b5072ebd739b73ffffffffffffffffffffffffffffffffffffffff1663f6e4db6b878b86888a6040518663ffffffff1660e01b8152600401610ac7959493929190611751565b60408051808303816000875af1158015610ae5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0991906117a4565b9150915081600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050505050505050505050565b610be3610df9565b80600560006101000a81548160ff02191690831515021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600073ddd9845ba0d8f38d3045f804f67a1a8b9a528fcc73ffffffffffffffffffffffffffffffffffffffff166382dfdce48373039e2fb66102314ce7b64ce5ce3e5183bc94ad3860006040518463ffffffff1660e01b8152600401610c919392919061166a565b6020604051808303816000875af1158015610cb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd4919061163d565b9050919050565b610ce3610df9565b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610d2f610df9565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610d7b610df9565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610ded5760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610de4919061102e565b60405180910390fd5b610df681610e80565b50565b610e01610f44565b73ffffffffffffffffffffffffffffffffffffffff16610e1f610c00565b73ffffffffffffffffffffffffffffffffffffffff1614610e7e57610e42610f44565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610e75919061102e565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610f8b82610f60565b9050919050565b610f9b81610f80565b8114610fa657600080fd5b50565b600081359050610fb881610f92565b92915050565b600060208284031215610fd457610fd3610f56565b5b6000610fe284828501610fa9565b91505092915050565b6000819050919050565b610ffe81610feb565b82525050565b60006020820190506110196000830184610ff5565b92915050565b61102881610f80565b82525050565b6000602082019050611043600083018461101f565b92915050565b60008115159050919050565b61105e81611049565b82525050565b60006020820190506110796000830184611055565b92915050565b600061108a82610f60565b9050919050565b600061109c8261107f565b9050919050565b6110ac81611091565b81146110b757600080fd5b50565b6000813590506110c9816110a3565b92915050565b6000602082840312156110e5576110e4610f56565b5b60006110f3848285016110ba565b91505092915050565b61110581611049565b811461111057600080fd5b50565b600081359050611122816110fc565b92915050565b60006020828403121561113e5761113d610f56565b5b600061114c84828501611113565b91505092915050565b61115e81610feb565b811461116957600080fd5b50565b60008151905061117b81611155565b92915050565b60006020828403121561119757611196610f56565b5b60006111a58482850161116c565b91505092915050565b60006040820190506111c3600083018561101f565b6111d06020830184610ff5565b9392505050565b6000815190506111e6816110fc565b92915050565b60006020828403121561120257611201610f56565b5b6000611210848285016111d7565b91505092915050565b6000819050919050565b6000819050919050565b600061124861124361123e84611219565b611223565b610feb565b9050919050565b6112588161122d565b82525050565b600060e082019050611273600083018a61101f565b6112806020830189611055565b61128d6040830188610ff5565b61129a606083018761124f565b6112a7608083018661124f565b6112b460a083018561101f565b6112c160c0830184610ff5565b98975050505050505050565b6000806000606084860312156112e6576112e5610f56565b5b60006112f48682870161116c565b93505060206113058682870161116c565b92505060406113168682870161116c565b9150509250925092565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61136e82611325565b810181811067ffffffffffffffff8211171561138d5761138c611336565b5b80604052505050565b60006113a0610f4c565b90506113ac8282611365565b919050565b600080fd5b6000815190506113c581610f92565b92915050565b600063ffffffff82169050919050565b6113e4816113cb565b81146113ef57600080fd5b50565b600081519050611401816113db565b92915050565b600080fd5b600080fd5b600067ffffffffffffffff82111561142c5761142b611336565b5b61143582611325565b9050602081019050919050565b60005b83811015611460578082015181840152602081019050611445565b60008484015250505050565b600061147f61147a84611411565b611396565b90508281526020810184848401111561149b5761149a61140c565b5b6114a6848285611442565b509392505050565b600082601f8301126114c3576114c2611407565b5b81516114d384826020860161146c565b91505092915050565b600061012082840312156114f3576114f2611320565b5b6114fe610120611396565b9050600061150e848285016113b6565b6000830152506020611522848285016113b6565b6020830152506040611536848285016113b6565b604083015250606061154a848285016113f2565b606083015250608061155e848285016113f2565b60808301525060a0611572848285016113f2565b60a08301525060c082015167ffffffffffffffff811115611596576115956113b1565b5b6115a2848285016114ae565b60c08301525060e082015167ffffffffffffffff8111156115c6576115c56113b1565b5b6115d2848285016114ae565b60e0830152506101006115e78482850161116c565b6101008301525092915050565b60006020828403121561160a57611609610f56565b5b600082015167ffffffffffffffff81111561162857611627610f5b565b5b611634848285016114dc565b91505092915050565b60006020828403121561165357611652610f56565b5b6000611661848285016113b6565b91505092915050565b600060608201905061167f600083018661101f565b61168c602083018561101f565b6116996040830184611055565b949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006116db82610feb565b91506116e683610feb565b92508282019050808211156116fe576116fd6116a1565b5b92915050565b61170d81610f80565b82525050565b61171c81610feb565b82525050565b6040820160008201516117386000850182611704565b50602082015161174b6020850182611713565b50505050565b600060c082019050611766600083018861101f565b6117736020830187610ff5565b6117806040830186610ff5565b61178d606083018561101f565b61179a6080830184611722565b9695505050505050565b600080604083850312156117bb576117ba610f56565b5b60006117c9858286016113b6565b92505060206117da8582860161116c565b915050925092905056fea26469706673582212202779eee7de590105aade1478319b6229802342d0c4f8ee25894c4eea59b99f0264736f6c634300081c00330000000000000000000000001d624c56cf0c108350e1bc1d62912acf4d800fef
Deployed Bytecode
0x6080604052600436106100e15760003560e01c80637561a46d1161007f5780639ccb0744116100595780639ccb0744146102a5578063e1f3b2e2146102e2578063ebd2c7d91461030b578063f2fde38b14610334576100e8565b80637561a46d146102285780638558510e146102515780638da5cb5b1461027a576100e8565b806350551323116100bb578063505513231461019257806368447c93146101bd578063705e6bc1146101e8578063715018a614610211576100e8565b80631407d18b146100ed5780632e2dde121461012a5780634a7ca0a114610167576100e8565b366100e857005b600080fd5b3480156100f957600080fd5b50610114600480360381019061010f9190610fbe565b61035d565b6040516101219190611004565b60405180910390f35b34801561013657600080fd5b50610151600480360381019061014c9190610fbe565b610375565b60405161015e919061102e565b60405180910390f35b34801561017357600080fd5b5061017c6103a8565b604051610189919061102e565b60405180910390f35b34801561019e57600080fd5b506101a76103ce565b6040516101b49190611064565b60405180910390f35b3480156101c957600080fd5b506101d26103e1565b6040516101df919061102e565b60405180910390f35b3480156101f457600080fd5b5061020f600480360381019061020a91906110cf565b610407565b005b34801561021d57600080fd5b50610226610453565b005b34801561023457600080fd5b5061024f600480360381019061024a9190610fbe565b610467565b005b34801561025d57600080fd5b5061027860048036038101906102739190611128565b610bdb565b005b34801561028657600080fd5b5061028f610c00565b60405161029c919061102e565b60405180910390f35b3480156102b157600080fd5b506102cc60048036038101906102c79190610fbe565b610c29565b6040516102d9919061102e565b60405180910390f35b3480156102ee57600080fd5b5061030960048036038101906103049190610fbe565b610cdb565b005b34801561031757600080fd5b50610332600480360381019061032d9190610fbe565b610d27565b005b34801561034057600080fd5b5061035b60048036038101906103569190610fbe565b610d73565b005b60046020528060005260406000206000915090505481565b60036020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900460ff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61040f610df9565b80600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61045b610df9565b6104656000610e80565b565b8073ffffffffffffffffffffffffffffffffffffffff1663095ea7b373cc6169aa1e879d3a4227536671f85afdb2d23fad8373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016104d1919061102e565b602060405180830381865afa1580156104ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105129190611181565b6040518363ffffffff1660e01b815260040161052f9291906111ae565b6020604051808303816000875af115801561054e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057291906111ec565b50600073cc6169aa1e879d3a4227536671f85afdb2d23fad73ffffffffffffffffffffffffffffffffffffffff1663b7e0d4c0478460008673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016105e2919061102e565b602060405180830381865afa1580156105ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106239190611181565b60008030426040518963ffffffff1660e01b815260040161064a979695949392919061125e565b60606040518083038185885af1158015610668573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061068d91906112cd565b925050506000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166304bc3b1c846040518263ffffffff1660e01b81526004016106ee919061102e565b602060405180830381865afa15801561070b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072f9190611181565b90506000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e4b50cb8836040518263ffffffff1660e01b815260040161078e9190611004565b600060405180830381865afa1580156107ab573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906107d491906115f4565b604001519050600073ddd9845ba0d8f38d3045f804f67a1a8b9a528fcc73ffffffffffffffffffffffffffffffffffffffff16636801cc308673cc6169aa1e879d3a4227536671f85afdb2d23fad73ffffffffffffffffffffffffffffffffffffffff16633fc8cef36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561086c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610890919061163d565b60006040518463ffffffff1660e01b81526004016108b09392919061166a565b602060405180830381865afa1580156108cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f1919061163d565b90508073ffffffffffffffffffffffffffffffffffffffff1663095ea7b3734eb733172b17f0ea9d5620adad62b5072ebd739b866040518363ffffffff1660e01b81526004016109429291906111ae565b6020604051808303816000875af1158015610961573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098591906111ec565b5060006040518060400160405280600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200167016345785d8a000081525090506000600560009054906101000a900460ff166109fb5783610a1f565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff165b90506000600560009054906101000a900460ff16610a5d577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610a6d565b62278d0042610a6c91906116d0565b5b9050600080734eb733172b17f0ea9d5620adad62b5072ebd739b73ffffffffffffffffffffffffffffffffffffffff1663f6e4db6b878b86888a6040518663ffffffff1660e01b8152600401610ac7959493929190611751565b60408051808303816000875af1158015610ae5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0991906117a4565b9150915081600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600460008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050505050505050505050565b610be3610df9565b80600560006101000a81548160ff02191690831515021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600073ddd9845ba0d8f38d3045f804f67a1a8b9a528fcc73ffffffffffffffffffffffffffffffffffffffff166382dfdce48373039e2fb66102314ce7b64ce5ce3e5183bc94ad3860006040518463ffffffff1660e01b8152600401610c919392919061166a565b6020604051808303816000875af1158015610cb0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd4919061163d565b9050919050565b610ce3610df9565b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610d2f610df9565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b610d7b610df9565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610ded5760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610de4919061102e565b60405180910390fd5b610df681610e80565b50565b610e01610f44565b73ffffffffffffffffffffffffffffffffffffffff16610e1f610c00565b73ffffffffffffffffffffffffffffffffffffffff1614610e7e57610e42610f44565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610e75919061102e565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610f8b82610f60565b9050919050565b610f9b81610f80565b8114610fa657600080fd5b50565b600081359050610fb881610f92565b92915050565b600060208284031215610fd457610fd3610f56565b5b6000610fe284828501610fa9565b91505092915050565b6000819050919050565b610ffe81610feb565b82525050565b60006020820190506110196000830184610ff5565b92915050565b61102881610f80565b82525050565b6000602082019050611043600083018461101f565b92915050565b60008115159050919050565b61105e81611049565b82525050565b60006020820190506110796000830184611055565b92915050565b600061108a82610f60565b9050919050565b600061109c8261107f565b9050919050565b6110ac81611091565b81146110b757600080fd5b50565b6000813590506110c9816110a3565b92915050565b6000602082840312156110e5576110e4610f56565b5b60006110f3848285016110ba565b91505092915050565b61110581611049565b811461111057600080fd5b50565b600081359050611122816110fc565b92915050565b60006020828403121561113e5761113d610f56565b5b600061114c84828501611113565b91505092915050565b61115e81610feb565b811461116957600080fd5b50565b60008151905061117b81611155565b92915050565b60006020828403121561119757611196610f56565b5b60006111a58482850161116c565b91505092915050565b60006040820190506111c3600083018561101f565b6111d06020830184610ff5565b9392505050565b6000815190506111e6816110fc565b92915050565b60006020828403121561120257611201610f56565b5b6000611210848285016111d7565b91505092915050565b6000819050919050565b6000819050919050565b600061124861124361123e84611219565b611223565b610feb565b9050919050565b6112588161122d565b82525050565b600060e082019050611273600083018a61101f565b6112806020830189611055565b61128d6040830188610ff5565b61129a606083018761124f565b6112a7608083018661124f565b6112b460a083018561101f565b6112c160c0830184610ff5565b98975050505050505050565b6000806000606084860312156112e6576112e5610f56565b5b60006112f48682870161116c565b93505060206113058682870161116c565b92505060406113168682870161116c565b9150509250925092565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61136e82611325565b810181811067ffffffffffffffff8211171561138d5761138c611336565b5b80604052505050565b60006113a0610f4c565b90506113ac8282611365565b919050565b600080fd5b6000815190506113c581610f92565b92915050565b600063ffffffff82169050919050565b6113e4816113cb565b81146113ef57600080fd5b50565b600081519050611401816113db565b92915050565b600080fd5b600080fd5b600067ffffffffffffffff82111561142c5761142b611336565b5b61143582611325565b9050602081019050919050565b60005b83811015611460578082015181840152602081019050611445565b60008484015250505050565b600061147f61147a84611411565b611396565b90508281526020810184848401111561149b5761149a61140c565b5b6114a6848285611442565b509392505050565b600082601f8301126114c3576114c2611407565b5b81516114d384826020860161146c565b91505092915050565b600061012082840312156114f3576114f2611320565b5b6114fe610120611396565b9050600061150e848285016113b6565b6000830152506020611522848285016113b6565b6020830152506040611536848285016113b6565b604083015250606061154a848285016113f2565b606083015250608061155e848285016113f2565b60808301525060a0611572848285016113f2565b60a08301525060c082015167ffffffffffffffff811115611596576115956113b1565b5b6115a2848285016114ae565b60c08301525060e082015167ffffffffffffffff8111156115c6576115c56113b1565b5b6115d2848285016114ae565b60e0830152506101006115e78482850161116c565b6101008301525092915050565b60006020828403121561160a57611609610f56565b5b600082015167ffffffffffffffff81111561162857611627610f5b565b5b611634848285016114dc565b91505092915050565b60006020828403121561165357611652610f56565b5b6000611661848285016113b6565b91505092915050565b600060608201905061167f600083018661101f565b61168c602083018561101f565b6116996040830184611055565b949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006116db82610feb565b91506116e683610feb565b92508282019050808211156116fe576116fd6116a1565b5b92915050565b61170d81610f80565b82525050565b61171c81610feb565b82525050565b6040820160008201516117386000850182611704565b50602082015161174b6020850182611713565b50505050565b600060c082019050611766600083018861101f565b6117736020830187610ff5565b6117806040830186610ff5565b61178d606083018561101f565b61179a6080830184611722565b9695505050505050565b600080604083850312156117bb576117ba610f56565b5b60006117c9858286016113b6565b92505060206117da8582860161116c565b915050925092905056fea26469706673582212202779eee7de590105aade1478319b6229802342d0c4f8ee25894c4eea59b99f0264736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001d624c56cf0c108350e1bc1d62912acf4d800fef
-----Decoded View---------------
Arg [0] : _sonicPad (address): 0x1d624C56Cf0c108350e1BC1d62912ACF4d800fef
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000001d624c56cf0c108350e1bc1d62912acf4d800fef
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 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.