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";
55import { z } from "zod" ;
66
77import { MAINNET_API_RPC } from "../../../../../config/server" ;
8+ import { tokensToString } from "../../../../../tokens" ;
89
910const querySchema = z . enum ( [ "totalSupply" , "circulatingSupply" ] ) ;
1011
1112export async function GET ( req : NextRequest ) {
1213 const isMainnet = req . nextUrl . searchParams . get ( "devnet" ) !== "true" ;
14+ const asDecimal = req . nextUrl . searchParams . get ( "as_decimal" ) === "true" ;
1315 const stakingClient = new PythStakingClient ( {
1416 connection : new Connection (
1517 isMainnet && MAINNET_API_RPC !== undefined
@@ -34,9 +36,13 @@ export async function GET(req: NextRequest) {
3436
3537 if ( q === "circulatingSupply" ) {
3638 const circulatingSupply = await stakingClient . getCirculatingSupply ( ) ;
37- return Response . json ( Number ( circulatingSupply ) ) ;
39+ return Response . json (
40+ asDecimal ? tokensToString ( circulatingSupply ) : Number ( circulatingSupply ) ,
41+ ) ;
3842 } else {
3943 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+ ) ;
4147 }
4248}
You can’t perform that action at this time.
0 commit comments