账户
0xac...7590
0xac...7590

0xac...7590

$500
此合同的源代码已经过验证!
合同元数据
编译器
0.8.23+commit.f704f362
语言
Solidity
合同源代码
文件 1 的 2:CoreV4.sol
// Copyright (c) Immutable Pty Ltd 2018 - 2024
// SPDX-License-Identifier: MIT
//
// This contract is an interface for the StarkEx Core contract v4 version.
// It is used to interact with the StarkEx Core contract from the Registration contract.
// The Core contract is used to register and withdraw users and assets from the StarkEx system.
//
// This file was generated using the abi-to-sol tool.
// the StarkEx contract ABI that was provided by StarkWare via slack.
pragma solidity ^0.8.19;

interface CoreV4 {
    fallback() external payable;

    function VERSION() external view returns (string memory);

    function initialize(bytes memory data) external;

    receive() external payable;

    event LogFrozen();
    event LogNewGovernorAccepted(address acceptedGovernor);
    event LogNominatedGovernor(address nominatedGovernor);
    event LogNominationCancelled();
    event LogRegistered(address entry, string entryId);
    event LogRemovalIntent(address entry, string entryId);
    event LogRemoved(address entry, string entryId);
    event LogRemovedGovernor(address removedGovernor);
    event LogUnFrozen();

    function DEPOSIT_CANCEL_DELAY() external view returns (uint256);

    function FREEZE_GRACE_PERIOD() external view returns (uint256);

    function MAIN_GOVERNANCE_INFO_TAG() external view returns (string memory);

    function MAX_FORCED_ACTIONS_REQS_PER_BLOCK() external view returns (uint256);

    function MAX_VERIFIER_COUNT() external view returns (uint256);

    function UNFREEZE_DELAY() external view returns (uint256);

    function VERIFIER_REMOVAL_DELAY() external view returns (uint256);

    function announceAvailabilityVerifierRemovalIntent(address verifier) external;

    function announceVerifierRemovalIntent(address verifier) external;

    function getRegisteredAvailabilityVerifiers() external view returns (address[] memory _verifers);

    function getRegisteredVerifiers() external view returns (address[] memory _verifers);

    function isAvailabilityVerifier(address verifierAddress) external view returns (bool);

    function isFrozen() external view returns (bool);

    function isVerifier(address verifierAddress) external view returns (bool);

    function mainAcceptGovernance() external;

    function mainCancelNomination() external;

    function mainIsGovernor(address testGovernor) external view returns (bool);

    function mainNominateNewGovernor(address newGovernor) external;

    function mainRemoveGovernor(address governorForRemoval) external;

    function registerAvailabilityVerifier(address verifier, string memory identifier) external;

    function registerVerifier(address verifier, string memory identifier) external;

    function removeAvailabilityVerifier(address verifier) external;

    function removeVerifier(address verifier) external;

    function unFreeze() external;

    event LogDeposit(
        address depositorEthKey,
        uint256 starkKey,
        uint256 vaultId,
        uint256 assetType,
        uint256 nonQuantizedAmount,
        uint256 quantizedAmount
    );
    event LogDepositCancel(uint256 starkKey, uint256 vaultId, uint256 assetId);
    event LogDepositCancelReclaimed(
        uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount
    );
    event LogDepositNftCancelReclaimed(
        uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 tokenId, uint256 assetId
    );
    event LogMintWithdrawalPerformed(
        uint256 ownerKey, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount, uint256 assetId
    );
    event LogMintableWithdrawalAllowed(uint256 ownerKey, uint256 assetId, uint256 quantizedAmount);
    event LogNftDeposit(
        address depositorEthKey, uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 tokenId, uint256 assetId
    );
    event LogNftWithdrawalAllowed(uint256 ownerKey, uint256 assetId);
    event LogNftWithdrawalPerformed(
        uint256 ownerKey, uint256 assetType, uint256 tokenId, uint256 assetId, address recipient
    );
    event LogTokenAdminAdded(address tokenAdmin);
    event LogTokenAdminRemoved(address tokenAdmin);
    event LogTokenRegistered(uint256 assetType, bytes assetInfo, uint256 quantum);
    event LogUserRegistered(address ethKey, uint256 starkKey, address sender);
    event LogWithdrawalAllowed(
        uint256 ownerKey, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount
    );
    event LogWithdrawalPerformed(
        uint256 ownerKey, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount, address recipient
    );

