Signing

Signing Vertex executes

All executes are signed using EIP712. Each execute request contains:

  1. A piece of structured data that includes the sender address i.e: the primaryType that needs to be signed.

  2. A signature of the hash of that structured data, signed by the sender.

Domain

The following is the domain required as part of the EIP712 structure:

{
    name: 'Vertex',
    version: '0.0.1',
    chainId: chainId,
    verifyingContract: contractAddress
}

You can retrieve the corresponding chain id and verifying contract via the contracts query.

Note: make sure to use the correct verifying contract for each execute:

  • For place order: should use the orderbook address of the corresponding product.

  • For everything else: should use the endpoint address.

See more details in the contracts query page.

EIP712 Types

See below the EIP712 type for each execute:

See more details in the Signing section of each execute's page.

Primary Type: Order

Solidity struct that needs to be signed:

struct Order {
    bytes32 sender;
    int128 priceX18;
    int128 amount;
    uint64 expiration;
    uint64 nonce;
}

JSON representation:

{
  Order: [
    { name: 'sender', type: 'bytes32' },
    { name: 'priceX18', type: 'int128' },
    { name: 'amount', type: 'int128' },
    { name: 'expiration', type: 'uint64' },
    { name: 'nonce', type: 'uint64' },
  ],
}

Primary Type: Cancellation

Solidity struct that needs to be signed:

struct Cancellation {
    bytes32 sender;
    uint32[] productIds;
    bytes32[] digests;
    uint64 nonce;
}

JSON representation:

{
  Cancellation: [
    { name: 'sender', type: 'bytes32' },
    { name: 'productIds', type: 'uint32[]' },
    { name: 'digests', type: 'bytes32[]' },
    { name: 'nonce', type: 'uint64' },
  ],
}

Primary Type: CancellationProducts

Solidity struct that needs to be signed:

struct CancellationProducts {
    bytes32 sender;
    uint32[] productIds;
    uint64 nonce;
}

JSON representation:

{
  CancellationProducts: [
    { name: 'sender', type: 'bytes32' },
    { name: 'productIds', type: 'uint32[]' },
    { name: 'nonce', type: 'uint64' },
  ],
}

Primary Type: WithdrawCollateral

Solidity struct that needs to be signed:

struct WithdrawCollateral {
    bytes32 sender;
    uint32 productId;
    uint128 amount;
    uint64 nonce;
}

JSON representation:

{
  WithdrawCollateral: [
    { name: 'sender', type: 'bytes32' },
    { name: 'productId', type: 'uint32' },
    { name: 'amount', type: 'uint128' },
    { name: 'nonce', type: 'uint64' },
  ],
}

Primary Type: LiquidateSubaccount

Solidity struct that needs to be signed:

struct LiquidateSubaccount {
    bytes32 sender;
    bytes32 liquidatee;
    uint32 productId;
    bool isEncodedSpread;
    int128 amount;
    uint64 nonce;
}

JSON representation:

{
  LiquidateSubaccount: [
    { name: 'sender', type: 'bytes32' },
    { name: 'liquidatee', type: 'bytes32' },
    { name: 'productId', type: 'uint32' },
    { name: 'isEncodedSpread', type: 'bool' },
    { name: 'amount', type: 'int128' },
    { name: 'nonce', type: 'uint64' },
  ],
}

Primary Type: MintLp

Solidity struct that needs to be signed:

struct MintLp {
    bytes32 sender;
    uint32 productId;
    uint128 amountBase;
    uint128 quoteAmountLow;
    uint128 quoteAmountHigh;
    uint64 nonce;
}

JSON representation:

{
  MintLp: [
    { name: 'sender', type: 'bytes32' },
    { name: 'productId', type: 'uint32' },
    { name: 'amountBase', type: 'uint128' },
    { name: 'quoteAmountLow', type: 'uint128' },
    { name: 'quoteAmountHigh', type: 'uint128' },
    { name: 'nonce', type: 'uint64' },
  ],
}

Primary Type: BurnLp

Solidity struct that needs to be signed:

struct BurnLp {
    bytes32 sender;
    uint32 productId;
    uint128 amount;
    uint64 nonce;
}

JSON representation:

{
  BurnLp: [
    { name: 'sender', type: 'bytes32' },
    { name: 'productId', type: 'uint32' },
    { name: 'amount', type: 'uint128' },
    { name: 'nonce', type: 'uint64' },
  ],
}

Primary Type: LinkSigner

Solidity struct that needs to be signed:

struct LinkSigner {
    bytes32 sender;
    bytes32 signer;
    uint64 nonce;
}

JSON representation:

{
  LinkSigner: [
    { name: 'sender', type: 'bytes32' },
    { name: 'signer', type: 'bytes32' },
    { name: 'nonce', type: 'uint64' },
  ],
}

Primary Type: ListTriggerOrders

Solidity struct that needs to be signed:

struct ListTriggerOrders {
    bytes32 sender;
    uint64 recvTime;
}

JSON representation:

{
  ListTriggerOrders: [
    { name: 'sender', type: 'bytes32' },
    { name: 'recvTime', type: 'uint64' },
  ],
}

Primary Type: StreamAuthentication

Struct that needs to be signed:

struct StreamAuthentication {
    bytes32 sender;
    uint64 expiration;
}

JSON representation:

{
  StreamAuthentication: [
    { name: 'sender', type: 'bytes32' },
    { name: 'expiration', type: 'uint64' },
  ],
}

Last updated