Function: swap(address token, address owner, address receiver, uint256 amount, uint256 slippage)
This acts like a middleware for swapping on a specific DEX.
Inputs
token
Control: Fully controlled by the user.
Constraints: Must be a valid address, not whitelisted.
Impact: The token to be swapped.
owner
Control: Fully controlled by the user.
Constraints: N/A.
Impact: Not used.
receiver
Control: Fully controlled by the user.
Constraints: N/A.
Impact: The address to receive the swapped tokens.
amount
Control: Fully controlled by the user.
Constraints: N/A; transfer logic handled in
safeTransferToSelf
.Impact: The amount of tokens to be swapped.
slippage
Control: Fully controlled by the user.
Constraints: N/A.
Impact: The maximum amount of slippage allowed.
Branches and code coverage (including function calls)
Intended branches
Decrease the depositing token balance of the
msg.sender
.Increase the swapped token balance of the
receiver
.Assure that the resulting tokens are within the slippage bounds.
Negative behavior
Should not allow swapping same token for same token.