File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
apps/staking/src/app/api/v1/cmc/supply Expand file tree Collapse file tree 1 file changed +12
-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,17 @@ 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
41+ ? tokensToString ( circulatingSupply )
42+ : Number ( circulatingSupply )
43+ ) ;
3844 } else {
3945 const pythMint = await stakingClient . getPythTokenMint ( ) ;
40- return Response . json ( Number ( pythMint . supply ) ) ;
46+ return Response . json (
47+ asDecimal
48+ ? tokensToString ( pythMint . supply )
49+ : Number ( pythMint . supply )
50+ ) ;
4151 }
4252}
You can’t perform that action at this time.
0 commit comments