Skip to content

Swap deadline & explicit slippage parameters #215

Description

@DevMuhdishaq

Description
swap/pool_swap should accept a user-supplied min_amount_out and a deadline ledger timestamp to protect against slippage and stale execution, standard for AMM safety.

Direction

  • Add min_amount_out: i128 and deadline: u64 parameters (or an overloaded swap_with_protection).
  • Reject if env.ledger().timestamp() > deadline (Expired error) or output < min_amount_out (SlippageExceeded error).
  • Keep the existing max_slippage_bps global as a fallback ceiling.

Acceptance criteria

  • Swap succeeds when output ≥ min_amount_out and before deadline.
  • Swap reverts with SlippageExceeded when output would be below min_amount_out (no state change).
  • Swap reverts with Expired past the deadline.
  • Existing swap tests updated/added; all pass.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions