Problem
dex_router.rs contains only a stub implementation. Both swap_exact_tokens_for_tokens and swap_tokens_for_exact_tokens are no-ops: they do not transfer tokens, do not enforce slippage, and emit event symbols without actually publishing them. Additionally, SwapAndPayArgs is defined in lib.rs but there is no swap_and_pay entry point on PaymentProcessor.
// Current stub — does nothing
pub fn swap_exact_tokens_for_tokens(...) -> Vec<i128> {
soroban_sdk::Symbol::new(&env, "SWAP"); // no-op
...
}
Required Work
- Implement
swap_and_pay on PaymentProcessor using SwapAndPayArgs
- Call the external DEX router contract via cross-contract invocation using
DexRouterClient
- Enforce
amount_out_min slippage guard — panic/error if output < minimum
- Enforce
deadline — reject if env.ledger().timestamp() > deadline
- After swap succeeds, create the payment via normal
create_payment flow
- Emit
SWAP/EXECUTED event with correct data payload
Acceptance Criteria
Branch & Commit Examples
branch: feat/swap-and-pay
commit: feat(payment-processor): implement swap_and_pay with DEX router integration
Problem
dex_router.rscontains only a stub implementation. Bothswap_exact_tokens_for_tokensandswap_tokens_for_exact_tokensare no-ops: they do not transfer tokens, do not enforce slippage, and emit event symbols without actually publishing them. Additionally,SwapAndPayArgsis defined inlib.rsbut there is noswap_and_payentry point onPaymentProcessor.Required Work
swap_and_payonPaymentProcessorusingSwapAndPayArgsDexRouterClientamount_out_minslippage guard — panic/error if output < minimumdeadline— reject ifenv.ledger().timestamp() > deadlinecreate_paymentflowSWAP/EXECUTEDevent with correct data payloadAcceptance Criteria
swap_and_payis callable onPaymentProcessorand acceptsSwapAndPayArgsamount_out_minslippage is enforced; returnsInvalidAmounterror if violateddeadlineis enforced; returnsPaymentExpirederror if pastSWAP/EXECUTEDevent is emitted with(stream_id, sender, amount_in, amount_out)dataEVENTS.mdis updated with theSWAP/EXECUTEDevent definitionBranch & Commit Examples