@glamsystems/glam-sdk 1.1.0-alpha.6 → 1.1.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.
Files changed (137) hide show
  1. package/LICENSE +201 -0
  2. package/buffer-layout.d.ts +88 -0
  3. package/index.cjs.d.ts +1 -0
  4. package/index.cjs.js +1 -92594
  5. package/index.esm.d.ts +1 -0
  6. package/index.esm.js +1 -92146
  7. package/package.json +29 -17
  8. package/src/assets.d.ts +39 -0
  9. package/src/client/access.d.ts +57 -0
  10. package/src/client/base.d.ts +234 -0
  11. package/src/client/bridge.d.ts +205 -0
  12. package/src/client/bridgeRegistry.d.ts +32 -0
  13. package/src/client/cctp.d.ts +164 -0
  14. package/src/client/epi.d.ts +228 -0
  15. package/src/client/fees.d.ts +33 -0
  16. package/src/client/invest.d.ts +37 -0
  17. package/src/client/jupiter-lend/borrow.d.ts +92 -0
  18. package/src/client/jupiter-lend/earn.d.ts +64 -0
  19. package/src/client/jupiter-lend/index.d.ts +3 -0
  20. package/src/client/jupiter-lend/shared.d.ts +129 -0
  21. package/src/client/jupiter.d.ts +53 -0
  22. package/src/client/kamino/farm.d.ts +39 -0
  23. package/src/client/kamino/index.d.ts +4 -0
  24. package/src/client/kamino/lending.d.ts +94 -0
  25. package/src/client/kamino/types.d.ts +56 -0
  26. package/src/client/kamino/vaults.d.ts +39 -0
  27. package/src/client/loopscale/borrow.d.ts +118 -0
  28. package/src/client/loopscale/core.d.ts +604 -0
  29. package/src/client/loopscale/index.d.ts +5 -0
  30. package/src/client/loopscale/lend.d.ts +123 -0
  31. package/src/client/loopscale/vault.d.ts +43 -0
  32. package/src/client/marinade.d.ts +42 -0
  33. package/src/client/mint.d.ts +143 -0
  34. package/src/client/orca.d.ts +255 -0
  35. package/src/client/phoenix.d.ts +214 -0
  36. package/src/client/price.d.ts +182 -0
  37. package/src/client/stake-pool.d.ts +39 -0
  38. package/src/client/stake.d.ts +34 -0
  39. package/src/client/state.d.ts +56 -0
  40. package/src/client/timelock.d.ts +31 -0
  41. package/src/client/vault.d.ts +98 -0
  42. package/src/client.d.ts +82 -0
  43. package/src/clientConfig.d.ts +32 -0
  44. package/src/constants.d.ts +111 -0
  45. package/src/deser/base.d.ts +18 -0
  46. package/src/deser/index.d.ts +4 -0
  47. package/src/deser/integrationPolicies.d.ts +195 -0
  48. package/src/deser/kaminoLayouts.d.ts +264 -0
  49. package/src/deser/loopscaleLayouts.d.ts +157 -0
  50. package/src/deser/tokenAclLayouts.d.ts +67 -0
  51. package/src/error.d.ts +29 -0
  52. package/src/glamExports.d.ts +6260 -0
  53. package/src/globalConfig.d.ts +27 -0
  54. package/src/index.d.ts +24 -0
  55. package/src/models/acl.d.ts +43 -0
  56. package/src/models/index.d.ts +8 -0
  57. package/src/models/mint.d.ts +57 -0
  58. package/src/models/state.d.ts +94 -0
  59. package/src/models/types.d.ts +28 -0
  60. package/src/protocols.d.ts +29 -0
  61. package/src/utils/accounts.d.ts +71 -0
  62. package/src/utils/bitmask.d.ts +53 -0
  63. package/src/utils/blockhash.d.ts +11 -0
  64. package/src/utils/common.d.ts +73 -0
  65. package/src/utils/computeBudget.d.ts +15 -0
  66. package/src/utils/evm.d.ts +10 -0
  67. package/src/utils/fraction.d.ts +29 -0
  68. package/src/utils/glamPDAs.d.ts +15 -0
  69. package/src/utils/helius.d.ts +66 -0
  70. package/src/utils/index.d.ts +17 -0
  71. package/src/utils/jupiterApi.d.ts +95 -0
  72. package/src/utils/lookupTables.d.ts +83 -0
  73. package/src/utils/phoenixApi.d.ts +146 -0
  74. package/src/utils/pkmap.d.ts +87 -0
  75. package/src/utils/pkset.d.ts +73 -0
  76. package/src/utils/positionCategorizer.d.ts +38 -0
  77. package/src/utils/rpc.d.ts +18 -0
  78. package/src/utils/timelock.d.ts +52 -0
  79. package/src/utils/transaction.d.ts +13 -0
  80. package/target/idl/ext_bridge-staging.json +2379 -0
  81. package/target/idl/ext_bridge.json +2379 -0
  82. package/target/idl/ext_drift.json +5464 -0
  83. package/target/idl/ext_epi-staging.json +2862 -0
  84. package/target/idl/ext_epi.json +2862 -0
  85. package/target/idl/ext_loopscale-staging.json +4708 -0
  86. package/target/idl/ext_loopscale.json +4708 -0
  87. package/target/idl/ext_marinade-staging.json +1587 -0
  88. package/target/idl/ext_phoenix-staging.json +3525 -0
  89. package/target/idl/ext_phoenix.json +3525 -0
  90. package/target/idl/mock_layerzero_endpoint.json +144 -0
  91. package/target/idl/mock_layerzero_oft.json +155 -0
  92. package/target/idl/mock_wormhole_verify_vaa_shim.json +58 -0
  93. package/target/types/ext_bridge-staging.d.ts +2385 -0
  94. package/target/types/ext_bridge-staging.ts +2385 -0
  95. package/target/types/ext_bridge.d.ts +2385 -0
  96. package/target/types/ext_bridge.ts +2385 -0
  97. package/target/types/ext_cctp-staging.d.ts +1268 -0
  98. package/target/types/ext_cctp.d.ts +1268 -0
  99. package/target/types/ext_drift.d.ts +5470 -0
  100. package/target/types/ext_drift.ts +5470 -0
  101. package/target/types/ext_epi-staging.d.ts +2868 -0
  102. package/target/types/ext_epi-staging.ts +2868 -0
  103. package/target/types/ext_epi.d.ts +2868 -0
  104. package/target/types/ext_epi.ts +2868 -0
  105. package/target/types/ext_jupiter-staging.d.ts +1966 -0
  106. package/target/types/ext_jupiter.d.ts +1966 -0
  107. package/target/types/ext_kamino-staging.d.ts +3433 -0
  108. package/target/types/ext_kamino.d.ts +3433 -0
  109. package/target/types/ext_loopscale-staging.d.ts +4714 -0
  110. package/target/types/ext_loopscale-staging.ts +4714 -0
  111. package/target/types/ext_loopscale.d.ts +4714 -0
  112. package/target/types/ext_loopscale.ts +4714 -0
  113. package/target/types/ext_marinade-staging.d.ts +1593 -0
  114. package/target/types/ext_marinade-staging.ts +1593 -0
  115. package/target/types/ext_marinade.d.ts +1593 -0
  116. package/target/types/ext_orca-staging.d.ts +2829 -0
  117. package/target/types/ext_orca.d.ts +2829 -0
  118. package/target/types/ext_phoenix-staging.d.ts +3531 -0
  119. package/target/types/ext_phoenix-staging.ts +3531 -0
  120. package/target/types/ext_phoenix.d.ts +3531 -0
  121. package/target/types/ext_phoenix.ts +3531 -0
  122. package/target/types/ext_spl-staging.d.ts +1274 -0
  123. package/target/types/ext_spl.d.ts +1274 -0
  124. package/target/types/ext_stake_pool-staging.d.ts +1622 -0
  125. package/target/types/ext_stake_pool.d.ts +1622 -0
  126. package/target/types/glam_config.d.ts +755 -0
  127. package/target/types/glam_mint-staging.d.ts +8802 -0
  128. package/target/types/glam_mint.d.ts +6349 -0
  129. package/target/types/glam_policies.d.ts +477 -0
  130. package/target/types/glam_protocol-staging.d.ts +3362 -0
  131. package/target/types/glam_protocol.d.ts +2783 -0
  132. package/target/types/mock_layerzero_endpoint.d.ts +150 -0
  133. package/target/types/mock_layerzero_endpoint.ts +150 -0
  134. package/target/types/mock_layerzero_oft.d.ts +161 -0
  135. package/target/types/mock_layerzero_oft.ts +161 -0
  136. package/target/types/mock_wormhole_verify_vaa_shim.d.ts +64 -0
  137. package/target/types/mock_wormhole_verify_vaa_shim.ts +64 -0
