Skip to content

[Feature] Multi-Hop Swap Routing Logic #178

Description

@AlAfiz

Description: Implement a Router contract capable of chaining multiple swaps together in a single transaction (e.g., swapping Token A -> Token B -> Token C).
Context / Motivation: Users shouldn't need to perform multiple manual transactions if a direct pair (A to C) doesn't exist or lacks liquidity. The Router is essential for seamless UX.
Acceptance Criteria: - [ ] Create a swap_exact_tokens_for_tokens function that takes a Vec<Address> representing the path.

  • Iterate through the path, executing swaps sequentially on the respective pool contracts.
  • Verify the final output amount matches or exceeds the user's amount_out_min slippage parameter.
  • Revert the entire transaction if the slippage tolerance is breached.
    Technical Pointers: The router shouldn't hold funds; it should act as an intermediary. Rely heavily on env.authorize_as_client() to allow the router to pull the initial token from the user, then handle subsequent cross-contract calls.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaignhelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions