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 a data request for swapping 1.05 ETH on Ethereum to POL on Polygon:
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
}
*/{
"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": []
}Request data for deposit
Using the swap method, you can get directly a depositAddress, amountToSend, exchangeId and extraFields optionally to manually make transfer on wallet of selected deposit provider, obtained on previous step. You can check available request params here.
Here is an example of a data request for swapping 50 USDT on Solana to USDT on Ethereum:
const quoteParams = {
"dstTokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"dstTokenBlockchain": "ETH",
"referrer": "rubic.exchange",
"srcTokenAddress": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
"srcTokenAmount": "50",
"srcTokenBlockchain": "SOLANA"
};
const depositTrade = await axios.post('https://api-v2.rubic.exchange/api/routes/quoteDepositTrades', {
params: quoteParams
});
const swapParams = {
...quoteParams,
id: depositTrade.id,
receiverAddress: "Target chain receiver address"
};
const tradeWithData = await axios.post('https://api-v2.rubic.exchange/api/routes/swapDepositTrade', {
params: swapParams
});
console.log(tradeWithData.transaction);
/**
{
depositAddress: string;
amountToSend: string;
exchangeId: string;
extraFields?: {
name: string;
valu: string;
}
}
*/{
"estimate": {
"destinationTokenAmount": "49.29526",
"destinationTokenMinAmount": "47.816402",
"destinationUsdAmount": 49.3,
"destinationUsdMinAmount": 47.82,
"destinationWeiAmount": "49295260",
"destinationWeiMinAmount": "47816402",
"durationInMinutes": 5,
"priceImpact": 1.41,
"slippage": 0.03
},
"fees": {
"gasTokenFees": {
"gas": {
"baseFee": null,
"gasLimit": null,
"gasPrice": null,
"maxFeePerGas": null,
"maxPriorityFeePerGas": null,
"totalUsdAmount": null,
"totalWeiAmount": null
},
"nativeToken": {
"address": "So11111111111111111111111111111111111111111",
"blockchain": "SOLANA",
"blockchainId": 7565164,
"decimals": 9,
"name": "Solana",
"price": 194.98,
"symbol": "SOL"
},
"protocol": {
"fixedAmount": "0",
"fixedUsdAmount": 0,
"fixedWeiAmount": "0"
},
"provider": {
"fixedAmount": "0",
"fixedUsdAmount": 0,
"fixedWeiAmount": "0"
}
},
"percentFees": {
"percent": 0,
"token": null
}
},
"providerType": "exolix",
"routing": [
{
"path": [
{
"address": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
"amount": "50",
"blockchain": "SOLANA",
"blockchainId": 7565164,
"decimals": 6,
"name": "Tether (SOL)",
"symbol": "USDT",
"price": 1
},
{
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"amount": "49.29526",
"blockchain": "ETH",
"blockchainId": 1,
"decimals": 6,
"name": "Tether USD",
"symbol": "USDT",
"price": 1
}
],
"provider": "exolix",
"type": "cross-chain"
}
],
"swapType": "cross-chain",
"tokens": {
"from": {
"address": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
"amount": "50",
"blockchain": "SOLANA",
"blockchainId": 7565164,
"decimals": 6,
"name": "Tether (SOL)",
"price": 1,
"symbol": "USDT"
},
"to": {
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"blockchain": "ETH",
"blockchainId": 1,
"decimals": 6,
"name": "Tether USD",
"price": 1,
"symbol": "USDT"
}
},
"transaction": {
"depositAddress": "86ynSAUzZQzdBV5MQTNBiL9nnQs2sDCCTovnYfxEJwb8",
"amountToSend": "50",
"exchangeId": "46bb477f86a8d0"
},
"useRubicContract": false,
"warnings": [],
"quote": {
"nativeBlacklist": [],
"foreignBlacklist": {
"lifi": [
"multichain",
"thorswap",
"chainflip",
"dflow",
"relay"
],
"rango": [
"Rainbow Bridge",
"Synapse Bridge",
"Optimism Bridge",
"Orbiter",
"Arbitrum Bridge",
"IBC",
"Symbiosis",
"Osmosis",
"Maya Protocol",
"Across"
]
},
"timeout": 30,
"referrer": "rubic.exchange",
"enableChecks": true,
"skipFeeProviders": false,
"showFailedRoutes": false,
"showDangerousRoutes": false,
"depositTradeParams": "all",
"receiver": "0x1b3cB81E51011b549d78bf720b0d924ac763A7C2",
"fromAddress": "",
"dstTokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"dstTokenBlockchain": "ETH",
"srcTokenAddress": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
"srcTokenAmount": "50",
"srcTokenBlockchain": "SOLANA",
"id": "e88fad3f-70db-4901-a14e-caa140d27805",
"onlyDepositTrades": true,
"integratorAddress": "0x3fFF9bDEb3147cE13A7FFEf85Dae81874E0AEDbE",
"slippage": 0.03
},
"uniqueInfo": {
"exolixId": "46bb477f86a8d0"
}
}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
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
Required params for swapDepositTrade
srcTokenAddress*
string
Source token address
0x0000000000000000000000000000000000000000
srcTokenBlockchain*
string
Source token blockchain
SOLANA
srcTokenAmount*
string
Source token amount with decimals
50
dstTokenAddress*
string
Destination token address
0x0000000000000000000000000000000000000000
dstTokenBlockchain*
string
Destination token blockchain
ETH
referrer*
string
Referrer address
rubic.exchange
id*
string
Trade identifier obtained on quote step
e88fad3f-70db-4901-a14e-caa140d27805
receiver*
string
Receipient wallet in target chain
0x1b3cB81E51011b549d78bf720b0d924ac763A7C2
Optional params for swapDepositTrade
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
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
fromAddress
string
Wallet address to make tx from
5dPq2Zehaf4wR5kyvd4ZtyyvuQYD2Ld27icJNygcpGNh
Swap response params
id
string
Trade identifier
60e513d5-8a2d-4e0d-b513-6236d86bc7da
swapType
'cross-chain' | 'on-chain'
Type of swap
cross-chain
transaction
Transaction config to call swap or make deposit
For ordinary swap request: { "approvalAddress": "0x3335733c454805df6a77f825f266e136FB4a3333", "data": "0x...", "to": "0x3335733c454805df6a77f825f266e136FB4a3333", "value": "1050000000000000000" }
For deposit swap: { "depositAddress": "86ynSAUzZQzdBV5MQTNBiL9nnQs2sDCCTovnYfxEJwb8", "amountToSend": "50", "exchangeId": "46bb477f86a8d0" }
warnings
ErrorDto[]
Specific info about quote params provider
[ { code: 301, reason: amountTooLow, data: { minAmount: 0.1 eth } ]
Last updated
Was this helpful?
