GMX Exclusive API

This API is exclusively to leverage GMX V1 and V2 pools on Arbitrum. To ensure users get the best trading rates, v1 and v2 pools are compared and the API swaps with the most favorable option.

Price Quote

  • url: https://open-api.openocean.finance/v3/arbitrum/gmx_quote

  • method: get

  • params:

parameter

type

example

description

inTokenAddress

string

0xaf88d065e77c8cC2239327C5EDb3A432268e5831

token address

outTokenAddress

string

0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9

out token address

amount

string

100

Please set token amount without decimals. e.g. 1.00 ETH set as 1

1.23 USDC set as 1.23

gasPrice

string

0.1

Please set the gas price in GWEI without decimals e.g. 14 GWEI set as 14

multi_dex

boolean (Optional)

false (default false)

If added, it's the comparison between the price from dexs integrated to the price from GMX V2.

  • Example:

  • request

https://open-api.openocean.finance/v3/arbitrum/gmx_quote?inTokenAddress=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&outTokenAddress=0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9&amount=100&slippage=1&gasPrice=0.0111875
  • response:

{
"code": 200,
"data": {
    "inToken": {
        "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        "decimals": 6,
        "symbol": "USDC",
        "name": "USD Coin",
        "usd": "1.001",
        "volume": 100.1
    },
    "outToken": {
        "address": "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
        "decimals": 6,
        "symbol": "USDT",
        "name": "Tether USD",
        "usd": "1.001",
        "volume": 100.07039042
    },
    "inAmount": "100000000",
    "outAmount": "99970420",
    "estimatedGas": "859474",
    "dexes": [
        {
            "dexIndex": 54,
            "dexCode": "GMXV2",
            "swapAmount": "99970420"
        }
    ],
    "path": {
        "from": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        "to": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
        "parts": 10,
        "routes": [
            {}
        ]
    },
    "save": 0,
    "price_impact": "-0.03%"
}
}

Swap Quote

  • url: https://open-api.openocean.finance/v3/arbitrum/gmx_swap_quote

  • method: get

  • params:

parameter

type

example

description

inTokenAddress

string

0xaf88d065e77c8cC2239327C5EDb3A432268e5831

token address

outTokenAddress

string

0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9

out token address

amount

string

100

Please set token amount without decimals. e.g. 1.00 ETH set as 1

1.23 USDC set as 1.23

gasPrice

string

0.1

Please set the gas price in GWEI without decimals e.g. 14 GWEI set as 14

slippage

number

1

Define the acceptable slippage level by inputting a percentage value within the range of 0.05 to 50. e.g. 1% slippage set as 1

default value 1

account

string

user's address

referrer

string (Optional)

0x0000000000000000000000000000000000000000

Please contact us for a unique referrer parameter

multi_dex

boolean. (Optional)

false (default false)

If added, it's the comparison between the price from dexs integrated to the price from GMX V2.

  • Example:

  • Request:

https://open-api.openocean.finance/v3/arbitrum/gmx_swap_quote?inTokenAddress=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&outTokenAddress=0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9&amount=100&slippage=1&gasPrice=0.0111875&account=0x929B44e589AC4dD99c0282614e9a844Ea9483C69
  • response:

{
"code": 200,
"data": {
    "inToken": {
        "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        "decimals": 6,
        "symbol": "USDC",
        "name": "USD Coin",
        "usd": "1.001",
        "volume": 100.1
    },
    "outToken": {
        "address": "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
        "decimals": 6,
        "symbol": "USDT",
        "name": "Tether USD",
        "usd": "1.001",
        "volume": 100.06667270599999
    },
    "inAmount": "100000000",
    "outAmount": "99966706",
    "estimatedGas": 3442140,
    "minOutAmount": "0",
    "from": "0x7AeEF1035Ba6794C0478718a2330671Ec8802aF1",
    "to": "0x6352a56caadC4F1E25CD6c75970Fa768A3304e64",
    "value": "0",
    "gasPrice": "11187500",
    "data": "0x30eef8bd...",
    "chainId": 42161,
    "rfqDeadline": 0,
    "gmxFee": 64005007625000,
    "price_impact": "-0.04%"
}
}

If the "gmxFee" from above response is gmxFee>0 (meaning the swaps go through GMX V2 pools), it needs to use the following Get Transaction method to fetch the swap hash. otherwise, you could refer the docs here to get hashes.

Get Transaction

  • url: https://open-api.openocean.finance/v3/arbitrum/gmx_transaction

  • method: get

  • params:

parameter

type

example

description

hash

string

transaction hash

  • Example:

  • request:

https://open-api.openocean.finance/v3/arbitrum/gmx_transaction?hash=0xd5f0bb09e95abf7a73fd02e465d1c4aa9a1a45a5bc8dee422cbdef706b00bd50
  • response:

{
"code": 200,
"data": {
    srcHash: '', 
    dstHash: '', 
    status: 'success' || 'fail'
}
}