Skip to content

[CT-25] Complete atomic swap functionality in multisig_transfer in opsce crate #820

@yusuftomilola

Description

@yusuftomilola

Problem

contracts/multisig_transfer/ handles asset transfers but has no atomic swap capability. Two parties cannot atomically exchange different assets in a single transaction, meaning each leg must be executed separately and introduces counterparty risk.

Proposed Solution

Create contracts/opsce/src/atomic_swap.rs. Implement a two-phase commit swap: both parties lock their assets into the contract, then a single execute_swap() call transfers both legs atomically.

Acceptance Criteria

  • propose_swap(env, asset_a_id, asset_b_id, amount_a, amount_b, counterparty) locks Asset A from the proposer
  • accept_swap(env, swap_id) locks Asset B from the counterparty
  • execute_swap(env, swap_id) transfers Asset A to counterparty and Asset B to proposer atomically — either both succeed or neither does
  • cancel_swap(env, swap_id) returns locked assets to their owners — can be called by either party before execute_swap
  • SwapStatus enum: Proposed, Accepted, Executed, Cancelled
  • Emits swap_proposed, swap_accepted, swap_executed, swap_cancelled events
  • Unit tests cover: full happy path, cancellation by proposer, cancellation by counterparty, re-execution attempt

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions