@glamsystems/glam-sdk 1.0.12 → 1.0.14-alpha.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 (75) hide show
  1. package/README.md +1 -1
  2. package/index.cjs.js +23827 -26772
  3. package/index.esm.js +23795 -26716
  4. package/package.json +2 -2
  5. package/src/assets.d.ts +9 -15
  6. package/src/client/access.d.ts +13 -0
  7. package/src/client/base.d.ts +27 -6
  8. package/src/client/bridge.d.ts +184 -0
  9. package/src/client/bridgeRegistry.d.ts +32 -0
  10. package/src/client/epi.d.ts +78 -0
  11. package/src/client/fees.d.ts +4 -0
  12. package/src/client/invest.d.ts +1 -1
  13. package/src/client/jupiter.d.ts +22 -18
  14. package/src/client/mint.d.ts +54 -1
  15. package/src/client/price.d.ts +13 -37
  16. package/src/client.d.ts +6 -5
  17. package/src/constants.d.ts +10 -7
  18. package/src/deser/index.d.ts +1 -1
  19. package/src/deser/integrationPolicies.d.ts +23 -20
  20. package/src/deser/tokenAclLayouts.d.ts +67 -0
  21. package/src/error.d.ts +2 -1
  22. package/src/glamExports.d.ts +2344 -1758
  23. package/src/globalConfig.d.ts +22 -0
  24. package/src/index.d.ts +4 -1
  25. package/src/react/glam.d.ts +0 -4
  26. package/src/react/query-keys.d.ts +1 -3
  27. package/src/utils/accounts.d.ts +9 -1
  28. package/src/utils/bitmask.d.ts +3 -0
  29. package/src/utils/common.d.ts +2 -0
  30. package/src/utils/glamPDAs.d.ts +5 -0
  31. package/src/utils/index.d.ts +0 -1
  32. package/src/utils/positionCategorizer.d.ts +3 -21
  33. package/target/idl/ext_cctp.json +1 -1
  34. package/target/idl/ext_kamino-staging.json +1 -1
  35. package/target/idl/ext_kamino.json +109 -1
  36. package/target/idl/ext_spl-staging.json +1 -1
  37. package/target/idl/ext_spl.json +1 -1
  38. package/target/idl/glam_config.json +78 -9
  39. package/target/idl/glam_mint-staging.json +865 -0
  40. package/target/idl/glam_mint.json +227 -8
  41. package/target/idl/glam_policies.json +2 -7
  42. package/target/idl/glam_protocol-staging.json +176 -275
  43. package/target/idl/glam_protocol.json +212 -114
  44. package/target/types/ext_bridge.d.ts +2397 -0
  45. package/target/types/ext_cctp.d.ts +1 -1
  46. package/target/types/ext_cctp.ts +1 -1
  47. package/target/types/ext_epi.d.ts +2175 -0
  48. package/target/types/ext_kamino-staging.ts +1 -1
  49. package/target/types/ext_kamino.d.ts +109 -1
  50. package/target/types/ext_kamino.ts +109 -1
  51. package/target/types/ext_spl-staging.ts +1 -1
  52. package/target/types/ext_spl.d.ts +1 -1
  53. package/target/types/ext_spl.ts +1 -1
  54. package/target/types/glam_config.d.ts +78 -9
  55. package/target/types/glam_config.ts +78 -9
  56. package/target/types/glam_mint-staging.ts +865 -0
  57. package/target/types/glam_mint.d.ts +227 -8
  58. package/target/types/glam_mint.ts +227 -8
  59. package/target/types/glam_policies.ts +2 -7
  60. package/target/types/glam_protocol-staging.ts +176 -275
  61. package/target/types/glam_protocol.d.ts +212 -114
  62. package/target/types/glam_protocol.ts +212 -114
  63. package/src/client/drift/index.d.ts +0 -2
  64. package/src/client/drift/protocol-v2.d.ts +0 -93
  65. package/src/client/drift/vaults.d.ts +0 -60
  66. package/src/deser/driftLayouts.d.ts +0 -217
  67. package/src/utils/drift/index.d.ts +0 -2
  68. package/src/utils/drift/orderParams.d.ts +0 -28
  69. package/src/utils/drift/types.d.ts +0 -522
  70. package/target/idl/ext_drift-staging.json +0 -3993
  71. package/target/idl/ext_drift.json +0 -3993
  72. package/target/types/ext_drift-staging.ts +0 -3999
  73. package/target/types/ext_drift.d.ts +0 -3999
  74. package/target/types/ext_drift.ts +0 -3999
  75. package/target/types/ext_offchain.d.ts +0 -1074
