@pear-protocol/symmio-client 0.1.5 → 0.1.6

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.
@@ -44,6 +44,22 @@ type Account = {
44
44
  accountAddress: Address;
45
45
  name: string;
46
46
  };
47
+ type AccountBalance = {
48
+ collateralBalance: bigint;
49
+ allocatedBalance: bigint;
50
+ availableBalance: bigint;
51
+ lockedCVA: bigint;
52
+ lockedLF: bigint;
53
+ lockedPartyAMM: bigint;
54
+ lockedPartyBMM: bigint;
55
+ pendingLockedCVA: bigint;
56
+ pendingLockedLF: bigint;
57
+ pendingLockedPartyAMM: bigint;
58
+ pendingLockedPartyBMM: bigint;
59
+ positionsCount: number;
60
+ pendingCount: number;
61
+ nonces: number;
62
+ };
47
63
 
48
64
  type SchnorrSign = {
49
65
  signature: bigint;
@@ -246,6 +262,11 @@ type RevokeAccessParams = {
246
262
  target: Address;
247
263
  selectors: Hex[];
248
264
  };
265
+ type DelegatedAccessParams = {
266
+ account: Address;
267
+ target: Address;
268
+ selector: Hex;
269
+ };
249
270
 
250
271
  /**
251
272
  * SymmioSDK — Main client for Symmio protocol.
@@ -362,6 +383,8 @@ declare class SymmioSDK {
362
383
  proposeRevoke: (params: ProposeRevokeParams) => Promise<`0x${string}`>;
363
384
  /** Revoke delegated access (after cooldown). */
364
385
  revokeAccess: (params: RevokeAccessParams) => Promise<`0x${string}`>;
386
+ /** Reads whether a selector is delegated to a target for a sub-account. */
387
+ hasAccess: (params: DelegatedAccessParams) => Promise<boolean>;
365
388
  };
366
389
  get signature(): {
367
390
  signTerms: () => Promise<`0x${string}`>;
@@ -389,6 +412,12 @@ declare class SymmioSDK {
389
412
  /** Fetches the list of open instant close requests for an account. */
390
413
  getOpenCloses: (account: Address, accessToken: string) => Promise<unknown[]>;
391
414
  };
415
+ get stats(): {
416
+ /** Reads partyA statistics (balances, locks) from the Diamond contract. */
417
+ getPartyAStats: (partyA: Address) => Promise<AccountBalance>;
418
+ /** Calculates available margin for placing orders given uPNL. */
419
+ calculateAvailableForOrder: (stats: AccountBalance, upnl: bigint) => bigint;
420
+ };
392
421
  getQuoteSig(partyA: Address, symbolId: number): Promise<MuonSingleUpnlAndPriceSig>;
393
422
  getDeallocateSig(partyA: Address): Promise<MuonSingleUpnlSig>;
394
423
  }
@@ -416,6 +445,55 @@ declare function useSymmAuth(): {
416
445
  refresh: (accountAddress?: viem.Address) => Promise<string | null>;
417
446
  };
418
447
 
