Page MenuHomePhabricator

[ecash-lib] Initial draft of eCash Agora for ALP
DraftPublic

Authored by tobias_ruck on Apr 2 2024, 12:30.
This is a draft revision that has not yet been submitted for review.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Summary

Add an initial draft version of "Agora" for ALP, a covenant that allows "sellers" to lock up ALP tokens, and "buyers" to accept offers by sending the right amount of satoshis to the seller in an atomic multisig swap tx.

Unlike SLPAgora, this version allows users to partially accept an offer (down to a minimum), and send the remainder back into another loopback covenant with the same price but lower offered tokens.

It uses kinda whacky truncation maths to allow users to specify any combination of offered tokens and requested price in satoshis per token.

This means that the amounts/price entered by the user will often not be identical to the actual price, however, the difference should be far below <1% (except for extreme edge cases). The library returns a AgoraRealParams which contains the actual tokens/prices of the covenant.

The covenant hasn't been thoroughly verified or anything like that, so caution should be taken. A "cancel" path has been added to allow cancelling a trade by a seller.

Test Plan
  • build lib: cd ./modules/ecash-lib && npm install && npm run build
  • run example: cd ./apps/examples-ecash-lib && npm install && npm start

It will show you a div with -a <sats> -s <p2sh> -t <rawtx>, these are params that can be put into the "meep" tx debugger: https://github.com/gcash/meep

meep debug -a <sats> -s <p2sh> -t <rawtx>

Diff Detail

Repository
rABC Bitcoin ABC
Branch
ecash-lib-agora
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 28257
Build 56058: Build Diff
Build 56057: arc lint + arc unit