POST
/
api
/
crosschaindeposit

Overview

The Cross-Chain Deposit endpoint enables deposits from chains other than Arbitrum into your margin wallet. It handles the entire process of bridging tokens and depositing them into your account automatically.

Request Body

userAddress
string
required

Ethereum address of the user making the deposit

fromChainId
integer
required

Chain ID of the source chain where your tokens are currently located

amount
string
required

Amount to deposit in token units (including decimals)

tokenAddress
string
required

Contract address of the token on the source chain

Process Flow

The cross-chain deposit process follows these steps:

  1. Check if token approval is needed
  2. If needed, approve token (separate transaction)
  3. Execute cross-chain transfer
  4. Automatic conversion to Arbitrum USDC
  5. Automatic deposit into margin wallet

Response Fields

Initial Check Response

needsApproval
boolean

Indicates if token approval is required before deposit

approvalCalldata
string

Present if needsApproval is true. Encoded approval transaction data

Deposit Response

calldata
string

Encoded function call data for the cross-chain deposit

routerAddress
string

Address of the Squid Router contract

Example Usage

Example Responses

When Approval Needed

{
  "needsApproval": true,
  "approvalCalldata": "0x095ea7b3...",
  "spenderAddress": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
}

When Ready for Deposit

{
  "calldata": "0x4d595245...",
  "routerAddress": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
}

Implementation Notes

  • Higher fees compared to direct Arbitrum deposits due to cross-chain operations
  • Transaction time varies based on source chain and network conditions
  • Amount is automatically converted to USDC on Arbitrum
  • Requires two transactions if token approval is needed
  • Uses Squid Router for cross-chain transfers

Best Practices

  1. Always Check Approval First

    • Call endpoint first without sending any transactions
    • Handle approval if needed before proceeding
  2. Handle Network-Specific Requirements

    • Different chains may have different token decimals
    • Gas fees vary by network
    • Transaction confirmation times vary
  3. Error Handling

    • Implement proper timeout handling
    • Account for potential cross-chain delays
    • Verify final deposit in margin wallet

Error Responses

The endpoint will return a 400 status code for:

  • Invalid or missing userAddress
  • Invalid fromChainId
  • Invalid amount format
  • Unsupported token or chain
  • Invalid token address

A 500 status code will be returned for:

  • Router contract errors
  • Bridge service unavailability
  • Other internal errors

Body

application/json
userAddress
string
required

User's Ethereum address

fromChainId
integer
required

Source chain ID

amount
string
required

Amount to deposit

tokenAddress
string
required

Token contract address on source chain

Response

200 - application/json
needsApproval
boolean
required

Indicates if token approval is required

approvalCalldata
string

Encoded approval transaction data

spenderAddress
string

Address of the contract to approve