Skip to content

Feature Request: Add support for specifying recipient address in executeSwap #2

@limitlxx

Description

@limitlxx

Description:
Currently, the executeSwap function sends the swapped tokens to the account executing the transaction. For my use case (EgyptPay — a StarkNet-based payment platform), I need the ability to specify a different recipient address so that:

  • The swap can be executed by the user (payer)
  • The swapped tokens are sent directly to our EgyptPay smart contract, which will handle merchant settlements and withdrawals

Why this is important:
This feature is critical for payment processing platforms where the funds need to be routed through an escrow or settlement contract instead of the user's account. Without it, we must add an extra transaction to transfer funds from the user’s account to our contract, increasing gas costs and complexity.

Proposed solution:
Add an optional recipient parameter to the executeSwap method:

await autoswappr.executeSwap(
  TOKEN_ADDRESSES.STRK,
  TOKEN_ADDRESSES.USDC,
  {
    amount: "2000000000000000000",
    isToken1: false,
    skipAhead: 0,
    recipient: "0xEgyptPayContractAddress" // New optional param
  }
);

If recipient is not provided, default to the current account (for backward compatibility).

Example scenario:

  1. User pays in STRK
  2. AutoSwap swaps STRK → USDC
  3. Swapped USDC is sent directly to EgyptPay contract
  4. Merchant later withdraws from EgyptPay

Benefits:

  • Reduces gas cost by removing extra transfer step
  • Improves UX by making payments atomic
  • Makes the SDK more flexible for dApps needing escrow or treasury routing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions