You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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 singleexecute_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 proposeraccept_swap(env, swap_id)locks Asset B from the counterpartyexecute_swap(env, swap_id)transfers Asset A to counterparty and Asset B to proposer atomically — either both succeed or neither doescancel_swap(env, swap_id)returns locked assets to their owners — can be called by either party beforeexecute_swapSwapStatusenum: Proposed, Accepted, Executed, Cancelledswap_proposed,swap_accepted,swap_executed,swap_cancelledevents