Skip to content

feat: implement atomic swap contract for peer-to-peer key exchanges - #1085

Open
AzahasTech wants to merge 1 commit into
accesslayerorg:mainfrom
AzahasTech:feat/issue-1072-implement-atomic-swap-contract-for-peer-to-peer
Open

AzahasTech wants to merge 1 commit into
accesslayerorg:mainfrom
AzahasTech:feat/issue-1072-implement-atomic-swap-contract-for-peer-to-peer

Conversation

@AzahasTech

Copy link
Copy Markdown

Overview

This PR implements an atomic swap contract for peer-to-peer creator key exchanges, enabling two parties to swap key allocations in a single transaction. It adds a propose/accept/cancel lifecycle with counterparty restrictions, a 1-hour expiry with automatic unlock, and the three required lifecycle events.

Related Issue

Changes

🔁 Atomic Swap Contract

  • [MODIFY] creator-keys/src/curve_subscriptions_swaps.rs

    • propose_swap(offered_key, offered_amount, requested_key, requested_amount, counterparty) — locks the proposer's offered amount and records the proposal with its counterparty and expiry.
    • accept_swap(proposal_id) — counterparty-only; atomically transfers both sides of the swap.
    • cancel_swap(proposal_id) — proposer-only; releases the locked offered amount back to the proposer.
    • 1-hour expiry on proposals, with automatic unlock of locked amounts once expired.
  • [MODIFY] creator-keys/src/events.rs

    • Adds SwapProposed, SwapExecuted, and SwapCancelled event definitions carrying proposal and amount data.

Verification Results

cargo build -p creator-keys
✅ Compiles cleanly

cargo test -p creator-keys
✅ Swap lifecycle tests passed (propose, accept, cancel, expiry)
Acceptance Criteria Status
accept_swap correctly transfers both sides atomically ✅ Both sides transferred in a single execution path
cancel_swap releases locked amounts to proposer ✅ Locked offered amount released to proposer
Proposal expires correctly after 1h with automatic unlock ✅ Expiry enforced at 1h with automatic unlock
accept_swap restricted to specified counterparty ✅ Counterparty-only guard enforced
All three events emitted with correct proposal and amount data ✅ SwapProposed, SwapExecuted, SwapCancelled emitted

Closes #1072

@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

@AzahasTech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement atomic swap contract for peer-to-peer key exchanges

1 participant