-
Notifications
You must be signed in to change notification settings - Fork 5
Description
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:
- User pays in STRK
- AutoSwap swaps STRK → USDC
- Swapped USDC is sent directly to EgyptPay contract
- 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