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,
from: "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
}
*/
{
"estimate": {
"destinationTokenAmount": "6677.631394620135930652",
"destinationTokenMinAmount": "6477.302452781531852732",
"destinationUsdAmount": 2740.43,
"destinationUsdMinAmount": 2658.22,
"destinationWeiAmount": "6677631394620135930652",
"destinationWeiMinAmount": "6477302452781531852732",
"durationInMinutes": 5,
"priceImpact": 0.42,
"slippage": 0.03
},
"fees": {
"gasTokenFees": {
"gas": {
"gasLimit": "0",
"gasPrice": "0",
"totalUsdAmount": 0,
"totalWeiAmount": "0"
},
"nativeToken": {
"address": "0x0000000000000000000000000000000000000000",
"blockchainId": 1,
"decimals": 18,
"name": "Ethereum",
"symbol": "ETH"
},
"protocol": {
"fixedAmount": "0.000780454302449455",
"fixedUsdAmount": 2.05,
"fixedWeiAmount": "780454302449455"
},
"provider": {
"fixedAmount": "0",
"fixedUsdAmount": 0,
"fixedWeiAmount": "0"
}
},
"percentFees": {
"percent": 0,
"token": {
"address": "0x0000000000000000000000000000000000000000",
"blockchainId": 1,
"decimals": 18,
"name": "Ethereum",
"symbol": "ETH"
}
}
},
"providerType": "symbiosis",
"quote": {
"nativeBlacklist": [],
"foreignBlacklist": {
"lifi": [],
"rango": []
},
"timeout": 30,
"referrer": "rubic.exchange",
"showFailedRoutes": false,
"id": "faee0bb6-8990-4c13-80e7-70cfa202e656",
"enableChecks": false,
"fromAddress": "0xB72DE277A58577C955B0C52acD8fD2a7cFDaFD17",
"dstTokenAddress": "0x0000000000000000000000000000000000000000",
"dstTokenBlockchain": "POLYGON",
"srcTokenAddress": "0x0000000000000000000000000000000000000000",
"srcTokenAmount": "1.05",
"srcTokenBlockchain": "ETH",
"integratorAddress": "0x3fFF9bDEb3147cE13A7FFEf85Dae81874E0AEDbE",
"slippage": 0.03
},
"routing": [
{
"path": [
{
"address": "0x0000000000000000000000000000000000000000",
"amount": "1.05",
"blockchainId": 1,
"decimals": 18,
"name": "Ethereum",
"symbol": "ETH"
},
{
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"amount": "0",
"blockchainId": 1,
"decimals": 6,
"name": "USD Coin",
"symbol": "USDC"
}
],
"provider": "SYMBIOSIS_SWAP",
"type": "on-chain"
},
{
"path": [
{
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"amount": "0",
"blockchainId": 1,
"decimals": 6,
"name": "USD Coin",
"symbol": "USDC"
},
{
"address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"amount": "0",
"blockchainId": 137,
"decimals": 6,
"name": "USD Coin (PoS)",
"symbol": "USDC"
}
],
"provider": "symbiosis",
"type": "cross-chain"
},
{
"path": [
{
"address": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"amount": "0",
"blockchainId": 137,
"decimals": 6,
"name": "USD Coin (PoS)",
"symbol": "USDC"
},
{
"address": "0x0000000000000000000000000000000000000000",
"amount": "6677.631394620135930652",
"blockchainId": 137,
"decimals": 18,
"name": "Matic Network",
"symbol": "MATIC"
}
],
"provider": "SYMBIOSIS_SWAP",
"type": "on-chain"
}
],
"swapType": "cross-chain",
"transaction": {
"approvalAddress": "0x3335733c454805df6a77f825f266e136FB4a3333",
"data": "0x...",
"to": "0x3335733c454805df6a77f825f266e136FB4a3333",
"value": "1050780454302449455"
},
"warnings": []
}
Swap request params
Required params
Optional params
Swap Response params
Last updated