Sync workspace: config, docs, scripts, CI, operator rules, and submodule pointers.
- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains - Omit embedded publish git dirs and empty placeholders from index Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
pragma solidity >=0.8.13 <0.9.0;
|
||||
|
||||
import {IERC165} from "./IERC165.sol";
|
||||
|
||||
/// @title ERC-1155 Multi Token Standard
|
||||
/// @dev See https://eips.ethereum.org/EIPS/eip-1155
|
||||
/// Note: The ERC-165 identifier for this interface is 0xd9b67a26.
|
||||
interface IERC1155 is IERC165 {
|
||||
/// @dev
|
||||
/// - Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard).
|
||||
/// - The `_operator` argument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender).
|
||||
/// - The `_from` argument MUST be the address of the holder whose balance is decreased.
|
||||
/// - The `_to` argument MUST be the address of the recipient whose balance is increased.
|
||||
/// - The `_id` argument MUST be the token type being transferred.
|
||||
/// - The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by.
|
||||
/// - When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).
|
||||
/// - When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).
|
||||
event TransferSingle(
|
||||
address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value
|
||||
);
|
||||
|
||||
/// @dev
|
||||
/// - Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard).
|
||||
/// - The `_operator` argument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender).
|
||||
/// - The `_from` argument MUST be the address of the holder whose balance is decreased.
|
||||
/// - The `_to` argument MUST be the address of the recipient whose balance is increased.
|
||||
/// - The `_ids` argument MUST be the list of tokens being transferred.
|
||||
/// - The `_values` argument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by.
|
||||
/// - When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).
|
||||
/// - When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).
|
||||
event TransferBatch(
|
||||
address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values
|
||||
);
|
||||
|
||||
/// @dev MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absence of an event assumes disabled).
|
||||
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
|
||||
|
||||
/// @dev MUST emit when the URI is updated for a token ID. URIs are defined in RFC 3986.
|
||||
/// The URI MUST point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
|
||||
event URI(string _value, uint256 indexed _id);
|
||||
|
||||
/// @notice Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call).
|
||||
/// @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard).
|
||||
/// - MUST revert if `_to` is the zero address.
|
||||
/// - MUST revert if balance of holder for token `_id` is lower than the `_value` sent.
|
||||
/// - MUST revert on any other error.
|
||||
/// - MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard).
|
||||
/// - After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).
|
||||
/// @param _from Source address
|
||||
/// @param _to Target address
|
||||
/// @param _id ID of the token type
|
||||
/// @param _value Transfer amount
|
||||
/// @param _data Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to`
|
||||
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external;
|
||||
|
||||
/// @notice Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call).
|
||||
/// @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard).
|
||||
/// - MUST revert if `_to` is the zero address.
|
||||
/// - MUST revert if length of `_ids` is not the same as length of `_values`.
|
||||
/// - MUST revert if any of the balance(s) of the holder(s) for token(s) in `_ids` is lower than the respective amount(s) in `_values` sent to the recipient.
|
||||
/// - MUST revert on any other error.
|
||||
/// - MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard).
|
||||
/// - Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
|
||||
/// - After the above conditions for the transfer(s) in the batch are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call the relevant `ERC1155TokenReceiver` hook(s) on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).
|
||||
/// @param _from Source address
|
||||
/// @param _to Target address
|
||||
/// @param _ids IDs of each token type (order and length must match _values array)
|
||||
/// @param _values Transfer amounts per token type (order and length must match _ids array)
|
||||
/// @param _data Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to`
|
||||
function safeBatchTransferFrom(
|
||||
address _from,
|
||||
address _to,
|
||||
uint256[] calldata _ids,
|
||||
uint256[] calldata _values,
|
||||
bytes calldata _data
|
||||
) external;
|
||||
|
||||
/// @notice Get the balance of an account's tokens.
|
||||
/// @param _owner The address of the token holder
|
||||
/// @param _id ID of the token
|
||||
/// @return The _owner's balance of the token type requested
|
||||
function balanceOf(address _owner, uint256 _id) external view returns (uint256);
|
||||
|
||||
/// @notice Get the balance of multiple account/token pairs
|
||||
/// @param _owners The addresses of the token holders
|
||||
/// @param _ids ID of the tokens
|
||||
/// @return The _owner's balance of the token types requested (i.e. balance for each (owner, id) pair)
|
||||
function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids)
|
||||
external
|
||||
view
|
||||
returns (uint256[] memory);
|
||||
|
||||
/// @notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
|
||||
/// @dev MUST emit the ApprovalForAll event on success.
|
||||
/// @param _operator Address to add to the set of authorized operators
|
||||
/// @param _approved True if the operator is approved, false to revoke approval
|
||||
function setApprovalForAll(address _operator, bool _approved) external;
|
||||
|
||||
/// @notice Queries the approval status of an operator for a given owner.
|
||||
/// @param _owner The owner of the tokens
|
||||
/// @param _operator Address of authorized operator
|
||||
/// @return True if the operator is approved, false if not
|
||||
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
pragma solidity >=0.8.13 <0.9.0;
|
||||
|
||||
interface IERC165 {
|
||||
/// @notice Query if a contract implements an interface
|
||||
/// @param interfaceID The interface identifier, as specified in ERC-165
|
||||
/// @dev Interface identification is specified in ERC-165. This function
|
||||
/// uses less than 30,000 gas.
|
||||
/// @return `true` if the contract implements `interfaceID` and
|
||||
/// `interfaceID` is not 0xffffffff, `false` otherwise
|
||||
function supportsInterface(bytes4 interfaceID) external view returns (bool);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
pragma solidity >=0.8.13 <0.9.0;
|
||||
|
||||
/// @dev Interface of the ERC20 standard as defined in the EIP.
|
||||
/// @dev This includes the optional name, symbol, and decimals metadata.
|
||||
interface IERC20 {
|
||||
/// @dev Emitted when `value` tokens are moved from one account (`from`) to another (`to`).
|
||||
event Transfer(address indexed from, address indexed to, uint256 value);
|
||||
|
||||
/// @dev Emitted when the allowance of a `spender` for an `owner` is set, where `value`
|
||||
/// is the new allowance.
|
||||
event Approval(address indexed owner, address indexed spender, uint256 value);
|
||||
|
||||
/// @notice Returns the amount of tokens in existence.
|
||||
function totalSupply() external view returns (uint256);
|
||||
|
||||
/// @notice Returns the amount of tokens owned by `account`.
|
||||
function balanceOf(address account) external view returns (uint256);
|
||||
|
||||
/// @notice Moves `amount` tokens from the caller's account to `to`.
|
||||
function transfer(address to, uint256 amount) external returns (bool);
|
||||
|
||||
/// @notice Returns the remaining number of tokens that `spender` is allowed
|
||||
/// to spend on behalf of `owner`
|
||||
function allowance(address owner, address spender) external view returns (uint256);
|
||||
|
||||
/// @notice Sets `amount` as the allowance of `spender` over the caller's tokens.
|
||||
/// @dev Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
||||
function approve(address spender, uint256 amount) external returns (bool);
|
||||
|
||||
/// @notice Moves `amount` tokens from `from` to `to` using the allowance mechanism.
|
||||
/// `amount` is then deducted from the caller's allowance.
|
||||
function transferFrom(address from, address to, uint256 amount) external returns (bool);
|
||||
|
||||
/// @notice Returns the name of the token.
|
||||
function name() external view returns (string memory);
|
||||
|
||||
/// @notice Returns the symbol of the token.
|
||||
function symbol() external view returns (string memory);
|
||||
|
||||
/// @notice Returns the decimals places of the token.
|
||||
function decimals() external view returns (uint8);
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
pragma solidity >=0.8.13 <0.9.0;
|
||||
|
||||
import {IERC20} from "./IERC20.sol";
|
||||
|
||||
/// @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
|
||||
/// https://eips.ethereum.org/EIPS/eip-4626
|
||||
interface IERC4626 is IERC20 {
|
||||
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
|
||||
|
||||
event Withdraw(
|
||||
address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares
|
||||
);
|
||||
|
||||
/// @notice Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
|
||||
/// @dev
|
||||
/// - MUST be an ERC-20 token contract.
|
||||
/// - MUST NOT revert.
|
||||
function asset() external view returns (address assetTokenAddress);
|
||||
|
||||
/// @notice Returns the total amount of the underlying asset that is “managed” by Vault.
|
||||
/// @dev
|
||||
/// - SHOULD include any compounding that occurs from yield.
|
||||
/// - MUST be inclusive of any fees that are charged against assets in the Vault.
|
||||
/// - MUST NOT revert.
|
||||
function totalAssets() external view returns (uint256 totalManagedAssets);
|
||||
|
||||
/// @notice Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
|
||||
/// scenario where all the conditions are met.
|
||||
/// @dev
|
||||
/// - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
|
||||
/// - MUST NOT show any variations depending on the caller.
|
||||
/// - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
|
||||
/// - MUST NOT revert.
|
||||
///
|
||||
/// NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
|
||||
/// “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
|
||||
/// from.
|
||||
function convertToShares(uint256 assets) external view returns (uint256 shares);
|
||||
|
||||
/// @notice Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
|
||||
/// scenario where all the conditions are met.
|
||||
/// @dev
|
||||
/// - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
|
||||
/// - MUST NOT show any variations depending on the caller.
|
||||
/// - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
|
||||
/// - MUST NOT revert.
|
||||
///
|
||||
/// NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
|
||||
/// “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
|
||||
/// from.
|
||||
function convertToAssets(uint256 shares) external view returns (uint256 assets);
|
||||
|
||||
/// @notice Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
|
||||
/// through a deposit call.
|
||||
/// @dev
|
||||
/// - MUST return a limited value if receiver is subject to some deposit limit.
|
||||
/// - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
|
||||
/// - MUST NOT revert.
|
||||
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
|
||||
|
||||
/// @notice Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
|
||||
/// current on-chain conditions.
|
||||
/// @dev
|
||||
/// - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
|
||||
/// call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
|
||||
/// in the same transaction.
|
||||
/// - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
|
||||
/// deposit would be accepted, regardless if the user has enough tokens approved, etc.
|
||||
/// - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
|
||||
/// - MUST NOT revert.
|
||||
///
|
||||
/// NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
|
||||
/// share price or some other type of condition, meaning the depositor will lose assets by depositing.
|
||||
function previewDeposit(uint256 assets) external view returns (uint256 shares);
|
||||
|
||||
/// @notice Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
|
||||
/// @dev
|
||||
/// - MUST emit the Deposit event.
|
||||
/// - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
|
||||
/// deposit execution, and are accounted for during deposit.
|
||||
/// - MUST revert if all assets cannot be deposited (due to deposit limit being reached, slippage, the user not
|
||||
/// approving enough underlying tokens to the Vault contract, etc).
|
||||
///
|
||||
/// NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
|
||||
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
|
||||
|
||||
/// @notice Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
|
||||
/// @dev
|
||||
/// - MUST return a limited value if receiver is subject to some mint limit.
|
||||
/// - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
|
||||
/// - MUST NOT revert.
|
||||
function maxMint(address receiver) external view returns (uint256 maxShares);
|
||||
|
||||
/// @notice Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
|
||||
/// current on-chain conditions.
|
||||
/// @dev
|
||||
/// - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
|
||||
/// in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
|
||||
/// same transaction.
|
||||
/// - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
|
||||
/// would be accepted, regardless if the user has enough tokens approved, etc.
|
||||
/// - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
|
||||
/// - MUST NOT revert.
|
||||
///
|
||||
/// NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
|
||||
/// share price or some other type of condition, meaning the depositor will lose assets by minting.
|
||||
function previewMint(uint256 shares) external view returns (uint256 assets);
|
||||
|
||||
/// @notice Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
|
||||
/// @dev
|
||||
/// - MUST emit the Deposit event.
|
||||
/// - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
|
||||
/// execution, and are accounted for during mint.
|
||||
/// - MUST revert if all shares cannot be minted (due to deposit limit being reached, slippage, the user not
|
||||
/// approving enough underlying tokens to the Vault contract, etc).
|
||||
///
|
||||
/// NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
|
||||
function mint(uint256 shares, address receiver) external returns (uint256 assets);
|
||||
|
||||
/// @notice Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
|
||||
/// Vault, through a withdrawal call.
|
||||
/// @dev
|
||||
/// - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
|
||||
/// - MUST NOT revert.
|
||||
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
|
||||
|
||||
/// @notice Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
|
||||
/// given current on-chain conditions.
|
||||
/// @dev
|
||||
/// - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
|
||||
/// call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
|
||||
/// called
|
||||
/// in the same transaction.
|
||||
/// - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
|
||||
/// the withdrawal would be accepted, regardless if the user has enough shares, etc.
|
||||
/// - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
|
||||
/// - MUST NOT revert.
|
||||
///
|
||||
/// NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
|
||||
/// share price or some other type of condition, meaning the owner will lose assets by withdrawing.
|
||||
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
|
||||
|
||||
/// @notice Burns shares from owner and sends exactly assets of underlying tokens to receiver.
|
||||
/// @dev
|
||||
/// - MUST emit the Withdraw event.
|
||||
/// - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
|
||||
/// withdraw execution, and are accounted for during withdrawal.
|
||||
/// - MUST revert if all assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
|
||||
/// not having enough shares, etc).
|
||||
///
|
||||
/// Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
|
||||
/// Those methods should be performed separately.
|
||||
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
|
||||
|
||||
/// @notice Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
|
||||
/// through a redeem call.
|
||||
/// @dev
|
||||
/// - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
|
||||
/// - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
|
||||
/// - MUST NOT revert.
|
||||
function maxRedeem(address owner) external view returns (uint256 maxShares);
|
||||
|
||||
/// @notice Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block,
|
||||
/// given current on-chain conditions.
|
||||
/// @dev
|
||||
/// - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
|
||||
/// in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
|
||||
/// same transaction.
|
||||
/// - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
|
||||
/// redemption would be accepted, regardless if the user has enough shares, etc.
|
||||
/// - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
|
||||
/// - MUST NOT revert.
|
||||
///
|
||||
/// NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
|
||||
/// share price or some other type of condition, meaning the owner will lose assets by redeeming.
|
||||
function previewRedeem(uint256 shares) external view returns (uint256 assets);
|
||||
|
||||
/// @notice Burns exactly shares from owner and sends assets of underlying tokens to receiver.
|
||||
/// @dev
|
||||
/// - MUST emit the Withdraw event.
|
||||
/// - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
|
||||
/// redeem execution, and are accounted for during redeem.
|
||||
/// - MUST revert if all shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
|
||||
/// not having enough shares, etc).
|
||||
///
|
||||
/// NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
|
||||
/// Those methods should be performed separately.
|
||||
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
pragma solidity >=0.8.13 <0.9.0;
|
||||
|
||||
import {IERC165} from "./IERC165.sol";
|
||||
|
||||
/// @dev Required interface of an ERC-6909 compliant contract, as defined in
|
||||
/// https://eips.ethereum.org/EIPS/eip-6909
|
||||
interface IERC6909 is IERC165 {
|
||||
/// @dev Emitted when the allowance of a `spender` for an `owner` is set for a token of type `id`.
|
||||
event Approval(address indexed owner, address indexed spender, uint256 indexed id, uint256 amount);
|
||||
|
||||
/// @dev Emitted when `owner` grants or revokes operator status for a `spender`.
|
||||
event OperatorSet(address indexed owner, address indexed spender, bool approved);
|
||||
|
||||
/// @dev Emitted when `amount` tokens of type `id` are moved from `sender` to `receiver` initiated by `caller`.
|
||||
event Transfer(
|
||||
address caller, address indexed sender, address indexed receiver, uint256 indexed id, uint256 amount
|
||||
);
|
||||
|
||||
///@dev Returns the amount of tokens of type `id` owned by `owner`.
|
||||
function balanceOf(address owner, uint256 id) external view returns (uint256);
|
||||
|
||||
/// @dev Returns the amount of tokens of type `id` that `spender` is allowed to spend on behalf of `owner`.
|
||||
/// NOTE: Does not include operator allowances.
|
||||
function allowance(address owner, address spender, uint256 id) external view returns (uint256);
|
||||
|
||||
/// @dev Returns true if `spender` is set as an operator for `owner`.
|
||||
function isOperator(address owner, address spender) external view returns (bool);
|
||||
|
||||
/// @dev Sets an approval to `spender` for `amount` tokens of type `id` from the caller's tokens.
|
||||
/// Must return true.
|
||||
function approve(address spender, uint256 id, uint256 amount) external returns (bool);
|
||||
|
||||
/// @dev Grants or revokes unlimited transfer permission of any token id to `spender` for the caller's tokens.
|
||||
/// Must return true.
|
||||
function setOperator(address spender, bool approved) external returns (bool);
|
||||
|
||||
/// @dev Transfers `amount` of token type `id` from the caller's account to `receiver`.
|
||||
/// Must return true.
|
||||
function transfer(address receiver, uint256 id, uint256 amount) external returns (bool);
|
||||
|
||||
/// @dev Transfers `amount` of token type `id` from `sender` to `receiver`.
|
||||
/// Must return true.
|
||||
function transferFrom(address sender, address receiver, uint256 id, uint256 amount) external returns (bool);
|
||||
}
|
||||
|
||||
/// @dev Optional extension of {IERC6909} that adds metadata functions.
|
||||
interface IERC6909Metadata is IERC6909 {
|
||||
/// @dev Returns the name of the token of type `id`.
|
||||
function name(uint256 id) external view returns (string memory);
|
||||
|
||||
/// @dev Returns the ticker symbol of the token of type `id`.
|
||||
function symbol(uint256 id) external view returns (string memory);
|
||||
|
||||
/// @dev Returns the number of decimals for the token of type `id`.
|
||||
function decimals(uint256 id) external view returns (uint8);
|
||||
}
|
||||
|
||||
/// @dev Optional extension of {IERC6909} that adds content URI functions.
|
||||
interface IERC6909ContentURI is IERC6909 {
|
||||
/// @dev Returns URI for the contract.
|
||||
function contractURI() external view returns (string memory);
|
||||
|
||||
/// @dev Returns the URI for the token of type `id`.
|
||||
function tokenURI(uint256 id) external view returns (string memory);
|
||||
}
|
||||
|
||||
/// @dev Optional extension of {IERC6909} that adds a token supply function.
|
||||
interface IERC6909TokenSupply is IERC6909 {
|
||||
/// @dev Returns the total supply of the token of type `id`.
|
||||
function totalSupply(uint256 id) external view returns (uint256);
|
||||
}
|
||||
164
thirdweb-core-2103-test/lib/forge-std/src/interfaces/IERC721.sol
Normal file
164
thirdweb-core-2103-test/lib/forge-std/src/interfaces/IERC721.sol
Normal file
@@ -0,0 +1,164 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
pragma solidity >=0.8.13 <0.9.0;
|
||||
|
||||
import {IERC165} from "./IERC165.sol";
|
||||
|
||||
/// @title ERC-721 Non-Fungible Token Standard
|
||||
/// @dev See https://eips.ethereum.org/EIPS/eip-721
|
||||
/// Note: the ERC-165 identifier for this interface is 0x80ac58cd.
|
||||
interface IERC721 is IERC165 {
|
||||
/// @dev This emits when ownership of any NFT changes by any mechanism.
|
||||
/// This event emits when NFTs are created (`from` == 0) and destroyed
|
||||
/// (`to` == 0). Exception: during contract creation, any number of NFTs
|
||||
/// may be created and assigned without emitting Transfer. At the time of
|
||||
/// any transfer, the approved address for that NFT (if any) is reset to none.
|
||||
event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
|
||||
|
||||
/// @dev This emits when the approved address for an NFT is changed or
|
||||
/// reaffirmed. The zero address indicates there is no approved address.
|
||||
/// When a Transfer event emits, this also indicates that the approved
|
||||
/// address for that NFT (if any) is reset to none.
|
||||
event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
|
||||
|
||||
/// @dev This emits when an operator is enabled or disabled for an owner.
|
||||
/// The operator can manage all NFTs of the owner.
|
||||
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
|
||||
|
||||
/// @notice Count all NFTs assigned to an owner
|
||||
/// @dev NFTs assigned to the zero address are considered invalid, and this
|
||||
/// function throws for queries about the zero address.
|
||||
/// @param _owner An address for whom to query the balance
|
||||
/// @return The number of NFTs owned by `_owner`, possibly zero
|
||||
function balanceOf(address _owner) external view returns (uint256);
|
||||
|
||||
/// @notice Find the owner of an NFT
|
||||
/// @dev NFTs assigned to zero address are considered invalid, and queries
|
||||
/// about them do throw.
|
||||
/// @param _tokenId The identifier for an NFT
|
||||
/// @return The address of the owner of the NFT
|
||||
function ownerOf(uint256 _tokenId) external view returns (address);
|
||||
|
||||
/// @notice Transfers the ownership of an NFT from one address to another address
|
||||
/// @dev Throws unless `msg.sender` is the current owner, an authorized
|
||||
/// operator, or the approved address for this NFT. Throws if `_from` is
|
||||
/// not the current owner. Throws if `_to` is the zero address. Throws if
|
||||
/// `_tokenId` is not a valid NFT. When transfer is complete, this function
|
||||
/// checks if `_to` is a smart contract (code size > 0). If so, it calls
|
||||
/// `onERC721Received` on `_to` and throws if the return value is not
|
||||
/// `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
|
||||
/// @param _from The current owner of the NFT
|
||||
/// @param _to The new owner
|
||||
/// @param _tokenId The NFT to transfer
|
||||
/// @param data Additional data with no specified format, sent in call to `_to`
|
||||
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes calldata data) external payable;
|
||||
|
||||
/// @notice Transfers the ownership of an NFT from one address to another address
|
||||
/// @dev This works identically to the other function with an extra data parameter,
|
||||
/// except this function just sets data to "".
|
||||
/// @param _from The current owner of the NFT
|
||||
/// @param _to The new owner
|
||||
/// @param _tokenId The NFT to transfer
|
||||
function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
|
||||
|
||||
/// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
|
||||
/// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE
|
||||
/// THEY MAY BE PERMANENTLY LOST
|
||||
/// @dev Throws unless `msg.sender` is the current owner, an authorized
|
||||
/// operator, or the approved address for this NFT. Throws if `_from` is
|
||||
/// not the current owner. Throws if `_to` is the zero address. Throws if
|
||||
/// `_tokenId` is not a valid NFT.
|
||||
/// @param _from The current owner of the NFT
|
||||
/// @param _to The new owner
|
||||
/// @param _tokenId The NFT to transfer
|
||||
function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
|
||||
|
||||
/// @notice Change or reaffirm the approved address for an NFT
|
||||
/// @dev The zero address indicates there is no approved address.
|
||||
/// Throws unless `msg.sender` is the current NFT owner, or an authorized
|
||||
/// operator of the current owner.
|
||||
/// @param _approved The new approved NFT controller
|
||||
/// @param _tokenId The NFT to approve
|
||||
function approve(address _approved, uint256 _tokenId) external payable;
|
||||
|
||||
/// @notice Enable or disable approval for a third party ("operator") to manage
|
||||
/// all of `msg.sender`'s assets
|
||||
/// @dev Emits the ApprovalForAll event. The contract MUST allow
|
||||
/// multiple operators per owner.
|
||||
/// @param _operator Address to add to the set of authorized operators
|
||||
/// @param _approved True if the operator is approved, false to revoke approval
|
||||
function setApprovalForAll(address _operator, bool _approved) external;
|
||||
|
||||
/// @notice Get the approved address for a single NFT
|
||||
/// @dev Throws if `_tokenId` is not a valid NFT.
|
||||
/// @param _tokenId The NFT to find the approved address for
|
||||
/// @return The approved address for this NFT, or the zero address if there is none
|
||||
function getApproved(uint256 _tokenId) external view returns (address);
|
||||
|
||||
/// @notice Query if an address is an authorized operator for another address
|
||||
/// @param _owner The address that owns the NFTs
|
||||
/// @param _operator The address that acts on behalf of the owner
|
||||
/// @return True if `_operator` is an approved operator for `_owner`, false otherwise
|
||||
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
|
||||
}
|
||||
|
||||
/// @dev Note: the ERC-165 identifier for this interface is 0x150b7a02.
|
||||
interface IERC721TokenReceiver {
|
||||
/// @notice Handle the receipt of an NFT
|
||||
/// @dev The ERC721 smart contract calls this function on the recipient
|
||||
/// after a `transfer`. This function MAY throw to revert and reject the
|
||||
/// transfer. Return of other than the magic value MUST result in the
|
||||
/// transaction being reverted.
|
||||
/// Note: the contract address is always the message sender.
|
||||
/// @param _operator The address which called `safeTransferFrom` function
|
||||
/// @param _from The address which previously owned the token
|
||||
/// @param _tokenId The NFT identifier which is being transferred
|
||||
/// @param _data Additional data with no specified format
|
||||
/// @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
|
||||
/// unless throwing
|
||||
function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes calldata _data)
|
||||
external
|
||||
returns (bytes4);
|
||||
}
|
||||
|
||||
/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
|
||||
/// @dev See https://eips.ethereum.org/EIPS/eip-721
|
||||
/// Note: the ERC-165 identifier for this interface is 0x5b5e139f.
|
||||
interface IERC721Metadata is IERC721 {
|
||||
/// @notice A descriptive name for a collection of NFTs in this contract
|
||||
function name() external view returns (string memory _name);
|
||||
|
||||
/// @notice An abbreviated name for NFTs in this contract
|
||||
function symbol() external view returns (string memory _symbol);
|
||||
|
||||
/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
|
||||
/// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC
|
||||
/// 3986. The URI may point to a JSON file that conforms to the "ERC721
|
||||
/// Metadata JSON Schema".
|
||||
function tokenURI(uint256 _tokenId) external view returns (string memory);
|
||||
}
|
||||
|
||||
/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
|
||||
/// @dev See https://eips.ethereum.org/EIPS/eip-721
|
||||
/// Note: the ERC-165 identifier for this interface is 0x780e9d63.
|
||||
interface IERC721Enumerable is IERC721 {
|
||||
/// @notice Count NFTs tracked by this contract
|
||||
/// @return A count of valid NFTs tracked by this contract, where each one of
|
||||
/// them has an assigned and queryable owner not equal to the zero address
|
||||
function totalSupply() external view returns (uint256);
|
||||
|
||||
/// @notice Enumerate valid NFTs
|
||||
/// @dev Throws if `_index` >= `totalSupply()`.
|
||||
/// @param _index A counter less than `totalSupply()`
|
||||
/// @return The token identifier for the `_index`th NFT,
|
||||
/// (sort order not specified)
|
||||
function tokenByIndex(uint256 _index) external view returns (uint256);
|
||||
|
||||
/// @notice Enumerate NFTs assigned to an owner
|
||||
/// @dev Throws if `_index` >= `balanceOf(_owner)` or if
|
||||
/// `_owner` is the zero address, representing invalid NFTs.
|
||||
/// @param _owner An address where we are interested in NFTs owned by them
|
||||
/// @param _index A counter less than `balanceOf(_owner)`
|
||||
/// @return The token identifier for the `_index`th NFT assigned to `_owner`,
|
||||
/// (sort order not specified)
|
||||
function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256);
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
pragma solidity >=0.8.13 <0.9.0;
|
||||
|
||||
import {IERC7575} from "./IERC7575.sol";
|
||||
|
||||
/// @dev Interface of the base operator logic of ERC7540, as defined in
|
||||
/// https://eips.ethereum.org/EIPS/eip-7540
|
||||
interface IERC7540Operator {
|
||||
/**
|
||||
* @dev The event emitted when an operator is set.
|
||||
*
|
||||
* @param controller The address of the controller.
|
||||
* @param operator The address of the operator.
|
||||
* @param approved The approval status.
|
||||
*/
|
||||
event OperatorSet(address indexed controller, address indexed operator, bool approved);
|
||||
|
||||
/**
|
||||
* @dev Sets or removes an operator for the caller.
|
||||
*
|
||||
* @param operator The address of the operator.
|
||||
* @param approved The approval status.
|
||||
* @return Whether the call was executed successfully or not
|
||||
*/
|
||||
function setOperator(address operator, bool approved) external returns (bool);
|
||||
|
||||
/**
|
||||
* @dev Returns `true` if the `operator` is approved as an operator for an `controller`.
|
||||
*
|
||||
* @param controller The address of the controller.
|
||||
* @param operator The address of the operator.
|
||||
* @return status The approval status
|
||||
*/
|
||||
function isOperator(address controller, address operator) external view returns (bool status);
|
||||
}
|
||||
|
||||
/// @dev Interface of the asynchronous deposit Vault interface of ERC7540, as defined in
|
||||
/// https://eips.ethereum.org/EIPS/eip-7540
|
||||
interface IERC7540Deposit is IERC7540Operator {
|
||||
event DepositRequest(
|
||||
address indexed controller, address indexed owner, uint256 indexed requestId, address sender, uint256 assets
|
||||
);
|
||||
/**
|
||||
* @dev Transfers assets from sender into the Vault and submits a Request for asynchronous deposit.
|
||||
*
|
||||
* - MUST support ERC-20 approve / transferFrom on asset as a deposit Request flow.
|
||||
* - MUST revert if all assets cannot be requested for deposit.
|
||||
* - owner MUST be msg.sender unless some unspecified explicit approval is given by the caller,
|
||||
* approval of ERC-20 tokens from owner to sender is NOT enough.
|
||||
*
|
||||
* @param assets the amount of deposit assets to transfer from owner
|
||||
* @param controller the controller of the request who will be able to operate the request
|
||||
* @param owner the source of the deposit assets
|
||||
*
|
||||
* NOTE: most implementations will require pre-approval of the Vault with the Vault's underlying asset token.
|
||||
*/
|
||||
|
||||
function requestDeposit(uint256 assets, address controller, address owner) external returns (uint256 requestId);
|
||||
|
||||
/**
|
||||
* @dev Returns the amount of requested assets in Pending state.
|
||||
*
|
||||
* - MUST NOT include any assets in Claimable state for deposit or mint.
|
||||
* - MUST NOT show any variations depending on the caller.
|
||||
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
|
||||
*/
|
||||
function pendingDepositRequest(uint256 requestId, address controller) external view returns (uint256 pendingAssets);
|
||||
|
||||
/**
|
||||
* @dev Returns the amount of requested assets in Claimable state for the controller to deposit or mint.
|
||||
*
|
||||
* - MUST NOT include any assets in Pending state.
|
||||
* - MUST NOT show any variations depending on the caller.
|
||||
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
|
||||
*/
|
||||
function claimableDepositRequest(uint256 requestId, address controller)
|
||||
external
|
||||
view
|
||||
returns (uint256 claimableAssets);
|
||||
|
||||
/**
|
||||
* @dev Mints shares Vault shares to receiver by claiming the Request of the controller.
|
||||
*
|
||||
* - MUST emit the Deposit event.
|
||||
* - controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator.
|
||||
*/
|
||||
function deposit(uint256 assets, address receiver, address controller) external returns (uint256 shares);
|
||||
|
||||
/**
|
||||
* @dev Mints exactly shares Vault shares to receiver by claiming the Request of the controller.
|
||||
*
|
||||
* - MUST emit the Deposit event.
|
||||
* - controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator.
|
||||
*/
|
||||
function mint(uint256 shares, address receiver, address controller) external returns (uint256 assets);
|
||||
}
|
||||
|
||||
/// @dev Interface of the asynchronous redeem Vault interface of ERC7540, as defined in
|
||||
/// https://eips.ethereum.org/EIPS/eip-7540
|
||||
interface IERC7540Redeem is IERC7540Operator {
|
||||
event RedeemRequest(
|
||||
address indexed controller, address indexed owner, uint256 indexed requestId, address sender, uint256 shares
|
||||
);
|
||||
|
||||
/**
|
||||
* @dev Assumes control of shares from owner and submits a Request for asynchronous redeem.
|
||||
*
|
||||
* - MUST support a redeem Request flow where the control of shares is taken from owner directly.
|
||||
* - Redeem Request approval of shares for a msg.sender not equal to owner MAY come either from ERC-20 approval
|
||||
* over the shares of owner or if the owner has approved the msg.sender as an operator.
|
||||
* - MUST revert if all shares cannot be requested for redeem or withdraw.
|
||||
*
|
||||
* @param shares the amount of shares to be redeemed to transfer from owner
|
||||
* @param controller the controller of the request who will be able to operate the request
|
||||
* @param owner the source of the shares to be redeemed
|
||||
*
|
||||
* NOTE: most implementations will require pre-approval of the Vault with the Vault's share token.
|
||||
*/
|
||||
function requestRedeem(uint256 shares, address controller, address owner) external returns (uint256 requestId);
|
||||
|
||||
/**
|
||||
* @dev Returns the amount of requested shares in Pending state.
|
||||
*
|
||||
* - MUST NOT include any shares in Claimable state for redeem or withdraw.
|
||||
* - MUST NOT show any variations depending on the caller.
|
||||
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
|
||||
*/
|
||||
function pendingRedeemRequest(uint256 requestId, address controller) external view returns (uint256 pendingShares);
|
||||
|
||||
/**
|
||||
* @dev Returns the amount of requested shares in Claimable state for the controller to redeem or withdraw.
|
||||
*
|
||||
* - MUST NOT include any shares in Pending state for redeem or withdraw.
|
||||
* - MUST NOT show any variations depending on the caller.
|
||||
* - MUST NOT revert unless due to integer overflow caused by an unreasonably large input.
|
||||
*/
|
||||
function claimableRedeemRequest(uint256 requestId, address controller)
|
||||
external
|
||||
view
|
||||
returns (uint256 claimableShares);
|
||||
}
|
||||
|
||||
/// @dev Interface of the fully asynchronous Vault interface of ERC7540, as defined in
|
||||
/// https://eips.ethereum.org/EIPS/eip-7540
|
||||
interface IERC7540 is IERC7540Deposit, IERC7540Redeem, IERC7575 {}
|
||||
@@ -0,0 +1,241 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
pragma solidity >=0.8.13 <0.9.0;
|
||||
|
||||
import {IERC165} from "./IERC165.sol";
|
||||
|
||||
/// @dev Interface of the ERC7575 "Multi-Asset ERC-4626 Vaults", as defined in
|
||||
/// https://eips.ethereum.org/EIPS/eip-7575
|
||||
interface IERC7575 is IERC165 {
|
||||
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
|
||||
event Withdraw(
|
||||
address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares
|
||||
);
|
||||
|
||||
/**
|
||||
* @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
|
||||
*
|
||||
* - MUST be an ERC-20 token contract.
|
||||
* - MUST NOT revert.
|
||||
*/
|
||||
function asset() external view returns (address assetTokenAddress);
|
||||
|
||||
/**
|
||||
* @dev Returns the address of the share token
|
||||
*
|
||||
* - MUST be an ERC-20 token contract.
|
||||
* - MUST NOT revert.
|
||||
*/
|
||||
function share() external view returns (address shareTokenAddress);
|
||||
|
||||
/**
|
||||
* @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
|
||||
* scenario where all the conditions are met.
|
||||
*
|
||||
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
|
||||
* - MUST NOT show any variations depending on the caller.
|
||||
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
|
||||
* - MUST NOT revert.
|
||||
*
|
||||
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
|
||||
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
|
||||
* from.
|
||||
*/
|
||||
function convertToShares(uint256 assets) external view returns (uint256 shares);
|
||||
|
||||
/**
|
||||
* @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
|
||||
* scenario where all the conditions are met.
|
||||
*
|
||||
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
|
||||
* - MUST NOT show any variations depending on the caller.
|
||||
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
|
||||
* - MUST NOT revert.
|
||||
*
|
||||
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
|
||||
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
|
||||
* from.
|
||||
*/
|
||||
function convertToAssets(uint256 shares) external view returns (uint256 assets);
|
||||
|
||||
/**
|
||||
* @dev Returns the total amount of the underlying asset that is “managed” by Vault.
|
||||
*
|
||||
* - SHOULD include any compounding that occurs from yield.
|
||||
* - MUST be inclusive of any fees that are charged against assets in the Vault.
|
||||
* - MUST NOT revert.
|
||||
*/
|
||||
function totalAssets() external view returns (uint256 totalManagedAssets);
|
||||
|
||||
/**
|
||||
* @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
|
||||
* through a deposit call.
|
||||
*
|
||||
* - MUST return a limited value if receiver is subject to some deposit limit.
|
||||
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
|
||||
* - MUST NOT revert.
|
||||
*/
|
||||
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
|
||||
|
||||
/**
|
||||
* @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
|
||||
* current on-chain conditions.
|
||||
*
|
||||
* - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
|
||||
* call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
|
||||
* in the same transaction.
|
||||
* - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
|
||||
* deposit would be accepted, regardless if the user has enough tokens approved, etc.
|
||||
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
|
||||
* - MUST NOT revert.
|
||||
*
|
||||
* NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
|
||||
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
|
||||
*/
|
||||
function previewDeposit(uint256 assets) external view returns (uint256 shares);
|
||||
|
||||
/**
|
||||
* @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
|
||||
*
|
||||
* - MUST emit the Deposit event.
|
||||
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
|
||||
* deposit execution, and are accounted for during deposit.
|
||||
* - MUST revert if all assets cannot be deposited (due to deposit limit being reached, slippage, the user not
|
||||
* approving enough underlying tokens to the Vault contract, etc).
|
||||
*
|
||||
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
|
||||
*/
|
||||
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
|
||||
|
||||
/**
|
||||
* @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
|
||||
* - MUST return a limited value if receiver is subject to some mint limit.
|
||||
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
|
||||
* - MUST NOT revert.
|
||||
*/
|
||||
function maxMint(address receiver) external view returns (uint256 maxShares);
|
||||
|
||||
/**
|
||||
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
|
||||
* current on-chain conditions.
|
||||
*
|
||||
* - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
|
||||
* in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
|
||||
* same transaction.
|
||||
* - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
|
||||
* would be accepted, regardless if the user has enough tokens approved, etc.
|
||||
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
|
||||
* - MUST NOT revert.
|
||||
*
|
||||
* NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
|
||||
* share price or some other type of condition, meaning the depositor will lose assets by minting.
|
||||
*/
|
||||
function previewMint(uint256 shares) external view returns (uint256 assets);
|
||||
|
||||
/**
|
||||
* @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
|
||||
*
|
||||
* - MUST emit the Deposit event.
|
||||
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
|
||||
* execution, and are accounted for during mint.
|
||||
* - MUST revert if all shares cannot be minted (due to deposit limit being reached, slippage, the user not
|
||||
* approving enough underlying tokens to the Vault contract, etc).
|
||||
*
|
||||
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
|
||||
*/
|
||||
function mint(uint256 shares, address receiver) external returns (uint256 assets);
|
||||
|
||||
/**
|
||||
* @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
|
||||
* Vault, through a withdraw call.
|
||||
*
|
||||
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
|
||||
* - MUST NOT revert.
|
||||
*/
|
||||
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
|
||||
|
||||
/**
|
||||
* @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
|
||||
* given current on-chain conditions.
|
||||
*
|
||||
* - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
|
||||
* call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
|
||||
* called
|
||||
* in the same transaction.
|
||||
* - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
|
||||
* the withdrawal would be accepted, regardless if the user has enough shares, etc.
|
||||
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
|
||||
* - MUST NOT revert.
|
||||
*
|
||||
* NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
|
||||
* share price or some other type of condition, meaning the owner will lose assets by withdrawing.
|
||||
*/
|
||||
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
|
||||
|
||||
/**
|
||||
* @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
|
||||
*
|
||||
* - MUST emit the Withdraw event.
|
||||
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
|
||||
* withdraw execution, and are accounted for during withdraw.
|
||||
* - MUST revert if all assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
|
||||
* not having enough shares, etc).
|
||||
*
|
||||
* Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
|
||||
* Those methods should be performed separately.
|
||||
*/
|
||||
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
|
||||
|
||||
/**
|
||||
* @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
|
||||
* through a redeem call.
|
||||
*
|
||||
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
|
||||
* - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
|
||||
* - MUST NOT revert.
|
||||
*/
|
||||
function maxRedeem(address owner) external view returns (uint256 maxShares);
|
||||
|
||||
/**
|
||||
* @dev Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block,
|
||||
* given current on-chain conditions.
|
||||
*
|
||||
* - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
|
||||
* in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
|
||||
* same transaction.
|
||||
* - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
|
||||
* redemption would be accepted, regardless if the user has enough shares, etc.
|
||||
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
|
||||
* - MUST NOT revert.
|
||||
*
|
||||
* NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
|
||||
* share price or some other type of condition, meaning the owner will lose assets by redeeming.
|
||||
*/
|
||||
function previewRedeem(uint256 shares) external view returns (uint256 assets);
|
||||
|
||||
/**
|
||||
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
|
||||
*
|
||||
* - MUST emit the Withdraw event.
|
||||
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
|
||||
* redeem execution, and are accounted for during redeem.
|
||||
* - MUST revert if all shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
|
||||
* not having enough shares, etc).
|
||||
*
|
||||
* NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
|
||||
* Those methods should be performed separately.
|
||||
*/
|
||||
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
|
||||
}
|
||||
|
||||
/// @dev Interface of the ERC20 share token, as defined in
|
||||
/// https://eips.ethereum.org/EIPS/eip-7575
|
||||
interface IERC7575Share is IERC165 {
|
||||
event VaultUpdate(address indexed asset, address vault);
|
||||
|
||||
/**
|
||||
* @dev Returns the address of the Vault for the given asset.
|
||||
*
|
||||
* @param asset the ERC-20 token to deposit with into the Vault
|
||||
*/
|
||||
function vault(address asset) external view returns (address);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
pragma solidity >=0.8.13 <0.9.0;
|
||||
|
||||
interface IMulticall3 {
|
||||
struct Call {
|
||||
address target;
|
||||
bytes callData;
|
||||
}
|
||||
|
||||
struct Call3 {
|
||||
address target;
|
||||
bool allowFailure;
|
||||
bytes callData;
|
||||
}
|
||||
|
||||
struct Call3Value {
|
||||
address target;
|
||||
bool allowFailure;
|
||||
uint256 value;
|
||||
bytes callData;
|
||||
}
|
||||
|
||||
struct Result {
|
||||
bool success;
|
||||
bytes returnData;
|
||||
}
|
||||
|
||||
function aggregate(Call[] calldata calls) external payable returns (uint256 blockNumber, bytes[] memory returnData);
|
||||
|
||||
function aggregate3(Call3[] calldata calls) external payable returns (Result[] memory returnData);
|
||||
|
||||
function aggregate3Value(Call3Value[] calldata calls) external payable returns (Result[] memory returnData);
|
||||
|
||||
function blockAndAggregate(Call[] calldata calls)
|
||||
external
|
||||
payable
|
||||
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);
|
||||
|
||||
function getBasefee() external view returns (uint256 basefee);
|
||||
|
||||
function getBlockHash(uint256 blockNumber) external view returns (bytes32 blockHash);
|
||||
|
||||
function getBlockNumber() external view returns (uint256 blockNumber);
|
||||
|
||||
function getChainId() external view returns (uint256 chainid);
|
||||
|
||||
function getCurrentBlockCoinbase() external view returns (address coinbase);
|
||||
|
||||
function getCurrentBlockDifficulty() external view returns (uint256 difficulty);
|
||||
|
||||
function getCurrentBlockGasLimit() external view returns (uint256 gaslimit);
|
||||
|
||||
function getCurrentBlockTimestamp() external view returns (uint256 timestamp);
|
||||
|
||||
function getEthBalance(address addr) external view returns (uint256 balance);
|
||||
|
||||
function getLastBlockHash() external view returns (bytes32 blockHash);
|
||||
|
||||
function tryAggregate(bool requireSuccess, Call[] calldata calls)
|
||||
external
|
||||
payable
|
||||
returns (Result[] memory returnData);
|
||||
|
||||
function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls)
|
||||
external
|
||||
payable
|
||||
returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData);
|
||||
}
|
||||
Reference in New Issue
Block a user