Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ components:
dailyRatePercent:
type: number
description: Daily funding rate as percentage
netLpPosition:
netLpPos:
type: string
description: Net LP position (inventory imbalance)

Expand All @@ -902,7 +902,7 @@ components:
type: number
annualizedPercent:
type: number
netLpPosition:
netLpPos:
type: string
last24hHistory:
type: array
Expand Down
10 changes: 5 additions & 5 deletions src/routes/funding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function fundingRoutes(): Hono {
// GH#1459: Filter blocked slabs from the global response.
// validateSlab middleware only runs on /:slab routes; the global endpoint
// queries all market_stats rows and previously exposed blocked slabs
// (8eFFEFBY, 3bmCyPee, 3YDqCJGz, 3ZKKwsK) with phantom netLpPosition values.
// (8eFFEFBY, 3bmCyPee, 3YDqCJGz, 3ZKKwsK) with phantom netLpPos values.
const markets = (allStats ?? [])
.filter((stats) => !isBlockedSlab(stats.slab_address))
.map((stats) => {
Expand All @@ -79,7 +79,7 @@ export function fundingRoutes(): Hono {
currentRateBpsPerSlot: rateBps,
hourlyRatePercent: Number(((rateBps / 10000.0) * SLOTS_PER_HOUR).toFixed(6)),
dailyRatePercent: Number(((rateBps / 10000.0) * SLOTS_PER_DAY).toFixed(4)),
netLpPosition: stats.net_lp_pos ?? "0",
netLpPos: stats.net_lp_pos ?? "0",
};
});

Expand All @@ -105,7 +105,7 @@ export function fundingRoutes(): Hono {
* "hourlyRatePercent": 0.42,
* "dailyRatePercent": 10.08,
* "annualizedPercent": 3679.2,
* "netLpPosition": "1500000",
* "netLpPos": "1500000",
* "fundingIndexQpbE6": "123456789",
* "lastUpdatedSlot": 123456789,
* "last24hHistory": [
Expand Down Expand Up @@ -140,7 +140,7 @@ export function fundingRoutes(): Hono {

// Parse current funding data
const currentRateBpsPerSlot = stats.funding_rate ?? 0;
const netLpPosition = stats.net_lp_pos ?? "0";
const netLpPos = stats.net_lp_pos ?? "0";

// Calculate rates
// Solana slots: ~2.5 slots/second = 400ms per slot
Expand Down Expand Up @@ -189,7 +189,7 @@ export function fundingRoutes(): Hono {
hourlyRatePercent: Number(hourlyRatePercent.toFixed(6)),
dailyRatePercent: Number(dailyRatePercent.toFixed(4)),
annualizedPercent: Number(annualizedPercent.toFixed(2)),
netLpPosition,
netLpPos,
last24hHistory,
metadata: {
// GH#1511: Populate symbol and last_price from markets_with_stats.
Expand Down
2 changes: 1 addition & 1 deletion tests/routes/funding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe("funding routes", () => {
const data = await res.json();
expect(data.slabAddress).toBe("11111111111111111111111111111111");
expect(data.currentRateBpsPerSlot).toBe(10);
expect(data.netLpPosition).toBe("1000000");
expect(data.netLpPos).toBe("1000000");
expect(data.last24hHistory).toHaveLength(1);
});

Expand Down
Loading