Skip to content

feat: add atomic swap contract for peer-to-peer key exchanges - #1206

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

AzahasTech wants to merge 2 commits into
accesslayerorg:mainfrom
AzahasTech:feat/issue-1072-implement-atomic-swap-contract-for-peer-to-peer-r2

Conversation

@AzahasTech

Copy link
Copy Markdown

Overview

This PR adds an atomic swap flow to the creator-keys curve subscriptions module, letting two parties exchange creator key allocations peer-to-peer in a single transaction. A proposer locks their offered allocation, a named counterparty can accept (executing both sides atomically), the proposer can cancel to release their lock, and unaccepted proposals expire automatically after 1 hour.

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 a pending proposal.
    • accept_swap(proposal_id) — restricted to the designated counterparty; transfers both legs atomically and emits SwapExecuted.
    • cancel_swap(proposal_id) — restricted to the proposer; releases locked amounts back to the proposer and emits SwapCancelled.
    • Proposals expire 1 hour after creation; expired proposals unlock automatically.
    • Emits SwapProposed, SwapExecuted, and SwapCancelled with proposal and amount data.

Verification Results

Not run as part of this description; reviewers should exercise the three entry points and the expiry path directly.

Acceptance Criteria Status
accept_swap correctly transfers both sides atomically ✅ Implemented in accept_swap
cancel_swap releases locked amounts to proposer ✅ Implemented in cancel_swap
Proposal expires correctly after 1h with automatic unlock ✅ Expiry check with automatic unlock
accept_swap restricted to specified counterparty ✅ Counterparty check in accept_swap
All three events emitted with correct proposal and amount data ✅ SwapProposed, SwapExecuted, SwapCancelled emitted

Closes #1072

AzahasTech added a commit to AzahasTech/accesslayer-contracts that referenced this pull request Oct 24, 2026
AzahasTech added a commit to AzahasTech/accesslayer-contracts that referenced this pull request Oct 24, 2026
@AzahasTech
AzahasTech force-pushed the feat/issue-1072-implement-atomic-swap-contract-for-peer-to-peer-r2 branch from 154107b to 7a809b1 Compare October 24, 2026 11:29
@AzahasTech
AzahasTech force-pushed the feat/issue-1072-implement-atomic-swap-contract-for-peer-to-peer-r2 branch from 7a809b1 to 354d483 Compare October 24, 2026 11:30
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