    function defaultVaultWithdrawalLock() external view returns (uint256);

    function deposit(uint256 starkKey, uint256 assetType, uint256 vaultId) external payable;

    function deposit(uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 quantizedAmount) external;

    function depositCancel(uint256 starkKey, uint256 assetId, uint256 vaultId) external;

    function depositERC20(uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 quantizedAmount) external;

    function depositEth(uint256 starkKey, uint256 assetType, uint256 vaultId) external payable;

    function depositNft(uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 tokenId) external;

    function depositNftReclaim(uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 tokenId) external;

    function depositReclaim(uint256 starkKey, uint256 assetId, uint256 vaultId) external;

    function getActionCount() external view returns (uint256);

    function getActionHashByIndex(uint256 actionIndex) external view returns (bytes32);

    function getAssetInfo(uint256 assetType) external view returns (bytes memory assetInfo);

    function getCancellationRequest(uint256 starkKey, uint256 assetId, uint256 vaultId)
        external
        view
        returns (uint256 request);

    function getDepositBalance(uint256 starkKey, uint256 assetId, uint256 vaultId)
        external
        view
        returns (uint256 balance);

    function getEthKey(uint256 ownerKey) external view returns (address);

    function getFullWithdrawalRequest(uint256 starkKey, uint256 vaultId) external view returns (uint256 res);

    function getQuantizedDepositBalance(uint256 starkKey, uint256 assetId, uint256 vaultId)
        external
        view
        returns (uint256 balance);

    function getQuantum(uint256 presumedAssetType) external view returns (uint256 quantum);

    function getWithdrawalBalance(uint256 ownerKey, uint256 assetId) external view returns (uint256 balance);

    function isAssetRegistered(uint256 assetType) external view returns (bool);

    function isTokenAdmin(address testedAdmin) external view returns (bool);

    function onERC721Received(address, address, uint256, bytes memory) external returns (bytes4);

    function orderRegistryAddress() external view returns (address);

    function registerAndDepositERC20(
        address ethKey,
        uint256 starkKey,
        bytes memory signature,
        uint256 assetType,
        uint256 vaultId,
        uint256 quantizedAmount
    ) external;

    function registerAndDepositEth(
        address ethKey,
        uint256 starkKey,
        bytes memory signature,
        uint256 assetType,
        uint256 vaultId
    ) external payable;

    function registerEthAddress(address ethKey, uint256 starkKey, bytes memory starkSignature) external;

    function registerSender(uint256 starkKey, bytes memory starkSignature) external;

    function registerToken(uint256 assetType, bytes memory assetInfo) external;

    function registerToken(uint256 assetType, bytes memory assetInfo, uint256 quantum) external;

    function registerTokenAdmin(address newAdmin) external;

    function unregisterTokenAdmin(address oldAdmin) external;

    function withdraw(uint256 ownerKey, uint256 assetType) external;

    function withdrawAndMint(uint256 ownerKey, uint256 assetType, bytes memory mintingBlob) external;

    function withdrawNft(uint256 ownerKey, uint256 assetType, uint256 tokenId) external;

    event LogOperatorAdded(address operator);
    event LogOperatorRemoved(address operator);
    event LogRootUpdate(uint256 sequenceNumber, uint256 batchId, uint256 vaultRoot, uint256 orderRoot);
    event LogStateTransitionFact(bytes32 stateTransitionFact);
    event LogVaultBalanceChangeApplied(address ethKey, uint256 assetId, uint256 vaultId, int256 quantizedAmountChange);

    function STARKEX_MAX_DEFAULT_VAULT_LOCK() external view returns (uint256);

    function escape(uint256 starkKey, uint256 vaultId, uint256 assetId, uint256 quantizedAmount) external;

    function getLastBatchId() external view returns (uint256 batchId);

    function getOrderRoot() external view returns (uint256 root);

