Interface TradeAdapter

interface TradeAdapter {
    cancelOrder(orderId, accountId, accountUser, nonce, signature): Promise<void>;
    cancelSubscription(subscriptionId): void;
    clearSystemParam(args): Promise<void>;
    deposit(amount, accountId, tokenAddress, depositorAddress, signature, useGasless?, psmToken?): Promise<DepositResponse>;
    getDepositMessage(signerAddress, accountId): Promise<Bytes>;
    getLpConfig(): Promise<LpConfigUpdateResponse>;
    getOpenAccountMessage(signerAddress): Promise<Bytes>;
    getOwnerMessage(signerAddress, accountId): Promise<Bytes>;
    getTradeMessage(signerAddress, accountId): Promise<Bytes>;
    getWithdrawMessage(signerAddress, accountId): Promise<Bytes>;
    grantAccountUserRole(accountId, user, role, accountOwner, signature): Promise<GrantAccountUserRoleResponse>;
    openAccount(amount, tokenAddress, ownerAddress, signature, referralCode?, useGasless?, psmToken?): Promise<OpenAccountResponse>;
    placeOrder(order): Promise<PlaceOrderResponse>;
    replaceOrder(cancelOrderId, cancelSignature, nonce, accountId, accountUser, newOrder): Promise<ReplaceOrderResponse>;
    revokeAccountUserRole(accountId, user, role, accountOwner, signature): Promise<RevokeAccountUserRoleResponse>;
    setSystemParam(args): Promise<void>;
    subscribeToAccount(accountId, listener): Promise<string>;
    subscribeToLp(lpId, listener): Promise<string>;
    trade(accountId, liquidityPoolId, size, pair, accountUser, signature): Promise<TradeResponse>;
    waitForConnect(): Promise<void>;
    withdraw(amount, accountId, accountUser, tokenAddress, recipientAddress, signature, psmToken?): Promise<WithdrawResponse>;
}

Implemented by

