Rubic Documents
  • RUBIC
    • Overview
    • Rubic's Ecosystem
    • Security
    • Tokenomics
    • Roadmap
    • Rubic Discord Roles
    • “Swap to Earn” Program on Rubic
    • MEV-bot Protection
    • B2B Cross-Chain Toolkit
      • Use Cases
      • Why Rubic?
    • Refund Guidelines for Stuck Transactions
  • ⚒️Integrate SDK
    • SDK Overview
    • SDK Architecture
    • SDK Advantages
    • SDK Integration
    • 1️⃣Install SDK
    • 2️⃣Set up SDK
    • 3️⃣Trade calculation
    • 4️⃣Swap Execution
    • 📜Advanced documentation
    • Migration from V2 to V3
    • Contact Us
  • Integrate Widget
    • Widget Overview
    • Instruction
    • White Label Widget Integration Instruction
    • Partners
    • Listing of tokens
  • Rubic API
    • 🔐Tokens API
    • Referrer And Rate Limits
    • Rubic API
      • Supported chains
      • Supported providers
      • Request Quote
      • Request Data
      • Get Cross-Chain Status
      • Integration example
        • Swaps from EVM
        • Swaps from Solana
        • Swaps from TON
        • Swaps from Tron
        • Swaps from Bitcoin
        • Swaps VIA deposit
      • Swagger
      • Models
        • OnChainTradeType
        • CrossChainTradeType
        • FeesDto
        • RoutingDto
        • TransactionDto
        • ErrorDto
      • Errors
    • Monetization And Fees
  • FAQ
    • What is Rubic?
    • How to start using Rubic?
    • Who can use our service?
    • Is KYC required?
    • What are the minimum and maximum trade sizes?
    • Should I list my token before using your service?
    • How to create a Swap?
    • How long does it take to complete a transaction?
    • How is the privacy and security of the transaction ensured?
    • How does Rubic unite different DEX platforms?
    • Why does Rubic offer a choice between different providers?
    • How do I add the BNB Smart Chain and Polygon networks to MetaMask?
    • What should I do when I see the message: “Trading on Uniswap is not available?”
    • What should I do if Uniswap doesn’t display any rates?
    • How can we integrate the Rubic Relay widget?
    • How do we get listed on Rubic?
    • How to Complete swaps to/from TON network using Rubic
  • Contacts
    • Community
    • PR Marketing
    • Business Development
    • Support
    • Influencers Collaboration Requests
  • Legal Documentation
    • Privacy Policy
    • Terms of Use
    • Third-Party Software
  • Audits
    • MixBytes Audit
  • Pitch Deck
Powered by GitBook
On this page
  • Requesting swap data
  • Swap request params

Was this helpful?

  1. Rubic API
  2. Rubic API

Request Data

Get transaction swap data

PreviousRequest QuoteNextGet Cross-Chain Status

Last updated 8 months ago

Was this helpful?

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 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
}
*/
{
  "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

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

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

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 perform approve

{

approvalAddress: string }

warnings

Specific info about quote params provider

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

|

[]

[]

here
QuoteRequestDto
CrossChainTradeType
OnChainTradeType
FeesDto
RoutingDto
TransactionDto
ErrorDto
Swagger link
Swagger UI
Logo