diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index edc68e1..e9127a3 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -23,3 +23,4 @@ - [Admin Cancel order](./admin_cancel_order.md) - [Admin Add Solver](./admin_add_solver.md) - [Actions](./actions.md) +- [Order event](./order-event.md) diff --git a/book/src/cancel.md b/book/src/cancel.md index f7b4839..0e907ab 100644 --- a/book/src/cancel.md +++ b/book/src/cancel.md @@ -50,6 +50,9 @@ Mostro updates the nip 33 event with `d` tag `ede61c96-4c13-4519-bf3a-dcf7f1e9d8 ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/fiatsent.md b/book/src/fiatsent.md index 79ed998..a156b6e 100644 --- a/book/src/fiatsent.md +++ b/book/src/fiatsent.md @@ -88,6 +88,9 @@ Mostro updates the nip 33 event with `d` tag `ede61c96-4c13-4519-bf3a-dcf7f1e9d8 ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/list_orders.md b/book/src/list_orders.md index ac18b80..1bf9364 100644 --- a/book/src/list_orders.md +++ b/book/src/list_orders.md @@ -20,6 +20,9 @@ Mostro publishes new orders with event kind `38383` and status `pending`: ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/new_buy_order.md b/book/src/new_buy_order.md index 7d9b693..eb33df0 100644 --- a/book/src/new_buy_order.md +++ b/book/src/new_buy_order.md @@ -90,6 +90,9 @@ Mostro publishes this order as an event kind `38383` with status `pending`: ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/new_buy_order_ln_address.md b/book/src/new_buy_order_ln_address.md index b6b7a56..09155cd 100644 --- a/book/src/new_buy_order_ln_address.md +++ b/book/src/new_buy_order_ln_address.md @@ -91,6 +91,9 @@ Mostro publishes this order as an event kind `38383` with status `pending`: ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/new_sell_order.md b/book/src/new_sell_order.md index 542571f..ad497c1 100644 --- a/book/src/new_sell_order.md +++ b/book/src/new_sell_order.md @@ -95,8 +95,11 @@ Mostro publishes this order as an event kind `38383` with status `pending`: ["s", "pending"], ["amt", "0"], ["fa", "100"], - ["pm", "face to face"], + ["pm", "face to face", "bank transfer"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/new_sell_range_order.md b/book/src/new_sell_range_order.md index eb259c8..efdc011 100644 --- a/book/src/new_sell_range_order.md +++ b/book/src/new_sell_range_order.md @@ -79,9 +79,11 @@ Mostro publishes this order as an event kind `38383` with status `pending`: ["fa", "10", "20"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], - ["z", "order"], - ["expiration", "1716453501"] + ["z", "order"] ], "content": "", "sig": "7e8fe1eb644f33ff51d8805c02a0e1a6d034e6234eac50ef7a7e0dac68a0414f7910366204fa8217086f90eddaa37ded71e61f736d1838e37c0b73f6a16c4af2" diff --git a/book/src/order-event.md b/book/src/order-event.md new file mode 100644 index 0000000..8c74b27 --- /dev/null +++ b/book/src/order-event.md @@ -0,0 +1,85 @@ +# Peer-to-peer Order events + +## Abstract + +Peer-to-peer (P2P) platforms have seen an upturn in recent years, while having more and more options is positive, in the specific case of p2p, having several options contributes to the liquidity split, meaning sometimes there's not enough assets available for trading. If we combine all these individual solutions into one big pool of orders, it will make them much more competitive compared to centralized systems, where a single authority controls the liquidity. + +This NIP defines a simple standard for peer-to-peer order events, which enables the creation of a big liquidity pool for all p2p platforms participating. + +## The event + +Events are [Parameterized Replaceable Events](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds) and use `38383` as event kind, a p2p event look like this: + +```json +[ + "EVENT", + "RAND", + { + "id": "84fad0d29cb3529d789faeff2033e88fe157a48e071c6a5d1619928289420e31", + "pubkey": "dbe0b1be7aafd3cfba92d7463edbd4e33b2969f61bd554d37ac56f032e13355a", + "created_at": 1702548701, + "kind": 38383, + "tags": [ + ["d", "ede61c96-4c13-4519-bf3a-dcf7f1e9d842"], + ["k", "sell"], + ["f", "VES"], + ["s", "pending"], + ["amt", "0"], + ["fa", "100"], + ["pm", "face to face", "bank transfer"], + ["premium", "1"], + [ + "rating", + "{\"total_reviews\":1,\"total_rating\":3.0,\"last_rating\":3,\"max_rate\":5,\"min_rate\":1}" + ], + ["source", "https://t.me/p2plightning/xxxxxxx"], + ["network", "mainnet"], + ["layer", "lightning"], + ["name", "Satoshi"], + ["g", ""], + ["bond", "0"], + ["expiration", "1719391096"], + ["y", "lnp2pbot"], + ["z", "order"] + ], + "content": "", + "sig": "7e8fe1eb644f33ff51d8805c02a0e1a6d034e6234eac50ef7a7e0dac68a0414f7910366204fa8217086f90eddaa37ded71e61f736d1838e37c0b73f6a16c4af2" + } +] +``` + +## Tags + +- `d` < Order ID >: A unique identifier for the order. +- `k` < Order type >: `sell` or `buy`. +- `f` < Currency >: The asset being traded, using the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) standard. +- `s` < Status >: `pending`, `canceled`, `in-progress`, `success`. +- `amt` < Amount >: The amount of Bitcoin to be traded, the amount is defined in satoshis, if `0` means that the amount of satoshis will be obtained from a public API after the taker accepts the order. +- `fa` < Fiat amount >: The fiat amount being traded, for range orders two values are expected, the minimum and maximum amount. +- `pm` < Payment method >: The payment method used for the trade, if the order has multiple payment methods, they should be separated by a comma. +- `premium` < Premium >: The percentage of the premium the maker is willing to pay. +- `source` [Source]: The source of the order, it can be a URL that redirects to the order. +- `rating` [Rating]: The rating of the maker, this document does not define how the rating is calculated, it's up to the platform to define it. +- `network` < Network >: The network used for the trade, it can be `mainnet`, `testnet`, `signet`, etc. +- `layer` < Layer >: The layer used for the trade, it can be `onchain`, `lightning`, `liquid`, etc. +- `name` [Name]: The name of the maker. +- `g` [Geohash]: The geohash of the operation, it can be useful in a face to face trade. +- `bond` [Bond]: The bond amount, the bond is a security deposit that both parties must pay. +- `expiration` < Expiration\>: The expiration date of the order ([NIP-40](https://github.com/nostr-protocol/nips/blob/master/40.md)). +- `y` < Platform >: The platform that created the order. +- `z` < Document >: `order`. + +Mandatory tags are enclosed with ``, optional tags are enclosed with `[tag]`. + +## Implementations + +Currently implemented on the following platforms: + +- [Mostro](https://github.com/MostroP2P/mostro) +- [@lnp2pBot](https://github.com/lnp2pBot/bot) + +## This document is inspired on + +- [Mostro messages specification](https://mostro.network/messages/) +- [Messages specification for peer 2 peer NIP proposal](https://github.com/nostr-protocol/nips/blob/8250274a22f4882f621510df0054fd6167c10c9e/31001.md) +- [n3xB](https://github.com/nobu-maeda/n3xb) diff --git a/book/src/overview.md b/book/src/overview.md index c3c8c87..ab1619c 100644 --- a/book/src/overview.md +++ b/book/src/overview.md @@ -2,7 +2,7 @@ ## Overview -All messages broadcasted by Mostro daemon are [Parameterized Replaceable Events](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds) and use `38383` as event `kind`, a list of standard event kinds can be found [here](https://github.com/nostr-protocol/nips#event-kinds) +In order to have a shared order's book, Mostro daemon send [Parameterized Replaceable Events](https://github.com/nostr-protocol/nips/blob/master/01.md#kinds) with `38383` as event `kind`, you can find more details about that specific event [here](./order-event.md) ## Communication between users and Mostro diff --git a/book/src/release.md b/book/src/release.md index e31df68..2256477 100644 --- a/book/src/release.md +++ b/book/src/release.md @@ -109,6 +109,9 @@ Seconds later Mostro will try to pay the buyer's invoice, if the payment is succ ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/seller_pay_hold_invoice.md b/book/src/seller_pay_hold_invoice.md index a7ff360..1405260 100644 --- a/book/src/seller_pay_hold_invoice.md +++ b/book/src/seller_pay_hold_invoice.md @@ -178,6 +178,9 @@ And updates the nip 33 event with `d` tag `ede61c96-4c13-4519-bf3a-dcf7f1e9d842` ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/take_buy.md b/book/src/take_buy.md index fcdbf3c..35b7625 100644 --- a/book/src/take_buy.md +++ b/book/src/take_buy.md @@ -81,6 +81,9 @@ Mostro updates the nip 33 event with `d` tag `ede61c96-4c13-4519-bf3a-dcf7f1e9d8 ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], @@ -140,6 +143,9 @@ Mostro updates the nip 33 event with `d` tag `ede61c96-4c13-4519-bf3a-dcf7f1e9d8 ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], @@ -217,6 +223,9 @@ Finally Mostro updates the nip 33 event with `d` tag `ede61c96-4c13-4519-bf3a-dc ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/take_sell.md b/book/src/take_sell.md index e461052..20472ff 100644 --- a/book/src/take_sell.md +++ b/book/src/take_sell.md @@ -77,6 +77,9 @@ Mostro updates the nip 33 event with `d` tag `ede61c96-4c13-4519-bf3a-dcf7f1e9d8 ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/take_sell_ln_address.md b/book/src/take_sell_ln_address.md index 68551b5..689436a 100644 --- a/book/src/take_sell_ln_address.md +++ b/book/src/take_sell_ln_address.md @@ -68,6 +68,9 @@ Mostro updates the nip 33 event with `d` tag `ede61c96-4c13-4519-bf3a-dcf7f1e9d8 ["fa", "100"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], ["z", "order"] ], diff --git a/book/src/take_sell_range_order.md b/book/src/take_sell_range_order.md index 68da0f1..1160df8 100644 --- a/book/src/take_sell_range_order.md +++ b/book/src/take_sell_range_order.md @@ -68,9 +68,11 @@ Mostro updates the nip 33 event with `d` tag `ede61c96-4c13-4519-bf3a-dcf7f1e9d8 ["fa", "15"], ["pm", "face to face"], ["premium", "1"], + ["network", "mainnet"], + ["layer", "lightning"], + ["expiration", "1719391096"], ["y", "mostrop2p"], - ["z", "order"], - ["expiration", "1716453501"] + ["z", "order"] ], "content": "", "sig": "a835f8620db3ebdd9fa142ae99c599a61da86321c60f7c9fed0cc57169950f4121757ff64a5e998baccf6b68272aa51819c3e688d8ad586c0177b3cd1ab09c0f"