@glamsystems/glam-sdk 1.0.12 → 1.0.13-test

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.
Files changed (110) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1 -1
  3. package/index.cjs.js +1 -57320
  4. package/index.esm.js +1 -57081
  5. package/package.json +26 -15
  6. package/src/assets.d.ts +10 -17
  7. package/src/client/access.d.ts +13 -0
  8. package/src/client/base.d.ts +30 -7
  9. package/src/client/bridge.d.ts +183 -0
  10. package/src/client/bridgeRegistry.d.ts +32 -0
  11. package/src/client/epi.d.ts +78 -0
  12. package/src/client/fees.d.ts +4 -0
  13. package/src/client/invest.d.ts +1 -1
  14. package/src/client/jupiter.d.ts +27 -20
  15. package/src/client/loopscale.d.ts +84 -0
  16. package/src/client/mint.d.ts +54 -1
  17. package/src/client/price.d.ts +26 -39
  18. package/src/client.d.ts +9 -5
  19. package/src/constants.d.ts +11 -7
  20. package/src/deser/index.d.ts +1 -1
  21. package/src/deser/integrationPolicies.d.ts +30 -20
  22. package/src/deser/tokenAclLayouts.d.ts +67 -0
  23. package/src/error.d.ts +2 -1
  24. package/src/glamExports.d.ts +1351 -1546
  25. package/src/globalConfig.d.ts +27 -0
  26. package/src/index.d.ts +5 -1
  27. package/src/models/state.d.ts +2 -0
  28. package/src/utils/accounts.d.ts +9 -1
  29. package/src/utils/bitmask.d.ts +3 -0
  30. package/src/utils/common.d.ts +2 -0
  31. package/src/utils/glamPDAs.d.ts +6 -0
  32. package/src/utils/index.d.ts +0 -1
  33. package/src/utils/pkmap.d.ts +23 -18
  34. package/src/utils/positionCategorizer.d.ts +3 -21
  35. package/target/idl/ext_bridge-staging.json +2379 -0
  36. package/target/idl/ext_bridge.json +2379 -0
  37. package/target/idl/ext_cctp.json +1 -1
  38. package/target/idl/ext_drift.json +1613 -142
  39. package/target/idl/ext_epi-staging.json +2169 -0
  40. package/target/idl/ext_epi.json +2169 -0
  41. package/target/idl/ext_kamino-staging.json +1 -1
  42. package/target/idl/ext_kamino.json +109 -1
  43. package/target/idl/{ext_drift-staging.json → ext_loopscale-staging.json} +986 -1438
  44. package/target/idl/ext_loopscale.json +3541 -0
  45. package/target/idl/ext_marinade-staging.json +1587 -0
  46. package/target/idl/ext_spl-staging.json +1 -1
  47. package/target/idl/ext_spl.json +1 -1
  48. package/target/idl/glam_config.json +78 -9
  49. package/target/idl/glam_mint-staging.json +3002 -1244
  50. package/target/idl/glam_mint.json +239 -8
  51. package/target/idl/glam_policies.json +2 -7
  52. package/target/idl/glam_protocol-staging.json +187 -266
  53. package/target/idl/glam_protocol.json +217 -114
  54. package/target/idl/mock_layerzero_endpoint.json +144 -0
  55. package/target/idl/mock_layerzero_oft.json +155 -0
  56. package/target/types/ext_bridge-staging.d.ts +2385 -0
  57. package/target/types/ext_bridge-staging.ts +2385 -0
  58. package/target/types/ext_bridge.d.ts +2385 -0
  59. package/target/types/ext_bridge.ts +2385 -0
  60. package/target/types/ext_cctp.d.ts +1 -1
  61. package/target/types/ext_cctp.ts +1 -1
  62. package/target/types/ext_drift.d.ts +1609 -138
  63. package/target/types/ext_drift.ts +1613 -142
  64. package/target/types/ext_epi-staging.d.ts +2175 -0
  65. package/target/types/ext_epi-staging.ts +2175 -0
  66. package/target/types/ext_epi.d.ts +2175 -0
  67. package/target/types/ext_epi.ts +2175 -0
  68. package/target/types/ext_kamino-staging.d.ts +3433 -0
  69. package/target/types/ext_kamino-staging.ts +1 -1
  70. package/target/types/ext_kamino.d.ts +109 -1
  71. package/target/types/ext_kamino.ts +109 -1
  72. package/target/types/ext_loopscale-staging.d.ts +3547 -0
  73. package/target/types/{ext_drift-staging.ts → ext_loopscale-staging.ts} +988 -1440
  74. package/target/types/ext_loopscale.d.ts +3547 -0
  75. package/target/types/ext_loopscale.ts +3547 -0
  76. package/target/types/ext_marinade-staging.d.ts +1593 -0
  77. package/target/types/ext_marinade-staging.ts +1593 -0
  78. package/target/types/{ext_offchain.d.ts → ext_spl-staging.d.ts} +219 -19
  79. package/target/types/ext_spl-staging.ts +1 -1
  80. package/target/types/ext_spl.d.ts +1 -1
  81. package/target/types/ext_spl.ts +1 -1
  82. package/target/types/ext_stake_pool-staging.d.ts +1622 -0
  83. package/target/types/glam_config.d.ts +78 -9
  84. package/target/types/glam_config.ts +78 -9
  85. package/target/types/glam_mint-staging.d.ts +7856 -0
  86. package/target/types/glam_mint-staging.ts +3002 -1244
  87. package/target/types/glam_mint.d.ts +239 -8
  88. package/target/types/glam_mint.ts +239 -8
  89. package/target/types/glam_policies.d.ts +477 -0
  90. package/target/types/glam_policies.ts +2 -7
  91. package/target/types/glam_protocol-staging.d.ts +3292 -0
  92. package/target/types/glam_protocol-staging.ts +187 -266
  93. package/target/types/glam_protocol.d.ts +217 -114
  94. package/target/types/glam_protocol.ts +217 -114
  95. package/target/types/mock_layerzero_endpoint.d.ts +150 -0
  96. package/target/types/mock_layerzero_endpoint.ts +150 -0
  97. package/target/types/mock_layerzero_oft.d.ts +161 -0
  98. package/target/types/mock_layerzero_oft.ts +161 -0
  99. package/src/client/drift/index.d.ts +0 -2
  100. package/src/client/drift/protocol-v2.d.ts +0 -93
  101. package/src/client/drift/vaults.d.ts +0 -60
  102. package/src/deser/driftLayouts.d.ts +0 -217
  103. package/src/react/cluster-provider.d.ts +0 -22
  104. package/src/react/glam.d.ts +0 -51
  105. package/src/react/index.d.ts +0 -5
  106. package/src/react/query-keys.d.ts +0 -40
  107. package/src/react/useVaultBalanceSubscription.d.ts +0 -17
  108. package/src/utils/drift/index.d.ts +0 -2
  109. package/src/utils/drift/orderParams.d.ts +0 -28
  110. package/src/utils/drift/types.d.ts +0 -522