    function getOrderTreeHeight() external view returns (uint256 height);

    function getSequenceNumber() external view returns (uint256 seq);

    function getVaultRoot() external view returns (uint256 root);

    function getVaultTreeHeight() external view returns (uint256 height);

    function isOperator(address testedOperator) external view returns (bool);

    function registerOperator(address newOperator) external;

    function unregisterOperator(address removedOperator) external;

    function updateState(uint256[] memory publicInput, uint256[] memory applicationData) external;

    event LogFullWithdrawalRequest(uint256 starkKey, uint256 vaultId);

    function freezeRequest(uint256 starkKey, uint256 vaultId) external;

    function fullWithdrawalRequest(uint256 starkKey, uint256 vaultId) external;

    event LogDefaultVaultWithdrawalLockSet(uint256 newDefaultLockTime);
    event LogDepositToVault(
        address ethKey, uint256 assetId, uint256 vaultId, uint256 nonQuantizedAmount, uint256 quantizedAmount
    );
    event LogVaultWithdrawalLockSet(address ethKey, uint256 assetId, uint256 vaultId, uint256 timeRelease);
    event LogWithdrawalFromVault(
        address ethKey, uint256 assetId, uint256 vaultId, uint256 nonQuantizedAmount, uint256 quantizedAmount
    );

    function depositERC20ToVault(uint256 assetId, uint256 vaultId, uint256 quantizedAmount) external;

    function depositEthToVault(uint256 assetId, uint256 vaultId) external payable;

    function getQuantizedVaultBalance(address ethKey, uint256 assetId, uint256 vaultId)
        external
        view
        returns (uint256);

    function getVaultBalance(address ethKey, uint256 assetId, uint256 vaultId) external view returns (uint256);

    function getVaultWithdrawalLock(address ethKey, uint256 assetId, uint256 vaultId) external view returns (uint256);

    function isStrictVaultBalancePolicy() external view returns (bool);

    function isVaultLocked(address ethKey, uint256 assetId, uint256 vaultId) external view returns (bool);

    function lockVault(uint256 assetId, uint256 vaultId, uint256 lockTime) external;

    function setDefaultVaultWithdrawalLock(uint256 newDefaultTime) external;

    function withdrawFromVault(uint256 assetId, uint256 vaultId, uint256 quantizedAmount) external;

    event ImplementationActivationRescheduled(address indexed implementation, uint256 updatedActivationTime);

    function updateImplementationActivationTime(address implementation, bytes memory data, bool finalize) external;
}
合同源代码
文件 2 的 2:RegistrationV4.sol
// Copyright (c) Immutable Pty Ltd 2018 - 2024
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {CoreV4} from "./CoreV4.sol";

/**
 * Emitted when there are no funds to withdraw when calling `withdrawAll`.
 */
error NoFundsToWithdraw(uint256 ethKey, uint256 starkKey);

/**
 * RegistrationV4 is a wrapper around the StarkEx contract to provide a more user-friendly interface for executing multiple transactions on the StarkEx contract at once.
 * This contract is not upgradeable. If an issue is found with this contract, a new version will be deployed.
 */
