AcrossHook
The AcrossHook contract is responsible for handling hook functionality after swaps in the OdosRouter contract. It implements the executeOdosHook
function, which can only be called by the OdosRouter contract. This function accepts hookData
bytes, which are provided by the initiator of the swap action in the OdosRouter contract.
The hookData
, which is fully controlled by the user, includes the following information:
struct AcrossDepositWithFee {
address depositor;
address recipient;
address inputToken;
address outputToken;
uint256 inputAmount;
uint256 outputAmount;
uint256 destinationChainId;
address exclusiveRelayer;
uint32 quoteTimestamp;
uint32 fillDeadline;
uint32 exclusivityParameter;
bytes message;
uint256 feePercentage;
address feeRecipient;
}
During executeOdosHook
execution, it sends fees to the feeRecipient
specified by the user and then calls the deposit
function in the SpokePool contract using tokens received from the OdosRouter contract to initiate the cross-chain bridging of both the message and funds.
The outputToken
address and outputAmount
that the recipient
will receive on the destination chain are also taken from hookData
. While executeOdosHook
does not validate these parameters, it does scale the outputAmount
based on the actual input amount after fees and the inputAmount
provided by the user. Additionally, the executeOdosHook
function facilitates cross-chain swaps; the deposited amount can be used for a swap on the destination chain. However, this only occurs if the specified recipient
on the destination chain is a smart contract, specifically, the AcrossHandler. If the recipient
is an externally owned account, then the output tokens will simply be sent directly to the recipient
, without any further logic execution.
Invariants
The caller must be the OdosRouter contract.
The fee percentage must be less than 10,000.
The fee-recipient address cannot be the zero address.
The token amount must be greater than zero.