Guide

Overview

OpenOcean Gasless Swap lets users trade tokens without paying gas fees - OpenOcean covers the transaction costs. This function supports batch gasless transactions to minimize on-chain expenses and leverages the Permit2 authorization mechanism for enhanced security and seamless signature approvals.

Supported Chains

const gaslessChain = [
  'arbitrum', 'bsc', 'sonic', 'base', 'sei', 
  'eth', 'hyperevm', 'avax', 'uni'
]

API Endpoints

1. Get Swap Quote

Endpoint: GET /v4/gasless/{chainId}/quote

Parameters:

  • inTokenAddress: Input token address

  • outTokenAddress: Output token address

  • amountDecimals: Input amount (in smallest unit)

  • slippage: Slippage percentage (0-100)

  • gasPrice: Gas price

  • account: User wallet address

2. Execute Gasless Swap

Endpoint: POST /v4/gasless/{chainId}/swap

Request Body:

3. Query Transaction Status

Endpoint: GET /v4/gasless/{chainId}/order?orderHash={orderHash}

  • Permit2 Signature Process

1. Get Permit2 Contract Address

2. Create Permit2 Signature

  • Complete Transaction Flow

1. Pre-flight Checks

2. Get Quote

3. Token Approval

4. Execute Swap

5. Poll Status

Error Handling

  • Wallet not connected

  • Chain not supported for gasless

  • User rejected signature

  • Transaction failed

  • Timeout handling

Dependencies

Important Notes

  1. Only supports specific chains

  2. Non-native tokens require approval

  3. Signatures valid for 30 minutes

  4. Set reasonable slippage

  5. Handle errors properly

  6. Poll transaction status

Last updated