Cross-Chain Deposit
Deposit tokens from other chains into your margin wallet
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
Ethereum address of the user making the deposit
Chain ID of the source chain where your tokens are currently located
Amount to deposit in token units (including decimals)
Contract address of the token on the source chain
Process Flow
The cross-chain deposit process follows these steps:
- Check if token approval is needed
- If needed, approve token (separate transaction)
- Execute cross-chain transfer
- Automatic conversion to Arbitrum USDC
- Automatic deposit into margin wallet
Response Fields
Initial Check Response
Indicates if token approval is required before deposit
Present if needsApproval is true. Encoded approval transaction data
Deposit Response
Encoded function call data for the cross-chain deposit
Address of the Squid Router contract
Example Usage
Example Responses
When Approval Needed
When Ready for Deposit
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
-
Always Check Approval First
- Call endpoint first without sending any transactions
- Handle approval if needed before proceeding
-
Handle Network-Specific Requirements
- Different chains may have different token decimals
- Gas fees vary by network
- Transaction confirmation times vary
-
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
User's Ethereum address
Source chain ID
Amount to deposit
Token contract address on source chain