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,12 @@ 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 :
78
+ 'String quoted decimal number of the total circulating number of STX (at the input block height if provided, otherwise the current block height)' ,
79
+ } ) ,
80
+ total_stx_year_2050 : Type . String ( {
81
+ description :
82
+ 'String quoted decimal number of total circulating STX supply in year 2050. STX supply grows approx 0.3% annually thereafter in perpetuity.' ,
74
83
} ) ,
75
84
unlocked_stx : Type . String ( {
76
85
description :
@@ -98,6 +107,7 @@ export const StxSupplyRoutes: FastifyPluginAsync<
98
107
await reply . send ( {
99
108
unlocked_percent : supply . unlockedPercent ,
100
109
total_stx : supply . totalStx ,
110
+ total_stx_year_2050 : supply . totalStxYear2050 ,
101
111
unlocked_stx : supply . unlockedStx ,
102
112
block_height : supply . blockHeight ,
103
113
} ) ;
@@ -109,10 +119,10 @@ export const StxSupplyRoutes: FastifyPluginAsync<
109
119
{
110
120
preHandler : handleChainTipCache ,
111
121
schema : {
122
+ deprecated : true ,
112
123
operationId : 'get_stx_supply_total_supply_plain' ,
113
124
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.` ,
125
+ description : `Retrieves the total circulating STX token supply as plain text.` ,
116
126
tags : [ 'Info' ] ,
117
127
response : {
118
128
200 : {
@@ -136,6 +146,7 @@ export const StxSupplyRoutes: FastifyPluginAsync<
136
146
{
137
147
preHandler : handleChainTipCache ,
138
148
schema : {
149
+ deprecated : true ,
139
150
operationId : 'get_stx_supply_circulating_plain' ,
140
151
summary : 'Get circulating STX supply in plain text format' ,
141
152
description : `Retrieves the STX tokens currently in circulation that have been unlocked as plain text.` ,
@@ -162,11 +173,11 @@ export const StxSupplyRoutes: FastifyPluginAsync<
162
173
{
163
174
preHandler : handleChainTipCache ,
164
175
schema : {
176
+ deprecated : true ,
165
177
operationId : 'get_total_stx_supply_legacy_format' ,
166
178
summary :
167
179
'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.` ,
180
+ description : `Retrieves total supply of STX tokens including those currently in circulation that have been unlocked.` ,
170
181
tags : [ 'Info' ] ,
171
182
querystring : Type . Object ( {
172
183
height : Type . Optional (
@@ -188,11 +199,20 @@ export const StxSupplyRoutes: FastifyPluginAsync<
188
199
'String quoted decimal number of the percentage of STX that have unlocked' ,
189
200
} ) ,
190
201
totalStacks : Type . String ( {
191
- description : 'String quoted decimal number of the total possible number of STX' ,
202
+ description :
203
+ 'String quoted decimal number of the total circulating number of STX (at the input block height if provided, otherwise the current block height)' ,
192
204
} ) ,
193
205
totalStacksFormatted : Type . String ( {
194
206
description : 'Same as `totalStacks` but formatted with comma thousands separators' ,
195
207
} ) ,
208
+ totalStacksYear2050 : Type . String ( {
209
+ description :
210
+ 'String quoted decimal number of total circulating STX supply in year 2050. STX supply grows approx 0.3% annually thereafter in perpetuity.' ,
211
+ } ) ,
212
+ totalStacksYear2050Formatted : Type . String ( {
213
+ description :
214
+ 'Same as `totalStacksYear2050` but formatted with comma thousands separators' ,
215
+ } ) ,
196
216
unlockedSupply : Type . String ( {
197
217
description :
198
218
'String quoted decimal number of the STX that have been mined or unlocked' ,
@@ -224,6 +244,11 @@ export const StxSupplyRoutes: FastifyPluginAsync<
224
244
unlockedPercent : supply . unlockedPercent ,
225
245
totalStacks : supply . totalStx ,
226
246
totalStacksFormatted : new BigNumber ( supply . totalStx ) . toFormat ( STACKS_DECIMAL_PLACES , 8 ) ,
247
+ totalStacksYear2050 : supply . totalStxYear2050 ,
248
+ totalStacksYear2050Formatted : new BigNumber ( supply . totalStxYear2050 ) . toFormat (
249
+ STACKS_DECIMAL_PLACES ,
250
+ 8
251
+ ) ,
227
252
unlockedSupply : supply . unlockedStx ,
228
253
unlockedSupplyFormatted : new BigNumber ( supply . unlockedStx ) . toFormat (
229
254
STACKS_DECIMAL_PLACES ,
0 commit comments