@pear-protocol/exchanges-sdk 0.9.1 → 0.11.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.
@@ -63,9 +63,11 @@ __name(createCctpDepositIntentAddress, "createCctpDepositIntentAddress");
63
63
  async function fetchDepositHistory(params, demo = false) {
64
64
  const query = new URLSearchParams({
65
65
  account_index: params.accountIndex.toString(),
66
- l1_address: params.l1Address,
67
- filter: "all"
66
+ l1_address: params.l1Address
68
67
  });
68
+ if (params.cursor) {
69
+ query.set("cursor", params.cursor);
70
+ }
69
71
  const response = await authenticatedLighterFetch(`${getLighterBaseUrl(demo)}/api/v1/deposit/history?${query.toString()}`, params.authToken);
70
72
  const data = await readLighterResponse(response, "/deposit/history");
71
73
  const deposits = [];
@@ -88,9 +90,48 @@ async function fetchDepositHistory(params, demo = false) {
88
90
  l1TxHash: typeof deposit.l1_tx_hash === "string" ? deposit.l1_tx_hash : ""
89
91
  });
90
92
  }
91
- return deposits;
93
+ return {
94
+ deposits,
95
+ nextCursor: readHistoryCursor(data.cursor)
96
+ };
92
97
  }
93
98
  __name(fetchDepositHistory, "fetchDepositHistory");
