API Reference

Source Code

The API is designed to be run serverlessly (without storing state) and is a wrapper on top of the SDKarrow-up-right. See full implementation herearrow-up-right.

Caching & Liveness

Users of the Across API are requested to cache results for no longer than 300 seconds.

The Across API serves data that is derived from the on-chain state of the Across contracts and relayer bots. The on-chain state is subject to change each block, and cached data can quickly become invalid as a result.

The exception is the /deposit/status endpoint which is implemented in this stateful repositoryarrow-up-right because it relies on an indexing solution.

circle-exclamation

API Endpoints

Get swap approval data

get

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

Query parameters
tradeTypestring Β· enumRequired

Type of trade. Use minOutput, exactInput or exactOutput.

Default: exactInputPossible values:
amountstringRequired

Required amount of output token in smallest unit.

Example: 1000000
inputTokenstringRequired

Address of the input token on the origin chain.

Example: 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85
outputTokenstringRequired

Address of the output token on the destination chain.

Example: 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
originChainIdintegerRequired

Chain ID of the origin chain.

Example: 10
destinationChainIdintegerRequired

Chain ID of the destination chain.

Example: 42161
depositorstringRequired

Address of the depositor initiating the swap.

Example: 0xA4d353BBc130cbeF1811f27ac70989F9d568CeAB
recipientstringRequired

Address of the account receiving the output token.

Example: 0xA4d353BBc130cbeF1811f27ac70989F9d568CeAB
integratorIdstringOptional

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

Example: 0xdead
refundAddressstringOptional

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

Default: 0xDEPOSITOR_ADDRESS
refundOnOriginbooleanOptional

Specifies whether refund should be sent on the origin chain. Defaults to true.

Default: true
slippageTolerancenumber Β· floatOptional

Slippage tolerance percentage (e.g., 1 for 1%, 0.5 for 0.5%).

Default: 1
Responses
chevron-right
200

Swap approval data returned successfully.

application/json
inputAmountstringOptional

Required input amount in the smallest unit of the input token.

Example: 1065159719994
expectedOutputAmountstringOptional

Expected amount of output token.

Example: 940201830
minOutputAmountstringOptional

Minimum guaranteed amount of output token.

Example: 940201830
expectedFillTimeintegerOptional

Expected time in seconds to complete the swap.

Example: 8
get
/swap/approval
circle-exclamation

Learn how to integrate the /swap/approval Endpoint

Let us now focus on conducting a crosschain swap with the following parameters:

  1. tradeType : Defines the type of trade for eg - minOutput.

  2. amount : Specifies amount of inputToken in the smallest unit (wei for ETH or 6 decimals for USDC).

  3. inputToken : Address of the token being swapped.

  4. originChainId : Chain ID of the source/origin chain (232 for Lens Chain mainnet).

  5. outputToken : Address of the token to be received after the swap.

  6. destinationChainId : Chain ID of the destination chain where the output token will be delivered.

  7. depositor : The address of the sender (usually the wallet initiating the swap).

In this specific example, we will be swapping 1 USDC on Optimism with a related amount of ETH on Arbitrum.

Run the following script to conduct the crosschain swap:

Upon successful execution of the /swap/approval endpoint, the return data should be something like this:

With the above response from the /swap/approval endpoint, you can proceed to sign transaction on the wallet client.

Planned Advancements

We're continuously enhancing the /swap endpoint to provide a more robust and flexible swapping experience. Here's a glimpse into upcoming improvements:

  • Advanced DEX Aggregation: Expect smarter routing across multiple DEXes, including 0x and LiFi, for optimal execution.

  • Customizable Application Fees: Integrate the ability to specify and manage application-specific fees directly within the swap.

  • Permit2 Integration: Streamlined token approvals through Permit2 for a smoother user experience.

  • Destination Chain Embedded Actions: Enable post-swap actions directly on the destination chain for more complex workflows.

  • Comprehensive Native Token Support: Seamlessly swap to and from native chain tokens (e.g., ETH).

  • Detailed API Documentation: Comprehensive API docs for all /swap related endpoints, including clear error responses and usage guides.


Retrieve current transfer limits of the system

get
/limits