Methods

  • Parameters

    • orderId: string
    • accountId: number
    • accountUser: string
    • nonce: string
    • signature: string

    Returns Promise<void>

  • Parameters

    • amount: string
    • accountId: number
    • tokenAddress: string
    • depositorAddress: string
    • signature: string
    • Optional useGasless: boolean
    • Optional psmToken: string

    Returns Promise<DepositResponse>

  • Parameters

    • signerAddress: string
    • accountId: number

    Returns Promise<Bytes>

  • Parameters

    • signerAddress: string
    • accountId: number

    Returns Promise<Bytes>

  • Parameters

    • amount: string
    • tokenAddress: string
    • ownerAddress: string
    • signature: string
    • Optional referralCode: string
    • Optional useGasless: boolean
    • Optional psmToken: string

    Returns Promise<OpenAccountResponse>

  • Parameters

    • order: {
          accountId: number;
          accountUser: string;
          createdTimestampUnixMillis: number;
          expiryTimestampUnixMillis: number;
          id: string;
          kind: {
              kind: "market";
          } | {
              args: {
                  limitPrice: BigNumber;
              };
              kind: "limit";
          } | {
              args: {
                  stopLoss?: null | {
                      kind: "position";
                  } | {
                      id: string;
                      kind: "order";
                  };
                  triggerPrice: BigNumber;
              };
              kind: "stopMarket";
          } | {
              args: {
                  limitPrice: BigNumber;
                  triggerPrice: BigNumber;
              };
              kind: "stopLimit";
          } | {
              args: {
                  takeProfit?: null | {
                      kind: "position";
                  } | {
                      id: string;
                      kind: "order";
                  };
                  triggerPrice: BigNumber;
              };
              kind: "limitTrigger";
          } | {
              kind: string;
          };
          lpId: string;
          nonce: string;
          pair: Pair;
          signature: string;
          size: {
              amount: BigNumber;
              unit: "lpc" | "lot";
          };
          status: {
              content: {
                  status: "placed";
              } | {
                  content: {
                      timestampUnixMillis: number;
                      triggerPrice: BigNumber;
                  };
                  status: "triggered";
              };
              status: "open";
          } | {
              content: {
                  price: BigNumber;
                  settlementStatus: {
                      status: "queued";
                  } | {
                      status: "beforeTx";
                  } | {
                      status: "indexing";
                  } | {
                      content: {
                          txHash: string;
                      };
                      status: "settled";
                  };
                  timestampUnixMillis: number;
              };
              status: "filled";
          } | {
              content: {
                  reason: string;
                  timestampUnixMillis: number;
                  userCancellation?: null | {
                      address: string;
                      nonce: string;
                      signature: {
                          r: string;
                          s: string;
                          v: number;
                      };
                  };
              };
              status: "cancelled";
          };
      }
      • accountId: number
      • accountUser: string
      • createdTimestampUnixMillis: number
      • expiryTimestampUnixMillis: number
      • id: string
      • kind: {
            kind: "market";
        } | {
            args: {
                limitPrice: BigNumber;
            };
            kind: "limit";
        } | {
            args: {
                stopLoss?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "stopMarket";
        } | {
            args: {
                limitPrice: BigNumber;
                triggerPrice: BigNumber;
            };
            kind: "stopLimit";
        } | {
            args: {
                takeProfit?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "limitTrigger";
        } | {
            kind: string;
        }
      • lpId: string
      • nonce: string
      • pair: Pair
      • signature: string
      • size: {
            amount: BigNumber;
            unit: "lpc" | "lot";
        }
        • amount: BigNumber
        • unit: "lpc" | "lot"
      • status: {
            content: {
                status: "placed";
            } | {
                content: {
                    timestampUnixMillis: number;
                    triggerPrice: BigNumber;
                };
                status: "triggered";
            };
            status: "open";
        } | {
            content: {
                price: BigNumber;
                settlementStatus: {
                    status: "queued";
                } | {
                    status: "beforeTx";
                } | {
                    status: "indexing";
                } | {
                    content: {
                        txHash: string;
                    };
                    status: "settled";
                };
                timestampUnixMillis: number;
            };
            status: "filled";
        } | {
            content: {
                reason: string;
                timestampUnixMillis: number;
                userCancellation?: null | {
                    address: string;
                    nonce: string;
                    signature: {
                        r: string;
                        s: string;
                        v: number;
                    };
                };
            };
            status: "cancelled";
        }

    Returns Promise<PlaceOrderResponse>

  • Parameters

    • cancelOrderId: string
    • cancelSignature: string
    • nonce: string
    • accountId: number
    • accountUser: string
    • newOrder: {
          accountId: number;
          accountUser: string;
          createdTimestampUnixMillis: number;
          expiryTimestampUnixMillis: number;
          id: string;
          kind: {
              kind: "market";
          } | {
              args: {
                  limitPrice: BigNumber;
              };
              kind: "limit";
          } | {
              args: {
                  stopLoss?: null | {
                      kind: "position";
                  } | {
                      id: string;
                      kind: "order";
                  };
                  triggerPrice: BigNumber;
              };
              kind: "stopMarket";
          } | {
              args: {
                  limitPrice: BigNumber;
                  triggerPrice: BigNumber;
              };
              kind: "stopLimit";
          } | {
              args: {
                  takeProfit?: null | {
                      kind: "position";
                  } | {
                      id: string;
                      kind: "order";
                  };
                  triggerPrice: BigNumber;
              };
              kind: "limitTrigger";
          } | {
              kind: string;
          };
          lpId: string;
          nonce: string;
          pair: Pair;
          signature: string;
          size: {
              amount: BigNumber;
              unit: "lpc" | "lot";
          };
          status: {
              content: {
                  status: "placed";
              } | {
                  content: {
                      timestampUnixMillis: number;
                      triggerPrice: BigNumber;
                  };
                  status: "triggered";
              };
              status: "open";
          } | {
              content: {
                  price: BigNumber;
                  settlementStatus: {
                      status: "queued";
                  } | {
                      status: "beforeTx";
                  } | {
                      status: "indexing";
                  } | {
                      content: {
                          txHash: string;
                      };
                      status: "settled";
                  };
                  timestampUnixMillis: number;
              };
              status: "filled";
          } | {
              content: {
                  reason: string;
                  timestampUnixMillis: number;
                  userCancellation?: null | {
                      address: string;
                      nonce: string;
                      signature: {
                          r: string;
                          s: string;
                          v: number;
                      };
                  };
              };
              status: "cancelled";
          };
      }
      • accountId: number
      • accountUser: string
      • createdTimestampUnixMillis: number
      • expiryTimestampUnixMillis: number
      • id: string
      • kind: {
            kind: "market";
        } | {
            args: {
                limitPrice: BigNumber;
            };
            kind: "limit";
        } | {
            args: {
                stopLoss?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "stopMarket";
        } | {
            args: {
                limitPrice: BigNumber;
                triggerPrice: BigNumber;
            };
            kind: "stopLimit";
        } | {
            args: {
                takeProfit?: null | {
                    kind: "position";
                } | {
                    id: string;
                    kind: "order";
                };
                triggerPrice: BigNumber;
            };
            kind: "limitTrigger";
        } | {
            kind: string;
        }
      • lpId: string
      • nonce: string
      • pair: Pair
      • signature: string
      • size: {
            amount: BigNumber;
            unit: "lpc" | "lot";
        }
        • amount: BigNumber
        • unit: "lpc" | "lot"
      • status: {
            content: {
                status: "placed";
            } | {
                content: {
                    timestampUnixMillis: number;
                    triggerPrice: BigNumber;
                };
                status: "triggered";
            };
            status: "open";
        } | {
            content: {
                price: BigNumber;
                settlementStatus: {
                    status: "queued";
                } | {
                    status: "beforeTx";
                } | {
                    status: "indexing";
                } | {
                    content: {
                        txHash: string;
                    };
                    status: "settled";
                };
                timestampUnixMillis: number;
            };
            status: "filled";
        } | {
            content: {
                reason: string;
                timestampUnixMillis: number;
                userCancellation?: null | {
                    address: string;
                    nonce: string;
                    signature: {
                        r: string;
                        s: string;
                        v: number;
                    };
                };
            };
            status: "cancelled";
        }

    Returns Promise<ReplaceOrderResponse>

  • Parameters

    • accountId: number
    • liquidityPoolId: string
    • size: {
          amount: BigNumber;
          unit: "lpc" | "lot";
      }
      • amount: BigNumber
      • unit: "lpc" | "lot"
    • pair: Pair
    • accountUser: string
    • signature: string

    Returns Promise<TradeResponse>

  • Parameters

    • amount: string
    • accountId: number
    • accountUser: string
    • tokenAddress: string
    • recipientAddress: string
    • signature: string
    • Optional psmToken: string

    Returns Promise<WithdrawResponse>