IFastBridgeRouter
Functions
setFastBridge
Sets the address of the FastBridge contract
This function is only callable by the owner
function setFastBridge(address fastBridge_) external;
Parameters
Name | Type | Description |
---|---|---|
fastBridge_ | address | The address of the FastBridge contract |
setSwapQuoter
Sets the address of the SwapQuoter contract
This function is only callable by the owner
function setSwapQuoter(address swapQuoter_) external;
Parameters
Name | Type | Description |
---|---|---|
swapQuoter_ | address | The address of the SwapQuoter contract |
bridge
Initiate an RFQ transaction with an optional swap on origin chain, and an optional gas rebate on destination chain.
*Note that method is payable.
If token is ETH_ADDRESS, this method should be invoked with msg.value = amountIn
.
If token is ERC20, the tokens will be pulled from msg.sender (use msg.value = 0
).
Make sure to approve this contract for spending token
beforehand.
originQuery
is supposed to be fetched using FastBridgeRouter.getOriginAmountOut().
Alternatively one could use an external adapter for more complex swaps on the origin chain.
destQuery.rawParams
signals whether the user wants to receive a gas rebate on the destination chain:
- If the first byte of
destQuery.rawParams
is GAS_REBATE_FLAG, the user wants to receive a gas rebate. - Otherwise, the user does not want to receive a gas rebate.
Cross-chain RFQ swap will be performed between tokens:
originQuery.tokenOut
anddestQuery.tokenOut
. Note: both tokens could be ETH_ADDRESS or ERC20. Full proceeds of the origin swap are considered the bid for the cross-chain swap.destQuery.minAmountOut
is considered the ask for the cross-chain swap. Note: applying slippage todestQuery.minAmountOut
will result in a worse price for the user, the full Relayer quote should be used instead.*
function bridge(
address recipient,
uint256 chainId,
address token,
uint256 amount,
SwapQuery memory originQuery,
SwapQuery memory destQuery
)
external
payable;
Parameters
Name | Type | Description |
---|---|---|
recipient | address | Address to receive tokens on destination chain |
chainId | uint256 | Destination chain id |
token | address | Initial token to be pulled from the user |
amount | uint256 | Amount of the initial tokens to be pulled from the user |
originQuery | SwapQuery | Origin swap query (see above) |
destQuery | SwapQuery | Destination swap query (see above) |
getOriginAmountOut
Finds the best path between tokenIn
and every RFQ token from the given list,
treating the swap as "origin swap", without putting any restrictions on the swap.
Check (query.minAmountOut != 0): this is true only if the swap is possible.
The returned queries with minAmountOut != 0 could be used as originQuery
with FastBridgeRouter.
Note: it is possible to form a SwapQuery off-chain using alternative SwapAdapter for the origin swap.
function getOriginAmountOut(
address tokenIn,
address[] memory rfqTokens,
uint256 amountIn
)
external
view
returns (SwapQuery[] memory originQueries);
Parameters
Name | Type | Description |
---|---|---|
tokenIn | address | Initial token that user wants to bridge/swap |
rfqTokens | address[] | List of RFQ tokens |
amountIn | uint256 | Amount of tokens user wants to bridge/swap |
Returns
Name | Type | Description |
---|---|---|
originQueries | SwapQuery[] | List of structs that could be used as originQuery in FastBridgeRouter. minAmountOut and deadline fields will need to be adjusted based on the user settings. |
GAS_REBATE_FLAG
Magic value that indicates that the user wants to receive gas rebate on the destination chain. This is the answer to the ultimate question of life, the universe, and everything.
function GAS_REBATE_FLAG() external view returns (bytes1);
fastBridge
Address of the FastBridge contract, used to initiate cross-chain RFQ swaps.
function fastBridge() external view returns (address);
swapQuoter
Address of the SwapQuoter contract, used to fetch quotes for the origin swap.
function swapQuoter() external view returns (address);