Skip to content

Commit

Permalink
fix(staking): use Pyth units in locked accounts api (#1974)
Browse files Browse the repository at this point in the history
* fix(staking): use Pyth units in locked accounts api

* fix
  • Loading branch information
keyvankhademi authored Sep 26, 2024
1 parent 4f983ee commit b6b5946
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/staking/src/app/api/v1/locked_accounts/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import type { NextRequest } from "next/server";
import { z } from "zod";

import { IS_MAINNET, RPC } from "../../../../config/server";
import { tokensToString } from "../../../../tokens";

const UnlockScheduleSchema = z.object({
date: z.date(),
amount: z.number(),
amount: z.string(),
});

const LockSchema = z.object({
Expand All @@ -19,7 +20,7 @@ const LockSchema = z.object({
const ResponseSchema = z.array(
z.object({
custodyAccount: z.string(),
actualAmount: z.number(),
actualAmount: z.string(),
lock: LockSchema,
}),
);
Expand Down Expand Up @@ -76,12 +77,12 @@ export async function GET(req: NextRequest) {
const lock = await stakingClient.getUnlockSchedule(position, true);
return {
custodyAccount: custodyAccount.address.toBase58(),
actualAmount: Number(custodyAccount.amount),
actualAmount: tokensToString(custodyAccount.amount),
lock: {
type: lock.type,
schedule: lock.schedule.map((unlock) => ({
date: unlock.date,
amount: Number(unlock.amount),
amount: tokensToString(unlock.amount),
})),
},
};
Expand Down

0 comments on commit b6b5946

Please sign in to comment.