Skip to content
Verified contractExactMIT

UniswapV3PositionTimelock

Address0xc39a5edec1acc38a31ae54cc7dc15b3ceedb7d39
Balance

0 ETH

 

Transactions

2

 

Compiler

solc 0.8.26

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.26+commit.8a97fa7a
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,382,667
Creation transaction
0x9f009f68db…39d4d1346d

contracts/liquidity/UniswapV3PositionTimelock.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

interface IERC721PositionManager {
    function safeTransferFrom(address from, address to, uint256 tokenId) external;
    function transferFrom(address from, address to, uint256 tokenId) external;
}

/// @notice Minimal, non-upgradeable custody escrow for one Uniswap V3 position NFT.
/// @dev The contract intentionally has no admin, migrator, fee, or arbitrary-call path.
contract UniswapV3PositionTimelock {
    error AlreadyDeposited();
    error NotOwner();
    error NotPositionManager();
    error WrongTokenId();
    error InvalidUnlockDate();
    error NotDeposited();
    error StillLocked();
    error TransferFailed();

    IERC721PositionManager public immutable positionManager;
    uint256 public immutable tokenId;
    address public immutable beneficiary;
    uint256 public immutable unlockTime;
    bool public deposited;

    event PositionDeposited(address indexed beneficiary, uint256 indexed tokenId, uint256 unlockTime);
    event PositionWithdrawn(address indexed beneficiary, uint256 indexed tokenId);

    constructor(address positionManager_, uint256 tokenId_, address beneficiary_, uint256 unlockTime_) {
        if (positionManager_ == address(0) || beneficiary_ == address(0)) revert NotOwner();
        // A timestamp is the intended unlock boundary; miner variance cannot bypass a multi-year lock.
        // slither-disable-next-line timestamp
        if (unlockTime_ <= block.timestamp) revert InvalidUnlockDate();
        positionManager = IERC721PositionManager(positionManager_);
        tokenId = tokenId_;
        beneficiary = beneficiary_;
        unlockTime = unlockTime_;
    }

    function deposit() external {
        if (msg.sender != beneficiary) revert NotOwner();
        if (deposited) revert AlreadyDeposited();
        positionManager.safeTransferFrom(msg.sender, address(this), tokenId);
        if (!deposited) revert TransferFailed();
    }

    function withdraw() external {
        if (msg.sender != beneficiary) revert NotOwner();
        if (!deposited) revert NotDeposited();
        // slither-disable-next-line timestamp
        if (block.timestamp < unlockTime) revert StillLocked();
        deposited = false;
        emit PositionWithdrawn(beneficiary, tokenId);
        positionManager.transferFrom(address(this), beneficiary, tokenId);
    }

    function onERC721Received(address, address from, uint256 receivedTokenId, bytes calldata)
        external
        returns (bytes4)
    {
        if (msg.sender != address(positionManager)) revert NotPositionManager();
        if (receivedTokenId != tokenId) revert WrongTokenId();
        if (from != beneficiary || deposited) revert TransferFailed();
        deposited = true;
        emit PositionDeposited(beneficiary, tokenId, unlockTime);
        return this.onERC721Received.selector;
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "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/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "@emoney/=contracts/emoney/",
    "@emoney-scripts/=script/emoney/",
    "@chainlink/contracts-ccip/=node_modules/@chainlink/contracts-ccip/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "@gru/=lib/gru-contracts/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.