WithdrawInbox

Description:

Proxy contract enabling upgradeable smart contract patterns. Delegates calls to an implementation contract.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "contracts/liquidity-bridge/WithdrawInbox.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-only\r
\r
pragma solidity 0.8.17;\r
\r
import "../safeguard/Ownable.sol";\r
\r
/**\r
 * @title A contract to initiate withdrawal requests for contracts that provide liquidity to {Bridge}.\r
 */\r
contract WithdrawInbox is Ownable {\r
    // min allowed max slippage uint32 value is slippage * 1M, eg. 0.5% -> 5000\r
    uint32 public minimalMaxSlippage;\r
    // the period of time during which a withdrawal request is intended to be valid\r
    uint256 public validityPeriod;\r
\r
    // contract LP withdrawal request\r
    event WithdrawalRequest(\r
        uint64 seqNum,\r
        address sender,\r
        address receiver,\r
        uint64 toChain,\r
        uint64[] fromChains,\r
        address[] tokens,\r
        uint32[] ratios,\r
        uint32[] slippages,\r
        uint256 deadline\r
    );\r
\r
    constructor() {\r
        // default validityPeriod is 2 hours\r
        validityPeriod = 7200;\r
    }\r
\r
    /**\r
     * @notice Withdraw liquidity from the pool-based bridge.\r
     * NOTE: Each of your withdrawal request should have different _wdSeq.\r
     * NOTE: Tokens to withdraw within one withdrawal request should have the same symbol.\r
     * @param _wdSeq The unique sequence number to identify this withdrawal request.\r
     * @param _receiver The receiver address on _toChain.\r
     * @param _toChain The chain Id to receive the withdrawn tokens.\r
     * @param _fromChains The chain Ids to withdraw tokens.\r
     * @param _tokens The token to withdraw on each fromChain.\r
     * @param _ratios The withdrawal ratios of each token.\r
     * @param _slippages The max slippages of each token for cross-chain withdraw.\r
     */\r
    function withdraw(\r
        uint64 _wdSeq,\r
        address _receiver,\r
        uint64 _toChain,\r
        uint64[] calldata _fromChains,\r
        address[] calldata _tokens,\r
        uint32[] calldata _ratios,\r
        uint32[] calldata _slippages\r
    ) external {\r
        require(_fromChains.length > 0, "empty withdrawal request");\r
        require(\r
            _tokens.length == _fromChains.length &&\r
                _ratios.length == _fromChains.length &&\r
                _slippages.length == _fromChains.length,\r
            "length mismatch"\r
        );\r
        for (uint256 i = 0; i < _ratios.length; i++) {\r
            require(_ratios[i] > 0 && _ratios[i] <= 1e8, "invalid ratio");\r
            require(_slippages[i] >= minimalMaxSlippage, "slippage too small");\r
        }\r
        uint256 _deadline = block.timestamp + validityPeriod;\r
        emit WithdrawalRequest(\r
            _wdSeq,\r
            msg.sender,\r
            _receiver,\r
            _toChain,\r
            _fromChains,\r
            _tokens,\r
            _ratios,\r
            _slippages,\r
            _deadline\r
        );\r
    }\r
\r
    // ------------------------Admin operations--------------------------\r
\r
    function setMinimalMaxSlippage(uint32 _minimalMaxSlippage) external onlyOwner {\r
        minimalMaxSlippage = _minimalMaxSlippage;\r
    }\r
\r
    function setValidityPeriod(uint256 _validityPeriod) external onlyOwner {\r
        validityPeriod = _validityPeriod;\r
    }\r
}\r
"
    },
    "contracts/safeguard/Ownable.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-only\r
\r
pragma solidity ^0.8.0;\r
\r
/**\r
 * @dev Contract module which provides a basic access control mechanism, where\r
 * there is an account (an owner) that can be granted exclusive access to\r
 * specific functions.\r
 *\r
 * By default, the owner account will be the one that deploys the contract. This\r
 * can later be changed with {transferOwnership}.\r
 *\r
 * This module is used through inheritance. It will make available the modifier\r
 * `onlyOwner`, which can be applied to your functions to restrict their use to\r
 * the owner.\r
 *\r
 * This adds a normal func that setOwner if _owner is address(0). So we can't allow\r
 * renounceOwnership. So we can support Proxy based upgradable contract\r
 */\r
abstract contract Ownable {\r
    address private _owner;\r
\r
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r
\r
    /**\r
     * @dev Initializes the contract setting the deployer as the initial owner.\r
     */\r
    constructor() {\r
        _setOwner(msg.sender);\r
    }\r
\r
    /**\r
     * @dev Only to be called by inherit contracts, in their init func called by Proxy\r
     * we require _owner == address(0), which is only possible when it's a delegateCall\r
     * because constructor sets _owner in contract state.\r
     */\r
    function initOwner() internal {\r
        require(_owner == address(0), "owner already set");\r
        _setOwner(msg.sender);\r
    }\r
\r
    /**\r
     * @dev Returns the address of the current owner.\r
     */\r
    function owner() public view virtual returns (address) {\r
        return _owner;\r
    }\r
\r
    /**\r
     * @dev Throws if called by any account other than the owner.\r
     */\r
    modifier onlyOwner() {\r
        require(owner() == msg.sender, "Ownable: caller is not the owner");\r
        _;\r
    }\r
\r
    /**\r
     * @dev Transfers ownership of the contract to a new account (`newOwner`).\r
     * Can only be called by the current owner.\r
     */\r
    function transferOwnership(address newOwner) public virtual onlyOwner {\r
        require(newOwner != address(0), "Ownable: new owner is the zero address");\r
        _setOwner(newOwner);\r
    }\r
\r
    function _setOwner(address newOwner) private {\r
        address oldOwner = _owner;\r
        _owner = newOwner;\r
        emit OwnershipTransferred(oldOwner, newOwner);\r
    }\r
}\r
"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 800
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    }
  }
}}

Tags:
Proxy, Liquidity, Upgradeable, Factory|addr:0x91830a8f5f20ef56804ce2e7b2d727ad89cb995f|verified:true|block:23743007|tx:0xeeabf95bd440b9f9d6e4fe7c5ac143c50582d8059ddcb49b92fae34f68ad05b7|first_check:1762508890

Submitted on: 2025-11-07 10:48:11

Comments

Log in to comment.

No comments yet.