Chain Abstraction Guide
Adapter Contract
Installation
forge install connext/connext-integrationSwapForwarderXReceiver
abstract contract SwapForwarderXReceiver is ForwarderXReceiver, SwapAdapter {
using Address for address;
/// @dev The address of the Connext contract on this domain.
constructor(address _connext) ForwarderXReceiver(_connext) {}
/// INTERNAL
/**
* @notice Prepare the data by calling to the swap adapter. Return the data to be swapped.
* @dev This is called by the xReceive function so the input data is provided by the Connext bridge.
* @param _transferId The transferId of the transfer.
* @param _data The data to be swapped.
* @param _amount The amount to be swapped.
* @param _asset The incoming asset to be swapped.
*/
function _prepare(
bytes32 _transferId,
bytes memory _data,
uint256 _amount,
address _asset
) internal override returns (bytes memory) {
//highlight-start
(address _swapper, address _toAsset, bytes memory _swapData, bytes memory _forwardCallData) = abi.decode(
_data,
(address, address, bytes, bytes)
);
//highlight-end
uint256 _amountOut = this.exactSwap(_swapper, _amount, _asset, _toAsset, _swapData);
return abi.encode(_forwardCallData, _amountOut, _asset, _toAsset, _transferId);
}
}Adapter Contract
Origin Domain Transaction
Installation
1) Get the pool fee
2) Encode the forward call
3) Construct the xcall
4) Prepare swap and xcall
5) Estimate relayer fee
6) Estimate amount received
Last updated