@@ -18,7 +18,7 @@ window.onload = () => {
1818 connectgaps : true ,
1919 line : {
2020 color : '#5C8DFF'
21- }
21+ }
2222 }
2323
2424 const difference = {
@@ -29,7 +29,7 @@ window.onload = () => {
2929 connectgaps : true ,
3030 line : {
3131 color : '#1EC198'
32- }
32+ }
3333 }
3434
3535 const relativeDifference = {
@@ -40,13 +40,18 @@ window.onload = () => {
4040 connectgaps : true ,
4141 line : {
4242 color : '#1EC198'
43- }
43+ }
4444 }
4545
4646 const lovelaceToAda = ( lovelace ) => {
4747 return Math . round ( lovelace / 1000000 ) ;
4848 }
4949
50+ const formatAda = ( ada ) => {
51+ const amount = ada . toLocaleString ( ) ;
52+ return `${ amount === '-0' ? '0' : amount } ₳` ;
53+ }
54+
5055 const treasuryCalculationTable = document . getElementById ( 'treasury-calculation-table' ) ;
5156
5257 for ( const epoch of Object . keys ( treasuryCalculationResult ) ) {
@@ -61,7 +66,7 @@ window.onload = () => {
6166
6267 relativeDifference . x . push ( epoch ) ;
6368 relativeDifference . y . push (
64- Math . round (
69+ epoch === "208" ? 0 : Math . round (
6570 ( Math . abs ( treasuryCalculationResult [ epoch ] . actualTreasury - treasuryCalculationResult [ epoch ] . calculatedTreasury ) /
6671 Math . abs ( ( treasuryCalculationResult [ epoch ] . actualTreasury + treasuryCalculationResult [ epoch ] . calculatedTreasury ) / 2 ) * 100 ) * 1000 ) / 1000
6772 ) ;
@@ -70,10 +75,10 @@ window.onload = () => {
7075 const row = document . createElement ( 'tr' ) ;
7176 row . innerHTML = `
7277 <td>${ epoch } </td>
73- <td>${ lovelaceToAda ( treasuryCalculationResult [ epoch ] . actualTreasury ) } ₳ </td>
74- <td>${ lovelaceToAda ( treasuryCalculationResult [ epoch ] . calculatedTreasury ) } ₳ </td>
75- <td>${ differenceAbsolut } ₳ </td>
76- <td>${ Math . round (
78+ <td>${ formatAda ( lovelaceToAda ( treasuryCalculationResult [ epoch ] . actualTreasury ) ) } </td>
79+ <td>${ formatAda ( lovelaceToAda ( treasuryCalculationResult [ epoch ] . calculatedTreasury ) ) } </td>
80+ <td>${ formatAda ( differenceAbsolut ) } </td>
81+ <td>${ epoch === "208" ? 0 : Math . round (
7782 ( Math . abs ( treasuryCalculationResult [ epoch ] . actualTreasury - treasuryCalculationResult [ epoch ] . calculatedTreasury ) /
7883 Math . abs ( ( treasuryCalculationResult [ epoch ] . actualTreasury + treasuryCalculationResult [ epoch ] . calculatedTreasury ) / 2 ) * 100 ) * 1000 ) / 1000
7984 } %</td>
@@ -87,6 +92,45 @@ window.onload = () => {
8792 treasuryCalculationTable . appendChild ( row ) ;
8893 }
8994
95+ const treasuryDevelopmentTable = document . getElementById ( 'treasury-development-table' ) ;
96+
97+ let totalAdaAddedToTreasury = 0.0 ;
98+ let totalAdaWithdrawledFromTreasury = 0.0 ;
99+ let totalAdaAddedOnTopOfTreasuryCut = 0.0 ;
100+
101+ for ( const epoch of Object . keys ( treasuryCalculationResult ) ) {
102+ const currentEpochTreasury = treasuryCalculationResult [ epoch ] . actualTreasury ;
103+ const previousEpochTreasury = treasuryCalculationResult [ epoch - 1 ] ?. actualTreasury ;
104+
105+ if ( previousEpochTreasury === undefined ) {
106+ continue ;
107+ }
108+
109+ const totalRewardPot = treasuryCalculationResult [ epoch ] . totalRewardPot ;
110+ const treasuryWithdrawals = treasuryCalculationResult [ epoch ] . treasuryWithdrawals ;
111+ totalAdaWithdrawledFromTreasury += treasuryWithdrawals ;
112+ const adaAddedToTreasury = ( currentEpochTreasury + treasuryWithdrawals ) - previousEpochTreasury ;
113+ totalAdaAddedToTreasury += adaAddedToTreasury ;
114+ const percentageAddedToTreasury = Math . round ( adaAddedToTreasury / totalRewardPot * 100 * 1000 ) / 1000 ;
115+
116+ const tauParameter = 0.2 ;
117+ const treasuryCut = tauParameter * totalRewardPot ;
118+ const adaAddedOnTopOfTreasuryCut = adaAddedToTreasury - treasuryCut ;
119+ totalAdaAddedOnTopOfTreasuryCut += adaAddedOnTopOfTreasuryCut ;
120+
121+ const row = document . createElement ( 'tr' ) ;
122+ row . innerHTML = `
123+ <td>${ epoch } </td>
124+ <td>${ formatAda ( lovelaceToAda ( adaAddedToTreasury ) ) } </td>
125+ <td>${ formatAda ( lovelaceToAda ( totalRewardPot ) ) } </td>
126+ <td>${ percentageAddedToTreasury } %</td>
127+ <td>${ formatAda ( lovelaceToAda ( adaAddedOnTopOfTreasuryCut ) ) } </td>
128+ <td>${ formatAda ( lovelaceToAda ( treasuryWithdrawals ) ) } </td>
129+ ` ;
130+
131+ treasuryDevelopmentTable . appendChild ( row ) ;
132+ }
133+
90134 const layoutAda = {
91135 title : 'Treasury Calculation & Actual Values' ,
92136 showlegend : false ,
@@ -100,7 +144,7 @@ window.onload = () => {
100144 showline : false
101145 }
102146 } ;
103-
147+
104148 const layoutAdaDifference = {
105149 title : 'Treasury Calculation - Difference in ADA' ,
106150 showlegend : false ,
@@ -134,7 +178,7 @@ window.onload = () => {
134178 Plotly . newPlot ( 'difference-percentage-plot' , [ relativeDifference ] , layoutPercentage ) ;
135179
136180 const epochInfo = document . getElementById ( 'epoch-info' ) ;
137- const epochs = Object . keys ( treasuryCalculationResult ) . map ( ( epoch ) => Number ( epoch ) ) ;
181+ const epochs = Object . keys ( treasuryCalculationResult ) . map ( ( epoch ) => Number ( epoch ) ) ;
138182 const epochStart = Math . min ( ...epochs ) ;
139183 const epochEnd = Math . max ( ...epochs ) ;
140184 epochInfo . innerHTML = `Epoch ${ epochStart } - ${ epochEnd } ` ;
@@ -156,13 +200,13 @@ window.onload = () => {
156200
157201 const highestAbsolutDifference = Math . max ( ...difference . y ) ;
158202 const highestAbsolutDifferenceEpoch = difference . x [ difference . y . indexOf ( highestAbsolutDifference ) ] ;
159- fillCard ( 'highest-absolut-difference' , 'Highest absolut difference' , `${ highestAbsolutDifference } ₳` , `Epoch ${ highestAbsolutDifferenceEpoch } ` ) ;
203+ fillCard ( 'highest-absolut-difference' , 'Highest absolut difference' , `${ highestAbsolutDifference . toLocaleString ( ) } ₳` , `Epoch ${ highestAbsolutDifferenceEpoch } ` ) ;
160204
161205 const averageDifferenceMedian = relativeDifference . y . sort ( ( a , b ) => a - b ) [ Math . round ( relativeDifference . y . length / 2 ) ] ;
162206 fillCard ( 'average-difference-percentage' , 'Average relative difference' , `${ averageDifferenceMedian } %` , 'Median' ) ;
163207
164208 const averageAbsolutDifferenceMedian = difference . y . sort ( ( a , b ) => a - b ) [ Math . round ( difference . y . length / 2 ) ]
165- fillCard ( 'average-absolut-difference' , 'Average absolut difference' , `${ averageAbsolutDifferenceMedian } ₳` , 'Median' ) ;
209+ fillCard ( 'average-absolut-difference' , 'Average absolut difference' , `${ averageAbsolutDifferenceMedian . toLocaleString ( ) } ₳` , 'Median' ) ;
166210
167211 const absolutDifferences = difference . y . map ( ( difference ) => Math . abs ( difference ) ) ;
168212
@@ -175,4 +219,8 @@ window.onload = () => {
175219 fillCard ( 'difference-5k-10k-ADA' , 'Difference between 5k₳ and 10k₳' , `${ absolutDifferences . filter ( ( difference ) => difference >= 5000 && difference < 10000 ) . length } ` , '' ) ;
176220 fillCard ( 'difference-10k-50k-ADA' , 'Difference between 10k₳ and 50k₳' , `${ absolutDifferences . filter ( ( difference ) => difference >= 10000 && difference < 50000 ) . length } ` , '' ) ;
177221 fillCard ( 'difference-above-50k-ADA' , 'Difference above 50k₳' , `${ absolutDifferences . filter ( ( difference ) => difference >= 50000 ) . length } ` , '' ) ;
222+
223+ fillCard ( 'ada-added-to-treasury' , 'Total ADA added to treasury' , `${ formatAda ( lovelaceToAda ( totalAdaAddedToTreasury ) ) } ` , '' ) ;
224+ fillCard ( 'ada-withdrawled-from-treasury' , 'Total ADA withdrawled from treasury' , `${ formatAda ( lovelaceToAda ( totalAdaWithdrawledFromTreasury ) ) } ` , '' ) ;
225+ fillCard ( 'total-ada-added-on-top-of-treasury-cut' , 'Total ADA added on top of treasury cut' , `${ formatAda ( lovelaceToAda ( totalAdaAddedOnTopOfTreasuryCut ) ) } ` , '' ) ;
178226} ;
0 commit comments