Skip to content

Commit 9cf5e9a

Browse files
Hiksangclaude
andcommitted
fix: HL getFundingPayments — direct API call instead of SDK
SDK's getUserFunding silently truncates to ~30 results, missing PURR and other symbols. Direct API returns all payments (103 vs 30). PURR funding: $0.0535 (was $0.0132 estimate, HL shows $0.07). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d613c73 commit 9cf5e9a

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/exchanges/hyperliquid.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -770,18 +770,21 @@ export class HyperliquidAdapter implements ExchangeAdapter {
770770
}));
771771
}
772772

773-
async getFundingPayments(limit = 30): Promise<ExchangeFundingPayment[]> {
773+
async getFundingPayments(limit = 200): Promise<ExchangeFundingPayment[]> {
774774
this.ensureAddress();
775-
const now = Date.now();
776-
const history = await this.client.info.perpetuals.getUserFunding(this._address, now - 7 * 24 * 60 * 60 * 1000);
777-
return (history as unknown as Record<string, unknown>[] ?? []).slice(0, limit).map((h) => {
778-
const delta = (h.delta ?? {}) as Record<string, unknown>;
779-
return {
780-
time: Number(h.time ?? 0),
781-
symbol: String(delta.coin ?? ""),
782-
payment: String(delta.usdc ?? "0"),
783-
};
775+
// Direct API call — SDK's getUserFunding silently truncates results
776+
const apiUrl = this._testnet ? "https://api.hyperliquid-testnet.xyz/info" : "https://api.hyperliquid.xyz/info";
777+
const res = await fetch(apiUrl, {
778+
method: "POST",
779+
headers: { "Content-Type": "application/json" },
780+
body: JSON.stringify({ type: "userFunding", user: this._address, startTime: Date.now() - 7 * 24 * 60 * 60 * 1000 }),
784781
});
782+
const data = await res.json() as { time: number; delta: { coin: string; usdc: string } }[];
783+
return (data ?? []).slice(0, limit).map((h) => ({
784+
time: h.time,
785+
symbol: h.delta.coin + "-PERP",
786+
payment: h.delta.usdc,
787+
}));
785788
}
786789

787790
async getFundingHistory(symbol: string, limit = 10): Promise<{ time: number; rate: string; price: string | null }[]> {

0 commit comments

Comments
 (0)