feat: Remove router_address from Solution, set default

- The router address can be set when creating the SplitSwapStrategy, which now takes an Option<Bytes> as input during initialization (another breaking interface change)
- This change allows us to change our router address in the future with minimal effect on the users. Users should only pass the router address in the split swap initialization if they intend to use their own router for execution.
- This change also means that the router address does not need to be passed with the solution, even when using the executor strategy (which was pointless).
- I thought of having a router_address() method to set this in the encoder builder - but it seemed too messy, since we don't need the router address for execution for example. We would then potentially unnecessarily load and set the default router address when not needed. It is also not even used at the highest level EVMTychoEncoder, so it makes more sense for it to be directly associated with the swap strategy instead.
- Users will now not be able to encode for different routers without re-initializing the strategy. We assumed this use case to be very rare and not worth supporting.
This commit is contained in:
TAMARA LIPOWSKI
2025-03-26 12:42:28 +01:00
parent 3835842e88
commit d5c589d2c0
7 changed files with 103 additions and 55 deletions

View File

@@ -41,8 +41,6 @@ pub struct Solution {
pub checked_amount: Option<BigUint>,
/// List of swaps to fulfill the solution.
pub swaps: Vec<Swap>,
/// Address of the router contract to be used for the swaps.
pub router_address: Bytes,
/// If set, the corresponding native action will be executed.
pub native_action: Option<NativeAction>,
}
@@ -104,7 +102,8 @@ pub struct Transaction {
///
/// * `receiver`: Address of the receiver of the out token after the swaps are completed.
/// * `exact_out`: true if the solution is a buy order, false if it is a sell order.
/// * `router_address`: Address of the router contract to be used for the swaps.
/// * `router_address`: Address of the router contract to be used for the swaps. Zero address if
/// solution does not require router address.
/// * `group_token_in`: Token to be used as the input for the group swap.
/// * `group_token_out`: Token to be used as the output for the group swap.
#[derive(Clone, Debug)]