API (Order-Router)

Haystack Order Router API specifications for fetching quotes and executing swaps.

Fetch the Haystack quote for a given swap.

GET https://hayrouter.txnlab.dev/api/fetchQuote

Path Parameters

Name
Type
Description

chain

String

Chain for the given swap, either mainnet or testnet. The default is mainnet.

algodUri*

String

Algod client URI.

algodToken*

String

Algod client token.

algodPort*

String

Algod port.

amount*

Integer

Swap amount. The input swap amount, if the swap type is fixed-input, or the expected output swap amount, if the swap type is fixed-output. The amount is expected to be in base units (not normalized to account for decimals). Eg. an amount of 1000001 for asset ALGO would equate to 1.000001 ALGO (since ALGO is displayed with 6 decimals).

type*

String

Swap type. Either fixed-input or fixed-output.

fromASAID*

Integer

The asset ID of the input asset for the swap (ALGO ID is 0).

toASAID*

Integer

The asset ID of the output asset for the swap (ALGO ID is 0).

apiKey*

String

API key. To obtain a custom API key, reach out to support@txnlab.devenvelope.

disabledProtocols

String

List of protocols (comma-delimitied) to disable for routing. Note: Humble is always disabled at this point as it no longer seems to be functioning/maintained.

Tinyman isn't composable and should probably be disabled in most cases as well. Valid protocol names are: - Humble - Tinyman - TinymanV2 - Algofi - Pact - Folks - TAlgo

maxDepth

Integer

Path search depth between 1-4.

maxGroupSize

Integer

The max allowable size of the transaction group for the quote to be generated.

optIn

Boolean

set to true to have the returned transactions from fetchExecuteSwapTxns automatically include an opt-in transaction to sign.

Whether or not opt-in is necessary is up to the caller to determine. Reduces the group size to allow room.

referrerAddress

String

Algorand address of the referrer, who will receive 25% of the swap fees. The default is the order protocol treasury address.

feeBps

Integer

Output fee basis points charged on output, split 75% / 25% between treasury and referrer. Must be at least 10 (the default, but can be set as high 300).

atomicOnly

String

Guarantee that the swap can be executed using a single transaction group. Either true or false. The default is true.

Fetch the transaction group for a given Haystack quote.

POST https://hayrouter.txnlab.dev/api/fetchExecuteSwapTxns

The transaction group does not handle any required asset or application opt-ins, or redeeming excess amounts (eg. from Tinyman).

Request Body

Name
Type
Description

address*

String

Algorand address of swapper.

txnPayloadJSON*

Object

Txn payload from the Haystack quote (value at txnPayload key)

slippage*

Float

Slippage threshold percentage for the swap (the swap will fail if the prices changes unfavorable by more than this percentage).

apiKey*

String

API key (required). To obtain a custom API key with a custom rate limit, reach out to support@txnlab.devenvelope.

Last updated