superstack-wallet-sdk 0.5.2 → 0.5.4

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.
package/dist/index.d.ts CHANGED
@@ -114,8 +114,9 @@ interface IModalManager {
114
114
  enableGoogle?: boolean;
115
115
  enableTwitter?: boolean;
116
116
  enablePhantom?: boolean;
117
+ isBackup?: boolean;
117
118
  }) => Promise<void>;
118
- hideModal: () => void;
119
+ hideModal: (isBackup?: boolean) => void;
119
120
  }
120
121
  interface MiddleAccountRequest {
121
122
  order_id: string;
@@ -190,6 +191,138 @@ type BuildTransactionRequest = {
190
191
  interface BuildTransactionResponse {
191
192
  raw_transaction: string;
192
193
  }
194
+ type BigDecimalString = string;
195
+ declare enum BorrowedAsset {
196
+ HypercorePerpsUSDC = "HypercorePerpsUSDC"
197
+ }
198
+ declare enum CollateralAsset {
199
+ HypercoreSpotBTC = "HypercoreSpotBTC"
200
+ }
201
+ declare enum CrossMarginPositionStatus {
202
+ Open = "Open",
203
+ Closed = "Closed",
204
+ PartiallyLiquidated = "PartiallyLiquidated",
205
+ AllLiquidated = "AllLiquidated"
206
+ }
207
+ declare enum CrossMarginOperationType {
208
+ Borrow = "Borrow",
209
+ Repay = "Repay",
210
+ AddMargin = "AddMargin",
211
+ RemoveMargin = "RemoveMargin",
212
+ Liquidation = "Liquidation"
213
+ }
214
+ interface CollateralAssetInfo {
215
+ amount: BigDecimalString;
216
+ contribution?: number;
217
+ liquidation_price?: number;
218
+ }
219
+ interface CrossMarginBorrowQuoteRequest {
220
+ collateral_assets: Partial<Record<CollateralAsset, BigDecimalString>>;
221
+ }
222
+ interface CrossMarginBorrowQuoteResponse {
223
+ quote_id: string;
224
+ collateral_asset_infos: Record<CollateralAsset, CollateralAssetInfo>;
225
+ total_collateral_value: number;
226
+ borrowed_asset: BorrowedAsset;
227
+ max_borrowed_amount: BigDecimalString;
228
+ max_borrowed_value: number;
229
+ created_at: number;
230
+ expires_at: number;
231
+ }
232
+ interface CrossMarginBorrowRequest {
233
+ network: Network;
234
+ address: string;
235
+ quote_id: string;
236
+ collateral_assets: Partial<Record<CollateralAsset, BigDecimalString>>;
237
+ borrowed_asset: BorrowedAsset;
238
+ borrowed_amount: BigDecimalString;
239
+ }
240
+ interface CrossMarginBorrowResponse {
241
+ position_id: string;
242
+ }
243
+ interface CrossMarginRepayQuoteRequest {
244
+ position_id: string;
245
+ }
246
+ interface CrossMarginRepayQuoteResponse {
247
+ quote_id: string;
248
+ repay_asset: BorrowedAsset;
249
+ borrowed_amount: BigDecimalString;
250
+ interest_cost: BigDecimalString;
251
+ repay_amount: BigDecimalString;
252
+ created_at: number;
253
+ expires_at: number;
254
+ }
255
+ interface CrossMarginRepayRequest {
256
+ position_id: string;
257
+ quote_id: string;
258
+ repay_asset: BorrowedAsset;
259
+ repay_amount: BigDecimalString;
260
+ }
261
+ interface CrossMarginRepayResponse {
262
+ position_id: string;
263
+ }
264
+ interface CrossMarginAdjustMarginRequest {
265
+ position_id: string;
266
+ is_add_margin: boolean;
267
+ collateral_assets: Partial<Record<CollateralAsset, BigDecimalString>>;
268
+ }
269
+ interface CrossMarginAdjustMarginResponse {
270
+ position_id: string;
271
+ }
272
+ interface BorrowedAssetGeneralInfo {
273
+ interest_rate_hourly: number;
274
+ interest_rate_annual: number;
275
+ available_amount: number;
276
+ max_borrowable_amount: number;
277
+ }
278
+ interface CollateralAssetGeneralInfo {
279
+ liquidation_threshold: number;
280
+ h_vol: number;
281
+ price: number;
282
+ }
283
+ interface CrossMarginGeneralInfoResponse {
284
+ collateral_info: Record<CollateralAsset, CollateralAssetGeneralInfo>;
285
+ borrowed_info: Record<BorrowedAsset, BorrowedAssetGeneralInfo>;
286
+ }
287
+ interface UserOpenPositionInfo {
288
+ position_id: string;
289
+ collateral_assets: Record<CollateralAsset, CollateralAssetInfo>;
290
+ borrowed_asset: BorrowedAsset;
291
+ borrowed_amount: BigDecimalString;
292
+ created_at: number;
293
+ updated_at: number;
294
+ current_ltv: number;
295
+ margin_call_ltv: number;
296
+ liquidation_ltv: number;
297
+ interest_cost: number;
298
+ }
299
+ interface UserOpenPositionsResponse {
300
+ positions: UserOpenPositionInfo[];
301
+ }
302
+ interface UserClosedPositionInfo {
303
+ position_id: string;
304
+ collateral_assets: Record<CollateralAsset, CollateralAssetInfo>;
305
+ borrowed_asset: BorrowedAsset;
306
+ borrowed_amount: BigDecimalString;
307
+ created_at: number;
308
+ closed_at: number;
309
+ interest_cost: number;
310
+ status: CrossMarginPositionStatus;
311
+ repaid_amount?: number;
312
+ }
313
+ interface UserOperationInfo {
314
+ position_id: string;
315
+ operation_id: string;
316
+ created_at: number;
317
+ finished_at: number;
318
+ operation_type: CrossMarginOperationType;
319
+ amount: BigDecimalString;
320
+ symbol: string;
321
+ }
322
+ interface UserHistoryResponse {
323
+ positions: UserClosedPositionInfo[];
324
+ operations: UserOperationInfo[];
325
+ }
193
326
 
194
327
  interface PhantomWalletAdapterConfig {
195
328
  }
@@ -248,15 +381,18 @@ declare class WalletClient {
248
381
  private walletInfo;
249
382
  private phantomAdapter;
250
383
  private walletType;
384
+ private backupWalletType;
251
385
  private solanaCluster;
252
386
  private ethereumNetwork;
253
387
  private defaultNetwork;
254
388
  constructor(config: WalletProviderConfig);
255
389
  private setWallet;
256
390
  private setWalletType;
391
+ private setBackupWalletType;
257
392
  getWallet(): WalletInfo | null;
258
393
  getPhantomAdapter(): PhantomWalletAdapter | null;
259
394
  getWalletType(): "phantom" | "embedded";
395
+ getBackupWalletType(): "phantom_backup" | "embedded_backup";
260
396
  get wallet(): Wallet | null;
261
397
  get address(): string | null;
262
398
  get network(): Network | null;
@@ -270,7 +406,7 @@ declare class WalletClient {
270
406
  get solanaAddress(): string | null;
271
407
  get id(): string | null;
272
408
  get social_links(): Social[] | null;
273
- reconnect(): Promise<WalletInfo | null>;
409
+ reconnect(isBackup?: boolean): Promise<WalletInfo | null>;
274
410
  connectPhantom(): Promise<WalletInfo | null>;
275
411
  updateAccountName(name: string): Promise<any>;
276
412
  signSolanaTransaction(transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
@@ -314,12 +450,14 @@ declare class WalletClient {
314
450
  code: string;
315
451
  code_verifier: string;
316
452
  network?: Network;
453
+ isBackup?: boolean;
317
454
  }): Promise<WalletInfo | null>;
318
455
  loginWithChallenge(type: LoginType, params: {
319
456
  wallet_address: string;
320
457
  challenge: string;
321
458
  signature: string;
322
459
  network?: Network;
460
+ isBackup?: boolean;
323
461
  }): Promise<WalletInfo | null>;
324
462
  oauthInit(params: {
325
463
  provider: string;
@@ -339,7 +477,7 @@ declare class WalletClient {
339
477
  expires_at: number;
340
478
  }>;
341
479
  getSession(): Promise<WalletInfo>;
342
- logout(): Promise<void>;
480
+ logout(isBackup?: boolean): Promise<void>;
343
481
  getOAuth2ClientId(provider: string): Promise<string>;
344
482
  setSelectedWallet(walletId: string): void;
345
483
  getSelectedWallet(): string | null;
@@ -400,10 +538,18 @@ declare class WalletClient {
400
538
  * @returns Build transaction response with raw transaction
401
539
  */
402
540
  buildTransaction(request: BuildTransactionRequest): Promise<BuildTransactionResponse>;
541
+ getCrossMarginGeneralInfo(): Promise<CrossMarginGeneralInfoResponse>;
542
+ getCrossMarginBorrowQuote(payload: CrossMarginBorrowQuoteRequest): Promise<CrossMarginBorrowQuoteResponse>;
543
+ borrowCrossMargin(payload: CrossMarginBorrowRequest): Promise<CrossMarginBorrowResponse>;
544
+ getCrossMarginRepayQuote(payload: CrossMarginRepayQuoteRequest): Promise<CrossMarginRepayQuoteResponse>;
545
+ repayCrossMargin(payload: CrossMarginRepayRequest): Promise<CrossMarginRepayResponse>;
546
+ adjustCrossMarginMargin(payload: CrossMarginAdjustMarginRequest): Promise<CrossMarginAdjustMarginResponse>;
547
+ getCrossMarginOpenPositions(): Promise<UserOpenPositionsResponse>;
548
+ getCrossMarginHistory(): Promise<UserHistoryResponse>;
403
549
  }
404
550
  type SignTransactionReturnType<serializer extends viem.SerializeTransactionFn<viem.TransactionSerializable> = viem.SerializeTransactionFn<viem.TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]> = viem.TransactionSerialized<viem.GetTransactionType<transaction>>;
405
551
 
406
- interface WalletState {
552
+ interface WalletState$1 {
407
553
  isAuthenticated: boolean;
408
554
  isConnecting: boolean;
409
555
  isInitialized: boolean;
@@ -417,7 +563,7 @@ interface WalletState {
417
563
  enableTwitter: boolean;
418
564
  enablePhantom: boolean;
419
565
  }
420
- interface WalletContextValue extends WalletState {
566
+ interface WalletContextValue$1 extends WalletState$1 {
421
567
  connect: () => Promise<void>;
422
568
  disconnect: () => void;
423
569
  }
@@ -426,7 +572,32 @@ interface WalletProviderProps {
426
572
  config: WalletProviderConfig;
427
573
  }
428
574
  declare function WalletProvider({ children, config }: WalletProviderProps): react__default.JSX.Element;
429
- declare function useWallet(): WalletContextValue;
575
+ declare function useWallet(): WalletContextValue$1;
576
+
577
+ interface WalletState {
578
+ isAuthenticated: boolean;
579
+ isConnecting: boolean;
580
+ isInitialized: boolean;
581
+ walletInfo: WalletInfo | null;
582
+ wallet: WalletClient | null;
583
+ session: UserSession | null;
584
+ error: string | null;
585
+ enableEmail: boolean;
586
+ enablePhone: boolean;
587
+ enableGoogle: boolean;
588
+ enableTwitter: boolean;
589
+ enablePhantom: boolean;
590
+ }
591
+ interface WalletContextValue extends WalletState {
592
+ connect: () => Promise<void>;
593
+ disconnect: () => void;
594
+ }
595
+ interface WalletProviderBackupProps {
596
+ children: ReactNode;
597
+ config: WalletProviderConfig;
598
+ }
599
+ declare function WalletProviderBackup({ children, config }: WalletProviderBackupProps): react__default.JSX.Element;
600
+ declare function useWalletBackup(): WalletContextValue;
430
601
 
431
602
  declare function useConnect(): {
432
603
  connect: () => Promise<void>;
@@ -441,10 +612,18 @@ declare function useWalletStatus(): {
441
612
  isInitialized: boolean;
442
613
  ready: boolean;
443
614
  };
615
+ declare function useWalletBackupStatus(): {
616
+ isAuthenticated: boolean;
617
+ authenticated: boolean;
618
+ error: string | null;
619
+ session: UserSession | null;
620
+ isInitialized: boolean;
621
+ ready: boolean;
622
+ };
444
623
  declare function useActiveWallet(): {
445
624
  wallet: WalletClient | null;
446
625
  };
447
- declare function useLoginModal({ client, isOpen, onClose, onLogin, isLoading, }: LoginModalProps): {
626
+ declare function useLoginModal({ client, isOpen, onClose, onLogin, isLoading }: LoginModalProps): {
448
627
  email: string;
449
628
  setEmail: react.Dispatch<react.SetStateAction<string>>;
450
629
  emailSent: boolean;
@@ -471,6 +650,7 @@ declare function useLoginModal({ client, isOpen, onClose, onLogin, isLoading, }:
471
650
  wallet_address: string;
472
651
  challenge: string;
473
652
  signature: string;
653
+ isBackup?: boolean;
474
654
  }) => Promise<void>;
475
655
  phone: string;
476
656
  setPhone: react.Dispatch<react.SetStateAction<string>>;
@@ -486,6 +666,7 @@ declare function useLoginModal({ client, isOpen, onClose, onLogin, isLoading, }:
486
666
 
487
667
  declare const STORAGE_STATE_KEY = "embedded_wallet_state";
488
668
  declare const WALLET_TYPE_KEY = "superstack_wallet_type";
669
+ declare const BACKUP_WALLET_TYPE_KEY = "superstack_backup_wallet_type";
489
670
  declare const ACCESS_TOKEN_KEY = "embedded_wallet_access_token";
490
671
  declare const SWITCHED_ACCOUNT_ADDRESS = "switched_account_address";
491
672
  interface StorageState {
@@ -497,13 +678,16 @@ declare class Storage {
497
678
  static saveState(token: string, socials: Social[]): void;
498
679
  static saveAccessToken(token: string): void;
499
680
  static saveWalletType(type: "phantom" | "embedded"): void;
681
+ static saveBackupWalletType(type: "phantom_backup" | "embedded_backup"): void;
500
682
  static saveSwitchedAccountAddress(address: string): void;
501
683
  static getWalletType(): "phantom" | "embedded" | null;
684
+ static getBackupWalletType(): "phantom_backup" | "embedded_backup" | null;
502
685
  static getState(): StorageState | null;
503
686
  static getSocials(): Social[] | null;
504
687
  static getAccessToken(): string | null;
505
688
  static getSwitchedAccountAddress(): string | null;
506
689
  static clear(): void;
690
+ static clearBackup(): void;
507
691
  }
508
692
 
509
693
  declare const theme: {
@@ -615,5 +799,5 @@ declare function useCoinbaseOnramp(): {
615
799
  getCoinbaseOnrampUrl: (amount: number, blockchain?: "solana" | "ethereum", redirectUrl?: string) => Promise<string>;
616
800
  };
617
801
 
618
- export { ACCESS_TOKEN_KEY, Network, STORAGE_STATE_KEY, SWITCHED_ACCOUNT_ADDRESS, SocialType, Storage, VaultId, WALLET_TYPE_KEY, WalletClient, WalletProvider, WalletType, injectStyles, isVersionedTransaction, theme, useActiveWallet, useCoinbaseOnramp, useConnect, useLoginModal, useWallet, useWalletStatus };
619
- export type { AccountInfo, ApiResponse, BuildTransactionRequest, BuildTransactionResponse, CoinbaseOnrampRequest, IModalManager, LoginModalProps, LoginType, MiddleAccount, MiddleAccountRequest, OrderState, SignMessageResponse, SignRequestV1, SignRequestV2, SignTransactionResponse, SignTransactionReturnType, Social, SocialInfo, SupportedTransactionVersions, TransactionOrVersionedTransaction, TransferRequest, UnsignedTx, UserSession, Wallet, WalletInfo, WalletProviderConfig };
802
+ export { ACCESS_TOKEN_KEY, BACKUP_WALLET_TYPE_KEY, BorrowedAsset, CollateralAsset, CrossMarginOperationType, CrossMarginPositionStatus, Network, STORAGE_STATE_KEY, SWITCHED_ACCOUNT_ADDRESS, SocialType, Storage, VaultId, WALLET_TYPE_KEY, WalletClient, WalletProvider, WalletProviderBackup, WalletType, injectStyles, isVersionedTransaction, theme, useActiveWallet, useCoinbaseOnramp, useConnect, useLoginModal, useWallet, useWalletBackup, useWalletBackupStatus, useWalletStatus };
803
+ export type { AccountInfo, ApiResponse, BigDecimalString, BorrowedAssetGeneralInfo, BuildTransactionRequest, BuildTransactionResponse, CoinbaseOnrampRequest, CollateralAssetGeneralInfo, CollateralAssetInfo, CrossMarginAdjustMarginRequest, CrossMarginAdjustMarginResponse, CrossMarginBorrowQuoteRequest, CrossMarginBorrowQuoteResponse, CrossMarginBorrowRequest, CrossMarginBorrowResponse, CrossMarginGeneralInfoResponse, CrossMarginRepayQuoteRequest, CrossMarginRepayQuoteResponse, CrossMarginRepayRequest, CrossMarginRepayResponse, IModalManager, LoginModalProps, LoginType, MiddleAccount, MiddleAccountRequest, OrderState, SignMessageResponse, SignRequestV1, SignRequestV2, SignTransactionResponse, SignTransactionReturnType, Social, SocialInfo, SupportedTransactionVersions, TransactionOrVersionedTransaction, TransferRequest, UnsignedTx, UserClosedPositionInfo, UserHistoryResponse, UserOpenPositionInfo, UserOpenPositionsResponse, UserOperationInfo, UserSession, Wallet, WalletInfo, WalletProviderConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superstack-wallet-sdk",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "A wallet SDK for superstack",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",