contract RegistrationV4 {
    CoreV4 public immutable imx;

    constructor(address payable _imx) {
        imx = CoreV4(_imx);
    }

    function registerAndWithdrawAll(address ethKey, uint256 starkKey, bytes calldata signature, uint256 assetType)
        external
    {
        if (!isRegistered(starkKey)) {
            imx.registerEthAddress(ethKey, starkKey, signature);
        }
        withdrawAll(uint160(ethKey), starkKey, assetType);
    }

    function withdrawAll(uint256 ethKey, uint256 starkKey, uint256 assetType) public {
        uint256 ethKeyBalance = imx.getWithdrawalBalance(ethKey, assetType);
        uint256 starkKeyBalance = imx.getWithdrawalBalance(starkKey, assetType);
        if (ethKeyBalance == 0 && starkKeyBalance == 0) {
            revert NoFundsToWithdraw(ethKey, starkKey);
        }

        if (ethKeyBalance > 0) {
            imx.withdraw(ethKey, assetType);
        }

        if (starkKeyBalance > 0) {
            imx.withdraw(starkKey, assetType);
        }
    }

    function registerAndWithdrawNft(
        address ethKey,
        uint256 starkKey,
        bytes calldata signature,
        uint256 assetType,
        uint256 tokenId
    ) external {
        if (!isRegistered(starkKey)) {
            imx.registerEthAddress(ethKey, starkKey, signature);
        }
        imx.withdrawNft(starkKey, assetType, tokenId);
    }

    function registerWithdrawAndMint(
        address ethKey,
        uint256 starkKey,
        bytes calldata signature,
        uint256 assetType,
        bytes calldata mintingBlob
    ) external {
        if (!isRegistered(starkKey)) {
            imx.registerEthAddress(ethKey, starkKey, signature);
        }
        imx.withdrawAndMint(starkKey, assetType, mintingBlob);
    }

    function getVersion() external view returns (string memory) {
        return imx.VERSION();
    }

    function isRegistered(uint256 starkKey) public view returns (bool) {
        return imx.getEthKey(starkKey) != address(0);
    }
}
设置
{
  "compilationTarget": {
    "contracts/bridge/x/v4/RegistrationV4.sol": "RegistrationV4"
  },
  "evmVersion": "paris",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [
    ":@openzeppelin/contracts/=lib/openzeppelin-contracts-4.9.3/contracts/",
    ":@rari-capital/solmate/=lib/immutable-seaport-1.5.0+im1.3/lib/solmate/",
    ":ds-test/=lib/forge-std/lib/ds-test/src/",
    ":erc4626-tests/=lib/openzeppelin-contracts-upgradeable-4.9.3/lib/erc4626-tests/",
    ":forge-std/=lib/forge-std/src/",
    ":immutable-seaport-1.5.0+im1.3/=lib/immutable-seaport-1.5.0+im1.3/",
    ":immutable-seaport-core-1.5.0+im1/=lib/immutable-seaport-core-1.5.0+im1/src/",
    ":murky/=lib/immutable-seaport-1.5.0+im1.3/lib/murky/src/",
    ":openzeppelin-contracts-4.9.3/=lib/openzeppelin-contracts-4.9.3/",
    ":openzeppelin-contracts-upgradeable-4.9.3/=lib/openzeppelin-contracts-upgradeable-4.9.3/contracts/",
    ":openzeppelin-contracts/=lib/immutable-seaport-1.5.0+im1.3/lib/openzeppelin-contracts/",
    ":openzeppelin/=lib/openzeppelin-contracts-upgradeable-4.9.3/contracts/",
    ":seaport-core/=lib/immutable-seaport-core-1.5.0+im1/",
    ":seaport-sol/=lib/immutable-seaport-1.5.0+im1.3/lib/seaport-sol/",
    ":seaport-types/=lib/immutable-seaport-1.5.0+im1.3/lib/seaport-types/",
    ":seaport/contracts/=lib/immutable-seaport-1.5.0+im1.3/contracts/",
    ":solady/=lib/immutable-seaport-1.5.0+im1.3/lib/solady/",
    ":solarray/=lib/immutable-seaport-1.5.0+im1.3/lib/solarray/src/",
    ":solidity-bits/=lib/solidity-bits/",
    ":solidity-bytes-utils/=lib/solidity-bytes-utils/",
    ":solmate/=lib/immutable-seaport-1.5.0+im1.3/lib/solmate/src/"
  ]
}
ABI
[{"inputs":[{"internalType":"address payable","name":"_imx","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"ethKey","type":"uint256"},{"internalType":"uint256","name":"starkKey","type":"uint256"}],"name":"NoFundsToWithdraw","type":"error"},{"inputs":[],"name":"getVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"imx","outputs":[{"internalType":"contract CoreV4","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"}],"name":"isRegistered","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"ethKey","type":"address"},{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"uint256","name":"assetType","type":"uint256"}],"name":"registerAndWithdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"ethKey","type":"address"},{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"registerAndWithdrawNft","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"ethKey","type":"address"},{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"bytes","name":"mintingBlob","type":"bytes"}],"name":"registerWithdrawAndMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ethKey","type":"uint256"},{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"}],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"}]