Skip to content

✨ Feature: Add streamlined process for finding and cancelling open orders #225

Description

@ericsharma

ℹ Overview

Order Execution for placing an order:

    const execute = composePromise(
        ()=>resOrders,
        (txns)=>_sendTransactions(this.algod, txns),
        (orders)=>{
          resOrders = orders;
          return wallet.connector.sign(orders, wallet?.connector?.sk);
        },
        (o)=>structure(this, o),
    );

Order execution for closing an order:

    const execute = composePromise(
        () => resOrders,
        (txns) => _sendTransactions(this.algod, txns),
        (orders) => {
          resOrders = orders;
          return order.wallet.connector.sign(orders, order.wallet?.connector?.sk);
        },
        (o) => structure(this, o),
    );

First thing to note: For placing an order we use the wallet set on the API. For closing an order we use the wallet set on the order. Why can't we use the wallet set on the API for closing an order?

Right now, the process for finding and cancelling an order can be done in many ways. A rough example below:

  const openOrders = await api.http.dexd.fetchOrders("wallet", order.address)

  const mappedOpenOrders = openOrders.map((order) => {
    return { ...order, wallet: api.wallet }
  })

  await api.closeOrder(mappedOpenOrders[0])

For easier to use canceling we should:

  1. discuss the composition of the closeOrder promise in respect to order.wallet
  2. Expose an easy to use method for finding and cancelling orders.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions