New features

StarkEx Spot Trading 5.0

Multi-asset trading

MultiAssetTrade is a new type of transaction in StarkEx Spot Trading.

Traders can now conduct all-or-nothing trading among multiple parties with multiple types of assets.

Some use cases:

  • Trade a combination of different NFTs in a single transaction.

  • Pay fees to multiple parties in a single transaction.

  • Alice gives Bob 1 ETH, Bob gives Carol 1000 USDC, and Carol gives Alice 1 dragon and 2 castle NFTs.

ERC-1155 and ERC-20 token minting

StarkEx Spot Trading now supports off-chain minting of ERC-1155 and ERC-20 tokens.

The flow for minting ERC-1155 and ERC-20 tokens off-chain is similar to that for ERC-721 tokens. The differences are:

  • You can mint multiple ERC-1155 and ERC-20 tokens, while with ERC-721 you can only mint one.

  • You can mint ERC-1155 and ERC-20 tokens repeatedly.

  • The format of the asset ID for ERC-1155 and ERC-20 tokens is different from that for ERC-721 tokens. For more information, see Identifiers for supported assets.

StarkEx Spot Trading 4.5

Volition

Your users can now choose between off-chain data availability, known as Validium, and on-chain data availability.

StarkEx now provides two vault trees: one for on-chain data, and one for off-chain data.

The valid vault ranges are: [0, 231] for Validium vaults (off-chain) [263, 263+231] for the ZK-Rollup vaults (on-chain)

  • The vault size results in each signature having 63 bits allocated for vaults.

  • The StarkEx contract supports both vault ID ranges. When depositing to a rollup vault, the 63rd bit of vaultId must be on. The roots of both vault trees are updated when UpdateState is called. The updated balances of rollup vaults are also emitted on-chain as calldata.

  • An escape hatch is checked against the tree in which the escaped vault is located.

Transaction bundling

StarkEx now supports a new type of transaction: A bundle set of transactions. With a transaction bundle, you can send StarkEx a list of transactions, where all transactions in the list are guaranteed to go into the same batch if possible, and if not possible, the system prompts for an alternative transaction. If any transaction inside the transaction bundle is invalid, you need to send an alternative transaction bundle.

A transaction bundle is useful for trading multiple asset types in one operation. For example, you can use transaction bundling to sell a set of NFTs as one package.

ERC-1155 token support

StarkEx now fully supports existing ERC-1155 tokens for both L1 and L2 vaults. Minting ERC-1155 tokens is not supported.

  • Each ERC-1155 token contract should be registered once, given assetInfo, which includes a selector and contract address, and a quantum. The same quantum applies to all different assets that belong to that asset type.

  • If different quantums are required for different assets within the same ERC-1155 contract, the same contract can be registered once per quantum. Note that each such registration results in a different asset type. The same tokenIds with different assetTypes result in different assetIds.

  • ERC1155_SELECTOR = bytes4(keccak256("ERC1155Token(address,uint256)")) (0x3348691d)

  • ERC-1155 tokens are deposited and withdrawn similarly to NFTs, including assetType and tokenId, but also including a quantizedAmount argument.

  • tokenId is the internal token ID within the ERC-1155 contract.

  • assetId is a unique StarkEx identifier calculated as follows: uint256(keccak256(abi.encodePacked("NON_MINTABLE:", assetType, tokenId))) & MASK_250

New L2 vault functions

  • Deposit for both ERC-721 and ERC-1155, recommended. For ERC-721, quantizedAmount must equal one:

      function depositWithTokenId(
          uint256 starkKey,
          uint256 assetType,
          uint256 tokenId,
          uint256 vaultId,
          uint256 quantizedAmount
      )
  • A wrapper for depositWithTokenId that supports only ERC-1155 tokens:

      function depositERC1155(
          uint256 starkKey,
          uint256 assetType,
          uint256 tokenId,
          uint256 vaultId,
          uint256 quantizedAmount
      )
  • To reclaim a cancelled deposit.

      function depositWithTokenIdReclaim(
          uint256 starkKey,
          uint256 assetType,
          uint256 tokenId,
          uint256 vaultId
      )
  • Withdrawal function that supports both ERC-721 and ERC-1155

      function withdrawWithTokenId(
          uint256 ownerKey,
          uint256 assetType,
          uint256 tokenId
      )
  • Return the StarkEx asset ID of a specific ERC-721 or ERC-1155 token. You can use this function to cancel a deposit, check pending on-chain balances, and so forth. function calculateAssetIdWithTokenId(uint256 assetType, uint256 tokenId) public view returns (uint256)

New L1 Vaults Functions

function depositERC1155ToVault(
    uint256 assetType,
    uint256 tokenId,
    uint256 vaultId,
    uint256 quantizedAmount
)

function withdrawErc1155FromVault(
    uint256 assetType,
    uint256 tokenId,
    uint256 vaultId,
    uint256 quantizedAmount
)

function getQuantizedErc1155VaultBalance(
    address ethKey,
    uint256 assetType,
    uint256 tokenId,
    uint256 vaultId
)