@@ -0,0 +1,22 @@
1
+ import { Connection, PublicKey } from "@solana/web3.js";
2
+ export type OracleSourceName = string;
3
+ export interface OnchainAssetMeta {
4
+ asset: PublicKey;
5
+ decimals: number;
6
+ oracle: PublicKey;
7
+ oracleSource: OracleSourceName;
8
+ maxAgeSeconds: number;
9
+ priority: number;
10
+ }
11
+ export interface GlobalConfigAccount {
12
+ admin: PublicKey;
13
+ feeAuthority: PublicKey;
14
+ referrer: PublicKey;
15
+ baseFeeBps: number;
16
+ flowFeeBps: number;
17
+ assetMetas: OnchainAssetMeta[];
18
+ }
19
+ export declare function normalizeOracleSource(oracleSource: unknown): OracleSourceName;
20
+ export declare function decodeGlobalConfigAccount(data: Buffer): GlobalConfigAccount;
21
+ export declare function fetchGlobalConfig(connection: Connection, address?: PublicKey): Promise<GlobalConfigAccount>;
22
+ export declare function fetchOnchainAssetMetas(connection: Connection, address?: PublicKey): Promise<Map<string, OnchainAssetMeta>>;
package/src/index.d.ts CHANGED
@@ -3,13 +3,16 @@ export * from "./models";
3
3
  export * from "./clientConfig";
4
4
  export * from "./client";
5
5
  export * from "./client/jupiter";
6
- export * from "./client/drift";
7
6
  export * from "./client/timelock";
8
7
  export * from "./client/cctp";
8
+ export * from "./client/bridge";
9
+ export * from "./client/epi";
9
10
  export * from "./client/price";
10
11
  export * from "./deser/integrationPolicies";
12
+ export * from "./deser/tokenAclLayouts";
11
13
  export * from "./client/base";
12
14
  export * from "./assets";
15
+ export * from "./globalConfig";
13
16
  export * from "./constants";
14
17
  export * from "./error";
15
18
  export * from "./utils";
@@ -1,11 +1,9 @@
1
1
  import type { DelegateAcl, StateModel, IntegrationAcl } from "../models";
2
2
  import { GlamClient } from "../client";
3
3
  import { PublicKey } from "@solana/web3.js";
4
- import { DriftMarketConfigs } from "../client/drift";
5
4
  import { TokenAccount } from "../client/base";
6
5
  import { JupTokenList } from "../utils/jupiterApi";
7
6
  import { VaultHoldings } from "../client/price";
