Explorar el Código

Implement tokenomics page

Edvin Dzidic hace 4 años
padre
commit
aa2cdfcbc5

+ 201 - 0
pioneer/packages/app-tokenomics/LICENSE

@@ -0,0 +1,201 @@
+                              Apache License
+                        Version 2.0, January 2004
+                    http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+  "License" shall mean the terms and conditions for use, reproduction,
+  and distribution as defined by Sections 1 through 9 of this document.
+
+  "Licensor" shall mean the copyright owner or entity authorized by
+  the copyright owner that is granting the License.
+
+  "Legal Entity" shall mean the union of the acting entity and all
+  other entities that control, are controlled by, or are under common
+  control with that entity. For the purposes of this definition,
+  "control" means (i) the power, direct or indirect, to cause the
+  direction or management of such entity, whether by contract or
+  otherwise, or (ii) ownership of fifty percent (50%) or more of the
+  outstanding shares, or (iii) beneficial ownership of such entity.
+
+  "You" (or "Your") shall mean an individual or Legal Entity
+  exercising permissions granted by this License.
+
+  "Source" form shall mean the preferred form for making modifications,
+  including but not limited to software source code, documentation
+  source, and configuration files.
+
+  "Object" form shall mean any form resulting from mechanical
+  transformation or translation of a Source form, including but
+  not limited to compiled object code, generated documentation,
+  and conversions to other media types.
+
+  "Work" shall mean the work of authorship, whether in Source or
+  Object form, made available under the License, as indicated by a
+  copyright notice that is included in or attached to the work
+  (an example is provided in the Appendix below).
+
+  "Derivative Works" shall mean any work, whether in Source or Object
+  form, that is based on (or derived from) the Work and for which the
+  editorial revisions, annotations, elaborations, or other modifications
+  represent, as a whole, an original work of authorship. For the purposes
+  of this License, Derivative Works shall not include works that remain
+  separable from, or merely link (or bind by name) to the interfaces of,
+  the Work and Derivative Works thereof.
+
+  "Contribution" shall mean any work of authorship, including
+  the original version of the Work and any modifications or additions
+  to that Work or Derivative Works thereof, that is intentionally
+  submitted to Licensor for inclusion in the Work by the copyright owner
+  or by an individual or Legal Entity authorized to submit on behalf of
+  the copyright owner. For the purposes of this definition, "submitted"
+  means any form of electronic, verbal, or written communication sent
+  to the Licensor or its representatives, including but not limited to
+  communication on electronic mailing lists, source code control systems,
+  and issue tracking systems that are managed by, or on behalf of, the
+  Licensor for the purpose of discussing and improving the Work, but
+  excluding communication that is conspicuously marked or otherwise
+  designated in writing by the copyright owner as "Not a Contribution."
+
+  "Contributor" shall mean Licensor and any individual or Legal Entity
+  on behalf of whom a Contribution has been received by Licensor and
+  subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+  this License, each Contributor hereby grants to You a perpetual,
+  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+  copyright license to reproduce, prepare Derivative Works of,
+  publicly display, publicly perform, sublicense, and distribute the
+  Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+  this License, each Contributor hereby grants to You a perpetual,
+  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+  (except as stated in this section) patent license to make, have made,
+  use, offer to sell, sell, import, and otherwise transfer the Work,
+  where such license applies only to those patent claims licensable
+  by such Contributor that are necessarily infringed by their
+  Contribution(s) alone or by combination of their Contribution(s)
+  with the Work to which such Contribution(s) was submitted. If You
+  institute patent litigation against any entity (including a
+  cross-claim or counterclaim in a lawsuit) alleging that the Work
+  or a Contribution incorporated within the Work constitutes direct
+  or contributory patent infringement, then any patent licenses
+  granted to You under this License for that Work shall terminate
+  as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+  Work or Derivative Works thereof in any medium, with or without
+  modifications, and in Source or Object form, provided that You
+  meet the following conditions:
+
+  (a) You must give any other recipients of the Work or
+      Derivative Works a copy of this License; and
+
+  (b) You must cause any modified files to carry prominent notices
+      stating that You changed the files; and
+
+  (c) You must retain, in the Source form of any Derivative Works
+      that You distribute, all copyright, patent, trademark, and
+      attribution notices from the Source form of the Work,
+      excluding those notices that do not pertain to any part of
+      the Derivative Works; and
+
+  (d) If the Work includes a "NOTICE" text file as part of its
+      distribution, then any Derivative Works that You distribute must
+      include a readable copy of the attribution notices contained
+      within such NOTICE file, excluding those notices that do not
+      pertain to any part of the Derivative Works, in at least one
+      of the following places: within a NOTICE text file distributed
+      as part of the Derivative Works; within the Source form or
+      documentation, if provided along with the Derivative Works; or,
+      within a display generated by the Derivative Works, if and
+      wherever such third-party notices normally appear. The contents
+      of the NOTICE file are for informational purposes only and
+      do not modify the License. You may add Your own attribution
+      notices within Derivative Works that You distribute, alongside
+      or as an addendum to the NOTICE text from the Work, provided
+      that such additional attribution notices cannot be construed
+      as modifying the License.
+
+  You may add Your own copyright statement to Your modifications and
+  may provide additional or different license terms and conditions
+  for use, reproduction, or distribution of Your modifications, or
+  for any such Derivative Works as a whole, provided Your use,
+  reproduction, and distribution of the Work otherwise complies with
+  the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+  any Contribution intentionally submitted for inclusion in the Work
+  by You to the Licensor shall be under the terms and conditions of
+  this License, without any additional terms or conditions.
+  Notwithstanding the above, nothing herein shall supersede or modify
+  the terms of any separate license agreement you may have executed
+  with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+  names, trademarks, service marks, or product names of the Licensor,
+  except as required for reasonable and customary use in describing the
+  origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+  agreed to in writing, Licensor provides the Work (and each
+  Contributor provides its Contributions) on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+  implied, including, without limitation, any warranties or conditions
+  of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+  PARTICULAR PURPOSE. You are solely responsible for determining the
+  appropriateness of using or redistributing the Work and assume any
+  risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+  whether in tort (including negligence), contract, or otherwise,
+  unless required by applicable law (such as deliberate and grossly
+  negligent acts) or agreed to in writing, shall any Contributor be
+  liable to You for damages, including any direct, indirect, special,
+  incidental, or consequential damages of any character arising as a
+  result of this License or out of the use or inability to use the
+  Work (including but not limited to damages for loss of goodwill,
+  work stoppage, computer failure or malfunction, or any and all
+  other commercial damages or losses), even if such Contributor
+  has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+  the Work or Derivative Works thereof, You may choose to offer,
+  and charge a fee for, acceptance of support, warranty, indemnity,
+  or other liability obligations and/or rights consistent with this
+  License. However, in accepting such obligations, You may act only
+  on Your own behalf and on Your sole responsibility, not on behalf
+  of any other Contributor, and only if You agree to indemnify,
+  defend, and hold each Contributor harmless for any liability
+  incurred by, or claims asserted against, such Contributor by reason
+  of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+  To apply the Apache License to your work, attach the following
+  boilerplate notice, with the fields enclosed by brackets "[]"
+  replaced with your own identifying information. (Don't include
+  the brackets!)  The text should be enclosed in the appropriate
+  comment syntax for the file format. We also recommend that a
+  file or class name and description of purpose be included on the
+  same "printed page" as the copyright notice for easier
+  identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.

