@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.
- package/LICENSE +201 -0
- package/README.md +1 -1
- package/index.cjs.js +1 -57320
- package/index.esm.js +1 -57081
- package/package.json +26 -15
- package/src/assets.d.ts +10 -17
- package/src/client/access.d.ts +13 -0
- package/src/client/base.d.ts +30 -7
- package/src/client/bridge.d.ts +183 -0
- package/src/client/bridgeRegistry.d.ts +32 -0
- package/src/client/epi.d.ts +78 -0
- package/src/client/fees.d.ts +4 -0
- package/src/client/invest.d.ts +1 -1
- package/src/client/jupiter.d.ts +27 -20
- package/src/client/loopscale.d.ts +84 -0
- package/src/client/mint.d.ts +54 -1
- package/src/client/price.d.ts +26 -39
- package/src/client.d.ts +9 -5
- package/src/constants.d.ts +11 -7
- package/src/deser/index.d.ts +1 -1
- package/src/deser/integrationPolicies.d.ts +30 -20
- package/src/deser/tokenAclLayouts.d.ts +67 -0
- package/src/error.d.ts +2 -1
- package/src/glamExports.d.ts +1351 -1546
- package/src/globalConfig.d.ts +27 -0
- package/src/index.d.ts +5 -1
- package/src/models/state.d.ts +2 -0
- package/src/utils/accounts.d.ts +9 -1
- package/src/utils/bitmask.d.ts +3 -0
- package/src/utils/common.d.ts +2 -0
- package/src/utils/glamPDAs.d.ts +6 -0
- package/src/utils/index.d.ts +0 -1
- package/src/utils/pkmap.d.ts +23 -18
- package/src/utils/positionCategorizer.d.ts +3 -21
- package/target/idl/ext_bridge-staging.json +2379 -0
- package/target/idl/ext_bridge.json +2379 -0
- package/target/idl/ext_cctp.json +1 -1
- package/target/idl/ext_drift.json +1613 -142
- package/target/idl/ext_epi-staging.json +2169 -0
- package/target/idl/ext_epi.json +2169 -0
- package/target/idl/ext_kamino-staging.json +1 -1
- package/target/idl/ext_kamino.json +109 -1
- package/target/idl/{ext_drift-staging.json → ext_loopscale-staging.json} +986 -1438
- package/target/idl/ext_loopscale.json +3541 -0
- package/target/idl/ext_marinade-staging.json +1587 -0
- package/target/idl/ext_spl-staging.json +1 -1
- package/target/idl/ext_spl.json +1 -1
- package/target/idl/glam_config.json +78 -9
- package/target/idl/glam_mint-staging.json +3002 -1244
- package/target/idl/glam_mint.json +239 -8
- package/target/idl/glam_policies.json +2 -7
- package/target/idl/glam_protocol-staging.json +187 -266
- package/target/idl/glam_protocol.json +217 -114
- package/target/idl/mock_layerzero_endpoint.json +144 -0
- package/target/idl/mock_layerzero_oft.json +155 -0
- package/target/types/ext_bridge-staging.d.ts +2385 -0
- package/target/types/ext_bridge-staging.ts +2385 -0
- package/target/types/ext_bridge.d.ts +2385 -0
- package/target/types/ext_bridge.ts +2385 -0
- package/target/types/ext_cctp.d.ts +1 -1
- package/target/types/ext_cctp.ts +1 -1
- package/target/types/ext_drift.d.ts +1609 -138
- package/target/types/ext_drift.ts +1613 -142
- package/target/types/ext_epi-staging.d.ts +2175 -0
- package/target/types/ext_epi-staging.ts +2175 -0
- package/target/types/ext_epi.d.ts +2175 -0
- package/target/types/ext_epi.ts +2175 -0
- package/target/types/ext_kamino-staging.d.ts +3433 -0
- package/target/types/ext_kamino-staging.ts +1 -1
- package/target/types/ext_kamino.d.ts +109 -1
- package/target/types/ext_kamino.ts +109 -1
- package/target/types/ext_loopscale-staging.d.ts +3547 -0
- package/target/types/{ext_drift-staging.ts → ext_loopscale-staging.ts} +988 -1440
- package/target/types/ext_loopscale.d.ts +3547 -0
- package/target/types/ext_loopscale.ts +3547 -0
- package/target/types/ext_marinade-staging.d.ts +1593 -0
- package/target/types/ext_marinade-staging.ts +1593 -0
- package/target/types/{ext_offchain.d.ts → ext_spl-staging.d.ts} +219 -19
- package/target/types/ext_spl-staging.ts +1 -1
- package/target/types/ext_spl.d.ts +1 -1
- package/target/types/ext_spl.ts +1 -1
- package/target/types/ext_stake_pool-staging.d.ts +1622 -0
- package/target/types/glam_config.d.ts +78 -9
- package/target/types/glam_config.ts +78 -9
- package/target/types/glam_mint-staging.d.ts +7856 -0
- package/target/types/glam_mint-staging.ts +3002 -1244
- package/target/types/glam_mint.d.ts +239 -8
- package/target/types/glam_mint.ts +239 -8
- package/target/types/glam_policies.d.ts +477 -0
- package/target/types/glam_policies.ts +2 -7
- package/target/types/glam_protocol-staging.d.ts +3292 -0
- package/target/types/glam_protocol-staging.ts +187 -266
- package/target/types/glam_protocol.d.ts +217 -114
- package/target/types/glam_protocol.ts +217 -114
- package/target/types/mock_layerzero_endpoint.d.ts +150 -0
- package/target/types/mock_layerzero_endpoint.ts +150 -0
- package/target/types/mock_layerzero_oft.d.ts +161 -0
- package/target/types/mock_layerzero_oft.ts +161 -0
- package/src/client/drift/index.d.ts +0 -2
- package/src/client/drift/protocol-v2.d.ts +0 -93
- package/src/client/drift/vaults.d.ts +0 -60
- package/src/deser/driftLayouts.d.ts +0 -217
- package/src/react/cluster-provider.d.ts +0 -22
- package/src/react/glam.d.ts +0 -51
- package/src/react/index.d.ts +0 -5
- package/src/react/query-keys.d.ts +0 -40
- package/src/react/useVaultBalanceSubscription.d.ts +0 -17
- package/src/utils/drift/index.d.ts +0 -2
- package/src/utils/drift/orderParams.d.ts +0 -28
- package/src/utils/drift/types.d.ts +0 -522
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { Decodable } from "./deser/base";
|
|
3
|
+
import { PkMap } from "./utils";
|
|
4
|
+
type RawAssetMeta = {
|
|
5
|
+
asset: PublicKey;
|
|
6
|
+
decimals: number;
|
|
7
|
+
oracle: PublicKey;
|
|
8
|
+
oracleSourceOrdinal: number;
|
|
9
|
+
maxAgeSeconds: number;
|
|
10
|
+
priority: number;
|
|
11
|
+
padding: number[];
|
|
12
|
+
};
|
|
13
|
+
export declare function fetchGlobalConfig(connection: Connection, address?: PublicKey): Promise<GlobalConfig>;
|
|
14
|
+
export declare class GlobalConfig extends Decodable {
|
|
15
|
+
discriminator: number[];
|
|
16
|
+
admin: PublicKey;
|
|
17
|
+
feeAuthority: PublicKey;
|
|
18
|
+
referrer: PublicKey;
|
|
19
|
+
baseFeeBps: number;
|
|
20
|
+
flowFeeBps: number;
|
|
21
|
+
assetMetas: RawAssetMeta[];
|
|
22
|
+
static _layout: any;
|
|
23
|
+
static encode(data: any): Buffer;
|
|
24
|
+
}
|
|
25
|
+
export declare function getOracleName(ordinal: number): string;
|
|
26
|
+
export declare function fetchOnchainAssetMetas(connection: Connection, address?: PublicKey): Promise<PkMap<RawAssetMeta>>;
|
|
27
|
+
export {};
|
package/src/index.d.ts
CHANGED
|
@@ -3,13 +3,17 @@ 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";
|
|
10
|
+
export * from "./client/loopscale";
|
|
9
11
|
export * from "./client/price";
|
|
10
12
|
export * from "./deser/integrationPolicies";
|
|
13
|
+
export * from "./deser/tokenAclLayouts";
|
|
11
14
|
export * from "./client/base";
|
|
12
15
|
export * from "./assets";
|
|
16
|
+
export * from "./globalConfig";
|
|
13
17
|
export * from "./constants";
|
|
14
18
|
export * from "./error";
|
|
15
19
|
export * from "./utils";
|
package/src/models/state.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { RequestQueue } from "./types";
|
|
|
8
8
|
import type { IntegrationAcl, DelegateAcl } from "./acl";
|
|
9
9
|
export type StateAccount = IdlAccounts<GlamProtocol>["stateAccount"];
|
|
10
10
|
export type StateModelType = IdlTypes<GlamProtocol>["stateModel"];
|
|
11
|
+
export type OracleConfigsType = IdlTypes<GlamProtocol>["oracleConfigs"];
|
|
11
12
|
/**
|
|
12
13
|
* State model class as defined in the IDL.
|
|
13
14
|
*/
|
|
@@ -16,6 +17,7 @@ export declare class StateIdlModel implements StateModelType {
|
|
|
16
17
|
name: number[] | null;
|
|
17
18
|
uri: string | null;
|
|
18
19
|
enabled: boolean | null;
|
|
20
|
+
oracleConfigs: OracleConfigsType | null;
|
|
19
21
|
assets: PublicKey[] | null;
|
|
20
22
|
created: CreatedModel | null;
|
|
21
23
|
owner: PublicKey | null;
|
package/src/utils/accounts.d.ts
CHANGED
|
@@ -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
|
|
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[]>;
|
package/src/utils/bitmask.d.ts
CHANGED
|
@@ -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
|
*
|
package/src/utils/common.d.ts
CHANGED
|
@@ -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
|
*
|
package/src/utils/glamPDAs.d.ts
CHANGED
|
@@ -6,4 +6,10 @@ 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;
|
|
15
|
+
export declare function getIntegrationAuthorityPda(integrationProgram: PublicKey): PublicKey;
|
package/src/utils/index.d.ts
CHANGED
package/src/utils/pkmap.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
type PkMapKey = PublicKey | string;
|
|
2
3
|
/**
|
|
3
|
-
* A Map implementation that uses PublicKey
|
|
4
|
+
* A Map implementation that uses PublicKey-compatible keys.
|
|
4
5
|
*
|
|
5
6
|
* This class extends the standard Map and allows using PublicKey objects
|
|
6
|
-
* as keys by converting them to base58 strings internally.
|
|
7
|
-
* problem of PublicKey object reference equality - two
|
|
8
|
-
* with the same address would normally be considered
|
|
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.
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
13
|
* ```typescript
|
|
@@ -16,7 +18,7 @@ import { PublicKey } from "@solana/web3.js";
|
|
|
16
18
|
*
|
|
17
19
|
* // Create with initial entries
|
|
18
20
|
* const map2 = new PkMap<string>([
|
|
19
|
-
* [
|
|
21
|
+
* ["11111111111111111111111111111111", "value1"],
|
|
20
22
|
* [new PublicKey("22222222222222222222222222222222"), "value2"]
|
|
21
23
|
* ]);
|
|
22
24
|
*
|
|
@@ -29,34 +31,36 @@ export declare class PkMap<V> {
|
|
|
29
31
|
private readonly _map;
|
|
30
32
|
/**
|
|
31
33
|
* Creates a new PkMap instance.
|
|
32
|
-
* @param entries - Optional initial entries as [PublicKey, V] pairs
|
|
34
|
+
* @param entries - Optional initial entries as [PublicKey|string, V] pairs
|
|
33
35
|
*/
|
|
34
|
-
constructor(
|
|
36
|
+
constructor();
|
|
37
|
+
constructor(entries?: readonly (readonly [PkMapKey, V])[] | null);
|
|
38
|
+
constructor(entries?: Iterable<readonly [PkMapKey, V]> | null);
|
|
35
39
|
/**
|
|
36
40
|
* Associates the specified value with the specified PublicKey in this map.
|
|
37
|
-
* @param key - The PublicKey to use as the key
|
|
41
|
+
* @param key - The PublicKey or base58 string to use as the key
|
|
38
42
|
* @param value - The value to associate with the key
|
|
39
43
|
* @returns This PkMap instance for chaining
|
|
40
44
|
*/
|
|
41
|
-
set(key:
|
|
45
|
+
set(key: PkMapKey, value: V): this;
|
|
42
46
|
/**
|
|
43
|
-
* Returns the value associated with the specified
|
|
44
|
-
* @param key - The PublicKey whose associated value is to be returned
|
|
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
|
|
45
49
|
* @returns The value associated with the specified key, or undefined
|
|
46
50
|
*/
|
|
47
|
-
get(key:
|
|
51
|
+
get(key: PkMapKey): V | undefined;
|
|
48
52
|
/**
|
|
49
|
-
* Returns true if this map contains a mapping for the specified
|
|
50
|
-
* @param key - The PublicKey whose presence in this map is to be tested
|
|
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
|
|
51
55
|
* @returns true if this map contains a mapping for the specified key
|
|
52
56
|
*/
|
|
53
|
-
has(key:
|
|
57
|
+
has(key: PkMapKey): boolean;
|
|
54
58
|
/**
|
|
55
|
-
* Removes the mapping for the specified
|
|
56
|
-
* @param key - The PublicKey whose mapping is to be removed
|
|
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
|
|
57
61
|
* @returns true if the element was removed, false otherwise
|
|
58
62
|
*/
|
|
59
|
-
delete(key:
|
|
63
|
+
delete(key: PkMapKey): boolean;
|
|
60
64
|
/**
|
|
61
65
|
* Returns an iterator of all PublicKey keys in this map.
|
|
62
66
|
* Note: This reconstructs PublicKey objects from the stored base58 strings.
|
|
@@ -80,3 +84,4 @@ export declare class PkMap<V> {
|
|
|
80
84
|
values(): IterableIterator<V>;
|
|
81
85
|
[Symbol.iterator](): IterableIterator<[PublicKey, V]>;
|
|
82
86
|
}
|
|
87
|
+
export {};
|
|
@@ -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
|
-
|
|
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.
|
|
47
|
-
* 2.
|
|
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
|