A representation of a Trade, which trades an amount of an Asset to another Asset on a Network. The fee is assumed to be paid in the native Asset of the Network.

Constructors

  • Trades should be created through Wallet.trade or Address.trade.

    Parameters

    • model: Trade

      The underlying Trade object.

    Returns Trade

    Throws

    • If the Trade model is empty.

Properties

approveTransaction?: Transaction
model: Trade
transaction?: Transaction

Methods

  • Broadcasts the Trade to the Network.

    Returns Promise<Trade>

    The Trade object

    Throws

    if the API request to broadcast a Trade fails.

  • Returns the Address ID of the Trade.

    Returns string

    The Address ID.

  • Returns the amount of the from asset for the Trade.

    Returns Decimal

    The amount of the from asset.

  • Returns the From Asset ID of the Trade.

    Returns string

    The From Asset ID.

  • Returns the Network ID of the Trade.

    Returns string

    The Network ID.

  • Returns the amount of the to asset for the Trade.

    Returns Decimal

    The amount of the to asset.

  • Returns the To Asset ID of the Trade.

    Returns string

    The To Asset ID.

  • Returns the Wallet ID of the Trade.

    Returns string

    The Wallet ID.

  • Reloads the Trade model with the latest version from the server side.

    Returns Promise<Trade>

    The most recent version of Trade from the server.

  • Resets the trade model with the specified data from the server.

    Parameters

    • model: Trade

      The Trade model

    Returns Trade

    The updated Trade object

  • Signs the Trade with the provided key. This signs the transfer transaction and will sign the approval transaction if present.

    Parameters

    • key: Wallet

      The key to sign the Transfer with

    Returns Promise<void>

  • Returns a String representation of the Trade.

    Returns string

    A String representation of the Trade.

  • Waits until the Trade is completed or failed by polling the Network at the given interval. Raises an error if the Trade takes longer than the given timeout.

    Parameters

    • options: {
          intervalSeconds: undefined | number;
          timeoutSeconds: undefined | number;
      } = {}

      The options to configure the wait function.

      • intervalSeconds: undefined | number

        The interval at which to poll the Network, in seconds

      • timeoutSeconds: undefined | number

        The maximum amount of time to wait for the Trade to complete, in seconds

    Returns Promise<Trade>

    The completed Trade object.

    Throws

    If the Trade takes longer than the given timeout.

    Throws

    If the request fails.