+ 22 - 0
pioneer/packages/app-tokenomics/README.md

@@ -0,0 +1,22 @@
+# @polkadot/app-123code
+
+A simple template to get started with adding an "app" to this UI. It contains the bare minimum for a nicely hackable app (if you just want to code _somewhere_) and the steps needed to create, add and register an new app that appears in the UI.
+
+## adding an app
+
+If you want to add a new app to the UI, this is the place to start.
+
+1. Duplicate this `app-123code` folder and give it an appropriate name, in this case we will select `app-example` to keep things clear.
+2. Edit the `apps-example/package.json` app description, i.e. the name, author and relevant overview.
+
+And we have the basic app source setup, time to get the tooling correct.
+
+3. Add the new app to the TypeScript config in root, `tsconfig.json`, i.e. an entry such as `"@polkadot/app-example/*": [ "packages/app-example/src/*" ],`
+
+At this point the app should be buildable, but not quite reachable. The final step is to add it to the actual sidebar in `apps`.
+
+4. In `apps-routing/src` duplicate the `123code.ts` file to `example.ts` and edit it with the appropriate information, including the hash link, name and icon (any icon name from semantic-ui-react/font-awesome 4 should be appropriate).
+5. In the above description file, the `isHidden` field needs to be toggled to make it appear - the base template is hidden by default.
+6. Finally add the `template` to the `apps-routing/src/index.ts` file at the appropriate place for both full and light mode (either optional)
+
+Yes. After all that we have things hooked up. Run `yarn start` and your new app (non-coded) should show up. Now start having fun and building something great.

+ 16 - 0
pioneer/packages/app-tokenomics/package.json

@@ -0,0 +1,16 @@
+{
+  "name": "@polkadot/app-tokenomics",
+  "version": "0.37.0-beta.63",
+  "description": "Tokenomics page, basic overview of data from the whole website.",
+  "main": "index.js",
+  "scripts": {},
+  "author": "Edvin Dzidic <edvindzidic2000@gmail.com>",
+  "maintainers": [
+    "Edvin Dzidic <edvindzidic2000@gmail.com>"
+  ],
+  "license": "Apache-2.0",
+  "dependencies": {
+    "@babel/runtime": "^7.7.1",
+    "@polkadot/react-components": "^0.37.0-beta.63"
+  }
+}

+ 25 - 0
pioneer/packages/app-tokenomics/src/Overview/Help.tsx

@@ -0,0 +1,25 @@
+import React, { useState } from 'react';
+import { Icon, Label, Transition } from 'semantic-ui-react';
+
+type HelpProps = {help: string; className?: string; position: { left?: string; right?: string}};
+
+export default function Help (props: HelpProps): React.ReactElement {
+  const [open, setOpen] = useState(false);
+  return (
+    <label
+      className={props.className}
+      onMouseEnter={ (): void => setOpen(true) }
+      onMouseLeave={ (): void => setOpen(false) }
+    >
+      <span style={{ position: 'absolute', display: 'inline-flex', flexWrap: 'wrap', marginTop: '-0.25em' }}>
+        <Icon
+          style={{ margin: '0.25em 0.1em 0.5em 0.25em' }}
+          name="help circle"
+          color="grey"/>
+        <Transition animation="fade" visible={open} duration={500}>
+          <Label basic style={{ minWidth: '15rem', position: 'absolute', ...props.position }} color="grey" content={props.help}/>
+        </Transition>
+      </span>
+    </label>
+  );
+}

+ 97 - 0
pioneer/packages/app-tokenomics/src/Overview/OverviewTable.tsx

@@ -0,0 +1,97 @@
+import React from 'react';
+import { Table } from 'semantic-ui-react';
+import Help from './Help';
+import styled from 'styled-components';
+
+import { TokenomicsData } from '../lib/getTokenomicsData';
+import { StatusServerData } from './index';
+
+const round = (num: number): number => Math.round((num + Number.EPSILON) * 100) / 100;
+
+const OverviewTableHelp = styled(Help)`
+    position:absolute;
+    cursor:pointer;
+    right:2rem;
+    top:0;
+    @media(max-width: 767px){
+      top:0.8rem;
+    }
+`;
+
+const OverviewTableRow: React.FC<{item: string; value: string; help?: string}> = ({ item, value, help }) => {
+  return (
+    <Table.Row>
+      <Table.Cell>
+        <div style={{ position: 'relative' }}>
+          {item}
+          {help && <OverviewTableHelp position={{ right: '2rem' }} help={help} />}
+        </div>
+      </Table.Cell>
+      <Table.Cell>{value}</Table.Cell>
+    </Table.Row>
+  );
+};
+
+const OverviewTable: React.FC<{data: TokenomicsData | undefined; statusData: StatusServerData | undefined | null}> = ({ data, statusData }) => {
+  return (
+    <Table style={{ marginBottom: '1.5rem' }} celled>
+      <Table.Header>
+        <Table.Row>
+          <Table.HeaderCell width={10}>Item</Table.HeaderCell>
+          <Table.HeaderCell width={2}>Value</Table.HeaderCell>
+        </Table.Row>
+      </Table.Header>
+
+      <Table.Body>
+        <OverviewTableRow
+          item='Total Issuance'
+          help='The current supply of tokens.'
+          value={data ? `${data.totalIssuance} JOY` : 'Loading...'}
+        />
+        <OverviewTableRow
+          item='Fiat Pool'
+          help='The current value of the Fiat Pool.'
+          value={statusData === null ? 'Data currently unavailable..' : statusData ? `${round(statusData.dollarPool.size)} USD` : 'Loading...'}
+        />
+        <OverviewTableRow
+          item='Currently Staked Tokens'
+          value={data ? `${data.currentlyStakedTokens} JOY` : 'Loading...'}
+          help='All tokens currently staked for active roles.'
+        />
+        <OverviewTableRow
+          item='Currently Staked Value'
+          value={statusData === null ? 'Data currently unavailable..' : (data && statusData) ? `${round(data.currentlyStakedTokens * Number(statusData.price))} USD` : 'Loading...'}
+          help='The value of all tokens currently staked for active roles.'
+        />
+        <OverviewTableRow
+          item='Exchange Rate'
+          value={statusData === null ? 'Data currently unavailable..' : statusData ? `${round(Number(statusData.price) * 1000000)} USD/1MJOY` : 'Loading...'}
+          help='The current exchange rate.'
+        />
+        {/* <OverviewTableRow help='Sum of all tokens burned through exchanges' item='Total Tokens Burned/Exchanged' value={statusData ? `${statusData.burned} JOY` : 'Loading...'}/> */}
+        <OverviewTableRow
+          item='Projected Weekly Token Mint Rate'
+          value={data ? `${Math.round(data.totalWeeklySpending)} JOY` : 'Loading...'}
+          help='Projection of tokens minted over the next week, based on current rewards for all roles.'
+        />
+        <OverviewTableRow
+          item='Projected Weekly Token Inflation Rate'
+          value={data ? `${round((data.totalWeeklySpending / data.totalIssuance) * 100)} %` : 'Loading...'}
+          help={'Based on \'Projected Weekly Token Mint Rate\'. Does not include any deflationary forces (fees, slashes, burns, etc.)'}
+        />
+        <OverviewTableRow
+          item='Projected Weekly Value Of Mint'
+          value={statusData === null ? 'Data currently unavailable..' : (data && statusData) ? `${round(data.totalWeeklySpending * Number(statusData.price))} USD` : 'Loading...'}
+          help={'Based on \'Projected Weekly Token Mint Rate\', and current \'Exchange Rate\'.'}
+        />
+        <OverviewTableRow
+          item='Weekly Top Ups'
+          value={statusData === null ? 'Data currently unavailable..' : statusData ? `${statusData.dollarPool.replenishAmount} USD` : 'Loading...'}
+          help={'The current weekly \'Fiat Pool\' replenishment amount. Does not include KPIs, or other potential top ups.'}
+        />
+      </Table.Body>
+    </Table>
+  );
+};
+
+export default OverviewTable;

