@glamsystems/glam-sdk 1.0.13 → 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 (67) hide show
  1. package/README.md +1 -1
  2. package/index.cjs.js +14542 -21898
  3. package/index.esm.js +14521 -21841
  4. package/package.json +2 -2
  5. package/src/assets.d.ts +6 -15
  6. package/src/client/base.d.ts +24 -5
  7. package/src/client/bridge.d.ts +184 -0
  8. package/src/client/bridgeRegistry.d.ts +32 -0
  9. package/src/client/epi.d.ts +78 -0
  10. package/src/client/fees.d.ts +1 -0
  11. package/src/client/jupiter.d.ts +22 -18
  12. package/src/client/price.d.ts +13 -37
  13. package/src/client.d.ts +6 -5
  14. package/src/constants.d.ts +5 -7
  15. package/src/deser/index.d.ts +0 -1
  16. package/src/deser/integrationPolicies.d.ts +23 -20
  17. package/src/error.d.ts +2 -1
  18. package/src/glamExports.d.ts +2423 -1787
  19. package/src/globalConfig.d.ts +22 -0
  20. package/src/index.d.ts +3 -1
  21. package/src/react/glam.d.ts +0 -4
  22. package/src/react/query-keys.d.ts +1 -3
  23. package/src/utils/accounts.d.ts +4 -1
  24. package/src/utils/common.d.ts +2 -0
  25. package/src/utils/index.d.ts +0 -1
  26. package/src/utils/positionCategorizer.d.ts +3 -21
  27. package/target/idl/ext_cctp.json +1 -1
  28. package/target/idl/ext_kamino-staging.json +1 -1
  29. package/target/idl/ext_kamino.json +109 -1
  30. package/target/idl/ext_spl-staging.json +1 -1
  31. package/target/idl/ext_spl.json +1 -1
  32. package/target/idl/glam_config.json +75 -9
  33. package/target/idl/glam_mint.json +205 -11
  34. package/target/idl/glam_policies.json +2 -7
  35. package/target/idl/glam_protocol-staging.json +118 -522
  36. package/target/idl/glam_protocol.json +204 -121
  37. package/target/types/ext_bridge.d.ts +2397 -0
  38. package/target/types/ext_cctp.d.ts +1 -1
  39. package/target/types/ext_cctp.ts +1 -1
  40. package/target/types/ext_epi.d.ts +2175 -0
  41. package/target/types/ext_kamino-staging.ts +1 -1
  42. package/target/types/ext_kamino.d.ts +109 -1
  43. package/target/types/ext_kamino.ts +109 -1
  44. package/target/types/ext_spl-staging.ts +1 -1
  45. package/target/types/ext_spl.d.ts +1 -1
  46. package/target/types/ext_spl.ts +1 -1
  47. package/target/types/glam_config.d.ts +75 -9
  48. package/target/types/glam_config.ts +75 -9
  49. package/target/types/glam_mint.d.ts +205 -11
  50. package/target/types/glam_mint.ts +205 -11
  51. package/target/types/glam_policies.ts +2 -7
  52. package/target/types/glam_protocol-staging.ts +118 -522
  53. package/target/types/glam_protocol.d.ts +204 -121
  54. package/target/types/glam_protocol.ts +204 -121
  55. package/src/client/drift/index.d.ts +0 -2
  56. package/src/client/drift/protocol-v2.d.ts +0 -130
  57. package/src/client/drift/vaults.d.ts +0 -60
  58. package/src/deser/driftLayouts.d.ts +0 -217
  59. package/src/utils/drift/index.d.ts +0 -2
  60. package/src/utils/drift/orderParams.d.ts +0 -28
  61. package/src/utils/drift/types.d.ts +0 -522
  62. package/target/idl/ext_drift-staging.json +0 -5442
  63. package/target/idl/ext_drift.json +0 -4962
  64. package/target/types/ext_drift-staging.ts +0 -5448
  65. package/target/types/ext_drift.d.ts +0 -4968
  66. package/target/types/ext_drift.ts +0 -4968
  67. 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,14 +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";
11
12
  export * from "./deser/tokenAclLayouts";
12
13
  export * from "./client/base";
13
14
  export * from "./assets";
15
+ export * from "./globalConfig";
14
16
  export * from "./constants";
15
17
  export * from "./error";
16
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;
@@ -64,6 +64,9 @@ export declare function isTokenAclEnabled(connection: Connection, mintPubkey: Pu
64
64
  * with filters.
65
65
  *
66
66
  * @returns Array of AddressLookupTableAccount objects for the vault
67
- * @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.
68
71
  */
69
72
  export declare function findGlamLookupTables(statePda: PublicKey, vaultPda: PublicKey, connection: Connection): Promise<AddressLookupTableAccount[]>;
@@ -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
  *
@@ -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": [
@@ -675,6 +738,9 @@
675
738
  },
676
739
  {
677
740
  "name": "ChainlinkX"
741
+ },
742
+ {
743
+ "name": "KaminoReserve"
678
744
  }
679
745
  ]
680
746
  }