CrosschainLib
Overview
License: Apache-2.0-or-later
library CrosschainLibProvides utilities for validating bridgeable token pairs, handling BSC decimal conversions, and resolving Across handler addresses.
Used by cross-chain adapters to ensure token compatibility and proper decimal handling.
Errors info
UnsupportedCrossChainToken
error UnsupportedCrossChainToken()WrongDestinationToken
error WrongDestinationToken()Functions info
isAllowedCrosschainToken
Check if a token is allowed for cross-chain operations on the current chain.
Parameters:
token
address
The token address to check.
Return values:
[0]
bool
True if the token is allowed for cross-chain operations.
applyBscDecimalConversion
Applies BSC decimal conversion for USDC/USDT (18 decimals on BSC vs 6 on other chains).
Handles bidirectional conversion to ensure exact cross-chain value calculation.
Parameters:
inputToken
address
Source token address.
outputToken
address
Destination token address.
amount
uint256
Original amount in source chain decimals.
Return values:
[0]
uint256
Normalized amount for correct cross-chain virtual supply calculation.
getAcrossHandler
Get the appropriate Across MulticallHandler address for a given chain.
BSC (chain ID 56) uses a different handler than other chains.
Parameters:
chainId
uint256
The destination chain ID.
Return values:
handler
address
The MulticallHandler address for the specified chain.
validateBridgeableTokenPair
Validates that input and output tokens are compatible for cross-chain bridging.
Only allows bridging between tokens of the same type (USDC↔USDC, USDT↔USDT, etc.).
Parameters:
inputToken
address
Source token address.
outputToken
address
Destination token address.
Last updated