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
}
*/
Swagger link

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;
    }
}
*/

Swap request params

Required params

Field
Type
Description
Example

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

Field
Type
Description
Example

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

Field
Type
Description
Example

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

Field
Type
Description
Example

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

Field
Type
Description
Example

id

string

Trade identifier

60e513d5-8a2d-4e0d-b513-6236d86bc7da

quote

Quote params that you send

swapType

'cross-chain' | 'on-chain'

Type of swap

cross-chain

providerType

Inner provider which we use to swap

Rango

fees

Different fees used for swap

routing

The path tokens take during the swap process

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

Specific info about quote params provider

[ { code: 301, reason: amountTooLow, data: { minAmount: 0.1 eth } ]

Last updated

Was this helpful?