Request Data
Get transaction swap data
Requesting swap data
Using the swap method, you can get a transaction data for swap, obtained on previous step. You can check available request params here.
Here is an example of requesting data 1.05 ETH in Ethereum Blockchain for Matic in Polygon Blockchain
const quoteParams = {
"dstTokenAddress": "0x0000000000000000000000000000000000000000",
"dstTokenBlockchain": "POLYGON",
"referrer": "rubic.exchange",
"srcTokenAddress": "0x0000000000000000000000000000000000000000",
"srcTokenAmount": "1.05",
"srcTokenBlockchain": "ETH"
};
const bestTrade = await axios.post('https://api-v2.rubic.exchange/api/routes/quoteBest', {
params: quoteParams
});
const swapParams = {
...quoteParams,
id: bestTrade.id,
fromAddress: "Your wallet address"
};
const tradeWithData = await axios.post('https://api-v2.rubic.exchange/api/routes/swap', {
params: swapParams
});
console.log(tradeWithData.transaction);
/**
{
data: 0x.....;
to: 0x....;
value: 0
}
*/
Swap request params
Required params
srcTokenAddress*
string
Source token address
0x0000000000000000000000000000000000000000
srcTokenBlockchain*
string
Source token blockchain
ETH
srcTokenAmount*
string
Source token amount with decimals
1.05
dstTokenAddress*
string
Destination token address
0x0000000000000000000000000000000000000000
dstTokenBlockchain*
string
Destination token blockchain
Polygon
referrer*
string
Referrer address
rubic.exchange
fromAddress*
string
Wallet address to make tx from
0x0000000000000000000000000000000000000000
id*
string
Trade identifier obtained on quote step
08df660f-49e5-42fd-a1f1-cdf0af5eac4c
Optional params
nativeBlacklist
string[]
Native providers to exclude from calculation
["xy", "symbiosis"]
showFailedRoutes
boolean
Show failed routes in response or not
false
integratorAddress
string
Integrator address to set fees
Get the address from our BD team
slippage
number minimum: 0.01 maximum: 0.5
Slippage tolerance in percents for trade, 0.01 equals 1%
0.02
receiver
string
Wallet address to send tokens to on the destination blockchain
0x0000000000000000000000000000000000000000
preferredProvider
string
Preferred provider for calculation
lifi
foreignBlacklist
{
lifi?: string[];
rango?: string[];
}
Foreign providers to exclude from calculation
{ lifi: ["stargate"] }
timeout
number minimum: 5 maximum: 60
Calculation timeout in seconds
32
enableTestnets
boolean
Include testnet in calculations
false
enableChecks
boolean
Should we perform transaction simulation and wallet checks or no default: true
false
Swap Response params
id
string
Trade identifier
60e513d5-8a2d-4e0d-b513-6236d86bc7da
swapType
'cross-chain' | 'on-chain'
Type of swap
cross-chain
warnings
ErrorDto[]
Specific info about quote params provider
[ { code: 301, reason: amountTooLow, data: { minAmount: 0.1 eth } ]
Last updated
Was this helpful?