Swap Adapter
Swap adapter will be the abstract contract inherited by most of the extensions. The abstract will hold some basic information (protocol token, swapper registry's address), while also standardizing and defining internal functions that will be used in a composable manner across several Extensions to create different swapping behaviours.
Some of those internal functions are:
_takeFromMsgSender:
Takes the given amount of tokens from the caller._maxApproveSpenderIfNeeded
: Checks if the given spender has enough allowance, and approves the max amount if it doesn't._assertSwapperIsAllowlisted
: Checks if given swapper is allowlisted, and reverts if it isn't._revokeAllowances
: Revokes ERC20 allowances for the given spenders._executeSwap
: Executes a swap (call) for the given swapper with the given data._sendBalanceOnContractToRecipient
: Checks if the contract has any balance of the given token, and if it does, it sends it to the given recipient. This function will be really helpful when chaining actions (like swaps) that might leave dust on the contract._sendToRecipient:
Transfers the given amount of tokens from the contract to the recipient.
Last updated