Also:
- Remove amount_out_min. Our reasoning is that we perform high-level final amount checks anyway (and expect users to do the same). Lower-level USV4 min amount checks are redundant.
To achieve this, a small refactor was necessary with the introduction of a SwapGroup object, and a separate method to create a vec of these objects. This then separates all logic related to combining protocol data nicely and cleanly into its own method with its own tests.
TODO:
- Deal with split swaps and add test for split swap scenario
- Clean up all existing PR comments
Return selector in the StrategyEncoder. This is needed for the ExecutorStrategyEncoder
--- don't change below this line ---
ENG-4088 Took 12 minutes
Took 13 seconds
- This way this chain object contains everything we need, we don't need to worry about doing any transformation or calling any supplementary functions inside any of the encoders
- Needed to move our new Chain object to a higher level since this is used in the higher-level encoder traits. This required some weird default values in the constants in order to avoid using alloy's hex literal. I could have instead opted to make Bytes parse a string I think, though this would mean possibly returning an error at the constants level, which is not nice either.
Question:
- Do we want the user to be in charge of passing the native and wrapped token every single time? This may be a bit annoying for the user. For now, I have defaulted to those in constants.rs, this would take 5 mins to remove though if you don't like it, and it would get rid of this complicated bytes initialization.
- Tried not to leave a single public function undocumented, though did not double-document public function with obvious names
- Remove all mentions of the strategy selector in favour of the strategy registry (to avoid confusion)
The strategy works as follows:
- Manage approvals needed
- Compute min amount (if check amount is any):
- if slippage is defined, apply slippage on the expected amount and take the min value between that and the check amount
- if not, it's just the check amount
- Iterate through the swaps
- call the corresponding swap encoder to encode the swap
- add swap header (tokens indexes and split)
- ple encode the swaps
- Add extra inputs (amounts, token addresses, min amount, (un)wrap, number of tokens and receiver)
Misc:
- Move executor address and selector encoding inside the SwapEncoder
- Add default executor_selector to SwapEncoder
- Pass router address inside the SplitSwapStrategyEncoder
- Move Permit2 inside the SplitSwapStrategyEncoder. It is a responsibility and a specificity of the strategy to need permit2 approvals
--- don't change below this line ---
ENG-4081 Took 1 hour 21 minutes
When will this not be the router address that we use for approvals? It will always be the router address. address_for_approvals sounds to me very vague (which approvals?).
No more SingleSwapStrategyEncoder or SequentialStrategyEncoder
No more batch routing (so no need for batch permits as well). If multiple solutions are found, return multiple Transactions
--- don't change below this line ---
ENG-4076 <#DTT#>
- Move all evm code inside evm directory
- StrategyEncoder:
- Kept StrategyEncoder trait but created a new one: EVMStrategyEncoder to implement encode_protocol_header (that is evm specific).
- All StrategyEncoders implement both traits now
- Renamed DefaultStrategySelector -> EVMStrategySelector
- RouterEncoder:
- Created a RouterEncoder trait and a EVMRouterEncoder that implements it
- Moved utils inside evm directory as well
- Renamed config.json -> executor_addresses.json and moved it to a higher config directory
- Make alloy optional and dependent on the evm feature gate
--- don't change below this line ---
ENG-4075 <#DTT#>