Skip to content
Verified contractPartialBUSL-1.1

PlasmaVaultBase

Address0x80f451017066494de93943c36ce453fb98ae0b29
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.30

 

Same code

2 more contracts

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
License
BUSL-1.1
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,255,248
Creation transaction
0xd6f9fd4c91…cfcc4bd924
Main copy (most transactions)
0x233074f6…a1a18c7b

79 files

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

lib/ipor-fusion/contracts/managers/access/RedemptionDelayLib.sol

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.30;

import {PlasmaVault} from "../../vaults/PlasmaVault.sol";
import {IporFusionAccessManagersStorageLib} from "./IporFusionAccessManagersStorageLib.sol";

/**
 * @dev Function selectors for vault operations that trigger or are affected by redemption delays
 */
bytes4 constant DEPOSIT_SELECTOR = PlasmaVault.deposit.selector;
bytes4 constant DEPOSIT_WITH_PERMIT_SELECTOR = PlasmaVault.depositWithPermit.selector;
bytes4 constant MINT_SELECTOR = PlasmaVault.mint.selector;
bytes4 constant WITHDRAW_SELECTOR = PlasmaVault.withdraw.selector;
bytes4 constant REDEEM_SELECTOR = PlasmaVault.redeem.selector;
bytes4 constant TRANSFER_FROM_SELECTOR = PlasmaVault.transferFrom.selector;
bytes4 constant TRANSFER_SELECTOR = PlasmaVault.transfer.selector;

/**
 * @title Redemption Delay Library
 * @notice Implements time-based restrictions on withdrawals and redemptions after deposits
 * @dev Provides functionality to enforce cooling periods between deposits and withdrawals
 * to prevent potential manipulation and protect the vault's assets
 * @custom:security-contact [email protected]
 */
