Verified contractPartialMIT
VaultAccount
Address0xa5781eae41e40e3bdfb57ce110f598625dc89d6a
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.8.24
- Same code
3 more contracts
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- shanghai
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,167,052
- Creation transaction
- 0xd545bcf8e2…3d75e6557c
10 files
- project/src/VaultAccount.solmain4.77 KB
- npm/@openzeppelin/[email protected]/interfaces/IERC1363.sol4.45 KB
- npm/@openzeppelin/[email protected]/interfaces/IERC165.sol193 B
- npm/@openzeppelin/[email protected]/interfaces/IERC20.sol182 B
- npm/@openzeppelin/[email protected]/interfaces/IERC20Metadata.sol216 B
- npm/@openzeppelin/[email protected]/token/ERC20/IERC20.sol2.78 KB
- npm/@openzeppelin/[email protected]/token/ERC20/extensions/IERC20Metadata.sol684 B
- npm/@openzeppelin/[email protected]/token/ERC20/utils/SafeERC20.sol13.96 KB
- npm/@openzeppelin/[email protected]/utils/introspection/IERC165.sol871 B
- project/src/Errors.sol6.29 KB
project/src/VaultAccount.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Errors} from "src/Errors.sol";
/// @title VaultAccount
/// @notice The custody boundary. One per vault, an EIP-1167 minimal proxy holding
/// every asset of that vault: idle deposit tokens, Curve LP, the Convex
/// stake, and any claimed rewards.
/// @dev No `initialize()`: `manager` is `immutable`, so it lives in the
/// implementation's runtime bytecode and a clone reads it through
/// DELEGATECALL without an SLOAD. An uninitialised clone therefore cannot
/// exist, and the front-run-the-initializer hole is absent rather than
/// guarded. The cost is that the manager and the implementation are welded
/// together; `LockVaultManager` deploys this in its own constructor, which
/// is what breaks the circular dependency.
///
/// This contract holds the funds and its code never changes.
contract VaultAccount {
using SafeERC20 for IERC20;
/// @dev Gas a reward transfer may use in `tryTransferOut`; far above any
/// ERC-20 `transfer`, low enough that a token burning all of it cannot
/// starve the rest of a claim (audit r2, L-1).
uint256 internal constant REWARD_TRANSFER_GAS = 300_000;
/// @notice The only address permitted to act on this account.
address public immutable manager;
constructor(address manager_) {
if (manager_ == address(0)) revert Errors.ZeroAddress();
manager = manager_;
}
modifier onlyManager() {
if (msg.sender != manager) revert Errors.NotManager();
_;
}
/// @notice DELEGATECALLs a strategy adapter in this account's context, so
/// tokens never leave the vault, not even transiently.
/// @dev The adapter must be stateless: its storage writes would land in this
/// contract's slots, starting at slot 0.
function execute(address target, bytes calldata data)
external
onlyManager
returns (bytes memory)
{
if (target == address(0)) revert Errors.ZeroAddress();
// A delegatecall into an address without code "succeeds" and returns
// nothing; refused here rather than left to every caller's decoding.
if (target.code.length == 0) revert Errors.NotAContract();
(bool ok, bytes memory ret) = target.delegatecall(data);
if (!ok) {
// slippage messages, the ones a user actually needs.
assembly {
revert(add(ret, 0x20), mload(ret))
}
}
return ret;
}
/// @notice Moves ERC-20 out of the account, at the manager's direction.
/// @dev Not the only exit: an adapter run through `execute` acts as this
/// account too, which is why adapters are trusted code.
function transferOut(address token, address to, uint256 amount) external onlyManager {
if (to == address(0)) revert Errors.ZeroAddress();
IERC20(token).safeTransfer(to, amount);
}
/// @notice `transferOut` that reports failure instead of reverting, for
/// reward tokens: one paused, blocklisting or gas-burning token
/// must not take the rest of a claim down with it. What fails
/// stays here.
/// @dev SafeERC20.trySafeTransfer's success rule (no return data from a
/// contract, or a return of `true`), but with the gas capped and at
/// most one word of return data copied.
function tryTransferOut(address token, address to, uint256 amount)
external
onlyManager
returns (bool ok)
{
if (to == address(0)) revert Errors.ZeroAddress();
bytes memory data = abi.encodeCall(IERC20.transfer, (to, amount));
uint256 gasCap = REWARD_TRANSFER_GAS;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
ok := call(gasCap, token, 0, add(data, 0x20), mload(data), 0x00, 0x20)
returnSize := returndatasize()
returnValue := mload(0x00)
}
if (!ok) return false;
return returnSize == 0 ? token.code.length > 0 : returnValue == 1;
}
/// @notice Grants an external protocol an allowance over this account's tokens.
/// @dev Kept on the account rather than reachable from adapter code, so every
/// approval is traceable to a manager-authorised action.
function approveToken(address token, address spender, uint256 amount) external onlyManager {
if (spender == address(0)) revert Errors.ZeroAddress();
IERC20(token).forceApprove(spender, amount);
}
}
npm/@openzeppelin/[email protected]/interfaces/IERC1363.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
npm/@openzeppelin/[email protected]/interfaces/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";
npm/@openzeppelin/[email protected]/interfaces/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";
npm/@openzeppelin/[email protected]/interfaces/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20Metadata} from "../token/ERC20/extensions/IERC20Metadata.sol";
npm/@openzeppelin/[email protected]/token/ERC20/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);
}
npm/@openzeppelin/[email protected]/token/ERC20/extensions/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);
}
npm/@openzeppelin/[email protected]/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.7.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {IERC20Metadata} from "../../../interfaces/IERC20Metadata.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
if (!_safeTransfer(token, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
if (!_safeTransferFrom(token, from, to, value, true)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _safeTransfer(token, to, value, false);
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _safeTransferFrom(token, from, to, value, false);
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
if (!_safeApprove(token, spender, value, false)) {
if (!_safeApprove(token, spender, 0, true)) revert SafeERC20FailedOperation(address(token));
if (!_safeApprove(token, spender, value, true)) revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that relies on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that relies on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Oppositely, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/// @dev Attempts to fetch the token decimals. A return value of false indicates that the attempt failed in some way.
function tryGetDecimals(IERC20 token) internal view returns (bool success, uint8 decimals) {
bytes4 selector = IERC20Metadata.decimals.selector;
assembly ("memory-safe") {
mstore(0x00, selector)
success := staticcall(gas(), token, 0x00, 4, 0x00, 0x20)
success := and(and(success, gt(returndatasize(), 0x1f)), lt(mload(0x00), 0x100))
decimals := mul(success, mload(0x00))
}
}
/**
* @dev Imitates a Solidity `token.transfer(to, value)` call, relaxing the requirement on the return value: the
* return value is optional (but if data is returned, it must not be false).
*
* @param token The token targeted by the call.
* @param to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransfer(IERC20 token, address to, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.transfer.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(to, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
/**
* @dev Imitates a Solidity `token.transferFrom(from, to, value)` call, relaxing the requirement on the return
* value: the return value is optional (but if data is returned, it must not be false).
*
* @param token The token targeted by the call.
* @param from The sender of the tokens
* @param to The recipient of the tokens
* @param value The amount of token to transfer
* @param bubble Behavior switch if the transfer call reverts: bubble the revert reason or return a false boolean.
*/
function _safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value,
bool bubble
) private returns (bool success) {
bytes4 selector = IERC20.transferFrom.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(from, shr(96, not(0))))
mstore(0x24, and(to, shr(96, not(0))))
mstore(0x44, value)
success := call(gas(), token, 0, 0x00, 0x64, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
mstore(0x60, 0)
}
}
/**
* @dev Imitates a Solidity `token.approve(spender, value)` call, relaxing the requirement on the return value:
* the return value is optional (but if data is returned, it must not be false).
*
* @param token The token targeted by the call.
* @param spender The spender of the tokens
* @param value The amount of token to approve
* @param bubble Behavior switch if the approve call reverts: bubble the revert reason or return a false boolean.
*/
function _safeApprove(IERC20 token, address spender, uint256 value, bool bubble) private returns (bool success) {
bytes4 selector = IERC20.approve.selector;
assembly ("memory-safe") {
let fmp := mload(0x40)
mstore(0x00, selector)
mstore(0x04, and(spender, shr(96, not(0))))
mstore(0x24, value)
success := call(gas(), token, 0, 0x00, 0x44, 0x00, 0x20)
// if call success and return is true, all is good.
// otherwise (not success or return is not true), we need to perform further checks
if iszero(and(success, eq(mload(0x00), 1))) {
// if the call was a failure and bubble is enabled, bubble the error
if and(iszero(success), bubble) {
returndatacopy(fmp, 0x00, returndatasize())
revert(fmp, returndatasize())
}
// if the return value is not true, then the call is only successful if:
// - the token address has code
// - the returndata is empty
success := and(success, and(iszero(returndatasize()), gt(extcodesize(token), 0)))
}
mstore(0x40, fmp)
}
}
}
npm/@openzeppelin/[email protected]/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
project/src/Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @title Errors
/// @notice Every custom error in the system, in one place.
/// @dev Custom errors are 4-byte selectors instead of revert strings: cheaper to
/// deploy, cheaper to revert with, and testable by selector rather than by
/// matching a string.
library Errors {
// ---------------------------------------------------------------- locks
/// @notice A requested lock or extension is shorter than the applicable minimum.
error DurationTooShort();
/// @notice The resulting unlock timestamp would exceed now + MAX_LOCK_HORIZON.
error LockHorizonExceeded();
/// @notice The vault is still locked; withdrawal and reopen are not yet permitted.
error StillLocked();
/// @notice Less than MIN_INITIAL_LOCK remains, so a top-up would dilute the lock.
error TopUpWindowTooShort();
/// @notice `reopenVault` requires a drained vault; leftover idle would be
/// silently relocked with the new deposit.
error IdleNotEmpty();
// ---------------------------------------------------------------- input
/// @notice A zero amount was supplied where a non-zero amount is required.
error ZeroAmount();
/// @notice The zero address was supplied where a real address is required.
error ZeroAddress();
/// @notice A batch was empty or exceeded `maxBatch`.
error InvalidBatchSize();
/// @notice A proposed `maxBatch` was zero or above MAX_BATCH.
error InvalidMaxBatch();
/// @notice A caller-supplied array didn't match the length the call expected.
error LengthMismatch();
// --------------------------------------------------------------- access
/// @notice The caller does not own the vault it is acting on.
error NotVaultOwner();
/// @notice `renounceOwnership` was called on a contract that must always
/// have an owner able to govern it.
error RenounceDisabled();
/// @notice No vault has ever been created under that id.
/// @dev Needed once the vault struct stops carrying an `owner` field: the
/// owner check used to double as an existence check, because a missing
/// vault had `owner == address(0)` and no caller can be the zero
/// address. With one manager per owner that field is gone, so
/// existence has to be asserted on its own.
error UnknownVault();
/// @notice The caller is not the LockVaultManager.
error NotManager();
/// @notice A zap-flavoured call was made before setZapAdapter configured one.
error ZapNotConfigured();
// ------------------------------------------------------------ strategies
/// @notice The strategy id has never been registered.
error UnknownStrategy();
/// @notice New entries into this strategy are disabled by governance.
error DepositsDisabled();
/// @notice Governance has paused ENTRY into every strategy at once.
/// @dev Distinct from `DepositsDisabled`, and the distinction is the point:
/// one says "this strategy", the other says "all of them, right now".
/// During an incident the responder needs to know which of the two
/// stopped a call without having to read storage.
error ProtocolPaused();
/// @notice The strategy's deposit token does not match the vault's token.
error TokenMismatch();
/// @notice The vault does not hold enough idle balance for this action.
error InsufficientIdle();
/// @notice The measured output fell below the caller-supplied minimum.
error SlippageExceeded();
/// @notice The transaction sat in the mempool past the caller's deadline.
/// @dev Distinct from slippage. A `minLpOut` floor bounds how bad a price may
/// be; it says nothing about *when* the trade executes. A transaction
/// mined hours later can satisfy the floor and still be a trade the
/// caller no longer wants.
error DeadlineExpired();
/// @notice The config disagrees with Convex's own record for that pool id.
error PoolMismatch();
/// @notice The Convex pool has been shut down; new deposits are impossible.
error PoolShutdown();
/// @notice The upstream protocol (e.g. Stake DAO's ProtocolController) has
/// paused deposits.
/// @dev Distinct from `ProtocolPaused`, which is THIS system's registry
/// pause. It tells the responder whose switch stopped the call.
error UpstreamPaused();
/// @notice The coin index is outside the range this adapter supports.
error InvalidCoinIndex();
/// @notice The vault still holds a position in at least one strategy.
error StillAllocated();
/// @notice A swap was asked from a token into that same token.
error SameToken();
/// @notice The router took less (or more) of the input token than asked,
/// which would leave the difference outside the vault's accounting.
error PartialSwap();
/// @notice A sweep would have moved a strategy position (e.g. Stake DAO
/// RewardVault shares), which is principal, not surplus.
error SweepTouchesPosition();
/// @notice A sweep would have taken the vault's balance of its own token
/// below `idleAmount` -- through an alias address of that token.
error SweepTouchesPrincipal();
/// @notice The adapter spent more or less of the vault's token than asked.
error SpendMismatch();
/// @notice The address has no code where a contract is required.
error NotAContract();
/// @notice `syncPosition` was called on a strategy the vault holds no
/// open position in.
error PositionNotOpen();
/// @notice The adapter reported a different reward token list than the
/// caller simulated, so its slippage floors no longer line up.
error RewardTokensChanged();
/// @notice A claim would have taken the vault's balance of its own token
/// below its principal -- e.g. an alias of that token listed as a
/// reward and paid out on top of it.
error ClaimTouchesPrincipal();
/// @notice A recipient that would strand the funds: the manager itself,
/// the VaultAccount implementation, or one of the vaults.
error InvalidRecipient();
}
Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "shanghai",
"remappings": [
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:src/=project/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.