99
+ async function fetchWithdrawHistory(params, demo = false) {
100
+ const query = new URLSearchParams({
101
+ account_index: params.accountIndex.toString()
102
+ });
103
+ if (params.cursor) {
104
+ query.set("cursor", params.cursor);
105
+ }
106
+ const response = await authenticatedLighterFetch(`${getLighterBaseUrl(demo)}/api/v1/withdraw/history?${query.toString()}`, params.authToken);
107
+ const data = await readLighterResponse(response, "/withdraw/history");
108
+ const withdraws = [];
109
+ for (const withdraw of data.withdraws ?? []) {
110
+ if (typeof withdraw !== "object" || withdraw === null) {
111
+ continue;
112
+ }
113
+ if (typeof withdraw.id !== "string" || typeof withdraw.amount !== "string" || !isLighterWithdrawStatus(withdraw.status) || !isLighterWithdrawType(withdraw.type)) {
114
+ continue;
115
+ }
116
+ if (typeof withdraw.timestamp !== "number" || !Number.isSafeInteger(withdraw.timestamp)) {
117
+ continue;
118
+ }
119
+ withdraws.push({
120
+ id: withdraw.id,
121
+ assetId: typeof withdraw.asset_id === "number" ? withdraw.asset_id : -1,
122
+ amount: withdraw.amount,
123
+ timestamp: withdraw.timestamp,
124
+ status: withdraw.status,
125
+ type: withdraw.type,
126
+ l1TxHash: typeof withdraw.l1_tx_hash === "string" ? withdraw.l1_tx_hash : ""
127
+ });
128
+ }
129
+ return {
130
+ withdraws,
131
+ nextCursor: readHistoryCursor(data.cursor)
132
+ };
133
+ }
134
+ __name(fetchWithdrawHistory, "fetchWithdrawHistory");
94
135
  async function fetchApiKeys(accountIndex, demo = false) {
95
136
  const url = `${getLighterBaseUrl(demo)}/api/v1/apikeys?account_index=${accountIndex}`;
96
137
  const response = await proxyFetch(url);
@@ -259,6 +300,80 @@ async function fetchPositionFundingSince(accountIndex, authToken, since, demo =
259
300
  return Array.from(results.values());
260
301
  }
261
302
  __name(fetchPositionFundingSince, "fetchPositionFundingSince");
303
+ async function submitReferralCode(params, demo = false) {
304
+ const body = new URLSearchParams({
305
+ l1_address: params.l1Address,
306
+ referral_code: params.referralCode
307
+ });
308
+ if (params.discord) {
309
+ body.set("discord", params.discord);
310
+ }
311
+ if (params.telegram) {
312
+ body.set("telegram", params.telegram);
313
+ }
314
+ if (params.x) {
315
+ body.set("x", params.x);
316
+ }
317
+ if (params.signature) {
318
+ body.set("signature", params.signature);
319
+ }
320
+ const response = await authenticatedLighterFetch(`${getLighterBaseUrl(demo)}/api/v1/referral/use`, params.authToken, {
321
+ method: "POST",
322
+ headers: {
323
+ "Content-Type": "application/x-www-form-urlencoded"
324
+ },
325
+ body
326
+ });
327
+ await readLighterResponse(response, "/referral/use");
328
+ }
329
+ __name(submitReferralCode, "submitReferralCode");
330
+ async function fetchUserReferrals(params, demo = false) {
331
+ const query = new URLSearchParams({
332
+ l1_address: params.l1Address
333
+ });
334
+ if (params.cursor) {
335
+ query.set("cursor", params.cursor);
336
+ }
337
+ if (params.statsStartTimestamp !== void 0) {
338
+ query.set("stats_start_timestamp", params.statsStartTimestamp.toString());
339
+ }
340
+ if (params.statsEndTimestamp !== void 0) {
341
+ query.set("stats_end_timestamp", params.statsEndTimestamp.toString());
342
+ }
343
+ if (params.limit !== void 0) {
344
+ query.set("limit", params.limit.toString());
345
+ }
346
+ if (params.eligibleOnly) {
347
+ query.set("is_eligible", "true");
348
+ }
349
+ const response = await authenticatedLighterFetch(`${getLighterBaseUrl(demo)}/api/v1/referral/userReferrals?${query.toString()}`, params.authToken);
350
+ const data = await readLighterResponse(response, "/referral/userReferrals");
351
+ const referrals = [];
352
+ for (const referral of data.referrals ?? []) {
353
+ if (typeof referral !== "object" || referral === null) {
354
+ continue;
355
+ }
356
+ if (typeof referral.l1_address !== "string") {
357
+ continue;
358
+ }
359
+ referrals.push({
360
+ l1Address: referral.l1_address,
361
+ referralCode: typeof referral.referral_code === "string" ? referral.referral_code : "",
362
+ usedAt: readReferralCount(referral.used_at),
363
+ tier: typeof referral.tier === "string" ? referral.tier : "",
364
+ tradeStats: readReferralTradeStats(referral.trade_stats)
365
+ });
366
+ }
367
+ return {
368
+ usedCode: typeof data.used_code === "string" && data.used_code.length > 0 ? data.used_code : null,
369
+ referrals,
370
+ totals: readReferralTotals(data.totals),
371
+ // Reuse the funding-history reading: it treats an unparseable cursor as live, so the worst an
372
+ // encoding mismatch costs here is one extra empty page rather than a dropped one.
373
+ nextCursor: readHistoryCursor(data.cursor)
374
+ };
375
+ }
376
+ __name(fetchUserReferrals, "fetchUserReferrals");
262
377
  async function authenticatedLighterFetch(url, authToken, init) {
263
378
  const headers = new Headers(init?.headers);
264
379
  headers.set("authorization", authToken);
@@ -283,6 +398,38 @@ function isLighterDepositStatus(value) {
283
398
  return value === "failed" || value === "pending" || value === "completed" || value === "claimable";
284
399
  }
285
400
  __name(isLighterDepositStatus, "isLighterDepositStatus");
401
+ function isLighterWithdrawStatus(value) {
402
+ return value === "failed" || value === "pending" || value === "claimable" || value === "refunded" || value === "completed";
403
+ }
404
+ __name(isLighterWithdrawStatus, "isLighterWithdrawStatus");
405
+ function isLighterWithdrawType(value) {
406
+ return value === "secure" || value === "fast";
407
+ }
408
+ __name(isLighterWithdrawType, "isLighterWithdrawType");
409
+ function readHistoryCursor(cursor) {
410
+ if (typeof cursor !== "string" || cursor.length === 0) {
411
+ return null;
412
+ }
413
+ if (isSpentHistoryCursor(cursor)) {
414
+ return null;
415
+ }
416
+ return cursor;
417
+ }
418
+ __name(readHistoryCursor, "readHistoryCursor");
419
+ function isSpentHistoryCursor(cursor) {
420
+ let decoded;
421
+ try {
422
+ decoded = JSON.parse(atob(cursor));
423
+ } catch {
424
+ return false;
425
+ }
426
+ if (typeof decoded !== "object" || decoded === null) {
427
+ return false;
428
+ }
429
+ const indexes = Object.values(decoded).filter((value) => typeof value === "number");
430
+ return indexes.length > 0 && indexes.every((index) => index < 0);
431
+ }
432
+ __name(isSpentHistoryCursor, "isSpentHistoryCursor");
286
433
  async function readLighterResponse(response, endpoint, acceptedCodes = [
287
434
  200
288
435
  ]) {
@@ -301,5 +448,49 @@ async function readLighterResponse(response, endpoint, acceptedCodes = [
301
448
  return data;
302
449
  }
303
450
  __name(readLighterResponse, "readLighterResponse");
451
+ function readReferralTradeStats(stats) {
452
+ const raw = typeof stats === "object" && stats !== null ? stats : {};
453
+ return {
454
+ count: readReferralCount(raw.count),
455
+ volume: readReferralAmount(raw.volume),
456
+ webCount: readReferralCount(raw.web_count),
457
+ webVolume: readReferralAmount(raw.web_volume),
458
+ mobileAppCount: readReferralCount(raw.mobile_app_count),
459
+ mobileAppVolume: readReferralAmount(raw.mobile_app_volume),
460
+ mobileBrowserCount: readReferralCount(raw.mobile_browser_count),
461
+ mobileBrowserVolume: readReferralAmount(raw.mobile_browser_volume),
462
+ freeMakerVolume: readReferralAmount(raw.free_maker_volume),
463
+ freeTakerVolume: readReferralAmount(raw.free_taker_volume),
464
+ nonFreeMakerVolume: readReferralAmount(raw.non_free_maker_volume),
465
+ nonFreeTakerVolume: readReferralAmount(raw.non_free_taker_volume),
466
+ makerFeesPaid: readReferralAmount(raw.maker_fees_paid),
467
+ takerFeesPaid: readReferralAmount(raw.taker_fees_paid)
468
+ };
469
+ }
470
+ __name(readReferralTradeStats, "readReferralTradeStats");
471
+ function readReferralTotals(totals) {
472
+ const raw = typeof totals === "object" && totals !== null ? totals : {};
473
+ return {
474
+ count: readReferralCount(raw.count),
475
+ volume: readReferralAmount(raw.volume),
476
+ freeMakerVolume: readReferralAmount(raw.free_maker_volume),
477
+ freeTakerVolume: readReferralAmount(raw.free_taker_volume),
478
+ nonFreeMakerVolume: readReferralAmount(raw.non_free_maker_volume),
479
+ nonFreeTakerVolume: readReferralAmount(raw.non_free_taker_volume),
480
+ makerFeesPaid: readReferralAmount(raw.maker_fees_paid),
481
+ takerFeesPaid: readReferralAmount(raw.taker_fees_paid),
482
+ totalReferrals: readReferralCount(raw.total_referrals),
483
+ totalPremiumReferrals: readReferralCount(raw.total_premium_referrals)
484
+ };
485
+ }
486
+ __name(readReferralTotals, "readReferralTotals");
487
+ function readReferralCount(value) {
488
+ return typeof value === "number" && Number.isFinite(value) ? value : 0;
489
+ }
490
+ __name(readReferralCount, "readReferralCount");
491
+ function readReferralAmount(value) {
492
+ return typeof value === "string" && value.length > 0 ? value : "0";
493
+ }
494
+ __name(readReferralAmount, "readReferralAmount");
304
495
 
305
- export { createCctpDepositIntentAddress, fetchAccount, fetchAccountLimits, fetchAccountMetadata, fetchAccountsByL1Address, fetchApiKeys, fetchAssetDetails, fetchDepositHistory, fetchDepositNetworks, fetchOrderBookDetails, fetchPositionFundingSince, fetchPublicAccount, fetchPublicOrderBookDetails, fetchTradesSince };
496
+ export { createCctpDepositIntentAddress, fetchAccount, fetchAccountLimits, fetchAccountMetadata, fetchAccountsByL1Address, fetchApiKeys, fetchAssetDetails, fetchDepositHistory, fetchDepositNetworks, fetchOrderBookDetails, fetchPositionFundingSince, fetchPublicAccount, fetchPublicOrderBookDetails, fetchTradesSince, fetchUserReferrals, fetchWithdrawHistory, submitReferralCode };
@@ -167,11 +167,12 @@ async function watchCctpDeposit(ownerAddress, txHash, watch, onProgress, sdk, de
167
167
  let deposits;
168
168
  try {
169
169
  const authToken = await retrieveLighterAuthToken(sdk, watch, demo);
170
- deposits = await fetchDepositHistory({
170
+ const page = await fetchDepositHistory({
171
171
  accountIndex: watch.accountIndex,
172
172
  l1Address: ownerAddress,
173
173
  authToken
174
174
  }, demo);
175
+ deposits = page.deposits;
175
176
  } catch {
176
177
  continue;
177
178
  }
@@ -5,7 +5,9 @@ import { resolveAssetDecimals } from './asset-decimals.helper';
5
5
  import { listCctpDepositNetworks } from './cctp-deposit.helper';
6
6
  import { createDepositAddressForRoute, depositThroughRoute } from './deposit.helper';
7
7
  import { writeWithdraw } from './ethereum';
8
+ import { readWithdrawHistory, readDepositHistory } from './history.helper';
8
9
  import { LIGHTER_ACCOUNT_NOT_REGISTERED_CODE, readOnboardingStatus } from './onboarding.helper';
10
+ import { readUserReferrals, applyReferralCode } from './referral.helper';
9
11
  import { MIN_LIGHTER_FAST_WITHDRAW_USDC } from './types';
10
12
 
11
13
  var __defProp = Object.defineProperty;
@@ -189,6 +191,26 @@ function createLighterHelper(sdk, demo = false) {
189
191
  return {
190
192
  txHash
191
193
  };
194
+ },
195
+ /** Reads one page of the account's deposit history, newest first. */
196
+ async getDepositHistory(params) {
197
+ return readDepositHistory(sdk, params, demo);
198
+ },
199
+ /** Reads one page of the account's withdrawal history, newest first. */
200
+ async getWithdrawHistory(params) {
201
+ return readWithdrawHistory(sdk, params, demo);
202
+ },
203
+ /** Reads the Fun.xyz bridge deposits Lighter has seen for a wallet. */
204
+ async listUdaDeposits(walletAddress) {
205
+ return sdk.core.misc.lighter.listUdaDeposits(walletAddress);
206
+ },
207
+ /** Applies a referrer's code to the owner. Lighter accepts this at most once per owner. */
208
+ async applyReferralCode(params) {
209
+ return applyReferralCode(sdk, params, demo);
210
+ },
211
+ /** Reads one page of the owner's referral record, including the code that referred them. */
212
+ async getUserReferrals(params) {
213
+ return readUserReferrals(sdk, params, demo);
192
214
  }
193
215
  };
194
216
  return helper;
@@ -0,0 +1,26 @@
1
+ import { fetchDepositHistory, fetchWithdrawHistory } from '../../client/lighter/rest';
2
+ import { retrieveLighterAuthToken } from './auth-token.helper';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ async function readDepositHistory(sdk, params, demo) {
7
+ const authToken = await retrieveLighterAuthToken(sdk, params.credentials, demo);
8
+ return fetchDepositHistory({
9
+ accountIndex: params.credentials.accountIndex,
10
+ l1Address: params.l1Address,
11
+ authToken,
12
+ cursor: params.cursor
13
+ }, demo);
14
+ }
15
+ __name(readDepositHistory, "readDepositHistory");
16
+ async function readWithdrawHistory(sdk, params, demo) {
17
+ const authToken = await retrieveLighterAuthToken(sdk, params.credentials, demo);
18
+ return fetchWithdrawHistory({
19
+ accountIndex: params.credentials.accountIndex,
20
+ authToken,
21
+ cursor: params.cursor
22
+ }, demo);
23
+ }
24
+ __name(readWithdrawHistory, "readWithdrawHistory");
25
+
26
+ export { readDepositHistory, readWithdrawHistory };
@@ -0,0 +1,33 @@
1
+ import { submitReferralCode, fetchUserReferrals } from '../../client/lighter/rest';
2
+ import { retrieveLighterAuthToken } from './auth-token.helper';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ async function applyReferralCode(sdk, params, demo) {
7
+ const authToken = await retrieveLighterAuthToken(sdk, params.credentials, demo);
8
+ await submitReferralCode({
9
+ l1Address: params.l1Address,
10
+ referralCode: params.referralCode,
11
+ authToken,
12
+ discord: params.discord,
13
+ telegram: params.telegram,
14
+ x: params.x,
15
+ signature: params.signature
16
+ }, demo);
17
+ }
18
+ __name(applyReferralCode, "applyReferralCode");
19
+ async function readUserReferrals(sdk, params, demo) {
20
+ const authToken = await retrieveLighterAuthToken(sdk, params.credentials, demo);
21
+ return fetchUserReferrals({
22
+ l1Address: params.l1Address,
23
+ authToken,
24
+ cursor: params.cursor,
25
+ statsStartTimestamp: params.statsStartTimestamp,
26
+ statsEndTimestamp: params.statsEndTimestamp,
27
+ limit: params.limit,
28
+ eligibleOnly: params.eligibleOnly
29
+ }, demo);
30
+ }
31
+ __name(readUserReferrals, "readUserReferrals");
32
+
33
+ export { applyReferralCode, readUserReferrals };
package/dist/index.d.ts CHANGED
@@ -279,11 +279,102 @@ type LighterDeposit = {
279
279
  assetId: number;
280
280
  /** Human-readable amount Lighter credited; the intent record never carries this. */
281
281
  amount: string;
282
- /** Unix seconds since epoch, matching Lighter's deposit-history wire format. */
282
+ /** Unix MILLISECONDS since epoch. Lighter's OpenAPI example shows seconds; mainnet sends ms. */
283
283
  timestamp: number;
284
284
  status: LighterDepositStatus;
285
285
  l1TxHash: string;
286
286
  };
287
+ /** One page of deposits, newest first, and the cursor that reads the page before it. */
288
+ type LighterDepositPage = {
289
+ deposits: LighterDeposit[];
290
+ /** Null once Lighter holds no older page. */
291
+ nextCursor: string | null;
292
+ };
293
+ /**
294
+ * The states Lighter reports for a withdrawal.
295
+ *
296
+ * A secure withdrawal stops at `claimable` and never reads `completed`: reaching L1 is a separate
297
+ * claim Lighter usually makes on the owner's behalf, and the history does not report it. Read the
298
+ * mainnet contract's `getPendingBalance()` to learn whether a claimable withdrawal has been paid.
299
+ * Only a fast withdrawal through Arbitrum reaches `completed` here.
300
+ */
301
+ type LighterWithdrawStatus = 'failed' | 'pending' | 'claimable' | 'refunded' | 'completed';
302
+ /** Which withdrawal path carried the funds, which decides how far its status can travel. */
303
+ type LighterWithdrawType = 'secure' | 'fast';
304
+ /** One withdrawal in Lighter's per-account history, paid out or still in flight. */
305
+ type LighterWithdraw = {
306
+ id: string;
307
+ assetId: number;
308
+ /** Human-readable amount Lighter debited, in the asset's own units. */
309
+ amount: string;
310
+ /** Unix MILLISECONDS since epoch. Lighter's OpenAPI example shows seconds; mainnet sends ms. */
311
+ timestamp: number;
312
+ status: LighterWithdrawStatus;
313
+ type: LighterWithdrawType;
314
+ l1TxHash: string;
315
+ };
316
+ /** One page of withdrawals, newest first, and the cursor that reads the page before it. */
317
+ type LighterWithdrawPage = {
318
+ withdraws: LighterWithdraw[];
319
+ /** Null once Lighter holds no older page. */
320
+ nextCursor: string | null;
321
+ };
322
+ /** What one referred trader has traded, over whatever window the request asked Lighter for. */
323
+ type LighterReferralTradeStats = {
324
+ count: number;
325
+ volume: string;
326
+ webCount: number;
327
+ webVolume: string;
328
+ mobileAppCount: number;
329
+ mobileAppVolume: string;
330
+ mobileBrowserCount: number;
331
+ mobileBrowserVolume: string;
332
+ freeMakerVolume: string;
333
+ freeTakerVolume: string;
334
+ nonFreeMakerVolume: string;
335
+ nonFreeTakerVolume: string;
336
+ makerFeesPaid: string;
337
+ takerFeesPaid: string;
338
+ };
339
+ /** One trader who signed up under the owner's code. */
340
+ type LighterReferral = {
341
+ l1Address: string;
342
+ /** The code that trader used, which is the owner's own code. */
343
+ referralCode: string;
344
+ /** When the code was used. Lighter states no unit; its funding histories send milliseconds. */
345
+ usedAt: number;
346
+ /** Lighter's tier wording for that trader; a kickback accrues only above `standard`. */
347
+ tier: string;
348
+ tradeStats: LighterReferralTradeStats;
349
+ };
350
+ /** The owner's running referral totals, which count every referral rather than only this page. */
351
+ type LighterReferralTotals = {
352
+ count: number;
353
+ volume: string;
354
+ freeMakerVolume: string;
355
+ freeTakerVolume: string;
356
+ nonFreeMakerVolume: string;
357
+ nonFreeTakerVolume: string;
358
+ makerFeesPaid: string;
359
+ takerFeesPaid: string;
360
+ totalReferrals: number;
361
+ /** How many referrals hold a paid tier, which is the only kind that earns a kickback. */
362
+ totalPremiumReferrals: number;
363
+ };
364
+ /**
365
+ * One page of an owner's referral record.
366
+ *
367
+ * `usedCode` is the only place Lighter reports who referred the owner, and it reports the code
368
+ * rather than the referrer. Lighter publishes no endpoint that resolves a code back to its owner.
369
+ */
370
+ type LighterUserReferrals = {
371
+ /** The code the owner signed up under, or null when nobody referred them. */
372
+ usedCode: string | null;
373
+ referrals: LighterReferral[];
374
+ totals: LighterReferralTotals;
375
+ /** Null once Lighter holds no further page. */
376
+ nextCursor: string | null;
377
+ };
287
378
 
288
379
  /** Shares one live Lighter auth token per account without crossing rotated credentials. */
289
380
 
@@ -690,6 +781,20 @@ type FastWithdrawResult = {
690
781
  /** Integer USDC units Lighter charged on top of the amount. */
691
782
  fee: number;
692
783
  };
784
+ type LighterDepositHistoryParams = {
785
+ /** Signs the read, and its `accountIndex` names the account whose deposits come back. */
786
+ credentials: LighterAuthCredentials;
787
+ /** The L1 address owning that account; Lighter's deposit history requires both identifiers. */
788
+ l1Address: string;
789
+ /** The `nextCursor` of the page just read; omit to read the newest page. */
790
+ cursor?: string;
791
+ };
792
+ type LighterWithdrawHistoryParams = {
793
+ /** Signs the read, and its `accountIndex` names the account whose withdrawals come back. */
794
+ credentials: LighterAuthCredentials;
795
+ /** The `nextCursor` of the page just read; omit to read the newest page. */
796
+ cursor?: string;
797
+ };
693
798
  /**
694
799
  * The next action an L1 address must take before it can hold a Lighter trade account.
695
800
  *
@@ -703,6 +808,38 @@ type LighterOnboardingStatus = {
703
808
  mainAccountIndex: number;
704
809
  subAccountIndexes: number[];
705
810
  };
811
+ type LighterApplyReferralCodeParams = {
812
+ /** Signs the write; the account it names must belong to the address below. */
813
+ credentials: LighterAuthCredentials;
814
+ /** The owner address the referral binds to; Lighter keys its referral record by address. */
815
+ l1Address: string;
816
+ /** The referrer's code, spelled the way Lighter prints it. */
817
+ referralCode: string;
818
+ /** Lighter accepts a Discord handle beside the code but documents no format for it. */
819
+ discord?: string;
820
+ /** Lighter accepts a Telegram handle beside the code but documents no format for it. */
821
+ telegram?: string;
822
+ /** Lighter accepts an X handle beside the code but documents no format for it. */
823
+ x?: string;
824
+ /** Lighter accepts a signature beside the code but documents neither its payload nor its scheme. */
825
+ signature?: string;
826
+ };
827
+ type LighterUserReferralsParams = {
828
+ /** Signs the read; the account it names must belong to the address below. */
829
+ credentials: LighterAuthCredentials;
830
+ /** The owner address whose referral record comes back. */
831
+ l1Address: string;
832
+ /** The `nextCursor` of the page just read; omit to read the first page. */
833
+ cursor?: string;
834
+ /** Opens the `tradeStats` window. Lighter states no unit for it, so pass what its own client passes. */
835
+ statsStartTimestamp?: number;
836
+ /** Closes the `tradeStats` window. Lighter states no unit for it, so pass what its own client passes. */
837
+ statsEndTimestamp?: number;
838
+ /** Rows per page, between 1 and 300; omit to take Lighter's own page size. */
839
+ limit?: number;
840
+ /** Narrows the page to the referrals Lighter counts toward a kickback tier. */
841
+ eligibleOnly?: boolean;
842
+ };
706
843
  interface LighterHelper {
707
844
  checkOnboarding(l1Address: string): Promise<LighterOnboardingStatus>;
708
845
  lookupAccount(l1Address: string): Promise<LighterLookupResult>;
@@ -721,6 +858,16 @@ interface LighterHelper {
721
858
  }>>;
722
859
  fastWithdraw(walletClient: WalletClientWithAccount, params: FastWithdrawParams): Promise<FastWithdrawResult>;
723
860
  withdraw(walletClient: WalletClientWithAccount, params: WithdrawParams): Promise<WithdrawResult>;
861
+ /** Reads one page of the account's deposit history, newest first. */
862
+ getDepositHistory(params: LighterDepositHistoryParams): Promise<LighterDepositPage>;
863
+ /** Reads one page of the account's withdrawal history, newest first. */
864
+ getWithdrawHistory(params: LighterWithdrawHistoryParams): Promise<LighterWithdrawPage>;
865
+ /** Reads the Fun.xyz bridge deposits Lighter has seen for a wallet. */
866
+ listUdaDeposits(walletAddress: string): Promise<HttpTypes.ListLighterUdaDepositsResult>;
867
+ /** Applies a referrer's code to the owner. Lighter accepts this at most once per owner. */
868
+ applyReferralCode(params: LighterApplyReferralCodeParams): Promise<void>;
869
+ /** Reads one page of the owner's referral record, including the code that referred them. */
870
+ getUserReferrals(params: LighterUserReferralsParams): Promise<LighterUserReferrals>;
724
871
  }
725
872
  type LighterLookupResult = {
726
873
  mainAccountIndex: number;
@@ -2550,4 +2697,4 @@ declare class ExchangesSDK {
2550
2697
  private fetchCredentials;
2551
2698
  }
2552
2699
 
2553
- export { ACCOUNT_MODE_LABELS, ASSET_DECIMALS, AccountBalance, AccountBalanceCore, type AccountHealthStatus, AccountMode, type AccountPosition, type AccountSnapshot, type AccountStatus, type AccountSyncer, type AccountSyncerConfig, type AccountTierCallback, type AccountTracker, type AccountTrackerConfig, type AccountWarningReason, type ApiKey, type ApproveIntegratorParams, type ApproveIntegratorResult, AssetId, type AssetSnapshotMap, type BalanceCallback, BaseAccountSyncer, BaseAccountTracker, BaseWs, BasketLeg, BinanceAccountSyncer, BinanceAccountTracker, type BinanceAccountTrackerConfig, BinanceExchangeWs, BinanceMultiAssetBalance, BinanceSingleAssetBalance, BinanceUserDataWs, type BinanceUserDataWsConfig, BinanceWsApi, type BinanceWsApiConfig, BybitAccountSyncer, BybitAccountTracker, type BybitAccountTrackerConfig, BybitExchangeWs, BybitIsolatedMarginBalance, BybitPortfolioMarginBalance, BybitRegularMarginBalance, BybitWs, type BybitWsConfig, type CappedBasketLeg, type CctpDepositAddressParams, type CctpDepositAddressResult, type CctpDepositHistorySettlement, type CctpDepositParams, type CctpDepositRegistrationSettlement, type CctpDepositResult, type CctpDepositSettlement, type ChangeAccountTierParams, type ChangeAccountTierResult, type CheckApiWalletParams, CollateralBalance, type ConnectOptions, type ConnectWalletParams, type ConnectWalletResult, type CreateAccountTrackerConfig, type CreateExchangeWsConfig, DecimalString, type EthereumDepositParams, type EthereumDepositResult, type ExchangeConnection, type ExchangeHelperExchange, type ExchangeHelperMap, type ExchangeState, ExchangeWs, type ExchangeWsByConnector, ExchangesSDK, type ExchangesSDKConfig, FUNXYZ_DEPOSIT_MINIMUMS_USD, FUNXYZ_ETHEREUM_MAINNET_CHAIN_ID, FUNXYZ_EVM_CHAIN_NAMES, type FastWithdrawParams, type FastWithdrawResult, type FillSyncOutcome, type FundingSyncOutcome, type FunxyzAccountState, type FunxyzAsset, type FunxyzDepositAddressParams, type FunxyzDepositAddressResult, type FunxyzDepositCredit, type FunxyzDepositParams, type FunxyzDepositResult, type FunxyzDepositSettlement, type FunxyzDepositSource, type FunxyzMarket, HyperliquidAccountSyncer, HyperliquidAccountTracker, type HyperliquidAccountTrackerConfig, HyperliquidDexState, HyperliquidExchangeWs, type HyperliquidHelper, HyperliquidPortfolioMarginBalance, HyperliquidPortfolioMarginCollateral, HyperliquidStandardBalance, HyperliquidUnifiedBalance, HyperliquidWs, type IntegratorApprovalRequirements, L2_ASSET_DECIMALS, LIGHTER_NATIVE_USDC_ADDRESSES, LIGHTER_USDC_DECIMALS, LighterAccountSyncer, type LighterAccountTier, LighterAccountTracker, type LighterAccountTrackerConfig, type LighterAuthCredentials, LighterClassicBalance, type LighterDeposit, type LighterDepositAddressParams, type LighterDepositAddressResult, type LighterDepositCredit, type LighterDepositNetwork, type LighterDepositParams, type LighterDepositProgress, type LighterDepositResult, type LighterDepositWalletAdapter, LighterExchangeWs, type LighterHelper, type LighterLookupResult, type LighterOnboardingStatus, LighterUnifiedBalance, LighterWs, type ListExternalFillsParams, type ListExternalFundingParams, type ListExternalPositionsParams, MAX_API_KEY_INDEX, MIN_LIGHTER_CCTP_DEPOSIT_USDC, MIN_LIGHTER_FAST_WITHDRAW_USDC, MIN_USER_API_KEY_INDEX, MarginMode, type MaxBasketSizeCalculation, MaxBasketSizeInput, MaxBasketSizeResult, type MessageListener, OkxAccountSyncer, OkxAccountTracker, type OkxAccountTrackerConfig, OkxExchangeWs, OkxFuturesBalance, OkxMultiCurrencyMarginBalance, OkxPortfolioMarginBalance, OkxSpotBalance, OkxWs, type OkxWsConfig, type OpenListener, type PositionsCallback, RouteType, Side, SignedDecimalString, type StateUpdate, type SupportedCredentials, type TrackedAssetCallback, type TrackedAssetInfo, type WalletClientWithAccount, type WithdrawParams, type WithdrawResult, type WsMessage, computeMaxBasketSize, createAccountSyncer, createAccountTracker, createExchangeWs, createHyperliquidHelper, createLighterHelper, findAvailableApiKeyIndex, getAssetDecimals, getLighterNativeUsdcAddress, listFunxyzTransferableChains, readFunxyzChainSource, readFunxyzMinimumUsd, retrieveLighterAuthToken, usdcAbi };
2700
+ export { ACCOUNT_MODE_LABELS, ASSET_DECIMALS, AccountBalance, AccountBalanceCore, type AccountHealthStatus, AccountMode, type AccountPosition, type AccountSnapshot, type AccountStatus, type AccountSyncer, type AccountSyncerConfig, type AccountTierCallback, type AccountTracker, type AccountTrackerConfig, type AccountWarningReason, type ApiKey, type ApproveIntegratorParams, type ApproveIntegratorResult, AssetId, type AssetSnapshotMap, type BalanceCallback, BaseAccountSyncer, BaseAccountTracker, BaseWs, BasketLeg, BinanceAccountSyncer, BinanceAccountTracker, type BinanceAccountTrackerConfig, BinanceExchangeWs, BinanceMultiAssetBalance, BinanceSingleAssetBalance, BinanceUserDataWs, type BinanceUserDataWsConfig, BinanceWsApi, type BinanceWsApiConfig, BybitAccountSyncer, BybitAccountTracker, type BybitAccountTrackerConfig, BybitExchangeWs, BybitIsolatedMarginBalance, BybitPortfolioMarginBalance, BybitRegularMarginBalance, BybitWs, type BybitWsConfig, type CappedBasketLeg, type CctpDepositAddressParams, type CctpDepositAddressResult, type CctpDepositHistorySettlement, type CctpDepositParams, type CctpDepositRegistrationSettlement, type CctpDepositResult, type CctpDepositSettlement, type ChangeAccountTierParams, type ChangeAccountTierResult, type CheckApiWalletParams, CollateralBalance, type ConnectOptions, type ConnectWalletParams, type ConnectWalletResult, type CreateAccountTrackerConfig, type CreateExchangeWsConfig, DecimalString, type EthereumDepositParams, type EthereumDepositResult, type ExchangeConnection, type ExchangeHelperExchange, type ExchangeHelperMap, type ExchangeState, ExchangeWs, type ExchangeWsByConnector, ExchangesSDK, type ExchangesSDKConfig, FUNXYZ_DEPOSIT_MINIMUMS_USD, FUNXYZ_ETHEREUM_MAINNET_CHAIN_ID, FUNXYZ_EVM_CHAIN_NAMES, type FastWithdrawParams, type FastWithdrawResult, type FillSyncOutcome, type FundingSyncOutcome, type FunxyzAccountState, type FunxyzAsset, type FunxyzDepositAddressParams, type FunxyzDepositAddressResult, type FunxyzDepositCredit, type FunxyzDepositParams, type FunxyzDepositResult, type FunxyzDepositSettlement, type FunxyzDepositSource, type FunxyzMarket, HyperliquidAccountSyncer, HyperliquidAccountTracker, type HyperliquidAccountTrackerConfig, HyperliquidDexState, HyperliquidExchangeWs, type HyperliquidHelper, HyperliquidPortfolioMarginBalance, HyperliquidPortfolioMarginCollateral, HyperliquidStandardBalance, HyperliquidUnifiedBalance, HyperliquidWs, type IntegratorApprovalRequirements, L2_ASSET_DECIMALS, LIGHTER_NATIVE_USDC_ADDRESSES, LIGHTER_USDC_DECIMALS, LighterAccountSyncer, type LighterAccountTier, LighterAccountTracker, type LighterAccountTrackerConfig, type LighterApplyReferralCodeParams, type LighterAuthCredentials, LighterClassicBalance, type LighterDeposit, type LighterDepositAddressParams, type LighterDepositAddressResult, type LighterDepositCredit, type LighterDepositHistoryParams, type LighterDepositNetwork, type LighterDepositPage, type LighterDepositParams, type LighterDepositProgress, type LighterDepositResult, type LighterDepositStatus, type LighterDepositWalletAdapter, LighterExchangeWs, type LighterHelper, type LighterLookupResult, type LighterOnboardingStatus, type LighterReferral, type LighterReferralTotals, type LighterReferralTradeStats, LighterUnifiedBalance, type LighterUserReferrals, type LighterUserReferralsParams, type LighterWithdraw, type LighterWithdrawHistoryParams, type LighterWithdrawPage, type LighterWithdrawStatus, type LighterWithdrawType, LighterWs, type ListExternalFillsParams, type ListExternalFundingParams, type ListExternalPositionsParams, MAX_API_KEY_INDEX, MIN_LIGHTER_CCTP_DEPOSIT_USDC, MIN_LIGHTER_FAST_WITHDRAW_USDC, MIN_USER_API_KEY_INDEX, MarginMode, type MaxBasketSizeCalculation, MaxBasketSizeInput, MaxBasketSizeResult, type MessageListener, OkxAccountSyncer, OkxAccountTracker, type OkxAccountTrackerConfig, OkxExchangeWs, OkxFuturesBalance, OkxMultiCurrencyMarginBalance, OkxPortfolioMarginBalance, OkxSpotBalance, OkxWs, type OkxWsConfig, type OpenListener, type PositionsCallback, RouteType, Side, SignedDecimalString, type StateUpdate, type SupportedCredentials, type TrackedAssetCallback, type TrackedAssetInfo, type WalletClientWithAccount, type WithdrawParams, type WithdrawResult, type WsMessage, computeMaxBasketSize, createAccountSyncer, createAccountTracker, createExchangeWs, createHyperliquidHelper, createLighterHelper, findAvailableApiKeyIndex, getAssetDecimals, getLighterNativeUsdcAddress, listFunxyzTransferableChains, readFunxyzChainSource, readFunxyzMinimumUsd, retrieveLighterAuthToken, usdcAbi };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/exchanges-sdk",
3
- "version": "0.9.1",
3
+ "version": "0.11.0",
4
4
  "description": "Pear Protocol Exchanges SDK",
5
5
  "private": false,
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@pear-protocol/core-sdk": "^1.19.0",
31
- "@pear-protocol/types": "^1.29.0",
31
+ "@pear-protocol/types": "^1.30.1",
32
32
  "@pear-protocol/utils": "^0.5.3",
33
33
  "bignumber.js": "^11.1.1",
34
34
  "partysocket": "^1.0.3",