diff --git a/components/RPC-Connection.jsx b/components/RPC-Connection.jsx index 96954c9fbfcf..64b0f0755945 100644 --- a/components/RPC-Connection.jsx +++ b/components/RPC-Connection.jsx @@ -1,6 +1,6 @@ import { useState, useEffect } from "react"; import { ApiPromise, WsProvider } from "@polkadot/api"; -import { HumanReadable, BlocksToDays } from "./utilities/filters"; +import { HumanReadable, Precise, BlocksToDays } from "./utilities/filters"; /* This component connects to the Polkadot/Kusama APIs and renders the response data. @@ -135,11 +135,14 @@ async function syncData(network, path, setReturnValue) { function applyFilter(value, filter, network, setReturnValue) { switch (filter) { case "humanReadable": - HumanReadable(value, network, setReturnValue) + HumanReadable(value, network, setReturnValue); break; + case "precise": + Precise(value, network, setReturnValue); + break; case "blocksToDays": BlocksToDays(value, setReturnValue); - break; + break; default: console.log("Ignoring unknown filter type"); return; diff --git a/components/utilities/filters.js b/components/utilities/filters.js index 4586ba228c4a..99a18495ec8a 100644 --- a/components/utilities/filters.js +++ b/components/utilities/filters.js @@ -46,6 +46,15 @@ module.exports = { setReturnValue(value.toString()); }, + Precise: function (value, network, setReturnValue) { + // String to number + value = parseFloat(value); + // Apply precision and append symbol without additional rounding + value = `${value / values[network].precision} ${values[network].symbol}`; + // Update value + setReturnValue(value); + }, + BlocksToDays: function (value, setReturnValue) { value = (value * 6) / 86400; // Update value diff --git a/docs/learn/learn-staking-miner.md b/docs/learn/learn-staking-miner.md index a4f9b59a5b9c..32eaf5d9c1c3 100644 --- a/docs/learn/learn-staking-miner.md +++ b/docs/learn/learn-staking-miner.md @@ -16,20 +16,20 @@ discretion, as there is a risk of losing some funds. ::: -At the end of each era on Polkadot and Kusama, using [NPoS](learn-phragmen), a new set of validators -must be elected based on the nominator preferences. This is a computationally intensive process, hence -the usage of the term "mining" for computing the solution. The validators use -[off-chain workers](https://docs.substrate.io/reference/how-to-guides/offchain-workers/) to -compute the result and submit a transaction to propose the set of winners. This can also be delegated -to stand-alone programs, whose task is to mine the optimal solution. Staking miners compete with each other -to produce election solutions which consist of a validator set, stake distribution across that set, and a score -indicating how optimal the solution is. Staking miners run any given staking algorithms (as of now, -sequential Phragmén or PhragMMS, subject to change if improved algorithms are introduced) to produce results, -which are then sent as a transaction to the relay chain via a normal signed extrinsic. The transaction -requires a bond and a transaction fee. The best solution is rewarded, which the least covers the -transaction fee, and the bond is returned to the account. [The bond and the fee](learn-staking-miner#deposit-and-reward-mechanics) are lost if the solution -is invalid. - +At the end of each era on Polkadot and Kusama, using [NPoS](learn-phragmen), a new set of validators +must be elected based on the nominator preferences. This is a computationally intensive process, +hence the usage of the term "mining" for computing the solution. The validators use +[off-chain workers](https://docs.substrate.io/reference/how-to-guides/offchain-workers/) to compute +the result and submit a transaction to propose the set of winners. This can also be delegated to +stand-alone programs, whose task is to mine the optimal solution. Staking miners compete with each +other to produce election solutions which consist of a validator set, stake distribution across that +set, and a score indicating how optimal the solution is. Staking miners run any given staking +algorithms (as of now, sequential Phragmén or PhragMMS, subject to change if improved algorithms are +introduced) to produce results, which are then sent as a transaction to the relay chain via a normal +signed extrinsic. The transaction requires a bond and a transaction fee. The best solution is +rewarded, which the least covers the transaction fee, and the bond is returned to the account. +[The bond and the fee](learn-staking-miner#deposit-and-reward-mechanics) are lost if the solution is +invalid. Staking miner uses a pallet called `pallet_election_provider_multi_phase` and can only produce solutions during the @@ -139,9 +139,10 @@ Current deposit(`SignedDepositBase`) is which is a fixed amount. Current deposit per byte(`SignedDepositByte`) is -{{ polkadot: 0.0000097656 DOT :polkadot }}{{ kusama: 0.00000032551 KSM :kusama }} and the total is -variable depending on the size of the solution data. For example a solution weighing 200KB would -yield {{ polkadot: 200 x 0.0000097656 = **0.00195312 DOT**. :polkadot }} +{{ polkadot: :polkadot }} +{{ kusama: :kusama }} +and the total is variable depending on the size of the solution data. For example, a solution +weighing 200KB would yield {{ polkadot: 200 x 0.0000097656 = **0.00195312 DOT**. :polkadot }} {{ kusama: 200 x 0.00000032551 = **0.000065102 KSM**. :kusama }} And the weight deposit(`SignedDepositWeight`) is currently set to `0` and has no effect.