fix: Do not count intermediary tokens in indices

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
This commit is contained in:
TAMARA LIPOWSKI
2025-02-14 18:48:39 -05:00
parent 556af0253d
commit e94154bc2d
2 changed files with 274 additions and 57 deletions

View File

@@ -65,7 +65,7 @@ pub enum NativeAction {
}
/// Represents a swap operation to be performed on a pool.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct Swap {
/// Protocol component from tycho indexer
pub component: ProtocolComponent,
@@ -111,6 +111,7 @@ 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.
#[derive(Clone, Debug)]
pub struct EncodingContext {
pub receiver: Bytes,
pub exact_out: bool,