Openocean APIs
  • Developer
    • ⚙️APIs
      • Swap API
        • Guide
        • API V4
        • API V3
        • GMX Exclusive API
        • SDK
      • Limit Order API
        • Guide
        • API
        • SDK
      • Sweep Swap API
        • Guide
        • API
      • DCA API
        • Guide
        • API
        • SDK
      • Meme API
        • Data API
        • Transaction API
        • Websocket API
      • Ticket API
        • API
      • 🤖Swagger
    • 👾Widget
      • Getting Started
      • Customize Theme
      • Other Reference
      • Widget V2
        • Getting Started
    • ℹ️Developer Resources
      • 🔗Supported Chains
      • 📋Contracts of Chains
      • 🚩Common Error Code
      • 📖Developer references & glossary
Powered by GitBook
On this page
  • Sweep Swap API
  • Send transaction
  1. Developer
  2. APIs
  3. Sweep Swap API

Guide

PreviousSweep Swap APINextAPI

Last updated 5 months ago

Sweep Swap API

Before you start using sweep swap API, make sure you understand the content of the swap API. Normally, you only need to use a transaction body different from the swap API in the last step to build. Check below OpenOcean swap API as reference. It currently applies to V3 version.

Send transaction

Here is the last step! Now you have several ways to swap the token you selected. You can use the multi_swap_quote API to get the transaction body from our API server. Here is a case for you to make a transaction on Arbitrum Chain.

The work flow we recommend for API users, is using swap_quote API to get transaction body, then use the wallet to request your transaction on chain.

https://open-api.openocean.finance/v3/arbitrum/multi_swap_quote
async swap() {
    let params = {
            inToken: [
                {
                    inTokenSymbol: "ETH",
                    inTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
                    amount: "1000000000000000000",
                    slippage: 100
                },
                {
                    inTokenSymbol: "ARB",
                    inTokenAddress: "0x912CE59144191C1204E64559FE8253a0e49E6548",
                    amount: "1000000000000000000",
                    slippage: 100
                }
            ],
            outToken: {
                outTokenSymbol: "USDT",
                outTokenAddress: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
            },
            gasPrice: 10000000,
            account: "0xB3cbefF0336BaA4863Cb51238bD6C35BDAaB3D84"
        };
       
    const res = await axios.post("https://open-api.openocean.finance/v3/arbitrum/multi_swap_quote", params);
    if(res) {
        const {data,gasPrice} = res.data;
        const swapParams = {
            from:this.address,
            to:'0x6352a56caadc4f1e25cd6c75970fa768a3304e64', //Please use the contract from the contract page
            gasPrice: gasPrice,
            data
            }; 
        const result = await this.myWallet.sdk.eth.sendTransaction(swapParams)
     };
    

Once your wallet plugin was triggered, which means you are successfully using the sendTransaction function and all params are set. You can swap your token and the transaction hash can be fetched once your transaction is sent on-chain.

⚙️
API
swap API Getting Started