### Integrations Source: https://docs.kyberswap.com/reference Guides and information for integrating with KyberSwap, covering getting started, use cases, integration types, smart contracts, and specific libraries. ```APIDOC ## Integrations ### Description Resources for developers looking to integrate with the KyberSwap protocol. ### Method GET ### Endpoint - /reference/legacy/integrations/getting-started.md - /reference/legacy/integrations/use-cases.md - /reference/legacy/integrations/integration-types.md - /reference/legacy/integrations/smart-contracts.md - /reference/legacy/integrations/ethers-js.md - /reference/legacy/integrations/slippage-rate-protection.md - /reference/legacy/integrations/price-feed-security.md - /reference/legacy/integrations/contract-events.md - /reference/legacy/integrations/platform-fees.md ### Parameters (Specific parameters depend on the integration guide) ### Request Example (Example request depends on the integration guide) ### Response (Documentation and code examples for various integration aspects) ``` -------------------------------- ### Install KyberSwap Liquidity Widget using npm Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-liquidity-widget/integrating-the-kyberswap-liquidity-widget Install the KyberSwap Liquidity Widget library using npm. This command fetches and installs the package, making its components available for use in your project. ```bash npm i @kyberswap/liquidity-widgets ``` -------------------------------- ### Install KyberSwap Liquidity Widget using Yarn Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-liquidity-widget/integrating-the-kyberswap-liquidity-widget Install the KyberSwap Liquidity Widget library using Yarn. This command fetches and installs the package, making its components available for use in your project. ```bash yarn add @kyberswap/liquidity-widgets ``` -------------------------------- ### Query Swap Rates with Aggregator API (JavaScript) Source: https://docs.kyberswap.com/kyberswap-solutions This JavaScript example demonstrates how to query the KyberSwap Aggregator API to get superior swap rates. It involves making an HTTP GET request to the API endpoint with relevant parameters such as token addresses and amounts. ```javascript async function getSwapRates(tokenIn, tokenOut, amountIn) { const apiUrl = 'https://aggregator-api.kyberswap.com/routes/simulate'; const params = { tokenIn: tokenIn, // e.g., '0x0000000000000000000000000000000000000001' for native token tokenOut: tokenOut, // e.g., '0x...' amountIn: amountIn.toString(), source: 'KyberSwap' }; const url = `${apiUrl}?${new URLSearchParams(params).toString()}`; try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); return data.data.bestRoute; } catch (error) { console.error('Error fetching swap rates:', error); return null; } } // Example usage: // const tokenInAddress = '0x...'; // Address of input token // const tokenOutAddress = '0x...'; // Address of output token // const amount = 1000000000000000000; // 1 token in Wei // getSwapRates(tokenInAddress, tokenOutAddress, amount).then(route => { // if (route) { // console.log('Best route:', route); // console.log('Estimated amount out:', route.amountOut); // } // }); ``` -------------------------------- ### Install KyberSwap Widget using npm Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-widget/developer-guides/integrating-the-kyberswap-widget Installs the KyberSwap widgets library using npm. This is the first step to integrate the swap widget into your application. ```bash npm i @kyberswap/widgets ``` -------------------------------- ### Install KyberSwap Widget using Yarn Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-widget/developer-guides/integrating-the-kyberswap-widget Installs the KyberSwap widgets library using Yarn. This is an alternative method for integrating the swap widget into your application. ```bash yarn add @kyberswap/widgets ``` -------------------------------- ### KyberSwap Widget Integration Guide Source: https://docs.kyberswap.com/kyberswap-solutions Guides on integrating the KyberSwap Widget into your application. This includes basic integration and customization options. The widget provides superior rates with minimal code. ```javascript import { KyberSwapWidget } from '@kyberswap/widget'; // Initialize the widget with your configuration KyberSwapWidget.init({ rpcUrl: 'YOUR_RPC_URL', tokenList: 'YOUR_TOKEN_LIST_URL', // ... other configuration options }); // Render the widget in your application KyberSwapWidget.render({ containerId: 'kyberswap-widget-container', // ... widget specific options }); ``` -------------------------------- ### Create Order(s) API Source: https://docs.kyberswap.com/kyberswap-solutions/limit-order/limit-order-api-specification/maker-apis This section details the 'Create Order(s)' endpoint for the KyberSwap Maker API. It provides a link to a developer guide with sequence diagrams and TypeScript examples. ```APIDOC ## POST /orders ### Description Allows users to create limit orders on the KyberSwap platform. Refer to the developer guide for detailed instructions and examples. ### Method POST ### Endpoint /orders ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body (Refer to developer guide for specific request body structure and fields) ### Request Example (Refer to developer guide for TypeScript example) ### Response #### Success Response (201 Created) (Details of the created order, refer to developer guide) #### Response Example (Refer to developer guide for response example) ``` -------------------------------- ### GET /api/v1/create/route Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-zap-as-a-service/kyberswap-zap-as-a-service-zaas-api/zaas-grpc-api Retrieves the best zap-create route. ```APIDOC ## GET /api/v1/create/route ### Description Retrieves the best zap-create route. ### Method GET ### Endpoint /api/v1/create/route ### Parameters #### Query Parameters - **dex** (string) - Required - The decentralized exchange to use for the zap. - **pool** (string) - Required - The pool to create, typically a comma-separated list of token addresses. - **zap_in** (string) - Required - Zap-in parameters. - **X-Client-Id** (string) - Optional - Client Id for request identification. - **X-Request-Id** (string) - Optional - Request Id for tracking. ### Response #### Success Response (200) - **code** (int32) - gRPC error code. - **message** (string) - gRPC error message. - **data** (object) - Response data containing route information. - **request_id** (string) - Request trace ID. #### Response Example ```json { "code": 0, "message": "OK", "data": { "route": "encodedRouteData" }, "request_id": "trace-id-456" } ``` ``` -------------------------------- ### Get Route Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-aggregator/aggregator-api-specification/evm-swaps Retrieves the optimal route for a token swap on KyberSwap. ```APIDOC ## GET /api/v1/route ### Description This endpoint calculates and returns the most efficient route for swapping one token to another on the KyberSwap network, considering various liquidity pools and potential slippage. ### Method GET ### Endpoint /api/v1/route ### Parameters #### Query Parameters - **tokenIn** (string) - Required - The address of the input token. - **tokenOut** (string) - Required - The address of the output token. - **amountIn** (string) - Required - The amount of the input token to be swapped. - **recipient** (string) - Optional - The address to receive the output tokens. - **slippageTolerance** (string) - Optional - The maximum acceptable slippage percentage. ### Response #### Success Response (200) - **route** (object) - An object containing details about the optimal route. - **pools** (array) - A list of pools involved in the route. - **tokenAmountOut** (string) - The estimated amount of the output token. - **gas** (string) - The estimated gas cost for the transaction. #### Response Example ```json { "route": { "pools": [ { "address": "0x...", "tokenIn": "0x...", "tokenOut": "0x...", "reserveIn": "1000000000000000000", "reserveOut": "500000000000000000" } ], "tokenAmountOut": "450000000000000000", "gas": "100000000000000" } } ``` ``` -------------------------------- ### Reserves Management Source: https://docs.kyberswap.com/reference Documentation for managing reserves on KyberSwap, including getting started, development guides for different reserve types, and operational details. ```APIDOC ## Reserves Management ### Description Guides and information for creating, managing, and operating reserves on the KyberSwap network. ### Method GET ### Endpoint - /reference/legacy/reserves/getting-started.md - /reference/legacy/reserves/development-guides.md - /reference/legacy/reserves/operations.md ### Parameters (Specific parameters depend on the reserve type or operation) ### Request Example (Example request depends on the reserve type or operation) ### Response (Documentation on reserve creation, development, and operational procedures) ``` -------------------------------- ### POST /GetRoute (Zap Migrate) Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-zap-as-a-service/kyberswap-zap-as-a-service-zaas-api Fetches the best zap route for migrating an existing liquidity position to a new one. ```APIDOC ## POST /GetRoute (Zap Migrate) ### Description Fetches the best zap route for migrating an existing liquidity position to a new one. Similar to Zap In, this API helps preview the migration results. ### Method POST ### Endpoint /GetRoute ### Parameters #### Header Parameters - **X-Client-ID** (string) - Optional - Client ID for easier technical support and traffic observability. #### Request Body - **dex** (string) - Required - The decentralized exchange to migrate from and to. - **fromPool** (object) - Required - Details of the source pool. - **token0** (string) - Required - Address of token 0 in the source pool. - **token1** (string) - Required - Address of token 1 in the source pool. - **feeTier** (number) - Required - The fee tier of the source pool. - **toPool** (object) - Required - Details of the destination pool. - **token0** (string) - Required - Address of token 0 in the destination pool. - **token1** (string) - Required - Address of token 1 in the destination pool. - **feeTier** (number) - Required - The fee tier of the destination pool. - **fromPosition** (object) - Required - Details of the position to migrate. - **id** (string) - Required - The position ID. - **toPosition** (object) - Required - Details of the target position. - **lowerTick** (number) - Required - The lower tick of the target position. - **upperTick** (number) - Required - The upper tick of the target position. - **slippageTolerance** (number) - Required - Slippage tolerance for the migration. - **feeConfig** (object) - Optional - Fee configuration. - **feeCollectorAddress** (string) - Optional - Address to collect fees. - **feePercentMille** (number) - Optional - Fee percentage in mille (0.001%). ### Request Example ```json { "dex": "uniswap_v3", "fromPool": { "token0": "0x...", "token1": "0x...", "feeTier": 3000 }, "toPool": { "token0": "0x...", "token1": "0x...", "feeTier": 10000 }, "fromPosition": { "id": "1" }, "toPosition": { "lowerTick": 500, "upperTick": 1500 }, "slippageTolerance": 50, "feeConfig": { "feeCollectorAddress": "0x...", "feePercentMille": 10 } } ``` ### Response #### Success Response (200) - **migrationDetails** (object) - Details about the migration route and expected outcome. - **route** (string) - Encoded migration route to be passed to BuildRoute. - **routerAddress** (string) - The router address for checking user allowance. - **gasInformation** (object) - Estimated gas needed for the transaction. #### Response Example ```json { "migrationDetails": { "estimatedOutputAmount": "1000000000000000000" }, "route": "0x...", "routerAddress": "0x...", "gasInformation": { "estimatedGas": "120000" } } ``` ``` -------------------------------- ### Error Response Example - KyberSwap API Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-zap-as-a-service/kyberswap-zap-as-a-service-zaas-api/zaas-grpc-api Example of a 404 Not Found error response from the KyberSwap API, indicating a failure to get zap routes due to unavailable tokens. ```json { "code": 5, "message": "failed to get zap routes: cannot swap tokens [0xE2035f04040A135c4dA2f96AcA742143c57c79F9]" } ``` -------------------------------- ### Query Orders API Source: https://docs.kyberswap.com/kyberswap-solutions/limit-order/limit-order-api-specification/taker-apis This endpoint allows you to query existing orders. Refer to the developer guide for a detailed sequence diagram and TypeScript example. ```APIDOC ## GET /read-partner/api/v1/orders ### Description Queries existing orders on the KyberSwap platform. ### Method GET ### Endpoint /read-partner/api/v1/orders ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of orders to return. - **offset** (integer) - Optional - The number of orders to skip before returning results. - **status** (string) - Optional - Filter orders by their status (e.g., 'open', 'filled', 'cancelled'). - **takerAddress** (string) - Optional - Filter orders by the taker's address. - **makerAddress** (string) - Optional - Filter orders by the maker's address. ### Request Example ```json { "example": "GET /read-partner/api/v1/orders?limit=10&status=open" } ``` ### Response #### Success Response (200) - **orders** (array) - An array of order objects. - **orderId** (string) - The unique identifier for the order. - **makerAddress** (string) - The address of the order maker. - **takerAddress** (string) - The address of the order taker. - **makerToken** (string) - The token address used by the maker. - **takerToken** (string) - The token address used by the taker. - **makingAmount** (string) - The total amount the maker intends to provide. - **takingAmount** (string) - The total amount the taker intends to receive. - **filledMakingAmount** (string) - The amount of makingAmount that has been filled. - **filledTakingAmount** (string) - The amount of takingAmount that has been filled. - **status** (string) - The current status of the order. - **createdAt** (string) - The timestamp when the order was created. - **updatedAt** (string) - The timestamp when the order was last updated. #### Response Example ```json { "example": { "orders": [ { "orderId": "0x123abc", "makerAddress": "0xmaker...", "takerAddress": "0xtaker...", "makerToken": "0xDAI...", "takerToken": "0xUSDC...", "makingAmount": "1000000000000000000", "takingAmount": "1000000000000000000", "filledMakingAmount": "500000000000000000", "filledTakingAmount": "500000000000000000", "status": "open", "createdAt": "2023-10-27T10:00:00Z", "updatedAt": "2023-10-27T10:05:00Z" } ] } } ``` ``` -------------------------------- ### POST /route/build Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-aggregator/aggregator-api-specification/evm-swaps This API builds a swap route. It is designed to be performant and real-time. It is recommended to not cache routes from client side for more than 5-10 seconds. ```APIDOC ## POST /route/build ### Description Builds a swap route for EVM chains. ### Method POST ### Endpoint /route/build ### Parameters #### Header Parameters - **x-client-id** (string) - Required - Client identifier (e.g., company name or app name). ### Request Example { "example": "See OpenAPI specification for details" } ### Response #### Success Response (200) - **route** (object) - The built swap route. #### Response Example { "example": "See OpenAPI specification for details" } ``` -------------------------------- ### Permit Parameter for Swaps (Solidity) Source: https://docs.kyberswap.com/kyberswap-solutions This Solidity example illustrates the use of the `permit` parameter for swaps with supported EIP-2616 tokens. It allows users to perform swaps without a prior approval transaction, enhancing gas efficiency and user experience. ```solidity pragma solidity ^0.8.0; interface IKyberSwapAggregatorRouter { struct PermitTransferFrom { address owner; address spender; uint256 nonce; uint256 deadline; uint256 amount; } function swapExactTokensForTokensSupportingPermit( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline, PermitTransferFrom calldata permit ) external returns (uint amountOut); } contract PermitSwapExample { IKyberSwapAggregatorRouter public immutable router; constructor(address _routerAddress) { router = IKyberSwapAggregatorRouter(_routerAddress); } function performSwapWithPermit( uint _amountIn, uint _amountOutMin, address[] calldata _path, address _to, uint _deadline, IKyberSwapAggregatorRouter.PermitTransferFrom calldata _permit ) external { router.swapExactTokensForTokensSupportingPermit(_amountIn, _amountOutMin, _path, _to, _deadline, _permit); } } ``` -------------------------------- ### Get Operator Signature API Source: https://docs.kyberswap.com/kyberswap-solutions/limit-order/limit-order-api-specification/taker-apis This endpoint retrieves the operator signature, which is necessary for certain limit order operations. Refer to the developer guide for more details. ```APIDOC ## GET /read-partner/api/v1/orders/operator-signature ### Description Retrieves the operator's signature, often used for authorizing or validating limit order transactions. ### Method GET ### Endpoint /read-partner/api/v1/orders/operator-signature ### Parameters No parameters are required for this endpoint. ### Request Example ```json { "example": "GET /read-partner/api/v1/orders/operator-signature" } ``` ### Response #### Success Response (200) - **operatorSignature** (string) - The operator's signature. #### Response Example ```json { "example": { "operatorSignature": "0xabcdef123456..." } } ``` ``` -------------------------------- ### GET /read-ks/api/v1/orders Source: https://docs.kyberswap.com/kyberswap-solutions/limit-order/developer-guides/gasless-cancel Retrieves a list of active or open limit orders created by a Maker address. This is useful for identifying orders that need to be cancelled. ```APIDOC ## GET /read-ks/api/v1/orders ### Description Retrieves a list of active or open limit orders created by a Maker address. This is useful for identifying orders that need to be cancelled. ### Method GET ### Endpoint /read-ks/api/v1/orders ### Parameters #### Query Parameters - **chainId** (number) - Required - The ID of the blockchain network. - **maker** (string) - Required - The address of the order maker. - **status** (string) - Optional - Filters orders by their status (e.g., "active", "open"). ### Request Example ```json { "chainId": 137, "maker": "0x123...", "status": "active" } ``` ### Response #### Success Response (200) - **orders** (array) - An array of order objects. - **id** (number) - The unique identifier of the order. - **maker** (string) - The maker's address. - **makerAsset** (string) - The address of the maker's asset. - **takerAsset** (string) - The address of the taker's asset. - **status** (string) - The current status of the order. #### Response Example ```json { "orders": [ { "id": 12345, "maker": "0x123...", "makerAsset": "0xabc...", "takerAsset": "0xdef...", "status": "active" } ] } ``` ``` -------------------------------- ### GET /routes Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-aggregator/aggregator-api-specification/evm-swaps This API retrieves swap routes. It is designed to be performant and real-time. It is recommended to not cache routes from client side for more than 5-10 seconds. ```APIDOC ## GET /routes ### Description Retrieves swap routes for EVM chains. ### Method GET ### Endpoint /routes ### Parameters #### Header Parameters - **x-client-id** (string) - Required - Client identifier (e.g., company name or app name). ### Request Example { "example": "N/A" } ### Response #### Success Response (200) - **routes** (array) - Array of swap routes. #### Response Example { "example": "See OpenAPI specification for details" } ``` -------------------------------- ### Get Maker Orders (TypeScript) Source: https://docs.kyberswap.com/kyberswap-solutions/limit-order/developer-guides/gasless-cancel Retrieves a list of active or open limit orders for a Maker address using the `/read-ks/api/v1/orders` endpoint. This is the first step in identifying orders to be cancelled. It requires chain ID, maker address, and order status as parameters. ```typescript const targetPathConfig = { params: { chainId: ChainId.MATIC, maker: signerAddress, status: "active" } }; ``` -------------------------------- ### Filter and Get Target Order ID (TypeScript) Source: https://docs.kyberswap.com/kyberswap-solutions/limit-order/developer-guides/gasless-cancel Filters the list of Maker orders obtained from the `/read-ks/api/v1/orders` endpoint to find a specific order based on maker address, maker asset, and taker asset. It then extracts the `orderId` of the target order for cancellation. This step assumes the `getOrders` function has already fetched the orders. ```typescript const orders = await getOrders(); const targetOrder = orders.filter(order => order.maker.toLowerCase() == signerAddress.toLowerCase() && order.makerAsset.toLowerCase() == makerAsset.address.toLowerCase() && order.takerAsset.toLowerCase() == takerAsset.address.toLowerCase() ); const targetOrderId = Number(targetOrder[0].id); ``` -------------------------------- ### Order Creation and Signing Source: https://docs.kyberswap.com/kyberswap-solutions/limit-order/limit-order-api-specification/maker-apis This section details the parameters and structure for creating and signing orders on KyberSwap. It includes information on maker and taker assets, amounts, and associated data for order validity and interaction. ```APIDOC ## POST /websites/kyberswap ### Description This endpoint is used for creating and signing orders on the KyberSwap protocol. It requires detailed information about the maker and taker assets, amounts, and associated data for order validity and interaction. ### Method POST ### Endpoint /websites/kyberswap ### Parameters #### Query Parameters - **makerAsset** (string) - Required - The address of the asset the maker is offering. - **takerAsset** (string) - Required - The address of the asset the taker is offering. - **makingAmount** (string) - Required - The amount of the maker asset being offered (as a hexstring). - **takingAmount** (string) - Required - The amount of the taker asset being requested (as a hexstring). - **maker** (string) - Required - The Ethereum address of the order maker. - **receiver** (string) - Required - The Ethereum address that will receive the taker asset. - **allowedSenders** (string) - Optional - A list of Ethereum addresses allowed to fill this order. - **expiry** (integer) - Required - The timestamp (in seconds) when the order expires. - **chainId** (integer) - Required - The ID of the blockchain network. #### Request Body - **data** (object) - Required - Contains additional data for order creation: - **sender** (string) - Required - The Ethereum address initiating the transaction. - **makerAssetData** (string) - Optional - ABIv2 encoded data for the maker asset. - **takerAssetData** (string) - Optional - ABIv2 encoded data for the taker asset. - **getMakerAmount** (string) - Optional - Hexstring representing the maker asset amount. - **getTakerAmount** (string) - Optional - Hexstring representing the taker asset amount. - **predicate** (string) - Optional - Call data for order validity logic. - **permit** (string) - Optional - Permit data for gasless approvals (EIP2612). - **interaction** (string) - Optional - Call data for intermediate contract interaction. ### Request Example ```json { "sender": "0x123...", "makerAssetData": "0xabc...", "takerAssetData": "0xdef...", "getMakerAmount": "0x1000", "getTakerAmount": "0x500", "predicate": "0xghi...", "permit": "0xjkl...", "interaction": "0x123..." } ``` ### Response #### Success Response (200) - **order** (object) - Contains the signed order details: - **hash** (string) - The hash of the signed order. - **makerAsset** (string) - The address of the maker asset. - **takerAsset** (string) - The address of the taker asset. - **makingAmount** (string) - The amount of the maker asset. - **takingAmount** (string) - The amount of the taker asset. - **maker** (string) - The address of the order maker. - **taker** (string) - The address of the order taker. - **expiry** (integer) - The expiration timestamp of the order. - **fee** (string) - The fee associated with the order. - **signature** (string) - The signature of the order. - **nonce** (string) - The nonce for the order. - **recipient** (string) - The recipient of the taker asset. - **makerAssetData** (string) - ABIv2 encoded data for the maker asset. - **takerAssetData** (string) - ABIv2 encoded data for the taker asset. - **sender** (string) - The sender of the order. - **feeRecipient** (string) - The recipient of the fee. - **predicate** (string) - Call data for order validity logic. - **permit** (string) - Permit data for gasless approvals. - **interaction** (string) - Call data for intermediate contract interaction. #### Response Example ```json { "order": { "hash": "0xabc123...", "makerAsset": "0x111...", "takerAsset": "0x222...", "makingAmount": "0x1000", "takingAmount": "0x500", "maker": "0x123...", "taker": "0x456...", "expiry": 1678886400, "fee": "0x0", "signature": "0xdef456...", "nonce": "0x1", "recipient": "0x789...", "makerAssetData": "0xabc...", "takerAssetData": "0xdef...", "sender": "0x123...", "feeRecipient": "0xabc...", "predicate": "0xghi...", "permit": "0xjkl...", "interaction": "0x123..." } } ``` #### Error Responses - **400 Bad Request**: Returned for invalid input parameters such as missing fields, unsupported chainId, invalid ETH addresses, native tokens as assets, non-positive amounts, incorrect amount formats, or expired orders. - **500 Internal Server Error**: Returned for unexpected server-side errors. ``` -------------------------------- ### APIv1 GET Endpoint Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-aggregator/developer-guides/upgrading-to-apiv1 This section details the parameters available for the APIv1 GET endpoint, noting differences from the general GET endpoint. ```APIDOC ## GET /websites/kyberswap/v1 ### Description Fetches swap information using the APIv1 GET endpoint. Some parameters differ from the general GET endpoint. ### Method GET ### Endpoint /websites/kyberswap/v1 ### Parameters #### Query Parameters - **amountIn** (string) - Required - The input amount. - **amountOut** (string) - Required - The output amount. - **gas** (string) - Required - The gas used. - **gasPrice** (string) - Required - The gas price. - **gasUsd** (string) - Required - The gas price in USD. - **amountInUsd** (string) - Required - The input amount in USD. - **amountOutUsd** (string) - Required - The output amount in USD. - **route** (string) - Required - The route taken for the swap. - **pool** (string) - Required - The pool used for the swap. - **tokenIn** (string) - Required - The input token. - **tokenOut** (string) - Required - The output token. - **swapAmount** (string) - Required - The amount swapped. - **amountOut** (string) - Required - The final output amount. - **limitReturnAmount** (string) - Required - The minimum amount to return. - **exchange** (string) - Required - The exchange used. - **poolLength** (string) - Required - The number of pools. - **poolType** (string) - Required - The type of pool. - **routerAddress** (string) - Required - The router address. - **code** (string) - Required - The status code. - **message** (string) - Required - The status message. - **data** (string) - Required - Additional data. - **routeSummary** (string) - Required - A summary of the route. - **extraFee** (string) - Required - Any extra fees. - **feeAmount** (string) - Required - The amount of the fee. - **chargeFeeBy** (string) - Required - How the fee is charged. - **isInBps** (string) - Required - Whether the fee is in basis points. - **feeReceiver** (string) - Required - The address of the fee receiver. ### Response #### Success Response (200) - **amountIn** (string) - The input amount. - **amountOut** (string) - The output amount. - **gas** (string) - The gas used. - **gasPrice** (string) - The gas price. - **gasUsd** (string) - The gas price in USD. - **amountInUsd** (string) - The input amount in USD. - **amountOutUsd** (string) - The output amount in USD. - **route** (string) - The route taken for the swap. - **pool** (string) - The pool used for the swap. - **tokenIn** (string) - The input token. - **tokenOut** (string) - The output token. - **swapAmount** (string) - The amount swapped. - **amountOut** (string) - The final output amount. - **limitReturnAmount** (string) - The minimum amount to return. - **exchange** (string) - The exchange used. - **poolLength** (string) - The number of pools. - **poolType** (string) - The type of pool. - **routerAddress** (string) - The router address. - **code** (string) - The status code. - **message** (string) - The status message. - **data** (string) - Additional data. - **routeSummary** (string) - A summary of the route. - **extraFee** (string) - Any extra fees. - **feeAmount** (string) - The amount of the fee. - **chargeFeeBy** (string) - How the fee is charged. - **isInBps** (string) - Whether the fee is in basis points. - **feeReceiver** (string) - The address of the fee receiver. ### Response Example ```json { "amountIn": "100", "amountOut": "99.5", "gas": "0.001", "gasPrice": "50", "gasUsd": "2.5", "amountInUsd": "200", "amountOutUsd": "199", "route": [...], "pool": "0x123...", "tokenIn": "ETH", "tokenOut": "DAI", "swapAmount": "100", "amountOut": "99.5", "limitReturnAmount": "99", "exchange": "Kyber", "poolLength": "2", "poolType": "AMM", "routerAddress": "0x789...", "code": "0", "message": "Success", "data": "0x123...", "routeSummary": "ETH -> DAI", "extraFee": "0.1", "feeAmount": "0.1", "chargeFeeBy": "percentage", "isInBps": "true", "feeReceiver": "0xabc..." } ``` ``` -------------------------------- ### API GET Endpoint Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-aggregator/developer-guides/upgrading-to-apiv1 This section details the parameters available for the general API GET endpoint. ```APIDOC ## GET /websites/kyberswap ### Description Fetches general swap information. ### Method GET ### Endpoint /websites/kyberswap ### Parameters #### Query Parameters - **inputAmount** (string) - Required - The amount of input token. - **outputAmount** (string) - Required - The amount of output token. - **totalGas** (string) - Required - The total gas used for the transaction. - **gasPriceGwei** (string) - Required - The gas price in Gwei. - **gasUsd** (string) - Required - The gas price in USD. - **amountInUsd** (string) - Required - The input amount in USD. - **amountOutUsd** (string) - Required - The output amount in USD. - **receiveUsd** (string) - Required - The received amount in USD. - **swaps** (string) - Required - Details about the swaps performed. - **pool** (string) - Required - The pool used for the swap. - **tokenIn** (string) - Required - The input token. - **tokenOut** (string) - Required - The output token. - **swapAmount** (string) - Required - The amount swapped. - **amountOut** (string) - Required - The final output amount. - **limitReturnAmount** (string) - Required - The minimum amount to return. - **maxPrice** (string) - Required - The maximum price allowed. - **exchange** (string) - Required - The exchange used. - **poolLength** (string) - Required - The number of pools. - **poolType** (string) - Required - The type of pool. - **tokens** (string) - Required - Information about the tokens. - **address** (string) - Required - The address associated with the swap. - **symbol** (string) - Required - The symbol of the token. - **name** (string) - Required - The name of the token. - **price** (string) - Required - The price of the token. - **decimals** (string) - Required - The number of decimals for the token. - **encodedSwapData** (string) - Required - Encoded swap data. - **routerAddress** (string) - Required - The router address. ### Response #### Success Response (200) - **inputAmount** (string) - The input amount. - **outputAmount** (string) - The output amount. - **totalGas** (string) - The total gas used. - **gasPriceGwei** (string) - The gas price in Gwei. - **gasUsd** (string) - The gas price in USD. - **amountInUsd** (string) - The input amount in USD. - **amountOutUsd** (string) - The output amount in USD. - **receiveUsd** (string) - The received amount in USD. - **swaps** (string) - Details about the swaps performed. - **pool** (string) - The pool used for the swap. - **tokenIn** (string) - The input token. - **tokenOut** (string) - The output token. - **swapAmount** (string) - The amount swapped. - **amountOut** (string) - The final output amount. - **limitReturnAmount** (string) - The minimum amount to return. - **maxPrice** (string) - The maximum price allowed. - **exchange** (string) - The exchange used. - **poolLength** (string) - The number of pools. - **poolType** (string) - The type of pool. - **tokens** (string) - Information about the tokens. - **address** (string) - The address associated with the swap. - **symbol** (string) - The symbol of the token. - **name** (string) - The name of the token. - **price** (string) - The price of the token. - **decimals** (string) - The number of decimals for the token. - **encodedSwapData** (string) - Encoded swap data. - **routerAddress** (string) - The router address. ### Response Example ```json { "inputAmount": "100", "outputAmount": "99.5", "totalGas": "0.001", "gasPriceGwei": "50", "gasUsd": "2.5", "amountInUsd": "200", "amountOutUsd": "199", "receiveUsd": "199", "swaps": [...], "pool": "0x123...", "tokenIn": "ETH", "tokenOut": "DAI", "swapAmount": "100", "amountOut": "99.5", "limitReturnAmount": "99", "maxPrice": "1.01", "exchange": "Kyber", "poolLength": "2", "poolType": "AMM", "tokens": [...], "address": "0x456...", "symbol": "ETH", "name": "Ethereum", "price": "2000", "decimals": "18", "encodedSwapData": "0xabc...", "routerAddress": "0x789..." } ``` ``` -------------------------------- ### POST /read-ks/api/v1/encode/fill-batch-orders-to Source: https://docs.kyberswap.com/kyberswap-solutions/limit-order/limit-order-api-specification/taker-apis Encodes and prepares multiple limit orders for filling in a batch on KyberSwap. ```APIDOC ## POST /read-ks/api/v1/encode/fill-batch-orders-to ### Description Encodes and prepares multiple limit orders for filling in a batch on KyberSwap. ### Method POST ### Endpoint /read-ks/api/v1/encode/fill-batch-orders-to ### Parameters #### Request Body - **orders** (array) - Required - An array of order details to be filled. - Each object in the array should follow the structure of the single order in `fill-order-to`. ### Request Example ```json { "orders": [ { "recipient": "0x...", "tokenToFill": "0x...", "amountToFill": "1000000000000000000", "tokenToAmount": "500000000000000000", "limitOrderType": "EXACT_INPUT", "nonce": "123", "signature": "0x...", "takerToken": "0x...", "takerAmount": "1000000000000000000" }, { "recipient": "0x...", "tokenToFill": "0x...", "amountToFill": "2000000000000000000", "tokenToAmount": "1000000000000000000", "limitOrderType": "EXACT_INPUT", "nonce": "124", "signature": "0x...", "takerToken": "0x...", "takerAmount": "2000000000000000000" } ] } ``` ### Response #### Success Response (200) - **encodedOrders** (string) - The encoded batch order data ready for submission. #### Response Example ```json { "encodedOrders": "0x..." } ``` ``` -------------------------------- ### POST /BuildRoute (Zap Migrate) Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-zap-as-a-service/kyberswap-zap-as-a-service-zaas-api Builds the necessary calldata from the route returned by GetRoute for migrating liquidity positions. ```APIDOC ## POST /BuildRoute (Zap Migrate) ### Description Builds the calldata from the route returned by GetRoute for migrating liquidity positions. This endpoint returns the necessary call data, transaction value, and router address. ### Method POST ### Endpoint /BuildRoute ### Parameters #### Request Body - **route** (string) - Required - The encoded migration route obtained from the GetRoute API. ### Request Example ```json { "route": "0x..." } ``` ### Response #### Success Response (200) - **calldata** (string) - The transaction calldata to be sent on-chain. - **value** (string) - The transaction value (e.g., for native tokens). - **routerAddress** (string) - The address of the router contract. #### Response Example ```json { "calldata": "0x...", "value": "0", "routerAddress": "0x..." } ``` ```