Get swap approval data

Returns data required to execute a crosschain swap. If the input token requires approval, `approvalTxns` will be included in the response.

GET
/swap/approval

Authorization

bearerAuth
AuthorizationBearer <token>

API key for authentication. Request your key at https://t.me/acrosstg.

In: header

Query Parameters

tradeType*string

Defines the type of trade execution strategy used in a swap or bridge request. Each trade type specifies how input and output token amounts are determined and how associated fees are handled. Here are the tradeTypes:

  • exactInput: Use this when you want to bridge or swap a fixed amount of your inputToken. You define the exact quantity of tokens to send, and the system calculates the amount of outputToken you'll receive after all fees are deducted. If your input isn't sufficient to cover the transaction fees, the request will fail.
  • minOutput: Use this when you need to receive at least a certain amount of the outputToken. You set the minimum output you're willing to accept, and the system calculates the necessary input amount, including fees and slippage. Due to price slippage, the final amount you receive will be at least your specified minimum but could be slightly more. This is especially useful for simple swaps without subsequent crosschain actions.
  • exactOutput: Use this when you need to receive a precise amount of the destination token. You specify the exact output you require, and the system calculates the total input needed to guarantee that amount. If market conditions prevent the system from delivering that exact amount, the entire transaction is cancelled, and your funds are refunded. This is recommended for multi-step transactions, like providing an exact amount of an ERC20 token to a minting contract.
Default"exactInput"
Value in"minOutput" | "exactOutput" | "exactInput"
amount*string

Required amount is in inputToken if tradeType=exactInput otherwise amount is in outputToken.

inputToken*string

Address of the input token on the origin chain.

outputToken*string

Address of the output token on the destination chain.

originChainId*integer

Chain ID of the origin chain.

destinationChainId*integer

Chain ID of the destination chain.

depositor*string

Address of the depositor initiating the swap.

recipient?string

Address of the account receiving the output token. Defaults to depositor if not provided.

appFee?number

Enables integrators to collect a customizable fee in the output token, sent to a designated address on the destination chain. appFee is expressed in percentage with value ranging between 0 and 1.

appFeeRecipient?string

Address of the account receiving the app fees. Must be defined if you are also defining appFee.

integratorId?string

2-byte hex-string that identifies the integrator. E.g., "0xdead".

refundAddress?string

Address to receive refunds. Defaults to depositor if not provided.

Default"0xDEPOSITOR_ADDRESS"
refundOnOrigin?boolean

For routes that include a destination swap (bridgeableToAny or anyToAny), destination refunds are the default behavior unless refundOnOrigin=true is explicitly set when calling the Swap API. Across determines refund behavior based on the route type (when refundOnOrigin is NOT explicitly set):

  1. B2B or A2B routes:
  • refundOnOrigin defaults to true
  • Refunds occur on the origin chain
  • Destination refunds do not apply here
  1. B2A or A2A routes
  • refundOnOrigin defaults to false
  • Refunds occur on the destination chain

If an explicit refundOnOrigin value is provided, that value is always respected. If a refund occurs, the address that receives the refunded funds is determined using the following priority order: 1. refundAddress (if explicitly specified) 2. recipient (if specified) 3. depositor (fallback) This applies to both origin and destination refunds.

Defaulttrue
slippage?string

Slippage tolerance percentage can be set to auto (default) or a numerical value. Numerical value must be between 0 and 1 representing corresponding percentage. So if you want slippage to be 0.5% , you need to pass 0.005 as the value here). If slippage is auto, the Swap API will select the best slippage intelligently and move ahead with the crosschain swap. If slippage is set to a numerical value, for example 0.01 (1% slippage), it divides this value equally for each leg. This means 0.5% slippage for origin and 0.5% slippage for destination.

Default"auto"
Formatfloat | string
skipOriginTxEstimation?boolean

Used to define whether you want to calculate the transaction details (swap) on origin chain. Defaults to false.

Defaulttrue
strictTradeType?boolean

Used to define whether you want to strictly follow the defined tradeType. Defaults to true.

Defaulttrue
excludeSources?array<>

Used to define the sources you want to exclude from the crosschain swap action. Defaults to an empty array. Available sources can be retrieved via /swap/sources endpoint

Default[]
includeSources?array<>

Used to define the sources you want to include from the crosschain swap action. Defaults to an empty array. Available sources can be retrieved via /swap/sources endpoint

Default[]

Response Body

application/json

application/json

application/json

