From fe7705d02e58ceeefcceee9d39dddc1dfad6a924 Mon Sep 17 00:00:00 2001 From: Philipp Gackstatter Date: Fri, 27 Oct 2023 18:29:30 +0100 Subject: [PATCH] Prettify Stored Mana calculation --- tips/TIP-0039/tip-0039.md | 67 ++++++++++----------------------------- 1 file changed, 17 insertions(+), 50 deletions(-) diff --git a/tips/TIP-0039/tip-0039.md b/tips/TIP-0039/tip-0039.md index c6e0bed82..c6d7373c0 100644 --- a/tips/TIP-0039/tip-0039.md +++ b/tips/TIP-0039/tip-0039.md @@ -66,7 +66,7 @@ It is an essential element of the IOTA protocol, as it is used: - [**Block Issuance Credit**](#block-issuance-credit) (BIC) is the form of Mana that can be used to issue blocks. During a transaction, Stored or Potential Mana can be _allotted_ which moves the Mana off the UTXO ledger and converts it to BIC. Only this form of Mana be used to issue blocks. -- [**Mana Rewards**](#mana-rewards) reward participation in staking for validation and delegating IOTA tokens. The Mana +- [**Mana Rewards**](#mana-rewards) reward participation in staking for validation and delegating IOTA coins. The Mana rewarded from these activities is not registered in the UTXO ledger and must be moved to it when claiming rewards as described in [TIP-40](../TIP-0040/tip-0040.md##mana-rewards). @@ -312,60 +312,27 @@ applies the decay to the result, where: ## Stored Mana -_Stored Mana_ is the main form of Mana. It is a UTXO-based form (i.e., it is contained in outputs, just like IOTA -tokens) of Mana that can be transferred within certain rules between different users, which allows for Mana market -development. +_Stored Mana_ is the main form of Mana. It is a UTXO-based form (i.e., it is contained in outputs, just like IOTA coins) +of Mana that can be transferred within certain rules between different users, which allows for the development of a Mana +market. -All output types, except Foundry and Delegation Outputs, can hold stored Mana in the _Mana_ field. This field represents +All output types, except Foundry and Delegation Outputs, can hold Stored Mana in the _Mana_ field. This field represents the amount of stored Mana at the output's creation time until the time when the output is consumed without decay applied to it. -Decay must, therefore, be applied whenever an output containing Stored Mana is consumed. The creation slot of each -output with stored Mana. - -### Stored Mana Semantic Validation - -- Stored Mana must be decayed before it is transferred into a new output as follows: - - Let `manaAmount`, `consumptionSlot`, and `creationSlot`, be - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
manaAmountuint64 - The amount of stored Mana held by the output. -
creationSlotuint64 - The index of slot in which the output was created. -
consumptionSlotuint64 - The index of slot in which the output is consumed. -
- -The algorithm to decay the Stored Mana is as follows: +Decay must, therefore, be applied whenever an output containing Stored Mana is consumed. -```go -creationEpoch = epoch(creationSlot) -consumptionEpoch = epoch(consumptionSlot) -if creationEpoch == consumptionEpoch: - newManaAmount = manaAmount -else: - newManaAmount = Decay(manaAmount, consumptionEpoch - creationEpoch) -``` +Let `Stored Mana(Mana Amount, Output Creation Slot, Transaction Creation Slot)` be the procedure that calculates the +decay whenever Stored Mana is consumed, where: + +- `Mana Amount` is the amount of Stored Mana held in an output. +- `Output Creation Slot` is the slot index in which the output was created. +- `Transaction Creation Slot` is the slot index in which the output is consumed. +- Let `Output Creation Epoch` be the epoch to which `Output Creation Slot` belongs. +- Let `Transaction Creation Epoch` be the epoch to which `Transaction Creation Slot` belongs. + - See [TIP-46 (Time)](TIP-0046/tip-0046.md#time) for the conversion procedure. +- If `Output Creation Epoch == Transaction Creation Epoch` return `Mana Amount`. +- Otherwise return `Decay(Mana Amount, Transaction Creation Epoch - Output Creation Epoch)`. ## Block Issuance Credit