Skip to content
Verified contractExactBSD-3-Clause-Clear

NestRedeemBatcherConfidential

Address0xf47a6fe1319495e12f7958cbc3e8dfc812b2bdd6
Balance

0 ETH

 

Transactions

2

 

Compiler

solc 0.8.28

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.28+commit.7893614a
Language
solidity
Optimization
Yes, 800 runs
EVM version
cancun
License
BSD-3-Clause-Clear
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,407,061
Creation transaction
0x13fe1880f9…7756d0e308

49 files

The source code is large: one file is shown at a time. Choose a file in the list.

src/batcher/adapters/NestRedeemBatcherConfidential.sol

// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity 0.8.28;

import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC7984ERC20Wrapper} from "@openzeppelin/confidential-contracts/interfaces/IERC7984ERC20Wrapper.sol";
import {INestVault} from "../../../vendor/nest/INestVault.sol";
import {AsyncRedeemVaultBatcherConfidential} from "../AsyncRedeemVaultBatcherConfidential.sol";

/// @custom:security-contact [email protected]
/// @notice Collects whole Nest requests, or takes back the controller's pending shares after a delay while they still
/// cover the batch's.
/// @dev Nest sums every request naming the batcher as controller. Collection waits for claimable shares above the
/// baseline to cover the batch's; take-back returns every pending share, and those beyond the batch's stay with the
/// batcher for a later batch. A refused take-back emits `AsyncCancelFailed` and leaves the request outstanding.
/// Pre-existing claimable gifts cannot qualify a request.
contract NestRedeemBatcherConfidential is AsyncRedeemVaultBatcherConfidential {
    error InvalidRequestCancelDelay();

    uint256 private immutable _REQUEST_CANCEL_DELAY;
    uint256 private _cancelAt;
    uint256 private _claimableBefore;
    uint256 private _requested;

    constructor(
        IERC7984ERC20Wrapper fromToken_,
        IERC7984ERC20Wrapper toToken_,
        IERC4626 vault_,
        address owner_,
        uint256 minBatchAge_,
        uint256 callbackDeadline_,
        uint256 requestCancelDelay_
    ) AsyncRedeemVaultBatcherConfidential(fromToken_, toToken_, vault_, owner_, minBatchAge_, callbackDeadline_) {
        address share = _shareToken(vault_);
        address fromUnderlying = fromToken_.underlying();
        require(fromUnderlying == share, RouteShareMismatch(fromUnderlying, share));
        address asset = vault_.asset();
        address toUnderlying = toToken_.underlying();
        require(toUnderlying == asset, RouteAssetMismatch(toUnderlying, asset));
        require(requestCancelDelay_ != 0 && requestCancelDelay_ <= 30 days, InvalidRequestCancelDelay());
        _REQUEST_CANCEL_DELAY = requestCancelDelay_;
        _nest().totalPendingShares();
    }

    function requestCancelDelay() external view returns (uint256) {
        return _REQUEST_CANCEL_DELAY;
    }

    function routeDescription() public pure override returns (string memory) {
        return "Request a Nest redemption for the vault shares and claim it once Nest fulfills it.";
    }

    /// @dev The batcher's requested shares until they are collected or taken back.
    function _pendingShares() internal view override returns (uint256) {
        return _cancelAt == 0 ? 0 : _requested;
    }

    function _asyncRequest() internal view override returns (AsyncRequest memory) {
        return AsyncRequest(0, _pendingShares(), 0);
    }

    function _claim() internal override {
        if (_cancelAt == 0) return;
        uint256 claimable = _nest().claimableRedeemRequest(0, address(this));
        if (claimable >= _claimableBefore + _requested) {
            _nest().redeem(claimable, address(this), address(this));
        } else if (block.timestamp >= _cancelAt) {
            // Part of the batch's request was fulfilled; leave it to collection.
            if (_nest().pendingRedeemRequest(0, address(this)) < _requested) return;
            try _nest().updateRedeem(0, address(this), address(this)) {}
            catch (bytes memory reason) {
                emit AsyncCancelFailed(0, reason);
                return;
            }
        } else {
            return;
        }
        _cancelAt = 0;
    }

    function _placeRequest(uint256 batchId, uint256 shares) internal override returns (bool) {
        try _nest().claimableRedeemRequest(0, address(this)) returns (uint256 claimable) {
            _claimableBefore = claimable;
        } catch (bytes memory reason) {
            emit AsyncRequestFailed(batchId, reason);
            return false;
        }
        IERC20 token = IERC20(fromToken().underlying());
        SafeERC20.forceApprove(token, address(_vault()), shares);
        try _nest().requestRedeem(shares, address(this), address(this)) returns (uint256) {
            _cancelAt = block.timestamp + _REQUEST_CANCEL_DELAY;
            _requested = shares;
            emit AsyncRequested(batchId, 0, shares);
            return true;
        } catch (bytes memory reason) {
            SafeERC20.forceApprove(token, address(_vault()), 0);
            emit AsyncRequestFailed(batchId, reason);
            return false;
        }
    }

    function _nest() private view returns (INestVault) {
        return INestVault(address(_vault()));
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 800,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@fhevm/solidity/=dependencies/@fhevm-solidity-0.13.0/",
    "@openzeppelin/confidential-contracts/=dependencies/@openzeppelin-confidential-contracts-0.5.3/contracts/",
    "@openzeppelin/community-contracts/=dependencies/@openzeppelin-community-contracts-0.0.1/contracts/",
    "dependencies/@openzeppelin-community-contracts-0.0.1/:@openzeppelin/contracts/=dependencies/community-oz-contracts-5.7.0/",
    "@openzeppelin/contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/",
    "@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.1.0/",
    "encrypted-types/=dependencies/@encrypted-types-0.0.4/",
    "forge-fhevm/=dependencies/forge-fhevm-0.1.0/src/",
    "forge-std/=dependencies/forge-std-1.14.0/src/",
    "metamorpho/=dependencies/metamorpho-v1.1-1.1.0/src/",
    "morpho-blue/=dependencies/morpho-blue-1.0.0/",
    "vault-v2/=dependencies/vault-v2-2026.08.13/src/",
    "vendor/nest/:@solmate/=vendor/nest/lib/solmate/src/",
    "vendor/nest/:contracts/=vendor/nest/contracts/",
    "@axelar-network/axelar-gmp-sdk-solidity/=dependencies/@openzeppelin-community-contracts-0.0.1/lib/axelar-gmp-sdk-solidity/",
    "@encrypted-types-0.0.4/=dependencies/@encrypted-types-0.0.4/",
    "@fhevm-solidity-0.13.0/=dependencies/@fhevm-solidity-0.13.0/",
    "@fhevm/host-contracts/=dependencies/forge-fhevm-0.1.0/src/fhevm-host/",
    "@openzeppelin-community-contracts-0.0.1/=dependencies/@openzeppelin-community-contracts-0.0.1/contracts/",
    "@openzeppelin-confidential-contracts-0.5.3/=dependencies/@openzeppelin-confidential-contracts-0.5.3/contracts/",
    "@openzeppelin-contracts-5.1.0/=dependencies/@openzeppelin-contracts-5.1.0/",
    "@openzeppelin-contracts-upgradeable-5.1.0/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/",
    "@zk-email/contracts/=dependencies/@openzeppelin-community-contracts-0.0.1/lib/zk-email-verify/packages/contracts/",
    "@zk-email/email-tx-builder/=dependencies/@openzeppelin-community-contracts-0.0.1/lib/email-tx-builder/packages/contracts/",
    "community-oz-contracts-5.7.0/=dependencies/community-oz-contracts-5.7.0/",
    "forge-fhevm-0.1.0/=dependencies/forge-fhevm-0.1.0/src/",
    "forge-std-1.14.0/=dependencies/forge-std-1.14.0/src/",
    "metamorpho-v1.1-1.1.0/=dependencies/metamorpho-v1.1-1.1.0/src/",
    "morpho-blue-1.0.0/=dependencies/morpho-blue-1.0.0/src/",
    "vault-v2-2026.08.13/=dependencies/vault-v2-2026.08.13/src/",
    "wormhole-solidity-sdk/=dependencies/@openzeppelin-community-contracts-0.0.1/lib/wormhole-solidity-sdk/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.