curl -X GET "https://app.across.to/api/swap/approval?tradeType=minOutput&amount=1000000&inputToken=0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85&outputToken=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1&originChainId=10&destinationChainId=42161&depositor=0xA4d353BBc130cbeF1811f27ac70989F9d568CeAB"
{
  "crossSwapType": "anyToBridgeable",
  "amountType": "exactInput",
  "checks": {
    "allowance": {
      "token": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
      "spender": "0x89415a82d909a7238d69094C3Dd1dCC1aCbDa85C",
      "actual": "115792089237316195423570985008687907853269984665640564039457584007913116539935",
      "expected": "1000000"
    },
    "balance": {
      "token": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
      "actual": "2993387",
      "expected": "1000000"
    }
  },
  "steps": {
    "originSwap": {
      "tokenIn": {
        "decimals": 6,
        "symbol": "USDC",
        "address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
        "name": "USD Coin",
        "chainId": 10
      },
      "tokenOut": {
        "address": "0x4200000000000000000000000000000000000006",
        "decimals": 18,
        "symbol": "WETH",
        "chainId": 10
      },
      "inputAmount": "1000000",
      "outputAmount": "472306805062946",
      "minOutputAmount": "468764504022050",
      "maxInputAmount": "1000000",
      "swapProvider": {
        "name": "0x",
        "sources": [
          "woofi_v2"
        ]
      },
      "slippage": 0.0075
    },
    "bridge": {
      "inputAmount": "468764504022050",
      "outputAmount": "464434354522974",
      "tokenIn": {
        "address": "0x4200000000000000000000000000000000000006",
        "decimals": 18,
        "symbol": "WETH",
        "chainId": 10
      },
      "tokenOut": {
        "decimals": 18,
        "symbol": "WETH",
        "address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
        "name": "Wrapped Ether",
        "chainId": 42161
      },
      "fees": {
        "amount": "4330149499076",
        "pct": "9237366442904769",
        "token": {
          "address": "0x4200000000000000000000000000000000000006",
          "decimals": 18,
          "symbol": "WETH",
          "chainId": 10
        },
        "details": {
          "type": "across",
          "relayerCapital": {
            "amount": "46867294561",
            "pct": "99980468145248",
            "token": {
              "address": "0x4200000000000000000000000000000000000006",
              "decimals": 18,
              "symbol": "WETH",
              "chainId": 10
            }
          },
          "destinationGas": {
            "amount": "4260773033213",
            "pct": "9089367895086142",
            "token": {
              "address": "0x4200000000000000000000000000000000000006",
              "decimals": 18,
              "symbol": "WETH",
              "chainId": 10
            }
          },
          "lp": {
            "amount": "22509171302",
            "pct": "48018079673379",
            "token": {
              "address": "0x4200000000000000000000000000000000000006",
              "decimals": 18,
              "symbol": "WETH",
              "chainId": 10
            }
          }
        }
      },
      "provider": "across"
    }
  },
  "inputToken": {
    "decimals": 6,
    "symbol": "USDC",
    "address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
    "name": "USD Coin",
    "chainId": 10
  },
  "outputToken": {
    "decimals": 18,
    "symbol": "WETH",
    "address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
    "name": "Wrapped Ether",
    "chainId": 42161
  },
  "refundToken": {
    "address": "0x4200000000000000000000000000000000000006",
    "decimals": 18,
    "symbol": "WETH",
    "chainId": 10
  },
  "fees": {
    "total": {
      "amount": "6701",
      "amountUsd": "0.0067",
      "token": {
        "decimals": 6,
        "symbol": "USDC",
        "address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
        "name": "USD Coin",
        "chainId": 10
      },
      "pct": "6701306754817189",
      "details": {
        "type": "total-breakdown",
        "swapImpact": {
          "amount": "-2490",
          "amountUsd": "-0.002490006186373967",
          "token": {
            "decimals": 6,
            "symbol": "USDC",
            "address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
            "name": "USD Coin",
            "chainId": 10
          },
          "pct": "-2490491832281262"
        },
        "app": {
          "amount": "0",
          "amountUsd": "0.0",
          "token": {
            "decimals": 18,
            "symbol": "WETH",
            "address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
            "name": "Wrapped Ether",
            "chainId": 42161
          },
          "pct": "0"
        },
        "bridge": {
          "amount": "4330149499076",
          "amountUsd": "0.009190006186373967",
          "token": {
            "address": "0x4200000000000000000000000000000000000006",
            "decimals": 18,
            "symbol": "WETH",
            "chainId": 10
          },
          "pct": "9191798587098451",
          "details": {
            "type": "across",
            "lp": {
              "amount": "22509171302",
              "amountUsd": "0.000047771889529374",
              "token": {
                "address": "0x4200000000000000000000000000000000000006",
                "decimals": 18,
                "symbol": "WETH",
                "chainId": 10
              },
              "pct": "47781206864712"
            },
            "relayerCapital": {
              "amount": "46867294561",
              "amountUsd": "0.000099467865265647",
              "token": {
                "address": "0x4200000000000000000000000000000000000006",
                "decimals": 18,
                "symbol": "WETH",
                "chainId": 10
              },
              "pct": "99487265282377"
            },
            "destinationGas": {
              "amount": "4260773033213",
              "amountUsd": "0.009042766431578945",
              "token": {
                "chainId": 42161,
                "address": "0x0000000000000000000000000000000000000000",
                "decimals": 18,
                "symbol": "ETH"
              },
              "pct": "9044530114951359"
            }
          }
        }
      }
    },
    "totalMax": {
      "amount": "14102",
      "amountUsd": "0.0141",
      "token": {
        "decimals": 6,
        "symbol": "USDC",
        "address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
        "name": "USD Coin",
        "chainId": 10
      },
      "pct": "14102750036257069",
      "details": {
        "type": "max-total-breakdown",
        "maxSwapImpact": {
          "amount": "4910",
          "amountUsd": "0.004909993813626033",
          "token": {
            "decimals": 6,
            "symbol": "USDC",
            "address": "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
            "name": "USD Coin",
            "chainId": 10
          },
          "pct": "4910951449158618"
        },
        "app": {
          "amount": "0",
          "amountUsd": "0.0",
          "token": {
            "decimals": 18,
            "symbol": "WETH",
            "address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
            "name": "Wrapped Ether",
            "chainId": 42161
          },
          "pct": "0"
        },
        "bridge": {
          "amount": "4330149499076",
          "amountUsd": "0.009190006186373967",
          "token": {
            "address": "0x4200000000000000000000000000000000000006",
            "decimals": 18,
            "symbol": "WETH",
            "chainId": 10
          },
          "pct": "9191798587098451",
          "details": {
            "type": "across",
            "lp": {
              "amount": "22509171302",
              "amountUsd": "0.000047771889529374",
              "token": {
                "address": "0x4200000000000000000000000000000000000006",
                "decimals": 18,
                "symbol": "WETH",
                "chainId": 10
              },
              "pct": "47781206864712"
            },
            "relayerCapital": {
              "amount": "46867294561",
              "amountUsd": "0.000099467865265647",
              "token": {
                "address": "0x4200000000000000000000000000000000000006",
                "decimals": 18,
                "symbol": "WETH",
                "chainId": 10
              },
              "pct": "99487265282377"
            },
            "destinationGas": {
              "amount": "4260773033213",
              "amountUsd": "0.009042766431578945",
              "token": {
                "chainId": 42161,
                "address": "0x0000000000000000000000000000000000000000",
                "decimals": 18,
                "symbol": "ETH"
              },
              "pct": "9044530114951359"
            }
          }
        }
      }
    },
    "originGas": {
      "amount": "626037662500",
      "amountUsd": "0.001328658512253625",
      "token": {
        "chainId": 10,
        "address": "0x0000000000000000000000000000000000000000",
        "decimals": 18,
        "symbol": "ETH"
      }
    }
  },
  "inputAmount": "1000000",
  "maxInputAmount": "1000000",
  "expectedOutputAmount": "467917612181896",
  "minOutputAmount": "464434354522974",
  "expectedFillTime": 2,
  "swapTx": {
    "simulationSuccess": true,
    "chainId": 10,
    "to": "0x89415a82d909a7238d69094C3Dd1dCC1aCbDa85C",
    "data": "0x110560ad0000000000000000000000000000000000000000000000000000000000000020...",
    "gas": "571750",
    "maxFeePerGas": "1094950",
    "maxPriorityFeePerGas": "1000000"
  },
  "quoteExpiryTimestamp": 1770679043,
  "id": "vqhfb-1770675636494-01dc8983f2fc",
  "x-gitbook-description-html": "<p>Swap approval data returned successfully.</p>"
}
{
  "type": "AcrossApiError",
  "code": "INVALID_PARAM",
  "status": 400,
  "message": "Invalid parameter at path 'depositor'. Expected type 'validAddress'",
  "id": "dbsft-1756414126692-6a64b1802b70"
}
{
  "type": "AcrossApiError",
  "code": "INVALID_PARAM",
  "status": 400,
  "message": "Relayer Address (0x00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e67) doesn't have enough funds to support this deposit; for help, please reach out to https://discord.across.to",
  "id": "dbsft-1756414126692-6a64b1802b70"
}