+ 52 - 0
pioneer/packages/app-tokenomics/src/Overview/PieChart.tsx

@@ -0,0 +1,52 @@
+import React, { useEffect } from 'react';
+import styled from 'styled-components';
+import { Icon, Label } from 'semantic-ui-react';
+
+const ChartContainer = styled('div')`
+  display:flex;
+  flex-direction:column;
+  align-items:center;
+`;
+
+const PieChart: React.FC<{icon: any; typeOfChart: string; percentages: Array<{ percent: any; color: string}>}> = ({ icon, typeOfChart, percentages }) => {
+  let cumulativePercent = 0;
+
+  const getCoordinatesForPercent = (percent: number): Array<number> => {
+    const x = Math.cos(2 * Math.PI * percent);
+    const y = Math.sin(2 * Math.PI * percent);
+    return [x, y];
+  };
+
+  useEffect(() => {
+    if (percentages) {
+      const svgEl = document.querySelector(`#pieChart${typeOfChart}`) as Element;
+      percentages.forEach(slice => {
+        const [startX, startY] = getCoordinatesForPercent(cumulativePercent);
+        cumulativePercent += slice.percent;
+        const [endX, endY] = getCoordinatesForPercent(cumulativePercent);
+        const largeArcFlag = slice.percent > 0.5 ? 1 : 0;
+        const pathData = [
+          `M ${startX} ${startY}`,
+          `A 1 1 0 ${largeArcFlag} 1 ${endX} ${endY}`,
+          'L 0 0'
+        ].join(' ');
+
+        const pathEl = document.createElementNS('http://www.w3.org/2000/svg', 'path');
+        pathEl.setAttribute('d', pathData);
+        pathEl.setAttribute('fill', slice.color);
+        svgEl.appendChild(pathEl);
+      });
+    }
+  }, []);
+  return (
+    <ChartContainer>
+      <svg id={`pieChart${typeOfChart}`} viewBox="-1 -1 2 2" style={{ transform: 'rotate(-90deg)', marginBottom: '2rem' }}></svg>
+      <Label as='div'>
+        <Icon name={icon} />
+        <span style={{ fontWeight: 600 }}>{typeOfChart}</span>
+      </Label>
+    </ChartContainer>
+  );
+};
+
+export default PieChart;

+ 218 - 0
pioneer/packages/app-tokenomics/src/Overview/SpendingAndStakeDistributionTable.tsx

