Verified contractExact
NestNavValidation
Address0x00a4461cdfafaf1627c773d09b4cb1e1befcc18f
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.8.25
- Same code
1 more contract
Details
- Compiler
- solc 0.8.25+commit.b61c2a91
- Language
- solidity
- Optimization
- Yes, 1 runs
- EVM version
- cancun
- License
- Not stated
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,377,165
- Creation transaction
- 0x809d0b9af8…7d25c56d55
src/navvaults/NestNavValidation.sol
pragma solidity ^0.8.25;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { INestVault } from "src/interfaces/INestVault.sol";
import { NavTypes } from "./types/NavTypes.sol";
/// @dev Immutable, stateless read-only validation shared by Nest implementations.
/// Kept outside the vault runtime to respect EIP-170; never holds funds or delegates calls.
contract NestNavValidation {
error InvalidConfiguration();
error UnavailableValuation();
error PositionMismatch();
error AccountingLimit();
function validateInitialization(NavTypes.Init calldata init, INestVault nest)
external
view
returns (IERC20 assetToken, uint256 multiplier)
{
address base = nest.asset();
if (
init.underlying.code.length == 0 || base.code.length == 0 || base == init.underlying
|| init.underlying == address(nest) || init.admin == address(0)
|| init.pauser == address(0) || init.recoveryTreasury == address(0)
|| bytes(init.name).length == 0 || IERC20Metadata(init.underlying).decimals() > 27
) revert InvalidConfiguration();
uint8 assetDecimals = IERC20Metadata(base).decimals();
if (assetDecimals > 18) revert InvalidConfiguration();
return (IERC20(base), 10 ** uint256(18 - assetDecimals));
}
function grossAssets(INestVault nest, IERC20 underlying, address asset, uint256 managedShares)
external
view
returns (uint256 assets)
{
if (nest.asset() != asset || nest.share() != address(underlying)) {
revert UnavailableValuation();
}
if (
managedShares > NavTypes.MAX_ACCOUNTING
|| underlying.balanceOf(msg.sender) < managedShares
) {
revert PositionMismatch();
}
assets = managedShares == 0 ? 0 : nest.convertToAssets(managedShares);
if (assets > NavTypes.MAX_ACCOUNTING) revert AccountingLimit();
}
}
lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
src/interfaces/INestVault.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;
/// @notice Shared Predicate authorization payload used by the Nest deposit proxy.
interface INestVaultPredicateProxy {
struct PredicateMessage {
string taskId;
uint256 expireByTime;
address[] signerAddresses;
bytes[] signatures;
}
/// @notice Public deposit entrypoint authorized against the immediate caller.
function deposit(
address depositAsset,
uint256 depositAmount,
address recipient,
address vault,
PredicateMessage calldata predicateMessage
) external returns (uint256 shares);
/// @notice Public mint entrypoint authorized against the immediate caller.
function mint(
address depositAsset,
uint256 shares,
address recipient,
address vault,
PredicateMessage calldata predicateMessage
) external returns (uint256 assets);
}
/// @notice Asset-specific Nest ERC-7575/ERC-7540 vault interface.
interface INestVault {
function asset() external view returns (address);
function share() external view returns (address);
function convertToAssets(uint256 shares) external view returns (uint256 assets);
function previewDeposit(uint256 assets) external view returns (uint256 shares);
function previewMint(uint256 shares) external view returns (uint256 assets);
function previewFulfillRedeem(uint256 shares)
external
view
returns (uint256 postFeeAssets, uint256 feeAssets);
function requestRedeem(uint256 shares, address controller, address owner)
external
returns (uint256 requestId);
function pendingRedeemRequest(uint256 requestId, address controller)
external
view
returns (uint256 pendingShares);
function claimableRedeemRequest(uint256 requestId, address controller)
external
view
returns (uint256 claimableShares);
function maxWithdraw(address controller) external view returns (uint256 claimableAssets);
function redeem(uint256 shares, address receiver, address controller)
external
returns (uint256 assets);
function withdraw(uint256 assets, address receiver, address controller)
external
returns (uint256 shares);
}
src/navvaults/types/NavTypes.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.25;
/// @notice Shared units: assets and shares are raw token units; the R suffix denotes raw shares scaled by RAY (1e27).
library NavTypes {
uint16 internal constant MAX_MANAGEMENT_BPS = 5000;
uint16 internal constant MAX_PERFORMANCE_BPS = 5000;
uint256 internal constant RAY = 1e27;
uint256 internal constant MAX_ACCOUNTING = type(uint128).max;
enum Operation {
Deposit,
Mint,
Withdraw,
Redeem
}
enum LimitState {
Bounded,
Unbounded,
Unknown,
Disabled
}
enum Assessment {
Pass,
Reject,
SimulationRequired
}
enum ValuationStatus {
Valid,
Empty,
Unavailable
}
struct FeeConfig {
uint16 managementBps;
uint16 performanceBps;
address recipient;
}
struct Init {
address underlying;
address lens;
address admin;
address pauser;
address recoveryTreasury;
string name;
string symbol;
FeeConfig fees;
}
struct Capacity {
LimitState state;
uint256 executableAssets;
bytes32 reason;
bytes32 configHash;
}
struct Quote {
uint256 inputRaw;
uint256 outputRaw;
Capacity capacity;
Assessment assessment;
uint256 netNavRay;
uint64 evaluatedAt;
}
/// @dev Exactly four persistent slots. All narrowing follows MAX_ACCOUNTING checks.
struct Accounting {
uint128 underlyingSharesRaw;
uint128 activeNetAssetsRaw;
uint256 feeUnderlyingSharesR;
uint256 highWaterMarkRay;
uint128 currentSupplyRaw;
uint64 checkpointAt;
uint40 managementRemainder;
}
/// @notice Live read DTO, never persisted. Unavailable values are not execution quotes.
struct Snapshot {
uint256 netNavRay;
uint256 activeNetAssetsRaw;
uint256 activeGrossAssetsRaw;
uint256 currentSupplyRaw;
uint256 underlyingSharesRaw;
uint256 feeUnderlyingSharesR;
uint256 highWaterMarkRay;
uint64 evaluatedAt;
uint64 checkpointAt;
ValuationStatus valuationStatus;
}
/// @dev Compact result of live valuation. Observation metadata stays in the vault.
struct Valuation {
uint256 grossAssets;
uint256 netAssets;
uint256 netNavRay;
uint256 highWaterMark;
uint256 managementSharesR;
uint256 performanceSharesR;
uint256 remainder;
}
struct Accrual {
uint256 managementSharesR;
uint256 performanceSharesR;
uint256 remainder;
uint256 netAssets;
uint256 highWaterMark;
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 1,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.