8
- import { DriftUser } from "../deser";
9
7
  declare global {
10
8
  interface Window {
11
9
  glam: GlamClient;
@@ -23,7 +21,6 @@ interface GlamProviderContext {
23
21
  integrationAcls: IntegrationAcl[];
24
22
  allGlamStates: StateModel[];
25
23
  jupTokenList?: JupTokenList;
26
- driftMarketConfigs?: DriftMarketConfigs;
27
24
  wsConnected: boolean;
28
25
  setActiveGlamState: (f: GlamStateCache) => void;
29
26
  refresh: () => Promise<void>;
@@ -34,7 +31,6 @@ export interface Vault {
34
31
  balanceLamports: number;
35
32
  uiAmount: number;
36
33
  tokenAccounts: TokenAccount[];
37
- driftUsers?: DriftUser[];
38
34
  }
39
35
  interface GlamStateCache {
40
36
  address: string;
@@ -5,7 +5,6 @@ export declare const queryKeys: {
5
5
  readonly holdings: (pk: string, cluster: string) => readonly ["vault", string, string, "holdings"];
6
6
  readonly acls: (pk: string, cluster: string) => readonly ["vault", string, string, "acls"];
7
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
8
  readonly stakes: (pk: string, cluster: string) => readonly ["vault", string, string, "stakes"];
10
9
  readonly holders: (mint: string, cluster: string) => readonly ["vault", "holders", string, string];
11
10
  };
@@ -16,7 +15,6 @@ export declare const queryKeys: {
16
15
  readonly allStates: (cluster: string) => readonly ["global", "all-states", string];
17
16
  readonly jupTokens: (cluster: string) => readonly ["global", "jup-tokens", string];
18
17
  readonly jupDexes: (cluster: string) => readonly ["global", "jup-dexes", string];
19
- readonly driftMarkets: (cluster: string) => readonly ["global", "drift-markets", string];
20
18
  readonly kaminoMarkets: (cluster: string) => readonly ["global", "kamino-markets", string];
21
19
  readonly kaminoVaults: (cluster: string) => readonly ["global", "kamino-vaults", string];
22
20
  readonly priorityFee: (cluster: string) => readonly ["global", "priority-fee", string];
@@ -30,7 +28,7 @@ export declare const queryKeys: {
30
28
  readonly status: (sig: string) => readonly ["tx", string];
31
29
  };
32
30
  };
33
- export type InvalidationScope = "balance" | "drift" | "acls" | "wallet" | "graph" | "stakes" | "all";
31
+ export type InvalidationScope = "balance" | "acls" | "wallet" | "graph" | "stakes" | "all";
34
32
  export interface InvalidationContext {
35
33
  vaultPk: string;
36
34
  walletPk: string;
@@ -51,6 +51,11 @@ export declare function fetchMintAndTokenProgram(connection: Connection, mintPub
51
51
  mint: Mint;
52
52
  tokenProgram: PublicKey;
53
53
  }>;
54
+ /**
55
+ * Checks if Token ACL (sRFC-37) is enabled for the given mint by verifying
56
+ * the freeze authority is set to the Token ACL program.
57
+ */
58
+ export declare function isTokenAclEnabled(connection: Connection, mintPubkey: PublicKey): Promise<boolean>;
54
59
  /**
55
60
  * Finds all Address Lookup Tables (ALTs) associated with the current vault.
56
61
  *
@@ -59,6 +64,9 @@ export declare function fetchMintAndTokenProgram(connection: Connection, mintPub
59
64
  * with filters.
60
65
  *
61
66
  * @returns Array of AddressLookupTableAccount objects for the vault
62
- * @throws May throw RPC errors
67
+ * @throws RPC errors from `getProgramAccounts`. Callers that only use the
68
+ * result to optimize transaction size may want to catch and fall back to an
69
+ * empty list; callers that rely on the result for correctness (e.g. ALT
70
+ * management commands) should let the error propagate.
63
71
  */
64
72
  export declare function findGlamLookupTables(statePda: PublicKey, vaultPda: PublicKey, connection: Connection): Promise<AddressLookupTableAccount[]>;
@@ -1,5 +1,8 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { BN } from "@coral-xyz/anchor";
3
+ export declare function resolveStateAclsStaging(integrationAcls: Array<{
4
+ integrationProgram: PublicKey;
5
+ }> | null | undefined, fallback: boolean): boolean;
3
6
  /**
4
7
  * Formats a bitmask as a binary string.
5
8
  *
@@ -3,10 +3,12 @@ import { BN } from "@coral-xyz/anchor";
3
3
  * Converts a buffer or array of character codes to a string
4
4
  */
5
5
  export declare function charsToString(chars: number[] | Buffer): string;
6
+ export declare function charsToName(chars: number[] | Buffer): string;
6
7
  /**
7
8
  * Converts a string to an array of character codes
8
9
  */
9
10
  export declare function stringToChars(name: string, length?: number): number[];
11
+ export declare function nameToChars(name: string, length?: number): number[];
10
12
  /**
11
13
  * Safely converts a BN amount to a UI amount (with decimals).
12
14
  *
@@ -6,4 +6,9 @@ export declare function getEscrowPda(mintPda: PublicKey, programId: PublicKey):
6
6
  export declare function getRequestQueuePda(glamMint: PublicKey, programId: PublicKey): PublicKey;
7
7
  export declare function getExtraMetasPda(mint: PublicKey): PublicKey;
8
8
  export declare function getAccountPolicyPda(tokenAccount: PublicKey): PublicKey;
9
+ export declare function getTokenAclMintConfigPda(mint: PublicKey): PublicKey;
10
+ export declare function getTokenAclFlagAccountPda(tokenAccount: PublicKey): PublicKey;
11
+ export declare function getTokenAclGateListConfigPda(authority: PublicKey, seed: Buffer): PublicKey;
12
+ export declare function getTokenAclGateWalletEntryPda(listConfig: PublicKey, wallet: PublicKey): PublicKey;
13
+ export declare function getTokenAclGateExtraMetasPda(mint: PublicKey): PublicKey;
9
14
  export declare function getGlobalConfigPda(): PublicKey;
@@ -9,7 +9,6 @@ export * from "./lookupTables";
9
9
  export * from "./rpc";
10
10
  export * from "./timelock";
11
11
  export * from "./transaction";
12
- export * from "./drift";
13
12
  export * from "./pkmap";
14
13
  export * from "./pkset";
15
14
  export * from "./fraction";
@@ -3,10 +3,6 @@ import { Commitment, Connection, PublicKey } from "@solana/web3.js";
3
3
  * Categorized external positions by protocol type.
4
4
  */
5
5
  export interface CategorizedPositions {
6
- /** Direct drift user PDAs controlled by the vault */
7
- driftUsers: PublicKey[];
8
- /** Drift vault depositor accounts */
9
- driftVaultDepositors: PublicKey[];
10
6
  /** Kamino lending obligation accounts */
11
7
  kaminoObligations: PublicKey[];
12
8
  /** Kamino vault share token accounts */
@@ -18,8 +14,6 @@ export interface CategorizedPositions {
18
14
  * Utility class for categorizing external positions by protocol type.
19
15
  *
20
16
  * External positions in GLAM vaults can be:
21
- * - Drift user PDAs (direct trading positions)
22
- * - Drift vault depositor accounts (shares in drift vaults)
23
17
  * - Kamino obligation accounts (lending positions)
24
18
  * - Kamino vault share ATAs (shares in kamino vaults)
25
19
  *
@@ -27,25 +21,13 @@ export interface CategorizedPositions {
27
21
  */
28
22
  export declare class PositionCategorizer {
29
23
  private readonly connection;
30
- private readonly vaultPda;
31
- private readonly possibleDriftUserPdas;
32
- constructor(connection: Connection, vaultPda: PublicKey);
33
- /**
34
- * Derives a drift user PDA for a given authority and subAccountId.
35
- */
36
- private getDriftUserPda;
37
- /**
38
- * Checks if a pubkey matches any drift user PDA for subAccountIds 0-99.
39
- * This is a pure computation - no RPC calls needed.
40
- */
41
- isDriftUserPda(pubkey: PublicKey): boolean;
24
+ constructor(connection: Connection, _vaultPda?: PublicKey);
42
25
  /**
43
26
  * Categorizes external positions by protocol type.
44
27
  *
45
28
  * Algorithm:
46
- * 1. Identify drift users by matching against pre-computed PDAs (no RPC)
47
- * 2. Batch fetch remaining positions to determine their type
48
- * 3. Categorize based on account owner and size
29
+ * 1. Batch fetch positions
30
+ * 2. Categorize based on account owner and size
49
31
  *
50
32
  * @param externalPositions - Array of external position pubkeys from state account
51
33
  * @returns Categorized positions by protocol type
@@ -2,7 +2,7 @@
2
2
  "address": "G1NTcMDYgNLpDwgnrpSZvoSKQuR9NXG7S3DmtNQCDmrK",
3
3
  "metadata": {
4
4
  "name": "ext_cctp",
5
- "version": "1.0.0",
5
+ "version": "1.0.1",
6
6
  "spec": "0.1.0",
7
7
  "description": "CCTP integration for GLAM Protocol"
8
8
  },
@@ -2,7 +2,7 @@
2
2
  "address": "gstgKa2Gq9wf5hM3DFWx1TvUrGYzDYszyFGq3XBY9Uq",
3
3
  "metadata": {
4
4
  "name": "ext_kamino",
5
- "version": "1.0.0",
5
+ "version": "1.0.1",
6
6
  "spec": "0.1.0",
7
7
  "description": "Kamino integration for GLAM Protocol"
8
8
  },
@@ -2,7 +2,7 @@
2
2
  "address": "G1NTkDEUR3pkEqGCKZtmtmVzCUEdYa86pezHkwYbLyde",
3
3
  "metadata": {
4
4
  "name": "ext_kamino",
5
- "version": "1.0.0",
5
+ "version": "1.0.1",
6
6
  "spec": "0.1.0",
7
7
  "description": "Kamino integration for GLAM Protocol"
8
8
  },
@@ -1652,6 +1652,114 @@
1652
1652
  }
1653
1653
  ]
1654
1654
  },
1655
+ {
1656
+ "name": "lending_request_elevation_group",
1657
+ "discriminator": [
1658
+ 162,
1659
+ 119,
1660
+ 197,
1661
+ 54,
1662
+ 246,
1663
+ 84,
1664
+ 55,
1665
+ 153
1666
+ ],
1667
+ "accounts": [
1668
+ {
1669
+ "name": "glam_state",
1670
+ "writable": true
1671
+ },
1672
+ {
1673
+ "name": "glam_vault",
1674
+ "writable": true,
1675
+ "pda": {
1676
+ "seeds": [
1677
+ {
1678
+ "kind": "const",
1679
+ "value": [
1680
+ 118,
1681
+ 97,
1682
+ 117,
1683
+ 108,
1684
+ 116
1685
+ ]
1686
+ },
1687
+ {
1688
+ "kind": "account",
1689
+ "path": "glam_state"
1690
+ }
1691
+ ],
1692
+ "program": {
1693
+ "kind": "account",
1694
+ "path": "glam_protocol_program"
1695
+ }
1696
+ }
1697
+ },
1698
+ {
1699
+ "name": "glam_signer",
1700
+ "writable": true,
1701
+ "signer": true
1702
+ },
1703
+ {
1704
+ "name": "integration_authority",
1705
+ "pda": {
1706
+ "seeds": [
1707
+ {
1708
+ "kind": "const",
1709
+ "value": [
1710
+ 105,
1711
+ 110,
1712
+ 116,
1713
+ 101,
1714
+ 103,
1715
+ 114,
1716
+ 97,
1717
+ 116,
1718
+ 105,
1719
+ 111,
1720
+ 110,
1721
+ 45,
1722
+ 97,
1723
+ 117,
1724
+ 116,
1725
+ 104,
1726
+ 111,
1727
+ 114,
1728
+ 105,
1729
+ 116,
1730
+ 121
1731
+ ]
1732
+ }
1733
+ ]
1734
+ }
1735
+ },
1736
+ {
1737
+ "name": "cpi_program",
1738
+ "address": "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD"
1739
+ },
1740
+ {
1741
+ "name": "glam_protocol_program",
1742
+ "address": "GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"
1743
+ },
1744
+ {
1745
+ "name": "system_program",
1746
+ "address": "11111111111111111111111111111111"
1747
+ },
1748
+ {
1749
+ "name": "obligation",
1750
+ "writable": true
1751
+ },
1752
+ {
1753
+ "name": "lending_market"
1754
+ }
1755
+ ],
1756
+ "args": [
1757
+ {
1758
+ "name": "elevation_group",
1759
+ "type": "u8"
1760
+ }
1761
+ ]
1762
+ },
1655
1763
  {
1656
1764
  "name": "lending_withdraw_obligation_collateral_and_redeem_reserve_collateral_v2",
1657
1765
  "discriminator": [
@@ -2,7 +2,7 @@
2
2
  "address": "gstgs9nJgX8PmRHWAAEP9H7xT3ZkaPWSGPYbj3mXdTa",
3
3
  "metadata": {
4
4
  "name": "ext_spl",
5
- "version": "1.0.0",
5
+ "version": "1.0.1",
6
6
  "spec": "0.1.0",
7
7
  "description": "SPL integration for GLAM Protocol"
8
8
  },
@@ -2,7 +2,7 @@
2
2
  "address": "G1NTsQ36mjPe89HtPYqxKsjY5HmYsDR6CbD2gd2U2pta",
3
3
  "metadata": {
4
4
  "name": "ext_spl",
5
- "version": "1.0.0",
5
+ "version": "1.0.1",
6
6
  "spec": "0.1.0",
7
7
  "description": "SPL integration for GLAM Protocol"
8
8
  },
@@ -2,7 +2,7 @@
2
2
  "address": "gConFzxKL9USmwTdJoeQJvfKmqhJ2CyUaXTyQ8v9TGX",
3
3
  "metadata": {
4
4
  "name": "glam_config",
5
- "version": "1.0.0",
5
+ "version": "1.0.1",
6
6
  "spec": "0.1.0",
7
7
  "description": "GLAM config program"
8
8
  },
@@ -36,6 +36,69 @@
36
36
  ],
37
37
  "args": []
38
38
  },
39
+ {
40
+ "name": "delete_asset_meta",
41
+ "docs": [
42
+ "Deletes an asset meta"
43
+ ],
44
+ "discriminator": [
45
+ 108,
46
+ 173,
47
+ 149,
48
+ 99,
49
+ 144,
50
+ 203,
51
+ 21,
52
+ 115
53
+ ],
54
+ "accounts": [
55
+ {
56
+ "name": "global_config",
57
+ "writable": true,
58
+ "pda": {
59
+ "seeds": [
60
+ {
61
+ "kind": "const",
62
+ "value": [
63
+ 103,
64
+ 108,
65
+ 111,
66
+ 98,
67
+ 97,
68
+ 108,
69
+ 45,
70
+ 99,
71
+ 111,
72
+ 110,
73
+ 102,
74
+ 105,
75
+ 103
76
+ ]
77
+ }
78
+ ]
79
+ }
80
+ },
81
+ {
82
+ "name": "admin",
83
+ "writable": true,
84
+ "signer": true
85
+ },
86
+ {
87
+ "name": "system_program",
88
+ "address": "11111111111111111111111111111111"
89
+ }
90
+ ],
91
+ "args": [
92
+ {
93
+ "name": "asset",
94
+ "type": "pubkey"
95
+ },
96
+ {
97
+ "name": "oracle",
98
+ "type": "pubkey"
99
+ }
100
+ ]
101
+ },
39
102
  {
40
103
  "name": "deprecate_asset_meta",
41
104
  "docs": [
@@ -479,28 +542,28 @@
479
542
  },
480
543
  {
481
544
  "code": 6002,
545
+ "name": "AssetMetaNotFound",
546
+ "msg": "Asset meta not found"
547
+ },
548
+ {
549
+ "code": 6003,
482
550
  "name": "InvalidParameters",
483
551
  "msg": "Invalid fee parameters or insufficient account space"
484
552
  },
485
553
  {
486
- "code": 6003,
554
+ "code": 6004,
487
555
  "name": "InvalidOracleSource",
488
556
  "msg": "Invalid oracle source"
489
557
  },
490
558
  {
491
- "code": 6004,
559
+ "code": 6005,
492
560
  "name": "InvalidGlobalConfig",
493
561
  "msg": "Invalid or corrupted global config account"
494
562
  },
495
563
  {
496
- "code": 6005,
564
+ "code": 6006,
497
565
  "name": "InvalidFeeAuthority",
498
566
  "msg": "Invalid fee authority"
499
- },
500
- {
501
- "code": 6006,
502
- "name": "AssetMetaNotFound",
503
- "msg": "Asset meta not found"
504
567
  }
505
568
  ],
506
569
  "types": [
@@ -672,6 +735,12 @@
672
735
  },
673
736
  {
674
737
  "name": "ChainlinkRWA"
738
+ },
739
+ {
740
+ "name": "ChainlinkX"
741
+ },
742
+ {
743
+ "name": "KaminoReserve"
675
744
  }
676
745
  ]
677
746
  }