### JavaScript Swap Action: Tx Building, Signing, Submission Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation/api-examples Demonstrates how to build a swap transaction payload, send it to the server for processing, sign the resulting transaction, and submit it using DexHunter's API methods. It covers the complete flow from defining swap parameters to receiving the transaction hash. ```javascript const buildSwapPayload = () => { const swapPayload = { buyer_address: userAddress, // The buyer's address token_in: tokenSell?.token_id, // Token being sold token_out: tokenBuy?.token_id, // Token being bought slippage: adjustedSlippage, // The acceptable slippage for the swap amount_in: formatAmount(), // The amount to be swapped tx_optimization: isDexSplitting, // Whether to optimize the swap for multiple DEXes blacklisted_dexes: adjustedDexBlacklist, // The DEXes to be avoided during the swap }; return swapPayload; } ``` ```javascript const sendSwapRequest = async (swapPayload) => { try { const { data: swap } = await server.post('/swap/build', swapPayload); return swap; // Response containing CBOR transaction data } catch (err) { console.error("Error sending swap request:", err); throw new Error("Error sending swap request"); } } ``` ```javascript const signTransaction = async (swap) => { try { const signatures = await api?.signTx(swap?.cbor, true); // Signing the transaction return signatures; } catch (err) { console.error("Error signing transaction:", err); throw new Error("Error signing transaction"); } } ``` ```javascript const submitTransaction = async (signatures, swap) => { try { const { data: sign } = await server.post(`/swap/sign`, { txCbor: swap?.cbor, // The transaction CBOR data signatures, }); // Submit the signed transaction const tx = await api?.submitTx(sign?.cbor); return tx; // The transaction hash after submission } catch (err) { console.error("Error submitting transaction:", err); throw new Error("Error submitting transaction"); } } ``` ```javascript const executeSwap = async () => { const swapPayload = buildSwapPayload(); // Step 1: Build the payload const swap = await sendSwapRequest(swapPayload); // Step 2: Send the swap request to the server const signatures = await signTransaction(swap); // Step 3: Sign the transaction const tx = await submitTransaction(signatures, swap); // Step 4: Submit the signed transaction // You can now handle the transaction result (e.g., showing a success message) console.log("Swap transaction successful with tx hash:", tx); }; ``` -------------------------------- ### Python Swap Script Example Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation/api-examples This section indicates the availability of a sample Python script for performing swaps. The actual code is not embedded but is linked externally, suggesting it's a standalone file for users to download and adapt. ```python # Python script for swap functionality (external link provided in original content) ``` -------------------------------- ### Install DexHunter Swap Library Source: https://dexhunter.gitbook.io/dexhunter-partners/swap-widget/dexhunter-swap-react-library Installs the DexHunter Swap React library using npm. This is the first step to integrate the swap functionality into your React application. ```bash npm i @dexhunterio/swaps ``` -------------------------------- ### DEX Blacklist Array Example Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation Provides an example of a DEX blacklist array used to specify decentralized exchanges to be avoided during a swap operation. This array is typically included in the swap request payload. ```javascript [ "SUNDAESWAPV3", "SPLASH", "MINSWAPV2", "MINSWAP", "AXO", "WINGRIDER", "WINGRIDERV2", "SNEKFUN", "SPECTRUM", "SUNDAESWAP", "VYFI", "MUESLISWAP" ] ``` -------------------------------- ### DEX Blacklist Array Example Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation/api-documentation Provides an example of a DEX blacklist array used to specify decentralized exchanges to be avoided during a swap operation. This array is typically included in the swap request payload. ```javascript [ "SUNDAESWAPV3", "SPLASH", "MINSWAPV2", "MINSWAP", "AXO", "WINGRIDER", "WINGRIDERV2", "SNEKFUN", "SPECTRUM", "SUNDAESWAP", "VYFI", "MUESLISWAP" ] ``` -------------------------------- ### Swap Operation: Build, Sign, and Submit Transaction Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation/api-documentation Illustrates the complete process of executing a swap, from building the swap payload with user-specific details to sending the request, signing the transaction, and finally submitting it. It includes functions for payload creation, server requests, transaction signing, and submission. ```javascript const buildSwapPayload = () => { const swapPayload = { buyer_address: userAddress, // The buyer's address token_in: tokenSell?.token_id, // Token being sold token_out: tokenBuy?.token_id, // Token being bought slippage: adjustedSlippage, // The acceptable slippage for the swap amount_in: formatAmount(), // The amount to be swapped tx_optimization: isDexSplitting, // Whether to optimize the swap for multiple DEXes blacklisted_dexes: adjustedDexBlacklist, // The DEXes to be avoided during the swap }; return swapPayload; } ``` ```javascript const sendSwapRequest = async (swapPayload) => { try { const { data: swap } = await server.post(routingMapping.swap, swapPayload); return swap; // Response containing CBOR transaction data } catch (err) { console.error("Error sending swap request:", err); throw new Error("Error sending swap request"); } } ``` ```javascript const signTransaction = async (swap) => { try { const signatures = await api?.signTx(swap?.cbor, true); // Signing the transaction return signatures; } catch (err) { console.error("Error signing transaction:", err); throw new Error("Error signing transaction"); } } ``` ```javascript const submitTransaction = async (signatures, swap) => { try { const { data: sign } = await server.post(`/swap/sign`, { txCbor: swap?.cbor, // The transaction CBOR data signatures, }); // Submit the signed transaction const tx = await api?.submitTx(sign?.cbor); return tx; // The transaction hash after submission } catch (err) { console.error("Error submitting transaction:", err); throw new Error("Error submitting transaction"); } } ``` ```javascript const executeSwap = async () => { const swapPayload = buildSwapPayload(); // Step 1: Build the payload const swap = await sendSwapRequest(swapPayload); // Step 2: Send the swap request to the server const signatures = await signTransaction(swap); // Step 3: Sign the transaction const tx = await submitTransaction(signatures, swap); // Step 4: Submit the signed transaction // You can now handle the transaction result (e.g., showing a success message) console.log("Swap transaction successful with tx hash:", tx); }; ``` -------------------------------- ### Initiate and Submit Swap Transaction Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation Manages the swap process by building a transaction, signing it, and submitting it to the blockchain. The build step prepares the transaction data, the sign step requires wallet signatures, and submission is typically handled by the user's wallet. ```APIDOC POST /swap/build Request Payload: { "buyer_address": "user_address", // User's wallet address "token_in": "token_id_for_selling", // Token being sold "token_out": "token_id_for_buying", // Token being bought "slippage": 0.5, // Maximum slippage allowed "amount_in": 1000, // Amount of token_in to sell "tx_optimization": true, // Optimize across multiple DEXes "blacklisted_dexes": ["DEX1", "DEX2"] // DEXes to avoid } Response: { "cbor": "transaction_cbor_data", // CBOR encoded transaction data "status": "pending" // Initial status of the swap } POST /swap/sign Request Payload: { "txCbor": "transaction_cbor_data", // CBOR data from /swap/build "signatures": ["signature_1", "signature_2"] // Signatures from wallet } Response: { "cbor": "signed_cbor_data", // Signed transaction data "strat_id": "strategy_id" // Optional strategy identifier } Submit Signed Transaction (User Action): User submits the signed CBOR data via their wallet or library. Example (TypeScript): const tx = await api.submitTx(sign.cbor); // Where 'api' is a cip30 wallet instance ``` -------------------------------- ### Initiate and Submit Swap Transaction Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation/api-documentation Manages the swap process by building a transaction, signing it, and submitting it to the blockchain. The build step prepares the transaction data, the sign step requires wallet signatures, and submission is typically handled by the user's wallet. ```APIDOC POST /swap/build Request Payload: { "buyer_address": "user_address", // User's wallet address "token_in": "token_id_for_selling", // Token being sold "token_out": "token_id_for_buying", // Token being bought "slippage": 0.5, // Maximum slippage allowed "amount_in": 1000, // Amount of token_in to sell "tx_optimization": true, // Optimize across multiple DEXes "blacklisted_dexes": ["DEX1", "DEX2"] // DEXes to avoid } Response: { "cbor": "transaction_cbor_data", // CBOR encoded transaction data "status": "pending" // Initial status of the swap } POST /swap/sign Request Payload: { "txCbor": "transaction_cbor_data", // CBOR data from /swap/build "signatures": ["signature_1", "signature_2"] // Signatures from wallet } Response: { "cbor": "signed_cbor_data", // Signed transaction data "strat_id": "strategy_id" // Optional strategy identifier } Submit Signed Transaction (User Action): User submits the signed CBOR data via their wallet or library. Example (TypeScript): const tx = await api.submitTx(sign.cbor); // Where 'api' is a cip30 wallet instance ``` -------------------------------- ### Swap Operation: Build, Sign, and Submit Transaction Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation Illustrates the complete process of executing a swap, from building the swap payload with user-specific details to sending the request, signing the transaction, and finally submitting it. It includes functions for payload creation, server requests, transaction signing, and submission. ```javascript const buildSwapPayload = () => { const swapPayload = { buyer_address: userAddress, // The buyer's address token_in: tokenSell?.token_id, // Token being sold token_out: tokenBuy?.token_id, // Token being bought slippage: adjustedSlippage, // The acceptable slippage for the swap amount_in: formatAmount(), // The amount to be swapped tx_optimization: isDexSplitting, // Whether to optimize the swap for multiple DEXes blacklisted_dexes: adjustedDexBlacklist, // The DEXes to be avoided during the swap }; return swapPayload; } ``` ```javascript const sendSwapRequest = async (swapPayload) => { try { const { data: swap } = await server.post(routingMapping.swap, swapPayload); return swap; // Response containing CBOR transaction data } catch (err) { console.error("Error sending swap request:", err); throw new Error("Error sending swap request"); } } ``` ```javascript const signTransaction = async (swap) => { try { const signatures = await api?.signTx(swap?.cbor, true); // Signing the transaction return signatures; } catch (err) { console.error("Error signing transaction:", err); throw new Error("Error signing transaction"); } } ``` ```javascript const submitTransaction = async (signatures, swap) => { try { const { data: sign } = await server.post(`/swap/sign`, { txCbor: swap?.cbor, // The transaction CBOR data signatures, }); // Submit the signed transaction const tx = await api?.submitTx(sign?.cbor); return tx; // The transaction hash after submission } catch (err) { console.error("Error submitting transaction:", err); throw new Error("Error submitting transaction"); } } ``` ```javascript const executeSwap = async () => { const swapPayload = buildSwapPayload(); // Step 1: Build the payload const swap = await sendSwapRequest(swapPayload); // Step 2: Send the swap request to the server const signatures = await signTransaction(swap); // Step 3: Sign the transaction const tx = await submitTransaction(signatures, swap); // Step 4: Submit the signed transaction // You can now handle the transaction result (e.g., showing a success message) console.log("Swap transaction successful with tx hash:", tx); }; ``` -------------------------------- ### Estimate Swap Details Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation/api-documentation Estimates swap details including input/output amounts, routes, and bonuses for a given trade. Requires specifying input/output tokens, amounts, slippage tolerance, and optionally blacklisted DEXes. ```APIDOC POST /estimate Request Payload: { "amount_in": 1000, // Amount being sold (in base units) "token_in": "token_id_for_selling", // ID of the token being sold "token_out": "token_id_for_buying", // ID of the token being bought "slippage": 0.5, // Slippage tolerance (e.g., 0.5 for 0.5%) "blacklisted_dexes": ["DEX1", "DEX2"] // Optional list of DEXes to avoid } Response: { "total_input_without_slippage": 1000, "total_output_without_slippage": 950, "possible_routes": [...], // Array of potential swap routes "bonus_output": "+5 ADA" // Bonus output for the swap, if applicable } ``` -------------------------------- ### Estimate Swap Details Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation Estimates swap details including input/output amounts, routes, and bonuses for a given trade. Requires specifying input/output tokens, amounts, slippage tolerance, and optionally blacklisted DEXes. ```APIDOC POST /estimate Request Payload: { "amount_in": 1000, // Amount being sold (in base units) "token_in": "token_id_for_selling", // ID of the token being sold "token_out": "token_id_for_buying", // ID of the token being bought "slippage": 0.5, // Slippage tolerance (e.g., 0.5 for 0.5%) "blacklisted_dexes": ["DEX1", "DEX2"] // Optional list of DEXes to avoid } Response: { "total_input_without_slippage": 1000, "total_output_without_slippage": 950, "possible_routes": [...], // Array of potential swap routes "bonus_output": "+5 ADA" // Bonus output for the swap, if applicable } ``` -------------------------------- ### DexHunter API: Token and Pool Endpoints Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation/api-documentation Provides access to token lists, liquidity pool data, and individual token information. Requires an X-Partner-Id header with an API Key. Base URL is https://api-us.dexhunterv3.app. ```APIDOC Base API URL: https://api-us.dexhunterv3.app/ Required Header: X-Partner-Id: 1. Token List (Verified and Unverified Tokens) Fetches a list of verified or unverified tokens based on search criteria. Endpoint: GET /swap/tokens Parameters: - query: The search input string for token filtering. - verified: Boolean to specify whether to fetch verified (true) or unverified (false) tokens. Example Request: GET /swap/tokens?query=name&verified=true Response Example: [ { "token_id": "279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f534e454b", "ticker": "ADA", "token_ascii": "Cardano", "is_verified": true }, { "token_id": "f87f9a14bb2c3dfbbacccd631d927a3f534e454b", "ticker": "TEST", "token_ascii": "Test Token", "is_verified": false } ] 2. Pools (Liquidity Pool Information) Fetches liquidity pool data for a given token pair. Endpoint: GET /stats/pools/{tokenIdSell}/{tokenIdBuy} Parameters: - tokenIdSell: The ID of the token being sold. - tokenIdBuy: The ID of the token being purchased. Example Request: GET /stats/pools/ADA/279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f534e454b Response Example: { "pool_id": "pool1xyz...", "token_in": "ADA", "token_out": "USDT", "liquidity": { "total_in": 100000, "total_out": 95000 }, "pool_fee": 0.003, "price": 1.05 } 3. Token Information Fetches details for a specific token, including verification status and metadata. Endpoint: GET /swap/token/{tokenId} Parameters: - tokenId: The unique ID of the token. Example Request: GET /swap/token/279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f534e454b Response Example: { "token_id": "279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f534e454b", "ticker": "ADA", "token_ascii": "Cardano", "is_verified": true, "total_supply": 45000000000, "decimals": 6 } Error Handling: If a token is not found, a fallback mechanism will attempt to parse the token details from the ID: { "token_id": "unverified_token_id", "token_policy": "policy_id_part_of_token_id", "token_ascii": "Parsed ASCII", "is_verified": false, "ticker": "Parsed Ticker" } ``` -------------------------------- ### DexHunter API: Token and Pool Endpoints Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation Provides access to token lists, liquidity pool data, and individual token information. Requires an X-Partner-Id header with an API Key. Base URL is https://api-us.dexhunterv3.app. ```APIDOC Base API URL: https://api-us.dexhunterv3.app/ Required Header: X-Partner-Id: 1. Token List (Verified and Unverified Tokens) Fetches a list of verified or unverified tokens based on search criteria. Endpoint: GET /swap/tokens Parameters: - query: The search input string for token filtering. - verified: Boolean to specify whether to fetch verified (true) or unverified (false) tokens. Example Request: GET /swap/tokens?query=name&verified=true Response Example: [ { "token_id": "279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f534e454b", "ticker": "ADA", "token_ascii": "Cardano", "is_verified": true }, { "token_id": "f87f9a14bb2c3dfbbacccd631d927a3f534e454b", "ticker": "TEST", "token_ascii": "Test Token", "is_verified": false } ] 2. Pools (Liquidity Pool Information) Fetches liquidity pool data for a given token pair. Endpoint: GET /stats/pools/{tokenIdSell}/{tokenIdBuy} Parameters: - tokenIdSell: The ID of the token being sold. - tokenIdBuy: The ID of the token being purchased. Example Request: GET /stats/pools/ADA/279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f534e454b Response Example: { "pool_id": "pool1xyz...", "token_in": "ADA", "token_out": "USDT", "liquidity": { "total_in": 100000, "total_out": 95000 }, "pool_fee": 0.003, "price": 1.05 } 3. Token Information Fetches details for a specific token, including verification status and metadata. Endpoint: GET /swap/token/{tokenId} Parameters: - tokenId: The unique ID of the token. Example Request: GET /swap/token/279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f534e454b Response Example: { "token_id": "279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f534e454b", "ticker": "ADA", "token_ascii": "Cardano", "is_verified": true, "total_supply": 45000000000, "decimals": 6 } Error Handling: If a token is not found, a fallback mechanism will attempt to parse the token details from the ID: { "token_id": "unverified_token_id", "token_policy": "policy_id_part_of_token_id", "token_ascii": "Parsed ASCII", "is_verified": false, "ticker": "Parsed Ticker" } ``` -------------------------------- ### Swap Operation API Endpoints Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation/api-documentation Details the API endpoints involved in the swap operation. This includes initiating a swap request and submitting a signed transaction. It outlines the HTTP methods, paths, and expected data flow. ```APIDOC POST /swap Description: Initiates a swap operation by sending the swap payload to the server. Request Body: - buyer_address: string (The buyer's address) - token_in: string (The token being sold) - token_out: string (The token being bought) - slippage: number (The acceptable slippage for the swap) - amount_in: string (The amount to be swapped) - tx_optimization: boolean (Whether to optimize the swap for multiple DEXes) - blacklisted_dexes: array of strings (The DEXes to be avoided during the swap) Response: - swap: object (Contains CBOR transaction data and other relevant information) POST /swap/sign Description: Submits the signed transaction to the network. Request Body: - txCbor: string (The transaction CBOR data) - signatures: array (The signatures for the transaction) Response: - cbor: string (The CBOR representation of the signed transaction, ready for submission) Submit Transaction (via wallet or node) Description: Submits the final signed transaction to the blockchain network. Method: - api.submitTx(signedTxCbor) Parameters: - signedTxCbor: string (The CBOR data of the signed transaction) Returns: - string (The transaction hash after successful submission) ``` -------------------------------- ### Swap Operation API Endpoints Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation Details the API endpoints involved in the swap operation. This includes initiating a swap request and submitting a signed transaction. It outlines the HTTP methods, paths, and expected data flow. ```APIDOC POST /swap Description: Initiates a swap operation by sending the swap payload to the server. Request Body: - buyer_address: string (The buyer's address) - token_in: string (The token being sold) - token_out: string (The token being bought) - slippage: number (The acceptable slippage for the swap) - amount_in: string (The amount to be swapped) - tx_optimization: boolean (Whether to optimize the swap for multiple DEXes) - blacklisted_dexes: array of strings (The DEXes to be avoided during the swap) Response: - swap: object (Contains CBOR transaction data and other relevant information) POST /swap/sign Description: Submits the signed transaction to the network. Request Body: - txCbor: string (The transaction CBOR data) - signatures: array (The signatures for the transaction) Response: - cbor: string (The CBOR representation of the signed transaction, ready for submission) Submit Transaction (via wallet or node) Description: Submits the final signed transaction to the blockchain network. Method: - api.submitTx(signedTxCbor) Parameters: - signedTxCbor: string (The CBOR data of the signed transaction) Returns: - string (The transaction hash after successful submission) ``` -------------------------------- ### Dexhunter Swap Transaction Flow Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation/api-documentation This entry describes the sequence of operations for a swap transaction. It highlights key functions and an API method used in the process. No actual code is provided, only a conceptual explanation. ```APIDOC Flow: Swap Transaction Execution 1. Build Swap Payload: - Function: `buildSwapPayload` - Purpose: Creates the necessary data payload for a swap request, including tokens, slippage, and blacklisted DEXes. 2. Send Swap Request: - Function: `sendSwapRequest` - Purpose: Sends the swap request to the server. - Output: CBOR transaction data (`swap.cbor`). 3. Sign Transaction: - Function: `signTransaction` - API Method Used: `api.signTx` - Purpose: Signs the transaction to ensure it can be submitted on the blockchain. 4. Submit Transaction: - Function: `submitTransaction` - Purpose: Sends the signed transaction data to the server for submission to the blockchain. - Output: Transaction hash (`tx`). Overall Process: Ensures the complete execution of a swap operation from request creation to final transaction submission. ``` -------------------------------- ### Dexhunter Swap Transaction Flow Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation This entry describes the sequence of operations for a swap transaction. It highlights key functions and an API method used in the process. No actual code is provided, only a conceptual explanation. ```APIDOC Flow: Swap Transaction Execution 1. Build Swap Payload: - Function: `buildSwapPayload` - Purpose: Creates the necessary data payload for a swap request, including tokens, slippage, and blacklisted DEXes. 2. Send Swap Request: - Function: `sendSwapRequest` - Purpose: Sends the swap request to the server. - Output: CBOR transaction data (`swap.cbor`). 3. Sign Transaction: - Function: `signTransaction` - API Method Used: `api.signTx` - Purpose: Signs the transaction to ensure it can be submitted on the blockchain. 4. Submit Transaction: - Function: `submitTransaction` - Purpose: Sends the signed transaction data to the server for submission to the blockchain. - Output: Transaction hash (`tx`). Overall Process: Ensures the complete execution of a swap operation from request creation to final transaction submission. ``` -------------------------------- ### DexHunter Swap React Library Versioning Source: https://dexhunter.gitbook.io/dexhunter-partners/swap-widget Information regarding version compatibility for the DexHunter Swap React Library based on the React version used in your project. ```APIDOC DexHunterSwapReactLibrary: Versioning: - For React 19 users: Use library version 183 and higher. - For React 18 and below: Use library version 182 as the last supported version. ``` -------------------------------- ### DexHunter Swap React Library Versioning Source: https://dexhunter.gitbook.io/dexhunter-partners/swap-widget/swap-integration Information regarding version compatibility for the DexHunter Swap React Library based on the React version used in your project. ```APIDOC DexHunterSwapReactLibrary: Versioning: - For React 19 users: Use library version 183 and higher. - For React 18 and below: Use library version 182 as the last supported version. ``` -------------------------------- ### Use DexHunter Swap Component Source: https://dexhunter.gitbook.io/dexhunter-partners/swap-widget/dexhunter-swap-react-library Renders the DexHunter Swap component within your React application. It requires a partnerName and partnerCode, and accepts additional customization props. ```javascript ``` -------------------------------- ### DexHunter Swap Widget Customization Settings Source: https://dexhunter.gitbook.io/dexhunter-partners/swap-widget/swap-customizations Configuration parameters for customizing the DexHunter Swap Widget's appearance and behavior. These settings can be passed to the widget to tailor the user experience. ```APIDOC DexHunterSwapWidgetSettings: description: Settings to customize the DexHunter Swap Widget. parameters: defaultToken: required: false type: string description: Pre-selects a default token. width: required: false type: string (e.g., 'px' or '%') description: Sets the width of the widget. height: required: false type: string (e.g., 'px' or '%') description: Sets the height of the widget. theme: required: false type: enum ('dark', 'light') default: 'dark' description: Sets the visual theme of the widget. orderTypes: required: false type: array of strings default: ['SWAP', 'LIMIT'] description: Specifies the types of orders to be supported. supportedTokens: required: false type: array of token IDs description: A list of token IDs that the widget should allow users to search and select. partnerName: required: true type: string description: The name of the partner integrating the widget. partnerCode: required: true type: string description: A unique code identifying the partner. colors: required: false type: object description: Customizes specific color elements of the widget. Supported keys include `mainText`, `subText`, `background`, `containers`, `buttonText`, `accent`. className: required: false type: string description: Allows adding custom CSS classes for further styling. style: required: false type: string description: Allows applying inline styles to the widget container. ``` -------------------------------- ### Fetch Average Price for Token Pair Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation Retrieves the average exchange rate for a specified token pair. This is useful for understanding current market prices before executing a trade. Requires the IDs of the tokens to be bought and sold. ```APIDOC GET /swap/averagePrice/{sellTokenId}/{buyTokenId} Example Request Path: /swap/averagePrice/ADA/279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f534e454b Parameters: sellTokenId: The ID of the token you are selling (e.g., ADA). buyTokenId: The ID of the token you want to buy (e.g., USDT). Response: { "price_ba": 1.234, // Average price (1 sellToken = X buyToken) "price_ab": 1.2 // Average price (1 buyToken = X sellToken) } ``` -------------------------------- ### Fetch Average Price for Token Pair Source: https://dexhunter.gitbook.io/dexhunter-partners/api-documentation/api-documentation Retrieves the average exchange rate for a specified token pair. This is useful for understanding current market prices before executing a trade. Requires the IDs of the tokens to be bought and sold. ```APIDOC GET /swap/averagePrice/{sellTokenId}/{buyTokenId} Example Request Path: /swap/averagePrice/ADA/279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f534e454b Parameters: sellTokenId: The ID of the token you are selling (e.g., ADA). buyTokenId: The ID of the token you want to buy (e.g., USDT). Response: { "price_ba": 1.234, // Average price (1 sellToken = X buyToken) "price_ab": 1.2 // Average price (1 buyToken = X sellToken) } ``` -------------------------------- ### Import DexHunter Swap Library and Styles Source: https://dexhunter.gitbook.io/dexhunter-partners/swap-widget/dexhunter-swap-react-library Imports the Swap component and its associated CSS styles into your React application. Ensure these imports are placed at the top level of your component or application entry point. ```javascript import Swap from '@dexhunterio/swaps' import '@dexhunterio/swaps/lib/assets/style.css' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.