@@ -1,217 +0,0 @@
1
- import { struct } from "@coral-xyz/borsh";
2
- import { BN } from "@coral-xyz/anchor";
3
- import { PublicKey } from "@solana/web3.js";
4
- import { Decodable } from "./base";
5
- import { PkMap } from "../utils";
6
- import { MarginMode, MarketType, OracleSource, Order, SpotBalanceType } from "../utils/drift/types";
7
- export declare class SpotPosition {
8
- marketIndex: number;
9
- balanceType: SpotBalanceType;
10
- scaledBalance: BN;
11
- openOrders: number;
12
- openBids: BN;
13
- openAsks: BN;
14
- cumulativeDeposits: BN;
15
- constructor(data: any);
16
- get marketPda(): PublicKey;
17
- calcBalance(decimals: number, cumulativeDepositInterest: BN, cumulativeBorrowInterest: BN): {
18
- amount: number;
19
- uiAmount: number;
20
- };
21
- calcBalanceBn(decimals: number, cumulativeDepositInterest: BN, cumulativeBorrowInterest: BN): BN;
22
- _interest(cumulativeDepositInterest: BN, cumulativeBorrowInterest: BN): BN;
23
- get direction(): "borrow" | "deposit";
24
- }
25
- export declare class PerpPosition {
26
- baseAssetAmount: BN;
27
- lastCumulativeFundingRate: BN;
28
- marketIndex: number;
29
- quoteAssetAmount: BN;
30
- quoteEntryAmount: BN;
31
- quoteBreakEvenAmount: BN;
32
- openOrders: number;
33
- openBids: BN;
34
- openAsks: BN;
35
- settledPnl: BN;
36
- lpShares: BN;
37
- remainderBaseAssetAmount: number;
38
- lastBaseAssetAmountPerLp: BN;
39
- lastQuoteAssetAmountPerLp: BN;
40
- perLpBase: number;
41
- constructor(data: any);
42
- get marketPda(): PublicKey;
43
- baseAssetValue(oraclePrice: BN): BN;
44
- unrealizedPnl(oraclePrice: BN): BN;
45
- getUsdValueScaled(oraclePrice: BN, cumulativeFundingRateLong: BN, cumulativeFundingRateShort: BN): BN;
46
- calcFundingPayment(cumulativeFundingRateLong: BN, cumulativeFundingRateShort: BN): BN;
47
- }
48
- export declare class DriftVaultDepositor extends Decodable {
49
- discriminator: number[];
50
- vault: PublicKey;
51
- pubkey: PublicKey;
52
- authority: PublicKey;
53
- vaultShares: BN;
54
- lastWithdrawRequest: {
55
- shares: BN;
56
- value: BN;
57
- ts: BN;
58
- };
59
- lastValidTs: BN;
60
- netDeposits: BN;
61
- totalDeposits: BN;
62
- totalWithdraws: BN;
63
- cumulativeProfitShareAmount: BN;
64
- profitShareFeePaid: BN;
65
- vaultSharesBase: number;
66
- lastFuelUpdateTs: number;
67
- cumulativeFuelPerShareAmount: BN;
68
- fuelAmount: BN;
69
- padding: BN[];
70
- static _layout: any;
71
- get netShares(): BN;
72
- /** Rebase shares to match the vault's current shares base. */
73
- private rebaseShares;
74
- /** Net shares rebased to the vault's current shares base. */
75
- netSharesRebased(vaultSharesBase: number): BN;
76
- }
77
- export declare class DriftVault extends Decodable {
78
- discriminator: number[];
79
- nameBytes: number[];
80
- pubkey: PublicKey;
81
- manager: PublicKey;
82
- tokenAccount: PublicKey;
83
- userStats: PublicKey;
84
- user: PublicKey;
85
- delegate: PublicKey;
86
- liquidationDelegate: PublicKey;
87
- userShares: BN;
88
- totalShares: BN;
89
- lastFeeUpdateTs: BN;
90
- liquidationStartTs: BN;
91
- redeemPeriod: BN;
92
- totalWithdrawRequested: BN;
93
- maxTokens: BN;
94
- managementFee: BN;
95
- initTs: BN;
96
- netDeposits: BN;
97
- managerNetDeposits: BN;
98
- totalDeposits: BN;
99
- totalWithdraws: BN;
100
- managerTotalDeposits: BN;
101
- managerTotalWithdraws: BN;
102
- managerTotalFee: BN;
103
- managerTotalProfitShare: BN;
104
- minDepositAmount: BN;
105
- lastManagerWithdrawRequest: {
106
- shares: BN;
107
- amount: BN;
108
- ts: BN;
109
- };
110
- sharesBase: number;
111
- profitShare: number;
112
- hurdleRate: number;
113
- spotMarketIndex: number;
114
- bump: number;
115
- permissioned: boolean;
116
- vaultProtocol: boolean;
117
- fuelDistributionMode: number;
118
- feeUpdateStatus: number;
119
- padding1: number;
120
- lastCumulativeFuelPerShareTs: number;
121
- cumulativeFuelPerShare: BN;
122
- cumulativeFuel: BN;
123
- managerBorrowedValue: BN;
124
- padding: BN[];
125
- static _layout: any;
126
- get name(): string;
127
- marketPda(marketType: MarketType, marketIndex: number): PublicKey;
128
- aum(spotPositions: SpotPosition[], perpPositions: PerpPosition[], spotMarketsMap: PkMap<DriftSpotMarket>, perpMarketsMap: PkMap<DriftPerpMarket>): BN;
129
- getBaseAsset(spotMarketsMap: PkMap<DriftSpotMarket>): {
130
- mint: PublicKey;
131
- decimals: number;
132
- };
133
- aumInBaseAsset(spotPositions: SpotPosition[], perpPositions: PerpPosition[], spotMarketsMap: PkMap<DriftSpotMarket>, perpMarketsMap: PkMap<DriftPerpMarket>): BN;
134
- }
135
- export declare class DriftUser {
136
- _address: PublicKey;
137
- authority: PublicKey;
138
- delegate: PublicKey;
139
- nameBytes: number[];
140
- subAccountId: number;
141
- spotPositions: SpotPosition[];
142
- perpPositions: PerpPosition[];
143
- orders: Order[];
144
- status: number;
145
- nextLiquidationId: number;
146
- nextOrderId: number;
147
- maxMarginRatio: number;
148
- lastAddPerpLpSharesTs: BN;
149
- settledPerpPnl: BN;
150
- totalDeposits: BN;
151
- totalWithdraws: BN;
152
- totalSocialLoss: BN;
153
- cumulativePerpFunding: BN;
154
- cumulativeSpotFees: BN;
155
- liquidationMarginFreed: BN;
156
- lastActiveSlot: BN;
157
- isMarginTradingEnabled: boolean;
158
- idle: boolean;
159
- openOrders: number;
160
- hasOpenOrder: boolean;
161
- openAuctions: number;
162
- hasOpenAuction: boolean;
163
- lastFuelBonusUpdateTs: number;
164
- marginMode: MarginMode;
165
- poolId: number;
166
- static decode(address: PublicKey, buffer: Buffer): DriftUser;
167
- get name(): string;
168
- getAddress(): PublicKey;
169
- }
170
- export declare class DriftSpotMarket extends Decodable {
171
- discriminator: number[];
172
- marketPda: PublicKey;
173
- oracle: PublicKey;
174
- lastOraclePrice: BN;
175
- mint: PublicKey;
176
- vault: PublicKey;
177
- nameBytes: number[];
178
- padding1: number[];
179
- cumulativeDepositInterest: BN;
180
- cumulativeBorrowInterest: BN;
181
- padding2: number[];
182
- decimals: number;
183
- marketIndex: number;
184
- padding3: number;
185
- oracleSourceOrd: number;
186
- padding4: number[];
187
- tokenProgram: number;
188
- poolId: number;
189
- padding5: number[];
190
- static _layout: any;
191
- get name(): string;
192
- get oracleSource(): OracleSource;
193
- get tokenProgramId(): PublicKey;
194
- }
195
- export declare class DriftPerpMarket extends Decodable {
196
- discriminator: number[];
197
- marketPda: PublicKey;
198
- oracle: PublicKey;
199
- lastOraclePrice: BN;
200
- cumulativeFundingRateLong: BN;
201
- cumulativeFundingRateShort: BN;
202
- padding1: number[];
203
- oracleSourceOrd: number;
204
- padding2: number[];
205
- nameBytes: number[];
206
- padding3: number[];
207
- marketIndex: number;
208
- padding4: number[];
209
- quoteSpotMarketIndex: number;
210
- static decode<T extends Decodable>(this: {
211
- new (): T;
212
- _layout: ReturnType<typeof struct>;
213
- }, address: PublicKey, buffer: Buffer): T;
214
- static _layout: any;
215
- get name(): string;
216
- get oracleSource(): OracleSource;
217
- }
@@ -1,22 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { ClusterNetwork } from "../clientConfig";
3
- export interface Cluster {
4
- name: string;
5
- endpoint: string;
6
- network?: ClusterNetwork;
7
- active?: boolean;
8
- }
9
- interface ClusterProviderContext {
10
- cluster: Cluster;
11
- clusters: Cluster[];
12
- addCluster: (cluster: Cluster) => void;
13
- deleteCluster: (cluster: Cluster) => void;
14
- setCluster: (cluster: Cluster) => void;
15
- getExplorerUrl(path: string): string;
16
- }
17
- export declare function ClusterProvider({ children }: {
18
- children: ReactNode;
19
- }): import("react/jsx-runtime").JSX.Element;
20
- export declare function useCluster(): ClusterProviderContext;
21
- export declare function getClusterUrlParam(cluster: Cluster): string;
22
- export {};
@@ -1,51 +0,0 @@
1
- import type { DelegateAcl, StateModel, IntegrationAcl } from "../models";
2
- import { GlamClient } from "../client";
3
- import { PublicKey } from "@solana/web3.js";
4
- import { DriftMarketConfigs } from "../client/drift";
5
- import { TokenAccount } from "../client/base";
6
- import { JupTokenList } from "../utils/jupiterApi";
7
- import { VaultHoldings } from "../client/price";
8
- import { DriftUser } from "../deser";
9
- declare global {
10
- interface Window {
11
- glam: GlamClient;
12
- PublicKey: any;
13
- BN: any;
14
- }
15
- }
16
- interface GlamProviderContext {
17
- glamClient: GlamClient;
18
- vault: Vault;
19
- vaultHoldings?: VaultHoldings;
20
- activeGlamState?: GlamStateCache;
21
- glamStatesList: GlamStateCache[];
22
- delegateAcls: DelegateAcl[];
23
- integrationAcls: IntegrationAcl[];
24
- allGlamStates: StateModel[];
25
- jupTokenList?: JupTokenList;
26
- driftMarketConfigs?: DriftMarketConfigs;
27
- wsConnected: boolean;
28
- setActiveGlamState: (f: GlamStateCache) => void;
29
- refresh: () => Promise<void>;
30
- refetchGlamStates: () => Promise<void>;
31
- }
32
- export interface Vault {
33
- pubkey: PublicKey;
34
- balanceLamports: number;
35
- uiAmount: number;
36
- tokenAccounts: TokenAccount[];
37
- driftUsers?: DriftUser[];
38
- }
39
- interface GlamStateCache {
40
- address: string;
41
- pubkey: PublicKey;
42
- owner: PublicKey;
43
- sparkleKey: string;
44
- name: string;
45
- product: "Mint" | "Vault" | "TokenizedVault" | "SingleAssetVault";
46
- }
47
- export declare function GlamProvider({ children, }: Readonly<{
48
- children: React.ReactNode;
49
- }>): import("react/jsx-runtime").JSX.Element;
50
- export declare const useGlam: () => GlamProviderContext;
51
- export {};
@@ -1,5 +0,0 @@
1
- export * from "../index";
2
- export * from "./glam";
3
- export * from "./cluster-provider";
4
- export * from "./query-keys";
5
- export * from "./useVaultBalanceSubscription";
@@ -1,40 +0,0 @@
1
- export declare const queryKeys: {
2
- readonly vault: {
3
- readonly all: (pk: string, cluster: string) => readonly ["vault", string, string];
4
- readonly balances: (pk: string, cluster: string) => readonly ["vault", string, string, "balances"];
5
- readonly holdings: (pk: string, cluster: string) => readonly ["vault", string, string, "holdings"];
6
- readonly acls: (pk: string, cluster: string) => readonly ["vault", string, string, "acls"];
7
- readonly config: (pk: string, cluster: string) => readonly ["vault", string, string, "config"];
8
- readonly driftUsers: (pk: string, cluster: string) => readonly ["vault", string, string, "drift-users"];
9
- readonly stakes: (pk: string, cluster: string) => readonly ["vault", string, string, "stakes"];
10
- readonly holders: (mint: string, cluster: string) => readonly ["vault", "holders", string, string];
11
- };
12
- readonly wallet: {
13
- readonly balances: (pk: string, cluster: string) => readonly ["wallet", string, "balances", string];
14
- };
15
- readonly global: {
16
- readonly allStates: (cluster: string) => readonly ["global", "all-states", string];
17
- readonly jupTokens: (cluster: string) => readonly ["global", "jup-tokens", string];
18
- readonly jupDexes: (cluster: string) => readonly ["global", "jup-dexes", string];
19
- readonly driftMarkets: (cluster: string) => readonly ["global", "drift-markets", string];
20
- readonly kaminoMarkets: (cluster: string) => readonly ["global", "kamino-markets", string];
21
- readonly kaminoVaults: (cluster: string) => readonly ["global", "kamino-vaults", string];
22
- readonly priorityFee: (cluster: string) => readonly ["global", "priority-fee", string];
23
- };
24
- readonly vaultGraph: {
25
- readonly vault: (vaultId: string, cluster: string) => readonly ["vault-graph", "vault", string, string];
26
- readonly tokenData: (mint: string, cluster: string) => readonly ["vault-graph", "token-data", string, string];
27
- readonly availableIntegrations: (cluster: string) => readonly ["vault-graph", "available-integrations", string];
28
- };
29
- readonly tx: {
30
- readonly status: (sig: string) => readonly ["tx", string];
31
- };
32
- };
33
- export type InvalidationScope = "balance" | "drift" | "acls" | "wallet" | "graph" | "stakes" | "all";
34
- export interface InvalidationContext {
35
- vaultPk: string;
36
- walletPk: string;
37
- cluster: string;
38
- }
39
- /** Maps invalidation scopes to the query keys that need to be invalidated. */
40
- export declare function getInvalidationKeys(scopes: InvalidationScope[], ctx: InvalidationContext): readonly (readonly string[])[];
@@ -1,17 +0,0 @@
1
- import { Connection, PublicKey } from "@solana/web3.js";
2
- import { QueryClient } from "@tanstack/react-query";
3
- import { TokenAccount } from "../client/base";
4
- export interface UseVaultBalanceSubscriptionOptions {
5
- connection: Connection;
6
- queryClient: QueryClient;
7
- vaultPda: PublicKey | undefined;
8
- /** Base58 string of the active vault state pubkey (used for query key scoping) */
9
- pk: string;
10
- /** Cluster network string for query key scoping */
11
- cluster: string;
12
- tokenAccounts: TokenAccount[];
13
- enabled: boolean;
14
- /** Called when WebSocket connection status changes (for polling fallback) */
15
- onWsStatusChange: (connected: boolean) => void;
16
- }
17
- export declare function useVaultBalanceSubscription({ connection, queryClient, vaultPda, pk, cluster, tokenAccounts, enabled, onWsStatusChange, }: UseVaultBalanceSubscriptionOptions): void;
@@ -1,2 +0,0 @@
1
- export * from "./types";
2
- export * from "./orderParams";
@@ -1,28 +0,0 @@
1
- import { OptionalOrderParams, OrderParams, OrderTriggerCondition } from "./types";
2
- import { BN } from "@coral-xyz/anchor";
3
- export declare function getLimitOrderParams(params: Omit<OptionalOrderParams, "orderType"> & {
4
- price: BN;
5
- }): OptionalOrderParams;
6
- export declare function getTriggerMarketOrderParams(params: Omit<OptionalOrderParams, "orderType"> & {
7
- triggerCondition: OrderTriggerCondition;
8
- triggerPrice: BN;
9
- }): OptionalOrderParams;
10
- export declare function getTriggerLimitOrderParams(params: Omit<OptionalOrderParams, "orderType"> & {
11
- triggerCondition: OrderTriggerCondition;
12
- triggerPrice: BN;
13
- price: BN;
14
- }): OptionalOrderParams;
15
- export declare function getMarketOrderParams(params: Omit<OptionalOrderParams, "orderType">): OptionalOrderParams;
16
- /**
17
- * Creates an OrderParams object with the given OptionalOrderParams and any params to override.
18
- *
19
- * example:
20
- * ```
21
- * const orderParams = getOrderParams(optionalOrderParams, { marketType: MarketType.PERP });
22
- * ```
23
- *
24
- * @param optionalOrderParams
25
- * @param overridingParams
26
- * @returns
27
- */
28
- export declare function getOrderParams(optionalOrderParams: OptionalOrderParams, overridingParams?: Record<string, any>): OrderParams;