@coffer_so/sdk 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,877 +0,0 @@
1
- import { SdkResult } from "../types/result";
2
- import { PoolSummary } from "../types/pool";
3
- export interface CubeBackendClientParams {
4
- apiEndpoint: string;
5
- apiKey?: string;
6
- defaultHeaders?: Record<string, string>;
7
- /**
8
- * Called when tokens are refreshed automatically after a 401.
9
- * The frontend should persist the new tokens (e.g. to localStorage).
10
- */
11
- onTokenRefreshed?: (tokens: AuthTokens) => void;
12
- /**
13
- * Called when both access and refresh tokens are expired/invalid.
14
- * The frontend should trigger a full re-authentication (SIWS sign-in).
15
- */
16
- onAuthExpired?: () => void;
17
- }
18
- export type StatsKind = "tvl" | "volume" | "swap_count" | "avg_swap" | "median_swap" | "fees_lp" | "fees_protocol" | "users_total" | "dau" | "mau" | "deposits" | "removals";
19
- export type StatsWindow = "1d" | "7d" | "30d" | "all";
20
- export interface StatsSeriesPoint {
21
- t: number;
22
- v: number;
23
- }
24
- export interface StatsSeries {
25
- points: StatsSeriesPoint[];
26
- }
27
- export interface PriceMap {
28
- [mint: string]: number;
29
- }
30
- export interface SwapRouteEntry {
31
- poolAddress: string;
32
- poolName: string;
33
- amountIn: string;
34
- /** Raw expected output for this leg — NET of the v5 sell-off surge fee
35
- * (what the user actually receives). */
36
- expectedOut: string;
37
- /** Raw minimum output for this leg after slippage — sign this into the
38
- * swap instruction. */
39
- minAmountOut: string;
40
- percentage: number;
41
- swapFee: number;
42
- /** Estimated v5 sell-off surge fee for this leg (raw units of tokenOut).
43
- * "0" in the common case — rises as the input token's max-selloff
44
- * window fills. */
45
- surgeFeeAmount: string;
46
- /** Surge fee rate applied to this leg (%). 0 when the window is calm. */
47
- surgeFeePct: number;
48
- tokenProgramIn: string;
49
- tokenProgramOut: string;
50
- tokenInIndex: number;
51
- tokenOutIndex: number;
52
- vaultIn: string | null;
53
- vaultOut: string | null;
54
- }
55
- export interface SwapRouteResponse {
56
- routes: SwapRouteEntry[];
57
- totalAmountIn: string;
58
- totalExpectedOut: string;
59
- /** Total raw minimum received after slippage (sum of per-leg
60
- * minAmountOut). Always ≤ totalExpectedOut — display this as "Min
61
- * received" instead of extrapolating from spot price. */
62
- minReceived: string;
63
- /** Slippage tolerance applied by the backend (basis points; 200 = 2%). */
64
- slippageBps: number;
65
- effectivePrice: number;
66
- priceImpact: number;
67
- spotPrice: number;
68
- /** Weighted average fee across routes (%), INCLUDING the v5 surge fee
69
- * when one is active. */
70
- feePercent: number;
71
- /** Total estimated v5 surge fee across legs (raw units of tokenOut).
72
- * "0" in the common case. */
73
- totalSurgeFee: string;
74
- /** Estimated XP earned from this swap (based on LP fees generated) */
75
- estimatedXp: number;
76
- /** True when a personalized XP boost (e.g. referred user +3%) was
77
- * applied to `estimatedXp` — requires the request to carry a JWT. */
78
- xpBoostApplied: boolean;
79
- }
80
- export interface LeaderboardEntry {
81
- address: string;
82
- points: number;
83
- place: number;
84
- }
85
- export interface LeaderboardResponse {
86
- total: number;
87
- page: number;
88
- limit: number;
89
- data: LeaderboardEntry[];
90
- }
91
- export interface LeaderboardUserStats {
92
- place: number;
93
- address: string;
94
- points: number;
95
- lastAccrualSwapUsd: number;
96
- lastAccrualLiqUsd: number;
97
- lastAccrualAt: string | null;
98
- }
99
- export interface XpAccrualHistoryEntry {
100
- accrualTime: string;
101
- swapVolumeUsd: number;
102
- swapXp: number;
103
- lpValueUsd: number;
104
- lpXp: number;
105
- totalXp: number;
106
- }
107
- export interface XpAccrualHistoryResponse {
108
- total: number;
109
- page: number;
110
- limit: number;
111
- data: XpAccrualHistoryEntry[];
112
- }
113
- export interface EpochHistoryEntry {
114
- epoch: number;
115
- start: string;
116
- end: string;
117
- multiplier: number;
118
- swapXpPerUsdLpFee: number;
119
- lpXpPerUsd: number;
120
- isCurrent: boolean;
121
- }
122
- export interface LeaderboardEpochResponse {
123
- currentEpoch: number;
124
- currentEpochStart: string;
125
- nextEpochStart: string;
126
- msUntilNextEpoch: number;
127
- currentMultiplier: number;
128
- baseRates: {
129
- swapXpPerUsdLpFee: number;
130
- lpXpPerUsd: number;
131
- };
132
- currentRates: {
133
- swapXpPerUsdLpFee: number;
134
- lpXpPerUsd: number;
135
- };
136
- epochs: EpochHistoryEntry[];
137
- }
138
- export interface LeaderboardStatsResponse {
139
- /** Total number of users in the leaderboard */
140
- totalUsers: number;
141
- /** Sum of all XP points across all users */
142
- totalXp: number;
143
- }
144
- export interface CampaignStatusResponse {
145
- /** Active campaign slug the backend is currently running. */
146
- campaign: string;
147
- participating: boolean;
148
- /** ISO time of the ORIGINAL join; null when not participating. */
149
- joinedAt: string | null;
150
- }
151
- export interface CampaignPrizeTier {
152
- /** Inclusive place range this prize applies to. */
153
- fromPlace: number;
154
- toPlace: number;
155
- usd: number;
156
- }
157
- export interface CampaignInfoResponse {
158
- campaign: string;
159
- startsAt: string;
160
- endsAt: string;
161
- /** Server-computed — drive the countdown from this, not client clocks. */
162
- msUntilEnd: number;
163
- ended: boolean;
164
- prizePoolUsd: number;
165
- /** Fixed for the whole campaign; paid out manually after the end. */
166
- prizes: CampaignPrizeTier[];
167
- rates: {
168
- /** Same swap-XP rate as the leaderboard; LP XP is NOT accrued here. */
169
- swapXpPerUsdLpFee: number;
170
- };
171
- }
172
- export interface CampaignRankResponse {
173
- campaign: string;
174
- from: string;
175
- /** Effective window end after server-side clamping to the campaign. */
176
- to: string;
177
- participating: boolean;
178
- /**
179
- * Place under the same ordering as the public top table; null when not
180
- * participating or no swap XP earned inside the window.
181
- */
182
- place: number | null;
183
- swapXp: number;
184
- swapVolumeUsd: number;
185
- /** Size of the ranked table — for "you are N of M" UI. */
186
- totalRanked: number;
187
- }
188
- export interface CampaignTopEntry {
189
- /** Continuous across pages. */
190
- place: number;
191
- address: string;
192
- /** XP earned from swaps inside the window (LP XP not counted). */
193
- swapXp: number;
194
- swapVolumeUsd: number;
195
- joinedAt: string;
196
- }
197
- export interface CampaignTopResponse {
198
- campaign: string;
199
- from: string;
200
- /** Effective window end after server-side clamping to the campaign. */
201
- to: string;
202
- /** Participants with swap XP > 0 in the window. */
203
- total: number;
204
- page: number;
205
- limit: number;
206
- data: CampaignTopEntry[];
207
- }
208
- export interface PlatformStatsResponse {
209
- totalTvlUsd: number;
210
- totalVirtualTvl: number;
211
- totalVolume24h: number;
212
- poolCount: number;
213
- updatedAt: string | null;
214
- }
215
- export interface AdminPoolEntry {
216
- poolAddress: string;
217
- poolName: string;
218
- /** Off-chain: mint shown first in the token list (null = default order). */
219
- baseAssetMint: string | null;
220
- /** Off-chain: short pool description. */
221
- description: string | null;
222
- tvlUsd: number;
223
- apy: number;
224
- volume24h: number;
225
- swapFee: number;
226
- poolEnabled: boolean;
227
- swapsEnabled: boolean;
228
- tokens: Array<{
229
- mintAddress: string;
230
- ticker: string;
231
- imageUrl: string | null;
232
- }>;
233
- }
234
- /** Off-chain, admin-editable pool settings. */
235
- export interface UpdatePoolSettingsBody {
236
- /** Mint of the base asset (one of the pool tokens); "" clears it. */
237
- baseAssetMint?: string;
238
- /** Short description; "" clears it. */
239
- description?: string;
240
- }
241
- export interface AdminPoolsResponse {
242
- pools: AdminPoolEntry[];
243
- }
244
- export interface IsAdminResponse {
245
- poolAddress: string;
246
- isAdmin: boolean;
247
- }
248
- export interface RenamePoolResponse {
249
- poolAddress: string;
250
- name: string;
251
- updated: true;
252
- }
253
- export interface ReferralBindResponse {
254
- referrer: string;
255
- bound: true;
256
- }
257
- export interface ReferralRates {
258
- l1Percent: number;
259
- l2Percent: number;
260
- }
261
- export interface ReferralStats {
262
- totalReferrals: number;
263
- l1Count: number;
264
- l2Count: number;
265
- totalBonusPoints: number;
266
- l1BonusPoints: number;
267
- l2BonusPoints: number;
268
- }
269
- export interface ReferralStatusResponse {
270
- referredBy: string | null;
271
- referralCode: string;
272
- customCodes: string[];
273
- rates: ReferralRates;
274
- stats: ReferralStats;
275
- }
276
- export interface ReferralEntry {
277
- /** Wallet address of the referral */
278
- address: string;
279
- /** Total bonus XP this referral has earned for you */
280
- earnedBonusXp: number;
281
- /** When this user became your referral */
282
- boundAt: string;
283
- }
284
- export interface ReferralListResponse {
285
- total: number;
286
- page: number;
287
- limit: number;
288
- data: ReferralEntry[];
289
- }
290
- export interface PortfolioValueChange {
291
- abs: number;
292
- pct: number;
293
- }
294
- export interface PortfolioSummaryResponse {
295
- value: {
296
- total: number;
297
- inPositions: number;
298
- inWallet: number;
299
- change: {
300
- d1: PortfolioValueChange;
301
- d7: PortfolioValueChange;
302
- };
303
- };
304
- totalPnl: {
305
- net: number;
306
- pct: number;
307
- components: {
308
- feesEarned: number;
309
- ilCurrent: number;
310
- ilRealized: number;
311
- };
312
- };
313
- }
314
- export interface PortfolioExposureToken {
315
- symbol: string;
316
- mint: string;
317
- logo: string | null;
318
- usd: number;
319
- amount: number;
320
- pct: number;
321
- inLp: number;
322
- inWallet: number;
323
- pools: string[];
324
- }
325
- export interface PortfolioExposureResponse {
326
- totalUsd: number;
327
- tokens: PortfolioExposureToken[];
328
- }
329
- export interface PortfolioHistoryPoint {
330
- t: number;
331
- feesCumulative: number;
332
- ilCumulative: number;
333
- netPnl: number;
334
- }
335
- export interface PortfolioHistoryResponse {
336
- range: string;
337
- series: PortfolioHistoryPoint[];
338
- }
339
- export interface PortfolioPoolEntry {
340
- poolAddress: string;
341
- poolName: string;
342
- tokens: Array<{
343
- symbol: string;
344
- mint: string;
345
- }>;
346
- value: number;
347
- feesEarned: number;
348
- /** LIVE unrealized IL only (≤ 0); realized part is `ilRealized` */
349
- il: number;
350
- /** Result locked in on past withdrawals vs HODL ("Realized PnL" in UI) */
351
- ilRealized: number;
352
- netPnl: number;
353
- /** POOL-wide APY, % — the same number as the pools page (legacy name). */
354
- apr: number;
355
- }
356
- export interface PortfolioPoolsResponse {
357
- pools: PortfolioPoolEntry[];
358
- }
359
- export interface PortfolioPoolHistoryPoint {
360
- t: number;
361
- feesCumulative: number;
362
- ilCumulative: number;
363
- }
364
- export interface PortfolioPoolHistoryResponse {
365
- poolAddress: string;
366
- range: string;
367
- series: PortfolioPoolHistoryPoint[];
368
- }
369
- export type PortfolioChartMetric = "networth" | "pnl" | "il" | "xp";
370
- export type PortfolioChartRange = "24h" | "1w" | "1m" | "1y" | "all";
371
- export interface PortfolioChartResponse {
372
- metric: PortfolioChartMetric;
373
- range: PortfolioChartRange;
374
- /** Distance between series/line points, seconds. */
375
- granularitySec: number;
376
- /**
377
- * Headline value: the last point. For `xp` — the lifetime XP total.
378
- * For `il` — the NET result (profit + IL, the bottom line vs HODL).
379
- */
380
- current: number;
381
- /**
382
- * Change over the range (for XP: abs = XP earned in the range; for il:
383
- * the net change). `pct` is null when the base is zero/near-zero
384
- * (growth from nothing, or a signed pnl/net-il base under $1) — render
385
- * it as "—".
386
- */
387
- change: {
388
- abs: number;
389
- pct: number | null;
390
- };
391
- /**
392
- * True when the data is partially estimated: wallet history coverage
393
- * hit its cap / the history API was unavailable (amounts frozen at the
394
- * horizon), or LP events inside the range (il / pnl metrics).
395
- */
396
- approximate: boolean;
397
- /**
398
- * The single line, [unixSeconds, value] pairs ascending — for
399
- * `networth`, `pnl` and `xp`. ABSENT for `il`, which returns two
400
- * separate lines in `lines` instead.
401
- *
402
- * - networth: whole-portfolio USD value at each point.
403
- * - pnl: cumulative profit/loss vs invested dollars (never-decreasing
404
- * is NOT guaranteed — it moves with the market and with fixations).
405
- * - xp: the total XP as of each point — cumulative, never decreasing.
406
- */
407
- series?: Array<[number, number]>;
408
- /**
409
- * `il` metric ONLY: two lines to draw on the same chart, both
410
- * [unixSeconds, value] ascending on a shared grid, BOTH as POSITIVE
411
- * magnitudes.
412
- * - `profit`: cumulative LP fees earned (≥ 0, draw green).
413
- * - `il`: impermanent loss as a positive number (≥ 0, draw red) — the
414
- * red line already means "loss", so it carries no minus sign.
415
- * The net LP result vs HODL is `profit − il`, and that is what
416
- * `current` and `change` report. There is no `series` for this metric.
417
- */
418
- lines?: {
419
- profit: Array<[number, number]>;
420
- il: Array<[number, number]>;
421
- };
422
- }
423
- export type PortfolioActivityType = "swap" | "added" | "removed" | "zap" | "sent" | "received" | "deployed";
424
- export type PortfolioActivityFilter = "all" | "liquidity" | "zap" | "swap" | "transfer" | "deployed";
425
- export interface ActivityTokenInfo {
426
- mint: string;
427
- symbol: string | null;
428
- logo: string | null;
429
- }
430
- export interface PortfolioActivityItem {
431
- type: PortfolioActivityType;
432
- signature: string;
433
- /** Unix seconds. */
434
- time: number;
435
- /**
436
- * Signed USD: + for added/zap/received, − for removed/sent, unsigned for
437
- * swap; null when unpriceable and for deployed rows.
438
- */
439
- valueUsd: number | null;
440
- pool: {
441
- address: string;
442
- name: string;
443
- feePercent: number | null;
444
- bptMint: string | null;
445
- tokens: ActivityTokenInfo[];
446
- /** Pool weights in % (for the deployed row's "80/20 weights" subtitle). */
447
- weights?: number[];
448
- } | null;
449
- /** Only on swap rows. */
450
- swap?: {
451
- tokenIn: ActivityTokenInfo;
452
- tokenOut: ActivityTokenInfo;
453
- };
454
- /** Only on sent/received rows (wallet-to-wallet LP token transfers). */
455
- transfer?: {
456
- counterparty: string | null;
457
- };
458
- }
459
- export interface PortfolioActivityResponse {
460
- total: number;
461
- page: number;
462
- limit: number;
463
- data: PortfolioActivityItem[];
464
- }
465
- export type SortOrder = "desc" | "asc";
466
- export type PortfolioActivitySortField = "time" | "value";
467
- export type PortfolioHoldingsSortField = "value" | "price" | "balance";
468
- export interface PortfolioHoldingItem {
469
- token: {
470
- mint: string;
471
- symbol: string | null;
472
- /** Full token name (e.g. "USD Coin"); null when metadata has none. */
473
- name: string | null;
474
- logo: string | null;
475
- };
476
- priceUsd: number;
477
- /** Total amount: wallet + decomposed LP positions. */
478
- balance: number;
479
- valueUsd: number;
480
- /** Source breakdown for the tooltip; pct is of the token's balance. */
481
- sources: {
482
- wallet: {
483
- amount: number;
484
- pct: number;
485
- };
486
- pools: Array<{
487
- poolAddress: string;
488
- poolName: string;
489
- amount: number;
490
- pct: number;
491
- }>;
492
- };
493
- }
494
- export interface PortfolioHoldingsResponse {
495
- total: number;
496
- page: number;
497
- limit: number;
498
- data: PortfolioHoldingItem[];
499
- }
500
- export type PortfolioPositionsSortField = "value" | "fees" | "il" | "pnl" | "apy";
501
- export interface PortfolioPositionItem {
502
- pool: {
503
- address: string;
504
- name: string;
505
- feePercent: number | null;
506
- bptMint: string | null;
507
- tokens: ActivityTokenInfo[];
508
- };
509
- /** Position value from the 30s-fresh wallet BPT balance. */
510
- valueUsd: number;
511
- /** Lifetime LP fees earned in this pool. */
512
- feesEarned: number;
513
- /** Live unrealized IL (≤ 0); the realized part is `ilRealized`. */
514
- il: number;
515
- ilRealized: number;
516
- /** feesEarned + il + ilRealized. */
517
- netPnl: number;
518
- /** POOL-wide APY, % (24h-based) — the same number as the pools page. */
519
- apy: number;
520
- }
521
- export interface PortfolioPositionsResponse {
522
- /** Number of ACTIVE positions (the "N active positions" header). */
523
- total: number;
524
- page: number;
525
- limit: number;
526
- /** Σ value of ALL active positions (the header total), not the page. */
527
- totalValueUsd: number;
528
- data: PortfolioPositionItem[];
529
- }
530
- export type PairChartRange = "1d" | "1w" | "1m" | "1y" | "all";
531
- /**
532
- * Price of token `a` expressed in units of token `b` over time — the
533
- * one-line chart behind the range picker on the pool creation page.
534
- */
535
- export interface TokenPairChartResponse {
536
- /** Numerator mint — the token being priced. */
537
- a: string;
538
- /** Denominator mint — the token `a` is priced IN. */
539
- b: string;
540
- range: PairChartRange;
541
- /** Spacing between series points, seconds. */
542
- granularitySec: number;
543
- current: {
544
- /**
545
- * How many units of `b` one unit of `a` is worth right now — the
546
- * big "1,284.52 SOL/USDT" headline number.
547
- */
548
- ratio: number;
549
- /** Current USD price of `a` — the grey "$345.44" next to it. */
550
- aUsd: number;
551
- /** Current USD price of `b`. */
552
- bUsd: number;
553
- };
554
- /**
555
- * Change of the pair price over the range. `pct` is null when the
556
- * range started from an unknown (zero) price — render "—".
557
- */
558
- change: {
559
- abs: number;
560
- pct: number | null;
561
- };
562
- /**
563
- * [unixSeconds, priceAinB] ascending — ONE line. Values are rounded
564
- * to 6 significant digits (pairs like BONK/SOL live around 1e-9).
565
- */
566
- series: Array<[number, number]>;
567
- }
568
- export interface NonceResponse {
569
- nonce: string;
570
- message: string;
571
- }
572
- /**
573
- * Challenge for the transaction-based sign-in fallback (wallets whose
574
- * signMessage path is broken — Ledger through mobile apps first of all).
575
- */
576
- export interface TxChallengeResponse {
577
- nonce: string;
578
- /** Base64-encoded UNSIGNED transaction to pass to wallet.signTransaction. */
579
- transaction: string;
580
- /** Human-readable memo embedded in the transaction (agreements + nonce). */
581
- memo: string;
582
- }
583
- export interface AuthTokens {
584
- accessToken: string;
585
- refreshToken: string;
586
- wallet: string;
587
- expiresIn: string;
588
- }
589
- /**
590
- * REST wrapper around the Cube backend. Every method is a SdkResult; no
591
- * exceptions escape. If a request fails, the result carries a
592
- * human-readable error plus the original cause.
593
- *
594
- * Auto-refresh: when a request gets 401, the client automatically tries
595
- * to refresh tokens via POST /api/auth/refresh. If successful, the
596
- * original request is retried once with the new access token.
597
- */
598
- export declare class CubeBackendClient {
599
- private readonly endpoint;
600
- private readonly headers;
601
- private refreshToken;
602
- private refreshInFlight;
603
- private readonly onTokenRefreshed?;
604
- private readonly onAuthExpired?;
605
- constructor(params: CubeBackendClientParams);
606
- listPools(): Promise<SdkResult<PoolSummary[]>>;
607
- getPool(addr: string): Promise<SdkResult<PoolSummary>>;
608
- /**
609
- * Raw pool-list response in the same envelope the backend returns
610
- * (`{ data, hasMore, totalCount }`). Kept so the frontend's React
611
- * Query hooks can map directly.
612
- */
613
- listPoolsRaw(limit: number, offset: number): Promise<SdkResult<{
614
- data: unknown[];
615
- hasMore: boolean;
616
- totalCount: number;
617
- }>>;
618
- getPoolRaw(addr: string): Promise<SdkResult<unknown>>;
619
- createPool<T>(body: unknown): Promise<SdkResult<T>>;
620
- getPoolsByTokenPair<T>(tokenA: string, tokenB: string): Promise<SdkResult<T>>;
621
- getPlatformStats(): Promise<SdkResult<PlatformStatsResponse>>;
622
- getPortfolio<T>(wallet: string): Promise<SdkResult<T>>;
623
- getAllTokens<T>(): Promise<SdkResult<T>>;
624
- getTopTokens<T>(limit?: number): Promise<SdkResult<T>>;
625
- getPoolTxStats<T>(addr: string): Promise<SdkResult<T>>;
626
- getTransactions<T>(addr: string, options?: {
627
- limit?: number;
628
- offset?: number;
629
- type?: "swap" | "add_liquidity" | "remove_liquidity";
630
- user?: string;
631
- }): Promise<SdkResult<T>>;
632
- getSwapRoute(tokenIn: string, tokenOut: string, amountIn: string, decimalsIn?: number, slippageBps?: number,
633
- /**
634
- * Restrict the quote to this single pool: no split routing, all
635
- * estimates (priceImpact against this pool's own spot, fees, XP) are
636
- * computed as if swapping only through it.
637
- */
638
- pool?: string): Promise<SdkResult<SwapRouteResponse>>;
639
- getLeaderboard(page?: number, limit?: number): Promise<SdkResult<LeaderboardResponse>>;
640
- getLeaderboardUser(address: string): Promise<SdkResult<LeaderboardUserStats>>;
641
- getLeaderboardUserHistory(address: string, page?: number, limit?: number): Promise<SdkResult<XpAccrualHistoryResponse>>;
642
- getLeaderboardEpoch(): Promise<SdkResult<LeaderboardEpochResponse>>;
643
- /** Get overall leaderboard stats: total users and total XP. */
644
- getLeaderboardStats(): Promise<SdkResult<LeaderboardStatsResponse>>;
645
- /**
646
- * Join the active swap-XP campaign. Requires SIWS auth (`setTokens`);
647
- * the wallet comes from the JWT. IDEMPOTENT — repeat calls are no-ops
648
- * returning the same status with the original join time.
649
- */
650
- joinCampaign(): Promise<SdkResult<CampaignStatusResponse>>;
651
- /** Participation status of the authenticated wallet (requires SIWS auth). */
652
- getCampaignStatus(): Promise<SdkResult<CampaignStatusResponse>>;
653
- /** Active campaign card: window, server-side countdown, prizes. Public. */
654
- getCampaignInfo(): Promise<SdkResult<CampaignInfoResponse>>;
655
- /**
656
- * The authenticated wallet's own place in the campaign standings
657
- * (requires SIWS auth). Same window semantics and ordering as
658
- * getCampaignTop, so the place always matches the public table.
659
- */
660
- getCampaignRank(from?: string, to?: string): Promise<SdkResult<CampaignRankResponse>>;
661
- /**
662
- * Campaign standings: participants only, ranked by swap XP inside
663
- * [from, to). Both dates are optional and CLAMPED into the campaign
664
- * window server-side (defaults: the whole campaign) — omit both for
665
- * the live standings of the running campaign; they freeze by
666
- * themselves once it ends. Public endpoint, paginated like the
667
- * leaderboard.
668
- */
669
- getCampaignTop(from?: string, to?: string, page?: number, limit?: number): Promise<SdkResult<CampaignTopResponse>>;
670
- getTokenPrices(mints: string[]): Promise<SdkResult<PriceMap>>;
671
- getStats(kind: StatsKind, window?: StatsWindow, poolAddr?: string, unit?: "usd" | "token"): Promise<SdkResult<StatsSeries>>;
672
- /**
673
- * Get pools where the authenticated user is the on-chain admin.
674
- * Requires authentication.
675
- */
676
- getAdminPools(): Promise<SdkResult<AdminPoolsResponse>>;
677
- /**
678
- * Check if the authenticated user is the on-chain admin of a specific pool.
679
- * Requires authentication.
680
- */
681
- isPoolAdmin(poolAddress: string): Promise<SdkResult<IsAdminResponse>>;
682
- /**
683
- * Rename a pool. Only the on-chain pool admin can do this.
684
- * Requires authentication.
685
- */
686
- renamePool(poolAddress: string, name: string): Promise<SdkResult<RenamePoolResponse>>;
687
- /**
688
- * Update off-chain pool settings (base asset, description). Only fields
689
- * present are changed; empty string clears a field. Base asset must be
690
- * one of the pool tokens. Pool admin only; requires authentication.
691
- */
692
- updatePoolSettings<T>(poolAddress: string, settings: UpdatePoolSettingsBody): Promise<SdkResult<T>>;
693
- /**
694
- * Bind the authenticated user as a referral of the given referrer.
695
- * The code can be a wallet address or a custom referral code.
696
- * Optionally pass UTM parameters from the referral link for analytics.
697
- * Requires authentication (setTokens must be called first).
698
- */
699
- bindReferral(code: string, utm?: {
700
- source?: string;
701
- medium?: string;
702
- campaign?: string;
703
- content?: string;
704
- term?: string;
705
- }): Promise<SdkResult<ReferralBindResponse>>;
706
- /**
707
- * Get the authenticated user's referral status: referrer, referral code,
708
- * custom codes, bonus rates (L1/L2 %), and aggregated stats.
709
- * Requires authentication.
710
- */
711
- getReferralStatus(): Promise<SdkResult<ReferralStatusResponse>>;
712
- /**
713
- * Get a paginated list of the authenticated user's direct referrals (L1).
714
- * Requires authentication.
715
- */
716
- getMyReferrals(page?: number, limit?: number): Promise<SdkResult<ReferralListResponse>>;
717
- /**
718
- * Portfolio summary: value (LP + wallet) + total PnL (fees, IL current, IL realized).
719
- * Returns 404 if user has no LP positions.
720
- */
721
- getPortfolioSummary(): Promise<SdkResult<PortfolioSummaryResponse>>;
722
- /**
723
- * Token exposure: per-token breakdown of LP positions + wallet balances.
724
- */
725
- getPortfolioExposure(): Promise<SdkResult<PortfolioExposureResponse>>;
726
- /**
727
- * Portfolio history for charts (fees cumulative + IL cumulative).
728
- * Daily data points for the selected range.
729
- */
730
- getPortfolioHistory(range?: "7d" | "30d" | "90d" | "all"): Promise<SdkResult<PortfolioHistoryResponse>>;
731
- /**
732
- * Per-pool portfolio metrics (value, fees, unrealized IL, realized
733
- * IL/PnL, net PnL, APR).
734
- */
735
- getPortfolioPools(): Promise<SdkResult<PortfolioPoolsResponse>>;
736
- /**
737
- * Per-pool history (lazy-loaded on row expand).
738
- * Fees cumulative + IL cumulative series for a single pool.
739
- */
740
- getPortfolioPoolHistory(poolAddress: string, range?: "7d" | "30d" | "90d" | "all"): Promise<SdkResult<PortfolioPoolHistoryResponse>>;
741
- /**
742
- * Chart data for the portfolio page chart card. Most metrics fill
743
- * `series` (one line); `il` fills `lines` (two lines) instead.
744
- *
745
- * Metrics: `networth` — whole portfolio value over time (wallet tokens +
746
- * LP positions, reconstructed from on-chain wallet history × historical
747
- * prices); `pnl` — CUMULATIVE profit/loss vs invested dollars:
748
- * unrealized (LP value minus entry-priced capital) + profit FIXED at
749
- * every exit (withdrawal = received USD − capital share, transfer-out =
750
- * amount × LP price at that moment − capital share) — continuous at
751
- * both top-ups and exits;
752
- * `il` — TWO lines in `lines`, both POSITIVE: `profit` (cumulative LP
753
- * fees earned) and `il` (impermanent loss magnitude, vs HODL); there is
754
- * no `series` for this metric, and `current`/`change` report the net
755
- * (profit − il);
756
- * `xp` — the total XP as of each point (cumulative, never decreasing).
757
- *
758
- * `all` range spans at least one year even for recent users, so it is
759
- * never shorter than `1y`.
760
- */
761
- getPortfolioChart(metric: PortfolioChartMetric, range: PortfolioChartRange): Promise<SdkResult<PortfolioChartResponse>>;
762
- /**
763
- * On-chain activity feed: swaps, liquidity added/removed, zaps
764
- * (single-token deposits), LP tokens sent/received (wallet transfers
765
- * with counterparties) and pools deployed by the user. Newest first,
766
- * page/limit pagination. The Recent Activity widget is `{ limit: 4 }`;
767
- * filters: `liquidity` = added + removed, `transfer` = sent + received.
768
- */
769
- getPortfolioActivity(options?: {
770
- page?: number;
771
- limit?: number;
772
- type?: PortfolioActivityFilter;
773
- /** Sort column; unpriced rows (deployed) always go last on "value". */
774
- sort?: PortfolioActivitySortField;
775
- order?: SortOrder;
776
- }): Promise<SdkResult<PortfolioActivityResponse>>;
777
- /**
778
- * Token Holdings: every token the user holds, with LP positions
779
- * DECOMPOSED into their underlying tokens (per-pool share of actual
780
- * balances — what the user would receive on withdrawal). LP tokens
781
- * themselves are never listed. Each row carries a source breakdown
782
- * (wallet + per-pool amounts/percentages) for the Source tooltip.
783
- * The widget is `{ limit: 4 }`; sortable by value/price/balance.
784
- */
785
- getPortfolioHoldings(options?: {
786
- page?: number;
787
- limit?: number;
788
- sort?: PortfolioHoldingsSortField;
789
- order?: SortOrder;
790
- }): Promise<SdkResult<PortfolioHoldingsResponse>>;
791
- /**
792
- * Position Pools: the user's ACTIVE LP positions with per-pool money
793
- * metrics — value (from the fresh wallet BPT balance), fees earned,
794
- * unrealized + realized IL, net PnL and personal compounded APY.
795
- * A freshly received (transferred) position appears immediately with
796
- * its value and zeroed metrics until the background snapshot builds.
797
- */
798
- getPortfolioPositions(options?: {
799
- page?: number;
800
- limit?: number;
801
- sort?: PortfolioPositionsSortField;
802
- order?: SortOrder;
803
- }): Promise<SdkResult<PortfolioPositionsResponse>>;
804
- /**
805
- * Price of token `a` expressed in token `b` over time — one line for
806
- * the range-picker chart on the pool creation page. Works for ANY two
807
- * Solana mints; no auth required.
808
- *
809
- * Cheap to call in bursts: the backend caches price history PER TOKEN,
810
- * so charting every token of a pool against one base costs at most one
811
- * upstream fetch per unique mint — flipping the base token reuses all
812
- * of them. Rate-limited per IP (90/min) on top of the global limiter.
813
- *
814
- * `"all"` is capped at one year — the historical price horizon for
815
- * arbitrary mints.
816
- */
817
- getTokenPairChart(a: string, b: string, range: PairChartRange): Promise<SdkResult<TokenPairChartResponse>>;
818
- /** Request a SIWS nonce + pre-built message for the given wallet. */
819
- getNonce(wallet: string): Promise<SdkResult<NonceResponse>>;
820
- /** Submit signed SIWS message to receive access + refresh tokens. */
821
- verifySignature(message: string, signature: string): Promise<SdkResult<AuthTokens>>;
822
- /**
823
- * Request a sign-in challenge transaction (fallback for wallets whose
824
- * signMessage is broken: Ledger via mobile apps, etc.). The returned
825
- * transaction is a 0-lamport self-transfer plus a memo with the
826
- * agreements statement and a single-use nonce; it is verified offline
827
- * by the backend and never broadcast on-chain.
828
- */
829
- getTxChallenge(wallet: string): Promise<SdkResult<TxChallengeResponse>>;
830
- /**
831
- * Submit the signed challenge transaction (base64, from
832
- * wallet.signTransaction + serialize) to receive the same access +
833
- * refresh token pair as verifySignature().
834
- */
835
- verifyTransaction(signedTransactionBase64: string): Promise<SdkResult<AuthTokens>>;
836
- /**
837
- * Set both tokens. Call this after verifySignature() and on app init
838
- * (restoring tokens from storage).
839
- */
840
- setTokens(accessToken: string, refreshToken: string): void;
841
- /** Clear both tokens (logout). */
842
- clearTokens(): void;
843
- /** @deprecated Use setTokens() instead. */
844
- setAccessToken(token: string): void;
845
- /** @deprecated Use clearTokens() instead. */
846
- clearAccessToken(): void;
847
- /** Generic GET with retry. Callers that need it for other endpoints. */
848
- get<T>(path: string): Promise<SdkResult<T>>;
849
- post<T>(path: string, body: unknown): Promise<SdkResult<T>>;
850
- put<T>(path: string, body: unknown): Promise<SdkResult<T>>;
851
- /**
852
- * Core request method with auto-refresh on 401.
853
- * If a request gets 401 and we have a refresh token:
854
- * 1. Call POST /api/auth/refresh (deduplicated if concurrent)
855
- * 2. On success: update tokens, notify via callback, retry original request
856
- * 3. On failure: notify via onAuthExpired callback, return original error
857
- */
858
- private requestWithRefresh;
859
- private rawRequest;
860
- /**
861
- * Attempt to refresh tokens. Returns true if successful.
862
- * Deduplicates concurrent refresh attempts.
863
- */
864
- private tryRefresh;
865
- private doRefresh;
866
- private is401;
867
- /**
868
- * Fetch a response envelope of the form `{ data: T, ... }` and unwrap
869
- * the `.data` field. The existing Cube backend wraps most endpoints
870
- * this way.
871
- */
872
- private getDataField;
873
- private postDataField;
874
- /** Fetch the full envelope (for endpoints that return meta alongside data). */
875
- private getEnvelope;
876
- }
877
- //# sourceMappingURL=CubeBackendClient.d.ts.map