448
+ type UseSymmDelegationParams = {
449
+ accountAddress?: Address;
450
+ target?: Address;
451
+ selectors?: readonly Hex[];
452
+ enabled?: boolean;
453
+ };
454
+ type SymmDelegationState = {
455
+ hasAccess: boolean;
456
+ account: Address | null;
457
+ target: Address | null;
458
+ selectors: readonly Hex[];
459
+ accessBySelector: Record<Hex, boolean>;
460
+ openAccess?: boolean;
461
+ closeAccess?: boolean;
462
+ };
463
+ declare function useSymmDelegation(params?: UseSymmDelegationParams): _tanstack_react_query.UseQueryResult<SymmDelegationState, Error>;
464
+
465
+ type SymmInstantTradeActionArgs = {
466
+ symmCoreClient: SymmSDK;
467
+ accessToken: string;
468
+ accountAddress: Address;
469
+ };
470
+ type SymmInstantTradeRequest = {
471
+ accountAddress?: Address;
472
+ target?: Address;
473
+ selectors?: readonly Hex[];
474
+ action: (args: SymmInstantTradeActionArgs) => Promise<unknown>;
475
+ invalidatePositionsOnSuccess?: boolean;
476
+ };
477
+ declare function useSymmInstantTrade(params?: {
478
+ accountAddress?: Address;
479
+ target?: Address;
480
+ selectors?: readonly Hex[];
481
+ enabled?: boolean;
482
+ }): {
483
+ delegation: _tanstack_react_query.UseQueryResult<SymmDelegationState, Error>;
484
+ ensureReady: _tanstack_react_query.UseMutationResult<{
485
+ accessToken: string;
486
+ accountAddress: `0x${string}`;
487
+ target: `0x${string}`;
488
+ selectors: readonly `0x${string}`[];
489
+ }, Error, {
490
+ accountAddress?: Address;
491
+ target?: Address;
492
+ selectors?: readonly Hex[];
493
+ } | undefined, unknown>;
494
+ execute: _tanstack_react_query.UseMutationResult<unknown, Error, SymmInstantTradeRequest, unknown>;
495
+ };
496
+
419
497
  declare function useSymmAccounts(userAddress?: Address): {
420
498
  accounts: Account[];
421
499
  count: number;
@@ -483,6 +561,50 @@ declare function useSymmSignature(userAddress?: Address): {
483
561
  signTerms: _tanstack_react_query.UseMutationResult<void, Error, void, unknown>;
484
562
  };
485
563
 
564
+ declare function useSymmAvailableMargin(params: {
565
+ accountAddress?: Address;
566
+ upnl?: bigint;
567
+ }): {
568
+ availableForOrder: bigint | null;
569
+ stats: {
570
+ upnl: bigint;
571
+ availableForOrder: bigint;
572
+ collateralBalance: bigint;
573
+ allocatedBalance: bigint;
574
+ availableBalance: bigint;
575
+ lockedCVA: bigint;
576
+ lockedLF: bigint;
577
+ lockedPartyAMM: bigint;
578
+ lockedPartyBMM: bigint;
579
+ pendingLockedCVA: bigint;
580
+ pendingLockedLF: bigint;
581
+ pendingLockedPartyAMM: bigint;
582
+ pendingLockedPartyBMM: bigint;
583
+ positionsCount: number;
584
+ pendingCount: number;
585
+ nonces: number;
586
+ } | null;
587
+ isLoading: boolean;
588
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
589
+ upnl: bigint;
590
+ availableForOrder: bigint;
591
+ collateralBalance: bigint;
592
+ allocatedBalance: bigint;
593
+ availableBalance: bigint;
594
+ lockedCVA: bigint;
595
+ lockedLF: bigint;
596
+ lockedPartyAMM: bigint;
597
+ lockedPartyBMM: bigint;
598
+ pendingLockedCVA: bigint;
599
+ pendingLockedLF: bigint;
600
+ pendingLockedPartyAMM: bigint;
601
+ pendingLockedPartyBMM: bigint;
602
+ positionsCount: number;
603
+ pendingCount: number;
604
+ nonces: number;
605
+ }, Error>>;
606
+ };
607
+
486
608
  declare function useSymmBalances(params: {
487
609
  userAddress?: Address;
488
610
  chainId?: number;
@@ -754,8 +876,10 @@ declare const symmKeys: {
754
876
  portfolio: (address?: Address, chainId?: number) => readonly ["symm", "portfolio", `0x${string}` | undefined, number | undefined];
755
877
  notifications: (address?: Address, chainId?: number) => readonly ["symm", "notifications", `0x${string}` | undefined, number | undefined];
756
878
  unreadCount: (address?: Address, chainId?: number) => readonly ["symm", "unreadCount", `0x${string}` | undefined, number | undefined];
879
+ availableMargin: (address?: Address, chainId?: number) => readonly ["symm", "availableMargin", `0x${string}` | undefined, number | undefined];
880
+ delegation: (account?: Address, target?: Address, selectors?: readonly Hex[], chainId?: number) => readonly ["symm", "delegation", `0x${string}` | undefined, `0x${string}` | undefined, readonly `0x${string}`[] | undefined, number | undefined];
757
881
  };
758
882
 
759
883
  declare function getSymmErrorMessage(error: unknown): string;
760
884
 
761
- export { type SymmChartSelection, type SymmChartSelectionInput, type SymmChartTokenSelection, type SymmContextValue, type SymmPerformanceOverlay, SymmProvider, type SymmProviderProps, type SymmTokenMetadata, type UseSymmChartCandlesReturn, type UseSymmHedgerMarketsParams, type UseSymmTokenSelectionMetadataReturn, getSymmErrorMessage, symmKeys, useSymmAccounts, useSymmApproval, useSymmAuth, useSymmBalances, useSymmChartCandles, useSymmChartSelection, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDeposit, useSymmFunding, useSymmHedgerMarkets, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTrade, useSymmTradeHistory, useSymmTwap, useSymmWithdraw, useSymmWs, useSymmioClient };
885
+ export { type SymmChartSelection, type SymmChartSelectionInput, type SymmChartTokenSelection, type SymmContextValue, type SymmDelegationState, type SymmInstantTradeActionArgs, type SymmInstantTradeRequest, type SymmPerformanceOverlay, SymmProvider, type SymmProviderProps, type SymmTokenMetadata, type UseSymmChartCandlesReturn, type UseSymmDelegationParams, type UseSymmHedgerMarketsParams, type UseSymmTokenSelectionMetadataReturn, getSymmErrorMessage, symmKeys, useSymmAccounts, useSymmApproval, useSymmAuth, useSymmAvailableMargin, useSymmBalances, useSymmChartCandles, useSymmChartSelection, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDelegation, useSymmDeposit, useSymmFunding, useSymmHedgerMarkets, useSymmInstantTrade, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTrade, useSymmTradeHistory, useSymmTwap, useSymmWithdraw, useSymmWs, useSymmioClient };
@@ -44,6 +44,22 @@ type Account = {
44
44
  accountAddress: Address;
45
45
  name: string;
46
46
  };
47
+ type AccountBalance = {
48
+ collateralBalance: bigint;
49
+ allocatedBalance: bigint;
50
+ availableBalance: bigint;
51
+ lockedCVA: bigint;
52
+ lockedLF: bigint;
53
+ lockedPartyAMM: bigint;
54
+ lockedPartyBMM: bigint;
55
+ pendingLockedCVA: bigint;
56
+ pendingLockedLF: bigint;
57
+ pendingLockedPartyAMM: bigint;
58
+ pendingLockedPartyBMM: bigint;
59
+ positionsCount: number;
60
+ pendingCount: number;
61
+ nonces: number;
62
+ };
47
63
 
48
64
  type SchnorrSign = {
49
65
  signature: bigint;
@@ -246,6 +262,11 @@ type RevokeAccessParams = {
246
262
  target: Address;
247
263
  selectors: Hex[];
248
264
  };
265
+ type DelegatedAccessParams = {
266
+ account: Address;
267
+ target: Address;
268
+ selector: Hex;
269
+ };
249
270
 
250
271
  /**
251
272
  * SymmioSDK — Main client for Symmio protocol.
@@ -362,6 +383,8 @@ declare class SymmioSDK {
362
383
  proposeRevoke: (params: ProposeRevokeParams) => Promise<`0x${string}`>;
363
384
  /** Revoke delegated access (after cooldown). */
364
385
  revokeAccess: (params: RevokeAccessParams) => Promise<`0x${string}`>;
386
+ /** Reads whether a selector is delegated to a target for a sub-account. */
387
+ hasAccess: (params: DelegatedAccessParams) => Promise<boolean>;
365
388
  };
366
389
  get signature(): {
367
390
  signTerms: () => Promise<`0x${string}`>;
@@ -389,6 +412,12 @@ declare class SymmioSDK {
389
412
  /** Fetches the list of open instant close requests for an account. */
390
413
  getOpenCloses: (account: Address, accessToken: string) => Promise<unknown[]>;
391
414
  };
415
+ get stats(): {
416
+ /** Reads partyA statistics (balances, locks) from the Diamond contract. */
417
+ getPartyAStats: (partyA: Address) => Promise<AccountBalance>;
418
+ /** Calculates available margin for placing orders given uPNL. */
419
+ calculateAvailableForOrder: (stats: AccountBalance, upnl: bigint) => bigint;
420
+ };
392
421
  getQuoteSig(partyA: Address, symbolId: number): Promise<MuonSingleUpnlAndPriceSig>;
393
422
  getDeallocateSig(partyA: Address): Promise<MuonSingleUpnlSig>;
394
423
  }
@@ -416,6 +445,55 @@ declare function useSymmAuth(): {
416
445
  refresh: (accountAddress?: viem.Address) => Promise<string | null>;
417
446
  };
418
447
 
448
+ type UseSymmDelegationParams = {
449
+ accountAddress?: Address;
450
+ target?: Address;
451
+ selectors?: readonly Hex[];
452
+ enabled?: boolean;
453
+ };
454
+ type SymmDelegationState = {
455
+ hasAccess: boolean;
456
+ account: Address | null;
457
+ target: Address | null;
458
+ selectors: readonly Hex[];
459
+ accessBySelector: Record<Hex, boolean>;
460
+ openAccess?: boolean;
461
+ closeAccess?: boolean;
462
+ };
463
+ declare function useSymmDelegation(params?: UseSymmDelegationParams): _tanstack_react_query.UseQueryResult<SymmDelegationState, Error>;
464
+
465
+ type SymmInstantTradeActionArgs = {
466
+ symmCoreClient: SymmSDK;
467
+ accessToken: string;
468
+ accountAddress: Address;
469
+ };
470
+ type SymmInstantTradeRequest = {
471
+ accountAddress?: Address;
472
+ target?: Address;
473
+ selectors?: readonly Hex[];
474
+ action: (args: SymmInstantTradeActionArgs) => Promise<unknown>;
475
+ invalidatePositionsOnSuccess?: boolean;
476
+ };
477
+ declare function useSymmInstantTrade(params?: {
478
+ accountAddress?: Address;
479
+ target?: Address;
480
+ selectors?: readonly Hex[];
481
+ enabled?: boolean;
482
+ }): {
483
+ delegation: _tanstack_react_query.UseQueryResult<SymmDelegationState, Error>;
484
+ ensureReady: _tanstack_react_query.UseMutationResult<{
485
+ accessToken: string;
486
+ accountAddress: `0x${string}`;
487
+ target: `0x${string}`;
488
+ selectors: readonly `0x${string}`[];
489
+ }, Error, {
490
+ accountAddress?: Address;
491
+ target?: Address;
492
+ selectors?: readonly Hex[];
493
+ } | undefined, unknown>;
494
+ execute: _tanstack_react_query.UseMutationResult<unknown, Error, SymmInstantTradeRequest, unknown>;
495
+ };
496
+
419
497
  declare function useSymmAccounts(userAddress?: Address): {
420
498
  accounts: Account[];
421
499
  count: number;
@@ -483,6 +561,50 @@ declare function useSymmSignature(userAddress?: Address): {
483
561
  signTerms: _tanstack_react_query.UseMutationResult<void, Error, void, unknown>;
484
562
  };
485
563
 
564
+ declare function useSymmAvailableMargin(params: {
565
+ accountAddress?: Address;
566
+ upnl?: bigint;
567
+ }): {
568
+ availableForOrder: bigint | null;
569
+ stats: {
570
+ upnl: bigint;
571
+ availableForOrder: bigint;
572
+ collateralBalance: bigint;
573
+ allocatedBalance: bigint;
574
+ availableBalance: bigint;
575
+ lockedCVA: bigint;
576
+ lockedLF: bigint;
577
+ lockedPartyAMM: bigint;
578
+ lockedPartyBMM: bigint;
579
+ pendingLockedCVA: bigint;
580
+ pendingLockedLF: bigint;
581
+ pendingLockedPartyAMM: bigint;
582
+ pendingLockedPartyBMM: bigint;
583
+ positionsCount: number;
584
+ pendingCount: number;
585
+ nonces: number;
586
+ } | null;
587
+ isLoading: boolean;
588
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
589
+ upnl: bigint;
590
+ availableForOrder: bigint;
591
+ collateralBalance: bigint;
592
+ allocatedBalance: bigint;
593
+ availableBalance: bigint;
594
+ lockedCVA: bigint;
595
+ lockedLF: bigint;
596
+ lockedPartyAMM: bigint;
597
+ lockedPartyBMM: bigint;
598
+ pendingLockedCVA: bigint;
599
+ pendingLockedLF: bigint;
600
+ pendingLockedPartyAMM: bigint;
601
+ pendingLockedPartyBMM: bigint;
602
+ positionsCount: number;
603
+ pendingCount: number;
604
+ nonces: number;
605
+ }, Error>>;
606
+ };
607
+
486
608
  declare function useSymmBalances(params: {
487
609
  userAddress?: Address;
488
610
  chainId?: number;
@@ -754,8 +876,10 @@ declare const symmKeys: {
754
876
  portfolio: (address?: Address, chainId?: number) => readonly ["symm", "portfolio", `0x${string}` | undefined, number | undefined];
755
877
  notifications: (address?: Address, chainId?: number) => readonly ["symm", "notifications", `0x${string}` | undefined, number | undefined];
756
878
  unreadCount: (address?: Address, chainId?: number) => readonly ["symm", "unreadCount", `0x${string}` | undefined, number | undefined];
879
+ availableMargin: (address?: Address, chainId?: number) => readonly ["symm", "availableMargin", `0x${string}` | undefined, number | undefined];
880
+ delegation: (account?: Address, target?: Address, selectors?: readonly Hex[], chainId?: number) => readonly ["symm", "delegation", `0x${string}` | undefined, `0x${string}` | undefined, readonly `0x${string}`[] | undefined, number | undefined];
757
881
  };
758
882
 
759
883
  declare function getSymmErrorMessage(error: unknown): string;
760
884
 
761
- export { type SymmChartSelection, type SymmChartSelectionInput, type SymmChartTokenSelection, type SymmContextValue, type SymmPerformanceOverlay, SymmProvider, type SymmProviderProps, type SymmTokenMetadata, type UseSymmChartCandlesReturn, type UseSymmHedgerMarketsParams, type UseSymmTokenSelectionMetadataReturn, getSymmErrorMessage, symmKeys, useSymmAccounts, useSymmApproval, useSymmAuth, useSymmBalances, useSymmChartCandles, useSymmChartSelection, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDeposit, useSymmFunding, useSymmHedgerMarkets, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTrade, useSymmTradeHistory, useSymmTwap, useSymmWithdraw, useSymmWs, useSymmioClient };
885
+ export { type SymmChartSelection, type SymmChartSelectionInput, type SymmChartTokenSelection, type SymmContextValue, type SymmDelegationState, type SymmInstantTradeActionArgs, type SymmInstantTradeRequest, type SymmPerformanceOverlay, SymmProvider, type SymmProviderProps, type SymmTokenMetadata, type UseSymmChartCandlesReturn, type UseSymmDelegationParams, type UseSymmHedgerMarketsParams, type UseSymmTokenSelectionMetadataReturn, getSymmErrorMessage, symmKeys, useSymmAccounts, useSymmApproval, useSymmAuth, useSymmAvailableMargin, useSymmBalances, useSymmChartCandles, useSymmChartSelection, useSymmCollateral, useSymmContext, useSymmCoreClient, useSymmDelegation, useSymmDeposit, useSymmFunding, useSymmHedgerMarkets, useSymmInstantTrade, useSymmMarkets, useSymmNotifications, useSymmOpenOrders, useSymmPerformanceOverlays, useSymmPortfolio, useSymmPositions, useSymmSignature, useSymmTokenSelectionMetadata, useSymmTpsl, useSymmTrade, useSymmTradeHistory, useSymmTwap, useSymmWithdraw, useSymmWs, useSymmioClient };