Skip to main content
Version: 0.2.x-amarok

Parameters for xcall

This is a reference for builders to understand the different parameters of xcall.

function xcall(XCallArgs calldata _args)

XCallArgs

struct XCallArgs {
CallParams params;
address transactingAsset;
uint256 transactingAmount;
uint256 originMinOut;
}
NameTypeDescription
transactingAssetaddressRefers to the contract address of the asset that is to be bridged. This could be the adopted, local, or canonical asset (see this for an explanation of the different kinds of assets).
Usually a xApp will have a higher-level function wrapping xcall in which the asset will be passed as an argument. This allows users to specify which asset they want to work with.
If the xcall is calldata-only (e.g. doesn't bridge any funds), any registered asset can be used here as long as amount: 0.
transactingAmountuint256The amount of tokens to bridge specified in standard format (i.e. to send 1 USDC, a token with 10^18 decimals, you must specify the amount as 1000000000000000000).
originMinOutuint256The minimum amount received after the swap from adopted -> local on the origin domain. This is the way to specify slippage due to the StableSwap Pool, if applicable.
For example, to achieve 3% slippage tolerance this can be calculated as (amount / 100) * 97.

CallParams

struct CallParams {
address to;
bytes callData;
uint32 originDomain;
uint32 destinationDomain;
address agent;
address recovery;
bool forceSlow;
bool receiveLocal;
address callback;
uint256 callbackFee;
uint256 relayerFee;
uint256 destinationMinOut;
}
NameTypeDescription
toaddressRefers to an address on the destination chain. Whether it’s a user’s wallet or the address of another contract depends on the desired use of xcall.
If the xcall is just used to bridge funds, then the user should be able to specify where the funds get sent to.
If the xcall is used to send calldata to a target contract, then this address must be the address of that contract.
callDatabytesIn the case of bridging funds only, this should be empty (""). If calldata is sent, then the encoded calldata must be passed here.
originDomainuint32These refer to Domain IDs (not equivalent to “Chain IDs”).
destinationDomainuint32These refer to Domain IDs (not equivalent to “Chain IDs”).
agentaddressThe address that is allowed to execute transactions on behalf of to on the destination domain. Usually this is a relayer's job but the user can specify an address (including themselves) to do it as well.
This cannot be address(0) if receiveLocal: false. Some address must be able to call forceReceiveLocal on BridgeFacet.sol in case transfers are facing unfavorable slippage conditions for extended periods.
recoveryaddressThe address on destination domain that should receive funds if the execution fails. This ensures that funds are never lost with failed calls.
forceSlowboolSince Solidity doesn't allow for default parameters, integrators must explicitly set this to true when using authenticated (slow path) calls.
If the xcall is unauthenticated (e.g. bridging funds), setting this to true allows users to force the xcall through the slow path and save on the 0.05% transaction fee levied by routers. This is an option for users who don’t care for speed to optimize on cost.
receiveLocalboolSetting this to true allows users to receive the local bridge-flavored asset instead of the adopted asset on the destination domain.
callbackaddressThe address of a contract that implements the ICallback interface. See the detailed spec for callback interaction.
If the target contract doesn’t return anything, this field must be address(0). Otherwise, the specified address must be a contract.
callbackFeeuint256Similar to the relayerFee except this is for paying relayers on the callback execution. If callback: address(0), then this must be 0.
This fee is also bump-able from the origin domain.
relayerFeeuint256This is a fee paid to relayers for relaying the transaction to the destination domain. The fee must be high enough to satisfy relayers’ cost conditions for relaying a transaction, which includes the gas fee plus a bit extra as incentive. This is paid in the origin domain’s native asset - it’s locked on the origin domain and eventually claimed by the relayer.
Connext contracts will assert that the relayerFee matches what is sent in msg.value for the xcall. If, for any reason, the initial relayerFee is set too low, BridgeFacet.sol has a bumpTransfer function that can be called on the origin domain to bump (increase) the initial fee until it’s sufficient for relayers.
destinationMinOutuint256The minimum amount received after the swap from local -> adopted on the destination domain. This is the way to specify slippage due to the StableSwap Pool, if applicable.
For example, to achieve 3% slippage tolerance this can be calculated as (amount / 100) * 97.