Returns transfer limits for inputToken+outputToken, originChainId, and destinationChainId.

Query parameters
inputTokenstringRequired

Address of token to bridge on the origin chain. Must be used together with parameter outputToken. For ETH, use the wrapped address, like WETH.

Note that the address provided must exist on the specified originChainId.

Example: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
outputTokenstringRequired

Address of token to bridge on the destination chain. Must be used together with parameter inputToken. For ETH, use the wrapped address, like WETH.

Note that the address provided must match the token address on the specified destinationChainId below.

Example: 0x4200000000000000000000000000000000000006
originChainIdall ofRequired

Chain ID where the specified token or inputToken exists.

Example: 1
integer Β· enum Β· min: 1OptionalPossible values:
destinationChainIdall ofRequired

The intended destination chain ID of the bridge transfer.

Example: 10
integer Β· enum Β· min: 1OptionalPossible values:
Responses
chevron-right
200

Transfer limits

application/json
minDepositstringOptional

The minimum deposit size in the tokens' units. Note: USDC has 6 decimals, so this value would be the number of USDC multiplied by 1e6. For WETH, that would be 1e18.

Example: 7799819
maxDepositstringOptional

The maximum deposit size in the tokens' units. Note: The formatting of this number is the same as minDeposit.

Example: 22287428516241
maxDepositInstantstringOptional

The max deposit size that can be relayed "instantly" on the destination chain. Instantly means that there is relayer capital readily available and that a relayer is expected to relay within seconds to 5 minutes of the deposit.

Example: 201958902363
maxDepositShortDelaystringOptional

The max deposit size that can be relayed with a "short delay" on the destination chain. This means that there is relayer capital available on mainnet and that a relayer will immediately begin moving that capital over the canonical bridge to relay the deposit. Depending on the chain, the time for this can vary. Polygon is the worst case where it can take between 20 and 35 minutes for the relayer to receive the funds and relay. Arbitrum is much faster, with a range between 5 and 15 minutes. Note: if the transfer size is greater than this, the estimate should be between 2-4 hours for a slow relay to be processed from the mainnet pool.

Example: 2045367713809
recommendedDepositInstantstringOptional

The recommended deposit size that can be relayed "instantly" on the destination chain. Instantly means that there is relayer capital readily available and that a relayer is expected to relay within seconds to 5 minutes of the deposit. Value is in the smallest unit of the respective token.

Example: 2045367713809
get
/limits
Curl

Track the lifecycle of a deposit

get
/deposit/status

Returns the fill status of a deposit along with a corresponding fill transaction hash if filled.

This endpoint loads data queried by an indexing service that polls relevant events on a 10-second cadence. Users should therefore expect an average latency of 1 to 15 seconds after submitting a deposit to see the status changed in this endpoint. This delay comes from the time it takes for the internal indexing to include the deposit transaction.

Query parameters
originChainIdall ofRequired

Chain Id where the deposit originated from.

Example: 137
integer Β· enum Β· min: 1OptionalPossible values:
depositIdintegerRequired

The deposit id that is emitted from the DepositV3 function call as a V3FundsDeposited event.

Example: 1349975
Responses
chevron-right
200

Lifecycle of a transaction

application/json
fillStatusstring Β· enumOptional

The status of the deposit.

  • filled: Deposits with this status have been filled on the destination chain and the recipient should have received funds. A FilledV3Relay event was emitted on the destination chain SpokePool.
  • pending: Deposit has not been filled yet.
  • expired: Deposit has expired and will not be filled. Expired deposits will be refunded to the depositor on the originChainId in the next batch of repayments.
  • refunded: Deposit has expired and the depositor has been successfully refunded on the originChain.
  • slowFillRequested: Deposit has been made but no relayer has filled the intent, therefore Across' relayer fills the user’s intent without requiring another relayer to front the capital. It's important that the input token and output token are the same asset here.
Possible values:
fillTxHashstringOptional

The transaction hash of the fill transaction on the destination chain. This field is only present when fillStatus is filled.

destinationChainIdintegerOptional

The chain id where the fill transaction will take place.

get
/deposit/status
200

Lifecycle of a transaction

circle-info

