From 6c0a2bfb30a692b7b88890937e57f0a73caa8004 Mon Sep 17 00:00:00 2001 From: Polly Labs Date: Mon, 13 Jul 2026 15:02:10 -0500 Subject: [PATCH] fix(web): parse pool total shares --- apps/web/lib/api.test.ts | 2 ++ apps/web/lib/transformers.test.ts | 19 +++++++++++++++++++ apps/web/lib/transformers.ts | 5 +++-- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 apps/web/lib/transformers.test.ts diff --git a/apps/web/lib/api.test.ts b/apps/web/lib/api.test.ts index 5452a29..a4ab28f 100644 --- a/apps/web/lib/api.test.ts +++ b/apps/web/lib/api.test.ts @@ -187,6 +187,7 @@ describe("parseRawPoolStats", () => { utilization_rate_bps: 5000, total_yield_distributed: "10000000000", active_invoice_count: 10, + total_shares: "250000000000", }; const result = parseRawPoolStats(raw); @@ -196,6 +197,7 @@ describe("parseRawPoolStats", () => { expect(result.utilizationRateBps).toEqual(5000); expect(result.totalYieldDistributed).toEqual(BigInt("10000000000")); expect(result.activeInvoiceCount).toEqual(10); + expect(result.totalShares).toEqual(BigInt("250000000000")); }); }); diff --git a/apps/web/lib/transformers.test.ts b/apps/web/lib/transformers.test.ts new file mode 100644 index 0000000..1c8c177 --- /dev/null +++ b/apps/web/lib/transformers.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from "vitest"; + +import { parseRawPoolStats } from "./transformers"; + +describe("parseRawPoolStats", () => { + it("parses total shares from raw pool stats", () => { + const result = parseRawPoolStats({ + total_deposits: "1000000000000", + total_funded: "500000000000", + available_liquidity: "500000000000", + utilization_rate_bps: 5000, + total_yield_distributed: "10000000000", + active_invoice_count: 10, + total_shares: "250000000000", + }); + + expect(result.totalShares).toEqual(BigInt("250000000000")); + }); +}); diff --git a/apps/web/lib/transformers.ts b/apps/web/lib/transformers.ts index e2a60ce..0113b27 100644 --- a/apps/web/lib/transformers.ts +++ b/apps/web/lib/transformers.ts @@ -48,7 +48,7 @@ function parseRawInvoice(raw: any): Invoice { }); } -function parseRawPoolStats(raw: any): PoolStats { +export function parseRawPoolStats(raw: any): PoolStats { return { totalDeposits: BigInt(raw.total_deposits || 0), totalFunded: BigInt(raw.total_funded || 0), @@ -56,6 +56,7 @@ function parseRawPoolStats(raw: any): PoolStats { utilizationRateBps: Number(raw.utilization_rate_bps || 0), totalYieldDistributed: BigInt(raw.total_yield_distributed || 0), activeInvoiceCount: Number(raw.active_invoice_count || 0), + totalShares: BigInt(raw.total_shares || 0), }; } @@ -78,4 +79,4 @@ function parseRawEventLog(raw: any): EventLog { event_type: raw.event_type, data: raw.data || {}, }; -} \ No newline at end of file +}