### Simple SDK - Get Rate and Build Transaction Source: https://developers.velora.xyz/api/augustusrfq/sdk/typescript Example of using the simple SDK to get a price route for a swap and then build the transaction parameters. ```APIDOC ## Simple SDK - Get Rate and Build Transaction ### Description This example shows how to fetch a price route for a token swap and then construct the transaction parameters using the simple SDK. ### Usage ```typescript import { constructSimpleSDK, SwapSide } from '@paraswap/sdk'; import axios from 'axios'; import { ethers } from 'ethers'; // Assuming ethers.js is used for signer const paraSwapMin = constructSimpleSDK({ chainId: 1, axios }); const ETH = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'; const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; async function swapExample() { // Replace with your actual signer and address const signer = ethers.Wallet.fromMnemonic('__your_mnemonic__'); const senderAddress = signer.address; const srcAmount = '1000000000000000000'; // Example amount in wei const destAmount = '1000000000000000000'; // Example amount in wei const referrer = '0x...'; // Optional referrer address // Get the price route const priceRoute = await paraSwapMin.swap.getRate({ srcToken: ETH, destToken: DAI, amount: srcAmount, userAddress: senderAddress, side: SwapSide.SELL, }); // Build the transaction parameters const txParams = await paraSwapMin.swap.buildTx({ srcToken: ETH, destToken: DAI, srcAmount: srcAmount, destAmount: destAmount, priceRoute: priceRoute, userAddress: senderAddress, partner: referrer, }); // Format transaction for sending (example with BigNumber conversion) const transaction = { ...txParams, gasPrice: '0x' + new BigNumber(txParams.gasPrice).toString(16), gasLimit: '0x' + new BigNumber(5000000).toString(16), value: '0x' + new BigNumber(txParams.value).toString(16), }; // Send the transaction (requires signer) // const txr = await signer.sendTransaction(transaction); console.log('Transaction Parameters:', transaction); } // swapExample(); // Uncomment to run ``` ``` -------------------------------- ### Install ParaSwap Python SDK V1 Source: https://developers.velora.xyz/api/augustusrfq/sdk/python Install the SDK by building and then installing it. The install command may require administrator privileges. ```bash python3 setup.py build python3 setup.py install # may need privilege authorization ``` -------------------------------- ### Dynamic Documentation Query Example Source: https://developers.velora.xyz/api/augustusrfq/augustusrfq-api-specification To get additional information not directly present on a page, perform an HTTP GET request with the 'ask' query parameter. The question should be specific and self-contained. ```http GET https://developers.velora.xyz/api/augustusrfq/augustusrfq-api-specification.md?ask= ``` -------------------------------- ### Perform a Swap Transaction Source: https://developers.velora.xyz/api/augustusrfq/sdk/typescript Example of how to get a swap rate and build a transaction using the simple SDK. Requires ethers.js for signer and transaction building. ```typescript import { constructSimpleSDK } from '@paraswap/sdk'; import axios from 'axios'; // construct minimal SDK with fetcher only const paraSwapMin = constructSimpleSDK({chainId: 1, axios}); // or const paraSwapMin = constructSimpleSDK({chainId: 1, fetch: window.fetch}); const ETH = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'; const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; async function swapExample() { // or any other signer/provider const signer: JsonRpcSigner = ethers.Wallet.fromMnmemonic('__your_mnemonic__'); const senderAddress = signer.address; const priceRoute = await paraSwapMin.swap.getRate({ srcToken: ETH, destToken: DAI, amount: srcAmount, userAddress: senderAddress, side: SwapSide.SELL, }); const txParams = await paraSwapMin.swap.buildTx( { srcToken, destToken, srcAmount, destAmount, priceRoute, userAddress: senderAddress, partner: referrer, } ); const transaction = { ...txParams, gasPrice: '0x' + new BigNumber(txParams.gasPrice).toString(16), gasLimit: '0x' + new BigNumber(5000000).toString(16), value: '0x' + new BigNumber(txParams.value).toString(16), }; const txr = await signer.sendTransaction(transaction); } async function approveTokenYourselfExample() { const TransferProxy = await paraSwapMin.swap.getSpender(); const DAI_CONTRACT = new ethers.Contract(DAI, ERC20_ABI, ethersSignerOrProvider); const tx = await DAI_CONTRACT.approve(TransferProxy, amountInWei); const txReceipt = await tx.wait(1); } ``` -------------------------------- ### Query Documentation Dynamically Source: https://developers.velora.xyz/api/velora-api/velora-market-api Perform an HTTP GET request with the 'ask' query parameter to get direct answers and relevant excerpts from the documentation. ```http GET https://developers.velora.xyz/api/velora-api/velora-market-api.md?ask= ``` -------------------------------- ### Install ParaSwap SDK Source: https://developers.velora.xyz/api/augustusrfq/sdk/typescript Install the ParaSwap SDK using yarn. ```bash yarn add @paraswap/sdk ``` -------------------------------- ### Environment Variables for SDK Examples Source: https://developers.velora.xyz/api/augustusrfq/sdk/python Configure essential environment variables in a .env file to run the SDK examples. PK1 and PK2 are EVM-compatible secret keys for signing orders, and RPC endpoints are required for various networks. ```dotenv PK1= PK2= RPC_HTTP_1= RPC_HTTP_3= RPC_HTTP_10= RPC_HTTP_56= RPC_HTTP_137= RPC_HTTP_250= RPC_HTTP_42161= RPC_HTTP_43114= ``` -------------------------------- ### Get Rate for a Token Pair Source: https://developers.velora.xyz/api/velora-api/velora-market-api/get-rate-for-a-token-pair-1 This example demonstrates how to get the rate for a token pair using the Velora Market API. It includes optional parameters like `srcDecimals` and `destDecimals` for better accuracy, especially for tokens not directly listed by Velora. ```APIDOC ## GET /getRate ### Description Retrieves the exchange rate for a specified token pair. ### Query Parameters - **data** (string) - Required - A JSON string containing the token pair details, including `data` (encoded token information), `gasPrice`, and `chainId`. - **gasPrice** (string) - Required - The gas price to consider for the transaction. - **chainId** (number) - Required - The ID of the blockchain network. ### Request Example ```json { "data": "0xe3ead59e0000000000000000000000005f0000d4780a00d2dce0a00004000800cb0e5041000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000000000f4240000000000000000000000000000000000000000000000000db4d11c67691ad50000000000000000000000000000000000000000000000000dd8426a4440caf10a8104c26c244959a1d46f205acc49520000000000000000000000000133fc2c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000160a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000006000240000ff00000300000000000000000000000000000000000000000000000000000000a9059cbb0000000000000000000000004610ba8d5d10fba8c048a2051a0883ce04eabace", "gasPrice": "16000000000", "chainId": 1 } ``` ### Response #### Success Response (200) - **data** (object) - Contains the rate information. - **srcAmount** (string) - The amount of the source token. - **destAmount** (string) - The amount of the destination token. - **gasLimit** (string) - The estimated gas limit for the transaction. - **srcDecimals** (number) - The number of decimals for the source token. - **destDecimals** (number) - The number of decimals for the destination token. - **tokenAddress** (string) - The address of the token. - **minAmountOut** (string) - The minimum amount of the destination token that will be received. - **maxAmountIn** (string) - The maximum amount of the source token that can be used. #### Response Example ```json { "data": { "srcAmount": "1000000000000000000", "destAmount": "500000000000000000", "gasLimit": "200000", "srcDecimals": 18, "destDecimals": 18, "tokenAddress": "0x...", "minAmountOut": "490000000000000000", "maxAmountIn": "1010000000000000000" } } ``` #### Error Response (400) - **error** (string) - Describes the error encountered, e.g., "computePrice Error". ### Hints - It is highly recommended to provide `srcDecimals` and `destDecimals` for accurate pricing, especially for tokens not directly listed by Velora. - Swap fees and Swap & Transfer operations might not work with certain contract methods like `swapOnUniswap`, `swapOnUniswapFork`, `swapOnZeroXv2`, and `swapOnZeroXv4`. To enable these, use `includeContractMethods=simpleSwap,multiSwap,megaSwap`. ``` -------------------------------- ### Fetch Price & Build Transaction (SDK) Source: https://developers.velora.xyz/api/velora-api/velora-market-api/examples This example demonstrates how to use Velora's SDK to fetch pricing information and build transactions for token swaps. ```javascript import { VeloraMarketAPI } from '@velora/sdk'; // Assuming SDK is available const marketApi = new VeloraMarketAPI(); async function getPriceAndBuildTransactionSDK(fromToken, toToken, amount) { try { // 1. Fetch price information using SDK const priceData = await marketApi.getPrice({ fromToken: fromToken, toToken: toToken, amount: amount, }); console.log('Price Data (SDK):', priceData); // 2. Build transaction using SDK const transactionData = await marketApi.buildTransaction({ fromToken: fromToken, toToken: toToken, amount: amount, price: priceData.price, // Use the fetched price // Add any other required parameters for transaction building }); console.log('Transaction Data (SDK):', transactionData); return { priceData, transactionData }; } catch (error) { console.error('Error (SDK):', error); throw error; } } // Example usage: // getPriceAndBuildTransactionSDK('ETH', 'USDC', '1000000000000000000'); // Example with 1 ETH ``` -------------------------------- ### Bundle Optimization Example Source: https://developers.velora.xyz/api/augustusrfq/sdk/typescript Demonstrates how to construct a lightweight version of the ParaSwap SDK by importing only the necessary functions, such as `getRate` and `getBalances`. ```APIDOC ## Bundle Optimization ### Description Construct a lightweight version of the SDK by importing only the functions you need, optimizing bundle size. ### Example Usage ```typescript import { constructPartialSDK, constructFetchFetcher, constructGetRate, constructGetBalances } from '@paraswap/sdk'; const fetcher = constructFetchFetcher(window.fetch); const minParaSwap = constructPartialSDK({ chainId: 1, fetcher, }, constructGetRate, constructGetBalances); // Now you can use the specific functions: const priceRoute = await minParaSwap.getRate(params); const allowance = await minParaSwap.getAllowance(userAddress, tokenAddress); ``` ### Available Functions for Optimization - `constructGetRate` - `constructGetBalances` - (and others as needed) ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://developers.velora.xyz/security/augustus-rfq To get additional information not explicitly present on the page, perform an HTTP GET request to the current page URL with the 'ask' query parameter. The question should be specific and self-contained. ```http GET https://developers.velora.xyz/security/augustus-rfq.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://developers.velora.xyz/api/velora-api/velora-delta-api/submit-a-delta-order Perform an HTTP GET request to the current page URL with the `ask` query parameter to dynamically query the documentation. The question should be specific and in natural language. ```http GET https://developers.velora.xyz/api/velora-api/velora-delta-api/submit-a-delta-order.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://developers.velora.xyz/api/augustusrfq/contracts To get additional information not directly present on the page, perform an HTTP GET request with the 'ask' query parameter. The question should be specific and in natural language. This mechanism is useful for clarifications, additional context, or retrieving related documentation sections. ```http GET https://developers.velora.xyz/api/augustusrfq/contracts.md?ask= ``` -------------------------------- ### Querying Documentation with GET Request Source: https://developers.velora.xyz/api/velora-api/velora-market-api/get-rate-for-a-token-pair-1 Perform an HTTP GET request to the current page URL with the 'ask' query parameter to retrieve specific information. The question should be self-contained and in natural language. Use this for clarifications or to find related documentation. ```HTTP GET https://developers.velora.xyz/api/velora-api/velora-market-api/get-rate-for-a-token-pair-1.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://developers.velora.xyz/api/velora-api/velora-market-api/examples To get additional information not directly present on a page, perform an HTTP GET request to the page URL with the `ask` query parameter. The question should be specific and self-contained. ```http GET https://developers.velora.xyz/api/velora-api/velora-market-api/examples.md?ask= ``` -------------------------------- ### Simple SDK - Approve Token (with Provider Options) Source: https://developers.velora.xyz/api/augustusrfq/sdk/typescript Shows how to initialize the simple SDK with provider options to enable token approval functionality. ```APIDOC ## Simple SDK - Approve Token (with Provider Options) ### Description Initialize the simple SDK with provider options for ethers.js or web3.js to enable the `approveToken` functionality. ### Usage with ethers.js ```typescript import { constructSimpleSDK } from '@paraswap/sdk'; import axios from 'axios'; import { ethers } from 'ethers'; // Assume 'provider' is an ethers.js provider instance and 'senderAddress' is the user's address const provider = new ethers.providers.Web3Provider(window.ethereum); const signer = provider.getSigner(); const senderAddress = await signer.getAddress(); const providerOptionsEther = { ethersProviderOrSigner: signer, // Use signer for approvals EthersContract: ethers.Contract, account: senderAddress, }; const paraSwap = constructSimpleSDK({ chainId: 1, axios }, providerOptionsEther); async function approveTokenExampleEther() { const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; const amountInWei = '1000000000000000000'; // Example amount const txHash = await paraSwap.approveToken(amountInWei, DAI); console.log('Approve transaction hash:', txHash); // Wait for transaction confirmation // await provider.waitForTransaction(txHash); } // approveTokenExampleEther(); // Uncomment to run ``` ### Usage with web3.js ```typescript import { constructSimpleSDK } from '@paraswap/sdk'; import axios from 'axios'; import Web3 from 'web3'; // Assume 'web3' is a web3.js instance and 'senderAddress' is the user's address const web3 = new Web3(window.ethereum); const senderAddress = await web3.eth.getAccounts().then(accounts => accounts[0]); const providerOptionsWeb3 = { web3: web3, account: senderAddress, }; const paraSwap = constructSimpleSDK({ chainId: 1, axios }, providerOptionsWeb3); async function approveTokenExampleWeb3() { const DAI = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; const amountInWei = '1000000000000000000'; // Example amount const txHash = await paraSwap.approveToken(amountInWei, DAI); console.log('Approve transaction hash:', txHash); // Wait for transaction confirmation (example using promises) // const receipt = await new Promise((resolve, reject) => { // txHash.once('receipt', resolve); // txHash.once('error', reject); // }); // console.log('Transaction receipt:', receipt); } // approveTokenExampleWeb3(); // Uncomment to run ``` ``` -------------------------------- ### Get Bridge Info Response Example Source: https://developers.velora.xyz/api/velora-api/velora-delta-api/retrieve-details-for-creating-cross-chain-order This JSON response details supported tokens for cross-chain transactions between different source and destination chain IDs. It's used to validate and construct cross-chain orders. ```json { "supportedTokens": { "1": { "10": [ "0x4200000000000000000000000000000000000006", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", "0x7F5c764cBc14f9669B88837ca1490cCa17c31607", "0x68f180fcCe6836688e9084f035309E29Bf0A2095", "0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea", "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1", "0xFE8B128bA8C78aabC59d4c64cEE7fF28e9379921", "0xFf733b2A3557a7ed6697007ab5D11B79FdD1b76B", "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58", "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", "0x395Ae52bB17aef68C2888d941736A71dC6d4e125" ], "137": [ "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619", "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359", "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6", "0x3066818837c5e6eD6601bd5a91B0762877A6B731", "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063", "0x9a71012B13CA4d3D0Cdc72A177DF3ef03b0E76A3", "0xF328b73B6c685831F238c30a23Fc19140CB4D8FC", "0xc2132D05D31c914a87C6611C10748AEb04B58e8F", "0x25788a1a171ec66Da6502f9975a15B609fF54CF6" ], "324": [ "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4", "0xBBeB516fb02a01611cBBE0453Fe3c580D7281011", "0x4B9eb6c0b6ea15176BBF62841C6B2A8a398cb656", "0x493257fD37EDB34451f62EDf8D2a0C418852bA4C" ], "480": [ "0x4200000000000000000000000000000000000006", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0x79A02482A880bCE3F13e09Da970dC34db4CD24d1", "0x03C7054BCB39f7b2e5B2c7AcB37583e32D70Cfa3", "0x7077C71B4AF70737a08287E279B717Dcf64fdC57" ], "690": [ "0x4200000000000000000000000000000000000006", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" ], "1135": [ "0x4200000000000000000000000000000000000006", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0x03C7054BCB39f7b2e5B2c7AcB37583e32D70Cfa3", "0x05D032ac25d322df992303dCa074EE7392C117b9", "0xac485391EB2d7D88253a7F1eF18C37f4242D1A24" ], "8453": [ "0x4200000000000000000000000000000000000006", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA", "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb", "0x4158734D47Fc9692176B5085E0F52ee0Da5d47F1", "0xd652C5425aea2Afd5fb142e120FeCf79e18fafc3" ], "34443": [ "0x4200000000000000000000000000000000000006", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0xd988097fb8612cc24eeC14542bC03424c656005f", "0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF", "0xf0F161fDA2712DB8b566946122a5af183995e2eD" ], "41455": [ "0xB3f0eE446723f4258862D949B4c9688e7e7d35d3", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0xD648529D4803d3467bA8850577BEd4e4b8Ae583C" ], "42161": [ "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f", "0xd693Ec944A85eeca4247eC1c3b130DCa9B0C3b22", "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1", "0x040d1EdC9569d4Bab2D15287Dc5A4F10F56a56B8", "0x53691596d1BCe8CEa565b84d4915e69e03d9C99d", "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", "0xCF934E2402A5e072928a39a956964eb8F2B5B79C" ] }, "8453": { "1": [ "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0x6B175474E89094C44Da98b954EedeAC495271d0F", "0xba100000625a3754423978a60c9317c58a424e3D", "0x0cEC1A9154Ff802e7934Fc916Ed7Ca50bDE6844e" ], "10": [ "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85", "0x7F5c764cBc14f9669B88837ca1490cCa17c31607", "0x4200000000000000000000000000000000000006", ``` -------------------------------- ### Transaction Examples Source: https://developers.velora.xyz/api/velora-api/velora-market-api/build-parameters-for-transaction Examples of successful and failed transaction responses. ```APIDOC ## Transaction Response Examples ### Success Response (200 Transaction Request Response) ```json { "from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "to": "0x6a000f20005980200259b80c5102003040001068", "value": "0", "data": "0xe3ead59e0000000000000000000000005f0000d4780a00d2dce0a00004000800cb0e5041000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000db4d11c67691ad50000000000000000000000000000000000000000000000000dd8426a4440caf10a8104c26c244959a1d46f205acc49520000000000000000000000000133fc2c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000160a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000006000240000ff00000300000000000000000000000000000000000000000000000000000000a9059cbb0000000000000000000000004610ba8d5d10fba8c048a2051a0883ce04eabace00000000000000000000000000000000000000000000000000000000000f42406a000f20005980200259b80c51020030400010680000008000240000ff0600030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000f4240000000000000000000004de54610ba8d5d10fba8c048a2051a0883ce04eabace", "gasPrice": "16000000000", "chainId": 1 } ``` ### Error Response (400 Transaction Building Error) ```json { "error": "Unable to process the transaction" } ``` ``` -------------------------------- ### Simple SDK Initialization Source: https://developers.velora.xyz/api/augustusrfq/sdk/typescript Demonstrates how to construct a simple ParaSwap SDK instance using either axios or window.fetch as the HTTP client. This SDK can be used to query the ParaSwap API. ```APIDOC ## Simple SDK Initialization ### Description Construct a minimal SDK with a fetcher only. This SDK can query the ParaSwap API. ### Usage ```typescript import { constructSimpleSDK } from '@paraswap/sdk'; import axios from 'axios'; // Using axios as the fetcher const paraSwapMinAxios = constructSimpleSDK({ chainId: 1, axios }); // Using window.fetch as the fetcher const paraSwapMinFetch = constructSimpleSDK({ chainId: 1, fetch: window.fetch }); ``` ``` -------------------------------- ### 400 Get Orders Error Source: https://developers.velora.xyz/api/velora-api/velora-delta-api/track-delta-order-status Handles validation errors for the get orders request. ```APIDOC ## 400 Get Orders Error ### Description This response indicates that the request to get orders failed due to validation errors. ### Response Example ```json { "error": "Validation failed with error" } ``` ``` -------------------------------- ### Get Price Route Source: https://developers.velora.xyz/api/velora-api/velora-market-api/get-rate-for-a-token-pair This endpoint gets the optimal price and price route required to swap from one token to another. ```APIDOC ## GET /prices ### Description This endpoint gets the optimal price and price route required to swap from one token to another. ### Method GET ### Endpoint https://api.paraswap.io/prices ### Parameters #### Query Parameters - **tokenIn** (string) - Required - The address of the token to swap from. - **tokenOut** (string) - Required - The address of the token to swap to. - **amountIn** (string) - Required - The amount of `tokenIn` to swap. - **maxImpactPercentage** (string) - Optional - The maximum percentage of price impact allowed for the swap. - **excludeDEXs** (string) - Optional - A comma-separated list of DEXs to exclude from the route calculation. - **includeDEXs** (string) - Optional - A comma-separated list of DEXs to include in the route calculation. - **networkVersion** (string) - Optional - The network version to use for the query. - **userAddress** (string) - Optional - The user's address for gas estimation and other network-specific calculations. - **partner** (string) - Optional - The partner ID for tracking purposes. - **srcSWAP** (string) - Optional - Specifies the source of the swap. - **destSWAP** (string) - Optional - Specifies the destination of the swap. - **fee** (string) - Optional - The fee to be applied to the swap. - **gasPrice** (string) - Optional - The gas price to use for the transaction. - **referrer** (string) - Optional - The referrer's address. - **referrerFee** (string) - Optional - The referrer's fee. - **routingType** (string) - Optional - The type of routing to use. - **slippage** (string) - Optional - The slippage tolerance for the swap. - **smartContract** (string) - Optional - The address of the smart contract to use for the swap. - **tokenInDecimals** (string) - Optional - The number of decimals for `tokenIn`. - **tokenOutDecimals** (string) - Optional - The number of decimals for `tokenOut`. ### Response #### Success Response (200) - **message** (string) - Indicates the success of the operation. - **status** (string) - The status of the response. - **result** (object) - Contains the price and route information. - **tokenAmount** (string) - The amount of the output token. - **routes** (array) - An array of possible routes. - **route** (string) - The route string. - **swaps** (array) - An array of swap details for the route. - **swapExchanges** (array) - An array of exchanges involved in the swap. - **exchange** (string) - The name of the exchange. - **tokenIn** (string) - The input token for the swap. - **tokenOut** (string) - The output token for the swap. - **tokenInAmount** (string) - The amount of input token for the swap. - **tokenOutAmount** (string) - The amount of output token for the swap. - **commission** (string) - The commission for the swap. - **commissionAmount** (string) - The commission amount for the swap. - **commissionType** (string) - The type of commission. - **totalPrice** (string) - The total price for the route. - **gas** (string) - The estimated gas cost for the route. ### Request Example ```json { "example": "https://api.paraswap.io/prices?tokenIn=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokenOut=0x6b175474e89094c44da98b954eedeac495271d0f&amountIn=1000000000000000000&maxImpactPercentage=10" } ``` ### Response Example ```json { "example": { "message": "OK", "status": "SUCCESS", "result": { "tokenAmount": "950000000000000000", "routes": [ { "route": "UniswapV2, Sushiswap", "swaps": [ { "swapExchanges": [ { "exchange": "UniswapV2", "tokenIn": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "tokenOut": "0x6b175474e89094c44da98b954eedeac495271d0f", "tokenInAmount": "1000000000000000000", "tokenOutAmount": "950000000000000000", "commission": "0", "commissionAmount": "0", "commissionType": "NONE" } ], "totalPrice": "950000000000000000", "gas": "100000000000000" } ] } ] } } } ``` ``` -------------------------------- ### Fetch Price & Build Transaction (API) Source: https://developers.velora.xyz/api/velora-api/velora-market-api/examples This example shows how to use Velora's endpoints to fetch pricing information and build transactions for token swaps using the API. ```javascript const fetch = require('node-fetch'); const VELORA_API_URL = 'https://api.velora.xyz'; // Replace with actual API endpoint async function getPriceAndBuildTransaction(fromToken, toToken, amount) { try { // 1. Fetch price information const priceResponse = await fetch(`${VELORA_API_URL}/market/price?from=${fromToken}&to=${toToken}&amount=${amount}`); if (!priceResponse.ok) { throw new Error(`Failed to fetch price: ${priceResponse.statusText}`); } const priceData = await priceResponse.json(); console.log('Price Data:', priceData); // 2. Build transaction const transactionResponse = await fetch(`${VELORA_API_URL}/market/transaction`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ fromToken: fromToken, toToken: toToken, amount: amount, price: priceData.price, // Use the fetched price // Add any other required parameters for transaction building }), }); if (!transactionResponse.ok) { throw new Error(`Failed to build transaction: ${transactionResponse.statusText}`); } const transactionData = await transactionResponse.json(); console.log('Transaction Data:', transactionData); return { priceData, transactionData }; } catch (error) { console.error('Error:', error); throw error; } } // Example usage: // getPriceAndBuildTransaction('ETH', 'USDC', '1000000000000000000'); // Example with 1 ETH ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://developers.velora.xyz/api/augustusrfq/sdk/python Perform an HTTP GET request to query documentation dynamically using the 'ask' query parameter. The question should be specific and self-contained. ```http GET https://developers.velora.xyz/api/augustusrfq/sdk/python.md?ask= ``` -------------------------------- ### Agent Instructions: Querying This Documentation Source: https://developers.velora.xyz/api/velora-api/velora-market-api/master/api-v6.2 Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation for additional information. ```APIDOC ## Agent Instructions: Querying This Documentation Perform an HTTP GET request on the current page URL with the `ask` query parameter: ``` GET https://developers.velora.xyz/api/velora-api/velora-market-api/master/api-v6.2.md?ask= ``` The question should be specific, self-contained, and written in natural language. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. ``` -------------------------------- ### Delta Order Structure and Example Source: https://developers.velora.xyz/api/velora-api/velora-delta-api/build-a-delta-order-to-sign Defines the structure of a Delta order, including request body parameters and the nested Bridge object. Provides a concrete example of a populated Delta order. ```json { "type": "object", "properties": { "owner": { "type": "address" }, "beneficiary": { "type": "address" }, "srcToken": { "type": "address" }, "destToken": { "type": "address" }, "srcAmount": { "type": "uint256" }, "destAmount": { "type": "uint256" }, "expectedAmount": { "type": "uint256" }, "deadline": { "type": "uint256" }, "kind": { "type": "uint8" }, "nonce": { "type": "uint256" }, "partnerAndFee": { "type": "uint256" }, "permit": { "type": "bytes" }, "metadata": { "type": "bytes" }, "bridge": { "type": "Bridge" } }, "Bridge": [ { "name": "protocolSelector", "type": "bytes4" }, { "name": "destinationChainId", "type": "uint256" }, { "name": "outputToken", "type": "address" }, { "name": "scalingFactor", "type": "int8" }, { "name": "protocolData", "type": "bytes" } ] }, "value": { "owner": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "beneficiary": "0x0000000000000000000000000000000000000000", "srcToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "destToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "srcAmount": "10000000", "destAmount": "9127760", "expectedAmount": "9219960", "deadline": 1757333024, "kind": 0, "nonce": "47551995136396664604384293391986507799897145387152361812735887931703330715323", "permit": "0x", "partnerAndFee": "0", "metadata": "0x", "bridge": { "protocolSelector": "0x21eaa4cd", "destinationChainId": 8453, "outputToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", "scalingFactor": 0, "protocolData": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" } } } ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://developers.velora.xyz/api/velora-api/velora-delta-api/contracts Use this endpoint to dynamically query the documentation. Append your question as the 'ask' query parameter. The response includes direct answers and relevant excerpts. ```http GET https://developers.velora.xyz/api/velora-api/velora-delta-api/contracts.md?ask= ``` -------------------------------- ### Get Price Route & Transaction Building Source: https://developers.velora.xyz/api/velora-api/velora-market-api/get-rate-for-a-token-pair-1 This endpoint gets the optimal price and price route required to swap from one token to another. Additionally, it generates the parameters required for the transaction. ```APIDOC ## GET https://api.paraswap.io/swap ### Description This endpoint gets the optimal price and price route required to swap from one token to another. Additionally, it generates the parameters required for the transaction. ### Method GET ### Endpoint https://api.paraswap.io/swap ### Limitations * Lower rate limits * It doesn't check sufficient allowances and balances * It doesn't return the gas field in txParams, thus the transaction should be simulated locally * It automatically excludes RFQ-based DEXs such as AugustusRFQ & ParaSwapLimitOrders. ``` -------------------------------- ### Lightweight SDK for Rates and Balances Source: https://developers.velora.xyz/api/augustusrfq/sdk/typescript Constructs a minimal version of the SDK for specific needs like fetching token rates and user balances. This is useful for reducing bundle size by only including necessary functions. ```typescript import { constructPartialSDK, constructFetchFetcher, constructGetRate, constructGetBalances } from '@paraswap/sdk'; const fetcher = constructFetchFetcher(window.fetch); const minParaSwap = constructPartialSDK({ chainId: 1, fetcher, }, constructGetRate, constructGetBalances); const priceRoute = await minParaSwap.getRate(params); const allowance = await minParaSwap.getAllowance(userAddress, tokenAddress); ``` -------------------------------- ### Query Documentation Dynamically Source: https://developers.velora.xyz/api/velora-api/velora-market-api/get-rate-for-a-token-pair Perform an HTTP GET request to query the documentation dynamically. Use the `ask` query parameter with a specific, self-contained question in natural language. The response will include a direct answer and relevant excerpts. ```http GET https://developers.velora.xyz/api/velora-api/velora-market-api/get-rate-for-a-token-pair.md?ask= ```