Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/LaunchList.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "./interfaces/IUniswapV3Pool.sol";
// Add this interface near the top of the file, after the imports
interface IQuoter {
struct QuoteExactInputSingleParams {
address tokenIn;
address tokenOut;
uint256 amountIn;
uint24 fee;
uint160 sqrtPriceLimitX96;
}
function quoteExactInputSingle(QuoteExactInputSingleParams calldata params)
external
view
returns (uint256 amountOut, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate);
}
/**
* @title LaunchList
* @dev Manages launch list addresses, pools, and launch phases for a token
*/
contract LaunchList is Ownable, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
// Role for managing whitelist (launch list addresses and pools)
bytes32 public constant WHITELIST_MANAGER_ROLE = keccak256("WHITELIST_MANAGER_ROLE");
// Role for authorized contracts that can call isTransactionAllowed (e.g., token contracts)
bytes32 public constant LAUNCHLIST_SPENDER_ROLE = keccak256("LAUNCHLIST_SPENDER_ROLE");
// Phase definitions
enum Phase {
LAUNCH_LIST_ONLY, // Phase 0: Launch list addresses can only send to other launch list addresses
LIMITED_POOL_TRADING, // Phase 1: Launch list addresses can trade with pools up to 1 ETH
EXTENDED_POOL_TRADING, // Phase 2: Launch list addresses can trade with pools up to 4 ETH
PUBLIC // Phase 3: No restrictions
}
// Current launch phase
Phase public currentPhase;
// Launch list mappings
EnumerableSet.AddressSet private _launchListAddresses;
EnumerableSet.AddressSet private _launchListPools;
// Uniswap V3 Oracle pool address
address public uniswapV3OraclePool;
// Mapping of user addresses to their USDC spent during limited phases
mapping(address => uint256) public addressUsdcSpent;
// Purchase limits by phase
uint256 public phase1UsdcLimit = 1000 * 10 ** 6;
uint256 public phase2UsdcLimit = 9000 * 10 ** 6;
// Add this state variable
address public constant UNISWAP_QUOTER = 0x5e55C9e631FAE526cd4B0526C4818D6e0a9eF0e3;
address public constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; // Mainnet USDC
uint8 public constant USDC_DECIMALS = 6;
// Events
event PhaseAdvanced(Phase newPhase);
event LaunchListAddressAdded(address indexed addr);
event LaunchListAddressRemoved(address indexed addr);
event LaunchListPoolAdded(address indexed pool);
event PoolRemovedFromLaunchList(address indexed pool);
event OraclePoolUpdated(address indexed newOraclePool);
event UsdcSpent(address indexed user, uint256 amount, uint256 total);
event PhaseLimitsUpdated(
uint256 oldPhase1UsdcLimit, uint256 oldPhase2UsdcLimit, uint256 newPhase1UsdcLimit, uint256 newPhase2UsdcLimit
);
/**
* @dev Constructor
* @param initialOwner Address of the contract owner
*/
constructor(address initialOwner) Ownable(initialOwner) {
currentPhase = Phase.LAUNCH_LIST_ONLY;
// Grant the DEFAULT_ADMIN_ROLE to the owner
_grantRole(DEFAULT_ADMIN_ROLE, initialOwner);
// Grant WHITELIST_MANAGER_ROLE to the owner initially
_grantRole(WHITELIST_MANAGER_ROLE, initialOwner);
emit PhaseAdvanced(currentPhase);
emit PhaseLimitsUpdated(0, 0, phase1UsdcLimit, phase2UsdcLimit);
}
function setPhaseLimits(uint256 phase1UsdcLimit_, uint256 phase2UsdcLimit_) external onlyOwner {
uint256 oldPhase1UsdcLimit = phase1UsdcLimit;
uint256 oldPhase2UsdcLimit = phase2UsdcLimit;
phase1UsdcLimit = phase1UsdcLimit_;
phase2UsdcLimit = phase2UsdcLimit_;
emit PhaseLimitsUpdated(oldPhase1UsdcLimit, oldPhase2UsdcLimit, phase1UsdcLimit_, phase2UsdcLimit_);
}
// ==================== Phase Management ====================
/**
* @dev Advances to the next phase
* @notice Can only be called by the owner
*/
function advancePhase() external onlyOwner {
require(uint8(currentPhase) < uint8(Phase.PUBLIC), "Already in final phase");
currentPhase = Phase(uint8(currentPhase) + 1);
emit PhaseAdvanced(currentPhase);
}
/**
* @dev Sets the phase directly
* @param newPhase The phase to set
* @notice Can only be called by the owner
*/
function setPhase(Phase newPhase) external onlyOwner {
currentPhase = newPhase;
emit PhaseAdvanced(newPhase);
}
// ==================== Launch List Management ====================
/**
* @dev Adds an address to the launch list
* @param addr Address to add
* @notice Can only be called by addresses with WHITELIST_MANAGER_ROLE
*/
function launchListAddress(address addr) external onlyRole(WHITELIST_MANAGER_ROLE) {
require(addr != address(0), "Cannot add zero address");
require(_launchListAddresses.add(addr), "Address already on launch list");
emit LaunchListAddressAdded(addr);
}
/**
* @dev Adds multiple addresses to the launch list
* @param addrs Array of addresses to add
* @notice Can only be called by addresses with WHITELIST_MANAGER_ROLE
*/
function launchListAddresses(address[] calldata addrs) external onlyRole(WHITELIST_MANAGER_ROLE) {
for (uint256 i = 0; i < addrs.length; i++) {
if (addrs[i] != address(0) && _launchListAddresses.add(addrs[i])) {
emit LaunchListAddressAdded(addrs[i]);
}
}
}
/**
* @dev Removes an address from the launch list
* @param addr Address to remove
* @notice Can only be called by addresses with WHITELIST_MANAGER_ROLE
*/
function removeLaunchListAddress(address addr) external onlyRole(WHITELIST_MANAGER_ROLE) {
require(_launchListAddresses.remove(addr), "Address not on launch list");
emit LaunchListAddressRemoved(addr);
}
/**
* @dev Adds a pool to the launch list
* @param pool Address of the pool to add
* @notice Can only be called by addresses with WHITELIST_MANAGER_ROLE
*/
function launchListPool(address pool) external onlyRole(WHITELIST_MANAGER_ROLE) {
require(pool != address(0), "Cannot add zero address");
require(_launchListPools.add(pool), "Pool already on launch list");
emit LaunchListPoolAdded(pool);
}
/**
* @dev Adds multiple pools to the launch list
* @param pools Array of pool addresses to add
* @notice Can only be called by addresses with WHITELIST_MANAGER_ROLE
*/
function launchListPools(address[] calldata pools) external onlyRole(WHITELIST_MANAGER_ROLE) {
for (uint256 i = 0; i < pools.length; i++) {
if (pools[i] != address(0) && _launchListPools.add(pools[i])) {
emit LaunchListPoolAdded(pools[i]);
}
}
}
/**
* @dev Removes a pool from the launch list
* @param pool Address of the pool to remove
* @notice Can only be called by addresses with WHITELIST_MANAGER_ROLE
*/
function removePoolFromLaunchList(address pool) external onlyRole(WHITELIST_MANAGER_ROLE) {
require(_launchListPools.remove(pool), "Pool not on launch list");
emit PoolRemovedFromLaunchList(pool);
}
/**
* @dev Sets the Uniswap V3 Oracle pool
* @param _uniswapV3OraclePool Address of the Uniswap V3 pool to use as price oracle
* @notice Can only be called by the owner
*/
function setUniswapV3OraclePool(address _uniswapV3OraclePool) external onlyOwner {
require(_uniswapV3OraclePool != address(0), "Cannot set zero address as oracle");
uniswapV3OraclePool = _uniswapV3OraclePool;
emit OraclePoolUpdated(_uniswapV3OraclePool);
}
// ==================== Launch List Queries ====================
/**
* @dev Checks if an address is on the launch list
* @param addr Address to check
* @return bool True if the address is on the launch list
*/
function isAddressOnLaunchList(address addr) public view returns (bool) {
return _launchListAddresses.contains(addr);
}
/**
* @dev Checks if a pool is on the launch list
* @param pool Address to check
* @return bool True if the pool is on the launch list
*/
function isPoolOnLaunchList(address pool) public view returns (bool) {
return _launchListPools.contains(pool);
}
/**
* @dev Gets the total number of addresses on the launch list
* @return uint256 Number of addresses on the launch list
*/
function getLaunchListAddressCount() external view returns (uint256) {
return _launchListAddresses.length();
}
/**
* @dev Gets an address on the launch list by index
* @param index Index in the set
* @return address Address on the launch list
*/
function getLaunchListAddressAtIndex(uint256 index) external view returns (address) {
return _launchListAddresses.at(index);
}
/**
* @dev Gets all addresses on the launch list
* @return addrs Array of addresses on the launch list
*/
function getAllLaunchListAddresses() external view returns (address[] memory) {
uint256 length = _launchListAddresses.length();
address[] memory addrs = new address[](length);
for (uint256 i = 0; i < length; i++) {
addrs[i] = _launchListAddresses.at(i);
}
return addrs;
}
/**
* @dev Gets the total number of pools on the launch list
* @return uint256 Number of pools on the launch list
*/
function getLaunchListPoolCount() external view returns (uint256) {
return _launchListPools.length();
}
/**
* @dev Gets a pool on the launch list by index
* @param index Index in the set
* @return address Pool address
*/
function getLaunchListPoolAtIndex(uint256 index) external view returns (address) {
return _launchListPools.at(index);
}
// ==================== Transaction Validation ====================
/**
* @dev Checks if a transaction is allowed according to current phase rules
* @param from Sender address
* @param to Recipient address
* @param amount Amount being transferred
* @return bool True if the transaction is allowed
* @notice Can only be called by contracts with LAUNCHLIST_SPENDER_ROLE to prevent DoS attacks
*/
function isTransactionAllowed(address from, address to, uint256 amount)
external
onlyRole(LAUNCHLIST_SPENDER_ROLE)
returns (bool)
{
// Phase 3: Public - No restrictions
if (currentPhase == Phase.PUBLIC) {
return true;
}
// If sender is token contract, allow (minting and special operations)
if (from == address(0) || from == msg.sender) {
return true;
}
// Phase 0: launch list only - recipient and sender must be on the launch list, or sender is adding liquidity
if (currentPhase == Phase.LAUNCH_LIST_ONLY) {
return ((isAddressOnLaunchList(to) && isAddressOnLaunchList(from))
|| (isAddressOnLaunchList(from) && isPoolOnLaunchList(to)));
}
// Phase 1 & 2: Launch list pools trading with USDC limits
if (currentPhase == Phase.LIMITED_POOL_TRADING || currentPhase == Phase.EXTENDED_POOL_TRADING) {
// If recipient is a launch list pool, check USDC spending limits
if (isPoolOnLaunchList(from) && isAddressOnLaunchList(to)) {
uint256 usdcValue = getUsdcValueForToken(amount);
uint256 limit;
if (currentPhase == Phase.LIMITED_POOL_TRADING) {
// Phase 1: Can spend up to phase1UsdcLimit (1,000 USDC)
limit = phase1UsdcLimit;
} else {
// Phase 2: Can spend up to phase1UsdcLimit + phase2UsdcLimit (10,000 USDC total)
limit = phase1UsdcLimit + phase2UsdcLimit;
}
if (addressUsdcSpent[to] + usdcValue <= limit) {
// Update user's USDC spent if the transaction is going through
addressUsdcSpent[to] += usdcValue;
emit UsdcSpent(to, usdcValue, addressUsdcSpent[to]);
return true;
}
return false;
} else if (isAddressOnLaunchList(from) && isPoolOnLaunchList(to)) {
return true;
} else if (isPoolOnLaunchList(from) && isPoolOnLaunchList(to)) {
return true;
}
return false;
}
return false;
}
/**
* @dev Gets the USDC value for a token amount using Uniswap V3 Quoter, or returns the starting
* amount if no trades have been made on the pool
* @param tokenAmount Amount of tokens
* @return usdcValue Equivalent USDC value
*/
function getUsdcValueForToken(uint256 tokenAmount) public view returns (uint256) {
require(uniswapV3OraclePool != address(0), "Oracle pool not set");
// Get the token addresses from the pool
address token0 = IUniswapV3Pool(uniswapV3OraclePool).token0();
address token1 = IUniswapV3Pool(uniswapV3OraclePool).token1();
uint24 fee = IUniswapV3Pool(uniswapV3OraclePool).fee();
// Determine which token is USDC and which is our token
(address tokenIn, address tokenOut) = token0 == USDC ? (token1, token0) : (token0, token1);
try IQuoter(UNISWAP_QUOTER)
.quoteExactInputSingle(
IQuoter.QuoteExactInputSingleParams({
tokenIn: tokenIn, tokenOut: tokenOut, amountIn: tokenAmount, fee: fee, sqrtPriceLimitX96: 0
})
) returns (
uint256 amountReceived, uint160, uint32, uint256
) {
return amountReceived;
} catch {
// Fallback to initial price if quote fails
return (tokenAmount * 10 ** USDC_DECIMALS) / 10 ** 18; // 1 token = 1 USDC initial price
}
}
}
"
},
"lib/openzeppelin-contracts/contracts/access/Ownable.sol": {
"content": "// 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);
}
}
"
},
"lib/openzeppelin-contracts/contracts/access/AccessControl.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
"
},
"lib/openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
}
"
},
"contracts/interfaces/IUniswapV3Pool.sol": {
"content": "pragma solidity ^0.8.28;
// Uniswap V3 Pool Interface
interface IUniswapV3Pool {
function observe(uint32[] calldata secondsAgos)
external
view
returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
function observations(uint256 index)
external
view
returns (uint32 observationTime, int56 tickCumulative, uint16 observationIndex, bool initialized);
function initialize(uint160 sqrtPriceX96) external;
function token0() external view returns (address);
function token1() external view returns (address);
function fee() external view returns (uint24);
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
}
"
},
"lib/openzeppelin-contracts/contracts/utils/Context.sol": {
"content": "// 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;
}
}
"
},
"lib/openzeppelin-contracts/contracts/access/IAccessControl.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}
"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// 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);
}
"
}
},
"settings": {
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@layerzerolabs/=node_modules/@layerzerolabs/",
"@openzeppelin-3/=node_modules/@openzeppelin-3/",
"@uniswap/=node_modules/@uniswap/",
"base64-sol/=node_modules/base64-sol/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"erc721a/=node_modules/erc721a/",
"eth-gas-reporter/=node_modules/eth-gas-reporter/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"hardhat-deploy/=node_modules/hardhat-deploy/",
"hardhat/=node_modules/hardhat/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
],
"optimizer": {
"enabled": false,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "prague",
"viaIR": true
}
}}
Submitted on: 2025-10-27 13:27:51
Comments
Log in to comment.
No comments yet.