File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
apps/staking/src/app/api/v1/cmc/supply Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,13 @@ import type { NextRequest } from "next/server";
5
5
import { z } from "zod" ;
6
6
7
7
import { MAINNET_API_RPC } from "../../../../../config/server" ;
8
+ import { tokensToString } from "../../../../../tokens" ;
8
9
9
10
const querySchema = z . enum ( [ "totalSupply" , "circulatingSupply" ] ) ;
10
11
11
12
export async function GET ( req : NextRequest ) {
12
13
const isMainnet = req . nextUrl . searchParams . get ( "devnet" ) !== "true" ;
14
+ const asDecimal = req . nextUrl . searchParams . get ( "as_decimal" ) === "true" ;
13
15
const stakingClient = new PythStakingClient ( {
14
16
connection : new Connection (
15
17
isMainnet && MAINNET_API_RPC !== undefined
@@ -34,9 +36,13 @@ export async function GET(req: NextRequest) {
34
36
35
37
if ( q === "circulatingSupply" ) {
36
38
const circulatingSupply = await stakingClient . getCirculatingSupply ( ) ;
37
- return Response . json ( Number ( circulatingSupply ) ) ;
39
+ return Response . json (
40
+ asDecimal ? tokensToString ( circulatingSupply ) : Number ( circulatingSupply ) ,
41
+ ) ;
38
42
} else {
39
43
const pythMint = await stakingClient . getPythTokenMint ( ) ;
40
- return Response . json ( Number ( pythMint . supply ) ) ;
44
+ return Response . json (
45
+ asDecimal ? tokensToString ( pythMint . supply ) : Number ( pythMint . supply ) ,
46
+ ) ;
41
47
}
42
48
}
You can’t perform that action at this time.
0 commit comments