@@ -0,0 +1,17 @@
1
+ export * from "./accounts";
2
+ export * from "./bitmask";
3
+ export * from "./blockhash";
4
+ export * from "./computeBudget";
5
+ export * from "./evm";
6
+ export * from "./common";
7
+ export * from "./glamPDAs";
8
+ export * from "./lookupTables";
9
+ export * from "./rpc";
10
+ export * from "./timelock";
11
+ export * from "./transaction";
12
+ export * from "./pkmap";
13
+ export * from "./pkset";
14
+ export * from "./fraction";
15
+ export * from "./jupiterApi";
16
+ export * from "./phoenixApi";
17
+ export * from "./positionCategorizer";
@@ -0,0 +1,95 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export type QuoteParams = {
3
+ inputMint: string;
4
+ outputMint: string;
5
+ amount: number;
6
+ slippageBps?: number;
7
+ swapMode?: string;
8
+ onlyDirectRoutes?: boolean;
9
+ asLegacyTransaction?: boolean;
10
+ maxAccounts?: number;
11
+ dexes?: string[];
12
+ excludeDexes?: string[];
13
+ instructionVersion: "V1" | "V2";
14
+ };
15
+ export type QuoteResponse = {
16
+ inputMint: string;
17
+ inAmount: string;
18
+ outputMint: string;
19
+ outAmount: string;
20
+ otherAmountThreshold: string;
21
+ swapMode: string;
22
+ slippageBps: number;
23
+ platformFee: any;
24
+ priceImpactPct: string;
25
+ routePlan: any[];
26
+ contextSlot: number;
27
+ timeTaken: number;
28
+ };
29
+ export type TokenListItem = {
30
+ address: string;
31
+ name: string;
32
+ symbol: string;
33
+ decimals: number;
34
+ logoURI: string;
35
+ tags: string[];
36
+ usdPrice: number;
37
+ slot: number;
38
+ };
39
+ export declare class JupTokenList {
40
+ readonly tokens: TokenListItem[];
41
+ readonly mintMap: Map<string, TokenListItem>;
42
+ constructor(tokens: TokenListItem[]);
43
+ getByMint(mintAddress: string | PublicKey): TokenListItem | undefined;
44
+ getBySymbol(symbol: string): TokenListItem | undefined;
45
+ }
46
+ export type JupiterInstruction = {
47
+ programId: string;
48
+ accounts: {
49
+ pubkey: string;
50
+ isSigner: boolean;
51
+ isWritable: boolean;
52
+ }[];
53
+ data: string;
54
+ };
55
+ export type SwapInstructions = {
56
+ tokenLedgerInstruction?: JupiterInstruction | null;
57
+ otherInstructions?: JupiterInstruction[];
58
+ computeBudgetInstructions: JupiterInstruction[];
59
+ setupInstructions?: JupiterInstruction[];
60
+ swapInstruction: JupiterInstruction;
61
+ cleanupInstruction?: JupiterInstruction;
62
+ addressLookupTableAddresses: string[];
63
+ };
64
+ export declare const JUPITER_API_DEFAULT = "https://api.jup.ag";
65
+ export type TokenPrice = {
66
+ mint: string;
67
+ usdPrice: number;
68
+ decimals: number;
69
+ blockId: number;
70
+ };
71
+ export type FetchTokensListOptions = {
72
+ forceRefresh?: boolean;
73
+ includeStakePools?: boolean;
74
+ };
75
+ export declare function withStakePoolTokens(tokenList: JupTokenList): JupTokenList;
76
+ export declare class JupiterApiClient {
77
+ swapApiBaseUrl: string;
78
+ isCustomSwapApi: boolean;
79
+ apiKey: string | null;
80
+ private tokenListCache;
81
+ private tokenListCacheTtl;
82
+ constructor(options?: {
83
+ apiKey?: string;
84
+ swapApiBaseUrl?: string;
85
+ cacheTtl?: number;
86
+ });
87
+ fetchTokenPrices(mints: string[]): Promise<TokenPrice[]>;
88
+ fetchTokensList(forceRefresh?: boolean): Promise<JupTokenList>;
89
+ fetchTokensListV2(options?: FetchTokensListOptions): Promise<JupTokenList>;
90
+ fetchProgramLabels(): Promise<{
91
+ [key: string]: string;
92
+ }>;
93
+ getQuoteResponse(quoteParams: QuoteParams): Promise<any>;
94
+ getSwapInstructions(quoteResponse: any, from: PublicKey, trackingAccount?: PublicKey): Promise<SwapInstructions>;
95
+ }
@@ -0,0 +1,83 @@
1
+ import { AddressLookupTableAccount, Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
2
+ export type LookupTableInput = string | PublicKey | AddressLookupTableAccount;
3
+ /**
4
+ * Returns the public key for an address lookup table input.
5
+ *
6
+ * @param lookupTable Lookup table account, public key, or base58 address
7
+ * @returns Lookup table public key
8
+ */
9
+ export declare function getLookupTableKey(lookupTable: LookupTableInput): PublicKey;
10
+ /**
11
+ * Merges lookup table inputs while preserving the first occurrence of each key.
12
+ *
13
+ * Accepts one or more lookup table arrays as separate arguments. Passing a
14
+ * single array merges and deduplicates that one group.
15
+ *
16
+ * @param lookupTableGroups Lookup table arrays to merge, in priority order
17
+ * @returns Deduplicated lookup table inputs
18
+ */
19
+ export declare function mergeLookupTables(...lookupTableGroups: LookupTableInput[][]): LookupTableInput[];
20
+ /**
21
+ * Fetches multiple address lookup table accounts
22
+ *
23
+ * @param connection Solana connection
24
+ * @param pubkeys Array of lookup table public keys
25
+ * @returns Array of address lookup table accounts
26
+ */
27
+ export declare function fetchAddressLookupTableAccounts(connection: Connection, pubkeys: string[] | PublicKey[]): Promise<AddressLookupTableAccount[]>;
28
+ /**
29
+ * Resolves lookup table inputs to address lookup table accounts.
30
+ *
31
+ * Already-resolved accounts are preserved, while public keys and base58
32
+ * addresses are fetched from the provided connection. Missing accounts are
33
+ * omitted from the result.
34
+ *
35
+ * @param connection Solana connection
36
+ * @param lookupTables Lookup table accounts, public keys, or base58 addresses
37
+ * @returns Resolved address lookup table accounts
38
+ */
39
+ export declare function resolveAddressLookupTableAccounts(connection: Connection, lookupTables: LookupTableInput[]): Promise<AddressLookupTableAccount[]>;
40
+ export interface VaultAccountsInfo {
41
+ statePda: PublicKey;
42
+ vaultPda: PublicKey;
43
+ mintPda: PublicKey;
44
+ escrowPda: PublicKey;
45
+ requestQueuePda: PublicKey;
46
+ extraMetasPda: PublicKey;
47
+ protocolProgramId: PublicKey;
48
+ mintProgramId: PublicKey;
49
+ connection: Connection;
50
+ stateAccount: {
51
+ mint: PublicKey;
52
+ baseAssetMint: PublicKey;
53
+ assets: PublicKey[];
54
+ externalPositions: PublicKey[];
55
+ integrationAcls: {
56
+ integrationProgram: PublicKey;
57
+ }[];
58
+ };
59
+ borrowable?: PublicKey[];
60
+ }
61
+ /**
62
+ * Collects all pubkeys that should be included in a vault's Address Lookup Table.
63
+ *
64
+ * The first 3 entries are fixed (statePda, vaultPda, GLAM_CONFIG_PROGRAM) to
65
+ * match the ALT discovery filter offsets used by findGlamLookupTables().
66
+ */
67
+ export declare function collectVaultLookupTableAddresses(info: VaultAccountsInfo): Promise<PublicKey[]>;
68
+ export interface CreateAltResult {
69
+ createIx: TransactionInstruction;
70
+ lookupTableAddress: PublicKey;
71
+ extendIxBatches: TransactionInstruction[];
72
+ }
73
+ /**
74
+ * Builds instructions to create an ALT and extend it with the given addresses.
75
+ * Returns the create instruction, the derived lookup table address, and batched
76
+ * extend instructions (each batch fits within a single transaction).
77
+ */
78
+ export declare function buildCreateAltInstructions(addresses: PublicKey[], authority: PublicKey, payer: PublicKey, recentSlot: number): CreateAltResult;
79
+ /**
80
+ * Builds batched extend instructions for an existing ALT.
81
+ * Each instruction extends the table with up to 20 addresses.
82
+ */
83
+ export declare function buildExtendAltInstructions(lookupTableAddress: PublicKey, newAddresses: PublicKey[], authority: PublicKey, payer: PublicKey): TransactionInstruction[];
@@ -0,0 +1,146 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export declare const DEFAULT_PHOENIX_API_URL = "https://perp-api.phoenix.trade";
3
+ export type PhoenixSnapshot = {
4
+ slot?: number;
5
+ exchange: {
6
+ programId: string;
7
+ globalConfig: string;
8
+ currentAuthorities?: {
9
+ rootAuthority?: string;
10
+ riskAuthority?: string;
11
+ marketAuthority?: string;
12
+ oracleAuthority?: string;
13
+ adlAuthority?: string;
14
+ cancelAuthority?: string;
15
+ backstopAuthority?: string;
16
+ };
17
+ canonicalMint: string;
18
+ usdcMint: string;
19
+ globalVault: string;
20
+ perpAssetMap: string;
21
+ globalTraderIndex: string[];
22
+ activeTraderBuffer: string[];
23
+ withdrawQueue: string;
24
+ active?: boolean;
25
+ gated?: boolean;
26
+ };
27
+ markets: PhoenixMarket[];
28
+ };
29
+ export type PhoenixMarket = {
30
+ symbol: string;
31
+ marketPubkey: string;
32
+ splinePubkey?: string;
33
+ tickSize: number | string;
34
+ baseLotsDecimals: number;
35
+ marketStatus?: string;
36
+ isolatedOnly?: boolean;
37
+ takerFee?: number;
38
+ makerFee?: number;
39
+ };
40
+ export type TraderCapabilityAccess = {
41
+ immediate?: boolean;
42
+ viaColdActivation?: boolean;
43
+ };
44
+ export type DisplayAmount = string | number | {
45
+ ui?: string;
46
+ value?: string | number;
47
+ decimals?: number;
48
+ };
49
+ export type LimitOrder = {
50
+ price?: DisplayAmount;
51
+ side?: string;
52
+ orderSequenceNumber?: string | number;
53
+ initialTradeSize?: DisplayAmount;
54
+ tradeSizeRemaining?: DisplayAmount;
55
+ marginRequirement?: DisplayAmount;
56
+ marginFactor?: DisplayAmount;
57
+ isReduceOnly?: boolean;
58
+ isConditionalOrder?: boolean;
59
+ isStopLoss?: boolean;
60
+ isStopLossDirection?: boolean;
61
+ nodePointer?: string | number;
62
+ node_pointer?: string | number;
63
+ priceInTicks?: string | number;
64
+ priceTicks?: string | number;
65
+ price_in_ticks?: string | number;
66
+ orderId?: {
67
+ priceInTicks?: string | number;
68
+ price_in_ticks?: string | number;
69
+ orderSequenceNumber?: string | number;
70
+ order_sequence_number?: string | number;
71
+ };
72
+ };
73
+ export type TraderPositionView = {
74
+ symbol?: string;
75
+ positionSize?: DisplayAmount;
76
+ virtualQuotePosition?: DisplayAmount;
77
+ entryPrice?: DisplayAmount;
78
+ unrealizedPnl?: DisplayAmount;
79
+ discountedUnrealizedPnl?: DisplayAmount;
80
+ positionInitialMargin?: DisplayAmount;
81
+ initialMargin?: DisplayAmount;
82
+ maintenanceMargin?: DisplayAmount;
83
+ backstopMargin?: DisplayAmount;
84
+ limitOrderMargin?: DisplayAmount;
85
+ positionValue?: DisplayAmount;
86
+ unsettledFunding?: DisplayAmount;
87
+ accumulatedFunding?: DisplayAmount;
88
+ liquidationPrice?: DisplayAmount | null;
89
+ takeProfitPrice?: DisplayAmount | null;
90
+ stopLossPrice?: DisplayAmount | null;
91
+ };
92
+ export type TraderView = {
93
+ flags?: number;
94
+ state?: string;
95
+ slot?: number;
96
+ slotIndex?: number;
97
+ traderKey?: string;
98
+ traderPdaIndex?: number;
99
+ traderSubaccountIndex?: number;
100
+ authority?: string;
101
+ capabilities?: {
102
+ placeLimitOrder?: TraderCapabilityAccess;
103
+ placeMarketOrder?: TraderCapabilityAccess;
104
+ riskIncreasingTrade?: TraderCapabilityAccess;
105
+ riskReducingTrade?: TraderCapabilityAccess;
106
+ depositCollateral?: TraderCapabilityAccess;
107
+ withdrawCollateral?: TraderCapabilityAccess;
108
+ };
109
+ collateralBalance?: DisplayAmount;
110
+ effectiveCollateral?: DisplayAmount;
111
+ effectiveCollateralForWithdrawals?: DisplayAmount;
112
+ unrealizedPnl?: DisplayAmount;
113
+ discountedUnrealizedPnl?: DisplayAmount;
114
+ unsettledFundingOwed?: DisplayAmount;
115
+ accumulatedFunding?: DisplayAmount;
116
+ portfolioValue?: DisplayAmount;
117
+ maintenanceMargin?: DisplayAmount;
118
+ cancelMargin?: DisplayAmount;
119
+ initialMargin?: DisplayAmount;
120
+ initialMarginForWithdrawals?: DisplayAmount;
121
+ riskState?: string;
122
+ riskTier?: string;
123
+ positions?: TraderPositionView[];
124
+ limitOrders?: Record<string, LimitOrder[]>;
125
+ makerFeeOverrideMultiplier?: number;
126
+ takerFeeOverrideMultiplier?: number;
127
+ maxPositions?: number;
128
+ lastDepositSlot?: number;
129
+ isInActiveTraders?: boolean;
130
+ };
131
+ export type TraderStateResponse = {
132
+ slot?: number;
133
+ slotIndex?: number;
134
+ authority?: string;
135
+ pdaIndex?: number;
136
+ traders?: TraderView[];
137
+ };
138
+ export declare function normalizePhoenixApiUrl(apiUrl: string): string;
139
+ export declare class PhoenixApiClient {
140
+ apiUrl: string;
141
+ constructor();
142
+ private url;
143
+ fetchPhoenixSnapshot(): Promise<PhoenixSnapshot>;
144
+ fetchTraderView(trader: PublicKey | string): Promise<TraderView | null>;
145
+ fetchTraderState(authority: PublicKey | string, pdaIndex: number): Promise<TraderStateResponse | null>;
146
+ }
@@ -0,0 +1,87 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ type PkMapKey = PublicKey | string;
3
+ /**
4
+ * A Map implementation that uses PublicKey-compatible keys.
5
+ *
6
+ * This class extends the standard Map and allows using PublicKey objects
7
+ * or base58 strings as keys by converting them to base58 strings internally.
8
+ * This solves the problem of PublicKey object reference equality - two
9
+ * PublicKey objects with the same address would normally be considered
10
+ * different keys in a Map.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Create empty map
15
+ * const map = new PkMap<string>();
16
+ * const key = new PublicKey("11111111111111111111111111111111");
17
+ * map.set(key, "value");
18
+ *
19
+ * // Create with initial entries
20
+ * const map2 = new PkMap<string>([
21
+ * ["11111111111111111111111111111111", "value1"],
22
+ * [new PublicKey("22222222222222222222222222222222"), "value2"]
23
+ * ]);
24
+ *
25
+ * // Can retrieve with a different PublicKey object with same address
26
+ * const sameKey = new PublicKey("11111111111111111111111111111111");
27
+ * console.log(map.get(sameKey)); // "value"
28
+ * ```
29
+ */
30
+ export declare class PkMap<V> {
31
+ private readonly _map;
32
+ /**
33
+ * Creates a new PkMap instance.
34
+ * @param entries - Optional initial entries as [PublicKey|string, V] pairs
35
+ */
36
+ constructor();
37
+ constructor(entries?: readonly (readonly [PkMapKey, V])[] | null);
38
+ constructor(entries?: Iterable<readonly [PkMapKey, V]> | null);
39
+ /**
40
+ * Associates the specified value with the specified PublicKey in this map.
41
+ * @param key - The PublicKey or base58 string to use as the key
42
+ * @param value - The value to associate with the key
43
+ * @returns This PkMap instance for chaining
44
+ */
45
+ set(key: PkMapKey, value: V): this;
46
+ /**
47
+ * Returns the value associated with the specified key, or undefined if not found.
48
+ * @param key - The PublicKey or base58 string whose associated value is to be returned
49
+ * @returns The value associated with the specified key, or undefined
50
+ */
51
+ get(key: PkMapKey): V | undefined;
52
+ /**
53
+ * Returns true if this map contains a mapping for the specified key.
54
+ * @param key - The PublicKey or base58 string whose presence in this map is to be tested
55
+ * @returns true if this map contains a mapping for the specified key
56
+ */
57
+ has(key: PkMapKey): boolean;
58
+ /**
59
+ * Removes the mapping for the specified key from this map if present.
60
+ * @param key - The PublicKey or base58 string whose mapping is to be removed
61
+ * @returns true if the element was removed, false otherwise
62
+ */
63
+ delete(key: PkMapKey): boolean;
64
+ /**
65
+ * Returns an iterator of all PublicKey keys in this map.
66
+ * Note: This reconstructs PublicKey objects from the stored base58 strings.
67
+ * @returns An iterator of PublicKey objects
68
+ */
69
+ pkKeys(): IterableIterator<PublicKey>;
70
+ /**
71
+ * Returns an iterator of [PublicKey, value] pairs for every entry in the map.
72
+ * Note: This reconstructs PublicKey objects from the stored base58 strings.
73
+ * @returns An iterator of [PublicKey, V] tuples
74
+ */
75
+ pkEntries(): IterableIterator<[PublicKey, V]>;
76
+ /**
77
+ * Executes a provided function once per each PublicKey/value pair in the Map.
78
+ * @param callbackfn - Function to execute for each entry
79
+ * @param thisArg - Value to use as this when executing callback
80
+ */
81
+ forEach(callbackfn: (value: V, key: PublicKey, map: PkMap<V>) => void, thisArg?: any): void;
82
+ get size(): number;
83
+ clear(): void;
84
+ values(): IterableIterator<V>;
85
+ [Symbol.iterator](): IterableIterator<[PublicKey, V]>;
86
+ }
87
+ export {};
@@ -0,0 +1,73 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ /**
3
+ * A Set implementation that uses PublicKey as values.
4
+ *
5
+ * This class extends the standard Set and allows using PublicKey objects
6
+ * as values by converting them to base58 strings internally. This solves the
7
+ * problem of PublicKey object reference equality - two PublicKey objects
8
+ * with the same address would normally be considered different values in a Set.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Create empty set
13
+ * const set = new PkSet();
14
+ * const key = new PublicKey("11111111111111111111111111111111");
15
+ * set.add(key);
16
+ *
17
+ * // Create with initial values
18
+ * const set2 = new PkSet([
19
+ * new PublicKey("11111111111111111111111111111111"),
20
+ * new PublicKey("22222222222222222222222222222222")
21
+ * ]);
22
+ *
23
+ * // Can check with a different PublicKey object with same address
24
+ * const sameKey = new PublicKey("11111111111111111111111111111111");
25
+ * console.log(set.has(sameKey)); // true
26
+ * ```
27
+ */
28
+ export declare class PkSet {
29
+ private readonly _set;
30
+ /**
31
+ * Creates a new PkSet instance.
32
+ * @param values - Optional initial values as PublicKey array
33
+ */
34
+ constructor(values?: readonly PublicKey[] | null);
35
+ /**
36
+ * Adds the specified PublicKey to this set.
37
+ * @param value - The PublicKey to add to the set
38
+ * @returns This PkSet instance for chaining
39
+ */
40
+ add(value: PublicKey): this;
41
+ /**
42
+ * Returns true if this set contains the specified PublicKey.
43
+ * @param value - The PublicKey whose presence in this set is to be tested
44
+ * @returns true if this set contains the specified PublicKey
45
+ */
46
+ has(value: PublicKey): boolean;
47
+ /**
48
+ * Removes the specified PublicKey from this set if present.
49
+ * @param value - The PublicKey to be removed
50
+ * @returns true if the element was removed, false otherwise
51
+ */
52
+ delete(value: PublicKey): boolean;
53
+ /**
54
+ * Returns an iterator of all PublicKey values in this set.
55
+ * Note: This reconstructs PublicKey objects from the stored base58 strings.
56
+ * @returns An iterator of PublicKey objects
57
+ */
58
+ pkValues(): IterableIterator<PublicKey>;
59
+ /**
60
+ * Executes a provided function once per each PublicKey in the Set.
61
+ * @param callbackfn - Function to execute for each value
62
+ * @param thisArg - Value to use as this when executing callback
63
+ */
64
+ forEach(callbackfn: (value: PublicKey, value2: PublicKey, set: PkSet) => void, thisArg?: any): void;
65
+ get size(): number;
66
+ clear(): void;
67
+ [Symbol.iterator](): IterableIterator<PublicKey>;
68
+ equals(other: PkSet): boolean;
69
+ /**
70
+ * @returns true if this set contains all the PublicKeys in the other set
71
+ */
72
+ includes(other: PkSet): boolean;
73
+ }
@@ -0,0 +1,38 @@
1
+ import { Commitment, Connection, PublicKey } from "@solana/web3.js";
2
+ /**
3
+ * Categorized external positions by protocol type.
4
+ */
5
+ export interface CategorizedPositions {
6
+ /** Kamino lending obligation accounts */
7
+ kaminoObligations: PublicKey[];
8
+ /** Kamino vault share token accounts */
9
+ kaminoVaultShareAtas: PublicKey[];
10
+ /** Orca Whirlpools position PDA accounts */
11
+ orcaWhirlpoolPositions: PublicKey[];
12
+ /** Positions that couldn't be categorized */
13
+ unknown: PublicKey[];
14
+ }
15
+ /**
16
+ * Utility class for categorizing external positions by protocol type.
17
+ *
18
+ * External positions in GLAM vaults can be:
19
+ * - Kamino obligation accounts (lending positions)
20
+ * - Kamino vault share ATAs (shares in kamino vaults)
21
+ *
22
+ * This class determines the type of each position to enable proper pricing.
23
+ */
24
+ export declare class PositionCategorizer {
25
+ private readonly connection;
26
+ constructor(connection: Connection, _vaultPda?: PublicKey);
27
+ /**
28
+ * Categorizes external positions by protocol type.
29
+ *
30
+ * Algorithm:
31
+ * 1. Batch fetch positions
32
+ * 2. Categorize based on account owner and size
33
+ *
34
+ * @param externalPositions - Array of external position pubkeys from state account
35
+ * @returns Categorized positions by protocol type
36
+ */
37
+ categorizePositions(externalPositions: PublicKey[], commitment: Commitment): Promise<CategorizedPositions>;
38
+ }
@@ -0,0 +1,18 @@
1
+ import { Connection, GetProgramAccountsConfig, GetProgramAccountsResponse, PublicKey, SignaturesForAddressOptions, VersionedTransactionResponse } from "@solana/web3.js";
2
+ import { GetTransactionsOptions, HeliusGetProgramAccountsV2Config } from "./helius";
3
+ export { getAsset, getHeliusApiKey, getHeliusRpcUrl, getPriorityFeeEstimate, getTokenAccountsByMint, getTokenAccountsByMintResult, heliusFetch, heliusGetProgramAccountsV2, heliusGetTransactionsForAddress, isHeliusRpc, } from "./helius";
4
+ export type { GetTokenAccountsByMintOptions, GetPriorityFeeEstimateOptions, GetTransactionsOptions, HeliusAsset, HeliusFetchOptions, HeliusGetProgramAccountsV2Config, HeliusTokenAccount, HeliusTokenAccountsByMintResult, PriorityLevel, } from "./helius";
5
+ /**
6
+ * Fetches program accounts using Helius getProgramAccountsV2 if available.
7
+ * Otherwise falls back to standard getProgramAccounts with retry logic.
8
+ */
9
+ export declare function getProgramAccounts(connection: Connection, programId: PublicKey, config: GetProgramAccountsConfig & HeliusGetProgramAccountsV2Config): Promise<GetProgramAccountsResponse>;
10
+ /**
11
+ * Standard getProgramAccounts with retry logic for transient errors.
12
+ */
13
+ export declare function getProgramAccountsWithRetry(connection: Connection, programId: PublicKey, config: GetProgramAccountsConfig): Promise<GetProgramAccountsResponse>;
14
+ /**
15
+ * Fetches transactions for an address using Helius getTransactionsForAddress if available.
16
+ * Otherwise falls back to getSignaturesForAddress + getTransaction.
17
+ */
18
+ export declare function getTransactionsForAddress(connection: Connection, address: PublicKey, options?: SignaturesForAddressOptions & GetTransactionsOptions): Promise<VersionedTransactionResponse[]>;
@@ -0,0 +1,52 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import { BN } from "@coral-xyz/anchor";
3
+ import { IntegrationAcl, DelegateAcl } from "../models";
4
+ /**
5
+ * Get protocol names from a bitmask for a given integration program
6
+ * Uses the SDK's parseProtocolsBitmask function
7
+ */
8
+ export declare function getProtocolNamesFromBitmask(integrationProgram: PublicKey, bitmask: number, staging: boolean): string[];
9
+ /**
10
+ * Get permission names from a permissions bitmask for a protocol
11
+ * Uses the SDK's parseProtocolPermissionsBitmask function
12
+ */
13
+ export declare function getPermissionNamesFromBitmask(integrationProgram: PublicKey, protocolBitflag: number, permissionsBitmask: BN, staging: boolean): string[];
14
+ /**
15
+ * Compare current and staged PublicKey arrays and return added/removed keys
16
+ */
17
+ export declare function comparePublicKeyArrays(current: PublicKey[] | null, staged: PublicKey[]): {
18
+ added: PublicKey[];
19
+ removed: PublicKey[];
20
+ };
21
+ /**
22
+ * Compare current and staged integrationAcls and return the differences
23
+ */
24
+ export declare function compareIntegrationAcls(current: IntegrationAcl[] | null, staged: IntegrationAcl[] | null, staging: boolean): {
25
+ added: IntegrationAcl[];
26
+ removed: IntegrationAcl[];
27
+ modified: Array<{
28
+ integrationProgram: PublicKey;
29
+ currentBitmask: number;
30
+ stagedBitmask: number;
31
+ enabledProtocols: string[];
32
+ disabledProtocols: string[];
33
+ }>;
34
+ };
35
+ /**
36
+ * Compare current and staged delegateAcls and return the differences
37
+ */
38
+ export declare function compareDelegateAcls(current: DelegateAcl[] | null, staged: DelegateAcl[] | null, staging: boolean): {
39
+ added: DelegateAcl[];
40
+ removed: DelegateAcl[];
41
+ modified: Array<{
42
+ pubkey: PublicKey;
43
+ currentExpiresAt: BN;
44
+ stagedExpiresAt: BN;
45
+ permissionChanges: Array<{
46
+ integrationProgram: PublicKey;
47
+ protocolName: string;
48
+ addedPermissions: string[];
49
+ removedPermissions: string[];
50
+ }>;
51
+ }>;
52
+ };
@@ -0,0 +1,13 @@
1
+ import { Connection, PublicKey, TransactionInstruction, AddressLookupTableAccount } from "@solana/web3.js";
2
+ /**
3
+ * Parses program logs to extract error message.
4
+ * Checks in order: Anchor "Error Message:", insufficient funds/lamports,
5
+ * and custom program error codes (resolved via IDL when possible).
6
+ * Returns "Unknown error" if no recognizable error pattern is found.
7
+ */
8
+ export declare function parseProgramLogs(logs: string[], staging: boolean): string;
9
+ export declare const getSimulationResult: (connection: Connection, instructions: Array<TransactionInstruction>, payer: PublicKey, lookupTables?: Array<AddressLookupTableAccount>, staging?: boolean) => Promise<{
10
+ unitsConsumed?: number;
11
+ error?: Error;
12
+ serializedTx?: String;
13
+ }>;