@@ -0,0 +1,218 @@
+import React from 'react';
+import { Table } from 'semantic-ui-react';
+import styled from 'styled-components';
+import Help from './Help';
+import useWindowDimensions from './hooks/useWindowDimensions';
+
+import { TokenomicsData } from '../lib/getTokenomicsData';
+import { StatusServerData } from './index';
+
+const round = (num: number): number => Math.round((num + Number.EPSILON) * 100) / 100;
+
+const StyledTable = styled(Table)`
+  border: none !important;
+  width: 70% !important;
+  margin-bottom:1.5rem;
+  @media (max-width: 1400px){
+    width:100% !important;
+  }
+  & > tbody > tr{
+    td:nth-of-type(1), td:nth-of-type(3), td:nth-of-type(6){
+      border-left: 0.12rem solid rgba(20,20,20,0.3) !important;
+    }
+    td:nth-of-type(9){
+      border-right: 0.12rem solid rgba(20,20,20,0.3) !important;
+      border-left:0.12rem solid rgba(20,20,20,0.3) !important;
+    }
+  }
+  & > tbody > tr:nth-of-type(6){
+    td{
+      border-bottom: 0.12rem solid rgba(20,20,20,0.3) !important;
+    }
+    td:nth-of-type(1){
+      border-bottom-left-radius: .28571429rem !important;
+    }
+    td:nth-of-type(9){
+      border-bottom-right-radius: .28571429rem !important;
+    }
+  }
+  & > thead > tr{
+    th{
+      border-top: 0.12rem solid rgba(20,20,20,0.3) !important;
+    }
+    th:nth-of-type(1), th:nth-of-type(3), th:nth-of-type(6){
+      border-left: 0.12rem solid rgba(20,20,20,0.3) !important;
+    }
+    th:nth-of-type(9){
+      border-right:0.12rem solid rgba(20,20,20,0.3) !important;
+      border-left:0.12rem solid rgba(20,20,20,0.3) !important;
+    }
+  }
+  & > tbody > tr > td:nth-of-type(1){
+    position:relative !important;
+  }
+  & .tableColorBlock{
+    height: 1rem;
+    width:1rem;
+    margin: 0 auto;
+    @media (max-width: 768px){
+      margin: 0;
+    }
+  }
+`;
+
+const SpendingAndStakeDistributionTableHelp = styled(Help)`
+    position:absolute;
+    cursor:pointer;
+    right:1.7rem;
+    top:0.7rem;
+    @media(max-width: 767px){
+      top:0.8rem;
+      right:3rem;
+    }
+`;
+
+const SpendingAndStakeTableRow: React.FC<{
+  role: string;
+  numberOfActors?: string;
+  groupEarning?: string;
+  groupEarningDollar?: string;
+  earningShare?: string;
+  groupStake?: string;
+  groupStakeDollar?: string;
+  stakeShare?: string;
+  color?: string;
+  active?: boolean;
+  helpContent?: string;
+  helpPosition?: string;
+}> = ({ role, numberOfActors, groupEarning, groupEarningDollar, earningShare, groupStake, groupStakeDollar, stakeShare, color, active, helpContent, helpPosition }) => {
+  const parseData = (data: string | undefined): string | JSX.Element => {
+    if (data && active) {
+      return <em>{data}</em>;
+    } else if (data) {
+      return data;
+    } else {
+      return 'Loading..';
+    }
+  };
+
+  return (
+    <Table.Row color={active && 'rgb(150, 150, 150)'}>
+      <Table.Cell>
+        {active ? <strong>{role}</strong> : role}
+        {(helpContent && helpPosition) && <SpendingAndStakeDistributionTableHelp position={helpPosition === 'left' ? { left: '2rem' } : { right: '2rem' }} help={helpContent} />}
+      </Table.Cell>
+      <Table.Cell>{parseData(numberOfActors)}</Table.Cell>
+      <Table.Cell>{parseData(groupEarning)}</Table.Cell>
+      <Table.Cell>{parseData(groupEarningDollar)}</Table.Cell>
+      <Table.Cell>{parseData(earningShare)}</Table.Cell>
+      <Table.Cell>{parseData(groupStake)}</Table.Cell>
+      <Table.Cell>{parseData(groupStakeDollar)}</Table.Cell>
+      <Table.Cell>{parseData(stakeShare)}</Table.Cell>
+      <Table.Cell><div className='tableColorBlock' style={{ backgroundColor: color }}></div></Table.Cell>
+    </Table.Row>
+  );
+};
+
+const SpendingAndStakeDistributionTable: React.FC<{data: TokenomicsData | undefined; statusData: StatusServerData | undefined | null}> = ({ data, statusData }) => {
+  const { height, width } = useWindowDimensions();
+
+  return (
+    <StyledTable celled>
+      <Table.Header>
+        <Table.Row>
+          <Table.HeaderCell width={4}>Group/Role</Table.HeaderCell>
+          <Table.HeaderCell><div>Actors</div>[Number]</Table.HeaderCell>
+          <Table.HeaderCell><div>Group earning</div> [JOY/Week]</Table.HeaderCell>
+          <Table.HeaderCell><div>Group earning</div> [USD/Week]</Table.HeaderCell>
+          <Table.HeaderCell><div>Share</div> [%]</Table.HeaderCell>
+          <Table.HeaderCell><div>Group Stake</div> [JOY]</Table.HeaderCell>
+          <Table.HeaderCell><div>Group Stake</div> [USD]</Table.HeaderCell>
+          <Table.HeaderCell><div>Share</div> [%]</Table.HeaderCell>
+          <Table.HeaderCell width={1}>Color</Table.HeaderCell>
+        </Table.Row>
+      </Table.Header>
+
+      <Table.Body>
+        <SpendingAndStakeTableRow
+          role={width <= 1050 ? 'Validators' : 'Validators (Nominators)'}
+          helpContent='The current set of active Validators (and Nominators), and the sum of the sets projected rewards and total stakes (including Nominators).'
+          helpPosition={width <= 767 ? 'right' : 'left'}
+          numberOfActors={data && `${data.validators.number} (${data.validators.nominators.number})`}
+          groupEarning={data && `${Math.round(data.validators.rewardsPerWeek)}`}
+          groupEarningDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.validators.rewardsPerWeek * Number(statusData.price))}`}
+          earningShare={data && `${round(data.validators.rewardsShare * 100)}`}
+          groupStake={data && `${data.validators.totalStake}`}
+          groupStakeDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.validators.totalStake * Number(statusData.price))}`}
+          stakeShare={data && `${round(data.validators.stakeShare * 100)}`}
+          color='rgb(246, 109, 68)'
+        />
+        <SpendingAndStakeTableRow
+          role={width <= 1015 ? 'Council' : 'Council Members'}
+          helpContent='The current Council Members, and the sum of their projected rewards and total stakes (including voters/backers).'
+          helpPosition={width <= 767 ? 'right' : 'left'}
+          numberOfActors={data && `${data.council.number}`}
+          groupEarning={data && `${Math.round(data.council.rewardsPerWeek)}`}
+          groupEarningDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.council.rewardsPerWeek * Number(statusData.price))}`}
+          earningShare={data && `${round(data.council.rewardsShare * 100)}`}
+          groupStake={data && `${data.council.totalStake}`}
+          groupStakeDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.council.totalStake * Number(statusData.price))}`}
+          stakeShare={data && `${round(data.council.stakeShare * 100)}`}
+          color='rgb(254, 174, 101)'
+        />
+        <SpendingAndStakeTableRow
+          role={width <= 1015 ? 'Storage' : 'Storage Providers'}
+          helpContent='The current Storage Providers, and the sum of their projected rewards and stakes.'
+          helpPosition={width <= 767 ? 'right' : 'left'}
+          numberOfActors={data && `${data.storageProviders.number}`}
+          groupEarning={data && `${Math.round(data.storageProviders.rewardsPerWeek)}`}
+          groupEarningDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.storageProviders.rewardsPerWeek * Number(statusData.price))}`}
+          earningShare={data && `${round(data.storageProviders.rewardsShare * 100)}`}
+          groupStake={data && `${data.storageProviders.totalStake}`}
+          groupStakeDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.storageProviders.totalStake * Number(statusData.price))}`}
+          stakeShare={data && `${round(data.storageProviders.stakeShare * 100)}`}
+          color='rgb(230, 246, 157)'
+        />
+        <SpendingAndStakeTableRow
+          role={width <= 1015 ? 'S. Lead' : width <= 1050 ? 'Storage Lead' : 'Storage Provider Lead'}
+          helpContent='Current Storage Provider Lead, and their projected reward and stake.'
+          helpPosition={width <= 767 ? 'right' : 'left'}
+          numberOfActors={data && `${data.storageProviders.lead.number}`}
+          groupEarning={data && `${Math.round(data.storageProviders.lead.rewardsPerWeek)}`}
+          groupEarningDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.storageProviders.lead.rewardsPerWeek * Number(statusData.price))}`}
+          earningShare={data && `${round(data.storageProviders.lead.rewardsShare * 100)}`}
+          groupStake={data && `${data.storageProviders.lead.totalStake}`}
+          groupStakeDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.storageProviders.lead.totalStake * Number(statusData.price))}`}
+          stakeShare={data && `${round(data.storageProviders.lead.stakeShare * 100)}`}
+          color='rgb(170, 222, 167)'
+        />
+        <SpendingAndStakeTableRow
+          role={width <= 1015 ? 'Content' : 'Content Curators'}
+          helpContent='The current Content Curators (and their Lead), and the sum of their projected rewards and stakes.'
+          helpPosition={width <= 767 ? 'right' : 'left'}
+          numberOfActors={data && `${data.contentCurators.number} (${data.contentCurators.contentCuratorLead})`}
+          groupEarning={data && `${Math.round(data.contentCurators.rewardsPerWeek)}`}
+          groupEarningDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.contentCurators.rewardsPerWeek * Number(statusData.price))}`}
+          earningShare={data && `${round(data.contentCurators.rewardsShare * 100)}`}
+          groupStake={data && `${data.contentCurators.totalStake}`}
+          groupStakeDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.contentCurators.totalStake * Number(statusData.price))}`}
+          stakeShare={data && `${round(data.contentCurators.stakeShare * 100)}`}
+          color='rgb(100, 194, 166)'
+        />
+        <SpendingAndStakeTableRow
+          role='TOTAL'
+          active={true}
+          numberOfActors={data && `${data.totalNumberOfActors}`}
+          groupEarning={data && `${Math.round(data.totalWeeklySpending)}`}
+          groupEarningDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.totalWeeklySpending * Number(statusData.price))}`}
+          earningShare={data && '100'}
+          groupStake={data && `${data.currentlyStakedTokens}`}
+          groupStakeDollar={statusData === null ? 'Data currently unavailable..' : (data && statusData) && `${round(data.currentlyStakedTokens * Number(statusData.price))}`}
+          stakeShare={data && '100'}
+        />
+      </Table.Body>
+    </StyledTable>
+  );
+};
+
+export default SpendingAndStakeDistributionTable;

+ 95 - 0
pioneer/packages/app-tokenomics/src/Overview/TokenomicsCharts.tsx

@@ -0,0 +1,95 @@
+import React from 'react';
+import PieChart from './PieChart';
+import { Icon } from 'semantic-ui-react';
+import styled from 'styled-components';
+
+import { TokenomicsData } from '../lib/getTokenomicsData';
+
+const TokenomicsChartsContainer = styled('div')`
+  width:30%;
+  display:flex;
+  align-items:center;
+  justify-content:space-evenly;
+  padding: 2rem 0;
+  svg{
+    height:15rem;
+  }
+  @media (max-width: 1650px){
+    svg{
+      height:12rem;
+    }
+  }
+  @media (max-width: 1400px){
+    width:100%;
+    svg{
+      height:15rem;
+    }
+  }
+  @media (max-width: 550px){
+    flex-direction:column;
+    & > div {
+      margin-bottom: 1.5rem;
+    }
+  }
+`;
+
+const TokenomicsCharts: React.FC<{data: TokenomicsData | undefined}> = ({ data }) => {
+  return (
+    <TokenomicsChartsContainer>
+      {data
+        ? <PieChart
+          icon='money'
+          typeOfChart='Spending'
+          percentages={[
+            {
+              percent: data.validators.rewardsShare,
+              color: 'rgb(246, 109, 68)'
+            },
+            {
+              percent: data.council.rewardsShare,
+              color: 'rgb(254, 174, 101)'
+            },
+            {
+              percent: data.storageProviders.rewardsShare,
+              color: 'rgb(230, 246, 157)'
+            },
+            {
+              percent: data.storageProviders.lead.rewardsShare,
+              color: 'rgb(170, 222, 167)'
+            },
+            {
+              percent: data.contentCurators.rewardsShare,
+              color: 'rgb(100, 194, 166)'
+            }
+          ]}/> : <Icon name='circle notched' loading/>}
+      {data
+        ? <PieChart
+          icon='block layout'
+          typeOfChart='Staking'
+          percentages={[
+            {
+              percent: data.validators.stakeShare,
+              color: 'rgb(246, 109, 68)'
+            },
+            {
+              percent: data.council.stakeShare,
+              color: 'rgb(254, 174, 101)'
+            },
+            {
+              percent: data.storageProviders.stakeShare,
+              color: 'rgb(230, 246, 157)'
+            },
+            {
+              percent: data.storageProviders.lead.stakeShare,
+              color: 'rgb(170, 222, 167)'
+            },
+            {
+              percent: data.contentCurators.stakeShare,
+              color: 'rgb(100, 194, 166)'
+            }
+          ]}/> : <Icon name='circle notched' loading />}
+    </TokenomicsChartsContainer>
+  );
+};
+
+export default TokenomicsCharts;

+ 24 - 0
pioneer/packages/app-tokenomics/src/Overview/hooks/useWindowDimensions.ts

@@ -0,0 +1,24 @@
+import { useState, useEffect } from 'react';
+
+function getWindowDimensions () {
+  const { innerWidth: width, innerHeight: height } = window;
+  return {
+    width,
+    height
+  };
+}
+
+export default function useWindowDimensions () {
+  const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
+
+  useEffect(() => {
+    function handleResize () {
+      setWindowDimensions(getWindowDimensions());
+    }
+
+    window.addEventListener('resize', handleResize);
+    return () => window.removeEventListener('resize', handleResize);
+  }, []);
+
+  return windowDimensions;
+}

+ 75 - 0
pioneer/packages/app-tokenomics/src/Overview/index.tsx

@@ -0,0 +1,75 @@
+import React, { useEffect, useState } from 'react';
+import getTokenomicsData, { TokenomicsData } from '../lib/getTokenomicsData';
+import { api } from '@polkadot/react-api';
+import OverviewTable from './OverviewTable';
+import SpendingAndStakeDistributionTable from './SpendingAndStakeDistributionTable';
+import TokenomicsCharts from './TokenomicsCharts';
+import styled from 'styled-components';
+
+const SpendingAndStakeContainer = styled('div')`
+  display:flex;
+  justify-content:space-between;
+  @media (max-width: 1400px){
+    flex-direction:column;
+  }
+`;
+
+const Title = styled('h2')`
+  border-bottom: 1px solid #ddd;
+  margin: 0 0 2rem 0;
+`;
+
+export type StatusServerData = {
+  dollarPool: {
+    size: number;
+    replenishAmount: number;
+  };
+  price: string;
+}
+
+const Overview: React.FC<{}> = () => {
+  const [data, setData] = useState<TokenomicsData | undefined>();
+  const [statusData, setStatusData] = useState<StatusServerData | undefined | null>();
+
+  const getStatusData = async (): Promise<void> => {
+    try {
+      const response = await fetch('https://status.joystream.org/status');
+      if (response.status >= 200 && response.status <= 299) {
+        const statusData = await response.json();
+        setStatusData(statusData);
+      } else {
+        setStatusData(null);
+      }
+    } catch (e) {
+      console.log(e);
+    }
+  };
+
+  const getApiData = async (): Promise<void> => {
+    try {
+      const data = await getTokenomicsData(api);
+      setData(data);
+    } catch (e) {
+      console.log(e);
+    }
+  };
+
+  useEffect(() => {
+    getApiData();
+    getStatusData();
+  }, []);
+
+  return (
+        <>
+          <Title> Overview </Title>
+          <OverviewTable data={data} statusData={statusData}/>
+          <Title> Spending and Stake Distribution </Title>
+          <SpendingAndStakeContainer>
+            <SpendingAndStakeDistributionTable data={data} statusData={statusData}/>
+            <TokenomicsCharts data={data} />
+          </SpendingAndStakeContainer>
+        </>
+  );
+};
+
+export default Overview;

+ 33 - 0
pioneer/packages/app-tokenomics/src/index.tsx

@@ -0,0 +1,33 @@
+import React from 'react';
+import translate from './translate';
+import { Route, Switch } from 'react-router';
+import { Tabs } from '@polkadot/react-components';
+import Overview from './Overview';
+
+import { AppProps, I18nProps } from '@polkadot/react-components/types';
+
+interface Props extends AppProps, I18nProps {}
+
+function App ({ basePath, t }: Props): React.ReactElement<Props> {
+  return (
+    <main>
+      <header>
+        <Tabs
+          basePath={basePath}
+          items={[
+            {
+              isRoot: true,
+              name: 'overview',
+              text: t('Tokenomics')
+            }
+          ]}
+        />
+      </header>
+      <Switch>
+        <Route component={Overview} />
+      </Switch>
+    </main>
+  );
+}
+
+export default translate(App);

+ 58 - 0
pioneer/packages/app-tokenomics/src/lib/getContentCuratorData.ts

@@ -0,0 +1,58 @@
+import { ApiPromise } from '@polkadot/api';
+import { Reward } from './getTokenomicsData';
+
+type ContentCurator = {
+  reward_relationship: number;
+  role_stake_profile: {
+    stake_id: number;
+  };
+}
+
+const getCurators = async (api: ApiPromise): Promise<Array<ContentCurator>> => {
+  const curators: Array<ContentCurator> = [];
+  const [workerIds, curatorData] = ((await api.query.contentWorkingGroup.curatorById()).toJSON() as [Array<number>, Array<object>]);
+  curatorData.map((data: any, index: number) => {
+    if (Object.keys(data.stage)[0] === 'Active') {
+      curators.push({ ...data, workerId: workerIds[index] });
+    }
+  });
+  return curators;
+};
+
+const calculateRewards = (curators: Array<ContentCurator>, recurringRewards: Array<Reward>): number => {
+  let rewardsPerBlock = 0;
+  curators.forEach((curator: ContentCurator) => {
+    const reward: Reward = recurringRewards.filter((reward: Reward) => reward.recipient === curator.reward_relationship)[0];
+    if (reward && reward.amount_per_payout && reward.payout_interval) {
+      rewardsPerBlock += reward.amount_per_payout / reward.payout_interval;
+    }
+  });
+  return rewardsPerBlock;
+};
+
+const calculateStake = async (api: ApiPromise, curators: Array<ContentCurator>): Promise<number> => {
+  const stakeIds: Array<number> = []; let totalContentCuratorStake = 0;
+  curators.forEach((curator: any) => {
+    if (curator.role_stake_profile) {
+      stakeIds.push(curator.role_stake_profile.stake_id);
+    }
+  });
+  const curatorStakeData = await api.query.stake.stakes.multi(stakeIds);
+  curatorStakeData.map((stakeData: any) => {
+    totalContentCuratorStake += stakeData.toJSON()[0].staking_status.Staked.staked_amount;
+  });
+  return totalContentCuratorStake;
+};
+
+export default async (api: ApiPromise, recurringRewards: Array<Reward>): Promise<any> => {
+  const currentLead = (await api.query.contentWorkingGroup.currentLeadId()).toJSON() as number;
+  const curators = await getCurators(api);
+  const rewardsPerBlock = calculateRewards(curators, recurringRewards);
+  const totalContentCuratorStake = await calculateStake(api, curators);
+  return {
+    numberOfCurators: curators.length,
+    contentCuratorLead: currentLead ? 1 : 0,
+    curatorRewardsPerWeeek: rewardsPerBlock * 100800,
+    totalContentCuratorStake
+  };
+};

+ 70 - 0
pioneer/packages/app-tokenomics/src/lib/getCouncilData.ts

@@ -0,0 +1,70 @@
+import { Vec, u32 } from '@polkadot/types';
+import { ApiPromise } from '@polkadot/api';
+import { BlockNumber, BalanceOf } from '@polkadot/types/interfaces';
+
+const getCouncilMembers = async (api: ApiPromise): Promise<any> => {
+  let totalStake = 0;
+  const activeCouncil = await api.query.council.activeCouncil() as Vec<u32>;
+  const payoutInterval = (await api.query.council.payoutInterval()).toJSON() as number;
+  const amountPerPayout = (await api.query.council.amountPerPayout() as BalanceOf).toNumber();
+  console.log(amountPerPayout, payoutInterval);
+  activeCouncil.map((member: any) => {
+    let stakeAmount = 0;
+    stakeAmount += member.get('stake').toNumber();
+    member.get('backers').forEach((backer: any) => {
+      stakeAmount += backer.stake.toNumber();
+    });
+    totalStake += stakeAmount;
+  });
+  return {
+    numberOfCouncilMembers: activeCouncil.length,
+    totalCouncilRewardsPerBlock: (amountPerPayout * activeCouncil.length) / payoutInterval,
+    totalCouncilStake: totalStake
+  };
+};
+
+const calculateCouncilRewards = async (api: ApiPromise, totalCouncilRewardsPerBlock: number): Promise<any> => {
+  let weekInBlocks = 100800;
+  let councilRewardsInOneWeek = 0;
+  const termDuration = (await api.query.councilElection.newTermDuration() as BlockNumber).toNumber();
+  const votingPeriod = (await api.query.councilElection.votingPeriod() as BlockNumber).toNumber();
+  const revealingPeriod = (await api.query.councilElection.revealingPeriod() as BlockNumber).toNumber();
+  const announcingPeriod = (await api.query.councilElection.announcingPeriod() as BlockNumber).toNumber();
+  while (weekInBlocks > 0) {
+    if (weekInBlocks > termDuration) {
+      councilRewardsInOneWeek += termDuration * totalCouncilRewardsPerBlock;
+      weekInBlocks -= termDuration;
+    } else {
+      councilRewardsInOneWeek += weekInBlocks * totalCouncilRewardsPerBlock;
+      return councilRewardsInOneWeek;
+    }
+    // -----------------------------
+    if (weekInBlocks > revealingPeriod) {
+      weekInBlocks -= revealingPeriod;
+    } else {
+      return councilRewardsInOneWeek;
+    }
+    // -----------------------------
+    if (weekInBlocks > votingPeriod) {
+      weekInBlocks -= votingPeriod;
+    } else {
+      return councilRewardsInOneWeek;
+    }
+    // -----------------------------
+    if (weekInBlocks > announcingPeriod) {
+      weekInBlocks -= announcingPeriod;
+    } else {
+      return councilRewardsInOneWeek;
+    }
+  }
+};
+
+export default async (api: ApiPromise): Promise<any> => {
+  const { numberOfCouncilMembers, totalCouncilRewardsPerBlock, totalCouncilStake } = await getCouncilMembers(api);
+  const totalCouncilRewardsInOneWeek = await calculateCouncilRewards(api, totalCouncilRewardsPerBlock) as number;
+  return {
+    numberOfCouncilMembers,
+    totalCouncilRewardsInOneWeek,
+    totalCouncilStake
+  };
+};

+ 102 - 0
pioneer/packages/app-tokenomics/src/lib/getStorageProviderData.ts

@@ -0,0 +1,102 @@
+import { ApiPromise } from '@polkadot/api';
+import { Reward } from './getTokenomicsData';
+
+type StorageProvider = {
+  reward_relationship: number;
+  role_stake_profile: {
+    stake_id: number;
+  };
+  workerId: number;
+  lead?: boolean;
+}
+
+const getStorageProviders = async (api: ApiPromise): Promise<any> => {
+  const storageProviders: Array<StorageProvider> = [];
+  let [numberOfStorageProviders, leadNumber] = [0, 0];
+  const currentLead = (await api.query.storageWorkingGroup.currentLead()).toJSON() as number;
+  const [workerIds, storageProviderData] = (await api.query.storageWorkingGroup.workerById()).toJSON() as [Array<number>, Array<object>];
+  storageProviderData.map((providerData: any, index: number) => {
+    if (workerIds[index] === currentLead) {
+      leadNumber += 1;
+      storageProviders.push({
+        workerId: workerIds[index],
+        lead: true,
+        ...providerData
+      });
+    } else {
+      numberOfStorageProviders += 1;
+      storageProviders.push({
+        workerId: workerIds[index],
+        ...providerData
+      });
+    }
+  });
+  return {
+    numberOfStorageProviders,
+    leadNumber,
+    storageProviders
+  };
+};
+
+const calculateProviders = async (api: ApiPromise, storageProviders: Array<StorageProvider>, recurringRewards: Array<Reward>): Promise<any> => {
+  let totalProviderStake = 0; let providerRewardsPerBlock = 0; let leadRewardsPerBlock = 0; let leadStake = 0;
+  const providerStakeIds: Array<number> = [];
+  let leadStakeId: number | null = null;
+  storageProviders.forEach((provider: StorageProvider) => {
+    // CALCULATE REWARDS
+    recurringRewards.forEach((reward: Reward) => {
+      if (provider.reward_relationship && reward.recipient === provider.reward_relationship) {
+        if (!provider.lead) {
+          if (reward.amount_per_payout && reward.payout_interval) {
+            providerRewardsPerBlock += reward.amount_per_payout / reward.payout_interval;
+          }
+        } else {
+          if (reward.amount_per_payout && reward.payout_interval) {
+            leadRewardsPerBlock += reward.amount_per_payout / reward.payout_interval;
+          }
+        }
+      }
+    });
+    // ADD STAKING DATA FOR PROVIDERS
+    if (provider.role_stake_profile && provider.workerId) {
+      if (!provider.lead) {
+        providerStakeIds.push(provider.role_stake_profile.stake_id);
+      } else {
+        leadStakeId = provider.role_stake_profile.stake_id;
+      }
+    }
+  });
+
+  // CALCULATE PROVIDER STAKE
+  ((await api.query.stake.stakes.multi(providerStakeIds.map((id: number) => id)))).map((data: any) => {
+    totalProviderStake += data[0].toJSON().staking_status.Staked.staked_amount;
+  });
+
+  // CALCULATE LEAD STAKE
+  if (leadStakeId !== null) {
+    leadStake += ((await api.query.stake.stakes(leadStakeId)).toJSON() as Array<any>)[0].staking_status.Staked.staked_amount;
+  }
+
+  return {
+    totalProviderStake,
+    leadStake,
+    providerRewardsPerBlock,
+    leadRewardsPerBlock
+  };
+};
+
+export default async (api: ApiPromise, recurringRewards: Array<Reward>): Promise<any> => {
+  const { numberOfStorageProviders, leadNumber, storageProviders } = await getStorageProviders(api);
+  const { totalProviderStake, leadStake, providerRewardsPerBlock, leadRewardsPerBlock } = await calculateProviders(api, storageProviders, recurringRewards);
+
+  console.log(totalProviderStake, leadStake, providerRewardsPerBlock, leadRewardsPerBlock);
+
+  return {
+    numberOfStorageProviders,
+    totalProviderStake,
+    leadStake,
+    providerRewardsPerWeek: providerRewardsPerBlock * 100800,
+    leadRewardsPerWeek: leadRewardsPerBlock * 100800,
+    storageProviderLead: leadNumber
+  };
+};

+ 116 - 0
pioneer/packages/app-tokenomics/src/lib/getTokenomicsData.ts

@@ -0,0 +1,116 @@
+import { ApiPromise } from '@polkadot/api';
+
+import getStorageProviderData from './getStorageProviderData';
+import getCouncilData from './getCouncilData';
+import getValidatorData from './getValidatorData';
+import getContentCuratorData from './getContentCuratorData';
+
+export type TokenomicsData = {
+  totalIssuance: number;
+  currentlyStakedTokens: number;
+  totalWeeklySpending: number;
+  totalNumberOfActors: number;
+  validators: {
+    number: number;
+    nominators: {
+      number: number;
+    };
+    rewardsPerWeek: number;
+    rewardsShare: number;
+    totalStake: number;
+    stakeShare: number;
+  };
+  council: {
+    number: number;
+    rewardsPerWeek: number;
+    rewardsShare: number;
+    totalStake: number;
+    stakeShare: number;
+  };
+  storageProviders: {
+    number: number;
+    totalStake: number;
+    stakeShare: number;
+    rewardsPerWeek: number;
+    rewardsShare: number;
+    lead: {
+      number: number;
+      totalStake: number;
+      stakeShare: number;
+      rewardsPerWeek: number;
+      rewardsShare: number;
+    };
+  };
+  contentCurators: {
+    number: number;
+    contentCuratorLead: number;
+    rewardsPerWeek: number;
+    rewardsShare: number;
+    totalStake: number;
+    stakeShare: number;
+  };
+}
+
+export type Reward = {
+  recipient: number;
+  amount_per_payout: number;
+  payout_interval: number;
+}
+
+export default async (api: ApiPromise): Promise<TokenomicsData> => {
+  const totalIssuance = (await api.query.balances.totalIssuance()).toJSON() as number;
+  const [, recurringRewards] = (await api.query.recurringRewards.rewardRelationships()).toJSON() as [Array<number>, Array<Reward>];
+  const { numberOfValidators, numberOfNominators, validatorRewardsPerWeek, totalValidatorStake } = await getValidatorData(api, totalIssuance);
+  const { numberOfCouncilMembers, totalCouncilRewardsInOneWeek, totalCouncilStake } = await getCouncilData(api);
+  const { numberOfStorageProviders, totalProviderStake, leadStake, providerRewardsPerWeek, leadRewardsPerWeek, storageProviderLead } = await getStorageProviderData(api, recurringRewards);
+  const { numberOfCurators, contentCuratorLead, curatorRewardsPerWeeek, totalContentCuratorStake } = await getContentCuratorData(api, recurringRewards);
+  const currentlyStakedTokens = totalValidatorStake + totalCouncilStake + totalProviderStake + leadStake + totalContentCuratorStake;
+  const totalWeeklySpending = validatorRewardsPerWeek + totalCouncilRewardsInOneWeek + providerRewardsPerWeek + leadRewardsPerWeek + curatorRewardsPerWeeek;
+  const totalNumberOfActors = numberOfValidators + numberOfCouncilMembers + numberOfStorageProviders + storageProviderLead + numberOfCurators + contentCuratorLead;
+
+  return {
+    totalIssuance,
+    currentlyStakedTokens,
+    totalWeeklySpending,
+    totalNumberOfActors,
+    validators: {
+      number: numberOfValidators,
+      nominators: {
+        number: numberOfNominators
+      },
+      rewardsPerWeek: validatorRewardsPerWeek,
+      rewardsShare: validatorRewardsPerWeek / totalWeeklySpending,
+      totalStake: totalValidatorStake,
+      stakeShare: totalValidatorStake / currentlyStakedTokens
+    },
+    council: {
+      number: numberOfCouncilMembers,
+      rewardsPerWeek: totalCouncilRewardsInOneWeek,
+      rewardsShare: totalCouncilRewardsInOneWeek / totalWeeklySpending,
+      totalStake: totalCouncilStake,
+      stakeShare: totalCouncilStake / currentlyStakedTokens
+    },
+    storageProviders: {
+      number: numberOfStorageProviders,
+      totalStake: totalProviderStake,
+      stakeShare: totalProviderStake / currentlyStakedTokens,
+      rewardsPerWeek: providerRewardsPerWeek,
+      rewardsShare: providerRewardsPerWeek / totalWeeklySpending,
+      lead: {
+        number: storageProviderLead,
+        totalStake: leadStake,
+        stakeShare: leadStake / currentlyStakedTokens,
+        rewardsPerWeek: leadRewardsPerWeek,
+        rewardsShare: leadRewardsPerWeek / totalWeeklySpending
+      }
+    },
+    contentCurators: {
+      number: numberOfCurators,
+      contentCuratorLead,
+      rewardsPerWeek: curatorRewardsPerWeeek,
+      rewardsShare: curatorRewardsPerWeeek / totalWeeklySpending,
+      totalStake: totalContentCuratorStake,
+      stakeShare: totalContentCuratorStake / currentlyStakedTokens
+    }
+  };
+};

+ 51 - 0
pioneer/packages/app-tokenomics/src/lib/getValidatorData.ts

@@ -0,0 +1,51 @@
+import { ApiPromise } from '@polkadot/api';
+import { Vec } from '@polkadot/types';
+import { AccountId, IndividualExposure } from '@polkadot/types/interfaces';
+
+const getValidators = async (api: ApiPromise): Promise<any> => {
+  let [totalValidatorStake, slotStake, numberOfNominators, numberOfValidators] = [0, 0, 0, 0];
+  const validatorIds = await api.query.staking.currentElected() as Vec<AccountId>;
+  await Promise.all(validatorIds.map(async (id: AccountId, index: number) => {
+    const nominators = (await api.derive.staking.info(id)).stakers?.others as Vec<IndividualExposure>;
+    const totalStake = (await api.derive.staking.info(id)).stakers?.total.toNumber() as number;
+    numberOfValidators += 1;
+    totalValidatorStake += totalStake;
+    numberOfNominators += nominators.length;
+    if (index === 0) { slotStake = totalStake; }
+    if (slotStake > totalStake) { slotStake = totalStake; }
+  }));
+  return {
+    numberOfValidators,
+    totalValidatorStake,
+    effectiveStake: slotStake * validatorIds.length,
+    numberOfNominators
+  };
+};
+
+const calculateRewards = (totalIssuance: number, effectiveStake: number): any => {
+  let validatorRewards = 0;
+  const [idealStakingRate, minimumInflation, maximumInflation, fallOff, eraLength, year] = [0.3, 0.025, 0.3, 0.05, 3600, (365.2425 * 24 * 60 * 60)];
+  const stakingRate = effectiveStake / totalIssuance;
+  if (stakingRate > 0.3) {
+    validatorRewards = totalIssuance * (minimumInflation + (maximumInflation - minimumInflation) * 2 ** ((idealStakingRate - stakingRate) / fallOff)) * eraLength / year;
+  } else if (stakingRate === 0.3) {
+    validatorRewards = (totalIssuance * maximumInflation * eraLength) / year;
+  } else {
+    validatorRewards = (totalIssuance * minimumInflation + totalIssuance * (maximumInflation - minimumInflation) * (stakingRate / idealStakingRate)) * eraLength / year;
+  }
+  return {
+    validatorRewardsPerEra: validatorRewards
+  };
+};
+
+export default async (api: ApiPromise, totalIssuance: number): Promise<any> => {
+  const { numberOfValidators, totalValidatorStake, effectiveStake, numberOfNominators } = await getValidators(api);
+  const { validatorRewardsPerEra } = await calculateRewards(totalIssuance, effectiveStake);
+
+  return {
+    numberOfValidators,
+    numberOfNominators,
+    validatorRewardsPerWeek: validatorRewardsPerEra * 168,
+    totalValidatorStake
+  };
+};

+ 7 - 0
pioneer/packages/app-tokenomics/src/translate.ts

@@ -0,0 +1,7 @@
+// Copyright 2017-2019 @polkadot/app-123code authors & contributors
+// This software may be modified and distributed under the terms
+// of the Apache-2.0 license. See the LICENSE file for details.
+
+import { withTranslation } from 'react-i18next';
+
+export default withTranslation(['app-123code']);

+ 24 - 0
pioneer/packages/apps-routing/src/tokenomics.ts

@@ -0,0 +1,24 @@
+// Copyright 2017-2019 @polkadot/apps-routing authors & contributors
+// This software may be modified and distributed under the terms
+// of the Apache-2.0 license. See the LICENSE file for details.
+
+import { Routes } from './types';
+
+import Tokenomics from '@polkadot/app-tokenomics/';
+
+export default ([
+  {
+    Component: Tokenomics,
+    display: {
+      needsAccounts: true,
+      needsApi: [
+        'tx.balances.transfer'
+      ]
+    },
+    i18n: {
+      defaultValue: 'Overview'
+    },
+    icon: 'th',
+    name: 'tokenomics'
+  }
+] as Routes);

+ 3 - 1
pioneer/tsconfig.json

@@ -88,7 +88,9 @@
       "@polkadot/react-query": [ "packages/react-query/src" ],
       "@polkadot/react-query/*": [ "packages/react-query/src/*" ],
       "@polkadot/react-signer": [ "packages/react-signer/src" ],
-      "@polkadot/react-signer/*": [ "packages/react-signer/src/*" ]
+      "@polkadot/react-signer/*": [ "packages/react-signer/src/*" ],
+      "@polkadot/app-tokenomics": [ "packages/app-tokenomics/src" ],
+      "@polkadot/app-tokenomics/*": [ "packages/app-tokenomics/src/*" ]
     },
     "skipLibCheck": true,
     "typeRoots": [