1
1
import BigNumber from 'bignumber.js' ;
2
- import { microStxToStx , STACKS_DECIMAL_PLACES , TOTAL_STACKS } from '../../helpers' ;
2
+ import { microStxToStx , STACKS_DECIMAL_PLACES , TOTAL_STACKS_YEAR_2050 } from '../../helpers' ;
3
3
import { handleChainTipCache } from '../controllers/cache-controller' ;
4
4
5
5
import { FastifyPluginAsync } from 'fastify' ;
@@ -23,18 +23,23 @@ export const StxSupplyRoutes: FastifyPluginAsync<
23
23
) : Promise < {
24
24
unlockedPercent : string ;
25
25
totalStx : string ;
26
+ totalStxYear2050 : string ;
26
27
unlockedStx : string ;
27
28
blockHeight : number ;
28
29
} > {
29
30
const { stx : unlockedSupply , blockHeight } = await fastify . db . getUnlockedStxSupply ( args ) ;
30
- const totalMicroStx = new BigNumber ( TOTAL_STACKS ) . shiftedBy ( STACKS_DECIMAL_PLACES ) ;
31
+ const totalMicroStx = unlockedSupply ;
32
+ const totalMicroStxYear2050 = new BigNumber ( TOTAL_STACKS_YEAR_2050 ) . shiftedBy (
33
+ STACKS_DECIMAL_PLACES
34
+ ) ;
31
35
const unlockedPercent = new BigNumber ( unlockedSupply . toString ( ) )
32
- . div ( totalMicroStx )
36
+ . div ( new BigNumber ( totalMicroStx . toString ( ) ) )
33
37
. times ( 100 )
34
38
. toFixed ( 2 ) ;
35
39
return {
36
40
unlockedPercent,
37
41
totalStx : microStxToStx ( totalMicroStx ) ,
42
+ totalStxYear2050 : microStxToStx ( totalMicroStxYear2050 ) ,
38
43
unlockedStx : microStxToStx ( unlockedSupply ) ,
39
44
blockHeight : blockHeight ,
40
45
} ;
@@ -47,8 +52,7 @@ export const StxSupplyRoutes: FastifyPluginAsync<
47
52
schema : {
48
53
operationId : 'get_stx_supply' ,
49
54
summary : 'Get total and unlocked STX supply' ,
50
- description : `Retrieves the total and unlocked STX supply. More information on Stacking can be found [here] (https://docs.stacks.co/understand-stacks/stacking).
51
- **Note:** This uses the estimated future total supply for the year 2050.` ,
55
+ description : `Retrieves the total and unlocked STX supply. More information on Stacking can be found [here] (https://docs.stacks.co/understand-stacks/stacking).` ,
52
56
tags : [ 'Info' ] ,
53
57
querystring : Type . Object ( {
54
58
height : Type . Optional (
@@ -70,7 +74,11 @@ export const StxSupplyRoutes: FastifyPluginAsync<
70
74
'String quoted decimal number of the percentage of STX that have unlocked' ,
71
75
} ) ,
72
76
total_stx : Type . String ( {
73
- description : 'String quoted decimal number of the total possible number of STX' ,
77
+ description : 'String quoted decimal number of the total circulating number of STX' ,
78
+ } ) ,
79
+ total_stx_year_2050 : Type . String ( {
80
+ description :
81
+ 'The Stacks cryptocurrency has a predefined future supply that reaches approx 1,818M STX by year 2050' ,
74
82
} ) ,
75
83
unlocked_stx : Type . String ( {
76
84
description :
@@ -98,6 +106,7 @@ export const StxSupplyRoutes: FastifyPluginAsync<
98
106
await reply . send ( {
99
107
unlocked_percent : supply . unlockedPercent ,
100
108
total_stx : supply . totalStx ,
109
+ total_stx_year_2050 : supply . totalStxYear2050 ,
101
110
unlocked_stx : supply . unlockedStx ,
102
111
block_height : supply . blockHeight ,
103
112
} ) ;
@@ -111,8 +120,7 @@ export const StxSupplyRoutes: FastifyPluginAsync<
111
120
schema : {
112
121
operationId : 'get_stx_supply_total_supply_plain' ,
113
122
summary : 'Get total STX supply in plain text format' ,
114
- description : `Retrieves the total supply for STX tokens as plain text.
115
- **Note:** this uses the estimated future total supply for the year 2050.` ,
123
+ description : `Retrieves the total circulating STX token supply as plain text.` ,
116
124
tags : [ 'Info' ] ,
117
125
response : {
118
126
200 : {
@@ -165,8 +173,7 @@ export const StxSupplyRoutes: FastifyPluginAsync<
165
173
operationId : 'get_total_stx_supply_legacy_format' ,
166
174
summary :
167
175
'Get total and unlocked STX supply (results formatted the same as the legacy 1.0 API)' ,
168
- description : `Retrieves total supply of STX tokens including those currently in circulation that have been unlocked.
169
- **Note:** this uses the estimated future total supply for the year 2050.` ,
176
+ description : `Retrieves total supply of STX tokens including those currently in circulation that have been unlocked.` ,
170
177
tags : [ 'Info' ] ,
171
178
querystring : Type . Object ( {
172
179
height : Type . Optional (
@@ -188,11 +195,19 @@ export const StxSupplyRoutes: FastifyPluginAsync<
188
195
'String quoted decimal number of the percentage of STX that have unlocked' ,
189
196
} ) ,
190
197
totalStacks : Type . String ( {
191
- description : 'String quoted decimal number of the total possible number of STX' ,
198
+ description : 'String quoted decimal number of the total circulating number of STX' ,
192
199
} ) ,
193
200
totalStacksFormatted : Type . String ( {
194
201
description : 'Same as `totalStacks` but formatted with comma thousands separators' ,
195
202
} ) ,
203
+ totalStacksYear2050 : Type . String ( {
204
+ description :
205
+ 'The Stacks cryptocurrency has a predefined future supply that reaches approx 1,818M STX by year 2050' ,
206
+ } ) ,
207
+ totalStacksYear2050Formatted : Type . String ( {
208
+ description :
209
+ 'Same as `totalStacksYear2050` but formatted with comma thousands separators' ,
210
+ } ) ,
196
211
unlockedSupply : Type . String ( {
197
212
description :
198
213
'String quoted decimal number of the STX that have been mined or unlocked' ,
@@ -224,6 +239,11 @@ export const StxSupplyRoutes: FastifyPluginAsync<
224
239
unlockedPercent : supply . unlockedPercent ,
225
240
totalStacks : supply . totalStx ,
226
241
totalStacksFormatted : new BigNumber ( supply . totalStx ) . toFormat ( STACKS_DECIMAL_PLACES , 8 ) ,
242
+ totalStacksYear2050 : supply . totalStxYear2050 ,
243
+ totalStacksYear2050Formatted : new BigNumber ( supply . totalStxYear2050 ) . toFormat (
244
+ STACKS_DECIMAL_PLACES ,
245
+ 8
246
+ ) ,
227
247
unlockedSupply : supply . unlockedStx ,
228
248
unlockedSupplyFormatted : new BigNumber ( supply . unlockedStx ) . toFormat (
229
249
STACKS_DECIMAL_PLACES ,
0 commit comments