For best results, we recommend using the deposit/status endpoint on mainnet only. Our event indexing currently focuses on mainnet, so testnet queries may return incomplete data.

Get all deposits for a given depositor

get
/deposits

Returns all deposits for a given depositor.

This endpoint loads data queried by an indexing service that polls relevant events on a 10-second cadence. Users should therefore expect an average latency of 1 to 15 seconds after submitting a deposit to see the status changed in this endpoint. This delay comes from the time it takes for the internal indexing to include the deposit transaction.

Query parameters
limitintegerOptional

Maximum number of deposits to return in a single request; used for pagination.

Example: 50
skipintegerOptional

Number of deposits to skip from the beginning of the result set; used for pagination.

Example: 100
depositorstringOptional

Wallet address of the depositor; filters results to deposits made by this address.

Example: 0x89f423567c2648BB828c3997f60c47b54f57Fa6e
Responses
chevron-right
200

List of deposits for a given depositor

application/json
idintegerOptional

Internal unique identifier for the deposit record.

relayHashstringOptional

Hash of the relay data used to verify and track fill events.

depositIdstringOptional

Unique identifier assigned to the deposit event on the origin chain.

originChainIdintegerOptional

The chain ID where the deposit was originally made.

destinationChainIdintegerOptional

The target chain ID where the fill is expected to complete.

depositorstringOptional

Wallet address of the user who initiated the deposit.

recipientstringOptional

Wallet address intended to receive funds on the destination chain.

inputTokenstringOptional

Address of the token deposited on the origin chain.

inputAmountstringOptional

Amount of inputToken sent in the deposit (in wei).

outputTokenstringOptional

Address of the token expected to be received on the destination chain.

outputAmountstringOptional

Amount of outputToken expected to be received (in wei).

messagestringOptional

Optional arbitrary bytes message encoded with the deposit intent.

messageHashstringOptional

Hash of the message payload.

exclusiveRelayerstringOptional

Address of the relayer granted exclusivity to fill the deposit, if any.

exclusivityDeadlinestring Β· date-time Β· nullableOptional

Timestamp indicating when relayer exclusivity expires.

fillDeadlinestring Β· date-timeOptional

Deadline by which the deposit must be filled before expiring.

quoteTimestampstring Β· date-timeOptional

Time at which the quote for the deposit was generated.

depositTxHashstringOptional

Transaction hash of the deposit on the origin chain.

depositBlockNumberintegerOptional

Block number where the deposit transaction was confirmed.

depositBlockTimestampstring Β· date-timeOptional

Timestamp of the block containing the deposit transaction.

statusstring Β· enumOptional

The status of the deposit fill lifecycle.

Possible values:
depositRefundTxHashstring Β· nullableOptional

Transaction hash for refund if deposit expired and funds were returned to the depositor.

swapTokenPriceUsdstring Β· nullableOptional

USD price of the token used in any optional swap.

swapFeeUsdstring Β· nullableOptional

Fee paid in USD for the optional swap (if performed).

bridgeFeeUsdstringOptional

Fee paid in USD for bridging the funds across chains.

inputPriceUsdstringOptional

USD price of the input token at the time of deposit.

outputPriceUsdstringOptional

USD price of the output token at the time of quote.

fillGasFeestringOptional

Gas cost incurred in native token units during fill.

fillGasFeeUsdstringOptional

USD value of the gas fee for filling the deposit.

fillGasTokenPriceUsdstringOptional

USD price of the gas token on the destination chain at the time of fill.

swapTransactionHashstring Β· nullableOptional

Transaction hash for any token swap conducted on the destination chain.

swapTokenstring Β· nullableOptional

Token address used in a swap on the destination chain, if any.

swapTokenAmountstring Β· nullableOptional

Amount of the swapToken exchanged, if a swap occurred.

relayerstringOptional

Address of the relayer that submitted the fill on the destination chain.

fillBlockTimestampstring Β· date-timeOptional

Timestamp when the fill was confirmed on the destination chain.

fillTxstringOptional

Transaction hash of the actual fill transaction.

speedupsstring[]Optional

List of transaction hashes representing optional speedup fills.

get
/deposits
200

List of deposits for a given depositor

Last updated