Rhino also supports cross chain swaps using external swap aggregators.
bridge
or prepareBridge
functions. The only difference is that the arguments are slightly different compared to normal bridges:
token
field, a swap requires tokenIn
and tokenOut
fields as well as type: 'bridgeSwap'
to indicate that a swap should be performed.
pay
mode is available. receive
mode is only supported for bridges without swaps.prepareBridge
function with swaps or using the checkQuote
hook, you will receive a quote object that contains some additional properties compared to the quote for normal bridges. You will need to compare the _tag
field against bridgeSwap
first to narrow the type down to the swap quote case to get access to those properties:
bridgePayAmount
: The amount of tokenIn
that will be paidbridgePayAmountUsd
: The USD value of the pay amoutminReceiveAmount
: The minimum amount of tokenOut
that will be received on the destination chain after considering slippage.minReceiveAmountUsd
: The USD value of the minimum receive amountusdPriceTokenIn
: The current USD price of tokenIn
usdPriceTokenOut
: The current USD price of tokenOut
SwapFailed
that contains metadata about the refund (refund chain, token, amount and transaction hash).onBridgeStatusChange
hook will also first report swap-failed
and then follow up with failed-swap-refunded
once the refund has been processed. The latter update will contain the same metadata about the swap refund as the returned error.