소스 검색

Fix divideColumnsAt error, fix weekly top-ups to correctly display data, change council rewards based on the new 2-week format

Edvin 4 년 전
부모
커밋
05e035ba78

+ 1 - 1
pioneer/packages/joy-tokenomics/src/Overview/OverviewTable.tsx

@@ -93,7 +93,7 @@ const OverviewTable: React.FC<{data?: TokenomicsData; statusData?: StatusServerD
         />
         <OverviewTableRow
           item='Weekly Top Ups'
-          value={displayStatusData(statusData?.dollarPool.replenishAmount.toFixed(2) || '', 'USD')}
+          value={displayStatusData((Number(statusData?.dollarPool.replenishAmount) / 2).toFixed(2) || '', 'USD')}
           help={'The current weekly \'Fiat Pool\' replenishment amount. Does not include KPIs, or other potential top ups.'}
         />
       </Table.Body>

+ 2 - 2
pioneer/packages/joy-tokenomics/src/Overview/SpendingAndStakeDistributionTable.tsx

@@ -21,7 +21,7 @@ const applyCss = (columns: number[]): string => {
   return columnString;
 };
 
-const StyledTable = styled(Table)`
+const StyledTable = styled(({ divideColumnsAt, ...rest }) => <Table {...rest} />)`
   border: none !important;
   width: 70% !important;
   margin-bottom:1.5rem;
@@ -31,7 +31,7 @@ const StyledTable = styled(Table)`
   & tr {
     td:nth-of-type(1),
     th:nth-of-type(1),
-    ${(props): string => applyCss(props.divideColumnsAt)} {
+    ${(props: { divideColumnsAt: number[]}): string => applyCss(props.divideColumnsAt)} {
       border-left: 0.12rem solid rgba(20,20,20,0.3) !important;
     }
     td:nth-of-type(1){

+ 20 - 20
pioneer/packages/joy-utils/src/transport/tokenomics.ts

@@ -44,8 +44,8 @@ export default class TokenomicsTransport extends BaseTransport {
   }
 
   async calculateCouncilRewards (numberOfCouncilMembers: number) {
-    let weekInBlocks = 100800;
-    let councilRewardsInOneWeek = 0;
+    let twoWeeksInBlocks = 201600;
+    let councilRewardsInTwoWeeks = 0;
     let totalCouncilRewardsPerBlock = 0;
     const payoutInterval = Number((await this.api.query.council.payoutInterval() as Option<BlockNumber>).unwrapOr(0));
     const amountPerPayout = (await this.api.query.council.amountPerPayout() as BalanceOf).toNumber();
@@ -59,48 +59,48 @@ export default class TokenomicsTransport extends BaseTransport {
     const revealingPeriod = revealing_period.toNumber();
     const announcingPeriod = announcing_period.toNumber();
 
-    while (weekInBlocks > 0) {
-      if (weekInBlocks > termDuration) {
-        councilRewardsInOneWeek += termDuration * totalCouncilRewardsPerBlock;
-        weekInBlocks -= termDuration;
+    while (twoWeeksInBlocks > 0) {
+      if (twoWeeksInBlocks > termDuration) {
+        councilRewardsInTwoWeeks += termDuration * totalCouncilRewardsPerBlock;
+        twoWeeksInBlocks -= termDuration;
       } else {
-        councilRewardsInOneWeek += weekInBlocks * totalCouncilRewardsPerBlock;
+        councilRewardsInTwoWeeks += twoWeeksInBlocks * totalCouncilRewardsPerBlock;
 
-        return councilRewardsInOneWeek;
+        return councilRewardsInTwoWeeks;
       }
 
       // -----------------------------
-      if (weekInBlocks > revealingPeriod) {
-        weekInBlocks -= revealingPeriod;
+      if (twoWeeksInBlocks > revealingPeriod) {
+        twoWeeksInBlocks -= revealingPeriod;
       } else {
-        return councilRewardsInOneWeek;
+        return councilRewardsInTwoWeeks;
       }
 
       // -----------------------------
-      if (weekInBlocks > votingPeriod) {
-        weekInBlocks -= votingPeriod;
+      if (twoWeeksInBlocks > votingPeriod) {
+        twoWeeksInBlocks -= votingPeriod;
       } else {
-        return councilRewardsInOneWeek;
+        return councilRewardsInTwoWeeks;
       }
 
       // -----------------------------
-      if (weekInBlocks > announcingPeriod) {
-        weekInBlocks -= announcingPeriod;
+      if (twoWeeksInBlocks > announcingPeriod) {
+        twoWeeksInBlocks -= announcingPeriod;
       } else {
-        return councilRewardsInOneWeek;
+        return councilRewardsInTwoWeeks;
       }
     }
 
-    return councilRewardsInOneWeek;
+    return councilRewardsInTwoWeeks;
   }
 
   async getCouncilData () {
     const { numberOfCouncilMembers, totalCouncilStake } = await this.getCouncilMembers();
-    const totalCouncilRewardsInOneWeek = await this.calculateCouncilRewards(numberOfCouncilMembers);
+    const councilRewardsInTwoWeeks = await this.calculateCouncilRewards(numberOfCouncilMembers);
 
     return {
       numberOfCouncilMembers,
-      totalCouncilRewardsInOneWeek,
+      totalCouncilRewardsInOneWeek: councilRewardsInTwoWeeks / 2,
       totalCouncilStake
     };
   }