Verified contractPartialUNLICENSED
AaveV4ConfiguratorBatch
Address0xc60cd9a44b629042b048bb23003b228e90b2ed2a
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.28
- Same code
6 more contracts
Details
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- solidity
- Optimization
- Yes, 44,444,444 runs
- EVM version
- cancun
- License
- UNLICENSED
- Match
- Partialcreation code: no, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,630,322
- Creation transaction
- 0x8261fd1342…e206aacb71
39 files
- src/deployments/batches/AaveV4ConfiguratorBatch.solmain1.26 KB
- lib/forge-std/src/Vm.sol128.95 KB
- src/dependencies/openzeppelin/AccessManaged.sol4.41 KB
- src/dependencies/openzeppelin/Address.sol6.37 KB
- src/dependencies/openzeppelin/AuthorityUtils.sol1.27 KB
- src/dependencies/openzeppelin/Context.sol939 B
- src/dependencies/openzeppelin/ERC1967Proxy.sol1.67 KB
- src/dependencies/openzeppelin/ERC1967Utils.sol5.83 KB
- src/dependencies/openzeppelin/Errors.sol864 B
- src/dependencies/openzeppelin/IAccessManaged.sol1.07 KB
- src/dependencies/openzeppelin/IAccessManager.sol15.67 KB
- src/dependencies/openzeppelin/IAuthority.sol491 B
- src/dependencies/openzeppelin/IBeacon.sol461 B
- src/dependencies/openzeppelin/IERC1967.sol613 B
- src/dependencies/openzeppelin/IERC20.sol2.66 KB
- src/dependencies/openzeppelin/IERC20Metadata.sol659 B
- src/dependencies/openzeppelin/LowLevelCall.sol5.18 KB
- src/dependencies/openzeppelin/Ownable.sol2.92 KB
- src/dependencies/openzeppelin/Proxy.sol2.53 KB
- src/dependencies/openzeppelin/ProxyAdmin.sol1.89 KB
- src/dependencies/openzeppelin/SafeCast.sol32.15 KB
- src/dependencies/openzeppelin/StorageSlot.sol3.91 KB
- src/dependencies/openzeppelin/TransparentUpgradeableProxy.sol6.38 KB
- src/deployments/libraries/BatchReports.sol955 B
- src/deployments/procedures/AaveV4DeployProcedureBase.sol262 B
- src/deployments/procedures/deploy/hub/AaveV4HubConfiguratorDeployProcedure.sol727 B
- src/deployments/procedures/deploy/spoke/AaveV4SpokeConfiguratorDeployProcedure.sol738 B
- src/deployments/utils/libraries/Create2Utils.sol2.26 KB
- src/hub/HubConfigurator.sol10.51 KB
- src/hub/interfaces/IHub.sol19.89 KB
- src/hub/interfaces/IHubBase.sol17.13 KB
- src/hub/interfaces/IHubConfigurator.sol9.25 KB
- src/interfaces/IExtSload.sol694 B
- src/interfaces/IIntentConsumer.sol475 B
- src/interfaces/IMulticall.sol544 B
- src/interfaces/INoncesKeyed.sol1 KB
- src/spoke/SpokeConfigurator.sol11.09 KB
- src/spoke/interfaces/ISpoke.sol38.72 KB
- src/spoke/interfaces/ISpokeConfigurator.sol9.03 KB
src/deployments/batches/AaveV4ConfiguratorBatch.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;
import {BatchReports} from 'src/deployments/libraries/BatchReports.sol';
import {AaveV4HubConfiguratorDeployProcedure} from 'src/deployments/procedures/deploy/hub/AaveV4HubConfiguratorDeployProcedure.sol';
import {AaveV4SpokeConfiguratorDeployProcedure} from 'src/deployments/procedures/deploy/spoke/AaveV4SpokeConfiguratorDeployProcedure.sol';
contract AaveV4ConfiguratorBatch is
AaveV4HubConfiguratorDeployProcedure,
AaveV4SpokeConfiguratorDeployProcedure
{
BatchReports.ConfiguratorBatchReport internal _report;
constructor(
address hubConfiguratorAuthority_,
address spokeConfiguratorAuthority_,
bytes32 salt_
) {
address hubConfigurator = _deployHubConfigurator({
authority: hubConfiguratorAuthority_,
salt: salt_
});
address spokeConfigurator = _deploySpokeConfigurator({
authority: spokeConfiguratorAuthority_,
salt: salt_
});
_report = BatchReports.ConfiguratorBatchReport({
hubConfigurator: hubConfigurator,
spokeConfigurator: spokeConfigurator
});
}
function getReport() external view returns (BatchReports.ConfiguratorBatchReport memory) {
return _report;
}
}
lib/forge-std/src/Vm.sol
// Automatically @generated by scripts/vm.py. Do not modify manually.
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;
/// The `VmSafe` interface does not allow manipulation of the EVM state or other actions that may
/// result in Script simulations differing from on-chain execution. It is recommended to only use
/// these cheats in scripts.
interface VmSafe {
/// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`.
enum CallerMode {
// No caller modification is currently active.
None,
// A one time broadcast triggered by a `vm.broadcast()` call is currently active.
Broadcast,
// A recurrent broadcast triggered by a `vm.startBroadcast()` call is currently active.
RecurrentBroadcast,
// A one time prank triggered by a `vm.prank()` call is currently active.
Prank,
// A recurrent prank triggered by a `vm.startPrank()` call is currently active.
RecurrentPrank
}
/// The kind of account access that occurred.
enum AccountAccessKind {
// The account was called.
Call,
// The account was called via delegatecall.
DelegateCall,
// The account was called via callcode.
CallCode,
// The account was called via staticcall.
StaticCall,
// The account was created.
Create,
// The account was selfdestructed.
SelfDestruct,
// Synthetic access indicating the current context has resumed after a previous sub-context (AccountAccess).
Resume,
// The account's balance was read.
Balance,
// The account's codesize was read.
Extcodesize,
// The account's codehash was read.
Extcodehash,
// The account's code was copied.
Extcodecopy
}
/// Forge execution contexts.
enum ForgeContext {
// Test group execution context (test, coverage or snapshot).
TestGroup,
// `forge test` execution context.
Test,
// `forge coverage` execution context.
Coverage,
// `forge snapshot` execution context.
Snapshot,
// Script group execution context (dry run, broadcast or resume).
ScriptGroup,
// `forge script` execution context.
ScriptDryRun,
// `forge script --broadcast` execution context.
ScriptBroadcast,
// `forge script --resume` execution context.
ScriptResume,
// Unknown `forge` execution context.
Unknown
}
/// The transaction type (`txType`) of the broadcast.
enum BroadcastTxType {
// Represents a CALL broadcast tx.
Call,
// Represents a CREATE broadcast tx.
Create,
// Represents a CREATE2 broadcast tx.
Create2
}
/// An Ethereum log. Returned by `getRecordedLogs`.
struct Log {
// The topics of the log, including the signature, if any.
bytes32[] topics;
// The raw data of the log.
bytes data;
// The address of the log's emitter.
address emitter;
}
/// An RPC URL and its alias. Returned by `rpcUrlStructs`.
struct Rpc {
// The alias of the RPC URL.
string key;
// The RPC URL.
string url;
}
/// An RPC log object. Returned by `eth_getLogs`.
struct EthGetLogs {
// The address of the log's emitter.
address emitter;
// The topics of the log, including the signature, if any.
bytes32[] topics;
// The raw data of the log.
bytes data;
// The block hash.
bytes32 blockHash;
// The block number.
uint64 blockNumber;
// The transaction hash.
bytes32 transactionHash;
// The transaction index in the block.
uint64 transactionIndex;
// The log index.
uint256 logIndex;
// Whether the log was removed.
bool removed;
}
/// A single entry in a directory listing. Returned by `readDir`.
struct DirEntry {
// The error message, if any.
string errorMessage;
// The path of the entry.
string path;
// The depth of the entry.
uint64 depth;
// Whether the entry is a directory.
bool isDir;
// Whether the entry is a symlink.
bool isSymlink;
}
/// Metadata information about a file.
/// This structure is returned from the `fsMetadata` function and represents known
/// metadata about a file such as its permissions, size, modification
/// times, etc.
struct FsMetadata {
// True if this metadata is for a directory.
bool isDir;
// True if this metadata is for a symlink.
bool isSymlink;
// The size of the file, in bytes, this metadata is for.
uint256 length;
// True if this metadata is for a readonly (unwritable) file.
bool readOnly;
// The last modification time listed in this metadata.
uint256 modified;
// The last access time of this metadata.
uint256 accessed;
// The creation time listed in this metadata.
uint256 created;
}
/// A wallet with a public and private key.
struct Wallet {
// The wallet's address.
address addr;
// The wallet's public key `X`.
uint256 publicKeyX;
// The wallet's public key `Y`.
uint256 publicKeyY;
// The wallet's private key.
uint256 privateKey;
}
/// The result of a `tryFfi` call.
struct FfiResult {
// The exit code of the call.
int32 exitCode;
// The optionally hex-decoded `stdout` data.
bytes stdout;
// The `stderr` data.
bytes stderr;
}
/// Information on the chain and fork.
struct ChainInfo {
// The fork identifier. Set to zero if no fork is active.
uint256 forkId;
// The chain ID of the current fork.
uint256 chainId;
}
/// Information about a blockchain.
struct Chain {
// The chain name.
string name;
// The chain's Chain ID.
uint256 chainId;
// The chain's alias. (i.e. what gets specified in `foundry.toml`).
string chainAlias;
// A default RPC endpoint for this chain.
string rpcUrl;
}
/// The result of a `stopAndReturnStateDiff` call.
struct AccountAccess {
// The chain and fork the access occurred.
ChainInfo chainInfo;
// The kind of account access that determines what the account is.
// If kind is Call, DelegateCall, StaticCall or CallCode, then the account is the callee.
// If kind is Create, then the account is the newly created account.
// If kind is SelfDestruct, then the account is the selfdestruct recipient.
// If kind is a Resume, then account represents a account context that has resumed.
AccountAccessKind kind;
// The account that was accessed.
// It's either the account created, callee or a selfdestruct recipient for CREATE, CALL or SELFDESTRUCT.
address account;
// What accessed the account.
address accessor;
// If the account was initialized or empty prior to the access.
// An account is considered initialized if it has code, a
// non-zero nonce, or a non-zero balance.
bool initialized;
// The previous balance of the accessed account.
uint256 oldBalance;
// The potential new balance of the accessed account.
// That is, all balance changes are recorded here, even if reverts occurred.
uint256 newBalance;
// Code of the account deployed by CREATE.
bytes deployedCode;
// Value passed along with the account access
uint256 value;
// Input data provided to the CREATE or CALL
bytes data;
// If this access reverted in either the current or parent context.
bool reverted;
// An ordered list of storage accesses made during an account access operation.
StorageAccess[] storageAccesses;
// Call depth traversed during the recording of state differences
uint64 depth;
}
/// The storage accessed during an `AccountAccess`.
struct StorageAccess {
// The account whose storage was accessed.
address account;
// The slot that was accessed.
bytes32 slot;
// If the access was a write.
bool isWrite;
// The previous value of the slot.
bytes32 previousValue;
// The new value of the slot.
bytes32 newValue;
// If the access was reverted.
bool reverted;
}
/// Gas used. Returned by `lastCallGas`.
struct Gas {
// The gas limit of the call.
uint64 gasLimit;
// The total gas used.
uint64 gasTotalUsed;
// DEPRECATED: The amount of gas used for memory expansion. Ref: <https://github.com/foundry-rs/foundry/pull/7934#pullrequestreview-2069236939>
uint64 gasMemoryUsed;
// The amount of gas refunded.
int64 gasRefunded;
// The amount of gas remaining.
uint64 gasRemaining;
}
/// The result of the `stopDebugTraceRecording` call
struct DebugStep {
// The stack before executing the step of the run.
// stack\[0\] represents the top of the stack.
// and only stack data relevant to the opcode execution is contained.
uint256[] stack;
// The memory input data before executing the step of the run.
// only input data relevant to the opcode execution is contained.
// e.g. for MLOAD, it will have memory\[offset:offset+32\] copied here.
// the offset value can be get by the stack data.
bytes memoryInput;
// The opcode that was accessed.
uint8 opcode;
// The call depth of the step.
uint64 depth;
// Whether the call end up with out of gas error.
bool isOutOfGas;
// The contract address where the opcode is running
address contractAddr;
}
/// Represents a transaction's broadcast details.
struct BroadcastTxSummary {
// The hash of the transaction that was broadcasted
bytes32 txHash;
// Represent the type of transaction among CALL, CREATE, CREATE2
BroadcastTxType txType;
// The address of the contract that was called or created.
// This is address of the contract that is created if the txType is CREATE or CREATE2.
address contractAddress;
// The block number the transaction landed in.
uint64 blockNumber;
// Status of the transaction, retrieved from the transaction receipt.
bool success;
}
/// Holds a signed EIP-7702 authorization for an authority account to delegate to an implementation.
struct SignedDelegation {
// The y-parity of the recovered secp256k1 signature (0 or 1).
uint8 v;
// First 32 bytes of the signature.
bytes32 r;
// Second 32 bytes of the signature.
bytes32 s;
// The current nonce of the authority account at signing time.
// Used to ensure signature can't be replayed after account nonce changes.
uint64 nonce;
// Address of the contract implementation that will be delegated to.
// Gets encoded into delegation code: 0xef0100 || implementation.
address implementation;
}
/// Represents a "potential" revert reason from a single subsequent call when using `vm.assumeNoReverts`.
/// Reverts that match will result in a FOUNDRY::ASSUME rejection, whereas unmatched reverts will be surfaced
/// as normal.
struct PotentialRevert {
// The allowed origin of the revert opcode; address(0) allows reverts from any address
address reverter;
// When true, only matches on the beginning of the revert data, otherwise, matches on entire revert data
bool partialMatch;
// The data to use to match encountered reverts
bytes revertData;
}
/// An EIP-2930 access list item.
struct AccessListItem {
// The address to be added in access list.
address target;
// The storage keys to be added in access list.
bytes32[] storageKeys;
}
// ======== Crypto ========
/// Derives a private key from the name, labels the account with that name, and returns the wallet.
function createWallet(string calldata walletLabel) external returns (Wallet memory wallet);
/// Generates a wallet from the private key and returns the wallet.
function createWallet(uint256 privateKey) external returns (Wallet memory wallet);
/// Generates a wallet from the private key, labels the account with that name, and returns the wallet.
function createWallet(uint256 privateKey, string calldata walletLabel) external returns (Wallet memory wallet);
/// Derive a private key from a provided mnenomic string (or mnenomic file path)
/// at the derivation path `m/44'/60'/0'/0/{index}`.
function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey);
/// Derive a private key from a provided mnenomic string (or mnenomic file path)
/// at `{derivationPath}{index}`.
function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index)
external
pure
returns (uint256 privateKey);
/// Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
/// at the derivation path `m/44'/60'/0'/0/{index}`.
function deriveKey(string calldata mnemonic, uint32 index, string calldata language)
external
pure
returns (uint256 privateKey);
/// Derive a private key from a provided mnenomic string (or mnenomic file path) in the specified language
/// at `{derivationPath}{index}`.
function deriveKey(string calldata mnemonic, string calldata derivationPath, uint32 index, string calldata language)
external
pure
returns (uint256 privateKey);
/// Derives secp256r1 public key from the provided `privateKey`.
function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);
/// Adds a private key to the local forge wallet and returns the address.
function rememberKey(uint256 privateKey) external returns (address keyAddr);
/// Derive a set number of wallets from a mnemonic at the derivation path `m/44'/60'/0'/0/{0..count}`.
/// The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
function rememberKeys(string calldata mnemonic, string calldata derivationPath, uint32 count)
external
returns (address[] memory keyAddrs);
/// Derive a set number of wallets from a mnemonic in the specified language at the derivation path `m/44'/60'/0'/0/{0..count}`.
/// The respective private keys are saved to the local forge wallet for later use and their addresses are returned.
function rememberKeys(
string calldata mnemonic,
string calldata derivationPath,
string calldata language,
uint32 count
) external returns (address[] memory keyAddrs);
/// Signs data with a `Wallet`.
/// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
/// signature's `s` value, and the recovery id `v` in a single bytes32.
/// This format reduces the signature size from 65 to 64 bytes.
function signCompact(Wallet calldata wallet, bytes32 digest) external returns (bytes32 r, bytes32 vs);
/// Signs `digest` with `privateKey` using the secp256k1 curve.
/// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
/// signature's `s` value, and the recovery id `v` in a single bytes32.
/// This format reduces the signature size from 65 to 64 bytes.
function signCompact(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
/// Signs `digest` with signer provided to script using the secp256k1 curve.
/// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
/// signature's `s` value, and the recovery id `v` in a single bytes32.
/// This format reduces the signature size from 65 to 64 bytes.
/// If `--sender` is provided, the signer with provided address is used, otherwise,
/// if exactly one signer is provided to the script, that signer is used.
/// Raises error if signer passed through `--sender` does not match any unlocked signers or
/// if `--sender` is not provided and not exactly one signer is passed to the script.
function signCompact(bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
/// Signs `digest` with signer provided to script using the secp256k1 curve.
/// Returns a compact signature (`r`, `vs`) as per EIP-2098, where `vs` encodes both the
/// signature's `s` value, and the recovery id `v` in a single bytes32.
/// This format reduces the signature size from 65 to 64 bytes.
/// Raises error if none of the signers passed into the script have provided address.
function signCompact(address signer, bytes32 digest) external pure returns (bytes32 r, bytes32 vs);
/// Signs `digest` with `privateKey` using the secp256r1 curve.
function signP256(uint256 privateKey, bytes32 digest) external pure returns (bytes32 r, bytes32 s);
/// Signs data with a `Wallet`.
function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);
/// Signs `digest` with `privateKey` using the secp256k1 curve.
function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
/// Signs `digest` with signer provided to script using the secp256k1 curve.
/// If `--sender` is provided, the signer with provided address is used, otherwise,
/// if exactly one signer is provided to the script, that signer is used.
/// Raises error if signer passed through `--sender` does not match any unlocked signers or
/// if `--sender` is not provided and not exactly one signer is passed to the script.
function sign(bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
/// Signs `digest` with signer provided to script using the secp256k1 curve.
/// Raises error if none of the signers passed into the script have provided address.
function sign(address signer, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s);
// ======== Environment ========
/// Gets the environment variable `name` and parses it as `address`.
/// Reverts if the variable was not found or could not be parsed.
function envAddress(string calldata name) external view returns (address value);
/// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.
/// Reverts if the variable was not found or could not be parsed.
function envAddress(string calldata name, string calldata delim) external view returns (address[] memory value);
/// Gets the environment variable `name` and parses it as `bool`.
/// Reverts if the variable was not found or could not be parsed.
function envBool(string calldata name) external view returns (bool value);
/// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.
/// Reverts if the variable was not found or could not be parsed.
function envBool(string calldata name, string calldata delim) external view returns (bool[] memory value);
/// Gets the environment variable `name` and parses it as `bytes32`.
/// Reverts if the variable was not found or could not be parsed.
function envBytes32(string calldata name) external view returns (bytes32 value);
/// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.
/// Reverts if the variable was not found or could not be parsed.
function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory value);
/// Gets the environment variable `name` and parses it as `bytes`.
/// Reverts if the variable was not found or could not be parsed.
function envBytes(string calldata name) external view returns (bytes memory value);
/// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.
/// Reverts if the variable was not found or could not be parsed.
function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory value);
/// Gets the environment variable `name` and returns true if it exists, else returns false.
function envExists(string calldata name) external view returns (bool result);
/// Gets the environment variable `name` and parses it as `int256`.
/// Reverts if the variable was not found or could not be parsed.
function envInt(string calldata name) external view returns (int256 value);
/// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.
/// Reverts if the variable was not found or could not be parsed.
function envInt(string calldata name, string calldata delim) external view returns (int256[] memory value);
/// Gets the environment variable `name` and parses it as `bool`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, bool defaultValue) external view returns (bool value);
/// Gets the environment variable `name` and parses it as `uint256`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, uint256 defaultValue) external view returns (uint256 value);
/// Gets the environment variable `name` and parses it as an array of `address`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, string calldata delim, address[] calldata defaultValue)
external
view
returns (address[] memory value);
/// Gets the environment variable `name` and parses it as an array of `bytes32`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, string calldata delim, bytes32[] calldata defaultValue)
external
view
returns (bytes32[] memory value);
/// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, string calldata delim, string[] calldata defaultValue)
external
view
returns (string[] memory value);
/// Gets the environment variable `name` and parses it as an array of `bytes`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, string calldata delim, bytes[] calldata defaultValue)
external
view
returns (bytes[] memory value);
/// Gets the environment variable `name` and parses it as `int256`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, int256 defaultValue) external view returns (int256 value);
/// Gets the environment variable `name` and parses it as `address`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, address defaultValue) external view returns (address value);
/// Gets the environment variable `name` and parses it as `bytes32`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, bytes32 defaultValue) external view returns (bytes32 value);
/// Gets the environment variable `name` and parses it as `string`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, string calldata defaultValue) external view returns (string memory value);
/// Gets the environment variable `name` and parses it as `bytes`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, bytes calldata defaultValue) external view returns (bytes memory value);
/// Gets the environment variable `name` and parses it as an array of `bool`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, string calldata delim, bool[] calldata defaultValue)
external
view
returns (bool[] memory value);
/// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, string calldata delim, uint256[] calldata defaultValue)
external
view
returns (uint256[] memory value);
/// Gets the environment variable `name` and parses it as an array of `int256`, delimited by `delim`.
/// Reverts if the variable could not be parsed.
/// Returns `defaultValue` if the variable was not found.
function envOr(string calldata name, string calldata delim, int256[] calldata defaultValue)
external
view
returns (int256[] memory value);
/// Gets the environment variable `name` and parses it as `string`.
/// Reverts if the variable was not found or could not be parsed.
function envString(string calldata name) external view returns (string memory value);
/// Gets the environment variable `name` and parses it as an array of `string`, delimited by `delim`.
/// Reverts if the variable was not found or could not be parsed.
function envString(string calldata name, string calldata delim) external view returns (string[] memory value);
/// Gets the environment variable `name` and parses it as `uint256`.
/// Reverts if the variable was not found or could not be parsed.
function envUint(string calldata name) external view returns (uint256 value);
/// Gets the environment variable `name` and parses it as an array of `uint256`, delimited by `delim`.
/// Reverts if the variable was not found or could not be parsed.
function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory value);
/// Returns true if `forge` command was executed in given context.
function isContext(ForgeContext context) external view returns (bool result);
/// Sets environment variables.
function setEnv(string calldata name, string calldata value) external;
// ======== EVM ========
/// Gets all accessed reads and write slot from a `vm.record` session, for a given address.
function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);
/// Gets the address for a given private key.
function addr(uint256 privateKey) external pure returns (address keyAddr);
/// Gets all the logs according to specified filter.
function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
external
returns (EthGetLogs[] memory logs);
/// Gets the current `block.blobbasefee`.
/// You should use this instead of `block.blobbasefee` if you use `vm.blobBaseFee`, as `block.blobbasefee` is assumed to be constant across a transaction,
/// and as a result will get optimized out by the compiler.
/// See https://github.com/foundry-rs/foundry/issues/6180
function getBlobBaseFee() external view returns (uint256 blobBaseFee);
/// Gets the current `block.number`.
/// You should use this instead of `block.number` if you use `vm.roll`, as `block.number` is assumed to be constant across a transaction,
/// and as a result will get optimized out by the compiler.
/// See https://github.com/foundry-rs/foundry/issues/6180
function getBlockNumber() external view returns (uint256 height);
/// Gets the current `block.timestamp`.
/// You should use this instead of `block.timestamp` if you use `vm.warp`, as `block.timestamp` is assumed to be constant across a transaction,
/// and as a result will get optimized out by the compiler.
/// See https://github.com/foundry-rs/foundry/issues/6180
function getBlockTimestamp() external view returns (uint256 timestamp);
/// Gets the map key and parent of a mapping at a given slot, for a given address.
function getMappingKeyAndParentOf(address target, bytes32 elementSlot)
external
returns (bool found, bytes32 key, bytes32 parent);
/// Gets the number of elements in the mapping at the given slot, for a given address.
function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);
/// Gets the elements at index idx of the mapping at the given slot, for a given address. The
/// index must be less than the length of the mapping (i.e. the number of keys in the mapping).
function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);
/// Gets the nonce of an account.
function getNonce(address account) external view returns (uint64 nonce);
/// Get the nonce of a `Wallet`.
function getNonce(Wallet calldata wallet) external returns (uint64 nonce);
/// Gets all the recorded logs.
function getRecordedLogs() external returns (Log[] memory logs);
/// Returns state diffs from current `vm.startStateDiffRecording` session.
function getStateDiff() external view returns (string memory diff);
/// Returns state diffs from current `vm.startStateDiffRecording` session, in json format.
function getStateDiffJson() external view returns (string memory diff);
/// Gets the gas used in the last call from the callee perspective.
function lastCallGas() external view returns (Gas memory gas);
/// Loads a storage slot from an address.
function load(address target, bytes32 slot) external view returns (bytes32 data);
/// Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.
function pauseGasMetering() external;
/// Records all storage reads and writes. Use `accesses` to get the recorded data.
/// Subsequent calls to `record` will clear the previous data.
function record() external;
/// Record all the transaction logs.
function recordLogs() external;
/// Reset gas metering (i.e. gas usage is set to gas limit).
function resetGasMetering() external;
/// Resumes gas metering (i.e. gas usage is counted again). Noop if already on.
function resumeGasMetering() external;
/// Performs an Ethereum JSON-RPC request to the current fork URL.
function rpc(string calldata method, string calldata params) external returns (bytes memory data);
/// Performs an Ethereum JSON-RPC request to the given endpoint.
function rpc(string calldata urlOrAlias, string calldata method, string calldata params)
external
returns (bytes memory data);
/// Records the debug trace during the run.
function startDebugTraceRecording() external;
/// Starts recording all map SSTOREs for later retrieval.
function startMappingRecording() external;
/// Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order,
/// along with the context of the calls
function startStateDiffRecording() external;
/// Stop debug trace recording and returns the recorded debug trace.
function stopAndReturnDebugTraceRecording() external returns (DebugStep[] memory step);
/// Returns an ordered array of all account accesses from a `vm.startStateDiffRecording` session.
function stopAndReturnStateDiff() external returns (AccountAccess[] memory accountAccesses);
/// Stops recording all map SSTOREs for later retrieval and clears the recorded data.
function stopMappingRecording() external;
/// Stops recording storage reads and writes.
function stopRecord() external;
// ======== Filesystem ========
/// Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.
/// `path` is relative to the project root.
function closeFile(string calldata path) external;
/// Copies the contents of one file to another. This function will **overwrite** the contents of `to`.
/// On success, the total number of bytes copied is returned and it is equal to the length of the `to` file as reported by `metadata`.
/// Both `from` and `to` are relative to the project root.
function copyFile(string calldata from, string calldata to) external returns (uint64 copied);
/// Creates a new, empty directory at the provided path.
/// This cheatcode will revert in the following situations, but is not limited to just these cases:
/// - User lacks permissions to modify `path`.
/// - A parent of the given path doesn't exist and `recursive` is false.
/// - `path` already exists and `recursive` is false.
/// `path` is relative to the project root.
function createDir(string calldata path, bool recursive) external;
/// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
/// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
function deployCode(string calldata artifactPath) external returns (address deployedAddress);
/// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
/// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
/// Additionally accepts abi-encoded constructor arguments.
function deployCode(string calldata artifactPath, bytes calldata constructorArgs)
external
returns (address deployedAddress);
/// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
/// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
/// Additionally accepts `msg.value`.
function deployCode(string calldata artifactPath, uint256 value) external returns (address deployedAddress);
/// Deploys a contract from an artifact file. Takes in the relative path to the json file or the path to the
/// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
/// Additionally accepts abi-encoded constructor arguments and `msg.value`.
function deployCode(string calldata artifactPath, bytes calldata constructorArgs, uint256 value)
external
returns (address deployedAddress);
/// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
/// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
function deployCode(string calldata artifactPath, bytes32 salt) external returns (address deployedAddress);
/// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
/// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
/// Additionally accepts abi-encoded constructor arguments.
function deployCode(string calldata artifactPath, bytes calldata constructorArgs, bytes32 salt)
external
returns (address deployedAddress);
/// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
/// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
/// Additionally accepts `msg.value`.
function deployCode(string calldata artifactPath, uint256 value, bytes32 salt)
external
returns (address deployedAddress);
/// Deploys a contract from an artifact file, using the CREATE2 salt. Takes in the relative path to the json file or the path to the
/// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
/// Additionally accepts abi-encoded constructor arguments and `msg.value`.
function deployCode(string calldata artifactPath, bytes calldata constructorArgs, uint256 value, bytes32 salt)
external
returns (address deployedAddress);
/// Returns true if the given path points to an existing entity, else returns false.
function exists(string calldata path) external view returns (bool result);
/// Performs a foreign function call via the terminal.
function ffi(string[] calldata commandInput) external returns (bytes memory result);
/// Given a path, query the file system to get information about a file, directory, etc.
function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);
/// Gets the artifact path from code (aka. creation code).
function getArtifactPathByCode(bytes calldata code) external view returns (string memory path);
/// Gets the artifact path from deployed code (aka. runtime code).
function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path);
/// Returns the most recent broadcast for the given contract on `chainId` matching `txType`.
/// For example:
/// The most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`.
/// The most recent call can be fetched by passing `txType` as `CALL`.
function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType)
external
view
returns (BroadcastTxSummary memory);
/// Returns all broadcasts for the given contract on `chainId` with the specified `txType`.
/// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType)
external
view
returns (BroadcastTxSummary[] memory);
/// Returns all broadcasts for the given contract on `chainId`.
/// Sorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.
function getBroadcasts(string calldata contractName, uint64 chainId)
external
view
returns (BroadcastTxSummary[] memory);
/// Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the
/// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);
/// Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the
/// artifact in the form of <path>:<contract>:<version> where <contract> and <version> parts are optional.
function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);
/// Returns the most recent deployment for the current `chainId`.
function getDeployment(string calldata contractName) external view returns (address deployedAddress);
/// Returns the most recent deployment for the given contract on `chainId`
function getDeployment(string calldata contractName, uint64 chainId)
external
view
returns (address deployedAddress);
/// Returns all deployments for the given contract on `chainId`
/// Sorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.
/// The most recent deployment is the first element, and the oldest is the last.
function getDeployments(string calldata contractName, uint64 chainId)
external
view
returns (address[] memory deployedAddresses);
/// Returns true if the path exists on disk and is pointing at a directory, else returns false.
function isDir(string calldata path) external view returns (bool result);
/// Returns true if the path exists on disk and is pointing at a regular file, else returns false.
function isFile(string calldata path) external view returns (bool result);
/// Get the path of the current project root.
function projectRoot() external view returns (string memory path);
/// Prompts the user for a string value in the terminal.
function prompt(string calldata promptText) external returns (string memory input);
/// Prompts the user for an address in the terminal.
function promptAddress(string calldata promptText) external returns (address);
/// Prompts the user for a hidden string value in the terminal.
function promptSecret(string calldata promptText) external returns (string memory input);
/// Prompts the user for hidden uint256 in the terminal (usually pk).
function promptSecretUint(string calldata promptText) external returns (uint256);
/// Prompts the user for uint256 in the terminal.
function promptUint(string calldata promptText) external returns (uint256);
/// Reads the directory at the given path recursively, up to `maxDepth`.
/// `maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned.
/// Follows symbolic links if `followLinks` is true.
function readDir(string calldata path) external view returns (DirEntry[] memory entries);
/// See `readDir(string)`.
function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);
/// See `readDir(string)`.
function readDir(string calldata path, uint64 maxDepth, bool followLinks)
external
view
returns (DirEntry[] memory entries);
/// Reads the entire content of file to string. `path` is relative to the project root.
function readFile(string calldata path) external view returns (string memory data);
/// Reads the entire content of file as binary. `path` is relative to the project root.
function readFileBinary(string calldata path) external view returns (bytes memory data);
/// Reads next line of file to string.
function readLine(string calldata path) external view returns (string memory line);
/// Reads a symbolic link, returning the path that the link points to.
/// This cheatcode will revert in the following situations, but is not limited to just these cases:
/// - `path` is not a symbolic link.
/// - `path` does not exist.
function readLink(string calldata linkPath) external view returns (string memory targetPath);
/// Removes a directory at the provided path.
/// This cheatcode will revert in the following situations, but is not limited to just these cases:
/// - `path` doesn't exist.
/// - `path` isn't a directory.
/// - User lacks permissions to modify `path`.
/// - The directory is not empty and `recursive` is false.
/// `path` is relative to the project root.
function removeDir(string calldata path, bool recursive) external;
/// Removes a file from the filesystem.
/// This cheatcode will revert in the following situations, but is not limited to just these cases:
/// - `path` points to a directory.
/// - The file doesn't exist.
/// - The user lacks permissions to remove the file.
/// `path` is relative to the project root.
function removeFile(string calldata path) external;
/// Performs a foreign function call via terminal and returns the exit code, stdout, and stderr.
function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);
/// Returns the time since unix epoch in milliseconds.
function unixTime() external view returns (uint256 milliseconds);
/// Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.
/// `path` is relative to the project root.
function writeFile(string calldata path, string calldata data) external;
/// Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.
/// `path` is relative to the project root.
function writeFileBinary(string calldata path, bytes calldata data) external;
/// Writes line to file, creating a file if it does not exist.
/// `path` is relative to the project root.
function writeLine(string calldata path, string calldata data) external;
// ======== JSON ========
/// Checks if `key` exists in a JSON object.
function keyExistsJson(string calldata json, string calldata key) external view returns (bool);
/// Parses a string of JSON data at `key` and coerces it to `address`.
function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);
/// Parses a string of JSON data at `key` and coerces it to `address[]`.
function parseJsonAddressArray(string calldata json, string calldata key)
external
pure
returns (address[] memory);
/// Parses a string of JSON data at `key` and coerces it to `bool`.
function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);
/// Parses a string of JSON data at `key` and coerces it to `bool[]`.
function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);
/// Parses a string of JSON data at `key` and coerces it to `bytes`.
function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);
/// Parses a string of JSON data at `key` and coerces it to `bytes32`.
function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);
/// Parses a string of JSON data at `key` and coerces it to `bytes32[]`.
function parseJsonBytes32Array(string calldata json, string calldata key)
external
pure
returns (bytes32[] memory);
/// Parses a string of JSON data at `key` and coerces it to `bytes[]`.
function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);
/// Parses a string of JSON data at `key` and coerces it to `int256`.
function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);
/// Parses a string of JSON data at `key` and coerces it to `int256[]`.
function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);
/// Returns an array of all the keys in a JSON object.
function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);
/// Parses a string of JSON data at `key` and coerces it to `string`.
function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);
/// Parses a string of JSON data at `key` and coerces it to `string[]`.
function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);
/// Parses a string of JSON data at `key` and coerces it to type array corresponding to `typeDescription`.
function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
/// Parses a string of JSON data and coerces it to type corresponding to `typeDescription`.
function parseJsonType(string calldata json, string calldata typeDescription)
external
pure
returns (bytes memory);
/// Parses a string of JSON data at `key` and coerces it to type corresponding to `typeDescription`.
function parseJsonType(string calldata json, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
/// Parses a string of JSON data at `key` and coerces it to `uint256`.
function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);
/// Parses a string of JSON data at `key` and coerces it to `uint256[]`.
function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);
/// ABI-encodes a JSON object.
function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);
/// ABI-encodes a JSON object at `key`.
function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);
/// See `serializeJson`.
function serializeAddress(string calldata objectKey, string calldata valueKey, address value)
external
returns (string memory json);
/// See `serializeJson`.
function serializeAddress(string calldata objectKey, string calldata valueKey, address[] calldata values)
external
returns (string memory json);
/// See `serializeJson`.
function serializeBool(string calldata objectKey, string calldata valueKey, bool value)
external
returns (string memory json);
/// See `serializeJson`.
function serializeBool(string calldata objectKey, string calldata valueKey, bool[] calldata values)
external
returns (string memory json);
/// See `serializeJson`.
function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32 value)
external
returns (string memory json);
/// See `serializeJson`.
function serializeBytes32(string calldata objectKey, string calldata valueKey, bytes32[] calldata values)
external
returns (string memory json);
/// See `serializeJson`.
function serializeBytes(string calldata objectKey, string calldata valueKey, bytes calldata value)
external
returns (string memory json);
/// See `serializeJson`.
function serializeBytes(string calldata objectKey, string calldata valueKey, bytes[] calldata values)
external
returns (string memory json);
/// See `serializeJson`.
function serializeInt(string calldata objectKey, string calldata valueKey, int256 value)
external
returns (string memory json);
/// See `serializeJson`.
function serializeInt(string calldata objectKey, string calldata valueKey, int256[] calldata values)
external
returns (string memory json);
/// Serializes a key and value to a JSON object stored in-memory that can be later written to a file.
/// Returns the stringified version of the specific JSON file up to that moment.
function serializeJson(string calldata objectKey, string calldata value) external returns (string memory json);
/// See `serializeJson`.
function serializeJsonType(string calldata typeDescription, bytes calldata value)
external
pure
returns (string memory json);
/// See `serializeJson`.
function serializeJsonType(
string calldata objectKey,
string calldata valueKey,
string calldata typeDescription,
bytes calldata value
) external returns (string memory json);
/// See `serializeJson`.
function serializeString(string calldata objectKey, string calldata valueKey, string calldata value)
external
returns (string memory json);
/// See `serializeJson`.
function serializeString(string calldata objectKey, string calldata valueKey, string[] calldata values)
external
returns (string memory json);
/// See `serializeJson`.
function serializeUintToHex(string calldata objectKey, string calldata valueKey, uint256 value)
external
returns (string memory json);
/// See `serializeJson`.
function serializeUint(string calldata objectKey, string calldata valueKey, uint256 value)
external
returns (string memory json);
/// See `serializeJson`.
function serializeUint(string calldata objectKey, string calldata valueKey, uint256[] calldata values)
external
returns (string memory json);
/// Write a serialized JSON object to a file. If the file exists, it will be overwritten.
function writeJson(string calldata json, string calldata path) external;
/// Write a serialized JSON object to an **existing** JSON file, replacing a value with key = <value_key.>
/// This is useful to replace a specific value of a JSON file, without having to parse the entire thing.
function writeJson(string calldata json, string calldata path, string calldata valueKey) external;
/// Checks if `key` exists in a JSON object
/// `keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions.
function keyExists(string calldata json, string calldata key) external view returns (bool);
// ======== Scripting ========
/// Attach an EIP-4844 blob to the next call
function attachBlob(bytes calldata blob) external;
/// Designate the next call as an EIP-7702 transaction
function attachDelegation(SignedDelegation calldata signedDelegation) external;
/// Designate the next call as an EIP-7702 transaction, with optional cross-chain validity.
function attachDelegation(SignedDelegation calldata signedDelegation, bool crossChain) external;
/// Takes a signed transaction and broadcasts it to the network.
function broadcastRawTransaction(bytes calldata data) external;
/// Has the next call (at this call depth only) create transactions that can later be signed and sent onchain.
/// Broadcasting address is determined by checking the following in order:
/// 1. If `--sender` argument was provided, that address is used.
/// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used.
/// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
function broadcast() external;
/// Has the next call (at this call depth only) create a transaction with the address provided
/// as the sender that can later be signed and sent onchain.
function broadcast(address signer) external;
/// Has the next call (at this call depth only) create a transaction with the private key
/// provided as the sender that can later be signed and sent onchain.
function broadcast(uint256 privateKey) external;
/// Returns addresses of available unlocked wallets in the script environment.
function getWallets() external returns (address[] memory wallets);
/// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction
function signAndAttachDelegation(address implementation, uint256 privateKey)
external
returns (SignedDelegation memory signedDelegation);
/// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction for specific nonce
function signAndAttachDelegation(address implementation, uint256 privateKey, uint64 nonce)
external
returns (SignedDelegation memory signedDelegation);
/// Sign an EIP-7702 authorization and designate the next call as an EIP-7702 transaction, with optional cross-chain validity.
function signAndAttachDelegation(address implementation, uint256 privateKey, bool crossChain)
external
returns (SignedDelegation memory signedDelegation);
/// Sign an EIP-7702 authorization for delegation
function signDelegation(address implementation, uint256 privateKey)
external
returns (SignedDelegation memory signedDelegation);
/// Sign an EIP-7702 authorization for delegation for specific nonce
function signDelegation(address implementation, uint256 privateKey, uint64 nonce)
external
returns (SignedDelegation memory signedDelegation);
/// Sign an EIP-7702 authorization for delegation, with optional cross-chain validity.
function signDelegation(address implementation, uint256 privateKey, bool crossChain)
external
returns (SignedDelegation memory signedDelegation);
/// Has all subsequent calls (at this call depth only) create transactions that can later be signed and sent onchain.
/// Broadcasting address is determined by checking the following in order:
/// 1. If `--sender` argument was provided, that address is used.
/// 2. If exactly one signer (e.g. private key, hw wallet, keystore) is set when `forge broadcast` is invoked, that signer is used.
/// 3. Otherwise, default foundry sender (1804c8AB1F12E6bbf3894d4083f33e07309d1f38) is used.
function startBroadcast() external;
/// Has all subsequent calls (at this call depth only) create transactions with the address
/// provided that can later be signed and sent onchain.
function startBroadcast(address signer) external;
/// Has all subsequent calls (at this call depth only) create transactions with the private key
/// provided that can later be signed and sent onchain.
function startBroadcast(uint256 privateKey) external;
/// Stops collecting onchain transactions.
function stopBroadcast() external;
// ======== String ========
/// Returns true if `search` is found in `subject`, false otherwise.
function contains(string calldata subject, string calldata search) external returns (bool result);
/// Returns the index of the first occurrence of a `key` in an `input` string.
/// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found.
/// Returns 0 in case of an empty `key`.
function indexOf(string calldata input, string calldata key) external pure returns (uint256);
/// Parses the given `string` into an `address`.
function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);
/// Parses the given `string` into a `bool`.
function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);
/// Parses the given `string` into `bytes`.
function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);
/// Parses the given `string` into a `bytes32`.
function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);
/// Parses the given `string` into a `int256`.
function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);
/// Parses the given `string` into a `uint256`.
function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);
/// Replaces occurrences of `from` in the given `string` with `to`.
function replace(string calldata input, string calldata from, string calldata to)
external
pure
returns (string memory output);
/// Splits the given `string` into an array of strings divided by the `delimiter`.
function split(string calldata input, string calldata delimiter) external pure returns (string[] memory outputs);
/// Converts the given `string` value to Lowercase.
function toLowercase(string calldata input) external pure returns (string memory output);
/// Converts the given value to a `string`.
function toString(address value) external pure returns (string memory stringifiedValue);
/// Converts the given value to a `string`.
function toString(bytes calldata value) external pure returns (string memory stringifiedValue);
/// Converts the given value to a `string`.
function toString(bytes32 value) external pure returns (string memory stringifiedValue);
/// Converts the given value to a `string`.
function toString(bool value) external pure returns (string memory stringifiedValue);
/// Converts the given value to a `string`.
function toString(uint256 value) external pure returns (string memory stringifiedValue);
/// Converts the given value to a `string`.
function toString(int256 value) external pure returns (string memory stringifiedValue);
/// Converts the given `string` value to Uppercase.
function toUppercase(string calldata input) external pure returns (string memory output);
/// Trims leading and trailing whitespace from the given `string` value.
function trim(string calldata input) external pure returns (string memory output);
// ======== Testing ========
/// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
/// Formats values with decimals in failure message.
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals) external pure;
/// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqAbsDecimal(
uint256 left,
uint256 right,
uint256 maxDelta,
uint256 decimals,
string calldata error
) external pure;
/// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
/// Formats values with decimals in failure message.
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals) external pure;
/// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqAbsDecimal(
int256 left,
int256 right,
uint256 maxDelta,
uint256 decimals,
string calldata error
) external pure;
/// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) external pure;
/// Compares two `uint256` values. Expects difference to be less than or equal to `maxDelta`.
/// Includes error message into revert string on failure.
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string calldata error) external pure;
/// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) external pure;
/// Compares two `int256` values. Expects difference to be less than or equal to `maxDelta`.
/// Includes error message into revert string on failure.
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string calldata error) external pure;
/// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
/// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
/// Formats values with decimals in failure message.
function assertApproxEqRelDecimal(uint256 left, uint256 right, uint256 maxPercentDelta, uint256 decimals)
external
pure;
/// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
/// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqRelDecimal(
uint256 left,
uint256 right,
uint256 maxPercentDelta,
uint256 decimals,
string calldata error
) external pure;
/// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
/// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
/// Formats values with decimals in failure message.
function assertApproxEqRelDecimal(int256 left, int256 right, uint256 maxPercentDelta, uint256 decimals)
external
pure;
/// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
/// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertApproxEqRelDecimal(
int256 left,
int256 right,
uint256 maxPercentDelta,
uint256 decimals,
string calldata error
) external pure;
/// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
/// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta) external pure;
/// Compares two `uint256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
/// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
/// Includes error message into revert string on failure.
function assertApproxEqRel(uint256 left, uint256 right, uint256 maxPercentDelta, string calldata error)
external
pure;
/// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
/// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) external pure;
/// Compares two `int256` values. Expects relative difference in percents to be less than or equal to `maxPercentDelta`.
/// `maxPercentDelta` is an 18 decimal fixed point number, where 1e18 == 100%
/// Includes error message into revert string on failure.
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta, string calldata error)
external
pure;
/// Asserts that two `uint256` values are equal, formatting them with decimals in failure message.
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
/// Asserts that two `uint256` values are equal, formatting them with decimals in failure message.
/// Includes error message into revert string on failure.
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
/// Asserts that two `int256` values are equal, formatting them with decimals in failure message.
function assertEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
/// Asserts that two `int256` values are equal, formatting them with decimals in failure message.
/// Includes error message into revert string on failure.
function assertEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
/// Asserts that two `bool` values are equal.
function assertEq(bool left, bool right) external pure;
/// Asserts that two `bool` values are equal and includes error message into revert string on failure.
function assertEq(bool left, bool right, string calldata error) external pure;
/// Asserts that two `string` values are equal.
function assertEq(string calldata left, string calldata right) external pure;
/// Asserts that two `string` values are equal and includes error message into revert string on failure.
function assertEq(string calldata left, string calldata right, string calldata error) external pure;
/// Asserts that two `bytes` values are equal.
function assertEq(bytes calldata left, bytes calldata right) external pure;
/// Asserts that two `bytes` values are equal and includes error message into revert string on failure.
function assertEq(bytes calldata left, bytes calldata right, string calldata error) external pure;
/// Asserts that two arrays of `bool` values are equal.
function assertEq(bool[] calldata left, bool[] calldata right) external pure;
/// Asserts that two arrays of `bool` values are equal and includes error message into revert string on failure.
function assertEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;
/// Asserts that two arrays of `uint256 values are equal.
function assertEq(uint256[] calldata left, uint256[] calldata right) external pure;
/// Asserts that two arrays of `uint256` values are equal and includes error message into revert string on failure.
function assertEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;
/// Asserts that two arrays of `int256` values are equal.
function assertEq(int256[] calldata left, int256[] calldata right) external pure;
/// Asserts that two arrays of `int256` values are equal and includes error message into revert string on failure.
function assertEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;
/// Asserts that two `uint256` values are equal.
function assertEq(uint256 left, uint256 right) external pure;
/// Asserts that two arrays of `address` values are equal.
function assertEq(address[] calldata left, address[] calldata right) external pure;
/// Asserts that two arrays of `address` values are equal and includes error message into revert string on failure.
function assertEq(address[] calldata left, address[] calldata right, string calldata error) external pure;
/// Asserts that two arrays of `bytes32` values are equal.
function assertEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
/// Asserts that two arrays of `bytes32` values are equal and includes error message into revert string on failure.
function assertEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;
/// Asserts that two arrays of `string` values are equal.
function assertEq(string[] calldata left, string[] calldata right) external pure;
/// Asserts that two arrays of `string` values are equal and includes error message into revert string on failure.
function assertEq(string[] calldata left, string[] calldata right, string calldata error) external pure;
/// Asserts that two arrays of `bytes` values are equal.
function assertEq(bytes[] calldata left, bytes[] calldata right) external pure;
/// Asserts that two arrays of `bytes` values are equal and includes error message into revert string on failure.
function assertEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;
/// Asserts that two `uint256` values are equal and includes error message into revert string on failure.
function assertEq(uint256 left, uint256 right, string calldata error) external pure;
/// Asserts that two `int256` values are equal.
function assertEq(int256 left, int256 right) external pure;
/// Asserts that two `int256` values are equal and includes error message into revert string on failure.
function assertEq(int256 left, int256 right, string calldata error) external pure;
/// Asserts that two `address` values are equal.
function assertEq(address left, address right) external pure;
/// Asserts that two `address` values are equal and includes error message into revert string on failure.
function assertEq(address left, address right, string calldata error) external pure;
/// Asserts that two `bytes32` values are equal.
function assertEq(bytes32 left, bytes32 right) external pure;
/// Asserts that two `bytes32` values are equal and includes error message into revert string on failure.
function assertEq(bytes32 left, bytes32 right, string calldata error) external pure;
/// Asserts that the given condition is false.
function assertFalse(bool condition) external pure;
/// Asserts that the given condition is false and includes error message into revert string on failure.
function assertFalse(bool condition, string calldata error) external pure;
/// Compares two `uint256` values. Expects first value to be greater than or equal to second.
/// Formats values with decimals in failure message.
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
/// Compares two `uint256` values. Expects first value to be greater than or equal to second.
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
/// Compares two `int256` values. Expects first value to be greater than or equal to second.
/// Formats values with decimals in failure message.
function assertGeDecimal(int256 left, int256 right, uint256 decimals) external pure;
/// Compares two `int256` values. Expects first value to be greater than or equal to second.
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
/// Compares two `uint256` values. Expects first value to be greater than or equal to second.
function assertGe(uint256 left, uint256 right) external pure;
/// Compares two `uint256` values. Expects first value to be greater than or equal to second.
/// Includes error message into revert string on failure.
function assertGe(uint256 left, uint256 right, string calldata error) external pure;
/// Compares two `int256` values. Expects first value to be greater than or equal to second.
function assertGe(int256 left, int256 right) external pure;
/// Compares two `int256` values. Expects first value to be greater than or equal to second.
/// Includes error message into revert string on failure.
function assertGe(int256 left, int256 right, string calldata error) external pure;
/// Compares two `uint256` values. Expects first value to be greater than second.
/// Formats values with decimals in failure message.
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
/// Compares two `uint256` values. Expects first value to be greater than second.
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
/// Compares two `int256` values. Expects first value to be greater than second.
/// Formats values with decimals in failure message.
function assertGtDecimal(int256 left, int256 right, uint256 decimals) external pure;
/// Compares two `int256` values. Expects first value to be greater than second.
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertGtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
/// Compares two `uint256` values. Expects first value to be greater than second.
function assertGt(uint256 left, uint256 right) external pure;
/// Compares two `uint256` values. Expects first value to be greater than second.
/// Includes error message into revert string on failure.
function assertGt(uint256 left, uint256 right, string calldata error) external pure;
/// Compares two `int256` values. Expects first value to be greater than second.
function assertGt(int256 left, int256 right) external pure;
/// Compares two `int256` values. Expects first value to be greater than second.
/// Includes error message into revert string on failure.
function assertGt(int256 left, int256 right, string calldata error) external pure;
/// Compares two `uint256` values. Expects first value to be less than or equal to second.
/// Formats values with decimals in failure message.
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
/// Compares two `uint256` values. Expects first value to be less than or equal to second.
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
/// Compares two `int256` values. Expects first value to be less than or equal to second.
/// Formats values with decimals in failure message.
function assertLeDecimal(int256 left, int256 right, uint256 decimals) external pure;
/// Compares two `int256` values. Expects first value to be less than or equal to second.
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLeDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
/// Compares two `uint256` values. Expects first value to be less than or equal to second.
function assertLe(uint256 left, uint256 right) external pure;
/// Compares two `uint256` values. Expects first value to be less than or equal to second.
/// Includes error message into revert string on failure.
function assertLe(uint256 left, uint256 right, string calldata error) external pure;
/// Compares two `int256` values. Expects first value to be less than or equal to second.
function assertLe(int256 left, int256 right) external pure;
/// Compares two `int256` values. Expects first value to be less than or equal to second.
/// Includes error message into revert string on failure.
function assertLe(int256 left, int256 right, string calldata error) external pure;
/// Compares two `uint256` values. Expects first value to be less than second.
/// Formats values with decimals in failure message.
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
/// Compares two `uint256` values. Expects first value to be less than second.
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
/// Compares two `int256` values. Expects first value to be less than second.
/// Formats values with decimals in failure message.
function assertLtDecimal(int256 left, int256 right, uint256 decimals) external pure;
/// Compares two `int256` values. Expects first value to be less than second.
/// Formats values with decimals in failure message. Includes error message into revert string on failure.
function assertLtDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
/// Compares two `uint256` values. Expects first value to be less than second.
function assertLt(uint256 left, uint256 right) external pure;
/// Compares two `uint256` values. Expects first value to be less than second.
/// Includes error message into revert string on failure.
function assertLt(uint256 left, uint256 right, string calldata error) external pure;
/// Compares two `int256` values. Expects first value to be less than second.
function assertLt(int256 left, int256 right) external pure;
/// Compares two `int256` values. Expects first value to be less than second.
/// Includes error message into revert string on failure.
function assertLt(int256 left, int256 right, string calldata error) external pure;
/// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message.
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) external pure;
/// Asserts that two `uint256` values are not equal, formatting them with decimals in failure message.
/// Includes error message into revert string on failure.
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string calldata error) external pure;
/// Asserts that two `int256` values are not equal, formatting them with decimals in failure message.
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) external pure;
/// Asserts that two `int256` values are not equal, formatting them with decimals in failure message.
/// Includes error message into revert string on failure.
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string calldata error) external pure;
/// Asserts that two `bool` values are not equal.
function assertNotEq(bool left, bool right) external pure;
/// Asserts that two `bool` values are not equal and includes error message into revert string on failure.
function assertNotEq(bool left, bool right, string calldata error) external pure;
/// Asserts that two `string` values are not equal.
function assertNotEq(string calldata left, string calldata right) external pure;
/// Asserts that two `string` values are not equal and includes error message into revert string on failure.
function assertNotEq(string calldata left, string calldata right, string calldata error) external pure;
/// Asserts that two `bytes` values are not equal.
function assertNotEq(bytes calldata left, bytes calldata right) external pure;
/// Asserts that two `bytes` values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes calldata left, bytes calldata right, string calldata error) external pure;
/// Asserts that two arrays of `bool` values are not equal.
function assertNotEq(bool[] calldata left, bool[] calldata right) external pure;
/// Asserts that two arrays of `bool` values are not equal and includes error message into revert string on failure.
function assertNotEq(bool[] calldata left, bool[] calldata right, string calldata error) external pure;
/// Asserts that two arrays of `uint256` values are not equal.
function assertNotEq(uint256[] calldata left, uint256[] calldata right) external pure;
/// Asserts that two arrays of `uint256` values are not equal and includes error message into revert string on failure.
function assertNotEq(uint256[] calldata left, uint256[] calldata right, string calldata error) external pure;
/// Asserts that two arrays of `int256` values are not equal.
function assertNotEq(int256[] calldata left, int256[] calldata right) external pure;
/// Asserts that two arrays of `int256` values are not equal and includes error message into revert string on failure.
function assertNotEq(int256[] calldata left, int256[] calldata right, string calldata error) external pure;
/// Asserts that two `uint256` values are not equal.
function assertNotEq(uint256 left, uint256 right) external pure;
/// Asserts that two arrays of `address` values are not equal.
function assertNotEq(address[] calldata left, address[] calldata right) external pure;
/// Asserts that two arrays of `address` values are not equal and includes error message into revert string on failure.
function assertNotEq(address[] calldata left, address[] calldata right, string calldata error) external pure;
/// Asserts that two arrays of `bytes32` values are not equal.
function assertNotEq(bytes32[] calldata left, bytes32[] calldata right) external pure;
/// Asserts that two arrays of `bytes32` values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes32[] calldata left, bytes32[] calldata right, string calldata error) external pure;
/// Asserts that two arrays of `string` values are not equal.
function assertNotEq(string[] calldata left, string[] calldata right) external pure;
/// Asserts that two arrays of `string` values are not equal and includes error message into revert string on failure.
function assertNotEq(string[] calldata left, string[] calldata right, string calldata error) external pure;
/// Asserts that two arrays of `bytes` values are not equal.
function assertNotEq(bytes[] calldata left, bytes[] calldata right) external pure;
/// Asserts that two arrays of `bytes` values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes[] calldata left, bytes[] calldata right, string calldata error) external pure;
/// Asserts that two `uint256` values are not equal and includes error message into revert string on failure.
function assertNotEq(uint256 left, uint256 right, string calldata error) external pure;
/// Asserts that two `int256` values are not equal.
function assertNotEq(int256 left, int256 right) external pure;
/// Asserts that two `int256` values are not equal and includes error message into revert string on failure.
function assertNotEq(int256 left, int256 right, string calldata error) external pure;
/// Asserts that two `address` values are not equal.
function assertNotEq(address left, address right) external pure;
/// Asserts that two `address` values are not equal and includes error message into revert string on failure.
function assertNotEq(address left, address right, string calldata error) external pure;
/// Asserts that two `bytes32` values are not equal.
function assertNotEq(bytes32 left, bytes32 right) external pure;
/// Asserts that two `bytes32` values are not equal and includes error message into revert string on failure.
function assertNotEq(bytes32 left, bytes32 right, string calldata error) external pure;
/// Asserts that the given condition is true.
function assertTrue(bool condition) external pure;
/// Asserts that the given condition is true and includes error message into revert string on failure.
function assertTrue(bool condition, string calldata error) external pure;
/// If the condition is false, discard this run's fuzz inputs and generate new ones.
function assume(bool condition) external pure;
/// Discard this run's fuzz inputs and generate new ones if next call reverted.
function assumeNoRevert() external pure;
/// Discard this run's fuzz inputs and generate new ones if next call reverts with the potential revert parameters.
function assumeNoRevert(PotentialRevert calldata potentialRevert) external pure;
/// Discard this run's fuzz inputs and generate new ones if next call reverts with the any of the potential revert parameters.
function assumeNoRevert(PotentialRevert[] calldata potentialReverts) external pure;
/// Writes a breakpoint to jump to in the debugger.
function breakpoint(string calldata char) external pure;
/// Writes a conditional breakpoint to jump to in the debugger.
function breakpoint(string calldata char, bool value) external pure;
/// Returns true if the current Foundry version is greater than or equal to the given version.
/// The given version string must be in the format `major.minor.patch`.
/// This is equivalent to `foundryVersionCmp(version) >= 0`.
function foundryVersionAtLeast(string calldata version) external view returns (bool);
/// Compares the current Foundry version with the given version string.
/// The given version string must be in the format `major.minor.patch`.
/// Returns:
/// -1 if current Foundry version is less than the given version
/// 0 if current Foundry version equals the given version
/// 1 if current Foundry version is greater than the given version
/// This result can then be used with a comparison operator against `0`.
/// For example, to check if the current Foundry version is greater than or equal to `1.0.0`:
/// `if (foundryVersionCmp("1.0.0") >= 0) { ... }`
function foundryVersionCmp(string calldata version) external view returns (int256);
/// Returns a Chain struct for specific alias
function getChain(string calldata chainAlias) external view returns (Chain memory chain);
/// Returns a Chain struct for specific chainId
function getChain(uint256 chainId) external view returns (Chain memory chain);
/// Returns the Foundry version.
/// Format: <cargo_version>-<tag>+<git_sha_short>.<unix_build_timestamp>.<profile>
/// Sample output: 0.3.0-nightly+3cb96bde9b.1737036656.debug
/// Note: Build timestamps may vary slightly across platforms due to separate CI jobs.
/// For reliable version comparisons, use UNIX format (e.g., >= 1700000000)
/// to compare timestamps while ignoring minor time differences.
function getFoundryVersion() external view returns (string memory version);
/// Returns the RPC url for the given alias.
function rpcUrl(string calldata rpcAlias) external view returns (string memory json);
/// Returns all rpc urls and their aliases as structs.
function rpcUrlStructs() external view returns (Rpc[] memory urls);
/// Returns all rpc urls and their aliases `[alias, url][]`.
function rpcUrls() external view returns (string[2][] memory urls);
/// Suspends execution of the main thread for `duration` milliseconds.
function sleep(uint256 duration) external;
// ======== Toml ========
/// Checks if `key` exists in a TOML table.
function keyExistsToml(string calldata toml, string calldata key) external view returns (bool);
/// Parses a string of TOML data at `key` and coerces it to `address`.
function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address);
/// Parses a string of TOML data at `key` and coerces it to `address[]`.
function parseTomlAddressArray(string calldata toml, string calldata key)
external
pure
returns (address[] memory);
/// Parses a string of TOML data at `key` and coerces it to `bool`.
function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool);
/// Parses a string of TOML data at `key` and coerces it to `bool[]`.
function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory);
/// Parses a string of TOML data at `key` and coerces it to `bytes`.
function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory);
/// Parses a string of TOML data at `key` and coerces it to `bytes32`.
function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32);
/// Parses a string of TOML data at `key` and coerces it to `bytes32[]`.
function parseTomlBytes32Array(string calldata toml, string calldata key)
external
pure
returns (bytes32[] memory);
/// Parses a string of TOML data at `key` and coerces it to `bytes[]`.
function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory);
/// Parses a string of TOML data at `key` and coerces it to `int256`.
function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256);
/// Parses a string of TOML data at `key` and coerces it to `int256[]`.
function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory);
/// Returns an array of all the keys in a TOML table.
function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys);
/// Parses a string of TOML data at `key` and coerces it to `string`.
function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory);
/// Parses a string of TOML data at `key` and coerces it to `string[]`.
function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory);
/// Parses a string of TOML data at `key` and coerces it to type array corresponding to `typeDescription`.
function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
/// Parses a string of TOML data and coerces it to type corresponding to `typeDescription`.
function parseTomlType(string calldata toml, string calldata typeDescription)
external
pure
returns (bytes memory);
/// Parses a string of TOML data at `key` and coerces it to type corresponding to `typeDescription`.
function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription)
external
pure
returns (bytes memory);
/// Parses a string of TOML data at `key` and coerces it to `uint256`.
function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256);
/// Parses a string of TOML data at `key` and coerces it to `uint256[]`.
function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory);
/// ABI-encodes a TOML table.
function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData);
/// ABI-encodes a TOML table at `key`.
function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData);
/// Takes serialized JSON, converts to TOML and write a serialized TOML to a file.
function writeToml(string calldata json, string calldata path) external;
/// Takes serialized JSON, converts to TOML and write a serialized TOML table to an **existing** TOML file, replacing a value with key = <value_key.>
/// This is useful to replace a specific value of a TOML file, without having to parse the entire thing.
function writeToml(string calldata json, string calldata path, string calldata valueKey) external;
// ======== Utilities ========
/// Compute the address of a contract created with CREATE2 using the given CREATE2 deployer.
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash, address deployer)
external
pure
returns (address);
/// Compute the address of a contract created with CREATE2 using the default CREATE2 deployer.
function computeCreate2Address(bytes32 salt, bytes32 initCodeHash) external pure returns (address);
/// Compute the address a contract will be deployed at for a given deployer address and nonce.
function computeCreateAddress(address deployer, uint256 nonce) external pure returns (address);
/// Utility cheatcode to copy storage of `from` contract to another `to` contract.
function copyStorage(address from, address to) external;
/// Returns ENS namehash for provided string.
function ensNamehash(string calldata name) external pure returns (bytes32);
/// Gets the label for the specified address.
function getLabel(address account) external view returns (string memory currentLabel);
/// Labels an address in call traces.
function label(address account, string calldata newLabel) external;
/// Pauses collection of call traces. Useful in cases when you want to skip tracing of
/// complex calls which are not useful for debugging.
function pauseTracing() external view;
/// Returns a random `address`.
function randomAddress() external returns (address);
/// Returns a random `bool`.
function randomBool() external view returns (bool);
/// Returns a random byte array value of the given length.
function randomBytes(uint256 len) external view returns (bytes memory);
/// Returns a random fixed-size byte array of length 4.
function randomBytes4() external view returns (bytes4);
/// Returns a random fixed-size byte array of length 8.
function randomBytes8() external view returns (bytes8);
/// Returns a random `int256` value.
function randomInt() external view returns (int256);
/// Returns a random `int256` value of given bits.
function randomInt(uint256 bits) external view returns (int256);
/// Returns a random uint256 value.
function randomUint() external returns (uint256);
/// Returns random uint256 value between the provided range (=min..=max).
function randomUint(uint256 min, uint256 max) external returns (uint256);
/// Returns a random `uint256` value of given bits.
function randomUint(uint256 bits) external view returns (uint256);
/// Unpauses collection of call traces.
function resumeTracing() external view;
/// Utility cheatcode to set arbitrary storage for given target address.
function setArbitraryStorage(address target) external;
/// Utility cheatcode to set arbitrary storage for given target address and overwrite
/// any storage slots that have been previously set.
function setArbitraryStorage(address target, bool overwrite) external;
/// Randomly shuffles an array.
function shuffle(uint256[] calldata array) external returns (uint256[] memory);
/// Sorts an array in ascending order.
function sort(uint256[] calldata array) external returns (uint256[] memory);
/// Encodes a `bytes` value to a base64url string.
function toBase64URL(bytes calldata data) external pure returns (string memory);
/// Encodes a `string` value to a base64url string.
function toBase64URL(string calldata data) external pure returns (string memory);
/// Encodes a `bytes` value to a base64 string.
function toBase64(bytes calldata data) external pure returns (string memory);
/// Encodes a `string` value to a base64 string.
function toBase64(string calldata data) external pure returns (string memory);
// Generates the hash of the canonical EIP-712 type representation.
//
// Supports 2 different inputs:
// 1. Name of the type (i.e. "Transaction"):
// * requires previous binding generation with `forge bind-json`.
// * bindings will be retrieved from the path configured in `foundry.toml`.
//
// 2. String representation of the type (i.e. "Foo(Bar bar) Bar(uint256 baz)").
// * Note: the cheatcode will output the canonical type even if the input is malformated
// with the wrong order of elements or with extra whitespaces.
function eip712HashType(string calldata typeNameOrDefinition) external pure returns (bytes32 typeHash);
// Generates the hash of the canonical EIP-712 type representation.
// Requires previous binding generation with `forge bind-json`.
//
// Params:
// * `bindingsPath`: path where the output of `forge bind-json` is stored.
// * `typeName`: Name of the type (i.e. "Transaction").
function eip712HashType(string calldata bindingsPath, string calldata typeName)
external
pure
returns (bytes32 typeHash);
// Generates the struct hash of the canonical EIP-712 type representation and its abi-encoded data.
//
// Supports 2 different inputs:
// 1. Name of the type (i.e. "PermitSingle"):
// * requires previous binding generation with `forge bind-json`.
// * bindings will be retrieved from the path configured in `foundry.toml`.
//
// 2. String representation of the type (i.e. "Foo(Bar bar) Bar(uint256 baz)").
// * Note: the cheatcode will use the canonical type even if the input is malformated
// with the wrong order of elements or with extra whitespaces.
function eip712HashStruct(string calldata typeNameOrDefinition, bytes calldata abiEncodedData)
external
pure
returns (bytes32 typeHash);
// Generates the struct hash of the canonical EIP-712 type representation and its abi-encoded data.
// Requires previous binding generation with `forge bind-json`.
//
// Params:
// * `bindingsPath`: path where the output of `forge bind-json` is stored.
// * `typeName`: Name of the type (i.e. "PermitSingle").
// * `abiEncodedData`: ABI-encoded data for the struct that is being hashed.
function eip712HashStruct(string calldata bindingsPath, string calldata typeName, bytes calldata abiEncodedData)
external
pure
returns (bytes32 typeHash);
// Generates a ready-to-sign digest of human-readable typed data following the EIP-712 standard.
function eip712HashTypedData(string calldata jsonData) external pure returns (bytes32 digest);
}
/// The `Vm` interface does allow manipulation of the EVM state. These are all intended to be used
/// in tests, but it is not recommended to use these cheats in scripts.
interface Vm is VmSafe {
// ======== EVM ========
/// Utility cheatcode to set an EIP-2930 access list for all subsequent transactions.
function accessList(AccessListItem[] calldata access) external;
/// Returns the identifier of the currently active fork. Reverts if no fork is currently active.
function activeFork() external view returns (uint256 forkId);
/// In forking mode, explicitly grant the given address cheatcode access.
function allowCheatcodes(address account) external;
/// Sets `block.blobbasefee`
function blobBaseFee(uint256 newBlobBaseFee) external;
/// Sets the blobhashes in the transaction.
/// Not available on EVM versions before Cancun.
/// If used on unsupported EVM versions it will revert.
function blobhashes(bytes32[] calldata hashes) external;
/// Sets `block.chainid`.
function chainId(uint256 newChainId) external;
/// Clears all mocked calls.
function clearMockedCalls() external;
/// Clones a source account code, state, balance and nonce to a target account and updates in-memory EVM state.
function cloneAccount(address source, address target) external;
/// Sets `block.coinbase`.
function coinbase(address newCoinbase) external;
/// Marks the slots of an account and the account address as cold.
function cool(address target) external;
/// Utility cheatcode to mark specific storage slot as cold, simulating no prior read.
function coolSlot(address target, bytes32 slot) external;
/// Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork.
function createFork(string calldata urlOrAlias) external returns (uint256 forkId);
/// Creates a new fork with the given endpoint and block and returns the identifier of the fork.
function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
/// Creates a new fork with the given endpoint and at the block the given transaction was mined in,
/// replays all transaction mined in the block before the transaction, and returns the identifier of the fork.
function createFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
/// Creates and also selects a new fork with the given endpoint and the latest block and returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias) external returns (uint256 forkId);
/// Creates and also selects a new fork with the given endpoint and block and returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256 forkId);
/// Creates and also selects new fork with the given endpoint and at the block the given transaction was mined in,
/// replays all transaction mined in the block before the transaction, returns the identifier of the fork.
function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId);
/// Sets an address' balance.
function deal(address account, uint256 newBalance) external;
/// Removes the snapshot with the given ID created by `snapshot`.
/// Takes the snapshot ID to delete.
/// Returns `true` if the snapshot was successfully deleted.
/// Returns `false` if the snapshot does not exist.
function deleteStateSnapshot(uint256 snapshotId) external returns (bool success);
/// Removes _all_ snapshots previously created by `snapshot`.
function deleteStateSnapshots() external;
/// Sets `block.difficulty`.
/// Not available on EVM versions from Paris onwards. Use `prevrandao` instead.
/// Reverts if used on unsupported EVM versions.
function difficulty(uint256 newDifficulty) external;
/// Dump a genesis JSON file's `allocs` to disk.
function dumpState(string calldata pathToStateJson) external;
/// Sets an address' code.
function etch(address target, bytes calldata newRuntimeBytecode) external;
/// Sets `block.basefee`.
function fee(uint256 newBasefee) external;
/// Gets the blockhashes from the current transaction.
/// Not available on EVM versions before Cancun.
/// If used on unsupported EVM versions it will revert.
function getBlobhashes() external view returns (bytes32[] memory hashes);
/// Returns true if the account is marked as persistent.
function isPersistent(address account) external view returns (bool persistent);
/// Load a genesis JSON file's `allocs` into the in-memory EVM state.
function loadAllocs(string calldata pathToAllocsJson) external;
/// Marks that the account(s) should use persistent storage across fork swaps in a multifork setup
/// Meaning, changes made to the state of this account will be kept when switching forks.
function makePersistent(address account) external;
/// See `makePersistent(address)`.
function makePersistent(address account0, address account1) external;
/// See `makePersistent(address)`.
function makePersistent(address account0, address account1, address account2) external;
/// See `makePersistent(address)`.
function makePersistent(address[] calldata accounts) external;
/// Reverts a call to an address with specified revert data.
function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;
/// Reverts a call to an address with a specific `msg.value`, with specified revert data.
function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData)
external;
/// Reverts a call to an address with specified revert data.
/// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external;
/// Reverts a call to an address with a specific `msg.value`, with specified revert data.
/// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData) external;
/// Mocks a call to an address, returning specified data.
/// Calldata can either be strict or a partial match, e.g. if you only
/// pass a Solidity selector to the expected calldata, then the entire Solidity
/// function will be mocked.
function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;
/// Mocks a call to an address with a specific `msg.value`, returning specified data.
/// Calldata match takes precedence over `msg.value` in case of ambiguity.
function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;
/// Mocks a call to an address, returning specified data.
/// Calldata can either be strict or a partial match, e.g. if you only
/// pass a Solidity selector to the expected calldata, then the entire Solidity
/// function will be mocked.
/// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
function mockCall(address callee, bytes4 data, bytes calldata returnData) external;
/// Mocks a call to an address with a specific `msg.value`, returning specified data.
/// Calldata match takes precedence over `msg.value` in case of ambiguity.
/// Overload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.
function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external;
/// Mocks multiple calls to an address, returning specified data for each call.
function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external;
/// Mocks multiple calls to an address with a specific `msg.value`, returning specified data for each call.
function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external;
/// Whenever a call is made to `callee` with calldata `data`, this cheatcode instead calls
/// `target` with the same calldata. This functionality is similar to a delegate call made to
/// `target` contract from `callee`.
/// Can be used to substitute a call to a function with another implementation that captures
/// the primary logic of the original function but is easier to reason about.
/// If calldata is not a strict match then partial match by selector is attempted.
function mockFunction(address callee, address target, bytes calldata data) external;
/// Utility cheatcode to remove any EIP-2930 access list set by `accessList` cheatcode.
function noAccessList() external;
/// Sets the *next* call's `msg.sender` to be the input address.
function prank(address msgSender) external;
/// Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.
function prank(address msgSender, address txOrigin) external;
/// Sets the *next* delegate call's `msg.sender` to be the input address.
function prank(address msgSender, bool delegateCall) external;
/// Sets the *next* delegate call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.
function prank(address msgSender, address txOrigin, bool delegateCall) external;
/// Sets `block.prevrandao`.
/// Not available on EVM versions before Paris. Use `difficulty` instead.
/// If used on unsupported EVM versions it will revert.
function prevrandao(bytes32 newPrevrandao) external;
/// Sets `block.prevrandao`.
/// Not available on EVM versions before Paris. Use `difficulty` instead.
/// If used on unsupported EVM versions it will revert.
function prevrandao(uint256 newPrevrandao) external;
/// Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification.
function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);
/// Resets the nonce of an account to 0 for EOAs and 1 for contract accounts.
function resetNonce(address account) external;
/// Revert the state of the EVM to a previous snapshot
/// Takes the snapshot ID to revert to.
/// Returns `true` if the snapshot was successfully reverted.
/// Returns `false` if the snapshot does not exist.
/// **Note:** This does not automatically delete the snapshot. To delete the snapshot use `deleteStateSnapshot`.
function revertToState(uint256 snapshotId) external returns (bool success);
/// Revert the state of the EVM to a previous snapshot and automatically deletes the snapshots
/// Takes the snapshot ID to revert to.
/// Returns `true` if the snapshot was successfully reverted and deleted.
/// Returns `false` if the snapshot does not exist.
function revertToStateAndDelete(uint256 snapshotId) external returns (bool success);
/// Revokes persistent status from the address, previously added via `makePersistent`.
function revokePersistent(address account) external;
/// See `revokePersistent(address)`.
function revokePersistent(address[] calldata accounts) external;
/// Sets `block.height`.
function roll(uint256 newHeight) external;
/// Updates the currently active fork to given block number
/// This is similar to `roll` but for the currently active fork.
function rollFork(uint256 blockNumber) external;
/// Updates the currently active fork to given transaction. This will `rollFork` with the number
/// of the block the transaction was mined in and replays all transaction mined before it in the block.
function rollFork(bytes32 txHash) external;
/// Updates the given fork to given block number.
function rollFork(uint256 forkId, uint256 blockNumber) external;
/// Updates the given fork to block number of the given transaction and replays all transaction mined before it in the block.
function rollFork(uint256 forkId, bytes32 txHash) external;
/// Takes a fork identifier created by `createFork` and sets the corresponding forked state as active.
function selectFork(uint256 forkId) external;
/// Set blockhash for the current block.
/// It only sets the blockhash for blocks where `block.number - 256 <= number < block.number`.
function setBlockhash(uint256 blockNumber, bytes32 blockHash) external;
/// Sets the nonce of an account. Must be higher than the current nonce of the account.
function setNonce(address account, uint64 newNonce) external;
/// Sets the nonce of an account to an arbitrary value.
function setNonceUnsafe(address account, uint64 newNonce) external;
/// Snapshot capture the gas usage of the last call by name from the callee perspective.
function snapshotGasLastCall(string calldata name) external returns (uint256 gasUsed);
/// Snapshot capture the gas usage of the last call by name in a group from the callee perspective.
function snapshotGasLastCall(string calldata group, string calldata name) external returns (uint256 gasUsed);
/// Snapshot the current state of the evm.
/// Returns the ID of the snapshot that was created.
/// To revert a snapshot use `revertToState`.
function snapshotState() external returns (uint256 snapshotId);
/// Snapshot capture an arbitrary numerical value by name.
/// The group name is derived from the contract name.
function snapshotValue(string calldata name, uint256 value) external;
/// Snapshot capture an arbitrary numerical value by name in a group.
function snapshotValue(string calldata group, string calldata name, uint256 value) external;
/// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called.
function startPrank(address msgSender) external;
/// Sets all subsequent calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.
function startPrank(address msgSender, address txOrigin) external;
/// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called.
function startPrank(address msgSender, bool delegateCall) external;
/// Sets all subsequent delegate calls' `msg.sender` to be the input address until `stopPrank` is called, and the `tx.origin` to be the second input.
function startPrank(address msgSender, address txOrigin, bool delegateCall) external;
/// Start a snapshot capture of the current gas usage by name.
/// The group name is derived from the contract name.
function startSnapshotGas(string calldata name) external;
/// Start a snapshot capture of the current gas usage by name in a group.
function startSnapshotGas(string calldata group, string calldata name) external;
/// Resets subsequent calls' `msg.sender` to be `address(this)`.
function stopPrank() external;
/// Stop the snapshot capture of the current gas by latest snapshot name, capturing the gas used since the start.
function stopSnapshotGas() external returns (uint256 gasUsed);
/// Stop the snapshot capture of the current gas usage by name, capturing the gas used since the start.
/// The group name is derived from the contract name.
function stopSnapshotGas(string calldata name) external returns (uint256 gasUsed);
/// Stop the snapshot capture of the current gas usage by name in a group, capturing the gas used since the start.
function stopSnapshotGas(string calldata group, string calldata name) external returns (uint256 gasUsed);
/// Stores a value to an address' storage slot.
function store(address target, bytes32 slot, bytes32 value) external;
/// Fetches the given transaction from the active fork and executes it on the current state.
function transact(bytes32 txHash) external;
/// Fetches the given transaction from the given fork and executes it on the current state.
function transact(uint256 forkId, bytes32 txHash) external;
/// Sets `tx.gasprice`.
function txGasPrice(uint256 newGasPrice) external;
/// Utility cheatcode to mark specific storage slot as warm, simulating a prior read.
function warmSlot(address target, bytes32 slot) external;
/// Sets `block.timestamp`.
function warp(uint256 newTimestamp) external;
/// `deleteSnapshot` is being deprecated in favor of `deleteStateSnapshot`. It will be removed in future versions.
function deleteSnapshot(uint256 snapshotId) external returns (bool success);
/// `deleteSnapshots` is being deprecated in favor of `deleteStateSnapshots`. It will be removed in future versions.
function deleteSnapshots() external;
/// `revertToAndDelete` is being deprecated in favor of `revertToStateAndDelete`. It will be removed in future versions.
function revertToAndDelete(uint256 snapshotId) external returns (bool success);
/// `revertTo` is being deprecated in favor of `revertToState`. It will be removed in future versions.
function revertTo(uint256 snapshotId) external returns (bool success);
/// `snapshot` is being deprecated in favor of `snapshotState`. It will be removed in future versions.
function snapshot() external returns (uint256 snapshotId);
// ======== Testing ========
/// Expect a call to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.
function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external;
/// Expect given number of calls to an address with the specified `msg.value` and calldata, and a *minimum* amount of gas.
function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data, uint64 count)
external;
/// Expects a call to an address with the specified calldata.
/// Calldata can either be a strict or a partial match.
function expectCall(address callee, bytes calldata data) external;
/// Expects given number of calls to an address with the specified calldata.
function expectCall(address callee, bytes calldata data, uint64 count) external;
/// Expects a call to an address with the specified `msg.value` and calldata.
function expectCall(address callee, uint256 msgValue, bytes calldata data) external;
/// Expects given number of calls to an address with the specified `msg.value` and calldata.
function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external;
/// Expect a call to an address with the specified `msg.value`, gas, and calldata.
function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external;
/// Expects given number of calls to an address with the specified `msg.value`, gas, and calldata.
function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external;
/// Expects the deployment of the specified bytecode by the specified address using the CREATE opcode
function expectCreate(bytes calldata bytecode, address deployer) external;
/// Expects the deployment of the specified bytecode by the specified address using the CREATE2 opcode
function expectCreate2(bytes calldata bytecode, address deployer) external;
/// Prepare an expected anonymous log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).
/// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if
/// logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
function expectEmitAnonymous(bool checkTopic0, bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData)
external;
/// Same as the previous method, but also checks supplied address against emitting contract.
function expectEmitAnonymous(
bool checkTopic0,
bool checkTopic1,
bool checkTopic2,
bool checkTopic3,
bool checkData,
address emitter
) external;
/// Prepare an expected anonymous log with all topic and data checks enabled.
/// Call this function, then emit an anonymous event, then call a function. Internally after the call, we check if
/// logs were emitted in the expected order with the expected topics and data.
function expectEmitAnonymous() external;
/// Same as the previous method, but also checks supplied address against emitting contract.
function expectEmitAnonymous(address emitter) external;
/// Prepare an expected log with (bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData.).
/// Call this function, then emit an event, then call a function. Internally after the call, we check if
/// logs were emitted in the expected order with the expected topics and data (as specified by the booleans).
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external;
/// Same as the previous method, but also checks supplied address against emitting contract.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, address emitter)
external;
/// Prepare an expected log with all topic and data checks enabled.
/// Call this function, then emit an event, then call a function. Internally after the call, we check if
/// logs were emitted in the expected order with the expected topics and data.
function expectEmit() external;
/// Same as the previous method, but also checks supplied address against emitting contract.
function expectEmit(address emitter) external;
/// Expect a given number of logs with the provided topics.
function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData, uint64 count) external;
/// Expect a given number of logs from a specific emitter with the provided topics.
function expectEmit(
bool checkTopic1,
bool checkTopic2,
bool checkTopic3,
bool checkData,
address emitter,
uint64 count
) external;
/// Expect a given number of logs with all topic and data checks enabled.
function expectEmit(uint64 count) external;
/// Expect a given number of logs from a specific emitter with all topic and data checks enabled.
function expectEmit(address emitter, uint64 count) external;
/// Expects an error on next call that starts with the revert data.
function expectPartialRevert(bytes4 revertData) external;
/// Expects an error on next call to reverter address, that starts with the revert data.
function expectPartialRevert(bytes4 revertData, address reverter) external;
/// Expects an error on next call with any revert data.
function expectRevert() external;
/// Expects an error on next call that exactly matches the revert data.
function expectRevert(bytes4 revertData) external;
/// Expects a `count` number of reverts from the upcoming calls from the reverter address that match the revert data.
function expectRevert(bytes4 revertData, address reverter, uint64 count) external;
/// Expects a `count` number of reverts from the upcoming calls from the reverter address that exactly match the revert data.
function expectRevert(bytes calldata revertData, address reverter, uint64 count) external;
/// Expects an error on next call that exactly matches the revert data.
function expectRevert(bytes calldata revertData) external;
/// Expects an error with any revert data on next call to reverter address.
function expectRevert(address reverter) external;
/// Expects an error from reverter address on next call, with any revert data.
function expectRevert(bytes4 revertData, address reverter) external;
/// Expects an error from reverter address on next call, that exactly matches the revert data.
function expectRevert(bytes calldata revertData, address reverter) external;
/// Expects a `count` number of reverts from the upcoming calls with any revert data or reverter.
function expectRevert(uint64 count) external;
/// Expects a `count` number of reverts from the upcoming calls that match the revert data.
function expectRevert(bytes4 revertData, uint64 count) external;
/// Expects a `count` number of reverts from the upcoming calls that exactly match the revert data.
function expectRevert(bytes calldata revertData, uint64 count) external;
/// Expects a `count` number of reverts from the upcoming calls from the reverter address.
function expectRevert(address reverter, uint64 count) external;
/// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other
/// memory is written to, the test will fail. Can be called multiple times to add more ranges to the set.
function expectSafeMemory(uint64 min, uint64 max) external;
/// Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext.
/// If any other memory is written to, the test will fail. Can be called multiple times to add more ranges
/// to the set.
function expectSafeMemoryCall(uint64 min, uint64 max) external;
/// Marks a test as skipped. Must be called at the top level of a test.
function skip(bool skipTest) external;
/// Marks a test as skipped with a reason. Must be called at the top level of a test.
function skip(bool skipTest, string calldata reason) external;
/// Stops all safe memory expectation in the current subcontext.
function stopExpectSafeMemory() external;
// ======== Utilities ========
/// Causes the next contract creation (via new) to fail and return its initcode in the returndata buffer.
/// This allows type-safe access to the initcode payload that would be used for contract creation.
/// Example usage:
/// vm.interceptInitcode();
/// bytes memory initcode;
/// try new MyContract(param1, param2) { assert(false); }
/// catch (bytes memory interceptedInitcode) { initcode = interceptedInitcode; }
function interceptInitcode() external;
}
src/dependencies/openzeppelin/AccessManaged.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/manager/AccessManaged.sol)
pragma solidity ^0.8.20;
import {AuthorityUtils} from './AuthorityUtils.sol';
import {IAccessManager} from './IAccessManager.sol';
import {IAccessManaged} from './IAccessManaged.sol';
import {Context} from './Context.sol';
/**
* @dev This contract module makes available a {restricted} modifier. Functions decorated with this modifier will be
* permissioned according to an "authority": a contract like {AccessManager} that follows the {IAuthority} interface,
* implementing a policy that allows certain callers to access certain functions.
*
* IMPORTANT: The `restricted` modifier should never be used on `internal` functions, judiciously used in `public`
* functions, and ideally only used in `external` functions. See {restricted}.
*/
abstract contract AccessManaged is Context, IAccessManaged {
address private _authority;
bool private _consumingSchedule;
/**
* @dev Initializes the contract connected to an initial authority.
*/
constructor(address initialAuthority) {
_setAuthority(initialAuthority);
}
/**
* @dev Restricts access to a function as defined by the connected Authority for this contract and the
* caller and selector of the function that entered the contract.
*
* [IMPORTANT]
* ====
* In general, this modifier should only be used on `external` functions. It is okay to use it on `public`
* functions that are used as external entry points and are not called internally. Unless you know what you're
* doing, it should never be used on `internal` functions. Failure to follow these rules can have critical security
* implications! This is because the permissions are determined by the function that entered the contract, i.e. the
* function at the bottom of the call stack, and not the function where the modifier is visible in the source code.
* ====
*
* [WARNING]
* ====
* Avoid adding this modifier to the https://docs.soliditylang.org/en/v0.8.20/contracts.html#receive-ether-function[`receive()`]
* function or the https://docs.soliditylang.org/en/v0.8.20/contracts.html#fallback-function[`fallback()`]. These
* functions are the only execution paths where a function selector cannot be unambiguously determined from the calldata
* since the selector defaults to `0x00000000` in the `receive()` function and similarly in the `fallback()` function
* if no calldata is provided. (See {_checkCanCall}).
*
* The `receive()` function will always panic whereas the `fallback()` may panic depending on the calldata length.
* ====
*/
modifier restricted() {
_checkCanCall(_msgSender(), _msgData());
_;
}
/// @inheritdoc IAccessManaged
function authority() public view virtual returns (address) {
return _authority;
}
/// @inheritdoc IAccessManaged
function setAuthority(address newAuthority) public virtual {
address caller = _msgSender();
if (caller != authority()) {
revert AccessManagedUnauthorized(caller);
}
if (newAuthority.code.length == 0) {
revert AccessManagedInvalidAuthority(newAuthority);
}
_setAuthority(newAuthority);
}
/// @inheritdoc IAccessManaged
function isConsumingScheduledOp() public view returns (bytes4) {
return _consumingSchedule ? this.isConsumingScheduledOp.selector : bytes4(0);
}
/**
* @dev Transfers control to a new authority. Internal function with no access restriction. Allows bypassing the
* permissions set by the current authority.
*/
function _setAuthority(address newAuthority) internal virtual {
_authority = newAuthority;
emit AuthorityUpdated(newAuthority);
}
/**
* @dev Reverts if the caller is not allowed to call the function identified by a selector. Panics if the calldata
* is less than 4 bytes long.
*/
function _checkCanCall(address caller, bytes calldata data) internal virtual {
(bool immediate, uint32 delay) = AuthorityUtils.canCallWithDelay(
authority(),
caller,
address(this),
bytes4(data[0:4])
);
if (!immediate) {
if (delay > 0) {
_consumingSchedule = true;
IAccessManager(authority()).consumeScheduledOp(caller, data);
_consumingSchedule = false;
} else {
revert AccessManagedUnauthorized(caller);
}
}
}
}
src/dependencies/openzeppelin/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from './Errors.sol';
import {LowLevelCall} from './LowLevelCall.sol';
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
if (LowLevelCall.callNoReturn(recipient, amount, '')) {
// call successful, nothing to do
return;
} else if (LowLevelCall.returnDataSize() > 0) {
LowLevelCall.bubbleRevert();
} else {
revert Errors.FailedCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
bool success = LowLevelCall.callNoReturn(target, value, data);
if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {
return LowLevelCall.returnData();
} else if (success) {
revert AddressEmptyCode(target);
} else if (LowLevelCall.returnDataSize() > 0) {
LowLevelCall.bubbleRevert();
} else {
revert Errors.FailedCall();
}
}
/**
* @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 = LowLevelCall.staticcallNoReturn(target, data);
if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {
return LowLevelCall.returnData();
} else if (success) {
revert AddressEmptyCode(target);
} else if (LowLevelCall.returnDataSize() > 0) {
LowLevelCall.bubbleRevert();
} else {
revert Errors.FailedCall();
}
}
/**
* @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 = LowLevelCall.delegatecallNoReturn(target, data);
if (success && (LowLevelCall.returnDataSize() > 0 || target.code.length > 0)) {
return LowLevelCall.returnData();
} else if (success) {
revert AddressEmptyCode(target);
} else if (LowLevelCall.returnDataSize() > 0) {
LowLevelCall.bubbleRevert();
} else {
revert Errors.FailedCall();
}
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*
* NOTE: This function is DEPRECATED and may be removed in the next major release.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
// 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 (success && (returndata.length > 0 || target.code.length > 0)) {
return returndata;
} else if (success) {
revert AddressEmptyCode(target);
} else if (returndata.length > 0) {
LowLevelCall.bubbleRevert(returndata);
} else {
revert Errors.FailedCall();
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(
bool success,
bytes memory returndata
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else if (returndata.length > 0) {
LowLevelCall.bubbleRevert(returndata);
} else {
revert Errors.FailedCall();
}
}
}
src/dependencies/openzeppelin/AuthorityUtils.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (access/manager/AuthorityUtils.sol)
pragma solidity ^0.8.20;
import {IAuthority} from './IAuthority.sol';
library AuthorityUtils {
/**
* @dev Since `AccessManager` implements an extended IAuthority interface, invoking `canCall` with backwards compatibility
* for the preexisting `IAuthority` interface requires special care to avoid reverting on insufficient return data.
* This helper function takes care of invoking `canCall` in a backwards compatible way without reverting.
*/
function canCallWithDelay(
address authority,
address caller,
address target,
bytes4 selector
) internal view returns (bool immediate, uint32 delay) {
bytes memory data = abi.encodeCall(IAuthority.canCall, (caller, target, selector));
assembly ('memory-safe') {
mstore(0x00, 0x00)
mstore(0x20, 0x00)
if staticcall(gas(), authority, add(data, 0x20), mload(data), 0x00, 0x40) {
immediate := mload(0x00)
delay := mload(0x20)
// If delay does not fit in a uint32, return 0 (no delay)
// equivalent to: if gt(delay, 0xFFFFFFFF) { delay := 0 }
delay := mul(delay, iszero(shr(32, delay)))
}
}
}
}
src/dependencies/openzeppelin/Context.sol
// 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;
}
}
src/dependencies/openzeppelin/ERC1967Proxy.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Proxy.sol)
pragma solidity ^0.8.22;
import {Proxy} from './Proxy.sol';
import {ERC1967Utils} from './ERC1967Utils.sol';
/**
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
* implementation address that can be changed. This address is stored in storage in the location specified by
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967], so that it doesn't conflict with the storage layout of the
* implementation behind the proxy.
*/
contract ERC1967Proxy is Proxy {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
* encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
*
* Requirements:
*
* - If `data` is empty, `msg.value` must be zero.
*/
constructor(address implementation, bytes memory _data) payable {
ERC1967Utils.upgradeToAndCall(implementation, _data);
}
/**
* @dev Returns the current implementation address.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function _implementation() internal view virtual override returns (address) {
return ERC1967Utils.getImplementation();
}
}
src/dependencies/openzeppelin/ERC1967Utils.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.21;
import {IBeacon} from './IBeacon.sol';
import {IERC1967} from './IERC1967.sol';
import {Address} from './Address.sol';
import {StorageSlot} from './StorageSlot.sol';
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT =
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT =
0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}
src/dependencies/openzeppelin/Errors.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}
src/dependencies/openzeppelin/IAccessManaged.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/manager/IAccessManaged.sol)
pragma solidity >=0.8.4;
interface IAccessManaged {
/**
* @dev Authority that manages this contract was updated.
*/
event AuthorityUpdated(address authority);
error AccessManagedUnauthorized(address caller);
error AccessManagedRequiredDelay(address caller, uint32 delay);
error AccessManagedInvalidAuthority(address authority);
/**
* @dev Returns the current authority.
*/
function authority() external view returns (address);
/**
* @dev Transfers control to a new authority. The caller must be the current authority.
*/
function setAuthority(address) external;
/**
* @dev Returns true only in the context of a delayed restricted call, at the moment that the scheduled operation is
* being consumed. Prevents denial of service for delayed restricted calls in the case that the contract performs
* attacker controlled calls.
*/
function isConsumingScheduledOp() external view returns (bytes4);
}
src/dependencies/openzeppelin/IAccessManager.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (access/manager/IAccessManager.sol)
pragma solidity >=0.8.4;
interface IAccessManager {
/**
* @dev A delayed operation was scheduled.
*/
event OperationScheduled(
bytes32 indexed operationId,
uint32 indexed nonce,
uint48 schedule,
address caller,
address target,
bytes data
);
/**
* @dev A scheduled operation was executed.
*/
event OperationExecuted(bytes32 indexed operationId, uint32 indexed nonce);
/**
* @dev A scheduled operation was canceled.
*/
event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce);
/**
* @dev Informational labelling for a roleId.
*/
event RoleLabel(uint64 indexed roleId, string label);
/**
* @dev Emitted when `account` is granted `roleId`.
*
* NOTE: The meaning of the `since` argument depends on the `newMember` argument.
* If the role is granted to a new member, the `since` argument indicates when the account becomes a member of the role,
* otherwise it indicates the execution delay for this account and roleId is updated.
*/
event RoleGranted(
uint64 indexed roleId,
address indexed account,
uint32 delay,
uint48 since,
bool newMember
);
/**
* @dev Emitted when `account` membership or `roleId` is revoked. Unlike granting, revoking is instantaneous.
*/
event RoleRevoked(uint64 indexed roleId, address indexed account);
/**
* @dev Role acting as admin over a given `roleId` is updated.
*/
event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin);
/**
* @dev Role acting as guardian over a given `roleId` is updated.
*/
event RoleGuardianChanged(uint64 indexed roleId, uint64 indexed guardian);
/**
* @dev Grant delay for a given `roleId` will be updated to `delay` when `since` is reached.
*/
event RoleGrantDelayChanged(uint64 indexed roleId, uint32 delay, uint48 since);
/**
* @dev Target mode is updated (true = closed, false = open).
*/
event TargetClosed(address indexed target, bool closed);
/**
* @dev Role required to invoke `selector` on `target` is updated to `roleId`.
*/
event TargetFunctionRoleUpdated(address indexed target, bytes4 selector, uint64 indexed roleId);
/**
* @dev Admin delay for a given `target` will be updated to `delay` when `since` is reached.
*/
event TargetAdminDelayUpdated(address indexed target, uint32 delay, uint48 since);
error AccessManagerAlreadyScheduled(bytes32 operationId);
error AccessManagerNotScheduled(bytes32 operationId);
error AccessManagerNotReady(bytes32 operationId);
error AccessManagerExpired(bytes32 operationId);
error AccessManagerLockedRole(uint64 roleId);
error AccessManagerBadConfirmation();
error AccessManagerUnauthorizedAccount(address msgsender, uint64 roleId);
error AccessManagerUnauthorizedCall(address caller, address target, bytes4 selector);
error AccessManagerUnauthorizedConsume(address target);
error AccessManagerUnauthorizedCancel(
address msgsender,
address caller,
address target,
bytes4 selector
);
error AccessManagerInvalidInitialAdmin(address initialAdmin);
/**
* @dev Check if an address (`caller`) is authorised to call a given function on a given contract directly (with
* no restriction). Additionally, it returns the delay needed to perform the call indirectly through the {schedule}
* & {execute} workflow.
*
* This function is usually called by the targeted contract to control immediate execution of restricted functions.
* Therefore we only return true if the call can be performed without any delay. If the call is subject to a
* previously set delay (not zero), then the function should return false and the caller should schedule the operation
* for future execution.
*
* If `allowed` is true, the delay can be disregarded and the operation can be immediately executed, otherwise
* the operation can be executed if and only if delay is greater than 0.
*
* NOTE: The IAuthority interface does not include the `uint32` delay. This is an extension of that interface that
* is backward compatible. Some contracts may thus ignore the second return argument. In that case they will fail
* to identify the indirect workflow, and will consider calls that require a delay to be forbidden.
*
* NOTE: This function does not report the permissions of the admin functions in the manager itself. These are defined by the
* {AccessManager} documentation.
*/
function canCall(
address caller,
address target,
bytes4 selector
) external view returns (bool allowed, uint32 delay);
/**
* @dev Expiration delay for scheduled proposals. Defaults to 1 week.
*
* IMPORTANT: Avoid overriding the expiration with 0. Otherwise every contract proposal will be expired immediately,
* disabling any scheduling usage.
*/
function expiration() external view returns (uint32);
/**
* @dev Minimum setback for all delay updates, with the exception of execution delays. It
* can be increased without setback (and reset via {revokeRole} in the event of an
* accidental increase). Defaults to 5 days.
*/
function minSetback() external view returns (uint32);
/**
* @dev Get whether the contract is closed disabling any access. Otherwise role permissions are applied.
*
* NOTE: When the manager itself is closed, admin functions are still accessible to avoid locking the contract.
*/
function isTargetClosed(address target) external view returns (bool);
/**
* @dev Get the role required to call a function.
*/
function getTargetFunctionRole(address target, bytes4 selector) external view returns (uint64);
/**
* @dev Get the admin delay for a target contract. Changes to contract configuration are subject to this delay.
*/
function getTargetAdminDelay(address target) external view returns (uint32);
/**
* @dev Get the id of the role that acts as an admin for the given role.
*
* The admin permission is required to grant the role, revoke the role and update the execution delay to execute
* an operation that is restricted to this role.
*/
function getRoleAdmin(uint64 roleId) external view returns (uint64);
/**
* @dev Get the role that acts as a guardian for a given role.
*
* The guardian permission allows canceling operations that have been scheduled under the role.
*/
function getRoleGuardian(uint64 roleId) external view returns (uint64);
/**
* @dev Get the role current grant delay.
*
* Its value may change at any point without an event emitted following a call to {setGrantDelay}.
* Changes to this value, including effect timepoint are notified in advance by the {RoleGrantDelayChanged} event.
*/
function getRoleGrantDelay(uint64 roleId) external view returns (uint32);
/**
* @dev Get the access details for a given account for a given role. These details include the timepoint at which
* membership becomes active, and the delay applied to all operations by this user that requires this permission
* level.
*
* Returns:
* [0] Timestamp at which the account membership becomes valid. 0 means role is not granted.
* [1] Current execution delay for the account.
* [2] Pending execution delay for the account.
* [3] Timestamp at which the pending execution delay will become active. 0 means no delay update is scheduled.
*/
function getAccess(
uint64 roleId,
address account
) external view returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect);
/**
* @dev Check if a given account currently has the permission level corresponding to a given role. Note that this
* permission might be associated with an execution delay. {getAccess} can provide more details.
*/
function hasRole(
uint64 roleId,
address account
) external view returns (bool isMember, uint32 executionDelay);
/**
* @dev Give a label to a role, for improved role discoverability by UIs.
*
* Requirements:
*
* - the caller must be a global admin
*
* Emits a {RoleLabel} event.
*/
function labelRole(uint64 roleId, string calldata label) external;
/**
* @dev Add `account` to `roleId`, or change its execution delay.
*
* This gives the account the authorization to call any function that is restricted to this role. An optional
* execution delay (in seconds) can be set. If that delay is non 0, the user is required to schedule any operation
* that is restricted to members of this role. The user will only be able to execute the operation after the delay has
* passed, before it has expired. During this period, admin and guardians can cancel the operation (see {cancel}).
*
* If the account has already been granted this role, the execution delay will be updated. This update is not
* immediate and follows the delay rules. For example, if a user currently has a delay of 3 hours, and this is
* called to reduce that delay to 1 hour, the new delay will take some time to take effect, enforcing that any
* operation executed in the 3 hours that follows this update was indeed scheduled before this update.
*
* Requirements:
*
* - the caller must be an admin for the role (see {getRoleAdmin})
* - granted role must not be the `PUBLIC_ROLE`
*
* Emits a {RoleGranted} event.
*/
function grantRole(uint64 roleId, address account, uint32 executionDelay) external;
/**
* @dev Remove an account from a role, with immediate effect. If the account does not have the role, this call has
* no effect.
*
* Requirements:
*
* - the caller must be an admin for the role (see {getRoleAdmin})
* - revoked role must not be the `PUBLIC_ROLE`
*
* Emits a {RoleRevoked} event if the account had the role.
*/
function revokeRole(uint64 roleId, address account) external;
/**
* @dev Renounce role permissions for the calling account with immediate effect. If the sender is not in
* the role this call has no effect.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* Emits a {RoleRevoked} event if the account had the role.
*/
function renounceRole(uint64 roleId, address callerConfirmation) external;
/**
* @dev Change admin role for a given role.
*
* Requirements:
*
* - the caller must be a global admin
*
* Emits a {RoleAdminChanged} event
*/
function setRoleAdmin(uint64 roleId, uint64 admin) external;
/**
* @dev Change guardian role for a given role.
*
* Requirements:
*
* - the caller must be a global admin
*
* Emits a {RoleGuardianChanged} event
*/
function setRoleGuardian(uint64 roleId, uint64 guardian) external;
/**
* @dev Update the delay for granting a `roleId`.
*
* Requirements:
*
* - the caller must be a global admin
*
* Emits a {RoleGrantDelayChanged} event.
*/
function setGrantDelay(uint64 roleId, uint32 newDelay) external;
/**
* @dev Set the role required to call functions identified by the `selectors` in the `target` contract.
*
* Requirements:
*
* - the caller must be a global admin
*
* Emits a {TargetFunctionRoleUpdated} event per selector.
*/
function setTargetFunctionRole(
address target,
bytes4[] calldata selectors,
uint64 roleId
) external;
/**
* @dev Set the delay for changing the configuration of a given target contract.
*
* Requirements:
*
* - the caller must be a global admin
*
* Emits a {TargetAdminDelayUpdated} event.
*/
function setTargetAdminDelay(address target, uint32 newDelay) external;
/**
* @dev Set the closed flag for a contract.
*
* Closing the manager itself won't disable access to admin methods to avoid locking the contract.
*
* Requirements:
*
* - the caller must be a global admin
*
* Emits a {TargetClosed} event.
*/
function setTargetClosed(address target, bool closed) external;
/**
* @dev Return the timepoint at which a scheduled operation will be ready for execution. This returns 0 if the
* operation is not yet scheduled, has expired, was executed, or was canceled.
*/
function getSchedule(bytes32 id) external view returns (uint48);
/**
* @dev Return the nonce for the latest scheduled operation with a given id. Returns 0 if the operation has never
* been scheduled.
*/
function getNonce(bytes32 id) external view returns (uint32);
/**
* @dev Schedule a delayed operation for future execution, and return the operation identifier. It is possible to
* choose the timestamp at which the operation becomes executable as long as it satisfies the execution delays
* required for the caller. The special value zero will automatically set the earliest possible time.
*
* Returns the `operationId` that was scheduled. Since this value is a hash of the parameters, it can reoccur when
* the same parameters are used; if this is relevant, the returned `nonce` can be used to uniquely identify this
* scheduled operation from other occurrences of the same `operationId` in invocations of {execute} and {cancel}.
*
* Emits a {OperationScheduled} event.
*
* NOTE: It is not possible to concurrently schedule more than one operation with the same `target` and `data`. If
* this is necessary, a random byte can be appended to `data` to act as a salt that will be ignored by the target
* contract if it is using standard Solidity ABI encoding.
*/
function schedule(
address target,
bytes calldata data,
uint48 when
) external returns (bytes32 operationId, uint32 nonce);
/**
* @dev Execute a function that is delay restricted, provided it was properly scheduled beforehand, or the
* execution delay is 0.
*
* Returns the nonce that identifies the previously scheduled operation that is executed, or 0 if the
* operation wasn't previously scheduled (if the caller doesn't have an execution delay).
*
* Emits an {OperationExecuted} event only if the call was scheduled and delayed.
*/
function execute(address target, bytes calldata data) external payable returns (uint32);
/**
* @dev Cancel a scheduled (delayed) operation. Returns the nonce that identifies the previously scheduled
* operation that is cancelled.
*
* Requirements:
*
* - the caller must be the proposer, a guardian of the targeted function, or a global admin
*
* Emits a {OperationCanceled} event.
*/
function cancel(address caller, address target, bytes calldata data) external returns (uint32);
/**
* @dev Consume a scheduled operation targeting the caller. If such an operation exists, mark it as consumed
* (emit an {OperationExecuted} event and clean the state). Otherwise, throw an error.
*
* This is useful for contracts that want to enforce that calls targeting them were scheduled on the manager,
* with all the verifications that it implies.
*
* Emit a {OperationExecuted} event.
*/
function consumeScheduledOp(address caller, bytes calldata data) external;
/**
* @dev Hashing function for delayed operations.
*/
function hashOperation(
address caller,
address target,
bytes calldata data
) external view returns (bytes32);
/**
* @dev Changes the authority of a target managed by this manager instance.
*
* Requirements:
*
* - the caller must be a global admin
*/
function updateAuthority(address target, address newAuthority) external;
}
src/dependencies/openzeppelin/IAuthority.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (access/manager/IAuthority.sol)
pragma solidity >=0.4.16;
/**
* @dev Standard interface for permissioning originally defined in Dappsys.
*/
interface IAuthority {
/**
* @dev Returns true if the caller can invoke on a target the function identified by a function selector.
*/
function canCall(
address caller,
address target,
bytes4 selector
) external view returns (bool allowed);
}
src/dependencies/openzeppelin/IBeacon.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/beacon/IBeacon.sol)
pragma solidity >=0.4.16;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
src/dependencies/openzeppelin/IERC1967.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1967.sol)
pragma solidity >=0.4.11;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}
src/dependencies/openzeppelin/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
src/dependencies/openzeppelin/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from './IERC20.sol';
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
src/dependencies/openzeppelin/LowLevelCall.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (utils/LowLevelCall.sol)
pragma solidity ^0.8.20;
/**
* @dev Library of low level call functions that implement different calling strategies to deal with the return data.
*
* WARNING: Using this library requires an advanced understanding of Solidity and how the EVM works. It is recommended
* to use the {Address} library instead.
*/
library LowLevelCall {
/// @dev Performs a Solidity function call using a low level `call` and ignoring the return data.
function callNoReturn(address target, bytes memory data) internal returns (bool success) {
return callNoReturn(target, 0, data);
}
/// @dev Same as {callNoReturn}, but allows to specify the value to be sent in the call.
function callNoReturn(
address target,
uint256 value,
bytes memory data
) internal returns (bool success) {
assembly ('memory-safe') {
success := call(gas(), target, value, add(data, 0x20), mload(data), 0x00, 0x00)
}
}
/// @dev Performs a Solidity function call using a low level `call` and returns the first 64 bytes of the result
/// in the scratch space of memory. Useful for functions that return a tuple of single-word values.
///
/// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated
/// and this function doesn't zero it out.
function callReturn64Bytes(
address target,
bytes memory data
) internal returns (bool success, bytes32 result1, bytes32 result2) {
return callReturn64Bytes(target, 0, data);
}
/// @dev Same as {callReturnBytes32Pair}, but allows to specify the value to be sent in the call.
function callReturn64Bytes(
address target,
uint256 value,
bytes memory data
) internal returns (bool success, bytes32 result1, bytes32 result2) {
assembly ('memory-safe') {
success := call(gas(), target, value, add(data, 0x20), mload(data), 0x00, 0x40)
result1 := mload(0x00)
result2 := mload(0x20)
}
}
/// @dev Performs a Solidity function call using a low level `staticcall` and ignoring the return data.
function staticcallNoReturn(
address target,
bytes memory data
) internal view returns (bool success) {
assembly ('memory-safe') {
success := staticcall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x00)
}
}
/// @dev Performs a Solidity function call using a low level `staticcall` and returns the first 64 bytes of the result
/// in the scratch space of memory. Useful for functions that return a tuple of single-word values.
///
/// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated
/// and this function doesn't zero it out.
function staticcallReturn64Bytes(
address target,
bytes memory data
) internal view returns (bool success, bytes32 result1, bytes32 result2) {
assembly ('memory-safe') {
success := staticcall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x40)
result1 := mload(0x00)
result2 := mload(0x20)
}
}
/// @dev Performs a Solidity function call using a low level `delegatecall` and ignoring the return data.
function delegatecallNoReturn(address target, bytes memory data) internal returns (bool success) {
assembly ('memory-safe') {
success := delegatecall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x00)
}
}
/// @dev Performs a Solidity function call using a low level `delegatecall` and returns the first 64 bytes of the result
/// in the scratch space of memory. Useful for functions that return a tuple of single-word values.
///
/// WARNING: Do not assume that the results are zero if `success` is false. Memory can be already allocated
/// and this function doesn't zero it out.
function delegatecallReturn64Bytes(
address target,
bytes memory data
) internal returns (bool success, bytes32 result1, bytes32 result2) {
assembly ('memory-safe') {
success := delegatecall(gas(), target, add(data, 0x20), mload(data), 0x00, 0x40)
result1 := mload(0x00)
result2 := mload(0x20)
}
}
/// @dev Returns the size of the return data buffer.
function returnDataSize() internal pure returns (uint256 size) {
assembly ('memory-safe') {
size := returndatasize()
}
}
/// @dev Returns a buffer containing the return data from the last call.
function returnData() internal pure returns (bytes memory result) {
assembly ('memory-safe') {
result := mload(0x40)
mstore(result, returndatasize())
returndatacopy(add(result, 0x20), 0x00, returndatasize())
mstore(0x40, add(result, add(0x20, returndatasize())))
}
}
/// @dev Revert with the return data from the last call.
function bubbleRevert() internal pure {
assembly ('memory-safe') {
let fmp := mload(0x40)
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
}
function bubbleRevert(bytes memory returndata) internal pure {
assembly ('memory-safe') {
revert(add(returndata, 0x20), mload(returndata))
}
}
}
src/dependencies/openzeppelin/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from './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);
}
}
src/dependencies/openzeppelin/Proxy.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (proxy/Proxy.sol)
pragma solidity ^0.8.20;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0x00, 0x00, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0x00, calldatasize(), 0x00, 0x00)
// Copy the returned data.
returndatacopy(0x00, 0x00, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0x00, returndatasize())
}
default {
return(0x00, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback
* function and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
}
src/dependencies/openzeppelin/ProxyAdmin.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/transparent/ProxyAdmin.sol)
pragma solidity ^0.8.22;
import {ITransparentUpgradeableProxy} from './TransparentUpgradeableProxy.sol';
import {Ownable} from './Ownable.sol';
/**
* @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
* explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
*/
contract ProxyAdmin is Ownable {
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgrade(address,address)`
* and `upgradeAndCall(address,address,bytes)` are present, and `upgrade` must be used if no function should be called,
* while `upgradeAndCall` will invoke the `receive` function if the third argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeAndCall(address,address,bytes)` is present, and the third argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = '5.0.0';
/**
* @dev Sets the initial owner who can perform upgrades.
*/
constructor(address initialOwner) Ownable(initialOwner) {}
/**
* @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation.
* See {TransparentUpgradeableProxy-_dispatchUpgradeToAndCall}.
*
* Requirements:
*
* - This contract must be the admin of `proxy`.
* - If `data` is empty, `msg.value` must be zero.
*/
function upgradeAndCall(
ITransparentUpgradeableProxy proxy,
address implementation,
bytes memory data
) public payable virtual onlyOwner {
proxy.upgradeToAndCall{value: msg.value}(implementation, data);
}
}
src/dependencies/openzeppelin/SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ('memory-safe') {
u := iszero(iszero(b))
}
}
}
src/dependencies/openzeppelin/StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ('memory-safe') {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ('memory-safe') {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ('memory-safe') {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ('memory-safe') {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ('memory-safe') {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ('memory-safe') {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ('memory-safe') {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ('memory-safe') {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ('memory-safe') {
r.slot := store.slot
}
}
}
src/dependencies/openzeppelin/TransparentUpgradeableProxy.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.5.0) (proxy/transparent/TransparentUpgradeableProxy.sol)
pragma solidity ^0.8.22;
import {ERC1967Utils} from './ERC1967Utils.sol';
import {ERC1967Proxy} from './ERC1967Proxy.sol';
import {IERC1967} from './IERC1967.sol';
import {ProxyAdmin} from './ProxyAdmin.sol';
/**
* @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}
* does not implement this interface directly, and its upgradeability mechanism is implemented by an internal dispatch
* mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not
* include them in the ABI so this interface must be used to interact with it.
*/
interface ITransparentUpgradeableProxy is IERC1967 {
/// @dev See {UUPSUpgradeable-upgradeToAndCall}
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable;
}
/**
* @dev This contract implements a proxy that is upgradeable through an associated {ProxyAdmin} instance.
*
* To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
* clashing], which can potentially be used in an attack, this contract uses the
* https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
* things that go hand in hand:
*
* 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
* that call matches the {ITransparentUpgradeableProxy-upgradeToAndCall} function exposed by the proxy itself.
* 2. If the admin calls the proxy, it can call the `upgradeToAndCall` function, but any other call won't be forwarded to
* the implementation. If the admin tries to call a function on the implementation it will fail with an error indicating
* the proxy admin cannot fallback to the target implementation.
*
* These properties mean that the admin account can only be used for upgrading the proxy, so it's best if it's a
* dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to
* call a function from the proxy implementation. For this reason, the proxy deploys an instance of {ProxyAdmin} and
* allows upgrades only if they come through it. You should think of the `ProxyAdmin` instance as the administrative
* interface of the proxy, including the ability to change who can trigger upgrades by transferring ownership.
*
* NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not
* inherit from that interface, and instead `upgradeToAndCall` is implicitly implemented using a custom dispatch
* mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to
* fully implement transparency without decoding reverts caused by selector clashes between the proxy and the
* implementation.
*
* NOTE: This proxy does not inherit from {Context} deliberately. The {ProxyAdmin} of this contract won't send a
* meta-transaction in any way, and any other meta-transaction setup should be made in the implementation contract.
*
* IMPORTANT: This contract avoids unnecessary storage reads by setting the admin only during construction as an
* immutable variable, preventing any changes thereafter. However, the admin slot defined in ERC-1967 can still be
* overwritten by the implementation logic pointed to by this proxy. In such cases, the contract may end up in an
* undesirable state where the admin slot is different from the actual admin. Relying on the value of the admin slot
* is generally fine if the implementation is trusted.
*
* WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the
* compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new
* function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This
* could render the `upgradeToAndCall` function inaccessible, preventing upgradeability and compromising transparency.
*/
contract TransparentUpgradeableProxy is ERC1967Proxy {
// An immutable address for the admin to avoid unnecessary SLOADs before each call
// at the expense of removing the ability to change the admin once it's set.
// This is acceptable if the admin is always a ProxyAdmin instance or similar contract
// with its own ability to transfer the permissions to another account.
address private immutable _admin;
/**
* @dev The proxy caller is the current admin, and can't fallback to the proxy target.
*/
error ProxyDeniedAdminAccess();
/**
* @dev Initializes an upgradeable proxy managed by an instance of a {ProxyAdmin} with an `initialOwner`,
* backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in
* {ERC1967Proxy-constructor}.
*/
constructor(
address _logic,
address initialOwner,
bytes memory _data
) payable ERC1967Proxy(_logic, _data) {
_admin = address(new ProxyAdmin(initialOwner));
// Set the storage value and emit an event for ERC-1967 compatibility
ERC1967Utils.changeAdmin(_proxyAdmin());
}
/**
* @dev Returns the admin of this proxy.
*/
function _proxyAdmin() internal view virtual returns (address) {
return _admin;
}
/**
* @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.
*/
function _fallback() internal virtual override {
if (msg.sender == _proxyAdmin()) {
if (msg.sig != ITransparentUpgradeableProxy.upgradeToAndCall.selector) {
revert ProxyDeniedAdminAccess();
} else {
_dispatchUpgradeToAndCall();
}
} else {
super._fallback();
}
}
/**
* @dev Upgrade the implementation of the proxy. See {ERC1967Utils-upgradeToAndCall}.
*
* Requirements:
*
* - If `data` is empty, `msg.value` must be zero.
*/
function _dispatchUpgradeToAndCall() private {
(address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));
ERC1967Utils.upgradeToAndCall(newImplementation, data);
}
}
src/deployments/libraries/BatchReports.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;
library BatchReports {
struct AuthorityBatchReport {
address accessManager;
}
struct ConfiguratorBatchReport {
address hubConfigurator;
address spokeConfigurator;
}
struct SpokeInstanceBatchReport {
address spokeImplementation;
address spokeProxy;
address aaveOracle;
}
struct HubInstanceBatchReport {
address hubImplementation;
address hubProxy;
address irStrategy;
}
struct TreasurySpokeBatchReport {
address treasurySpoke;
}
struct GatewaysBatchReport {
address signatureGateway;
address nativeGateway;
}
struct PositionManagerBatchReport {
address giverPositionManager;
address takerPositionManager;
address configPositionManager;
}
struct TokenizationSpokeBatchReport {
address tokenizationSpokeImplementation;
address tokenizationSpokeProxy;
}
}
src/deployments/procedures/AaveV4DeployProcedureBase.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;
import {Vm} from 'forge-std/Vm.sol';
contract AaveV4DeployProcedureBase {
Vm internal constant vm = Vm(address(uint160(uint256(keccak256('hevm cheat code')))));
}
src/deployments/procedures/deploy/hub/AaveV4HubConfiguratorDeployProcedure.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;
import {Create2Utils} from 'src/deployments/utils/libraries/Create2Utils.sol';
import {AaveV4DeployProcedureBase} from 'src/deployments/procedures/AaveV4DeployProcedureBase.sol';
import {HubConfigurator} from 'src/hub/HubConfigurator.sol';
contract AaveV4HubConfiguratorDeployProcedure is AaveV4DeployProcedureBase {
function _deployHubConfigurator(address authority, bytes32 salt) internal returns (address) {
require(authority != address(0), 'invalid authority');
return
Create2Utils.create2Deploy(
salt,
abi.encodePacked(type(HubConfigurator).creationCode, abi.encode(authority))
);
}
}
src/deployments/procedures/deploy/spoke/AaveV4SpokeConfiguratorDeployProcedure.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;
import {AaveV4DeployProcedureBase} from 'src/deployments/procedures/AaveV4DeployProcedureBase.sol';
import {Create2Utils} from 'src/deployments/utils/libraries/Create2Utils.sol';
import {SpokeConfigurator} from 'src/spoke/SpokeConfigurator.sol';
contract AaveV4SpokeConfiguratorDeployProcedure is AaveV4DeployProcedureBase {
function _deploySpokeConfigurator(address authority, bytes32 salt) internal returns (address) {
require(authority != address(0), 'invalid authority');
return
Create2Utils.create2Deploy(
salt,
abi.encodePacked(type(SpokeConfigurator).creationCode, abi.encode(authority))
);
}
}
src/deployments/utils/libraries/Create2Utils.sol
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.20;
import {TransparentUpgradeableProxy} from 'src/dependencies/openzeppelin/TransparentUpgradeableProxy.sol';
library Create2Utils {
// https://github.com/safe-global/safe-singleton-factory
address public constant CREATE2_FACTORY = 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7;
error MissingCreate2Factory();
error Create2AddressDerivationFailure();
error FailedCreate2FactoryCall();
error ContractAlreadyDeployed();
function create2Deploy(bytes32 salt, bytes memory bytecode) internal returns (address) {
require(isContractDeployed(CREATE2_FACTORY), MissingCreate2Factory());
address computed = computeCreate2Address({salt: salt, bytecode: bytecode});
require(!isContractDeployed(computed), ContractAlreadyDeployed());
bytes memory creationBytecode = abi.encodePacked(salt, bytecode);
(bool success, bytes memory returnData) = CREATE2_FACTORY.call(creationBytecode);
require(success, FailedCreate2FactoryCall());
address deployedAt = address(uint160(bytes20(returnData)));
require(deployedAt == computed, Create2AddressDerivationFailure());
return deployedAt;
}
function proxify(
bytes32 salt,
address logic,
address initialOwner,
bytes memory data
) internal returns (address) {
return
create2Deploy(
salt,
abi.encodePacked(
type(TransparentUpgradeableProxy).creationCode,
abi.encode(logic, initialOwner, data)
)
);
}
function isContractDeployed(address _addr) internal view returns (bool isContract) {
return (_addr.code.length > 0);
}
function computeCreate2Address(
bytes32 salt,
bytes32 initcodeHash
) internal pure returns (address) {
return
addressFromLast20Bytes(
keccak256(abi.encodePacked(bytes1(0xff), CREATE2_FACTORY, salt, initcodeHash))
);
}
function computeCreate2Address(
bytes32 salt,
bytes memory bytecode
) internal pure returns (address) {
return computeCreate2Address(salt, keccak256(bytecode));
}
function addressFromLast20Bytes(bytes32 bytesValue) internal pure returns (address) {
return address(uint160(uint256(bytesValue)));
}
}
src/hub/HubConfigurator.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity 0.8.28;
import {IERC20Metadata} from 'src/dependencies/openzeppelin/IERC20Metadata.sol';
import {AccessManaged} from 'src/dependencies/openzeppelin/AccessManaged.sol';
import {SafeCast} from 'src/dependencies/openzeppelin/SafeCast.sol';
import {IHub} from 'src/hub/interfaces/IHub.sol';
import {IHubConfigurator} from 'src/hub/interfaces/IHubConfigurator.sol';
/// @title HubConfigurator
/// @author Aave Labs
/// @notice Handles administrative functions on the Hub.
/// @dev Must be granted permission by the Hub.
contract HubConfigurator is AccessManaged, IHubConfigurator {
using SafeCast for uint256;
/// @dev Constructor.
/// @param authority_ The address of the authority contract which manages permissions.
constructor(address authority_) AccessManaged(authority_) {
require(authority_ != address(0), InvalidAddress());
}
/// @inheritdoc IHubConfigurator
function addAsset(
address hub,
address underlying,
address feeReceiver,
uint256 liquidityFee,
address irStrategy,
bytes calldata irData
) external restricted returns (uint256) {
IHub targetHub = IHub(hub);
uint256 assetId = targetHub.addAsset(
underlying,
IERC20Metadata(underlying).decimals(),
feeReceiver,
irStrategy,
irData
);
_updateLiquidityFee(targetHub, assetId, liquidityFee);
return assetId;
}
/// @inheritdoc IHubConfigurator
function addAssetWithDecimals(
address hub,
address underlying,
uint8 decimals,
address feeReceiver,
uint256 liquidityFee,
address irStrategy,
bytes calldata irData
) external restricted returns (uint256) {
IHub targetHub = IHub(hub);
uint256 assetId = targetHub.addAsset(underlying, decimals, feeReceiver, irStrategy, irData);
_updateLiquidityFee(targetHub, assetId, liquidityFee);
return assetId;
}
/// @inheritdoc IHubConfigurator
function updateLiquidityFee(
address hub,
uint256 assetId,
uint256 liquidityFee
) external restricted {
_updateLiquidityFee(IHub(hub), assetId, liquidityFee);
}
/// @inheritdoc IHubConfigurator
function updateFeeReceiver(
address hub,
uint256 assetId,
address feeReceiver
) external restricted {
IHub targetHub = IHub(hub);
IHub.AssetConfig memory config = targetHub.getAssetConfig(assetId);
config.feeReceiver = feeReceiver;
targetHub.updateAssetConfig(assetId, config, new bytes(0));
}
/// @inheritdoc IHubConfigurator
function updateFeeConfig(
address hub,
uint256 assetId,
uint256 liquidityFee,
address feeReceiver
) external restricted {
IHub targetHub = IHub(hub);
IHub.AssetConfig memory config = targetHub.getAssetConfig(assetId);
config.liquidityFee = liquidityFee.toUint16();
config.feeReceiver = feeReceiver;
targetHub.updateAssetConfig(assetId, config, new bytes(0));
}
/// @inheritdoc IHubConfigurator
function updateInterestRateStrategy(
address hub,
uint256 assetId,
address irStrategy,
bytes calldata irData
) external restricted {
IHub targetHub = IHub(hub);
IHub.AssetConfig memory config = targetHub.getAssetConfig(assetId);
config.irStrategy = irStrategy;
targetHub.updateAssetConfig(assetId, config, irData);
}
/// @inheritdoc IHubConfigurator
function updateReinvestmentController(
address hub,
uint256 assetId,
address reinvestmentController
) external restricted {
IHub targetHub = IHub(hub);
IHub.AssetConfig memory config = targetHub.getAssetConfig(assetId);
config.reinvestmentController = reinvestmentController;
targetHub.updateAssetConfig(assetId, config, new bytes(0));
}
/// @inheritdoc IHubConfigurator
function resetAssetCaps(address hub, uint256 assetId) external restricted {
IHub targetHub = IHub(hub);
uint256 spokesCount = targetHub.getSpokeCount(assetId);
for (uint256 i = 0; i < spokesCount; ++i) {
address spoke = targetHub.getSpokeAddress(assetId, i);
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.addCap = 0;
config.drawCap = 0;
targetHub.updateSpokeConfig(assetId, spoke, config);
}
}
/// @inheritdoc IHubConfigurator
function deactivateAsset(address hub, uint256 assetId) external restricted {
IHub targetHub = IHub(hub);
uint256 spokesCount = targetHub.getSpokeCount(assetId);
for (uint256 i = 0; i < spokesCount; ++i) {
address spoke = targetHub.getSpokeAddress(assetId, i);
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.active = false;
targetHub.updateSpokeConfig(assetId, spoke, config);
}
}
/// @inheritdoc IHubConfigurator
function haltAsset(address hub, uint256 assetId) external restricted {
IHub targetHub = IHub(hub);
uint256 spokesCount = targetHub.getSpokeCount(assetId);
for (uint256 i = 0; i < spokesCount; ++i) {
address spoke = targetHub.getSpokeAddress(assetId, i);
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.halted = true;
targetHub.updateSpokeConfig(assetId, spoke, config);
}
}
/// @inheritdoc IHubConfigurator
function addSpoke(
address hub,
address spoke,
uint256 assetId,
IHub.SpokeConfig calldata config
) external restricted {
IHub(hub).addSpoke(assetId, spoke, config);
}
/// @inheritdoc IHubConfigurator
function addSpokeToAssets(
address hub,
address spoke,
uint256[] calldata assetIds,
IHub.SpokeConfig[] calldata configs
) external restricted {
uint256 assetCount = assetIds.length;
require(assetCount == configs.length, MismatchedConfigs());
for (uint256 i = 0; i < assetCount; ++i) {
IHub(hub).addSpoke(assetIds[i], spoke, configs[i]);
}
}
/// @inheritdoc IHubConfigurator
function updateSpokeActive(
address hub,
uint256 assetId,
address spoke,
bool active
) external restricted {
IHub targetHub = IHub(hub);
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.active = active;
targetHub.updateSpokeConfig(assetId, spoke, config);
}
/// @inheritdoc IHubConfigurator
function updateSpokeHalted(
address hub,
uint256 assetId,
address spoke,
bool halted
) external restricted {
IHub targetHub = IHub(hub);
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.halted = halted;
targetHub.updateSpokeConfig(assetId, spoke, config);
}
/// @inheritdoc IHubConfigurator
function updateSpokeAddCap(
address hub,
uint256 assetId,
address spoke,
uint256 addCap
) external restricted {
IHub targetHub = IHub(hub);
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.addCap = addCap.toUint40();
targetHub.updateSpokeConfig(assetId, spoke, config);
}
/// @inheritdoc IHubConfigurator
function updateSpokeDrawCap(
address hub,
uint256 assetId,
address spoke,
uint256 drawCap
) external restricted {
IHub targetHub = IHub(hub);
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.drawCap = drawCap.toUint40();
targetHub.updateSpokeConfig(assetId, spoke, config);
}
/// @inheritdoc IHubConfigurator
function updateSpokeRiskPremiumThreshold(
address hub,
uint256 assetId,
address spoke,
uint256 riskPremiumThreshold
) external restricted {
IHub targetHub = IHub(hub);
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.riskPremiumThreshold = riskPremiumThreshold.toUint24();
targetHub.updateSpokeConfig(assetId, spoke, config);
}
/// @inheritdoc IHubConfigurator
function updateSpokeCaps(
address hub,
uint256 assetId,
address spoke,
uint256 addCap,
uint256 drawCap
) external restricted {
_updateSpokeCaps(IHub(hub), assetId, spoke, addCap, drawCap);
}
/// @inheritdoc IHubConfigurator
function deactivateSpoke(address hub, address spoke) external restricted {
IHub targetHub = IHub(hub);
uint256 assetCount = targetHub.getAssetCount();
for (uint256 assetId = 0; assetId < assetCount; ++assetId) {
if (targetHub.isSpokeListed(assetId, spoke)) {
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.active = false;
targetHub.updateSpokeConfig(assetId, spoke, config);
}
}
}
/// @inheritdoc IHubConfigurator
function haltSpoke(address hub, address spoke) external restricted {
IHub targetHub = IHub(hub);
uint256 assetCount = targetHub.getAssetCount();
for (uint256 assetId = 0; assetId < assetCount; ++assetId) {
if (targetHub.isSpokeListed(assetId, spoke)) {
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.halted = true;
targetHub.updateSpokeConfig(assetId, spoke, config);
}
}
}
/// @inheritdoc IHubConfigurator
function resetSpokeCaps(address hub, address spoke) external restricted {
IHub targetHub = IHub(hub);
uint256 assetCount = targetHub.getAssetCount();
for (uint256 assetId = 0; assetId < assetCount; ++assetId) {
if (targetHub.isSpokeListed(assetId, spoke)) {
IHub.SpokeConfig memory config = targetHub.getSpokeConfig(assetId, spoke);
config.addCap = 0;
config.drawCap = 0;
targetHub.updateSpokeConfig(assetId, spoke, config);
}
}
}
/// @inheritdoc IHubConfigurator
function updateInterestRateData(
address hub,
uint256 assetId,
bytes calldata irData
) external restricted {
IHub(hub).setInterestRateData(assetId, irData);
}
/// @dev Updates spoke caps without changing the active flag.
function _updateSpokeCaps(
IHub hub,
uint256 assetId,
address spoke,
uint256 addCap,
uint256 drawCap
) internal {
IHub.SpokeConfig memory config = hub.getSpokeConfig(assetId, spoke);
config.addCap = addCap.toUint40();
config.drawCap = drawCap.toUint40();
hub.updateSpokeConfig(assetId, spoke, config);
}
function _updateLiquidityFee(IHub hub, uint256 assetId, uint256 liquidityFee) internal {
IHub.AssetConfig memory config = hub.getAssetConfig(assetId);
config.liquidityFee = liquidityFee.toUint16();
hub.updateAssetConfig(assetId, config, new bytes(0));
}
}
src/hub/interfaces/IHub.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity ^0.8.0;
import {IAccessManaged} from 'src/dependencies/openzeppelin/IAccessManaged.sol';
import {IHubBase} from 'src/hub/interfaces/IHubBase.sol';
/// @title IHub
/// @author Aave Labs
/// @notice Full interface for the Hub.
interface IHub is IHubBase, IAccessManaged {
/// @notice Asset position and configuration data.
/// @dev liquidity The liquidity available to be accessed, expressed in asset units.
/// @dev realizedFees The amount of fees realized but not yet minted, expressed in asset units.
/// @dev decimals The number of decimals of the underlying asset.
/// @dev addedShares The total shares added across all spokes.
/// @dev swept The outstanding liquidity which has been invested by the reinvestment controller, expressed in asset units.
/// @dev premiumOffsetRay The total premium offset across all spokes, used to calculate the premium, expressed in asset units and scaled by RAY.
/// @dev drawnShares The total drawn shares across all spokes.
/// @dev premiumShares The total premium shares across all spokes.
/// @dev liquidityFee The protocol fee charged on drawn and premium liquidity growth, expressed in BPS.
/// @dev drawnIndex The drawn index which monotonically increases according to the drawn rate, expressed in RAY.
/// @dev drawnRate The rate at which drawn assets grow, expressed in RAY.
/// @dev lastUpdateTimestamp The timestamp of the last accrual.
/// @dev underlying The address of the underlying asset.
/// @dev irStrategy The address of the interest rate strategy.
/// @dev reinvestmentController The address of the reinvestment controller.
/// @dev feeReceiver The address of the fee receiver spoke.
/// @dev deficitRay The amount of outstanding bad debt across all spokes, expressed in asset units and scaled by RAY.
struct Asset {
uint120 liquidity;
uint120 realizedFees;
uint8 decimals;
//
uint120 addedShares;
uint120 swept;
//
int200 premiumOffsetRay;
//
uint120 drawnShares;
uint120 premiumShares;
uint16 liquidityFee;
//
uint120 drawnIndex;
uint96 drawnRate;
uint40 lastUpdateTimestamp;
//
address underlying;
//
address irStrategy;
//
address reinvestmentController;
//
address feeReceiver;
//
uint200 deficitRay;
}
/// @notice Asset configuration. Subset of the `Asset` struct.
struct AssetConfig {
address feeReceiver;
uint16 liquidityFee;
address irStrategy;
address reinvestmentController;
}
/// @notice Spoke position and configuration data.
/// @dev drawnShares The drawn shares of a spoke for a given asset.
/// @dev premiumShares The premium shares of a spoke for a given asset.
/// @dev premiumOffsetRay The premium offset of a spoke for a given asset, used to calculate the premium, expressed in asset units and scaled by RAY.
/// @dev addedShares The added shares of a spoke for a given asset.
/// @dev addCap The maximum amount that can be added by a spoke, expressed in whole assets (not scaled by decimals). A value of `MAX_ALLOWED_SPOKE_CAP` indicates no cap.
/// @dev drawCap The maximum amount that can be drawn by a spoke, expressed in whole assets (not scaled by decimals). A value of `MAX_ALLOWED_SPOKE_CAP` indicates no cap.
/// @dev riskPremiumThreshold The maximum ratio of premium to drawn shares a spoke can have, expressed in BPS. A value of `MAX_RISK_PREMIUM_THRESHOLD` indicates no threshold.
/// @dev active True if the Spoke is allowed to perform any action.
/// @dev halted True if the Spoke is prevented from performing actions that instantly update liquidity.
/// @dev deficitRay The deficit reported by a spoke for a given asset, expressed in asset units and scaled by RAY.
struct SpokeData {
uint120 drawnShares;
uint120 premiumShares;
//
int200 premiumOffsetRay;
//
uint120 addedShares;
uint40 addCap;
uint40 drawCap;
uint24 riskPremiumThreshold;
bool active;
bool halted;
//
uint200 deficitRay;
}
/// @notice Spoke configuration data. Subset of the `SpokeData` struct.
struct SpokeConfig {
uint40 addCap;
uint40 drawCap;
uint24 riskPremiumThreshold;
bool active;
bool halted;
}
/// @notice Emitted when an asset is added.
/// @param assetId The identifier of the asset.
/// @param underlying The address of the underlying asset.
/// @param decimals The number of decimals of the asset.
event AddAsset(uint256 indexed assetId, address indexed underlying, uint8 decimals);
/// @notice Emitted when an asset is updated.
/// @param assetId The identifier of the asset.
/// @param drawnIndex The new drawn index of the asset.
/// @param drawnRate The new drawn rate of the asset.
/// @param accruedFees The accrued fees of the asset since the last mint.
event UpdateAsset(
uint256 indexed assetId,
uint256 drawnIndex,
uint256 drawnRate,
uint256 accruedFees
);
/// @notice Emitted when an asset configuration is updated.
/// @param assetId The identifier of the asset.
/// @param config The new asset configuration struct.
event UpdateAssetConfig(uint256 indexed assetId, AssetConfig config);
/// @notice Emitted when a spoke is added.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
event AddSpoke(uint256 indexed assetId, address indexed spoke);
/// @notice Emitted when a spoke configuration is updated.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param config The new spoke configuration struct.
event UpdateSpokeConfig(uint256 indexed assetId, address indexed spoke, SpokeConfig config);
/// @notice Emitted when fees are minted to the fee receiver spoke.
/// @param assetId The identifier of the asset.
/// @param feeReceiver The address of the current fee receiver spoke.
/// @param shares The amount of shares minted.
/// @param assets The amount of assets used to mint the shares.
event MintFeeShares(
uint256 indexed assetId,
address indexed feeReceiver,
uint256 shares,
uint256 assets
);
/// @notice Emitted when liquidity is invested by the reinvestment controller.
/// @param assetId The identifier of the asset.
/// @param reinvestmentController The active asset controller.
/// @param amount The amount invested.
event Sweep(uint256 indexed assetId, address indexed reinvestmentController, uint256 amount);
/// @notice Emitted when liquidity is reclaimed (from swept liquidity) by the reinvestment controller.
/// @param assetId The identifier of the asset.
/// @param reinvestmentController The active asset controller.
/// @param amount The amount reclaimed.
event Reclaim(uint256 indexed assetId, address indexed reinvestmentController, uint256 amount);
/// @notice Emitted when a deficit is eliminated.
/// @param assetId The identifier of the asset.
/// @param callerSpoke The spoke that eliminated the deficit using its added shares.
/// @param coveredSpoke The spoke for which the deficit was eliminated.
/// @param shares The amount of shares removed.
/// @param deficitAmountRay The amount of deficit eliminated, expressed in asset units and scaled by RAY.
event EliminateDeficit(
uint256 indexed assetId,
address indexed callerSpoke,
address indexed coveredSpoke,
uint256 shares,
uint256 deficitAmountRay
);
/// @notice Thrown when an underlying asset is already listed.
error UnderlyingAlreadyListed();
/// @notice Thrown when an asset is not listed.
error AssetNotListed();
/// @notice Thrown when the add cap is exceeded.
/// @param addCap The current `addCap` of the asset, expressed in whole assets (not scaled by decimals).
error AddCapExceeded(uint256 addCap);
/// @notice Thrown when the available liquidity is insufficient.
/// @param liquidity The current available liquidity.
error InsufficientLiquidity(uint256 liquidity);
/// @notice Thrown when the transferred liquidity is insufficient.
/// @param liquidityNeeded The amount of additional liquidity needed.
error InsufficientTransferred(uint256 liquidityNeeded);
/// @notice Thrown when the draw cap is exceeded.
/// @param drawCap The current `drawCap` of the asset, expressed in whole assets (not scaled by decimals).
error DrawCapExceeded(uint256 drawCap);
/// @notice Thrown when a surplus amount of drawn is restored.
/// @param maxAllowedRestore The maximum allowed drawn amount to restore.
error SurplusDrawnRestored(uint256 maxAllowedRestore);
/// @notice Thrown when a surplus amount of premium is restored.
/// @param maxAllowedRestoreRay The maximum allowed premium amount to restore, expressed in asset units and scaled by RAY.
error SurplusPremiumRayRestored(uint256 maxAllowedRestoreRay);
/// @notice Thrown when the premium change is invalid.
error InvalidPremiumChange();
/// @notice Thrown when a surplus amount of drawn is reported as deficit.
/// @param maxAllowedDeficit The maximum allowed drawn to report as deficit.
error SurplusDrawnDeficitReported(uint256 maxAllowedDeficit);
/// @notice Thrown when a surplus amount of premium is reported as deficit.
/// @param maxAllowedDeficitRay The maximum allowed premium to report as deficit, expressed in asset units and scaled by RAY.
error SurplusPremiumRayDeficitReported(uint256 maxAllowedDeficitRay);
/// @notice Thrown when a spoke is not active.
error SpokeNotActive();
/// @notice Thrown when a spoke is halted.
error SpokeHalted();
/// @notice Thrown when a new reinvestment controller is the zero address and the asset has existing swept liquidity.
error InvalidReinvestmentController();
/// @notice Thrown when an invalid reinvestment controller attempts to perform a `sweep` action.
error OnlyReinvestmentController();
/// @notice Thrown when a spoke being added is already listed.
error SpokeAlreadyListed();
/// @notice Thrown when a spoke being updated is not listed.
error SpokeNotListed();
/// @notice Thrown when the amount is invalid.
error InvalidAmount();
/// @notice Thrown when the shares amount is invalid.
error InvalidShares();
/// @notice Thrown when an input address is invalid.
error InvalidAddress();
/// @notice Thrown if the liquidity fee is invalid when updating an asset configuration.
error InvalidLiquidityFee();
/// @notice Thrown when the asset decimals exceed the maximum allowed decimals.
error InvalidAssetDecimals();
/// @notice Thrown if the interest rate strategy or data are invalid when updating an asset configuration.
/// @dev The `irData` must be empty if the interest rate strategy is not updated.
error InvalidInterestRateStrategy();
/// @notice Adds a new asset to the Hub.
/// @dev The same underlying asset address cannot be added as an asset multiple times.
/// @dev The fee receiver is added as a new spoke with maximum add cap and zero draw cap.
/// @param underlying The address of the underlying asset.
/// @param decimals The number of decimals of `underlying`.
/// @param feeReceiver The address of the fee receiver spoke.
/// @param irStrategy The address of the interest rate strategy contract.
/// @param irData The interest rate data to apply to the given asset encoded in bytes.
/// @return The unique identifier of the added asset.
function addAsset(
address underlying,
uint8 decimals,
address feeReceiver,
address irStrategy,
bytes calldata irData
) external returns (uint256);
/// @notice Updates the configuration of an asset.
/// @dev If the fee receiver is updated, adds it as a new spoke with maximum add cap and zero draw cap, and sets old fee receiver caps to zero.
/// @dev If the fee receiver is updated, accrued fees are minted as shares before the update if their value exceeds one share.
/// @dev If the interest rate strategy is updated, it is configured with `irData`. Otherwise, `irData` must be empty.
/// @param assetId The identifier of the asset.
/// @param config The new configuration for the asset.
/// @param irData The interest rate data to apply to the given asset, encoded in bytes.
function updateAssetConfig(
uint256 assetId,
AssetConfig calldata config,
bytes calldata irData
) external;
/// @notice Registers a new spoke for a specific asset in the Hub.
/// @dev Reverts with `SpokeAlreadyListed` if spoke is already listed.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke to add.
/// @param params The configuration parameters for the Spoke.
function addSpoke(uint256 assetId, address spoke, SpokeConfig calldata params) external;
/// @notice Updates the configuration of a spoke for a specific asset.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke to update.
/// @param config The new configuration for the Spoke.
function updateSpokeConfig(uint256 assetId, address spoke, SpokeConfig calldata config) external;
/// @notice Updates the interest rate strategy for a specified asset.
/// @param assetId The identifier of the asset.
/// @param irData The interest rate data to apply to the given asset, encoded in bytes.
function setInterestRateData(uint256 assetId, bytes calldata irData) external;
/// @notice Mints shares to the fee receiver from accrued fees.
/// @dev No op when fees are worth less than one share.
/// @param assetId The identifier of the asset.
/// @return The amount of shares minted.
function mintFeeShares(uint256 assetId) external returns (uint256);
/// @notice Eliminates deficit by removing added shares of caller spoke.
/// @dev Only callable by active and authorized spokes.
/// @param assetId The identifier of the asset.
/// @param amount The amount of deficit to eliminate.
/// @param spoke The spoke for which the deficit is eliminated.
/// @return The amount of added shares removed.
/// @return The amount of deficit eliminated, expressed in asset units.
function eliminateDeficit(
uint256 assetId,
uint256 amount,
address spoke
) external returns (uint256, uint256);
/// @notice Allows a spoke to transfer its added shares of an asset to another spoke.
/// @dev Only callable by spokes.
/// @param assetId The identifier of the asset.
/// @param shares The amount of shares to move.
/// @param toSpoke The address of the recipient spoke.
function transferShares(uint256 assetId, uint256 shares, address toSpoke) external;
/// @notice Sweeps an amount of liquidity of the corresponding asset and sends it to the configured reinvestment controller.
/// @dev The controller handles the actual reinvestment of funds, redistribution of interest, and investment caps.
/// @param assetId The identifier of the asset.
/// @param amount The amount to sweep.
function sweep(uint256 assetId, uint256 amount) external;
/// @notice Reclaims an amount of liquidity of the corresponding asset from the configured reinvestment controller.
/// @dev The controller can only reclaim up to swept amount. All accrued interest is distributed offchain.
/// @dev Underlying assets must be transferred to the Hub before invocation.
/// @dev Extra untracked underlying liquidity in the Hub can be skimmed into the Hub's liquidity accounting through this action.
/// @param assetId The identifier of the asset.
/// @param amount The amount to reclaim.
function reclaim(uint256 assetId, uint256 amount) external;
/// @notice Returns whether the underlying is listed as an asset.
/// @param underlying The address of the underlying asset.
/// @return True if the underlying asset is listed.
function isUnderlyingListed(address underlying) external view returns (bool);
/// @notice Returns the number of listed assets.
function getAssetCount() external view returns (uint256);
/// @notice Returns information regarding the specified asset.
/// @dev `drawnIndex`, `drawnRate` and `lastUpdateTimestamp` can be outdated due to passage of time.
/// @param assetId The identifier of the asset.
/// @return The asset struct.
function getAsset(uint256 assetId) external view returns (Asset memory);
/// @notice Returns the asset configuration for the specified asset.
/// @param assetId The identifier of the asset.
/// @return The asset configuration struct.
function getAssetConfig(uint256 assetId) external view returns (AssetConfig memory);
/// @notice Returns the accrued fees for the asset, expressed in asset units.
/// @dev Accrued fees are excluded from total added assets.
/// @param assetId The identifier of the asset.
/// @return The amount of accrued fees.
function getAssetAccruedFees(uint256 assetId) external view returns (uint256);
/// @notice Returns the amount of liquidity swept by the reinvestment controller for the specified asset.
/// @param assetId The identifier of the asset.
/// @return The amount of liquidity swept.
function getAssetSwept(uint256 assetId) external view returns (uint256);
/// @notice Calculates the current drawn rate for the specified asset.
/// @param assetId The identifier of the asset.
/// @return The current drawn rate of the asset.
function getAssetDrawnRate(uint256 assetId) external view returns (uint256);
/// @notice Returns the number of spokes listed for the specified asset.
/// @param assetId The identifier of the asset.
function getSpokeCount(uint256 assetId) external view returns (uint256);
/// @notice Returns whether the Spoke is listed for the specified asset.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return True if the Spoke is listed.
function isSpokeListed(uint256 assetId, address spoke) external view returns (bool);
/// @notice Returns the address of the Spoke for an asset at the given index.
/// @param assetId The identifier of the asset.
/// @param index The index of the Spoke.
/// @return The address of the Spoke.
function getSpokeAddress(uint256 assetId, uint256 index) external view returns (address);
/// @notice Returns the Spoke data struct.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return The spoke data struct.
function getSpoke(uint256 assetId, address spoke) external view returns (SpokeData memory);
/// @notice Returns the Spoke configuration struct.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return The spoke configuration struct.
function getSpokeConfig(
uint256 assetId,
address spoke
) external view returns (SpokeConfig memory);
/// @notice Returns the maximum allowed number of decimals for the underlying asset.
/// @return The maximum number of decimals (inclusive).
function MAX_ALLOWED_UNDERLYING_DECIMALS() external view returns (uint8);
/// @notice Returns the minimum allowed number of decimals for the underlying asset.
/// @return The minimum number of decimals (inclusive).
function MIN_ALLOWED_UNDERLYING_DECIMALS() external view returns (uint8);
/// @notice Returns the maximum value for any spoke cap (add or draw).
/// @dev The value is not inclusive; using the maximum value indicates no cap.
/// @return The maximum cap value, expressed in asset units.
function MAX_ALLOWED_SPOKE_CAP() external view returns (uint40);
/// @notice Returns the maximum value for any spoke risk premium threshold.
/// @dev The value is not inclusive; using the maximum value indicates no threshold.
/// @return The maximum risk premium threshold, expressed in BPS.
function MAX_RISK_PREMIUM_THRESHOLD() external view returns (uint24);
}
src/hub/interfaces/IHubBase.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity ^0.8.0;
/// @title IHubBase
/// @author Aave Labs
/// @notice Minimal interface for Hub.
interface IHubBase {
/// @notice Changes to premium owed accounting.
/// @dev sharesDelta The change in premium shares.
/// @dev offsetRayDelta The change in premium offset, expressed in asset units and scaled by RAY.
/// @dev restoredPremiumRay The restored premium, expressed in asset units and scaled by RAY.
struct PremiumDelta {
int256 sharesDelta;
int256 offsetRayDelta;
uint256 restoredPremiumRay;
}
/// @notice Emitted on the `add` action.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param shares The amount of shares added.
/// @param amount The amount of assets added.
event Add(uint256 indexed assetId, address indexed spoke, uint256 shares, uint256 amount);
/// @notice Emitted on the `remove` action.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param shares The amount of shares removed.
/// @param amount The amount of assets removed.
event Remove(uint256 indexed assetId, address indexed spoke, uint256 shares, uint256 amount);
/// @notice Emitted on the `draw` action.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param drawnShares The amount of drawn shares.
/// @param drawnAmount The amount of drawn assets.
event Draw(
uint256 indexed assetId,
address indexed spoke,
uint256 drawnShares,
uint256 drawnAmount
);
/// @notice Emitted on the `restore` action.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param drawnShares The amount of drawn shares.
/// @param premiumDelta The premium delta data struct.
/// @param drawnAmount The amount of drawn assets restored.
/// @param premiumAmount The amount of premium assets restored.
event Restore(
uint256 indexed assetId,
address indexed spoke,
uint256 drawnShares,
PremiumDelta premiumDelta,
uint256 drawnAmount,
uint256 premiumAmount
);
/// @notice Emitted on the `refreshPremium` action.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param premiumDelta The premium delta data struct.
event RefreshPremium(uint256 indexed assetId, address indexed spoke, PremiumDelta premiumDelta);
/// @notice Emitted on the `reportDeficit` action.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param drawnShares The amount of drawn shares reported as deficit.
/// @param premiumDelta The premium delta data struct.
/// @param deficitAmountRay The amount of deficit reported, expressed in asset units and scaled by RAY.
event ReportDeficit(
uint256 indexed assetId,
address indexed spoke,
uint256 drawnShares,
PremiumDelta premiumDelta,
uint256 deficitAmountRay
);
/// @notice Emitted on the `transferShares` action.
/// @param assetId The identifier of the asset.
/// @param sender The address of the sender.
/// @param receiver The address of the receiver.
/// @param shares The amount of shares transferred.
event TransferShares(
uint256 indexed assetId,
address indexed sender,
address indexed receiver,
uint256 shares
);
/// @notice Adds assets on behalf of a user.
/// @dev Only callable by active spokes.
/// @dev Underlying assets must be transferred to the Hub before invocation.
/// @dev Extra untracked underlying liquidity in the Hub can be skimmed into the Hub's liquidity accounting through this action.
/// @param assetId The identifier of the asset.
/// @param amount The amount of asset liquidity to add.
/// @return The amount of shares added.
function add(uint256 assetId, uint256 amount) external returns (uint256);
/// @notice Removes assets on behalf of a user.
/// @dev Only callable by active spokes.
/// @param assetId The identifier of the asset.
/// @param amount The amount of asset liquidity to remove.
/// @param to The address to transfer the assets to.
/// @return The amount of shares removed.
function remove(uint256 assetId, uint256 amount, address to) external returns (uint256);
/// @notice Draws assets on behalf of a user.
/// @dev Only callable by active spokes.
/// @param assetId The identifier of the asset.
/// @param amount The amount of assets to draw.
/// @param to The address to transfer the underlying assets to.
/// @return The amount of drawn shares.
function draw(uint256 assetId, uint256 amount, address to) external returns (uint256);
/// @notice Restores assets on behalf of a user.
/// @dev Only callable by active spokes.
/// @dev Interest is always paid off first from premium, then from drawn.
/// @dev Underlying assets must be transferred to the Hub before invocation.
/// @dev Extra untracked underlying liquidity in the Hub can be skimmed into the Hub's liquidity accounting through this action.
/// @param assetId The identifier of the asset.
/// @param drawnAmount The drawn amount to restore.
/// @param premiumDelta The premium delta to apply which signals premium repayment.
/// @return The amount of drawn shares restored.
function restore(
uint256 assetId,
uint256 drawnAmount,
PremiumDelta calldata premiumDelta
) external returns (uint256);
/// @notice Reports an owed amount by the caller Spoke as a deficit.
/// @dev Only callable by active spokes.
/// @param assetId The identifier of the asset.
/// @param drawnAmount The drawn amount to report as deficit.
/// @param premiumDelta The premium delta to apply which signals premium deficit.
/// @return The amount of drawn shares reported as deficit.
/// @return The amount of deficit reported, expressed in asset units.
function reportDeficit(
uint256 assetId,
uint256 drawnAmount,
PremiumDelta calldata premiumDelta
) external returns (uint256, uint256);
/// @notice Refreshes premium accounting.
/// @dev Only callable by active spokes.
/// @dev Asset and spoke premium should not decrease.
/// @param assetId The identifier of the asset.
/// @param premiumDelta The change in premium.
function refreshPremium(uint256 assetId, PremiumDelta calldata premiumDelta) external;
/// @notice Transfers an amount of added shares of the caller Spoke to the fee receiver Spoke.
/// @dev It can be used to execute one-time payments to the fee receiver Spoke (e.g., liquidation fees).
/// @dev Only callable by active spokes.
/// @param assetId The identifier of the asset.
/// @param shares The amount of shares to pay to feeReceiver.
function payFeeShares(uint256 assetId, uint256 shares) external;
/// @notice Converts the specified amount of assets to shares upon an `add` action.
/// @dev Rounds down to the nearest shares amount.
/// @dev Defaults to a 1:1 exchange rate.
/// @param assetId The identifier of the asset.
/// @param assets The amount of assets to convert to shares amount.
/// @return The amount of shares converted from assets amount.
function previewAddByAssets(uint256 assetId, uint256 assets) external view returns (uint256);
/// @notice Converts the specified shares amount to assets amount added upon an `add` action.
/// @dev Rounds up to the nearest assets amount.
/// @dev Defaults to a 1:1 exchange rate.
/// @param assetId The identifier of the asset.
/// @param shares The amount of shares to convert to assets amount.
/// @return The amount of assets converted from shares amount.
function previewAddByShares(uint256 assetId, uint256 shares) external view returns (uint256);
/// @notice Converts the specified amount of assets to shares amount removed upon a `remove` action.
/// @dev Rounds up to the nearest shares amount.
/// @dev Defaults to a 1:1 exchange rate.
/// @param assetId The identifier of the asset.
/// @param assets The amount of assets to convert to shares amount.
/// @return The amount of shares converted from assets amount.
function previewRemoveByAssets(uint256 assetId, uint256 assets) external view returns (uint256);
/// @notice Converts the specified amount of shares to assets amount removed upon a `remove` action.
/// @dev Rounds down to the nearest assets amount.
/// @dev Defaults to a 1:1 exchange rate.
/// @param assetId The identifier of the asset.
/// @param shares The amount of shares to convert to assets amount.
/// @return The amount of assets converted from shares amount.
function previewRemoveByShares(uint256 assetId, uint256 shares) external view returns (uint256);
/// @notice Converts the specified amount of assets to shares amount drawn upon a `draw` action.
/// @dev Rounds up to the nearest shares amount.
/// @param assetId The identifier of the asset.
/// @param assets The amount of assets to convert to shares amount.
/// @return The amount of shares converted from assets amount.
function previewDrawByAssets(uint256 assetId, uint256 assets) external view returns (uint256);
/// @notice Converts the specified amount of shares to assets amount drawn upon a `draw` action.
/// @dev Rounds down to the nearest assets amount.
/// @param assetId The identifier of the asset.
/// @param shares The amount of shares to convert to assets amount.
/// @return The amount of assets converted from shares amount.
function previewDrawByShares(uint256 assetId, uint256 shares) external view returns (uint256);
/// @notice Converts the specified amount of assets to shares amount restored upon a `restore` action.
/// @dev Rounds down to the nearest shares amount.
/// @param assetId The identifier of the asset.
/// @param assets The amount of assets to convert to shares amount.
/// @return The amount of shares converted from assets amount.
function previewRestoreByAssets(uint256 assetId, uint256 assets) external view returns (uint256);
/// @notice Converts the specified amount of shares to assets amount restored upon a `restore` action.
/// @dev Rounds up to the nearest assets amount.
/// @param assetId The identifier of the asset.
/// @param shares The amount of drawn shares to convert to assets amount.
/// @return The amount of assets converted from shares amount.
function previewRestoreByShares(uint256 assetId, uint256 shares) external view returns (uint256);
/// @notice Returns the asset identifier for the specified underlying asset.
/// @dev Reverts with `AssetNotListed` if the underlying is not listed.
/// @param underlying The address of the underlying asset.
function getAssetId(address underlying) external view returns (uint256);
/// @notice Returns the underlying address and decimals of the specified asset.
/// @param assetId The identifier of the asset.
/// @return The underlying address of the asset.
/// @return The decimals of the asset.
function getAssetUnderlyingAndDecimals(uint256 assetId) external view returns (address, uint8);
/// @notice Calculates the current drawn index for the specified asset.
/// @param assetId The identifier of the asset.
/// @return The current drawn index of the asset.
function getAssetDrawnIndex(uint256 assetId) external view returns (uint256);
/// @notice Returns the total amount of the specified asset added to the Hub.
/// @param assetId The identifier of the asset.
/// @return The amount of the asset added.
function getAddedAssets(uint256 assetId) external view returns (uint256);
/// @notice Returns the total amount of shares of the specified asset added to the Hub.
/// @param assetId The identifier of the asset.
/// @return The amount of shares of the asset added.
function getAddedShares(uint256 assetId) external view returns (uint256);
/// @notice Returns the amount of owed drawn and premium assets for the specified asset.
/// @param assetId The identifier of the asset.
/// @return The amount of owed drawn assets.
/// @return The amount of owed premium assets.
function getAssetOwed(uint256 assetId) external view returns (uint256, uint256);
/// @notice Returns the total amount of assets owed to the Hub.
/// @param assetId The identifier of the asset.
/// @return The total amount of the assets owed.
function getAssetTotalOwed(uint256 assetId) external view returns (uint256);
/// @notice Returns the amount of owed premium with full precision for specified asset.
/// @param assetId The identifier of the asset.
/// @return The amount of premium owed, expressed in asset units and scaled by RAY.
function getAssetPremiumRay(uint256 assetId) external view returns (uint256);
/// @notice Returns the amount of drawn shares of the specified asset.
/// @param assetId The identifier of the asset.
/// @return The amount of drawn shares.
function getAssetDrawnShares(uint256 assetId) external view returns (uint256);
/// @notice Returns the information regarding premium shares of the specified asset.
/// @param assetId The identifier of the asset.
/// @return The amount of premium shares owed to the asset.
/// @return The premium offset of the asset, expressed in asset units and scaled by RAY.
function getAssetPremiumData(uint256 assetId) external view returns (uint256, int256);
/// @notice Returns the amount of available liquidity for the specified asset.
/// @param assetId The identifier of the asset.
/// @return The amount of available liquidity.
function getAssetLiquidity(uint256 assetId) external view returns (uint256);
/// @notice Returns the amount of deficit with full precision of the specified asset.
/// @param assetId The identifier of the asset.
/// @return The amount of deficit, expressed in asset units and scaled by RAY.
function getAssetDeficitRay(uint256 assetId) external view returns (uint256);
/// @notice Returns the total amount of the specified assets added to the Hub by the specified spoke.
/// @dev If spoke is `asset.feeReceiver`, includes converted `unrealizedFeeShares` in return value.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return The amount of added assets.
function getSpokeAddedAssets(uint256 assetId, address spoke) external view returns (uint256);
/// @notice Returns the total amount of shares of the specified asset added to the Hub by the specified spoke.
/// @dev If spoke is `asset.feeReceiver`, includes `unrealizedFeeShares` in return value.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return The amount of added shares.
function getSpokeAddedShares(uint256 assetId, address spoke) external view returns (uint256);
/// @notice Returns the amount of the specified assets owed to the Hub by the specified spoke.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return The amount of owed drawn assets.
/// @return The amount of owed premium assets.
function getSpokeOwed(uint256 assetId, address spoke) external view returns (uint256, uint256);
/// @notice Returns the total amount of the specified asset owed to the Hub by the specified spoke.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return The total amount of the asset owed.
function getSpokeTotalOwed(uint256 assetId, address spoke) external view returns (uint256);
/// @notice Returns the amount of owed premium with full precision for specified asset and spoke.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return The amount of owed premium assets, expressed in asset units and scaled by RAY.
function getSpokePremiumRay(uint256 assetId, address spoke) external view returns (uint256);
/// @notice Returns the amount of drawn shares of the specified asset by the specified spoke.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return The amount of drawn shares.
function getSpokeDrawnShares(uint256 assetId, address spoke) external view returns (uint256);
/// @notice Returns the information regarding premium shares of the specified asset for the specified spoke.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return The amount of premium shares.
/// @return The premium offset, expressed in asset units and scaled by RAY.
function getSpokePremiumData(
uint256 assetId,
address spoke
) external view returns (uint256, int256);
/// @notice Returns the amount of a given spoke's deficit with full precision for the specified asset.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @return The amount of deficit, expressed in asset units and scaled by RAY.
function getSpokeDeficitRay(uint256 assetId, address spoke) external view returns (uint256);
}
src/hub/interfaces/IHubConfigurator.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity ^0.8.0;
import {IHub} from 'src/hub/interfaces/IHub.sol';
/// @title IHubConfigurator
/// @author Aave Labs
/// @notice Interface for HubConfigurator.
interface IHubConfigurator {
/// @notice Thrown when an address parameter is the zero address.
error InvalidAddress();
/// @notice Thrown when the list of assets and spoke configs are not the same length in `addSpokeToAssets`.
error MismatchedConfigs();
/// @notice Adds a new asset to a specified Hub.
/// @dev Retrieves the decimals of the underlying asset from its ERC20 contract.
/// @dev The fee receiver is automatically added as a Spoke with maximum caps.
/// @param hub The address of the Hub.
/// @param underlying The address of the underlying asset.
/// @param feeReceiver The address of the fee receiver Spoke.
/// @param liquidityFee The liquidity fee of the asset, expressed in BPS.
/// @param irStrategy The address of the interest rate strategy contract.
/// @param irData The interest rate data to apply to the given asset, encoded in bytes.
/// @return The unique identifier of the added asset.
function addAsset(
address hub,
address underlying,
address feeReceiver,
uint256 liquidityFee,
address irStrategy,
bytes calldata irData
) external returns (uint256);
/// @notice Adds a new asset to a specified Hub with explicit decimals.
/// @dev The fee receiver is automatically added as a Spoke with maximum caps.
/// @param hub The address of the Hub.
/// @param underlying The address of the underlying asset.
/// @param decimals The number of decimals of the asset.
/// @param feeReceiver The address of the fee receiver Spoke.
/// @param liquidityFee The liquidity fee of the asset, expressed in BPS.
/// @param irStrategy The address of the interest rate strategy contract.
/// @param irData The interest rate data to apply to the given asset, encoded in bytes.
/// @return The unique identifier of the added asset.
function addAssetWithDecimals(
address hub,
address underlying,
uint8 decimals,
address feeReceiver,
uint256 liquidityFee,
address irStrategy,
bytes calldata irData
) external returns (uint256);
/// @notice Updates the liquidity fee of an asset on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param liquidityFee The new liquidity fee.
function updateLiquidityFee(address hub, uint256 assetId, uint256 liquidityFee) external;
/// @notice Updates the fee receiver of an asset on a specified hub.
/// @dev The fee receiver cannot be zero.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param feeReceiver The new fee receiver.
function updateFeeReceiver(address hub, uint256 assetId, address feeReceiver) external;
/// @notice Updates the liquidity fee and fee receiver of an asset on a specified Hub.
/// @dev The fee receiver cannot be zero.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param liquidityFee The new liquidity fee.
/// @param feeReceiver The new fee receiver.
function updateFeeConfig(
address hub,
uint256 assetId,
uint256 liquidityFee,
address feeReceiver
) external;
/// @notice Updates the interest rate strategy of an asset on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param irStrategy The new interest rate strategy.
/// @param irData The interest rate data to apply to the given asset, encoded in bytes.
function updateInterestRateStrategy(
address hub,
uint256 assetId,
address irStrategy,
bytes calldata irData
) external;
/// @notice Updates the reinvestment controller of an asset on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param reinvestmentController The new reinvestment controller.
function updateReinvestmentController(
address hub,
uint256 assetId,
address reinvestmentController
) external;
/// @notice Resets all Spokes' add and draw caps to zero for an asset on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
function resetAssetCaps(address hub, uint256 assetId) external;
/// @notice Deactivates an asset on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
function deactivateAsset(address hub, uint256 assetId) external;
/// @notice Halts an asset on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
function haltAsset(address hub, uint256 assetId) external;
/// @notice Registers the Spoke for the specified asset on a specified Hub.
/// @param hub The address of the Hub.
/// @param spoke The address of the Spoke.
/// @param assetId The identifier of the asset to register the Spoke for.
/// @param config The Spoke configuration to register.
function addSpoke(
address hub,
address spoke,
uint256 assetId,
IHub.SpokeConfig calldata config
) external;
/// @notice Registers the same Spoke for multiple assets on a specified Hub, each with their own configuration.
/// @dev The i-th asset identifier in `assetIds` corresponds to the i-th configuration in `configs`.
/// @param hub The address of the Hub.
/// @param spoke The address of the Spoke.
/// @param assetIds The list of asset identifiers to register the Spoke for.
/// @param configs The list of Spoke configurations to register.
function addSpokeToAssets(
address hub,
address spoke,
uint256[] calldata assetIds,
IHub.SpokeConfig[] calldata configs
) external;
/// @notice Updates the active flag of an asset's Spoke on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param active The new active flag.
function updateSpokeActive(address hub, uint256 assetId, address spoke, bool active) external;
/// @notice Updates the halted flag of an asset's Spoke on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param halted The new halted flag.
function updateSpokeHalted(address hub, uint256 assetId, address spoke, bool halted) external;
/// @notice Updates the add cap of an asset's spoke on a specified hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param addCap The new add cap.
function updateSpokeAddCap(address hub, uint256 assetId, address spoke, uint256 addCap) external;
/// @notice Updates the draw cap of an asset's Spoke on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param drawCap The new draw cap.
function updateSpokeDrawCap(
address hub,
uint256 assetId,
address spoke,
uint256 drawCap
) external;
/// @notice Updates the risk premium threshold of an asset's Spoke on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param riskPremiumThreshold The new risk premium threshold.
function updateSpokeRiskPremiumThreshold(
address hub,
uint256 assetId,
address spoke,
uint256 riskPremiumThreshold
) external;
/// @notice Updates the caps of an asset's Spoke on a specified Hub.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param spoke The address of the Spoke.
/// @param addCap The new add cap.
/// @param drawCap The new draw cap.
function updateSpokeCaps(
address hub,
uint256 assetId,
address spoke,
uint256 addCap,
uint256 drawCap
) external;
/// @notice Deactivates all assets of a Spoke on a specified Hub by setting the active flag to false.
/// @param hub The address of the Hub.
/// @param spoke The address of the Spoke.
function deactivateSpoke(address hub, address spoke) external;
/// @notice Halts all assets of a Spoke on a specified Hub by setting the halted flag to true.
/// @param hub The address of the Hub.
/// @param spoke The address of the Spoke.
function haltSpoke(address hub, address spoke) external;
/// @notice Resets draw cap and add cap to zero for a Spoke on a specified Hub.
/// @param hub The address of the Hub.
/// @param spoke The address of the Spoke.
function resetSpokeCaps(address hub, address spoke) external;
/// @notice Updates the interest rate data for an asset.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset.
/// @param irData The interest rate data to apply to the given asset, encoded in bytes.
function updateInterestRateData(address hub, uint256 assetId, bytes calldata irData) external;
}
src/interfaces/IExtSload.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity ^0.8.0;
/// @title IExtSload
/// @author Aave Labs
/// @notice Minimal interface to easily access storage of source contract externally. See https://eips.ethereum.org/EIPS/eip-2330#rationale.
interface IExtSload {
/// @notice Returns the storage `value` of this contract at a given `slot`.
/// @param slot Slot to SLOAD from.
function extSload(bytes32 slot) external view returns (bytes32 value);
/// @notice Returns the storage `values` of this contract at the given `slots`.
/// @param slots Array of slots to SLOAD from.
function extSloads(bytes32[] calldata slots) external view returns (bytes32[] memory values);
}
src/interfaces/IIntentConsumer.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity ^0.8.0;
import {INoncesKeyed} from 'src/interfaces/INoncesKeyed.sol';
/// @title IIntentConsumer
/// @author Aave Labs
/// @notice Minimal interface for IntentConsumer.
interface IIntentConsumer is INoncesKeyed {
/// @notice Thrown when given signature is invalid.
error InvalidSignature();
/// @notice Returns the EIP-712 domain separator.
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
src/interfaces/IMulticall.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity ^0.8.0;
/// @title IMulticall
/// @author Aave Labs
/// @notice Minimal interface for Multicall.
interface IMulticall {
/// @notice Call multiple functions in the current contract and return the data from each if they all succeed.
/// @param data The encoded function data for each of the calls to make to this contract.
/// @return results The results from each of the calls passed in via data.
function multicall(bytes[] calldata data) external returns (bytes[] memory);
}
src/interfaces/INoncesKeyed.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity ^0.8.0;
interface INoncesKeyed {
/// @notice Thrown when nonce being consumed does not match `currentNonce` for `account`.
error InvalidAccountNonce(address account, uint256 currentNonce);
/// @notice Allows caller to revoke their next sequential nonce at specified `key`.
/// @dev This does not invalidate nonce at other `key`s namespace.
/// @param key The key which specifies namespace of the nonce.
/// @return keyNonce The revoked key-prefixed nonce.
function useNonce(uint192 key) external returns (uint256 keyNonce);
/// @notice Returns the next unused nonce for an address and key. Result contains the key prefix.
/// @param owner The address of the nonce owner.
/// @param key The key which specifies namespace of the nonce.
/// @return keyNonce The first 24 bytes are for the key, & the last 8 bytes for the nonce.
function nonces(address owner, uint192 key) external view returns (uint256 keyNonce);
}
src/spoke/SpokeConfigurator.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity 0.8.28;
import {SafeCast} from 'src/dependencies/openzeppelin/SafeCast.sol';
import {AccessManaged} from 'src/dependencies/openzeppelin/AccessManaged.sol';
import {ISpoke} from 'src/spoke/interfaces/ISpoke.sol';
import {ISpokeConfigurator} from 'src/spoke/interfaces/ISpokeConfigurator.sol';
/// @title SpokeConfigurator
/// @author Aave Labs
/// @notice Handles administrative functions on the Spoke.
/// @dev Must be granted permission by the Spoke.
contract SpokeConfigurator is AccessManaged, ISpokeConfigurator {
using SafeCast for uint256;
/// @dev Constructor.
/// @param authority_ The address of the authority contract which manages permissions.
constructor(address authority_) AccessManaged(authority_) {
require(authority_ != address(0), InvalidAddress());
}
/// @inheritdoc ISpokeConfigurator
function updateReservePriceSource(
address spoke,
uint256 reserveId,
address priceSource
) external restricted {
ISpoke(spoke).updateReservePriceSource(reserveId, priceSource);
}
/// @inheritdoc ISpokeConfigurator
function updateLiquidationTargetHealthFactor(
address spoke,
uint256 targetHealthFactor
) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.LiquidationConfig memory liquidationConfig = targetSpoke.getLiquidationConfig();
liquidationConfig.targetHealthFactor = targetHealthFactor.toUint128();
targetSpoke.updateLiquidationConfig(liquidationConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateHealthFactorForMaxBonus(
address spoke,
uint256 healthFactorForMaxBonus
) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.LiquidationConfig memory liquidationConfig = targetSpoke.getLiquidationConfig();
liquidationConfig.healthFactorForMaxBonus = healthFactorForMaxBonus.toUint64();
targetSpoke.updateLiquidationConfig(liquidationConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateLiquidationBonusFactor(
address spoke,
uint256 liquidationBonusFactor
) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.LiquidationConfig memory liquidationConfig = targetSpoke.getLiquidationConfig();
liquidationConfig.liquidationBonusFactor = liquidationBonusFactor.toUint16();
targetSpoke.updateLiquidationConfig(liquidationConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateLiquidationConfig(
address spoke,
ISpoke.LiquidationConfig calldata liquidationConfig
) external restricted {
ISpoke(spoke).updateLiquidationConfig(liquidationConfig);
}
/// @inheritdoc ISpokeConfigurator
function addReserve(
address spoke,
address hub,
uint256 assetId,
address priceSource,
ISpoke.ReserveConfig calldata config,
ISpoke.DynamicReserveConfig calldata dynamicConfig
) external restricted returns (uint256) {
return ISpoke(spoke).addReserve(hub, assetId, priceSource, config, dynamicConfig);
}
/// @inheritdoc ISpokeConfigurator
function updatePaused(address spoke, uint256 reserveId, bool paused) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.ReserveConfig memory reserveConfig = targetSpoke.getReserveConfig(reserveId);
reserveConfig.paused = paused;
targetSpoke.updateReserveConfig(reserveId, reserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateFrozen(address spoke, uint256 reserveId, bool frozen) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.ReserveConfig memory reserveConfig = targetSpoke.getReserveConfig(reserveId);
reserveConfig.frozen = frozen;
targetSpoke.updateReserveConfig(reserveId, reserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateBorrowable(address spoke, uint256 reserveId, bool borrowable) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.ReserveConfig memory reserveConfig = targetSpoke.getReserveConfig(reserveId);
reserveConfig.borrowable = borrowable;
targetSpoke.updateReserveConfig(reserveId, reserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateReceiveSharesEnabled(
address spoke,
uint256 reserveId,
bool receiveSharesEnabled
) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.ReserveConfig memory reserveConfig = targetSpoke.getReserveConfig(reserveId);
reserveConfig.receiveSharesEnabled = receiveSharesEnabled;
targetSpoke.updateReserveConfig(reserveId, reserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateCollateralRisk(
address spoke,
uint256 reserveId,
uint256 collateralRisk
) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.ReserveConfig memory reserveConfig = targetSpoke.getReserveConfig(reserveId);
reserveConfig.collateralRisk = collateralRisk.toUint24();
targetSpoke.updateReserveConfig(reserveId, reserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function addCollateralFactor(
address spoke,
uint256 reserveId,
uint16 collateralFactor
) external restricted returns (uint32) {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.DynamicReserveConfig memory dynamicReserveConfig = targetSpoke.getDynamicReserveConfig(
reserveId,
_getReserveLastDynamicConfigKey(spoke, reserveId)
);
dynamicReserveConfig.collateralFactor = collateralFactor;
return targetSpoke.addDynamicReserveConfig(reserveId, dynamicReserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateCollateralFactor(
address spoke,
uint256 reserveId,
uint32 dynamicConfigKey,
uint16 collateralFactor
) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.DynamicReserveConfig memory dynamicReserveConfig = targetSpoke.getDynamicReserveConfig(
reserveId,
dynamicConfigKey
);
dynamicReserveConfig.collateralFactor = collateralFactor;
targetSpoke.updateDynamicReserveConfig(reserveId, dynamicConfigKey, dynamicReserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function addMaxLiquidationBonus(
address spoke,
uint256 reserveId,
uint256 maxLiquidationBonus
) external restricted returns (uint32) {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.DynamicReserveConfig memory dynamicReserveConfig = targetSpoke.getDynamicReserveConfig(
reserveId,
_getReserveLastDynamicConfigKey(spoke, reserveId)
);
dynamicReserveConfig.maxLiquidationBonus = maxLiquidationBonus.toUint32();
return targetSpoke.addDynamicReserveConfig(reserveId, dynamicReserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateMaxLiquidationBonus(
address spoke,
uint256 reserveId,
uint32 dynamicConfigKey,
uint256 maxLiquidationBonus
) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.DynamicReserveConfig memory dynamicReserveConfig = targetSpoke.getDynamicReserveConfig(
reserveId,
dynamicConfigKey
);
dynamicReserveConfig.maxLiquidationBonus = maxLiquidationBonus.toUint32();
targetSpoke.updateDynamicReserveConfig(reserveId, dynamicConfigKey, dynamicReserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function addLiquidationFee(
address spoke,
uint256 reserveId,
uint256 liquidationFee
) external restricted returns (uint32) {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.DynamicReserveConfig memory dynamicReserveConfig = targetSpoke.getDynamicReserveConfig(
reserveId,
_getReserveLastDynamicConfigKey(spoke, reserveId)
);
dynamicReserveConfig.liquidationFee = liquidationFee.toUint16();
return targetSpoke.addDynamicReserveConfig(reserveId, dynamicReserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateLiquidationFee(
address spoke,
uint256 reserveId,
uint32 dynamicConfigKey,
uint256 liquidationFee
) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.DynamicReserveConfig memory dynamicReserveConfig = targetSpoke.getDynamicReserveConfig(
reserveId,
dynamicConfigKey
);
dynamicReserveConfig.liquidationFee = liquidationFee.toUint16();
targetSpoke.updateDynamicReserveConfig(reserveId, dynamicConfigKey, dynamicReserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function addDynamicReserveConfig(
address spoke,
uint256 reserveId,
ISpoke.DynamicReserveConfig calldata dynamicConfig
) external restricted returns (uint32) {
return ISpoke(spoke).addDynamicReserveConfig(reserveId, dynamicConfig);
}
/// @inheritdoc ISpokeConfigurator
function updateDynamicReserveConfig(
address spoke,
uint256 reserveId,
uint32 dynamicConfigKey,
ISpoke.DynamicReserveConfig calldata dynamicConfig
) external restricted {
ISpoke(spoke).updateDynamicReserveConfig(reserveId, dynamicConfigKey, dynamicConfig);
}
/// @inheritdoc ISpokeConfigurator
function pauseAllReserves(address spoke) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
uint256 reserveCount = targetSpoke.getReserveCount();
for (uint256 reserveId = 0; reserveId < reserveCount; ++reserveId) {
ISpoke.ReserveConfig memory reserveConfig = targetSpoke.getReserveConfig(reserveId);
reserveConfig.paused = true;
targetSpoke.updateReserveConfig(reserveId, reserveConfig);
}
}
/// @inheritdoc ISpokeConfigurator
function freezeAllReserves(address spoke) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
uint256 reserveCount = targetSpoke.getReserveCount();
for (uint256 reserveId = 0; reserveId < reserveCount; ++reserveId) {
ISpoke.ReserveConfig memory reserveConfig = targetSpoke.getReserveConfig(reserveId);
reserveConfig.frozen = true;
targetSpoke.updateReserveConfig(reserveId, reserveConfig);
}
}
// @inheritdoc ISpokeConfigurator
function pauseReserve(address spoke, uint256 reserveId) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.ReserveConfig memory reserveConfig = targetSpoke.getReserveConfig(reserveId);
reserveConfig.paused = true;
targetSpoke.updateReserveConfig(reserveId, reserveConfig);
}
// @inheritdoc ISpokeConfigurator
function freezeReserve(address spoke, uint256 reserveId) external restricted {
ISpoke targetSpoke = ISpoke(spoke);
ISpoke.ReserveConfig memory reserveConfig = targetSpoke.getReserveConfig(reserveId);
reserveConfig.frozen = true;
targetSpoke.updateReserveConfig(reserveId, reserveConfig);
}
/// @inheritdoc ISpokeConfigurator
function updatePositionManager(
address spoke,
address positionManager,
bool active
) external restricted {
ISpoke(spoke).updatePositionManager(positionManager, active);
}
/// @dev Returns the last dynamic config key of the reserve for the specified Spoke.
function _getReserveLastDynamicConfigKey(
address spoke,
uint256 reserveId
) internal view returns (uint32) {
return ISpoke(spoke).getReserve(reserveId).dynamicConfigKey;
}
}
src/spoke/interfaces/ISpoke.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity ^0.8.0;
import {IAccessManaged} from 'src/dependencies/openzeppelin/IAccessManaged.sol';
import {IIntentConsumer} from 'src/interfaces/IIntentConsumer.sol';
import {IMulticall} from 'src/interfaces/IMulticall.sol';
import {IHubBase} from 'src/hub/interfaces/IHubBase.sol';
import {IExtSload} from 'src/interfaces/IExtSload.sol';
type ReserveFlags is uint8;
/// @title ISpoke
/// @author Aave Labs
/// @notice Full interface for Spoke.
interface ISpoke is IAccessManaged, IIntentConsumer, IExtSload, IMulticall {
/// @notice Intent data to set user position managers with EIP712-typed signature.
/// @param onBehalfOf The address of the user on whose behalf position manager can act.
/// @param updates The array of position manager updates.
/// @param nonce The nonce for the signature.
/// @param deadline The deadline for the signature.
struct SetUserPositionManagers {
address onBehalfOf;
PositionManagerUpdate[] updates;
uint256 nonce;
uint256 deadline;
}
/// @notice Sub-Intent data to apply position manager update for user.
/// @param positionManager The address of the position manager.
/// @param approve True to approve the position manager, false to revoke approval.
struct PositionManagerUpdate {
address positionManager;
bool approve;
}
/// @notice Reserve level data.
/// @dev underlying The address of the underlying asset.
/// @dev hub The address of the associated Hub.
/// @dev assetId The identifier of the asset in the Hub.
/// @dev decimals The number of decimals of the underlying asset.
/// @dev collateralRisk The risk associated with a collateral asset, expressed in BPS.
/// @dev flags The packed boolean flags of the reserve (a wrapped uint8).
/// @dev dynamicConfigKey The key of the last reserve dynamic config.
struct Reserve {
address underlying;
//
IHubBase hub;
uint16 assetId;
uint8 decimals;
uint24 collateralRisk;
ReserveFlags flags;
uint32 dynamicConfigKey;
}
/// @notice Reserve configuration. Subset of the `Reserve` struct.
/// @dev collateralRisk The risk associated with a collateral asset, expressed in BPS.
/// @dev paused True if all actions are prevented for the reserve.
/// @dev frozen True if new activity is prevented for the reserve.
/// @dev borrowable True if the reserve is borrowable.
/// @dev receiveSharesEnabled True if the liquidator can receive collateral shares during liquidation.
struct ReserveConfig {
uint24 collateralRisk;
bool paused;
bool frozen;
bool borrowable;
bool receiveSharesEnabled;
}
/// @notice Dynamic reserve configuration data.
/// @dev collateralFactor The proportion of a reserve's value eligible to be used as collateral, expressed in BPS.
/// @dev maxLiquidationBonus The maximum extra amount of collateral given to the liquidator as bonus, expressed in BPS. 100_00 represents 0.00% bonus.
/// @dev liquidationFee The protocol fee charged on liquidations, taken from the collateral bonus given to the liquidator, expressed in BPS.
struct DynamicReserveConfig {
uint16 collateralFactor;
uint32 maxLiquidationBonus;
uint16 liquidationFee;
}
/// @notice Liquidation configuration data.
/// @dev targetHealthFactor The ideal health factor to restore a user position during liquidation, expressed in WAD.
/// @dev healthFactorForMaxBonus The health factor under which liquidation bonus is maximum, expressed in WAD.
/// @dev liquidationBonusFactor The value multiplied by `maxLiquidationBonus` to compute the minimum liquidation bonus, expressed in BPS.
struct LiquidationConfig {
uint128 targetHealthFactor;
uint64 healthFactorForMaxBonus;
uint16 liquidationBonusFactor;
}
/// @notice User position data per reserve.
/// @dev drawnShares The drawn shares of the user position.
/// @dev premiumShares The premium shares of the user position.
/// @dev premiumOffsetRay The premium offset of the user position, used to calculate the premium, expressed in asset units and scaled by RAY.
/// @dev suppliedShares The supplied shares of the user position.
/// @dev dynamicConfigKey The key of the user position dynamic config.
struct UserPosition {
uint120 drawnShares;
uint120 premiumShares;
//
int200 premiumOffsetRay;
//
uint120 suppliedShares;
uint32 dynamicConfigKey;
}
/// @notice Position manager configuration data.
/// @dev approval The mapping of position manager user approvals.
/// @dev active True if the position manager is active.
struct PositionManagerConfig {
mapping(address user => bool) approval;
bool active;
}
/// @notice User position status data.
/// @dev map The map of bitmap buckets for the position status.
/// @dev riskPremium The risk premium of the user position, expressed in BPS.
struct PositionStatus {
mapping(uint256 bucket => uint256) map;
uint24 riskPremium;
}
/// @notice User account data describing a user position and its health.
/// @dev riskPremium The risk premium of the user position, expressed in BPS.
/// @dev avgCollateralFactor The weighted average collateral factor of the user position, expressed in WAD.
/// @dev healthFactor The health factor of the user position, expressed in WAD. 1e18 represents a health factor of 1.00.
/// @dev totalCollateralValue The total collateral value of the user position, expressed in units of Value.
/// @dev totalDebtValueRay The total debt value of the user position, expressed in units of Value and scaled by RAY.
/// @dev activeCollateralCount The number of active collaterals, which includes reserves with `collateralFactor` > 0, `enabledAsCollateral` and `suppliedAmount` > 0.
/// @dev borrowCount The number of borrowed reserves of the user position.
struct UserAccountData {
uint256 riskPremium;
uint256 avgCollateralFactor;
uint256 healthFactor;
uint256 totalCollateralValue;
uint256 totalDebtValueRay;
uint256 activeCollateralCount;
uint256 borrowCount;
}
/// @notice Emitted when the immutable variables of the Spoke are set.
/// @param oracle The address of the oracle.
/// @param maxUserReservesLimit The max user reserves limit.
event SetSpokeImmutables(address indexed oracle, uint16 maxUserReservesLimit);
/// @notice Emitted when a liquidation config is updated.
/// @param config The new liquidation config.
event UpdateLiquidationConfig(LiquidationConfig config);
/// @notice Emitted when a reserve is added.
/// @param reserveId The identifier of the reserve.
/// @param assetId The identifier of the asset.
/// @param hub The address of the Hub where the asset is listed.
event AddReserve(uint256 indexed reserveId, uint256 indexed assetId, address indexed hub);
/// @notice Emitted when a reserve configuration is updated.
/// @param reserveId The identifier of the reserve.
/// @param config The reserve configuration.
event UpdateReserveConfig(uint256 indexed reserveId, ReserveConfig config);
/// @notice Emitted when the price source of a reserve is updated.
/// @param reserveId The identifier of the reserve.
/// @param priceSource The address of the new price source.
event UpdateReservePriceSource(uint256 indexed reserveId, address indexed priceSource);
/// @notice Emitted when a dynamic reserve config is added.
/// @dev The config key is the next available key for the reserve, which is now the latest config
/// key of the reserve.
/// @param reserveId The identifier of the reserve.
/// @param dynamicConfigKey The key of the added dynamic config.
/// @param config The dynamic reserve config.
event AddDynamicReserveConfig(
uint256 indexed reserveId,
uint32 indexed dynamicConfigKey,
DynamicReserveConfig config
);
/// @notice Emitted when a dynamic reserve config is updated.
/// @param reserveId The identifier of the reserve.
/// @param dynamicConfigKey The key of the updated dynamic config.
/// @param config The dynamic reserve config.
event UpdateDynamicReserveConfig(
uint256 indexed reserveId,
uint32 indexed dynamicConfigKey,
DynamicReserveConfig config
);
/// @notice Emitted on updatePositionManager action.
/// @param positionManager The address of the position manager.
/// @param active True if position manager has become active.
event UpdatePositionManager(address indexed positionManager, bool active);
/// @notice Emitted on the supply action.
/// @param reserveId The reserve identifier of the underlying asset.
/// @param caller The transaction initiator, and supplier of the underlying asset.
/// @param user The owner of the modified position.
/// @param suppliedShares The amount of supply shares minted.
/// @param suppliedAmount The amount of underlying asset supplied.
event Supply(
uint256 indexed reserveId,
address indexed caller,
address indexed user,
uint256 suppliedShares,
uint256 suppliedAmount
);
/// @notice Emitted on the withdraw action.
/// @param reserveId The reserve identifier of the underlying asset.
/// @param caller The transaction initiator, and recipient of the underlying asset being withdrawn.
/// @param user The owner of the modified position.
/// @param withdrawnShares The amount of supply shares burned.
/// @param withdrawnAmount The amount of underlying asset withdrawn.
event Withdraw(
uint256 indexed reserveId,
address indexed caller,
address indexed user,
uint256 withdrawnShares,
uint256 withdrawnAmount
);
/// @notice Emitted on the borrow action.
/// @param reserveId The reserve identifier of the underlying asset.
/// @param caller The transaction initiator, and recipient of the underlying asset being borrowed.
/// @param user The owner of the position on which debt is generated.
/// @param drawnShares The amount of debt shares minted.
/// @param drawnAmount The amount of underlying asset borrowed.
event Borrow(
uint256 indexed reserveId,
address indexed caller,
address indexed user,
uint256 drawnShares,
uint256 drawnAmount
);
/// @notice Emitted on the repay action.
/// @param reserveId The reserve identifier of the underlying asset.
/// @param caller The transaction initiator who is repaying the underlying asset.
/// @param user The owner of the position whose debt is being repaid.
/// @param drawnShares The amount of drawn shares burned.
/// @param totalAmountRepaid The amount of drawn and premium underlying assets repaid.
/// @param premiumDelta A struct representing the changes to premium debt after repayment.
event Repay(
uint256 indexed reserveId,
address indexed caller,
address indexed user,
uint256 drawnShares,
uint256 totalAmountRepaid,
IHubBase.PremiumDelta premiumDelta
);
/// @dev Emitted when a borrower is liquidated.
/// @param collateralReserveId The identifier of the reserve used as collateral, to receive as a result of the liquidation.
/// @param debtReserveId The identifier of the reserve to be repaid with the liquidation.
/// @param user The address of the borrower getting liquidated.
/// @param liquidator The address of the liquidator.
/// @param receiveShares True if the liquidator received collateral in supplied shares rather than underlying assets.
/// @param debtAmountRestored The amount of debt restored, expressed in asset units.
/// @param drawnSharesLiquidated The amount of drawn shares liquidated.
/// @param premiumDelta A struct representing the changes to premium debt after liquidation.
/// @param collateralAmountRemoved The amount of collateral removed, expressed in asset units.
/// @param collateralSharesLiquidated The total amount of collateral shares liquidated.
/// @param collateralSharesToLiquidator The amount of collateral shares that the liquidator received.
event LiquidationCall(
uint256 indexed collateralReserveId,
uint256 indexed debtReserveId,
address indexed user,
address liquidator,
bool receiveShares,
uint256 debtAmountRestored,
uint256 drawnSharesLiquidated,
IHubBase.PremiumDelta premiumDelta,
uint256 collateralAmountRemoved,
uint256 collateralSharesLiquidated,
uint256 collateralSharesToLiquidator
);
/// @notice Emitted when a reserve deficit is reported to the Hub.
/// @param reserveId The identifier of the reserve.
/// @param user The address of the user.
/// @param drawnShares The amount of drawn shares reported as deficit.
/// @param premiumDelta The premium delta data struct reported as deficit.
event ReportDeficit(
uint256 indexed reserveId,
address indexed user,
uint256 drawnShares,
IHubBase.PremiumDelta premiumDelta
);
/// @notice Emitted on setUsingAsCollateral action.
/// @param reserveId The reserve identifier of the underlying asset.
/// @param caller The transaction initiator.
/// @param user The owner of the position being modified.
/// @param usingAsCollateral Whether the reserve is enabled or disabled as collateral.
event SetUsingAsCollateral(
uint256 indexed reserveId,
address indexed caller,
address indexed user,
bool usingAsCollateral
);
/// @notice Emitted on updateUserRiskPremium action.
/// @param user The owner of the position being modified.
/// @param riskPremium The new risk premium (BPS) value of user.
event UpdateUserRiskPremium(address indexed user, uint256 riskPremium);
/// @notice Emitted when a user's dynamic config is refreshed for all reserves to their latest config key.
/// @param user The address of the user.
event RefreshAllUserDynamicConfig(address indexed user);
/// @notice Emitted when a user's dynamic config is refreshed for a single reserve to its latest config key.
/// @param user The address of the user.
/// @param reserveId The identifier of the reserve.
event RefreshSingleUserDynamicConfig(address indexed user, uint256 reserveId);
/// @notice Emitted on setUserPositionManager or renouncePositionManagerRole action.
/// @param user The address of the user on whose behalf position manager can act.
/// @param positionManager The address of the position manager.
/// @param approve True if position manager approval was granted, false if it was revoked.
event SetUserPositionManager(address indexed user, address indexed positionManager, bool approve);
/// @notice Emitted on refreshPremiumDebt action.
/// @param reserveId The identifier of the reserve.
/// @param user The address of the user.
/// @param premiumDelta The change in premium values.
event RefreshPremiumDebt(
uint256 indexed reserveId,
address indexed user,
IHubBase.PremiumDelta premiumDelta
);
/// @notice Thrown when an asset is not listed on the Hub when adding a reserve.
error AssetNotListed();
/// @notice Thrown when adding a new reserve if that reserve already exists for a given Hub/assetId pair.
error ReserveExists();
/// @notice Thrown when adding a new reserve if an asset id is invalid.
error InvalidAssetId();
/// @notice Thrown when adding a new reserve if the asset decimals are invalid.
error InvalidAssetDecimals();
/// @notice Thrown when updating a reserve if it is not listed.
error ReserveNotListed();
/// @notice Thrown when a reserve is not borrowable during a `borrow` action.
error ReserveNotBorrowable();
/// @notice Thrown when a reserve is paused during an attempted action.
error ReservePaused();
/// @notice Thrown when a reserve is frozen.
/// @dev Can only occur during an attempted `supply`, `borrow`, or `setUsingAsCollateral` action.
error ReserveFrozen();
/// @notice Thrown when an action causes a user's health factor to fall below the liquidation threshold.
error HealthFactorBelowThreshold();
/// @notice Thrown when reserve is not enabled as collateral during liquidation.
error ReserveNotEnabledAsCollateral();
/// @notice Thrown when a specified reserve is not supplied by the user during liquidation.
error ReserveNotSupplied();
/// @notice Thrown when a specified reserve is not borrowed by the user during liquidation.
error ReserveNotBorrowed();
/// @notice Thrown when an unauthorized caller attempts an action.
error Unauthorized();
/// @notice Thrown if a config key is uninitialized when updating a dynamic reserve config.
error DynamicConfigKeyUninitialized();
/// @notice Thrown for an invalid zero address.
error InvalidAddress();
/// @notice Thrown when the oracle decimals are not 8 in the constructor.
error InvalidOracleDecimals();
/// @notice Thrown when the maximum user reserves limit is zero in the constructor.
error InvalidMaxUserReservesLimit();
/// @notice Thrown when a collateral risk exceeds the maximum allowed.
error InvalidCollateralRisk();
/// @notice Thrown if a liquidation config is invalid when it is updated.
error InvalidLiquidationConfig();
/// @notice Thrown when a liquidation fee is invalid.
error InvalidLiquidationFee();
/// @notice Thrown when a collateral factor and max liquidation bonus are invalid.
error InvalidCollateralFactorAndMaxLiquidationBonus();
/// @notice Thrown when trying to set zero collateralFactor on historic dynamic configuration keys.
error InvalidCollateralFactor();
/// @notice Thrown when a self-liquidation is attempted.
error SelfLiquidation();
/// @notice Thrown during liquidation when a user's health factor is not below the liquidation threshold.
error HealthFactorNotBelowThreshold();
/// @notice Thrown when collateral or debt dust remains after a liquidation, and neither reserve is fully liquidated.
error MustNotLeaveDust();
/// @notice Thrown when a debt to cover input is zero.
error InvalidDebtToCover();
/// @notice Thrown when the liquidator tries to receive shares for a collateral reserve that is frozen or is not enabled to receive shares.
error CannotReceiveShares();
/// @notice Thrown when the maximum number of dynamic config keys is reached.
error MaximumDynamicConfigKeyReached();
/// @notice Thrown when user attempts to exceed either the maximum allowed collateral or borrowed reserves.
error MaximumUserReservesExceeded();
/// @notice Updates the liquidation config.
/// @param config The new liquidation config.
function updateLiquidationConfig(LiquidationConfig calldata config) external;
/// @notice Adds a new reserve to the Spoke.
/// @dev Allowed even if the Spoke has not yet been added to the Hub.
/// @dev Allowed even if the `active` flag is `false`.
/// @dev Allowed even if the Spoke has been added but the `addCap` is zero.
/// @param hub The address of the Hub where the asset is listed.
/// @param assetId The identifier of the asset in the Hub.
/// @param priceSource The address of the price source for the asset.
/// @param config The initial reserve configuration.
/// @param dynamicConfig The initial dynamic reserve configuration.
/// @return The identifier of the newly added reserve.
function addReserve(
address hub,
uint256 assetId,
address priceSource,
ReserveConfig calldata config,
DynamicReserveConfig calldata dynamicConfig
) external returns (uint256);
/// @notice Updates the reserve config for a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @param reserveId The identifier of the reserve.
/// @param params The new reserve config.
function updateReserveConfig(uint256 reserveId, ReserveConfig calldata params) external;
/// @notice Updates the price source of a reserve.
/// @param reserveId The identifier of the reserve.
/// @param priceSource The address of the price source.
function updateReservePriceSource(uint256 reserveId, address priceSource) external;
/// @notice Updates the dynamic reserve config for a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev Appends dynamic config to the next available key; reverts if `MAX_ALLOWED_DYNAMIC_CONFIG_KEY` is reached.
/// @param reserveId The identifier of the reserve.
/// @param dynamicConfig The new dynamic reserve config.
/// @return dynamicConfigKey The key of the added dynamic config.
function addDynamicReserveConfig(
uint256 reserveId,
DynamicReserveConfig calldata dynamicConfig
) external returns (uint32 dynamicConfigKey);
/// @notice Updates the dynamic reserve config for a given reserve at the specified key.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev Reverts with `DynamicConfigKeyUninitialized` if the config key has not been initialized yet.
/// @dev Reverts with `InvalidCollateralFactor` if the collateral factor is 0.
/// @param reserveId The identifier of the reserve.
/// @param dynamicConfigKey The key of the config to update.
/// @param dynamicConfig The new dynamic reserve config.
function updateDynamicReserveConfig(
uint256 reserveId,
uint32 dynamicConfigKey,
DynamicReserveConfig calldata dynamicConfig
) external;
/// @notice Allows an approved caller (admin) to toggle the active status of position manager.
/// @param positionManager The address of the position manager.
/// @param active True if positionManager is to be set as active.
function updatePositionManager(address positionManager, bool active) external;
/// @notice Supplies an amount of underlying asset of the specified reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev The Spoke pulls the underlying asset from the caller, so prior token approval is required.
/// @dev Caller must be `onBehalfOf` or an authorized position manager for `onBehalfOf`.
/// @param reserveId The reserve identifier.
/// @param amount The amount of asset to supply.
/// @param onBehalfOf The owner of the position to add supply shares to.
/// @return The amount of shares supplied.
/// @return The amount of assets supplied.
function supply(
uint256 reserveId,
uint256 amount,
address onBehalfOf
) external returns (uint256, uint256);
/// @notice Withdraws a specified amount of underlying asset from the given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev Providing an amount greater than the maximum withdrawable value signals a full withdrawal.
/// @dev Caller must be `onBehalfOf` or an authorized position manager for `onBehalfOf`.
/// @dev Caller receives the underlying asset withdrawn.
/// @param reserveId The identifier of the reserve.
/// @param amount The amount of asset to withdraw.
/// @param onBehalfOf The owner of position to remove supply shares from.
/// @return The amount of shares withdrawn.
/// @return The amount of assets withdrawn.
function withdraw(
uint256 reserveId,
uint256 amount,
address onBehalfOf
) external returns (uint256, uint256);
/// @notice Borrows a specified amount of underlying asset from the given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev It reverts if the user would borrow more than the maximum allowed number of borrowed reserves.
/// @dev Caller must be `onBehalfOf` or an authorized position manager for `onBehalfOf`.
/// @dev Caller receives the underlying asset borrowed.
/// @param reserveId The identifier of the reserve.
/// @param amount The amount of asset to borrow.
/// @param onBehalfOf The owner of the position against which debt is generated.
/// @return The amount of shares borrowed.
/// @return The amount of assets borrowed.
function borrow(
uint256 reserveId,
uint256 amount,
address onBehalfOf
) external returns (uint256, uint256);
/// @notice Repays a specified amount of underlying asset to a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev The Spoke pulls the underlying asset from the caller, so prior approval is required.
/// @dev Caller must be `onBehalfOf` or an authorized position manager for `onBehalfOf`.
/// @param reserveId The identifier of the reserve.
/// @param amount The amount of asset to repay.
/// @param onBehalfOf The owner of the position whose debt is repaid.
/// @return The amount of shares repaid.
/// @return The amount of assets repaid.
function repay(
uint256 reserveId,
uint256 amount,
address onBehalfOf
) external returns (uint256, uint256);
/// @notice Liquidates a user position.
/// @dev It reverts if the reserves associated with any of the given reserve identifiers are not listed.
/// @dev The Spoke pulls underlying repaid debt assets from caller (Liquidator), hence it needs prior approval.
/// @param collateralReserveId The reserveId of the underlying asset used as collateral by the liquidated user.
/// @param debtReserveId The reserveId of the underlying asset borrowed by the liquidated user, to be repaid by Liquidator.
/// @param user The address of the user to liquidate.
/// @param debtToCover The desired amount of debt to cover.
/// @param receiveShares True to receive collateral in supplied shares, false to receive in underlying assets.
function liquidationCall(
uint256 collateralReserveId,
uint256 debtReserveId,
address user,
uint256 debtToCover,
bool receiveShares
) external;
/// @notice Allows suppliers to enable/disable a specific supplied reserve as collateral.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev It reverts if the user exceeds the maximum allowed collateral reserves when enabling.
/// @dev Reserves with zero supplied or zero collateral factor count towards the max allowed collateral reserves.
/// @dev Caller must be `onBehalfOf` or an authorized position manager for `onBehalfOf`.
/// @param reserveId The reserve identifier of the underlying asset.
/// @param usingAsCollateral True if the user wants to use the supply as collateral.
/// @param onBehalfOf The owner of the position being modified.
function setUsingAsCollateral(
uint256 reserveId,
bool usingAsCollateral,
address onBehalfOf
) external;
/// @notice Allows updating the risk premium on onBehalfOf position.
/// @dev Caller must be `onBehalfOf`, an authorized position manager for `onBehalfOf`, or admin.
/// @param onBehalfOf The owner of the position being modified.
function updateUserRiskPremium(address onBehalfOf) external;
/// @notice Allows updating the dynamic configuration for all collateral reserves on onBehalfOf position.
/// @dev Caller must be `onBehalfOf`, an authorized position manager for `onBehalfOf`, or admin.
/// @param onBehalfOf The owner of the position being modified.
function updateUserDynamicConfig(address onBehalfOf) external;
/// @notice Enables a user to grant or revoke approval for a position manager.
/// @dev Allows approving inactive position managers.
/// @param positionManager The address of the position manager.
/// @param approve True to approve the position manager, false to revoke approval.
function setUserPositionManager(address positionManager, bool approve) external;
/// @notice Enables a user to grant or revoke approval for an array of position managers using an EIP712-typed intent.
/// @dev Uses keyed-nonces where for each key's namespace nonce is consumed sequentially.
/// @dev Allows duplicated updates and the last one is persisted. Allows approving inactive position managers.
/// @param params The structured setUserPositionManagers parameter.
/// @param signature The EIP712-compliant signature bytes.
function setUserPositionManagersWithSig(
SetUserPositionManagers calldata params,
bytes calldata signature
) external;
/// @notice Allows position manager (as caller) to renounce their approval given by the user.
/// @param user The address of the user.
function renouncePositionManagerRole(address user) external;
/// @notice Allows consuming a permit signature for the given reserve's underlying asset.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev The Spoke must be configured as the spender.
/// @param reserveId The identifier of the reserve.
/// @param onBehalfOf The address of the user on whose behalf the permit is being used.
/// @param value The amount of the underlying asset to permit.
/// @param deadline The deadline for the permit.
/// @param permitV The v parameter of the permit signature.
/// @param permitR The r parameter of the permit signature.
/// @param permitS The s parameter of the permit signature.
function permitReserve(
uint256 reserveId,
address onBehalfOf,
uint256 value,
uint256 deadline,
uint8 permitV,
bytes32 permitR,
bytes32 permitS
) external;
/// @notice Returns the liquidation config struct.
function getLiquidationConfig() external view returns (LiquidationConfig memory);
/// @notice Returns the number of listed reserves on the Spoke.
/// @dev Count includes reserves that are not currently active.
function getReserveCount() external view returns (uint256);
/// @notice Returns the total amount of supplied assets of a given reserve.
/// @param reserveId The identifier of the reserve.
/// @return The amount of supplied assets.
function getReserveSuppliedAssets(uint256 reserveId) external view returns (uint256);
/// @notice Returns the total amount of supplied shares of a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @param reserveId The identifier of the reserve.
/// @return The amount of supplied shares.
function getReserveSuppliedShares(uint256 reserveId) external view returns (uint256);
/// @notice Returns the debt of a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev The total debt of the reserve is the sum of drawn debt and premium debt.
/// @param reserveId The identifier of the reserve.
/// @return The amount of drawn debt.
/// @return The amount of premium debt.
function getReserveDebt(uint256 reserveId) external view returns (uint256, uint256);
/// @notice Returns the total debt of a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev The total debt of the reserve is the sum of drawn debt and premium debt.
/// @param reserveId The identifier of the reserve.
/// @return The total debt amount.
function getReserveTotalDebt(uint256 reserveId) external view returns (uint256);
/// @notice Returns the reserve identifier for a given asset in a Hub.
/// @dev It reverts if no reserve is associated with the given asset identifier.
/// @param hub The address of the Hub.
/// @param assetId The identifier of the asset on the Hub.
/// @return The identifier of the reserve.
function getReserveId(address hub, uint256 assetId) external view returns (uint256);
/// @notice Returns the reserve struct data in storage.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @param reserveId The identifier of the reserve.
/// @return The reserve struct.
function getReserve(uint256 reserveId) external view returns (Reserve memory);
/// @notice Returns the reserve configuration struct data in storage.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @param reserveId The identifier of the reserve.
/// @return The reserve configuration struct.
function getReserveConfig(uint256 reserveId) external view returns (ReserveConfig memory);
/// @notice Returns the dynamic reserve configuration struct at the specified key.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev Does not revert if `dynamicConfigKey` is unset.
/// @param reserveId The identifier of the reserve.
/// @param dynamicConfigKey The key of the dynamic config.
/// @return The dynamic reserve configuration struct.
function getDynamicReserveConfig(
uint256 reserveId,
uint32 dynamicConfigKey
) external view returns (DynamicReserveConfig memory);
/// @notice Returns two flags indicating whether the reserve is used as collateral and whether it is borrowed by the user.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev Even if enabled as collateral, it will only count towards user position if the collateral factor is greater than 0.
/// @param reserveId The identifier of the reserve.
/// @param user The address of the user.
/// @return True if the reserve is enabled as collateral by the user.
/// @return True if the reserve is borrowed by the user.
function getUserReserveStatus(uint256 reserveId, address user) external view returns (bool, bool);
/// @notice Returns the amount of assets supplied by a specific user for a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @param reserveId The identifier of the reserve.
/// @param user The address of the user.
/// @return The amount of assets supplied by the user.
function getUserSuppliedAssets(uint256 reserveId, address user) external view returns (uint256);
/// @notice Returns the amount of shares supplied by a specific user for a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @param reserveId The identifier of the reserve.
/// @param user The address of the user.
/// @return The amount of shares supplied by the user.
function getUserSuppliedShares(uint256 reserveId, address user) external view returns (uint256);
/// @notice Returns the debt of a specific user for a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev The total debt of the user is the sum of drawn debt and premium debt.
/// @param reserveId The identifier of the reserve.
/// @param user The address of the user.
/// @return The amount of drawn debt.
/// @return The amount of premium debt.
function getUserDebt(uint256 reserveId, address user) external view returns (uint256, uint256);
/// @notice Returns the total debt of a specific user for a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @dev The total debt of the user is the sum of drawn debt and premium debt.
/// @param reserveId The identifier of the reserve.
/// @param user The address of the user.
/// @return The total debt amount.
function getUserTotalDebt(uint256 reserveId, address user) external view returns (uint256);
/// @notice Returns the full precision premium debt of a specific user for a given reserve.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @param reserveId The identifier of the reserve.
/// @param user The address of the user.
/// @return The amount of premium debt, expressed in asset units and scaled by RAY.
function getUserPremiumDebtRay(uint256 reserveId, address user) external view returns (uint256);
/// @notice Returns the user position struct in storage.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @param reserveId The identifier of the reserve.
/// @param user The address of the user.
/// @return The user position struct.
function getUserPosition(
uint256 reserveId,
address user
) external view returns (UserPosition memory);
/// @notice Returns the most up-to-date user account data information.
/// @dev Utilizes user's current dynamic configuration of user position.
/// @param user The address of the user.
/// @return The user account data struct.
function getUserAccountData(address user) external view returns (UserAccountData memory);
/// @notice Returns the risk premium from the user's last position update.
/// @param user The address of the user.
/// @return The risk premium of the user from the last position update, expressed in BPS.
function getUserLastRiskPremium(address user) external view returns (uint256);
/// @notice Returns the liquidation bonus for a given health factor, based on the user's current dynamic configuration.
/// @dev It reverts if the reserve associated with the given reserve identifier is not listed.
/// @param reserveId The identifier of the reserve.
/// @param user The address of the user.
/// @param healthFactor The health factor of the user, expressed in WAD.
/// @return The liquidation bonus for the user, expressed in BPS.
function getLiquidationBonus(
uint256 reserveId,
address user,
uint256 healthFactor
) external view returns (uint256);
/// @notice Returns whether positionManager is currently activated by governance.
/// @param positionManager The address of the position manager.
/// @return True if positionManager is currently active.
function isPositionManagerActive(address positionManager) external view returns (bool);
/// @notice Returns whether positionManager is active and approved by user.
/// @param user The address of the user.
/// @param positionManager The address of the position manager.
/// @return True if positionManager is active and approved by user.
function isPositionManager(address user, address positionManager) external view returns (bool);
/// @notice Returns the address of the external `LiquidationLogic` library.
function getLiquidationLogic() external pure returns (address);
/// @notice Returns the type hash for the SetUserPositionManagers intent.
/// @return The bytes-encoded EIP-712 struct hash representing the intent.
function SET_USER_POSITION_MANAGERS_TYPEHASH() external view returns (bytes32);
/// @notice Returns the address of the AaveOracle contract.
function ORACLE() external view returns (address);
/// @notice Returns the maximum allowed number of collateral and borrow reserves per user (each counted separately).
function MAX_USER_RESERVES_LIMIT() external view returns (uint16);
}
src/spoke/interfaces/ISpokeConfigurator.sol
// SPDX-License-Identifier: LicenseRef-BUSL
pragma solidity ^0.8.0;
import {ISpoke} from 'src/spoke/interfaces/ISpoke.sol';
/// @title ISpokeConfigurator
/// @author Aave Labs
/// @notice Interface for the SpokeConfigurator.
interface ISpokeConfigurator {
/// @notice Thrown when an address parameter is the zero address.
error InvalidAddress();
/// @notice Updates the price source of a reserve.
/// @dev The price source must implement IPriceFeed.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param priceSource The new price source.
function updateReservePriceSource(address spoke, uint256 reserveId, address priceSource) external;
/// @notice Updates the liquidation target health factor of a spoke.
/// @param spoke The address of the Spoke.
/// @param targetHealthFactor The new liquidation target health factor.
function updateLiquidationTargetHealthFactor(address spoke, uint256 targetHealthFactor) external;
/// @notice Updates the health factor for max liquidation bonus of a spoke.
/// @param spoke The address of the Spoke.
/// @param healthFactorForMaxBonus The new health factor for max liquidation bonus.
function updateHealthFactorForMaxBonus(address spoke, uint256 healthFactorForMaxBonus) external;
/// @notice Updates the liquidation bonus factor of a spoke.
/// @param spoke The address of the Spoke.
/// @param liquidationBonusFactor The new liquidation bonus factor.
function updateLiquidationBonusFactor(address spoke, uint256 liquidationBonusFactor) external;
/// @notice Updates the liquidation config of a spoke.
/// @param spoke The address of the Spoke.
/// @param liquidationConfig The new liquidation config.
function updateLiquidationConfig(
address spoke,
ISpoke.LiquidationConfig calldata liquidationConfig
) external;
/// @notice Adds a new reserve to a spoke.
/// @dev The asset corresponding to the reserve must be already listed on the Hub.
/// @dev The price source must implement IPriceFeed.
/// @param spoke The address of the Spoke.
/// @param hub The address of the Hub where the asset corresponding to the reserve is listed.
/// @param assetId The identifier of the asset.
/// @param priceSource The address of the price source.
/// @param config The configuration of the reserve.
/// @param dynamicConfig The dynamic configuration of the reserve.
/// @return reserveId The identifier of the reserve.
function addReserve(
address spoke,
address hub,
uint256 assetId,
address priceSource,
ISpoke.ReserveConfig calldata config,
ISpoke.DynamicReserveConfig calldata dynamicConfig
) external returns (uint256);
/// @notice Updates the paused flag of a reserve.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param paused The new paused flag.
function updatePaused(address spoke, uint256 reserveId, bool paused) external;
/// @notice Updates the frozen flag of a reserve.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param frozen The new frozen flag.
function updateFrozen(address spoke, uint256 reserveId, bool frozen) external;
/// @notice Updates the borrowable flag of a reserve.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param borrowable The new borrowable flag.
function updateBorrowable(address spoke, uint256 reserveId, bool borrowable) external;
/// @notice Updates whether receiving shares on liquidation is enabled.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param receiveSharesEnabled The new receiveSharesEnabled flag.
function updateReceiveSharesEnabled(
address spoke,
uint256 reserveId,
bool receiveSharesEnabled
) external;
/// @notice Updates the collateral risk of a reserve.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param collateralRisk The new collateral risk.
function updateCollateralRisk(address spoke, uint256 reserveId, uint256 collateralRisk) external;
/// @notice Adds a dynamic config to a reserve, identical to the latest one but with the specified collateral factor.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param collateralFactor The new collateral factor.
/// @return The dynamicConfigKey of the added dynamic configuration.
function addCollateralFactor(
address spoke,
uint256 reserveId,
uint16 collateralFactor
) external returns (uint32);
/// @notice Updates an existing collateral factor of a reserve at the specified key.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param dynamicConfigKey The key of the dynamic config to update.
/// @param collateralFactor The new collateral factor.
function updateCollateralFactor(
address spoke,
uint256 reserveId,
uint32 dynamicConfigKey,
uint16 collateralFactor
) external;
/// @notice Adds a dynamic config to a reserve, identical to the latest one but with the specified max liquidation bonus.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param maxLiquidationBonus The new max liquidation bonus.
/// @return The dynamicConfigKey of the added dynamic configuration.
function addMaxLiquidationBonus(
address spoke,
uint256 reserveId,
uint256 maxLiquidationBonus
) external returns (uint32);
/// @notice Updates an existing liquidation bonus of a reserve at the specified key.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param dynamicConfigKey The key of the dynamic config to update.
/// @param maxLiquidationBonus The new liquidation bonus.
function updateMaxLiquidationBonus(
address spoke,
uint256 reserveId,
uint32 dynamicConfigKey,
uint256 maxLiquidationBonus
) external;
/// @notice Adds a dynamic config to a reserve, identical to the latest one but with the specified liquidation fee.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param liquidationFee The new liquidation fee.
/// @return The dynamicConfigKey of the added dynamic configuration.
function addLiquidationFee(
address spoke,
uint256 reserveId,
uint256 liquidationFee
) external returns (uint32);
/// @notice Updates an existing liquidation fee of a reserve at the specified key.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param dynamicConfigKey The key of the dynamic config to update.
/// @param liquidationFee The new liquidation fee.
function updateLiquidationFee(
address spoke,
uint256 reserveId,
uint32 dynamicConfigKey,
uint256 liquidationFee
) external;
/// @notice Adds a dynamic config to a reserve.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param dynamicConfig The new dynamic config.
/// @return dynamicConfigKey The key of the added dynamic config.
function addDynamicReserveConfig(
address spoke,
uint256 reserveId,
ISpoke.DynamicReserveConfig calldata dynamicConfig
) external returns (uint32);
/// @notice Updates the dynamic config of a reserve at the specified key.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
/// @param dynamicConfigKey The key of the dynamic config to update.
/// @param dynamicConfig The new dynamic config.
function updateDynamicReserveConfig(
address spoke,
uint256 reserveId,
uint32 dynamicConfigKey,
ISpoke.DynamicReserveConfig calldata dynamicConfig
) external;
/// @notice Pauses all reserves of a spoke.
/// @param spoke The address of the Spoke.
function pauseAllReserves(address spoke) external;
/// @notice Freezes all reserves of a spoke.
/// @param spoke The address of the Spoke.
function freezeAllReserves(address spoke) external;
/// @notice Pauses a reserve of a spoke.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
function pauseReserve(address spoke, uint256 reserveId) external;
/// @notice Freezes a reserve of a spoke.
/// @param spoke The address of the Spoke.
/// @param reserveId The identifier of the reserve.
function freezeReserve(address spoke, uint256 reserveId) external;
/// @notice Updates the active flag of a spoke's position manager.
/// @param spoke The address of the Spoke.
/// @param positionManager The address of the position manager.
/// @param active The new active flag.
function updatePositionManager(address spoke, address positionManager, bool active) external;
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "none",
"useLiteralContent": false
},
"optimizer": {
"runs": 44444444,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"erc4626-tests/=lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.