library RedemptionDelayLib {
    /**
     * @notice Error thrown when an account attempts to withdraw before their lock period expires
     * @param unlockTime The timestamp when the account will be unlocked
     */
    error AccountIsLocked(uint256 unlockTime);

    /**
     * @notice Emitted when an account's redemption lock is refreshed by a deposit or mint
     * @dev `unlockTime` is a snapshot under the redemption delay in force at the time of the deposit - it becomes
     * stale as soon as governance changes the delay. Indexers must persist `lockStartTime` and recompute the
     * unlock as lockStartTime + the delay from the latest IporFusionAccessManager.RedemptionDelayUpdated event
     * (or read getAccountLockTime on demand), never cache `unlockTime`
     * @param account The address of the affected account
     * @param lockStartTime The timestamp of the deposit or mint, the only durable value
     * @param unlockTime lockStartTime + the redemption delay at the time of the deposit (informational snapshot)
     */
    event RedemptionDelayForAccountUpdated(address account, uint256 lockStartTime, uint256 unlockTime);

    /**
     * @notice Retrieves the effective unlock timestamp for a specific account
     * @dev Computed at read time as lock start time (last deposit/mint) + the current
     * redemption delay, so every change of the vault-wide delay immediately moves the
     * unlock time of all accounts, in both directions
     * @param account_ The address to check the lock time for
     * @return The timestamp until which the account is locked under the current redemption delay,
     * possibly in the past when the lock has already expired, 0 if the account never deposited
     * @custom:security This value should be checked before allowing withdrawals
     */
    function getAccountLockTime(address account_) internal view returns (uint256) {
        uint256 lockStartTime = IporFusionAccessManagersStorageLib.getRedemptionLockStartTime(account_);
        if (lockStartTime == 0) {
            return 0;
        }
        return lockStartTime + IporFusionAccessManagersStorageLib.getRedemptionDelay();
    }

    /**
     * @notice Enforces redemption delay rules based on function calls
     * @dev Implements the following rules:
     * 1. For withdrawals/redemptions/transfers: Checks if the account is still locked under the current delay
     * 2. For deposits/mints: Records the lock start time
     * Gas: the lock start is written and the event emitted on EVERY deposit/mint, also when the redemption
     * delay is 0 (no early return). This is a deliberate cost (~20k gas on an account's first deposit, ~3-5k
     * afterwards, plus the event) accepted so that a later increase of the delay reaches accounts that
     * deposited while it was 0
     * @param account_ The account performing the operation
     * @param sig_ The function selector of the operation being performed
     * @custom:security Critical function that prevents quick deposit/withdrawal cycles
     * @custom:error-handling Reverts with AccountIsLocked if withdrawal attempted during lock period
     */
    function lockChecks(address account_, bytes4 sig_) internal {
        if (
            sig_ == WITHDRAW_SELECTOR ||
            sig_ == REDEEM_SELECTOR ||
            sig_ == TRANSFER_FROM_SELECTOR ||
            sig_ == TRANSFER_SELECTOR
        ) {
            uint256 unlockTime = getAccountLockTime(account_);
            if (unlockTime > block.timestamp) {
                revert AccountIsLocked(unlockTime);
            }
        } else if (sig_ == DEPOSIT_SELECTOR || sig_ == MINT_SELECTOR || sig_ == DEPOSIT_WITH_PERMIT_SELECTOR) {
            IporFusionAccessManagersStorageLib.setRedemptionLockStartTime(account_);
            emit RedemptionDelayForAccountUpdated(account_, block.timestamp, getAccountLockTime(account_));
        }
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@openzeppelin/=lib/ipor-fusion/node_modules/@openzeppelin/",
    "@chainlink/=lib/ipor-fusion/node_modules/@chainlink/",
    "@uniswap/v4-core/=lib/ipor-fusion/node_modules/@uniswap/v4-core/",
    "eth-gas-reporter/=node_modules/eth-gas-reporter/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "@ipor-protocol-deploy/=contracts/",
    "@ipor-fusion/=lib/ipor-fusion/",
    "@ipor-protocol/=lib/ipor-protocol/",
    "scripts/=scripts/",
    "@eth-optimism/=lib/ipor-fusion/node_modules/@eth-optimism/",
    "@ethereum-vault-connector/=lib/ipor-fusion/node_modules/ethereum-vault-connector/",
    "@morpho-org/=lib/ipor-fusion/node_modules/@morpho-org/",
    "@pendle/=lib/ipor-fusion/node_modules/@pendle/",
    "@prb/test/=lib/ipor-fusion/lib/foundry-random/lib/prb-test/src/",
    "@scroll-tech/=lib/ipor-fusion/node_modules/@scroll-tech/",
    "@uniswap/v3-core/=lib/ipor-fusion/node_modules/@uniswap/v3-core/",
    "CramBit/=lib/ipor-fusion/lib/foundry-random/lib/CramBit/",
    "abdk-libraries-solidity/=node_modules/abdk-libraries-solidity/",
    "base64-sol/=lib/ipor-fusion/node_modules/base64-sol/",
    "crambit/=lib/ipor-fusion/lib/foundry-random/lib/CramBit/src/",
    "erc4626-tests/=lib/ipor-fusion/node_modules/@uniswap/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "ethereum-vault-connector/=lib/ipor-fusion/node_modules/ethereum-vault-connector/",
    "foundry-random/=lib/ipor-fusion/lib/foundry-random/src/",
    "hardhat-deploy/=node_modules/hardhat-deploy/",
    "hardhat/=node_modules/hardhat/",
    "ipor-fusion/=lib/ipor-fusion/contracts/",
    "openzeppelin-contracts/=lib/ipor-fusion/node_modules/@uniswap/v4-core/lib/openzeppelin-contracts/",
    "openzeppelin/=lib/ipor-fusion/node_modules/ethereum-vault-connector/lib/openzeppelin-contracts/contracts/",
    "prb-test/=lib/ipor-fusion/lib/foundry-random/lib/prb-test/src/",
    "solidity-bytes-utils/=lib/ipor-fusion/lib/foundry-random/lib/solidity-bytes-utils/contracts/",
    "solmate/=lib/ipor-fusion/node_modules/@uniswap/v4-core/lib/solmate/",
    "src/=lib/ipor-fusion/lib/foundry-random/src/",
    "test/=lib/ipor-fusion/test/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.