Verified contractExactAGPL-3.0-only
BoringVaultSY
Address0x467d96e5908aaae602d992196fc2425337c2a311
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.30
- Same code
Only this contract
Details
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- osaka
- Via IR
- yes
- License
- AGPL-3.0-only
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,086,932
- Creation transaction
- 0x887748ab4d…85f6061383
85 files
The source code is large: one file is shown at a time. Choose a file in the list.
- contracts/pendle/BoringVaultSY.solmain10.84 KB
- contracts/NestShareOFT.sol20.5 KB
- contracts/accountant/NestAccountant.sol33.22 KB
- contracts/interfaces/IRateProvider.sol797 B
- contracts/interfaces/ITransferHook.sol419 B
- contracts/interfaces/vendor/Pendle/IAngleDistributor.sol280 B
- contracts/libraries/nest-vault/NestVaultAccountingLogic.sol4.72 KB
- contracts/types/Errors.sol5.72 KB
- contracts/upgradeable/auth/AuthUpgradeable.sol8.37 KB
- contracts/vendor/Pendle/MerklRewardAbstract__NoStorage.sol1.67 KB
- contracts/vendor/Pendle/SYBaseUpgV2.sol7.73 KB
- node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol2.59 KB
- node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroReceiver.sol519 B
- node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLib.sol805 B
- node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLibManager.sol2.76 KB
- node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingChannel.sol1.54 KB
- node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingComposer.sol1.03 KB
- node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingContext.sol239 B
- node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ISendLib.sol923 B
- node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol1.47 KB
- node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol3.67 KB
- node_modules/@layerzerolabs/oapp-evm-upgradeable/contracts/oapp/OAppCoreUpgradeable.sol4.23 KB
- node_modules/@layerzerolabs/oapp-evm-upgradeable/contracts/oapp/OAppReceiverUpgradeable.sol5.96 KB
- node_modules/@layerzerolabs/oapp-evm-upgradeable/contracts/oapp/OAppSenderUpgradeable.sol6.14 KB
- node_modules/@layerzerolabs/oapp-evm-upgradeable/contracts/oapp/OAppUpgradeable.sol2.21 KB
- node_modules/@layerzerolabs/oapp-evm-upgradeable/contracts/oapp/libs/OAppOptionsType3Upgradeable.sol5.29 KB
- node_modules/@layerzerolabs/oapp-evm-upgradeable/contracts/precrime/OAppPreCrimeSimulatorUpgradeable.sol6.64 KB
- node_modules/@layerzerolabs/oapp-evm/contracts/oapp/OAppCore.sol3.36 KB
- node_modules/@layerzerolabs/oapp-evm/contracts/oapp/OAppSender.sol5.63 KB
- node_modules/@layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppCore.sol1.86 KB
- node_modules/@layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppMsgInspector.sol909 B
- node_modules/@layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppOptionsType3.sol1.44 KB
- node_modules/@layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppReceiver.sol1.08 KB
- node_modules/@layerzerolabs/oapp-evm/contracts/precrime/interfaces/IOAppPreCrimeSimulator.sol1.92 KB
- node_modules/@layerzerolabs/oapp-evm/contracts/precrime/interfaces/IPreCrime.sol1.11 KB
- node_modules/@layerzerolabs/oapp-evm/contracts/precrime/libs/Packet.sol2.47 KB
- node_modules/@layerzerolabs/oft-evm-upgradeable/contracts/oft/OFTCoreUpgradeable.sol21.78 KB
- node_modules/@layerzerolabs/oft-evm-upgradeable/contracts/oft/OFTUpgradeable.sol3.97 KB
- node_modules/@layerzerolabs/oft-evm/contracts/interfaces/IOFT.sol6.28 KB
- node_modules/@layerzerolabs/oft-evm/contracts/libs/OFTComposeMsgCodec.sol2.99 KB
- node_modules/@layerzerolabs/oft-evm/contracts/libs/OFTMsgCodec.sol2.91 KB
- node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol4.03 KB
- node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol9.28 KB
- node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol12.13 KB
- node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol3.16 KB
- node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol1.19 KB
- node_modules/@openzeppelin/contracts-upgradeable/utils/NoncesUpgradeable.sol2.33 KB
- node_modules/@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol8.56 KB
- node_modules/@openzeppelin/contracts/access/Ownable.sol3.1 KB
- node_modules/@openzeppelin/contracts/interfaces/IERC1271.sol656 B
- node_modules/@openzeppelin/contracts/interfaces/IERC1363.sol4.45 KB
- node_modules/@openzeppelin/contracts/interfaces/IERC165.sol193 B
- node_modules/@openzeppelin/contracts/interfaces/IERC20.sol182 B
- node_modules/@openzeppelin/contracts/interfaces/IERC5267.sol740 B
- node_modules/@openzeppelin/contracts/interfaces/draft-IERC6093.sol6.54 KB
- node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol2.78 KB
- node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol684 B
- node_modules/@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol3.81 KB
- node_modules/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol10.08 KB
- node_modules/@openzeppelin/contracts/utils/Address.sol6 KB
- node_modules/@openzeppelin/contracts/utils/Context.sol963 B
- node_modules/@openzeppelin/contracts/utils/Errors.sol896 B
- node_modules/@openzeppelin/contracts/utils/Panic.sol1.97 KB
- node_modules/@openzeppelin/contracts/utils/Pausable.sol2.71 KB
- node_modules/@openzeppelin/contracts/utils/Strings.sol19.28 KB
- node_modules/@openzeppelin/contracts/utils/cryptography/ECDSA.sol7.82 KB
- node_modules/@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol4.25 KB
- node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol871 B
- node_modules/@openzeppelin/contracts/utils/math/Math.sol32.15 KB
- node_modules/@openzeppelin/contracts/utils/math/SafeCast.sol34.94 KB
- node_modules/@openzeppelin/contracts/utils/math/SignedMath.sol2.61 KB
- node_modules/@pendle/core-v2/contracts/core/erc20/PendleERC20Upg.sol11.28 KB
- node_modules/@pendle/core-v2/contracts/core/libraries/ArrayLib.sol4.45 KB
- node_modules/@pendle/core-v2/contracts/core/libraries/BoringOwnableUpgradeableV2.sol2.09 KB
- node_modules/@pendle/core-v2/contracts/core/libraries/Errors.sol7.64 KB
- node_modules/@pendle/core-v2/contracts/core/libraries/TokenHelper.sol2.96 KB
- node_modules/@pendle/core-v2/contracts/core/libraries/math/PMath.sol7.08 KB
- node_modules/@pendle/core-v2/contracts/interfaces/IStandardizedYield.sol6.57 KB
- node_modules/@pendle/core-v2/contracts/interfaces/IWETH.sol1.45 KB
- node_modules/forge-std/src/interfaces/IERC165.sol537 B
- node_modules/forge-std/src/interfaces/IERC7575.sol12.6 KB
- node_modules/solmate/src/auth/Auth.sol2.58 KB
- node_modules/solmate/src/tokens/ERC20.sol6.81 KB
- node_modules/solmate/src/utils/FixedPointMathLib.sol10.05 KB
- node_modules/solmate/src/utils/SafeTransferLib.sol5.77 KB
contracts/pendle/BoringVaultSY.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.30;
// libraries
import {PMath} from "@pendle/core-v2/contracts/core/libraries/math/PMath.sol";
import {ArrayLib} from "@pendle/core-v2/contracts/core/libraries/ArrayLib.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
// contracts
import {SYBaseUpgV2} from "contracts/vendor/Pendle/SYBaseUpgV2.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {MerklRewardAbstract__NoStorage} from "contracts/vendor/Pendle/MerklRewardAbstract__NoStorage.sol";
import {NestAccountant} from "contracts/accountant/NestAccountant.sol";
import {ERC20} from "@solmate/tokens/ERC20.sol";
// types
import {Errors} from "contracts/types/Errors.sol";
// interfaces
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
/// @title BoringVaultSY
/// @author PlumeNetwork
/// @notice A specialized vault that integrates with Pendle and rate providers via an external accountant.
/// @dev Inherits from Pendle SY base contracts, enabling yield-bearing asset management and Merkl reward distribution.
/// Reference : https://github.com/pendle-finance/Pendle-SY-Public/blob/21ccfee6c24936fb73c1ae78d1a87c83b05f105c/contracts/core/StandardizedYield/implementations/PendleERC4626NoRedeemNoDepositUpgSY.sol
contract BoringVaultSY is Initializable, SYBaseUpgV2, MerklRewardAbstract__NoStorage {
/// @notice The base asset associated with this vault (ERC20 token address)
/// @dev Immutable; set once at deployment
address public immutable asset;
/// @notice The minimum rate allowed for exchange calculation
/// @dev This constant represents the smallest allowed rate
uint256 public immutable MIN_RATE;
/// @notice The maximum rate allowed for certain calculations (e.g., fee rates)
/// @dev This constant prevents overflow by capping the rate at 1e30 in base units
uint256 public constant MAX_RATE = 1e30; // Example: prevent overflow
/// @dev Ensures consistent math when converting between shares and assets
uint256 internal immutable ONE_SHARE;
/*//////////////////////////////////////////////////////////////
ERC-7201 STORAGE
//////////////////////////////////////////////////////////////*/
/// @custom:storage-location erc7201:plumenetwork.storage.BoringVaultSY
struct BoringVaultSYStorage {
NestAccountant accountant;
}
// keccak256(abi.encode(uint256(keccak256("plumenetwork.storage.BoringVaultSY")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant BoringVaultSYStorageLocation =
0xba3cecd4d64affe75cd39a3d4a8081a70ba26075a4ef33e74e52794a68cdc400;
function _getBoringVaultSYStorage() private pure returns (BoringVaultSYStorage storage $) {
assembly {
$.slot := BoringVaultSYStorageLocation
}
}
/// @notice Constructs the PendleNestVault contract
/// @param _erc4626 The ERC4626-compatible yield token (SYBase) to wrap
/// @param _offchainRewardManager The address managing off-chain Merkl reward reporting
/// @param _asset The address of underlying asset
/// @param _minRate The minimum rate allowed for the vault, it should be less than the decimals of the underlying asset
constructor(address _erc4626, address _offchainRewardManager, address _asset, uint256 _minRate)
SYBaseUpgV2(_erc4626)
MerklRewardAbstract__NoStorage(_offchainRewardManager)
{
asset = _asset;
ONE_SHARE = 10 ** IERC20Metadata(_erc4626).decimals();
if (_minRate >= 10 ** IERC20Metadata(_asset).decimals()) {
revert Errors.InvalidRate();
}
MIN_RATE = _minRate;
}
/// @notice Initializes the PendleNestVault after deployment
/// @dev Should be called only once. Sets vault metadata and the rate accountant
/// @param _accountant The address of the Nest accountant
/// @param _name The vault token name
/// @param _symbol The vault token symbol
/// @param _owner The address with ownership privileges
function initialize(address _accountant, string memory _name, string memory _symbol, address _owner)
external
virtual
initializer
{
_setAccountant(_accountant);
__SYBaseUpgV2_init(_name, _symbol, _owner);
}
/// @notice Returns the version of the BoringVaultSY contract.
/// @dev This version is used to track contract upgrades.
/// @return string A string representing the version of the contract.
function version() public pure returns (string memory) {
return "2.0.0";
}
/// @dev Shared accountant validation and assignment logic.
/// Cross-checks the accountant returns a sane rate for `asset` rather than asserting share identity,
/// since the Nest accountants do not expose a vault getter.
function _setAccountant(address _accountant) internal {
if (_accountant == address(0)) {
revert Errors.ZeroAddress();
}
NestAccountant acc = NestAccountant(_accountant);
uint256 rate = acc.getRateInQuoteSafe(ERC20(asset));
if (rate == 0) revert Errors.InvalidRate();
if (rate < MIN_RATE || rate > MAX_RATE) revert Errors.RateOutOfBounds();
_getBoringVaultSYStorage().accountant = acc;
}
/// @dev Returns 1:1 shares for deposited amount since vault and token are equivalent.
/// @param amountDeposited The amount of token deposited.
/// @return amountSharesOut The amount of shares issued (equal to amountDeposited).
function _deposit(
address,
/*tokenIn*/
uint256 amountDeposited
)
internal
virtual
override
returns (
uint256 /*amountSharesOut*/
)
{
return amountDeposited;
}
/// @dev Transfers out the corresponding amount of yield tokens to the receiver.
/// @param receiver The address receiving redeemed tokens.
/// @param amountSharesToRedeem The amount of shares to redeem.
/// @return amountRedeemed The amount of underlying tokens redeemed (equal to shares).
function _redeem(
address receiver,
address,
/*tokenOut*/
uint256 amountSharesToRedeem
)
internal
virtual
override
returns (uint256)
{
_transferOut(yieldToken, receiver, amountSharesToRedeem);
return amountSharesToRedeem;
}
/// @notice Returns the current exchange rate between assets and shares
/// @dev Uses rate provided by the accountant and normalized by `ONE_SHARE`
/// @return The exchange rate as a fixed-point number
function exchangeRate() public view virtual override returns (uint256) {
return Math.mulDiv(PMath.ONE, _getValidatedRate(), ONE_SHARE, Math.Rounding.Floor);
}
/// @dev Returns 1:1 shares for deposit previews.
/// @param amountTokenToDeposit The amount of input tokens to deposit.
/// @return amountSharesOut The expected number of shares to be minted.
function _previewDeposit(
address,
/*tokenIn*/
uint256 amountTokenToDeposit
)
internal
view
virtual
override
returns (
uint256 /*amountSharesOut*/
)
{
return amountTokenToDeposit;
}
/// @dev Returns 1:1 token output for shares redeemed.
/// @param amountSharesToRedeem The number of shares to redeem.
/// @return amountTokenOut The expected token output amount.
function _previewRedeem(
address,
/*tokenOut*/
uint256 amountSharesToRedeem
)
internal
view
virtual
override
returns (
uint256 /*amountTokenOut*/
)
{
return amountSharesToRedeem;
}
/// @notice Returns the accountant that provides the exchange rate for this SY
function accountant() external view returns (NestAccountant) {
return _getBoringVaultSYStorage().accountant;
}
/// @notice Returns the list of valid input tokens for deposits.
/// @dev Always returns the yield token.
/// @return res Array containing only the yield token address.
function getTokensIn() public view virtual override returns (address[] memory res) {
return ArrayLib.create(yieldToken);
}
/// @notice Returns the list of valid output tokens for withdrawals
/// @dev Always returns the yield token
/// @return res Array containing only the yield token address
function getTokensOut() public view virtual override returns (address[] memory res) {
return ArrayLib.create(yieldToken);
}
/// @notice Checks if a token is valid for deposits
/// @param token The address of the token to check
/// @return True if the token matches the yield token, false otherwise
function isValidTokenIn(address token) public view virtual override returns (bool) {
return token == yieldToken;
}
/// @notice Checks if a token is valid for redemptions.
/// @param token The address of the token to check.
/// @return True if the token matches the yield token, false otherwise.
function isValidTokenOut(address token) public view virtual override returns (bool) {
return token == yieldToken;
}
/// @notice Returns information about the underlying asset.
/// @return assetType The type of asset (always TOKEN).
/// @return assetAddress The address of the underlying ERC20 asset.
/// @return assetDecimals The decimals of the underlying asset.
function assetInfo()
external
view
virtual
returns (AssetType assetType, address assetAddress, uint8 assetDecimals)
{
return (AssetType.TOKEN, asset, IERC20Metadata(asset).decimals());
}
/// @dev Internal helper to validate rate from external oracle
function _getValidatedRate() internal view returns (uint256 rate) {
rate = _getBoringVaultSYStorage().accountant.getRateInQuoteSafe(ERC20(asset));
// prevent division by zero
if (rate == 0) revert Errors.InvalidRate();
// prevent extreme values
if (rate < MIN_RATE || rate > MAX_RATE) {
revert Errors.RateOutOfBounds();
}
return rate;
}
/*//////////////////////////////////////////////////////////////
ADMIN FUNCTIONS
//////////////////////////////////////////////////////////////*/
/// @notice Updates the accountant
/// @dev Only authorized entity can update the accountant
/// @param _accountant The new accountant address
function setAccountant(address _accountant) external onlyOwner {
_setAccountant(_accountant);
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "osaka",
"remappings": [
"forge-std/=node_modules/forge-std/src/",
"@openzeppelin/=node_modules/@openzeppelin/",
"@openzeppelin-4.9.3/=script/vendor/openzeppelin-4.9.3/",
"@solmate/=node_modules/solmate/src/",
"@boring-vault/=node_modules/boring-vault/",
"src/=node_modules/boring-vault/src/",
"@predicate/=node_modules/@predicate/contracts/",
"@pendle/=node_modules/@pendle/",
"createx/=node_modules/createx/src/",
"solidity-bytes-utils/contracts/=node_modules/@layerzerolabs/toolbox-foundry/lib/solidity-bytes-utils/",
"@layerzerolabs/=node_modules/@layerzerolabs/",
"@uniswap/permit2/=node_modules/@uniswap/permit2/src/",
"@morpho/=node_modules/morpho/src/",
"boring-vault/=node_modules/boring-vault/",
"ds-test/=node_modules/@layerzerolabs/toolbox-foundry/lib/ds-test/",
"hardhat-deploy/=node_modules/hardhat-deploy/",
"hardhat/=node_modules/hardhat/",
"morpho/=node_modules/morpho/",
"solmate/=node_modules/solmate/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.