Quote

API details

Provide quotes for exchanges so that the returned quote value can be used to submit the actual swap request.

Quote exchange rate

get

Quotes the exchange rate between two assets.

Query parameters
SourceChainIdstringOptional

The blockchain where the source asset currently resides (e.g., Bitcoin, Ethereum, Kaspa).

SourceAssetTypestringOptional

The type of the source asset (Native, SPL, ERC20, KRC20 etc.). Determines how the asset is identified and processed.

SourceAssetstringOptional

The identifier for the source asset - either a contract address for tokens or a ticker symbol. Should be null when SourceAssetType is Native (e.g., BTC, ETH, KAS).

SourceVolumestring · stringOptional

The amount of source asset to be exchanged/transferred, expressed in the smallest unit of the asset (e.g., satoshi for Bitcoin, wei for Ethereum).

TargetChainIdstringOptional

The destination blockchain for the exchange operation. When null, the system will use the same chain as the source (intra-chain operation).

TargetAssetTypestringOptional

The type of the target asset to receive. When null, the system will use the same asset type as the source.

TargetAssetstringOptional

The identifier for the target asset - either a contract address for tokens or a ticker symbol. Should be null when TargetAssetType is Native (e.g., BTC, ETH, KAS).

Responses
200
OK
get
GET /v1/quote HTTP/1.1
Host: testnetbrokerapi.hibit.app
Accept: */*
{
  "code": 1,
  "message": "text",
  "data": {
    "targetChainId": "text",
    "targetVolume": "text",
    "receiveVolume": "text",
    "gasFee": "text",
    "brokerFee": "text",
    "brokerFeeRate": 1,
    "priceImpact": 1,
    "slippage": 1,
    "targetVolumeInUsd": 1
  }
}

Code example

import { brokerClient } from '@delandlabs/hibit-sdk';

const options = {
  network: HibitNetwork.Testnet
};
brokerClient.setOptions(options);

const req: QuoteInput = {
        sourceChainId:  new ChainId(Chain.Kaspa, ChainNetwork.KaspaTestNet)
        sourceAssetType: ChainAssetType.Native, 
        sourceVolume: BigInt(input.sourceVolume),
        // targetChainId: new ChainId(Chain.Ethereum, ChainNetwork.BscTest), // undefined means same as source chain id
        targetAssetType: ChainAssetType.ERC20,
        targetAsset: "erc20_token_contract_address"
      };
const res = await brokerClient.quote(req);

SDK

Source code https://github.com/Deland-Labs/hibit-sdk

Last updated