diff --git a/apps/staking/src/app/api/v1/amount_staked_per_account/route.ts b/apps/staking/src/app/api/v1/amount_staked_per_account/route.ts deleted file mode 100644 index 359b02a8b6..0000000000 --- a/apps/staking/src/app/api/v1/amount_staked_per_account/route.ts +++ /dev/null @@ -1,53 +0,0 @@ -import type { PositionState } from "@pythnetwork/staking-sdk"; -import { - PythStakingClient, - summarizeAccountPositions, - getCurrentEpoch, -} from "@pythnetwork/staking-sdk"; -import { WalletAdapterNetwork } from "@solana/wallet-adapter-base"; -import { clusterApiUrl, Connection } from "@solana/web3.js"; - -import { - AMOUNT_STAKED_PER_ACCOUNT_SECRET, - MAINNET_API_RPC, -} from "../../../../config/server"; - -export const maxDuration = 800; - -export const GET = async (req: Request) => { - if ( - AMOUNT_STAKED_PER_ACCOUNT_SECRET === undefined || - req.headers.get("authorization") === - `Bearer ${AMOUNT_STAKED_PER_ACCOUNT_SECRET}` - ) { - const [accounts, epoch] = await Promise.all([ - client.getAllStakeAccountPositionsAllOwners(), - getCurrentEpoch(client.connection), - ]); - return Response.json( - accounts.map((account) => { - const summary = summarizeAccountPositions(account, epoch); - return [ - account.data.owner, - { - voting: stringifySummaryValues(summary.voting), - integrityPool: stringifySummaryValues(summary.integrityPool), - }, - ]; - }), - ); - } else { - return new Response("Unauthorized", { status: 400 }); - } -}; - -const stringifySummaryValues = (values: Record) => - Object.fromEntries( - Object.entries(values).map(([state, value]) => [state, value.toString()]), - ); - -const client = new PythStakingClient({ - connection: new Connection( - MAINNET_API_RPC ?? clusterApiUrl(WalletAdapterNetwork.Mainnet), - ), -}); diff --git a/apps/staking/src/config/server.ts b/apps/staking/src/config/server.ts index 3c18e6e7fb..6e828646e8 100644 --- a/apps/staking/src/config/server.ts +++ b/apps/staking/src/config/server.ts @@ -80,9 +80,6 @@ export const SIMULATION_PAYER_ADDRESS = getOr( "SIMULATION_PAYER_ADDRESS", "E5KR7yfb9UyVB6ZhmhQki1rM1eBcxHvyGKFZakAC5uc", ); -export const AMOUNT_STAKED_PER_ACCOUNT_SECRET = demandInProduction( - "AMOUNT_STAKED_PER_ACCOUNT_SECRET", -); class MissingEnvironmentError extends Error { constructor(name: string) { diff --git a/apps/staking/turbo.json b/apps/staking/turbo.json index efbc34fc13..a01af66192 100644 --- a/apps/staking/turbo.json +++ b/apps/staking/turbo.json @@ -12,8 +12,7 @@ "MAINNET_API_RPC", "BLOCKED_REGIONS", "AMPLITUDE_API_KEY", - "GOOGLE_ANALYTICS_ID", - "AMOUNT_STAKED_PER_ACCOUNT_SECRET" + "GOOGLE_ANALYTICS_ID" ] }, "start:dev": {