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

Asset prices #1658

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions 85.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
NIP-85
======

Asset Prices
------------

`draft` `optional`

This NIP defines event kinds to host asset prices.

## Latest Price

Kind `31892` stores the latest conversion price. The `d` tag contains the commonly used ticket conversion symbol for the pair. The `value` tag contains the amount, parseable to a Decimal. `n` tags separate the pair into the two ticket symbols. The event's `created_at` field MUST be used as the date/time of the conversion value.

```js
{
"kind": 31892,
"tags": [
["d", "BTCUSD"],
["n", "BTC"],
["n", "USD"],
["value", "100000"]
],
// other fields
}
```

Since this is a replaceable event, only the latest price will be available.

## Historical Data

Historical prices can be found as `1892` events with the same structure as `31892`. Historical queries can then use Nostr's `since` and `until` filters to narrow the search.

```js
{
"kind": 1892,
"tags": [
["d", "BTCUSD"],
["n", "BTC"],
["n", "USD"],
["value", "100000"]
],
// other fields
}
```

Even though these events use the `d` tag, they are not replaceable.

## Declaring Pricing Providers

Kind 10041 lists the user's authorized providers for pricing services. It contains `s` tags with the provider's pubkey and the relay where those events are stored.

```js
{
"kind": 10041,
"tags": [
["s", "4fd5e210530e4f6b2cb083795834bfe5108324f1ed9f00ab73b9e8fcfe5f12fe", "wss://bitagent.prices"],
],
//...
}
```