Skip to content

Commit d58e576

Browse files
committed
feat: add price to bank output
1 parent 69c1d3c commit d58e576

File tree

6 files changed

+22
-0
lines changed

6 files changed

+22
-0
lines changed

src/app/api/search/arena/pools/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ export async function GET(request: Request) {
214214
totalAssetsUsd,
215215
totalLiabilitiesUsd,
216216
tvl,
217+
oraclePrice: oraclePrice.priceRealtime.price.toNumber(),
217218
config: {
218219
assetTag:
219220
bank.config.riskTier === RiskTier.Isolated

src/app/api/search/marginfi/banks/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export async function GET(request: Request) {
134134
totalAssetsUsd,
135135
totalLiabilitiesUsd,
136136
tvl,
137+
oraclePrice: oraclePrice.priceRealtime.price.toNumber(),
137138
config: {
138139
assetTag:
139140
bank.config.riskTier === RiskTier.Isolated

src/components/search-arena-pools.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,14 @@ const SearchArenaPools = ({ pools }: SearchArenaPoolsProps) => {
288288
</strong>
289289
<AddressActions address={bank.tokenAddress} />
290290
</li>
291+
<li className="grid w-full grid-cols-2 items-center">
292+
<strong className="font-medium text-muted-foreground">
293+
Oracle Price:
294+
</strong>
295+
<div className="text-right">
296+
{formatUsd(bank.oraclePrice)}
297+
</div>
298+
</li>
291299
{bank.config.oracleKeys.length > 0 && (
292300
<li className="grid w-full grid-cols-2 items-start">
293301
<strong className="font-medium text-muted-foreground">

src/components/search-banks.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@ const SearchBanks = ({ banks, stakedBanks }: SearchBanksProps) => {
255255
</strong>
256256
<AddressActions address={selectedBank.tokenAddress} />
257257
</li>
258+
<li className="grid w-full grid-cols-2 items-center">
259+
<strong className="font-medium text-muted-foreground">
260+
Oracle Price:
261+
</strong>
262+
<div className="text-right">
263+
{formatUsd(bankDetails.oraclePrice)}
264+
</div>
265+
</li>
258266
{bankDetails.config.oracleKeys.length > 0 && (
259267
<li className="grid w-full grid-cols-2 items-start">
260268
<strong className="font-medium text-muted-foreground">

src/lib/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type Bank = {
2828
totalAssetsUsd: number;
2929
totalLiabilitiesUsd: number;
3030
tvl: number;
31+
oraclePrice: number;
3132
config: {
3233
assetTag: "Isolated" | "Native Stake" | "Global";
3334
assetWeight: number;

src/lib/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export const formatNumber = (value: number) => {
2424
};
2525

2626
export const formatUsd = (value: number) => {
27+
if (value < 0.01) {
28+
return value.toFixed(8);
29+
}
2730
return new Intl.NumberFormat("en-US", {
2831
style: "currency",
2932
currency: "USD",

0 commit comments

Comments
 (0)