Pact Swap

Get multiple swap quotes based on send amount


Retrieves multiple swap quotes from available market makers based on the amount of source tokens you want to send. This endpoint queries active market maker orders and calculates how much of the destination token you will receive for the specified amount of source tokens. Returns an array of quotes, each containing the expected receive amount (amountTo) and optionally the market maker public key. This is useful when you know exactly how much you want to send and need to compare different market maker rates to see which offers the best return. The quotes are typically sorted by the best rate (highest amountTo for the same amountFrom).

GET
/pactswap_cm/getSwapQuotesByAmountFrom

Query Parameters

fromstring

The source token contract address. This is the L2 contract address (C1 contract) for the token you want to send in the swap.

tostring

The destination token contract address. This is the L2 contract address (C2 contract) for the token you want to receive in the swap.

amountFromnumber

The amount of source tokens you want to send. This is specified in the smallest unit of the source token (e.g., satoshis for BTC, wei for ETH). The endpoint will calculate how much of the destination token you will receive for this amount.

backendUrl?string

Backend URL. Default is https://api-cloud.coinweb.io/wallet. This URL is used to query available market maker orders and calculate swap quotes.

Formaturi
marketMaker?string

Optional filter to get quotes only from a specific market maker. If provided, only quotes from this market maker will be returned. The market maker is identified by their public key (hex string without 0x prefix).

fromType?string

The type of the source token blockchain. Used to determine the blockchain type for the source token (e.g., "btc", "eth", "usdc"). If not provided, the system may attempt to infer it from the contract address.

Value in"eth" | "btc" | "ltc" | "doge" | "bnb" | "pol" | "trx" | "usdt_trx" | "usdt_bnb" | "usdc_bnb" | "usd1_bnb" | "wbtc_bnb" | "usdt_eth" | "wbtc_eth" | "usdc_eth" | "usd1_eth" | "usdt_pol"
toType?string

The type of the destination token blockchain. Used to determine the blockchain type for the destination token (e.g., "btc", "eth", "usdc"). If not provided, the system may attempt to infer it from the contract address.

Value in"eth" | "btc" | "ltc" | "doge" | "bnb" | "pol" | "trx" | "usdt_trx" | "usdt_bnb" | "usdc_bnb" | "usd1_bnb" | "wbtc_bnb" | "usdt_eth" | "wbtc_eth" | "usdc_eth" | "usd1_eth" | "usdt_pol"

Response Body

curl -X GET "https://cwap-api.coinhq.store/pactswap_cm/getSwapQuotesByAmountFrom?from=0x6f20d1802288c90d2a044d3f7afae73fda261b27d85c0e01fdaaf3199b2c0e85&to=0x6f20d1802288c90d2a044d3f7afae73fda261b27d85c0e01fdaaf3199b2c0e85&amountFrom=0&backendUrl=https%3A%2F%2Fapi-cloud.coinweb.io%2Fwallet&marketMaker=020a89e0698443aaf4ecd613317d2fdf90ef73b99244182fc7bb3c6b85f375b876&fromType=eth&toType=eth"
[
  {
    "amountTo": 50000000,
    "marketMaker": "020a89e0698443aaf4ecd613317d2fdf90ef73b99244182fc7bb3c6b85f375b876"
  }
]

Was this documentation helpful? Any suggestions?