Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noto/Zeto atomic swap example #498

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open

Noto/Zeto atomic swap example #498

wants to merge 60 commits into from

Conversation

awrichar
Copy link
Contributor

@awrichar awrichar commented Jan 4, 2025

In a chain with #483

This example shows how to perform an atomic swap between Zeto and Noto (with Pente notary hooks), with full counterparty protection. It leverages locking functionality on both tokens to set aside the value for the swap, then approve a single base ledger Atom contract to finalize the swap. This ensures neither party can receive the other's tokens unless the full swap is executed.

Some caveats:

@awrichar awrichar force-pushed the swap-example branch 2 times, most recently from 6a7febe to 43f14d7 Compare January 8, 2025 13:20
@awrichar awrichar force-pushed the swap-example branch 6 times, most recently from 99b3fbf to 12d4d53 Compare January 16, 2025 20:50
Allows a domain to directly trigger a new transaction, such as in response to
an event.

Signed-off-by: Andrew Richardson <[email protected]>
Change Noto to ensure notary name is fully qualified during deploy, and to
check on contract init if the current node is the notary.

Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Allows a domain to look up specific states, regardless of whether they've been
spent or not.

Signed-off-by: Andrew Richardson <[email protected]>
@awrichar awrichar force-pushed the swap-example branch 2 times, most recently from 4c12bcc to e84f743 Compare January 17, 2025 16:58
Signed-off-by: Andrew Richardson <[email protected]>
This variant isn't fully proved out, and may begin causing confusion.
We can bring it back at the time we're able to work through all of the
flows in detail.

Signed-off-by: Andrew Richardson <[email protected]>
Allows an owner to "lock" some portion of value such that it cannot be
spent except when specific conditions are met.

Signed-off-by: Andrew Richardson <[email protected]>
Currently you can only unlock to return the value to yourself (additional
work needed to allow specifying and executing a transfer).

Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Also gather two separate sender signatures for transfer + lock, so that
they can be emitted separately in the two blockchain events.

Signed-off-by: Andrew Richardson <[email protected]>
Use shorter names "restrictMint" and "allowBurn".

Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Rather than storing all input/outputs states on the smart contract, store an
EIP-712 hash of the prepared unlock. Allow extracting the input/output states
from the state receipt (as info/read states) so that they can be passed in to
the final "unlockWithApproval" transaction.

Signed-off-by: Andrew Richardson <[email protected]>
Get states by ID, regardless of whether they are available.

Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
This helper is actually making the code more confusing.

Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
This makes it easier to separate locked/unlocked states.

Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Signed-off-by: Andrew Richardson <[email protected]>
Performs an atomic swap leveraging Zeto, Noto, and Pente together.

Signed-off-by: Andrew Richardson <[email protected]>
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.

1 participant