From 22eee6d96bb58825b29d733cc669dd50fad18056 Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Thu, 18 Jul 2019 14:40:56 -0700 Subject: [PATCH 01/17] Base Standard --- fatips/2.md | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 fatips/2.md diff --git a/fatips/2.md b/fatips/2.md new file mode 100644 index 0000000..1699c2a --- /dev/null +++ b/fatips/2.md @@ -0,0 +1,199 @@ +| FATIP | Title | Status | Category | Author | Created | +| ----- | --------------------------- | ------ | -------------- | -------------------- | --------- | +| 2 | Pegged Asset Token Standard | WIP | Token Standard | Pegnet Working Group | 7-17-2019 | + + + +# Summary + +From the [PegNet Whitepaper](https://docs.google.com/document/d/1yv1UaOXjJLEYOvPUT_a8RowRqPX_ofBTJuPHmq6mQGQ/edit#heading=h.b48un57wbewg): + +> PegNet is a Pegged Token Network, and it leverages simple game theory and a set of pegged assets that self reinforce each other. The network provides a mechanism for managing payments, treasury allocations, and budgets across jurisdictions without requiring expensive and slow processes through external parties such as financial institutions, payment processors, exchanges, etc. + + + +# Motivation + +From the Pegnet Whitepaper: + +> Pegged tokens are generally useful for payments, treasury management, exchanges, and wealth preservation. A Pegged Token network defines a set of pegged tokens, which reflect real market assets such as currencies, precious metals, other cryptocurrency assets, commodities, etc. For example, a token pegged to USD can be used to make USD purchases, and both the buyer and seller can be assured of the payment with the pegged value will be very close to equal to the dollar equivalent. For companies holding cryptocurrency assets, the ability to convert parts of those assets into a dollar peg can help to preserve capital when the cryptocurrency market is low. +> +> [...] +> +> Pegging to cryptocurrencies can facilitate transactions representing Bitcoin or other cryptocurrency values without the transaction limitations that might exist on the those blockchains. Pegging values to other commodities or assets are possible, expanding the use cases for a Pegged Token Network. + +# Specification + +### Oracle Price Records (OPR) + +The pegged asset token uses Oracle Price Record entries, or OPR's, as the main vehicle for oraclizing and forming consensus on exchange rates. An OPR is composed of several core components: + +- An answer to a proof of work question +- Asset exchange rates as witnessed by the miner +- A payout address for rewards + +Miners submit valid OPR entries to the OPR chain each block in hopes of winning a multi-party proof of work problem that rewards in the base token: PNT. + +#### OPR Chain + +A single Factom chain is defined to house OPR entries depending on test or production chains, defined as the chain with hex encoded External IDs in zero-indexed order: + +- `5065674e6574` - "Pegnet" in ascii +- `546573744e6574` - "Testnet" in ascii. Can be "Mainnet" for production +- `4f7261636c65205072696365205265636f726473` - "Oracle Price Records" in ascii + +Corresponding to chain ID `b312a0401879366b3d72a1844b3ca0da1009545ffa8e4038f80da1528cb572ab` + +#### OPR Entry + +Each OPR entry must contain an a valid solution to a LXRHash based proof of work problem (challenge) based on the Factom network block height height. For example: + +``` +Factom Network Height: 3033 +Expected Solution (Prefix?): +Winning Answer: +``` + +The proof of work solution is `` encoded in the 0th External ID of the OPR entry. + +##### Content Example & Validation + +```json +{ + "previous": [ + "6ZeCoXShJ4hdVJNfTvK9azESibUgLxjBGn5ceEU5x3Ae" + ], + "reward": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", + "rates":{ + "PNT": 0, + "USD": 0, + "EUR": 0, + "JPY": 0, + "FCT": 5.743 + } +} +``` + +| Name | Type | Description | Validation | Required | +| ---------- | ------ | --------------------------------------------------------- | ------------------------------------------------------------ | -------- | +| `previous` | array | Previous winning OPR Factom entry hashes | Values must be valid entry hashes that correspond to OPR entries. Can be 0 elements in length | Y | +| `reward` | string | The public Factoid address to credit the mining reward to | Must be a valid public Factoid address. | Y | +| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than or equal to `0` | N | + +##### External ID Validation + +| Index | Description | Encoding | Example | +| ----- | ----------------------------------------------------------- | ------------ | ------------------------------------------------------------ | +| 0 | The solution to the OPR challenge at current network height | `` | `ac9c7600006b7fc01f422e38cfde7ee9e441fe918418578406e6ad39ce867301` | + + + +#### OPR Grading Algorithm + +**NEED MORE INFO HERE** + + + +### Token Model + +#### FAT-0 + +The pegged asset token standard uses FAT-0 based tokens to represent pegged assets. Trading of terminal pegged assets from address to address will take place on FAT-0 tokens, while conversions inside an address from pegged asset to pegged asset will take place on the central pegnet chain. + +To be compatible with the pegged asset token standard a FAT-0 token must be issued with the parameters laid out in the [FAT-0 Spec](0.md) details on the pegged asset network compatibility section. The Pegnet pair string shall be the token's ID + +Namely, the FAT-0 token must be initialized by the anonymous "system issuer" identity chain `8888880000000000000000000000000000000000000000000000000000000000` which is un-mineable. This signifies that the pegged asset token system has issuer control over the tokens on that standard. + +For example, to issue the base PNT token the FAT-0 token will have the following traits: + +- ExtId 0 (Issuer ID) - `8888880000000000000000000000000000000000000000000000000000000000` + +- ExtId 1 (Token ID) - `PNT` +- Content - Unchanged + + + +### Conversions + +Conversions represent a specialized type of transaction that atomically converts one terminal pegged FAT-0 asset into another at the current OPR based exchange rate. Conversions happen inside an address and do not transact tokens between peers. + +#### Conversion Chain + +Each pegged network shall have it's own conversion chain, defined using the same network string as the OPR chain. For example, the Testnet conversion chain is defined as the following hex encoded External IDs: + +- `5065674e6574` - "Pegnet" in ascii +- `546573744e6574` - "Testnet" in ascii. Can be "Mainnet" for production +- `436F6E76657273696F6E73` - "Conversions" in ascii + +#### Conversion Entry + +##### Content Example & Validation + +```json +{ + "address": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", + "from": "PNT", + "to": "FCT", + "amount": 10.021, + "metadata": "I want Factom!" +} +``` + +| Name | Type | Description | Validation | Required | +| ---------- | ------ | --------------------------------------------------------- | ----------------------------------------------------- | -------- | +| `address` | string | The Public Factoid address to convert pegged tokens on | Must be a valid public Factoid address | Y | +| `from` | string | The pegged asset token ID to convert from | Must correspond to a valid issued pegged FAT-0 token | Y | +| `to` | string | The pegged asset token ID to convert to from `from` | Must correspond to a valid issued pegged FAT-0 token` | Y | +| `amount` | number | The amount of `from` to use as an input to the conversion | Must be greater than `0` | Y | +| `metadata` | any | Arbitrary user defined metadata for the conversion | Must be valid JSON | N | + +##### Implicit Base Token Conversion + +The pegged asset token uses the PNT base token to describe exchange rates. Since all conversions are in ratio of the base token, a conversion using `from` equal to FCT and `to` equal to USD have an implicit conversion to PNT as an intermediary at the current OPR exchange rate. + +##### Signing + +Conversions are signed according to [FATIP-103](103.md). The signing set is +the key corresponding to `address` field. The conversion must include an RCD/Signature pair for the source address of the conversion. Signatures and RCDs are defined in the External IDs of the conversion entry as laid out in FATIP-103. + +#### Conversion Validation + +Conversions must meet all of the following criteria to be valid. + +General Criteria: + +- The content of the entry must be a single well-formed JSON. +- The JSON must contain all required fields listed in the above table, all fields and their members must be of the correct type. No unspecified fields may be present. No duplicate field names are allowed. +- The entry hash of the conversion entry must be unique among all + previously valid conversions of the pegged asset token. +- The External IDs must follow the cryptographic and structural + requirements defined by [FATIP-103](103.md) for the `address` input + +Specific Criteria: + +- Pegged token `from` must exist and be issued +- Pegged token `to` must exist and be issued +- `address` must own at least `amount` of pegged token `from` for the conversion to be valid + + + +If all criteria is met, the following occurs as a single atomic operation: + +- `amount` of token `from` is burnt (destroyed) in address `address` +- `from` is converted to PNT (interim) at the OPR exchange rate +- Interim PNT is expended to create `to` via coinbase transaction at the OPR exchange rate + +The conversion is complete. + + + +# Implementation + +[Pegnet Project](https://github.com/pegnet/pegnet) + + + +# Copyright + +Copyright and related rights waived via +[CC0](https://creativecommons.org/publicdomain/zero/1.0/). \ No newline at end of file From 6272c6e9e8a4951dfc2b849311ecfb370c5b42a0 Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Thu, 18 Jul 2019 14:43:42 -0700 Subject: [PATCH 02/17] Add FAT-2 standard to FATIPS page, update standard links --- FATIPS.md | 8 ++++---- README.md | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/FATIPS.md b/FATIPS.md index 98ff251..f3058f5 100644 --- a/FATIPS.md +++ b/FATIPS.md @@ -2,7 +2,7 @@ # Factom Asset Token Improvement Proposals :gear: -[![](https://img.shields.io/badge/FAT%20Standards-5-brightgreen.svg?style=for-the-badge)](FATIPS.md) +[![](https://img.shields.io/badge/FAT%20Standards-7-brightgreen.svg?style=for-the-badge)](FATIPS.md) [![Discord](https://img.shields.io/discord/479606362507313152.svg?style=for-the-badge)](https://discord.gg/8ADPfSc) @@ -28,9 +28,9 @@ defines the FATIP process. ## Work In Progress -| FATIP | Name | Category | -| ----- | ---- | -------- | -| | | | +| FATIP | Name | Category | +| ----- | --------------------------- | -------------- | +| 2 | Pegged Asset Token Standard | Token Standard | ## Draft diff --git a/README.md b/README.md index f6e30c8..5aea5ca 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,12 @@ A non-fungible asset token standard. - Every token is unique, and can have unique properties - Tokens have a history of the addresses they've resided at +### [**FAT-2**](fatips/2.md) + +Pegnet: Pegged Asset Token Standard + + + # Getting Started From f2c37906aef5f11c3410f352a7b0145bb1862942 Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Thu, 18 Jul 2019 18:14:03 -0700 Subject: [PATCH 03/17] Add replay protection to OPR entries via FATIP-103 signing Move POW answer to 4th external ID, add identity field --- fatips/2.md | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 1699c2a..42577bf 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -44,7 +44,7 @@ A single Factom chain is defined to house OPR entries depending on test or produ Corresponding to chain ID `b312a0401879366b3d72a1844b3ca0da1009545ffa8e4038f80da1528cb572ab` -#### OPR Entry +#### OPR Challenge & Solution Each OPR entry must contain an a valid solution to a LXRHash based proof of work problem (challenge) based on the Factom network block height height. For example: @@ -54,7 +54,7 @@ Expected Solution (Prefix?): Winning Answer: ``` -The proof of work solution is `` encoded in the 0th External ID of the OPR entry. +#### OPR Entry ##### Content Example & Validation @@ -63,6 +63,7 @@ The proof of work solution is `` encoded in the 0th External ID of the "previous": [ "6ZeCoXShJ4hdVJNfTvK9azESibUgLxjBGn5ceEU5x3Ae" ], + "identity": "8888880000000000000000000000000000000000000000000000000000000000", "reward": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", "rates":{ "PNT": 0, @@ -74,17 +75,29 @@ The proof of work solution is `` encoded in the 0th External ID of the } ``` -| Name | Type | Description | Validation | Required | -| ---------- | ------ | --------------------------------------------------------- | ------------------------------------------------------------ | -------- | -| `previous` | array | Previous winning OPR Factom entry hashes | Values must be valid entry hashes that correspond to OPR entries. Can be 0 elements in length | Y | -| `reward` | string | The public Factoid address to credit the mining reward to | Must be a valid public Factoid address. | Y | -| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than or equal to `0` | N | +| Name | Type | Description | Validation | Required | +| ---------- | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | +| `previous` | array | Previous winning OPR Factom entry hashes | Values must be valid entry hashes that correspond to OPR entries. Can be 0 elements in length | Y | +| `identity` | string | The identity chain that produced this OPR result. The entry is signed by this identity | Valid Factom serveridentity or DID chain | Y | +| `reward` | string | The public Factoid address to credit the mining reward to | Must be a valid public Factoid address. | Y | +| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than or equal to `0` | N | + +##### Signing & Extids + +OPR Entries implement [FATIP-103](103.md) to prevent replay attacks, limit, and track OPR answers. As defined by the spec, the first 3 ExtIDS correspond to(please forgive 1 indexing on bullets): + +1. The unix timestamp of the OPR entry +2. The RCD of the signing identity (or DID in the future), corresponding to the `identity` field in the OPR content which defines the identity or DID chain +3. The signature of the OPR of a salt of, concatenated: + 1. The RCD+Signature index (`0` since this is the first) + 2. The timestamp in ExtID 0 + 3. The OPR Chain ID the entry is on -##### External ID Validation +The 4th ExtID is the answer to the OPR challenge via LXRHash: | Index | Description | Encoding | Example | | ----- | ----------------------------------------------------------- | ------------ | ------------------------------------------------------------ | -| 0 | The solution to the OPR challenge at current network height | `` | `ac9c7600006b7fc01f422e38cfde7ee9e441fe918418578406e6ad39ce867301` | +| 3 | The solution to the OPR challenge at current network height | `` | `ac9c7600006b7fc01f422e38cfde7ee9e441fe918418578406e6ad39ce867301` | From ed50dd5c8072d7982800e0ea5b0fe6d502c8e183 Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Thu, 18 Jul 2019 18:17:14 -0700 Subject: [PATCH 04/17] Correct chain establishment ExtIds --- fatips/2.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 42577bf..e178e5d 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -117,11 +117,18 @@ To be compatible with the pegged asset token standard a FAT-0 token must be issu Namely, the FAT-0 token must be initialized by the anonymous "system issuer" identity chain `8888880000000000000000000000000000000000000000000000000000000000` which is un-mineable. This signifies that the pegged asset token system has issuer control over the tokens on that standard. -For example, to issue the base PNT token the FAT-0 token will have the following traits: +For example, to issue the base PNT token the FAT-0 token chain's first entry will have the following traits: -- ExtId 0 (Issuer ID) - `8888880000000000000000000000000000000000000000000000000000000000` +- ExtId 0 - `token` - ExtId 1 (Token ID) - `PNT` + +- ExtId 2 - `issuer` + +- ExtId 0 (Issuer ID) - `8888880000000000000000000000000000000000000000000000000000000000` + + + - Content - Unchanged From b1c2a63c2c3d162f0dece71ab4d1797ceb9da15b Mon Sep 17 00:00:00 2001 From: Paul Snow Date: Sat, 20 Jul 2019 15:01:26 -0500 Subject: [PATCH 05/17] Updated fields to match PegNet use cases, fixed some errors, removed Identity dependencies for replay (not needed) --- .gitignore | 10 ++++++ fatips/2.md | 96 ++++++++++++++++++++++++++++++++++------------------- 2 files changed, 71 insertions(+), 35 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59aa937 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# Ignore common artifacts of editing +# +# Binaries for programs and plugins, merges, tools +*.idea +*.dat +*.orig +*.txt + +# Goland +.idea/* diff --git a/fatips/2.md b/fatips/2.md index e178e5d..68cf1b1 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -38,12 +38,20 @@ Miners submit valid OPR entries to the OPR chain each block in hopes of winning A single Factom chain is defined to house OPR entries depending on test or production chains, defined as the chain with hex encoded External IDs in zero-indexed order: -- `5065674e6574` - "Pegnet" in ascii -- `546573744e6574` - "Testnet" in ascii. Can be "Mainnet" for production +##### TestNet +- `5065674e6574` - "PegNet" in ascii +- `546573744e6574` - "TestNet" in ascii. - `4f7261636c65205072696365205265636f726473` - "Oracle Price Records" in ascii Corresponding to chain ID `b312a0401879366b3d72a1844b3ca0da1009545ffa8e4038f80da1528cb572ab` +##### MainNet +- `5065674e6574` - "PegNet" in ascii +- `4d61696e4e6574` - "MainNet" in ascii. +- `4f7261636c65205072696365205265636f726473` - "Oracle Price Records" in ascii + +Corresponding to chain ID `45b6e921922145e8102912fe3df87a0b658a8b4c3ed0a177885964969d16b989` + #### OPR Challenge & Solution Each OPR entry must contain an a valid solution to a LXRHash based proof of work problem (challenge) based on the Factom network block height height. For example: @@ -60,52 +68,70 @@ Winning Answer: ```json { - "previous": [ - "6ZeCoXShJ4hdVJNfTvK9azESibUgLxjBGn5ceEU5x3Ae" - ], - "identity": "8888880000000000000000000000000000000000000000000000000000000000", - "reward": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", - "rates":{ - "PNT": 0, - "USD": 0, - "EUR": 0, - "JPY": 0, - "FCT": 5.743 - } + "winners": [ + "ba98d1bc839877a6", + "450b0e3cf82c44a1", + "d836f7dd1bd35cea", + "622999fc9cd69d04", + "1445e65cb2950df5", + "ccc624f717fd404c", + "63ffab6aa79e290d", + "261495af94840ccd", + "f341e51eb9573352", + "e73d7efe8baa5cca" + ], + "reward": "tPNT_VN4aumDQwQMugTyNXTDbuRgg2jgFyCrwezGkRz7p35tQmJaFx", + "identity": [ + "Minder", + "Bob", + "99" + ], + "rates": { + "PNT": 0, + "USD": 1.0109, + "EUR": 0.9147, + "JPY": 110.7317, + "XBC": 339.839, + "FCT": 4.2861 + } } ``` | Name | Type | Description | Validation | Required | | ---------- | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | -| `previous` | array | Previous winning OPR Factom entry hashes | Values must be valid entry hashes that correspond to OPR entries. Can be 0 elements in length | Y | -| `identity` | string | The identity chain that produced this OPR result. The entry is signed by this identity | Valid Factom serveridentity or DID chain | Y | -| `reward` | string | The public Factoid address to credit the mining reward to | Must be a valid public Factoid address. | Y | -| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than or equal to `0` | N | +| `previous` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | +| `identity` | string | The identity fields for the Identity Chain ID | To be a Valid DID chain; initially a arbitrary set of fields | Y | +| `reward` | string | The public PNT address to credit the mining reward to | Must be a valid public PNT address. | Y | +| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than `0` (initially the PNT address can be zero) | Y | -##### Signing & Extids -OPR Entries implement [FATIP-103](103.md) to prevent replay attacks, limit, and track OPR answers. As defined by the spec, the first 3 ExtIDS correspond to(please forgive 1 indexing on bullets): - -1. The unix timestamp of the OPR entry -2. The RCD of the signing identity (or DID in the future), corresponding to the `identity` field in the OPR content which defines the identity or DID chain -3. The signature of the OPR of a salt of, concatenated: - 1. The RCD+Signature index (`0` since this is the first) - 2. The timestamp in ExtID 0 - 3. The OPR Chain ID the entry is on - -The 4th ExtID is the answer to the OPR challenge via LXRHash: - -| Index | Description | Encoding | Example | -| ----- | ----------------------------------------------------------- | ------------ | ------------------------------------------------------------ | -| 3 | The solution to the OPR challenge at current network height | `` | `ac9c7600006b7fc01f422e38cfde7ee9e441fe918418578406e6ad39ce867301` | +#### OPR Grading Algorithm +To grade, a block must have at least 10 valid OPRs. +With each block, OPRs submitted to the Oracle Price Record chain are graded for the purpose of distributing the +block reward. The highest graded OPR also provides the pricing for the Pegged assets for that block. -#### OPR Grading Algorithm +[Grading](https://docs.google.com/document/d/1yv1UaOXjJLEYOvPUT_a8RowRqPX_ofBTJuPHmq6mQGQ/edit#bookmark=id.4nst6v3fi9ki) is done as follows: -**NEED MORE INFO HERE** +* Sort all valid OPR by their difficulty. +* If less than 10, no OPR records are valid. +* If more than 50 are valid, take the top 50, and reduce the valid OPRs by repeated passes until only 10 OPR records remain: + * Compute the average value for each pegged asset as reported by all 50 OPRs + * For each remaining valid OPR + * Compute the grade for the opr + * For each asset in the OPR + * Calculate the difference of that OPR's price from the average price reported by all OPRs + * Add to the OPR grade the square of the square of the difference + * Sort OPRs by their grades, and remove the OPR with the highest grade +* The final 10 are sorted primary by grade and secondary by proof of work. +##### Rewards: +The best graded 10 OPR records + * Best graded OPR gets 16% (800 PNT) + * Second best OPR gets 12% (600 PNT) + * All Other OPRs get 9% each (450 PNT) ### Token Model From a878d7648ee92981f58e9c29938d87a2469938cb Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Tue, 23 Jul 2019 20:59:10 -0700 Subject: [PATCH 06/17] Change to basic SISO conversions, add origin flag --- fatips/2.md | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 68cf1b1..365c0d6 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -159,9 +159,9 @@ For example, to issue the base PNT token the FAT-0 token chain's first entry wil -### Conversions +### Conversion Transactions -Conversions represent a specialized type of transaction that atomically converts one terminal pegged FAT-0 asset into another at the current OPR based exchange rate. Conversions happen inside an address and do not transact tokens between peers. +Conversions represent a specialized type of transaction that atomically converts one terminal pegged FAT-0 asset into another at the current OPR based exchange rate. Conversions may also move tokens between addresses without conversion. #### Conversion Chain @@ -177,21 +177,25 @@ Each pegged network shall have it's own conversion chain, defined using the same ```json { - "address": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", - "from": "PNT", + "from": "PNT", + "input": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", "to": "FCT", + "output": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", "amount": 10.021, + "origin": true, "metadata": "I want Factom!" } ``` -| Name | Type | Description | Validation | Required | -| ---------- | ------ | --------------------------------------------------------- | ----------------------------------------------------- | -------- | -| `address` | string | The Public Factoid address to convert pegged tokens on | Must be a valid public Factoid address | Y | -| `from` | string | The pegged asset token ID to convert from | Must correspond to a valid issued pegged FAT-0 token | Y | -| `to` | string | The pegged asset token ID to convert to from `from` | Must correspond to a valid issued pegged FAT-0 token` | Y | -| `amount` | number | The amount of `from` to use as an input to the conversion | Must be greater than `0` | Y | -| `metadata` | any | Arbitrary user defined metadata for the conversion | Must be valid JSON | N | +| Name | Type | Description | Validation | Required | +| ---------- | ------- | ------------------------------------------------------------ | ----------------------------------------------------- | -------- | +| `from` | string | The pegged asset token ID to convert from | Must correspond to a valid issued pegged FAT-0 token | Y | +| `input` | string | The Public Factoid address to us as an input for `from` type of pegged token | Must be a valid public Factoid address | Y | +| `to` | string | The pegged asset token ID to convert to from `from` | Must correspond to a valid issued pegged FAT-0 token` | Y | +| `output` | string | The Public Factoid address to us as an output for `to` type of pegged token | Must be a valid public Factoid address | Y | +| `amount` | number | The amount of `from` to use as an input to the conversion | Must be greater than `0` | Y | +| `origin` | boolean | Whether to apply `amount` as the input amount of the conversion. `amount` is applied as the conversion output amount of `to` by default. | Valid boolean. May be omitted for default behavior. | N | +| `metadata` | any | Arbitrary user defined metadata for the conversion | Must be valid JSON | N | ##### Implicit Base Token Conversion @@ -200,7 +204,7 @@ The pegged asset token uses the PNT base token to describe exchange rates. Since ##### Signing Conversions are signed according to [FATIP-103](103.md). The signing set is -the key corresponding to `address` field. The conversion must include an RCD/Signature pair for the source address of the conversion. Signatures and RCDs are defined in the External IDs of the conversion entry as laid out in FATIP-103. +the key corresponding to `input` field. The conversion must include an RCD/Signature pair for the source address of the conversion. Signatures and RCDs are defined in the External IDs of the conversion entry as laid out in FATIP-103. #### Conversion Validation @@ -219,15 +223,16 @@ Specific Criteria: - Pegged token `from` must exist and be issued - Pegged token `to` must exist and be issued -- `address` must own at least `amount` of pegged token `from` for the conversion to be valid +- If `origin` is true, `input` must own at least `amount` of pegged token `from` for the conversion to be valid +- If `origin` is false or omitted, `input` must own at least `amount` of pegged token `from` at current ORP exchange rate for the conversion to be valid If all criteria is met, the following occurs as a single atomic operation: -- `amount` of token `from` is burnt (destroyed) in address `address` +- `amount` (or equivalent at current OPR exchange rate if `origin` is true) of token `from` is burnt (destroyed) in address `input` - `from` is converted to PNT (interim) at the OPR exchange rate -- Interim PNT is expended to create `to` via coinbase transaction at the OPR exchange rate +- Interim PNT is expended to create `to` via coinbase transaction to `output` at the current OPR exchange rate The conversion is complete. From 752237b885b4fd9da01dda0c4c7327218e2a08bf Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Tue, 23 Jul 2019 21:11:41 -0700 Subject: [PATCH 07/17] Correct "previous" key to "winners" in OPR to match datastructure. Clarify some language Remove old example --- fatips/2.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 365c0d6..5a108af 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -32,7 +32,7 @@ The pegged asset token uses Oracle Price Record entries, or OPR's, as the main v - Asset exchange rates as witnessed by the miner - A payout address for rewards -Miners submit valid OPR entries to the OPR chain each block in hopes of winning a multi-party proof of work problem that rewards in the base token: PNT. +Miners submit valid OPR entries to the OPR chain each block in hopes of winning a competitive proof of work problem against other miners that rewards in the base token: PNT. #### OPR Chain @@ -57,9 +57,7 @@ Corresponding to chain ID `45b6e921922145e8102912fe3df87a0b658a8b4c3ed0a17788596 Each OPR entry must contain an a valid solution to a LXRHash based proof of work problem (challenge) based on the Factom network block height height. For example: ``` -Factom Network Height: 3033 -Expected Solution (Prefix?): -Winning Answer: +TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE ``` #### OPR Entry @@ -97,12 +95,12 @@ Winning Answer: } ``` -| Name | Type | Description | Validation | Required | -| ---------- | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | -| `previous` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | -| `identity` | string | The identity fields for the Identity Chain ID | To be a Valid DID chain; initially a arbitrary set of fields | Y | -| `reward` | string | The public PNT address to credit the mining reward to | Must be a valid public PNT address. | Y | -| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than `0` (initially the PNT address can be zero) | Y | +| Name | Type | Description | Validation | Required | +| ---------- | ------ | ----------------------------------------------------- | ------------------------------------------------------------ | -------- | +| `winners` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | +| `reward` | string | The public PNT address to credit the mining reward to | Must be a valid public PNT address. | Y | +| `identity` | string | The identity fields for the Identity Chain ID | To be a Valid DID chain; initially a arbitrary set of fields | Y | +| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than `0` (initially the PNT address can be zero) | Y | #### OPR Grading Algorithm From 52a0bc51c4f7628f9ca07c3a55658865fc6d476c Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Tue, 23 Jul 2019 21:25:26 -0700 Subject: [PATCH 08/17] Transition Pegnet to be it's own FAT token type --- fatips/2.md | 56 +++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 5a108af..4d1f2c2 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -24,6 +24,12 @@ From the Pegnet Whitepaper: # Specification +### Token Model + +The pegged asset token standard ("Pegnet") describes a interconnected ecosystem of pegged fungible tokens. Pegged tokens are atomically convertable to eachother at the current OPR exchange rate as determined by the OPR grading algorithm. + +Pegged tokens are "virtual" in nature, as opposed to regular FAT-0 tokens which have their own issuances and chains. Pegged tokens have no dedicated chain or issuance datastructure as they have no issuers. Pegnet token balances are calculated solely on a combination of OPR and Conversion Transaction records. + ### Oracle Price Records (OPR) The pegged asset token uses Oracle Price Record entries, or OPR's, as the main vehicle for oraclizing and forming consensus on exchange rates. An OPR is composed of several core components: @@ -131,37 +137,13 @@ The best graded 10 OPR records * Second best OPR gets 12% (600 PNT) * All Other OPRs get 9% each (450 PNT) -### Token Model - -#### FAT-0 - -The pegged asset token standard uses FAT-0 based tokens to represent pegged assets. Trading of terminal pegged assets from address to address will take place on FAT-0 tokens, while conversions inside an address from pegged asset to pegged asset will take place on the central pegnet chain. - -To be compatible with the pegged asset token standard a FAT-0 token must be issued with the parameters laid out in the [FAT-0 Spec](0.md) details on the pegged asset network compatibility section. The Pegnet pair string shall be the token's ID - -Namely, the FAT-0 token must be initialized by the anonymous "system issuer" identity chain `8888880000000000000000000000000000000000000000000000000000000000` which is un-mineable. This signifies that the pegged asset token system has issuer control over the tokens on that standard. - -For example, to issue the base PNT token the FAT-0 token chain's first entry will have the following traits: - -- ExtId 0 - `token` - -- ExtId 1 (Token ID) - `PNT` - -- ExtId 2 - `issuer` - -- ExtId 0 (Issuer ID) - `8888880000000000000000000000000000000000000000000000000000000000` - - - -- Content - Unchanged - ### Conversion Transactions Conversions represent a specialized type of transaction that atomically converts one terminal pegged FAT-0 asset into another at the current OPR based exchange rate. Conversions may also move tokens between addresses without conversion. -#### Conversion Chain +#### Conversion Transaction Chain Each pegged network shall have it's own conversion chain, defined using the same network string as the OPR chain. For example, the Testnet conversion chain is defined as the following hex encoded External IDs: @@ -169,7 +151,7 @@ Each pegged network shall have it's own conversion chain, defined using the same - `546573744e6574` - "Testnet" in ascii. Can be "Mainnet" for production - `436F6E76657273696F6E73` - "Conversions" in ascii -#### Conversion Entry +#### Conversion Transaction Entry ##### Content Example & Validation @@ -185,15 +167,15 @@ Each pegged network shall have it's own conversion chain, defined using the same } ``` -| Name | Type | Description | Validation | Required | -| ---------- | ------- | ------------------------------------------------------------ | ----------------------------------------------------- | -------- | -| `from` | string | The pegged asset token ID to convert from | Must correspond to a valid issued pegged FAT-0 token | Y | -| `input` | string | The Public Factoid address to us as an input for `from` type of pegged token | Must be a valid public Factoid address | Y | -| `to` | string | The pegged asset token ID to convert to from `from` | Must correspond to a valid issued pegged FAT-0 token` | Y | -| `output` | string | The Public Factoid address to us as an output for `to` type of pegged token | Must be a valid public Factoid address | Y | -| `amount` | number | The amount of `from` to use as an input to the conversion | Must be greater than `0` | Y | -| `origin` | boolean | Whether to apply `amount` as the input amount of the conversion. `amount` is applied as the conversion output amount of `to` by default. | Valid boolean. May be omitted for default behavior. | N | -| `metadata` | any | Arbitrary user defined metadata for the conversion | Must be valid JSON | N | +| Name | Type | Description | Validation | Required | +| ---------- | ------- | ------------------------------------------------------------ | --------------------------------------------------- | -------- | +| `from` | string | The pegged asset token ID to convert from | Must be a valid pegged token symbol | Y | +| `input` | string | The Public Factoid address to us as an input for `from` type of pegged token | Must be a valid public Factoid address | Y | +| `to` | string | The pegged asset token ID to convert to from `from` | Must be a valid pegged token symbol | Y | +| `output` | string | The Public Factoid address to us as an output for `to` type of pegged token | Must be a valid public Factoid address | Y | +| `amount` | number | The amount of `from` to use as an input to the conversion | Must be greater than `0` | Y | +| `origin` | boolean | Whether to apply `amount` as the input amount of the conversion. `amount` is applied as the conversion output amount of `to` by default. | Valid boolean. May be omitted for default behavior. | N | +| `metadata` | any | Arbitrary user defined metadata for the conversion | Must be valid JSON | N | ##### Implicit Base Token Conversion @@ -204,7 +186,7 @@ The pegged asset token uses the PNT base token to describe exchange rates. Since Conversions are signed according to [FATIP-103](103.md). The signing set is the key corresponding to `input` field. The conversion must include an RCD/Signature pair for the source address of the conversion. Signatures and RCDs are defined in the External IDs of the conversion entry as laid out in FATIP-103. -#### Conversion Validation +#### Conversion Transaction Validation Conversions must meet all of the following criteria to be valid. @@ -219,8 +201,6 @@ General Criteria: Specific Criteria: -- Pegged token `from` must exist and be issued -- Pegged token `to` must exist and be issued - If `origin` is true, `input` must own at least `amount` of pegged token `from` for the conversion to be valid - If `origin` is false or omitted, `input` must own at least `amount` of pegged token `from` at current ORP exchange rate for the conversion to be valid From 04fd25af1807965f7594120b4645700f7d443254 Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Tue, 23 Jul 2019 22:52:16 -0700 Subject: [PATCH 09/17] Detail pFCT onramp via EC purchase --- fatips/2.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fatips/2.md b/fatips/2.md index 4d1f2c2..1e4a566 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -139,6 +139,21 @@ The best graded 10 OPR records +### Pegged Asset Onramps + +Pegged asset onramps are necessary to inject value into the pegged asset token system. Typically this is achieved by burning or locking up the underlying pegged asset. + +#### Factom + +Creation of pegged Factom ("pFCT") tokens is described by conducting an 1 Entry Credit purchase on the host Factom network to the following addresses to fund the respective virtual Pegnet networks: + +- Testnet - `EC1moooFCT2TESToooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` +- Mainnet - `EC1moooFCT2MAINoooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` + +The additional fees of the EC purchase transaction over the base network fee describe the quantity of pFCT credited to the purchasing Factoid address on the pegged asset token system. + + + ### Conversion Transactions Conversions represent a specialized type of transaction that atomically converts one terminal pegged FAT-0 asset into another at the current OPR based exchange rate. Conversions may also move tokens between addresses without conversion. From e31e51c9ac0635b65418aed0fc2bf62139f6f6d4 Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Tue, 23 Jul 2019 23:05:59 -0700 Subject: [PATCH 10/17] Detail partial pegged asset list, symbols, mainnet activation heights --- fatips/2.md | 55 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 1e4a566..3f46731 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -30,9 +30,47 @@ The pegged asset token standard ("Pegnet") describes a interconnected ecosystem Pegged tokens are "virtual" in nature, as opposed to regular FAT-0 tokens which have their own issuances and chains. Pegged tokens have no dedicated chain or issuance datastructure as they have no issuers. Pegnet token balances are calculated solely on a combination of OPR and Conversion Transaction records. + + +### Pegged Assets (PARTIAL LIST) + +The following assets are supported or will be supported by the pegged asset token system, detailed via Factom mainnet activation height on Pegnet. + +| Asset Name | [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) Symbol | Pegnet Symbol | Activation Height | +| ---------------- | --------------------------------------------------------- | ------------- | ----------------- | +| PegNet | - | PNT | 0 | +| US Dollar | USD | pUSD | 0 | +| Euro | EUR | pEUR | 0 | +| Japanese Yen | JPY | pJPY | 0 | +| Pound Sterling | GBP | pGBP | 0 | +| Canadian Dollar | CAD | pCAD | 0 | +| Swiss Franc | CHF | pCHF | 0 | +| Indian Rupee | INR | pINR | 0 | +| Singapore Dollar | SGD | pSGD | 0 | +| Chinese Yuan | CNY | pCNY | 0 | +| Hong Kong Dollar | HKD | pHKD | 0 | +| | | | | + + + +### Pegged Asset Onramps + +Pegged asset onramps are necessary to inject value into the pegged asset token system. Typically this is achieved by burning or locking up the underlying pegged asset. + +#### Factom + +Creation of pegged Factom ("pFCT") tokens is described by conducting an 1 Entry Credit purchase on the host Factom network to the following addresses to fund the respective virtual Pegnet networks: + +- Testnet - `EC1moooFCT2TESToooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` +- Mainnet - `EC1moooFCT2MAINoooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` + +The additional fees of the EC purchase transaction over the base network fee describe the quantity of pFCT credited to the purchasing Factoid address on the pegged asset token system. + + + ### Oracle Price Records (OPR) -The pegged asset token uses Oracle Price Record entries, or OPR's, as the main vehicle for oraclizing and forming consensus on exchange rates. An OPR is composed of several core components: +The pegged asset token system uses Oracle Price Record entries, or OPR's, as the main vehicle for oraclizing and forming consensus on exchange rates. An OPR is composed of several core components: - An answer to a proof of work question - Asset exchange rates as witnessed by the miner @@ -139,21 +177,6 @@ The best graded 10 OPR records -### Pegged Asset Onramps - -Pegged asset onramps are necessary to inject value into the pegged asset token system. Typically this is achieved by burning or locking up the underlying pegged asset. - -#### Factom - -Creation of pegged Factom ("pFCT") tokens is described by conducting an 1 Entry Credit purchase on the host Factom network to the following addresses to fund the respective virtual Pegnet networks: - -- Testnet - `EC1moooFCT2TESToooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` -- Mainnet - `EC1moooFCT2MAINoooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` - -The additional fees of the EC purchase transaction over the base network fee describe the quantity of pFCT credited to the purchasing Factoid address on the pegged asset token system. - - - ### Conversion Transactions Conversions represent a specialized type of transaction that atomically converts one terminal pegged FAT-0 asset into another at the current OPR based exchange rate. Conversions may also move tokens between addresses without conversion. From 2e391c03ca01daf8ff4828d1085824bfda8575be Mon Sep 17 00:00:00 2001 From: WhoSoup <34172041+WhoSoup@users.noreply.github.com> Date: Wed, 24 Jul 2019 13:01:08 +0200 Subject: [PATCH 11/17] Grammar and clarification * Fixed some minor grammatical issues * the section on "Implicit conversions" was wrong, it doesn't happen this way * updated the chain names to align with https://github.com/pegnet/pegnet/pull/116 --- fatips/2.md | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 3f46731..202c838 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -8,7 +8,7 @@ From the [PegNet Whitepaper](https://docs.google.com/document/d/1yv1UaOXjJLEYOvPUT_a8RowRqPX_ofBTJuPHmq6mQGQ/edit#heading=h.b48un57wbewg): -> PegNet is a Pegged Token Network, and it leverages simple game theory and a set of pegged assets that self reinforce each other. The network provides a mechanism for managing payments, treasury allocations, and budgets across jurisdictions without requiring expensive and slow processes through external parties such as financial institutions, payment processors, exchanges, etc. +> PegNet is a Pegged Token Network that leverages simple game theory to create a set of pegged assets that reinforce each other. The network provides a mechanism for managing payments, treasury allocations, and budgets across jurisdictions without requiring expensive and slow processes through external parties such as financial institutions, payment processors, exchanges, etc. @@ -26,9 +26,9 @@ From the Pegnet Whitepaper: ### Token Model -The pegged asset token standard ("Pegnet") describes a interconnected ecosystem of pegged fungible tokens. Pegged tokens are atomically convertable to eachother at the current OPR exchange rate as determined by the OPR grading algorithm. +The pegged asset token standard ("Pegnet") describes an interconnected ecosystem of pegged fungible tokens. Pegged tokens are atomically convertible to each other at exchange rates determined for that block by the OPR grading algorithm. -Pegged tokens are "virtual" in nature, as opposed to regular FAT-0 tokens which have their own issuances and chains. Pegged tokens have no dedicated chain or issuance datastructure as they have no issuers. Pegnet token balances are calculated solely on a combination of OPR and Conversion Transaction records. +Pegged tokens are "virtual" in nature, as opposed to regular FAT-0 tokens which have their own issuances and chains. Pegged tokens have no dedicated chain or issuance datastructure as they have no issuers. Pegnet token balances are calculated using a combination of mined OPRs, transactions, conversions, and burning of FCT. @@ -59,24 +59,24 @@ Pegged asset onramps are necessary to inject value into the pegged asset token s #### Factom -Creation of pegged Factom ("pFCT") tokens is described by conducting an 1 Entry Credit purchase on the host Factom network to the following addresses to fund the respective virtual Pegnet networks: +Creation of pegged Factom ("pFCT") tokens is described by conducting a 1 Entry Credit purchase on the host Factom network to the following addresses to fund the respective virtual Pegnet networks: -- Testnet - `EC1moooFCT2TESToooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` -- Mainnet - `EC1moooFCT2MAINoooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` +- TestNet - `EC1moooFCT2TESToooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` +- MainNet - `EC1moooFCT2MAINoooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` -The additional fees of the EC purchase transaction over the base network fee describe the quantity of pFCT credited to the purchasing Factoid address on the pegged asset token system. +The additional fees of the EC purchase transaction over the base network fee describe the quantity of pFCT credited to the purchasing Factoid address on the pegged asset token system at the rate set by the winning OPR for that block. ### Oracle Price Records (OPR) -The pegged asset token system uses Oracle Price Record entries, or OPR's, as the main vehicle for oraclizing and forming consensus on exchange rates. An OPR is composed of several core components: +The pegged asset token system uses Oracle Price Record entries, or OPRs, as the main vehicle for oraclizing and forming consensus on exchange rates. An OPR is composed of several core components: - An answer to a proof of work question -- Asset exchange rates as witnessed by the miner +- Asset exchange rates, relative to USD, as witnessed by the miner - A payout address for rewards -Miners submit valid OPR entries to the OPR chain each block in hopes of winning a competitive proof of work problem against other miners that rewards in the base token: PNT. +Miners submit valid OPRs to the OPR chain each block in hopes of winning a competitive proof of work problem against other miners that rewards in the base token: PNT. #### OPR Chain @@ -85,20 +85,20 @@ A single Factom chain is defined to house OPR entries depending on test or produ ##### TestNet - `5065674e6574` - "PegNet" in ascii - `546573744e6574` - "TestNet" in ascii. -- `4f7261636c65205072696365205265636f726473` - "Oracle Price Records" in ascii +- `4f7261636c6550726963655265636f726473` - "OraclePriceRecords" in ascii -Corresponding to chain ID `b312a0401879366b3d72a1844b3ca0da1009545ffa8e4038f80da1528cb572ab` +Corresponding to chain ID `fafedb5fb8e7d1512244b683608f0b248326f1b8fae497058ba8ae8d577e9c14` ##### MainNet - `5065674e6574` - "PegNet" in ascii - `4d61696e4e6574` - "MainNet" in ascii. -- `4f7261636c65205072696365205265636f726473` - "Oracle Price Records" in ascii +- `4f7261636c6550726963655265636f726473` - "OraclePriceRecords" in ascii -Corresponding to chain ID `45b6e921922145e8102912fe3df87a0b658a8b4c3ed0a177885964969d16b989` +Corresponding to chain ID `a642a8674f46696cc47fdb6b65f9c87b2a19c5ea8123b3d2f0c13b6f33a9d5ef` -#### OPR Challenge & Solution +#### OPR Proof of Work Calculation -Each OPR entry must contain an a valid solution to a LXRHash based proof of work problem (challenge) based on the Factom network block height height. For example: +Each OPR contains a set bytes in ExtId[0] called the nonce. To evaluate the proof of work result ("difficulty"), the Grading algorithm takes the LXR-Hash of the entry's content, appends it with the nonce, and LXR-Hashes it again. The first 8 bytes of the resulting hash are converted to an unsigned 64 bit integer in Big Endian order. A higher value is considered a better difficulty, with 0 being the worst and `2^64 - 1` being the best. ``` TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE @@ -181,9 +181,13 @@ The best graded 10 OPR records Conversions represent a specialized type of transaction that atomically converts one terminal pegged FAT-0 asset into another at the current OPR based exchange rate. Conversions may also move tokens between addresses without conversion. +#### Conversion Rate + +All conversions use the exchange rate defined in the OPR with the highest grade inside that block. If a conversion is written to a block that has no winners, the conversions are evaluated using the highest grade of the following block with winners. + #### Conversion Transaction Chain -Each pegged network shall have it's own conversion chain, defined using the same network string as the OPR chain. For example, the Testnet conversion chain is defined as the following hex encoded External IDs: +Each pegged network shall have its own conversion chain, defined using the same network string as the OPR chain. For example, the Testnet conversion chain is defined as the following hex encoded External IDs: - `5065674e6574` - "Pegnet" in ascii - `546573744e6574` - "Testnet" in ascii. Can be "Mainnet" for production @@ -215,10 +219,6 @@ Each pegged network shall have it's own conversion chain, defined using the same | `origin` | boolean | Whether to apply `amount` as the input amount of the conversion. `amount` is applied as the conversion output amount of `to` by default. | Valid boolean. May be omitted for default behavior. | N | | `metadata` | any | Arbitrary user defined metadata for the conversion | Must be valid JSON | N | -##### Implicit Base Token Conversion - -The pegged asset token uses the PNT base token to describe exchange rates. Since all conversions are in ratio of the base token, a conversion using `from` equal to FCT and `to` equal to USD have an implicit conversion to PNT as an intermediary at the current OPR exchange rate. - ##### Signing Conversions are signed according to [FATIP-103](103.md). The signing set is @@ -263,4 +263,4 @@ The conversion is complete. # Copyright Copyright and related rights waived via -[CC0](https://creativecommons.org/publicdomain/zero/1.0/). \ No newline at end of file +[CC0](https://creativecommons.org/publicdomain/zero/1.0/). From 09f2aaf201596f7beefa28a6ed64437ebf24ab04 Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Fri, 26 Jul 2019 13:42:01 -0700 Subject: [PATCH 12/17] Use Factoid addresses for OPR miner rewards --- fatips/2.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 202c838..bad9f1c 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -122,7 +122,7 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE "f341e51eb9573352", "e73d7efe8baa5cca" ], - "reward": "tPNT_VN4aumDQwQMugTyNXTDbuRgg2jgFyCrwezGkRz7p35tQmJaFx", + "reward": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", "identity": [ "Minder", "Bob", @@ -139,12 +139,12 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE } ``` -| Name | Type | Description | Validation | Required | -| ---------- | ------ | ----------------------------------------------------- | ------------------------------------------------------------ | -------- | -| `winners` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | -| `reward` | string | The public PNT address to credit the mining reward to | Must be a valid public PNT address. | Y | -| `identity` | string | The identity fields for the Identity Chain ID | To be a Valid DID chain; initially a arbitrary set of fields | Y | -| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than `0` (initially the PNT address can be zero) | Y | +| Name | Type | Description | Validation | Required | +| ---------- | ------ | --------------------------------------------------------- | ------------------------------------------------------------ | -------- | +| `winners` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | +| `reward` | string | The public Factoid address to credit the mining reward to | Must be a valid public Factoid address. | Y | +| `identity` | string | The identity fields for the Identity Chain ID | To be a Valid DID chain; initially a arbitrary set of fields | Y | +| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than `0` (initially the PNT address can be zero) | Y | #### OPR Grading Algorithm From a221974a15acfd209e23276ec0831632d1c66113 Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Fri, 26 Jul 2019 13:46:42 -0700 Subject: [PATCH 13/17] Add dbht back as height in OPR Required field --- fatips/2.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fatips/2.md b/fatips/2.md index bad9f1c..0e59eb9 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -110,6 +110,7 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE ```json { + "height":104981, "winners": [ "ba98d1bc839877a6", "450b0e3cf82c44a1", @@ -141,6 +142,7 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE | Name | Type | Description | Validation | Required | | ---------- | ------ | --------------------------------------------------------- | ------------------------------------------------------------ | -------- | +| `height` | number | The Factom block height this OPR was mined at | Must be a valid integer. Greater than zero. | Y | | `winners` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | | `reward` | string | The public Factoid address to credit the mining reward to | Must be a valid public Factoid address. | Y | | `identity` | string | The identity fields for the Identity Chain ID | To be a Valid DID chain; initially a arbitrary set of fields | Y | From 21dce16ba06a845790c74aeac0709f3de524eecc Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Fri, 26 Jul 2019 13:57:17 -0700 Subject: [PATCH 14/17] Move identity to miner in OPR. Make optional Fix validation description --- fatips/2.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 0e59eb9..8540c07 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -124,11 +124,7 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE "e73d7efe8baa5cca" ], "reward": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", - "identity": [ - "Minder", - "Bob", - "99" - ], + "miner": "identity-placeholder", "rates": { "PNT": 0, "USD": 1.0109, @@ -140,13 +136,13 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE } ``` -| Name | Type | Description | Validation | Required | -| ---------- | ------ | --------------------------------------------------------- | ------------------------------------------------------------ | -------- | -| `height` | number | The Factom block height this OPR was mined at | Must be a valid integer. Greater than zero. | Y | -| `winners` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | -| `reward` | string | The public Factoid address to credit the mining reward to | Must be a valid public Factoid address. | Y | -| `identity` | string | The identity fields for the Identity Chain ID | To be a Valid DID chain; initially a arbitrary set of fields | Y | -| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than `0` (initially the PNT address can be zero) | Y | +| Name | Type | Description | Validation | Required | +| --------- | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | +| `height` | number | The Factom block height this OPR was mined at | Must be a valid integer. Greater than zero. | Y | +| `winners` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | +| `reward` | string | The public Factoid address to credit the PNT mining reward to | Must be a valid public Factoid address. | Y | +| `miner` | string | Stub for future development. The identity of the miner that mined this OPR. | To be a Valid DID chain; initially a arbitrary string. Max length 64 chars if present. | N | +| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than `0` (initially the PNT address can be zero) | Y | #### OPR Grading Algorithm From 18ffe330f4c08a4cd026e03e199136ef612fc390 Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Wed, 31 Jul 2019 18:18:23 -0700 Subject: [PATCH 15/17] Use assets instead of rates to match implementation --- fatips/2.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 8540c07..f84854b 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -125,7 +125,7 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE ], "reward": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", "miner": "identity-placeholder", - "rates": { + "assets": { "PNT": 0, "USD": 1.0109, "EUR": 0.9147, @@ -142,7 +142,7 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE | `winners` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | | `reward` | string | The public Factoid address to credit the PNT mining reward to | Must be a valid public Factoid address. | Y | | `miner` | string | Stub for future development. The identity of the miner that mined this OPR. | To be a Valid DID chain; initially a arbitrary string. Max length 64 chars if present. | N | -| `rates` | object | The witnessed exchange rates by the miner | Keys must be currency symbols, values must be numbers greater than `0` (initially the PNT address can be zero) | Y | +| `assets` | object | The witnessed exchange rates by the miner | Keys must be pegnet currency symbols, values must be numbers greater than or equal to `0` (initially the PNT address can be zero) | Y | #### OPR Grading Algorithm From d36e56f4d28ed292c43fe3de6049f53709cc9fa1 Mon Sep 17 00:00:00 2001 From: Devon Katz Date: Wed, 31 Jul 2019 18:19:26 -0700 Subject: [PATCH 16/17] Use coinbase instead of reward to match implementation --- fatips/2.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index f84854b..550df02 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -123,7 +123,7 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE "f341e51eb9573352", "e73d7efe8baa5cca" ], - "reward": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", + "coinbase": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", "miner": "identity-placeholder", "assets": { "PNT": 0, @@ -136,13 +136,13 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE } ``` -| Name | Type | Description | Validation | Required | -| --------- | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | -| `height` | number | The Factom block height this OPR was mined at | Must be a valid integer. Greater than zero. | Y | -| `winners` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | -| `reward` | string | The public Factoid address to credit the PNT mining reward to | Must be a valid public Factoid address. | Y | -| `miner` | string | Stub for future development. The identity of the miner that mined this OPR. | To be a Valid DID chain; initially a arbitrary string. Max length 64 chars if present. | N | -| `assets` | object | The witnessed exchange rates by the miner | Keys must be pegnet currency symbols, values must be numbers greater than or equal to `0` (initially the PNT address can be zero) | Y | +| Name | Type | Description | Validation | Required | +| ---------- | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | +| `height` | number | The Factom block height this OPR was mined at | Must be a valid integer. Greater than zero. | Y | +| `winners` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | +| `coinbase` | string | The public Factoid address to credit the PNT mining reward to | Must be a valid public Factoid address. | Y | +| `miner` | string | Stub for future development. The identity of the miner that mined this OPR. | To be a Valid DID chain; initially a arbitrary string. Max length 64 chars if present. | N | +| `assets` | object | The witnessed exchange rates by the miner | Keys must be pegnet currency symbols, values must be numbers greater than or equal to `0` (initially the PNT address can be zero) | Y | #### OPR Grading Algorithm From 5621f998a5f1e5b2e18fd78cbd26ec3f4fecc104 Mon Sep 17 00:00:00 2001 From: WhoSoup <34172041+WhoSoup@users.noreply.github.com> Date: Mon, 2 Sep 2019 16:40:15 +0200 Subject: [PATCH 17/17] Updates to burns, opr, pow, pnt, opr version * clarification of burn mechanics * renaming PNT to PEG * OPR extids * PoW calculation * opr version distinction --- fatips/2.md | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/fatips/2.md b/fatips/2.md index 550df02..6af0edd 100644 --- a/fatips/2.md +++ b/fatips/2.md @@ -38,7 +38,7 @@ The following assets are supported or will be supported by the pegged asset toke | Asset Name | [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) Symbol | Pegnet Symbol | Activation Height | | ---------------- | --------------------------------------------------------- | ------------- | ----------------- | -| PegNet | - | PNT | 0 | +| PegNet | - | PEG | 0 | | US Dollar | USD | pUSD | 0 | | Euro | EUR | pEUR | 0 | | Japanese Yen | JPY | pJPY | 0 | @@ -59,12 +59,12 @@ Pegged asset onramps are necessary to inject value into the pegged asset token s #### Factom -Creation of pegged Factom ("pFCT") tokens is described by conducting a 1 Entry Credit purchase on the host Factom network to the following addresses to fund the respective virtual Pegnet networks: +Creation of pegged Factom ("pFCT") tokens is described by conducting a 0 Entry Credit purchase on the host Factom network to the following addresses to fund the respective virtual Pegnet networks: -- TestNet - `EC1moooFCT2TESToooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` -- MainNet - `EC1moooFCT2MAINoooo1oooo1oooo1oooo1oooo1oooo1oooo1oo` +- TestNet - `EC2BURNFCT2PEGNETooo1oooo1oooo1oooo1oooo1oooo19wthin` +- MainNet - `EC2BURNFCT2TESTxoooo1oooo1oooo1oooo1oooo1oooo1EoyM6d` -The additional fees of the EC purchase transaction over the base network fee describe the quantity of pFCT credited to the purchasing Factoid address on the pegged asset token system at the rate set by the winning OPR for that block. +The specified input amount describes the quantity of pFCT credited to the purchasing Factoid address on the pegged asset token system at a fixed rate of 1 FCT = 1 pFCT. @@ -76,18 +76,18 @@ The pegged asset token system uses Oracle Price Record entries, or OPRs, as the - Asset exchange rates, relative to USD, as witnessed by the miner - A payout address for rewards -Miners submit valid OPRs to the OPR chain each block in hopes of winning a competitive proof of work problem against other miners that rewards in the base token: PNT. +Miners submit valid OPRs to the OPR chain each block in hopes of winning a competitive proof of work problem against other miners that rewards in the base token: PEG. #### OPR Chain A single Factom chain is defined to house OPR entries depending on test or production chains, defined as the chain with hex encoded External IDs in zero-indexed order: -##### TestNet +##### TestNet for Milestone 1 - `5065674e6574` - "PegNet" in ascii -- `546573744e6574` - "TestNet" in ascii. +- `546573744e65742d704d31` - "TestNet-pM1" in ascii. - `4f7261636c6550726963655265636f726473` - "OraclePriceRecords" in ascii -Corresponding to chain ID `fafedb5fb8e7d1512244b683608f0b248326f1b8fae497058ba8ae8d577e9c14` +Corresponding to chain ID `13de39548b56de06a0c4637f6b16852db6fc56749cbd71692ef9af61a2da3247` ##### MainNet - `5065674e6574` - "PegNet" in ascii @@ -98,7 +98,7 @@ Corresponding to chain ID `a642a8674f46696cc47fdb6b65f9c87b2a19c5ea8123b3d2f0c13 #### OPR Proof of Work Calculation -Each OPR contains a set bytes in ExtId[0] called the nonce. To evaluate the proof of work result ("difficulty"), the Grading algorithm takes the LXR-Hash of the entry's content, appends it with the nonce, and LXR-Hashes it again. The first 8 bytes of the resulting hash are converted to an unsigned 64 bit integer in Big Endian order. A higher value is considered a better difficulty, with 0 being the worst and `2^64 - 1` being the best. +Each OPR contains a set bytes in ExtId[0] called the nonce. To evaluate the proof of work result ("difficulty"), the Grading algorithm takes the SHA-256 hash of the entry's content, appends it with the nonce, and LXR-Hashes it. The first 8 bytes of the resulting hash are converted to an unsigned 64 bit integer in Big Endian order. A higher value is considered a better difficulty, with 0 being the worst and `2^64 - 1` being the best. ``` TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE @@ -106,8 +106,18 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE #### OPR Entry +##### ExtIDs + +| ID | Type | Description | +|---|---|---| +| 0 | byte array | The OPR's nonce for the PoW calculation | +| 1 | 64-bit unsigned integer| Self-reported difficulty: the result of that OPR's PoW calculation | +| 2 | 8-bit unsigned integer | Version id | + ##### Content Example & Validation +##### Version: 1 + ```json { "height":104981, @@ -140,12 +150,14 @@ TODO: NEED HEIGHT-CHALLENGE-SOLUTION EXAMPLE | ---------- | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | | `height` | number | The Factom block height this OPR was mined at | Must be a valid integer. Greater than zero. | Y | | `winners` | array | Previous winning OPR Factom short entry hashes | Values must be 10 valid entry hashes that correspond to the previous OPR winning entries in order. The genesis OPR has no previous winning entries | Y | -| `coinbase` | string | The public Factoid address to credit the PNT mining reward to | Must be a valid public Factoid address. | Y | +| `coinbase` | string | The public Factoid address to credit the PEG mining reward to | Must be a valid public Factoid address. | Y | | `miner` | string | Stub for future development. The identity of the miner that mined this OPR. | To be a Valid DID chain; initially a arbitrary string. Max length 64 chars if present. | N | -| `assets` | object | The witnessed exchange rates by the miner | Keys must be pegnet currency symbols, values must be numbers greater than or equal to `0` (initially the PNT address can be zero) | Y | +| `assets` | object | The witnessed exchange rates by the miner | Keys must be pegnet currency symbols, values must be numbers greater than or equal to `0` (initially the PEG value can be zero) | Y | + +#### OPR Grading Algorithms -#### OPR Grading Algorithm +##### Version 1 (Activation Height: 0) To grade, a block must have at least 10 valid OPRs. @@ -169,9 +181,9 @@ block reward. The highest graded OPR also provides the pricing for the Pegged a ##### Rewards: The best graded 10 OPR records - * Best graded OPR gets 16% (800 PNT) - * Second best OPR gets 12% (600 PNT) - * All Other OPRs get 9% each (450 PNT) + * Best graded OPR gets 16% (800 PEG) + * Second best OPR gets 12% (600 PEG) + * All Other OPRs get 9% each (450 PEG) @@ -197,7 +209,7 @@ Each pegged network shall have its own conversion chain, defined using the same ```json { - "from": "PNT", + "from": "PEG", "input": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", "to": "FCT", "output": "FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC", @@ -245,8 +257,8 @@ Specific Criteria: If all criteria is met, the following occurs as a single atomic operation: - `amount` (or equivalent at current OPR exchange rate if `origin` is true) of token `from` is burnt (destroyed) in address `input` -- `from` is converted to PNT (interim) at the OPR exchange rate -- Interim PNT is expended to create `to` via coinbase transaction to `output` at the current OPR exchange rate +- `from` is converted to PEG (interim) at the OPR exchange rate +- Interim PEG is expended to create `to` via coinbase transaction to `output` at the current OPR exchange rate The conversion is complete.