Description:
Proxy contract enabling upgradeable smart contract patterns. Delegates calls to an implementation contract.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
"content": "// 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
}
}
}
"
},
"@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165Upgradeable is Initializable, IERC165 {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}
"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
"
},
"@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.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;
/// @solidity memory-safe-assembly
assembly {
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;
/// @solidity memory-safe-assembly
assembly {
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;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}
"
},
"contracts/base/StateMachine.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
import {LibBit} from "solady/src/utils/LibBit.sol";
type State is uint256;
using {and as &, neq as !=, eq as ==, or as |, includes, isInitialized, isValid} for State global;
function and(State self, State value) pure returns (State) {
return State.wrap(State.unwrap(self) & State.unwrap(value));
}
function neq(State self, State value) pure returns (bool) {
return State.unwrap(self) != State.unwrap(value);
}
function eq(State self, State value) pure returns (bool) {
return State.unwrap(self) == State.unwrap(value);
}
function or(State self, State value) pure returns (State) {
return State.wrap(State.unwrap(self) | State.unwrap(value));
}
function includes(State bitmap, State state) pure returns (bool) {
return State.unwrap(bitmap) & State.unwrap(state) != 0;
}
function isInitialized(State self) pure returns (bool answer_) {
return State.unwrap(self) != 0;
}
function isValid(State self) pure returns (bool) {
// most significant bit is reserved for the undefined state
uint256 mask = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
return LibBit.isPo2(State.unwrap(self) & mask);
}
abstract contract StateMachine {
struct StateStorage {
State currentState;
mapping(bytes32 transitionId => function(bytes memory) external transition) transitions;
}
// Undefined state cannot be zero because it will break bitmap comparison math in `onlyState`
/* solhint-disable-next-line immutable-vars-naming */
State internal immutable STATE_UNDEFINED = _newStateFromIdUnchecked(STATE_UNDEFINED_ID);
uint8 private constant STATE_UNDEFINED_ID = type(uint8).max;
// keccak256("StateMachine storage slot V2");
bytes32 private constant STORAGE_SLOT_STATE_MACHINE =
0xde4001bbdfdfed078acd4ae5c1023679bf2e3e2982cfd37f7c839d62304fe30d;
event StateChanged(State from, State to);
error TransitionAlreadyExists(State from, State to);
error TransitionDoesNotExist(State from, State to);
error UnexpectedState(State expectedStatesBitmap, State currentState);
// If transition function exists on current contract
// then it must be called only from the current contract.
error HostedTransitionMustBeCalledFromSelf();
// A valid state must be in form of 2^n, where n ∈ {x | x ∈ uint8, x < STATE_UNDEFINED_ID}.
error InvalidState(State);
error IdIsReservedForUndefinedState(uint256);
modifier onlyState(State _expectedStatesBitmap) {
State state = _currentState(_stateStorage());
if (!_expectedStatesBitmap.includes(state))
revert UnexpectedState(_expectedStatesBitmap, state);
_;
}
modifier transition() {
if (msg.sender != address(this)) revert HostedTransitionMustBeCalledFromSelf();
_;
}
function createTransition(
State _from,
State _to,
function(bytes memory) external _transition
) internal {
bytes32 id = _getTransitionId(_from, _to);
if (_isTransitionExists(id)) revert TransitionAlreadyExists(_from, _to);
_stateStorage().transitions[id] = _transition;
}
function changeState(State _newState) internal {
changeState(_newState, "");
}
function changeState(State _newState, bytes memory _transitionArgs) internal {
if (!_newState.isValid()) revert InvalidState(_newState);
StateStorage storage $ = _stateStorage();
State state = _currentState($);
bytes32 id = _getTransitionId(state, _newState);
if (!_isTransitionExists(id)) revert TransitionDoesNotExist(state, _newState);
emit StateChanged(state, _newState);
$.currentState = _newState;
$.transitions[id](_transitionArgs);
}
function currentState() internal view returns (State currentState_) {
return _currentState(_stateStorage());
}
function newStateFromId(uint8 _stateId) internal pure returns (State) {
if (_stateId == STATE_UNDEFINED_ID) revert IdIsReservedForUndefinedState(_stateId);
return _newStateFromIdUnchecked(_stateId);
}
function _currentState(StateStorage storage $) private view returns (State state) {
state = $.currentState;
// We substitute 0 with STATE_UNDEFINED here in order to avoid storage
// initialization with default value to save gas
if (!state.isInitialized()) state = STATE_UNDEFINED;
}
function _isTransitionExists(bytes32 _transitionId) private view returns (bool exists_) {
mapping(bytes32 => function(bytes memory) external) storage map = _stateStorage()
.transitions;
assembly {
// we won't use this memory location after keccak so it's safe to use 0x00 and 0x20
mstore(0x00, _transitionId)
mstore(0x20, map.slot)
let position := keccak256(0x00, 64)
// callback = map[_transition]
let callback := sload(position)
// exists_ = callback != null
exists_ := iszero(iszero(callback))
}
}
function _getTransitionId(State _from, State _to) private view returns (bytes32) {
if (_from != STATE_UNDEFINED && !_from.isValid()) revert InvalidState(_from);
if (!_to.isValid()) revert InvalidState(_to);
return keccak256(abi.encodePacked(_from, _to));
}
function _newStateFromIdUnchecked(uint8 _stateId) private pure returns (State) {
return State.wrap(1 << _stateId);
}
function _stateStorage() private pure returns (StateStorage storage $) {
assembly {
$.slot := STORAGE_SLOT_STATE_MACHINE
}
}
}
"
},
"contracts/compliance/AbstractValidator.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {CalldataLibrary} from "contracts/libraries/CalldataLibrary.sol";
/* solhint-disable-next-line no-unused-import */
import {Command} from "contracts/libraries/CommandLibrary.sol";
import {ProtocolsRepository} from "./libraries/ProtocolsRepository.sol";
/* solhint-disable-next-line no-unused-import */
import {TokensRepository} from "./libraries/TokensRepository.sol";
/* solhint-disable ordering */
abstract contract AbstractValidator {
using Address for address payable;
using ProtocolsRepository for address;
using CalldataLibrary for bytes;
/**
* @dev See [status](/interfaces/compliance/IWhitelistingController.sol/enum.Status.html)
* definition for validation rules.
*/
enum Support {
Required,
NotRequired
}
/// @dev Custom error for mismatched Eth amounts sent
error MismatchedEthValue(uint256 sentValue, uint256 expectedValue);
/**
* @dev Modifier that validates and refunds any Eth sent to the contract function back to the caller (Margin Account).
* Reverts if the sent Eth (`msg.value`) does not match the specified amount (`expectedValue`).
* @param expectedValue The expected amount of Eth to be sent.
*/
modifier refundEth(uint256 expectedValue) {
if (msg.value > 0 && msg.value != expectedValue)
revert MismatchedEthValue(msg.value, expectedValue);
_;
if (msg.value > 0) payable(msg.sender).sendValue(msg.value);
}
/// @dev This function allows us to store the name of protocol in the bytecode rather than in storage
function protocolName() internal pure virtual returns (string memory);
function getOperator(Support support) internal view virtual returns (address operator) {
validateOperator(operator = getOperatorUnsafe(), support);
}
function getOperatorUnsafe() internal view virtual returns (address) {
return msg.data.extractLastWordAsAddress();
}
function validateOperator(address operator, Support support) internal view {
if (support == Support.Required) {
enforceOperatorSupported(operator);
} else {
enforceOperatorSupportedOrSuspended(operator);
}
}
function enforceOperatorSupported(address _operator) internal view {
_operator.enforceOperatorSupported();
}
function enforceOperatorSupportedOrSuspended(address _operator) internal view {
_operator.enforceOperatorSupportedOrSuspended();
}
}
/* solhint-enable ordering */
"
},
"contracts/compliance/curveFi/base/CurveFiValidator.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
/* solhint-disable-next-line no-unused-import */
import {AbstractValidator, TokensRepository} from "contracts/compliance/AbstractValidator.sol";
abstract contract CurveFiValidator is AbstractValidator {
/// @dev We will override this in unit tests
function protocolName() internal pure virtual override returns (string memory) {
return "curvefi";
}
}
"
},
"contracts/compliance/curveFi/CurveFiValidatorTriCryptoPool.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
import {
Command,
ICurveFiPool,
ICurveFiValidatorTriCryptoPool
} from "contracts/interfaces/compliance/actions/curveFi/ICurveFiValidatorTriCryptoPool.sol";
import {CurveFiLib} from "contracts/compliance/curveFi/libraries/CurveFiLib.sol";
import {CurveFiValidator, TokensRepository} from "./base/CurveFiValidator.sol";
/* solhint-disable func-name-mixedcase, var-name-mixedcase, func-param-name-mixedcase */
contract CurveFiValidatorTriCryptoPool is ICurveFiValidatorTriCryptoPool, CurveFiValidator {
using CurveFiLib for address;
using TokensRepository for address;
/// @custom:withdraw (0x05e6f228)
function remove_liquidity(
uint256 amount,
uint256[4] calldata min_amounts,
bool use_eth,
address receiver,
bool claim_admin_fees
) external view override returns (Command[] memory cmds_) {
address pool = getOperator(Support.NotRequired);
pool.enforceTokensCompliance(use_eth, 4, Support.NotRequired);
bytes memory data = receiver == msg.sender
? msg.data
: abi.encodeWithSelector(
msg.sig,
amount,
min_amounts,
use_eth,
msg.sender,
claim_admin_fees
);
return Command({target: pool, value: 0, payload: data}).asArray();
}
/// @custom:withdraw (0x5cd34780)
function remove_liquidity(
uint256 amount,
uint256[3] calldata min_amounts,
bool use_eth,
address receiver,
bool claim_admin_fees
) external view override returns (Command[] memory cmds_) {
address pool = getOperator(Support.NotRequired);
pool.enforceTokensCompliance(use_eth, 3, Support.NotRequired);
bytes memory data = receiver == msg.sender
? msg.data
: abi.encodeWithSelector(
msg.sig,
amount,
min_amounts,
use_eth,
msg.sender,
claim_admin_fees
);
return Command({target: pool, value: 0, payload: data}).asArray();
}
/// @custom:withdraw (0xe52b6522)
function remove_liquidity(
uint256 amount,
uint256[2] calldata min_amounts,
bool use_eth,
address receiver,
bool claim_admin_fees
) external view override returns (Command[] memory cmds_) {
address pool = getOperator(Support.NotRequired);
pool.enforceTokensCompliance(use_eth, 2, Support.NotRequired);
bytes memory data = receiver == msg.sender
? msg.data
: abi.encodeWithSelector(
msg.sig,
amount,
min_amounts,
use_eth,
msg.sender,
claim_admin_fees
);
return Command({target: pool, value: 0, payload: data}).asArray();
}
/// @custom:withdraw (0x8f15b6b5)
function remove_liquidity_one_coin(
uint256,
uint256 i,
uint256,
bool
) external view override returns (Command[] memory cmds_) {
ICurveFiPool pool = ICurveFiPool(getOperator(Support.NotRequired));
pool.coins(i).enforceTokenSupportedOrSuspended();
return Command({target: address(pool), value: 0, payload: msg.data}).asArray();
}
/// @custom:withdraw (0x07329bcd)
function remove_liquidity_one_coin(
uint256 token_amount,
uint256 i,
uint256 min_amount,
bool use_eth,
address receiver
) external view override returns (Command[] memory cmds_) {
ICurveFiPool pool = ICurveFiPool(getOperator(Support.NotRequired));
pool.coins(i).enforceTokenSupportedOrSuspended();
bytes memory data = receiver == msg.sender
? msg.data
: abi.encodeWithSelector(msg.sig, token_amount, i, min_amount, use_eth, msg.sender);
return Command({target: address(pool), value: 0, payload: data}).asArray();
}
}
/* solhint-enable func-name-mixedcase, var-name-mixedcase, func-param-name-mixedcase */
"
},
"contracts/compliance/curveFi/libraries/CurveFiLib.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
import {ICurveFiPool} from "contracts/interfaces/compliance/internal/curveFi/index.sol";
import {AbstractValidator, TokensRepository} from "contracts/compliance/AbstractValidator.sol";
library CurveFiLib {
using TokensRepository for address;
function enforceTokensCompliance(
address pool,
/* solhint-disable-next-line func-param-name-mixedcase, var-name-mixedcase */
bool use_underlying,
uint256 nCoins,
AbstractValidator.Support support
) internal view {
ICurveFiPool _pool = ICurveFiPool(pool);
address _token;
bool _hasUnderlying = use_underlying ? hasUnderlying(_pool) : false;
for (uint256 i = 0; i < nCoins; i++) {
_token = _hasUnderlying ? _pool.underlying_coins(i) : _pool.coins(i);
support == AbstractValidator.Support.Required
? _token.enforceTokenSupported()
: _token.enforceTokenSupportedOrSuspended();
}
}
function enforceTokensCompliance(
address pool,
uint256 nCoins,
AbstractValidator.Support support
) internal view {
enforceTokensCompliance(pool, false, nCoins, support);
}
function hasUnderlying(ICurveFiPool pool) private view returns (bool) {
try pool.underlying_coins(0) returns (address) {
return true;
} catch {
return false;
}
}
}
"
},
"contracts/compliance/libraries/ProtocolsRepository.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {
OperatorIsNotSupported,
OperatorIsSuspended,
ProtocolIsNotSupported,
ProtocolIsSuspended,
Status
} from "contracts/interfaces/compliance/IWhitelistingController.sol";
import {IAccount} from "contracts/interfaces/marginAccount/IAccount.sol";
import {StringTruncatedHash} from "contracts/libraries/StringTruncatedHash.sol";
library ProtocolsRepository {
using StringTruncatedHash for string;
using EnumerableSet for EnumerableSet.AddressSet;
struct Operator {
bytes31 protocolNameHash;
Status status;
}
struct Storage {
mapping(bytes31 protocolNameHash => Status) protocols;
mapping(address externalOperator => Operator) operators;
mapping(address tenant => EnumerableSet.AddressSet operatorSet) tenantOperators;
}
// keccak256("Protocols repository slot V1");
bytes32 private constant STORAGE_SLOT =
0xe4244d04ebfd087f67ab21a5e230305c3364db215e5da5fe215a0e245a1265cc;
error ProtocolMustNotBeEmptyString();
function updateProtocolSupport(
string calldata _protocolName,
bool _supported
) internal returns (bool storageModified_) {
if (bytes(_protocolName).length == 0) revert ProtocolMustNotBeEmptyString();
Storage storage $ = _storage();
bytes31 _protocolHash = _protocolName.truncatedHash();
if (_supported && $.protocols[_protocolHash] != Status.Supported) {
$.protocols[_protocolHash] = Status.Supported;
storageModified_ = true;
} else if (!_supported && $.protocols[_protocolHash] == Status.Supported) {
$.protocols[_protocolHash] = Status.Suspended;
storageModified_ = true;
}
}
function updateOperatorSupport(
string calldata _protocolName,
address _source,
bool _supported
) internal returns (bool storageModified_) {
if (bytes(_protocolName).length == 0) revert ProtocolMustNotBeEmptyString();
Operator storage _operator = _storage().operators[_source];
bytes31 _protocolNameHash = _protocolName.truncatedHash();
if (
_supported &&
(_operator.status != Status.Supported ||
_operator.protocolNameHash != _protocolNameHash)
) {
_operator.protocolNameHash = _protocolNameHash;
_operator.status = Status.Supported;
storageModified_ = true;
} else if (!_supported && _operator.status == Status.Supported) {
_operator.status = Status.Suspended;
storageModified_ = true;
}
}
function addOperator(address tenant, address _operator) internal returns (bool) {
Storage storage $ = _storage();
_enforceOperatorSupportedGlobally($, _operator);
return $.tenantOperators[tenant].add(_operator);
}
function enforceProtocolSupported(string calldata _protocol) internal view {
_enforceProtocolSupported(_storage(), _protocol.truncatedHash());
}
function enforceProtocolSupportedOrSuspended(string calldata _protocol) internal view {
_enforceProtocolSupportedOrSuspended(_storage(), _protocol.truncatedHash());
}
function enforceOperatorSupportedGlobally(address _operator) internal view {
_enforceOperatorSupportedGlobally(_storage(), _operator);
}
function enforceOperatorSupportedOrSuspendedGlobally(address _operator) internal view {
_enforceOperatorSupportedOrSuspendedGlobally(_storage(), _operator);
}
function enforceOperatorSupported(address _operator) internal view {
Storage storage $ = _storage();
_enforceOperatorSupportedGlobally($, _operator);
_enforceOperatorSupported($, _operator);
}
function enforceOperatorSupportedOrSuspended(address _operator) internal view {
Storage storage $ = _storage();
_enforceOperatorSupported($, _operator);
}
function getProtocolStatus(string calldata protocol) internal view returns (Status) {
return _storage().protocols[protocol.truncatedHash()];
}
function getOperatorStatus(address _source) internal view returns (Status, Status) {
Storage storage $ = _storage();
Operator storage _operator = $.operators[_source];
return (_operator.status, $.protocols[_operator.protocolNameHash]);
}
function getOperatorSupport(address tenant, address _source) internal view returns (bool) {
return _storage().tenantOperators[tenant].contains(_source);
}
function getOperators(address tenant) internal view returns (address[] memory) {
return _storage().tenantOperators[tenant].values();
}
function _enforceProtocolSupported(Storage storage $, bytes31 protocolNameHash) private view {
Status status = $.protocols[protocolNameHash];
if (status != Status.Supported) {
if (status == Status.Suspended) revert ProtocolIsSuspended(protocolNameHash);
else revert ProtocolIsNotSupported(protocolNameHash);
}
}
function _enforceProtocolSupportedOrSuspended(
Storage storage $,
bytes31 protocolNameHash
) private view {
if ($.protocols[protocolNameHash] == Status.Undefined)
revert ProtocolIsNotSupported(protocolNameHash);
}
function _enforceOperatorSupportedGlobally(Storage storage $, address _operator) private view {
if ($.operators[_operator].protocolNameHash == 0x00)
revert OperatorIsNotSupported(_operator);
_enforceProtocolSupported($, $.operators[_operator].protocolNameHash);
_enforceOperatorSupportedOrSuspendedGlobally($, _operator);
if ($.operators[_operator].status == Status.Suspended)
revert OperatorIsSuspended(_operator);
}
function _enforceOperatorSupportedOrSuspendedGlobally(
Storage storage $,
address _operator
) private view {
if (
$.operators[_operator].protocolNameHash == 0x00 ||
$.operators[_operator].status == Status.Undefined
) revert OperatorIsNotSupported(_operator);
_enforceProtocolSupportedOrSuspended($, $.operators[_operator].protocolNameHash);
}
function _enforceOperatorSupported(Storage storage $, address _operator) private view {
_enforceOperatorSupportedOrSuspendedGlobally($, _operator);
address tenant = IAccount(payable(msg.sender)).agreement();
if (!$.tenantOperators[tenant].contains(_operator))
revert OperatorIsNotSupported(_operator);
}
function _storage() private pure returns (Storage storage $) {
assembly {
$.slot := STORAGE_SLOT
}
}
}
"
},
"contracts/compliance/libraries/TokensRepository.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {
Status,
TokenIsNotSupported,
TokenIsSuspended
} from "contracts/interfaces/compliance/IWhitelistingController.sol";
import {IAccount} from "contracts/interfaces/marginAccount/IAccount.sol";
library TokensRepository {
using EnumerableSet for EnumerableSet.AddressSet;
struct Storage {
mapping(address source => Status) tokenStatus;
mapping(address tenant => EnumerableSet.AddressSet tokenSet) tenantTokens;
}
// keccak256("Tokens repository slot V1")
bytes32 private constant STORAGE_SLOT =
0x83e9d38aac809607745297dd1279ab2c5a80c78fbb831277ade24255b51c5f49;
function updateTokenSupport(
address token,
bool supported
) internal returns (bool storageModified) {
Storage storage $ = _storage();
if (supported && $.tokenStatus[token] != Status.Supported) {
$.tokenStatus[token] = Status.Supported;
storageModified = true;
} else if (!supported && $.tokenStatus[token] == Status.Supported) {
$.tokenStatus[token] = Status.Suspended;
storageModified = true;
}
}
function addToken(address tenant, address token) internal returns (bool) {
Storage storage $ = _storage();
_enforceTokenSupportedGlobally($, token);
return $.tenantTokens[tenant].add(token);
}
function enforceTokenSupportedGlobally(address token) internal view {
Status status = getTokenStatus(token);
if (status != Status.Supported) {
if (status == Status.Suspended) revert TokenIsSuspended(token);
else revert TokenIsNotSupported(token);
}
}
function enforceTokenSupportedOrSuspendedGlobally(address token) internal view {
Status status = getTokenStatus(token);
if (status == Status.Undefined) revert TokenIsNotSupported(token);
}
function enforceTokenSupported(address token) internal view {
Storage storage $ = _storage();
_enforceTokenSupportedGlobally($, token);
_enforceTokenSupported($, token);
}
function enforceTokenSupportedOrSuspended(address token) internal view {
_enforceTokenSupported(_storage(), token);
}
function getTokenStatus(address token) internal view returns (Status) {
return _storage().tokenStatus[token];
}
function getTokenSupport(address tenant, address token) internal view returns (bool) {
return _storage().tenantTokens[tenant].contains(token);
}
function getTokens(address tenant) internal view returns (address[] memory) {
return _storage().tenantTokens[tenant].values();
}
function _enforceTokenSupportedGlobally(Storage storage $, address token) private view {
if ($.tokenStatus[token] != Status.Supported) {
if ($.tokenStatus[token] == Status.Suspended) revert TokenIsSuspended(token);
else revert TokenIsNotSupported(token);
}
}
function _enforceTokenSupported(Storage storage $, address token) private view {
address tenant = IAccount(payable(msg.sender)).agreement();
if (!$.tenantTokens[tenant].contains(token)) revert TokenIsNotSupported(token);
}
function _storage() private pure returns (Storage storage $) {
assembly {
$.slot := STORAGE_SLOT
}
}
}
"
},
"contracts/interfaces/base/CommonErrors.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
/**
* @notice An error indicating that the amount for the specified token is zero.
* @param token The address of the token with a zero amount.
*/
error AmountMustNotBeZero(address token);
/**
* @notice An error indicating that an address must not be zero.
*/
error AddressMustNotBeZero();
/**
* @notice An error indicating that an array must not be empty.
*/
error ArrayMustNotBeEmpty();
/**
* @notice An error indicating that an string must not be empty.
*/
error StringMustNotBeEmpty();
/**
* @notice An error indicating storage is already up to date and doesn't need further processing.
* @dev This error is thrown when attempting to update an entity(s) that is(are) already up to date.
*/
error AlreadyUpToDate();
/**
* @notice An error indicating that an action is unauthorized for the specified account.
* @param account The address of the unauthorized account.
*/
error UnauthorizedAccount(address account);
/**
* @notice An error indicating that the min amount out must not be zero.
*/
error MinAmountOutMustNotBeZero();
"
},
"contracts/interfaces/base/IERC165Extended.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
/* solhint-disable no-unused-import */
import {
IERC165
} from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";
/* solhint-enable no-unused-import */
/**
* @notice An error indicating that an address does not support the expected interface
* @param implementation The address that does not implement the required interface
*/
error UnsupportedInterface(address implementation);
/**
* @dev Extended interface of the ERC165 standard to ensure compatibility
* with Diamond facets as defined in EIP-2535.
*
* This interface extends the basic ERC165 mechanism to provide additional
* flexibility for querying supported interfaces, which can then be
* dynamically resolved by one of facets in a Diamond.
*/
interface IERC165Extended {
/**
* @notice Checks if the given interface ID is supported by the contract.
* @param interfaceId The ID of the interface to query.
* @return isSupported Boolean value indicating whether the interface is supported.
*/
function supportsInterfaceExtended(bytes4 interfaceId) external pure returns (bool isSupported);
}
"
},
"contracts/interfaces/common/IInitializable.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
interface IInitializable {
function initialize() external;
}
"
},
"contracts/interfaces/compiler/adapters/IDecreasePositionEvaluator.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
import {Asset} from "contracts/libraries/AssetLibrary.sol";
import {Command} from "../Command.sol";
import {PositionDescriptor} from "./PositionDescriptor.sol";
interface IDecreasePositionEvaluator {
/**
* @notice Request structure for decreasing a position.
* @dev `descriptor`: The [`PositionDescriptor`](/interfaces/compiler/adapters/PositionDescriptor.sol/struct.PositionDescriptor.html)
* struct.
* @dev `liquidity`: Abstract amount that can be interpreted differently in different protocols (e.g., amount of LP tokens to burn).
* @dev `minOutput`: [`Asset`](/interfaces/compliance/Asset.sol/struct.Asset.html) array with minimum amounts that must be retrieved from the position.
*/
struct DecreasePositionRequest {
PositionDescriptor descriptor;
uint256 liquidity;
Asset[] minOutput;
}
/**
* @notice Evaluate a decrease position request.
* @param _operator Address which initiated the request
* @param _request The [`DecreasePositionRequest`](#decreasepositionrequest) struct containing decrease position details.
* @return cmds_ An array of [`Command`](../../Command.sol/struct.Command.html) to execute the request.
*/
function evaluate(
address _operator,
DecreasePositionRequest calldata _request
) external returns (Command[] memory cmds_);
}
"
},
"contracts/interfaces/compiler/adapters/IExchangeEvaluator.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;
import {Command} from "../Command.sol";
/**
* @title IExchangeEvaluator
* @notice Interface for compiling commands for token exchanges for different protocols.
*/
interface IExchangeEvaluator {
/**
* @notice Structure for an exchange token request.
* @dev `path`: Encoded path of tokens to follow in the
Submitted on: 2025-10-14 12:21:02
Comments
Log in to comment.
No comments yet.