@glamsystems/glam-sdk 1.1.0-alpha.5 → 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
package/package.json CHANGED
@@ -1,27 +1,47 @@
1
1
  {
2
2
  "name": "@glamsystems/glam-sdk",
3
- "version": "1.1.0-alpha.5",
3
+ "version": "1.1.0",
4
4
  "description": "TypeScript SDK for the GLAM Protocol",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
7
+ "types": "./index.esm.d.ts",
7
8
  "homepage": "https://www.glam.systems",
8
9
  "repository": {
9
10
  "type": "git",
10
- "url": "git@github.com:glamsystems/glam-sdk-ts.git"
11
+ "url": "https://github.com/glamsystems/glam-sdk-ts.git"
11
12
  },
12
13
  "keywords": [
13
14
  "glam",
14
15
  "solana"
15
16
  ],
16
17
  "license": "Apache-2.0",
18
+ "scripts": {
19
+ "build": "node scripts/build.mjs",
20
+ "clean": "node scripts/clean.mjs",
21
+ "prepack": "npm run build",
22
+ "pack:dry-run": "npm pack --dry-run --json"
23
+ },
24
+ "files": [
25
+ "README.md",
26
+ "LICENSE",
27
+ "buffer-layout.d.ts",
28
+ "index.cjs.js",
29
+ "index.esm.js",
30
+ "index.cjs.d.ts",
31
+ "index.esm.d.ts",
32
+ "src/**/*.d.ts",
33
+ "target/idl/**/*.json",
34
+ "target/types/**/*.ts",
35
+ "target/types/**/*.d.ts"
36
+ ],
17
37
  "publishConfig": {
18
38
  "access": "public"
19
39
  },
20
40
  "dependencies": {
21
41
  "@coral-xyz/anchor": "^0.31.1",
22
42
  "@coral-xyz/borsh": "^0.31.1",
23
- "@glamsystems/ix-mapper": "0.2.3",
24
- "@glamsystems/sanctum-lst-list": "^0.2.54",
43
+ "@glamsystems/ix-mapper": "0.2.4",
44
+ "@glamsystems/sanctum-lst-list": "^0.2.55",
25
45
  "@marinade.finance/marinade-ts-sdk": "^5.0.15",
26
46
  "@solana/spl-stake-pool": "^1.1.5",
27
47
  "@solana/spl-token": "^0.4.9",
@@ -37,16 +57,8 @@
37
57
  "node": ">=24.0.0"
38
58
  },
39
59
  "devDependencies": {
40
- "@rollup/plugin-terser": "^0.4.4"
41
- },
42
- "pnpm": {
43
- "overrides": {
44
- "@solana/web3.js@>=0.0.1": "^1.98.4",
45
- "@solana/spl-token@>=0.0.1": "^0.4.6",
46
- "@solana/spl-stake-pool@>=0.0.1": "^1.1.5",
47
- "typescript@>=0.0.1": "^5.5.3",
48
- "solana-bankrun@>=0.0.1": "^0.3.0"
49
- }
50
- },
51
- "types": "./index.esm.d.ts"
52
- }
60
+ "@types/node": "^20.17.30",
61
+ "esbuild": "^0.25.2",
62
+ "typescript": "^5.8.3"
63
+ }
64
+ }
@@ -0,0 +1,39 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import { PkMap } from "./utils/pkmap";
3
+ export declare const STAKE_POOLS: {
4
+ name: string;
5
+ symbol: string;
6
+ mint: string;
7
+ decimals: number;
8
+ logoURI: string;
9
+ tokenProgram: PublicKey;
10
+ poolState: PublicKey;
11
+ isMarinade: boolean;
12
+ }[];
13
+ export declare const STAKE_POOLS_MAP: Map<string, {
14
+ name: string;
15
+ symbol: string;
16
+ mint: string;
17
+ decimals: number;
18
+ logoURI: string;
19
+ tokenProgram: PublicKey;
20
+ poolState: PublicKey;
21
+ isMarinade: boolean;
22
+ }>;
23
+ /**
24
+ * Metadata for an asset for pricing
25
+ */
26
+ export interface AssetMeta {
27
+ asset: PublicKey;
28
+ decimals: number;
29
+ oracle: PublicKey;
30
+ programId: PublicKey;
31
+ oracleSource: string;
32
+ }
33
+ /**
34
+ * Transforms the LST list into a map of asset metas.
35
+ *
36
+ * We use functional prices for LSTs, and the oracle pubkey of a LST
37
+ * asset is the pool state.
38
+ */
39
+ export declare const ASSETS_MAINNET: PkMap<AssetMeta>;
@@ -0,0 +1,57 @@
1
+ import { PublicKey, VersionedTransaction, TransactionSignature, TransactionInstruction } from "@solana/web3.js";
2
+ import { BN } from "@coral-xyz/anchor";
3
+ import { BaseClient, BaseTxBuilder, TxOptions } from "./base";
4
+ import { EmergencyAccessUpdateArgs } from "../models";
5
+ declare class TxBuilder extends BaseTxBuilder<AccessClient> {
6
+ emergencyAccessUpdateIx(args: Partial<EmergencyAccessUpdateArgs>, signer?: PublicKey): Promise<TransactionInstruction>;
7
+ emergencyAccessUpdateTx(args: Partial<EmergencyAccessUpdateArgs>, txOptions?: TxOptions): Promise<VersionedTransaction>;
8
+ enableDisableProtocolsIx(integrationProgram: PublicKey, protocolBitmask: number, setEnabled: boolean, glamSigner: PublicKey): Promise<TransactionInstruction>;
9
+ enableDisableProtocolsTx(integrationProgram: PublicKey, protocolBitmask: number, setEnabled: boolean, txOptions: TxOptions): Promise<VersionedTransaction>;
10
+ grantRevokeDelegatePermissionsIx(delegate: PublicKey, integrationProgram: PublicKey, protocolBitflag: number, permissionsBitmask: BN, setGranted: boolean, signer?: PublicKey): Promise<TransactionInstruction>;
11
+ grantRevokeDelegatePermissionsTx(delegate: PublicKey, integrationProgram: PublicKey, protocolBitflag: number, permissionsBitmask: BN, setGranted: boolean, txOptions: TxOptions): Promise<VersionedTransaction>;
12
+ addAssetsIx(assets: PublicKey[], signer?: PublicKey): Promise<TransactionInstruction>;
13
+ addAssetsTx(assets: PublicKey[], txOptions?: TxOptions): Promise<VersionedTransaction>;
14
+ deleteAssetsIx(assets: PublicKey[], signer?: PublicKey): Promise<TransactionInstruction>;
15
+ deleteAssetsTx(assets: PublicKey[], txOptions?: TxOptions): Promise<VersionedTransaction>;
16
+ setProtocolPolicyIx(integrationProgram: PublicKey, protocolBitflag: number, data: Buffer, glamSigner: PublicKey): Promise<TransactionInstruction>;
17
+ setProtocolPolicyTx(integrationProgram: PublicKey, protocolBitflag: number, data: Buffer, txOptions: TxOptions): Promise<VersionedTransaction>;
18
+ }
19
+ export declare class AccessClient {
20
+ readonly base: BaseClient;
21
+ txBuilder: TxBuilder;
22
+ constructor(base: BaseClient);
23
+ /**
24
+ * Add assets to the vault allowlist
25
+ */
26
+ addAssets(assets: PublicKey[], txOptions?: TxOptions): Promise<TransactionSignature>;
27
+ /**
28
+ * Delete assets from the vault allowlist.
29
+ * Assets must have zero vault balance (ATA empty or non-existent).
30
+ */
31
+ deleteAssets(assets: PublicKey[], txOptions?: TxOptions): Promise<TransactionSignature>;
32
+ /**
33
+ * Emergency access update - bypasses timelock for critical access control changes
34
+ */
35
+ emergencyAccessUpdate(args: Partial<EmergencyAccessUpdateArgs>, txOptions?: TxOptions): Promise<TransactionSignature>;
36
+ /**
37
+ * Enable protocols for an integration program
38
+ */
39
+ enableProtocols(integrationProgram: PublicKey, protocolBitmask: number, txOptions?: TxOptions): Promise<TransactionSignature>;
40
+ /**
41
+ * Disable protocols for an integration program
42
+ */
43
+ disableProtocols(integrationProgram: PublicKey, protocolBitmask: number, txOptions?: TxOptions): Promise<TransactionSignature>;
44
+ /**
45
+ * Grant delegate permissions for a specific protocol
46
+ */
47
+ grantDelegatePermissions(delegate: PublicKey, integrationProgram: PublicKey, protocolBitflag: number, permissionsBitmask: BN, txOptions?: TxOptions): Promise<TransactionSignature>;
48
+ /**
49
+ * Revoke delegate permissions for a specific protocol
50
+ */
51
+ revokeDelegatePermissions(delegate: PublicKey, integrationProgram: PublicKey, protocolBitflag: number, permissionsBitmask: BN, txOptions?: TxOptions): Promise<TransactionSignature>;
52
+ /**
53
+ * Set protocol policy data for an integration
54
+ */
55
+ setProtocolPolicy(integrationProgram: PublicKey, protocolBitflag: number, data: Buffer, txOptions?: TxOptions): Promise<TransactionSignature>;
56
+ }
57
+ export {};
@@ -0,0 +1,234 @@
1
+ import * as anchor from "@coral-xyz/anchor";
2
+ import { BN } from "@coral-xyz/anchor";
3
+ import { Wallet } from "@coral-xyz/anchor";
4
+ import { Connection, Keypair, PublicKey, Transaction, TransactionInstruction, TransactionSignature, VersionedTransaction } from "@solana/web3.js";
5
+ import { type LookupTableInput } from "../utils/lookupTables";
6
+ import { ExtBridgeProgram, ExtEpiProgram, ExtCctpProgram, ExtJupiterProgram, ExtKaminoProgram, ExtMarinadeProgram, ExtLoopscaleProgram, ExtPhoenixProgram, ExtOrcaProgram, ExtSplProgram, ExtStakePoolProgram, GlamMintProgram, GlamProtocolProgram } from "../glamExports";
7
+ import { ClusterNetwork, GlamClientConfig } from "../clientConfig";
8
+ import { GlobalConfig } from "../globalConfig";
9
+ import { RequestQueue, StateAccount, StateModel } from "../models";
10
+ import { BlockhashWithCache } from "../utils/blockhash";
11
+ import { JupiterApiClient, PhoenixApiClient, PkMap } from "../utils";
12
+ import { AssetMeta } from "../assets";
13
+ export type TxOptions = {
14
+ signer?: PublicKey;
15
+ computeUnitLimit?: number;
16
+ getPriorityFeeMicroLamports?: (tx: VersionedTransaction) => Promise<number>;
17
+ maxFeeLamports?: number;
18
+ useMaxFee?: boolean;
19
+ preInstructions?: TransactionInstruction[];
20
+ postInstructions?: TransactionInstruction[];
21
+ lookupTables?: LookupTableInput[];
22
+ simulate?: boolean;
23
+ };
24
+ export interface ProtocolPolicyTxBuilder<TPolicy> {
25
+ setPolicyIx(policy: TPolicy, signer?: PublicKey): Promise<TransactionInstruction>;
26
+ setPolicyTx(policy: TPolicy, txOptions?: TxOptions): Promise<VersionedTransaction>;
27
+ clearPolicyIx(signer?: PublicKey): Promise<TransactionInstruction>;
28
+ clearPolicyTx(txOptions?: TxOptions): Promise<VersionedTransaction>;
29
+ }
30
+ export interface ProtocolPolicyClient<TPolicy> {
31
+ fetchPolicy(): Promise<TPolicy | null>;
32
+ setPolicy(policy: TPolicy, txOptions?: TxOptions): Promise<TransactionSignature>;
33
+ clearPolicy(txOptions?: TxOptions): Promise<TransactionSignature>;
34
+ }
35
+ export type TokenAccount = {
36
+ owner: PublicKey;
37
+ pubkey: PublicKey;
38
+ mint: PublicKey;
39
+ programId: PublicKey;
40
+ decimals: number;
41
+ amount: string;
42
+ uiAmount: number;
43
+ frozen: boolean;
44
+ };
45
+ export declare class BaseClient {
46
+ cluster: ClusterNetwork;
47
+ provider: anchor.Provider;
48
+ blockhashWithCache: BlockhashWithCache;
49
+ jupiterApiKey?: string;
50
+ jupiterApiClient?: JupiterApiClient;
51
+ phoenixApiUrl?: string;
52
+ phoenixApiClient?: PhoenixApiClient;
53
+ onSentListeners: Set<(sig: string) => void>;
54
+ readonly staging: boolean;
55
+ private _protocolProgram?;
56
+ private _mintProgram?;
57
+ private _extSplProgram?;
58
+ private _extKaminoProgram?;
59
+ private _extMarinadeProgram?;
60
+ private _extStakePoolProgram?;
61
+ private _extCctpProgram?;
62
+ private _extBridgeProgram?;
63
+ private _extEpiProgram?;
64
+ private _extLoopscaleProgram?;
65
+ private _extPhoenixProgram?;
66
+ private _extJupiterProgram?;
67
+ private _extOrcaProgram?;
68
+ private _statePda?;
69
+ private _globalConfig?;
70
+ private _globalConfigPromise?;
71
+ private _assetMetas?;
72
+ private _assetMetasPromise?;
73
+ private _defaultLookupTablesPromise?;
74
+ private _glamLookupTablesPromise?;
75
+ private _glamLookupTablesCacheKey?;
76
+ constructor(config?: GlamClientConfig);
77
+ get protocolProgram(): GlamProtocolProgram;
78
+ get mintProgram(): GlamMintProgram;
79
+ get extSplProgram(): ExtSplProgram;
80
+ get extKaminoProgram(): ExtKaminoProgram;
81
+ get extMarinadeProgram(): ExtMarinadeProgram;
82
+ get extStakePoolProgram(): ExtStakePoolProgram;
83
+ get extCctpProgram(): ExtCctpProgram;
84
+ get extBridgeProgram(): ExtBridgeProgram;
85
+ get extEpiProgram(): ExtEpiProgram;
86
+ get extLoopscaleProgram(): ExtLoopscaleProgram;
87
+ get extPhoenixProgram(): ExtPhoenixProgram;
88
+ get extJupiterProgram(): ExtJupiterProgram;
89
+ get extOrcaProgram(): ExtOrcaProgram;
90
+ get isVaultConnected(): boolean;
91
+ get statePda(): PublicKey;
92
+ set statePda(statePda: PublicKey);
93
+ /**
94
+ * Mainnet-only default lookup tables (Kamino lending, Loopscale).
95
+ * Cached for the session; safe to assume static contents.
96
+ */
97
+ private getDefaultLookupTables;
98
+ /**
99
+ * Discovers GLAM ALTs for the connected vault and caches the result for the
100
+ * session.
101
+ *
102
+ * Call `invalidateGlamLookupTablesCache()` after creating or extending an ALT
103
+ * to force a re-discovery on the next tx.
104
+ */
105
+ private getGlamLookupTablesCached;
106
+ invalidateGlamLookupTablesCache(): void;
107
+ private warmupGlamLookupTables;
108
+ get isMainnet(): boolean;
109
+ /**
110
+ * Converts a legacy transaction into a versioned transaction.
111
+ */
112
+ intoVersionedTransaction(tx: Transaction, { lookupTables, signer, computeUnitLimit, getPriorityFeeMicroLamports, maxFeeLamports, useMaxFee, simulate, }: TxOptions): Promise<VersionedTransaction>;
113
+ /**
114
+ * Signs, sends, and confirms a transaction.
115
+ *
116
+ * Legacy transactions receive missing fee-payer/blockhash values here and
117
+ * extra signers are applied with `partialSign` before wallet signing.
118
+ * Versioned transactions are expected to be fully built by the caller; extra
119
+ * signers are applied after wallet signing so this remains compatible with
120
+ * transactions created by another `@solana/web3.js` package instance.
121
+ *
122
+ * Transactions are sent with preflight disabled because callers commonly
123
+ * simulate while building compute-budget instructions.
124
+ */
125
+ sendAndConfirm(tx: VersionedTransaction | Transaction, additionalSigners?: Keypair[]): Promise<TransactionSignature>;
126
+ private confirmTransaction;
127
+ get connection(): Connection;
128
+ get signer(): PublicKey;
129
+ get wallet(): Wallet;
130
+ get vaultPda(): PublicKey;
131
+ get mintPda(): PublicKey;
132
+ get escrowPda(): PublicKey;
133
+ get extraMetasPda(): PublicKey;
134
+ get requestQueuePda(): PublicKey;
135
+ /**
136
+ * Returns SOL and token balances of the given owner pubkey
137
+ */
138
+ getSolAndTokenBalances(owner: PublicKey): Promise<{
139
+ balanceLamports: number;
140
+ uiAmount: number;
141
+ tokenAccounts: TokenAccount[];
142
+ }>;
143
+ /**
144
+ * Returns user's token account for the given mint and token program ID
145
+ */
146
+ getAta(mint: PublicKey, owner: PublicKey, tokenProgram?: anchor.web3.PublicKey): PublicKey;
147
+ /**
148
+ * Returns glam vault's token account for the given mint and token program ID
149
+ */
150
+ getVaultAta(mint: PublicKey, tokenProgramId?: PublicKey): PublicKey;
151
+ /**
152
+ * Returns user's glam mint token account
153
+ */
154
+ getMintAta(user?: PublicKey): PublicKey;
155
+ /**
156
+ * Returns glam vault's SOL balance
157
+ */
158
+ getVaultBalance(): Promise<number>;
159
+ /**
160
+ * Returns glam vault's SOL balance in lamports
161
+ */
162
+ getVaultLamports(): Promise<number>;
163
+ /**
164
+ * Returns glam vault's token balance for the given mint
165
+ */
166
+ getVaultTokenBalance(mintPubkey: PublicKey): Promise<{
167
+ amount: BN;
168
+ uiAmount: number;
169
+ }>;
170
+ /**
171
+ * Returns user's glam mint token balance
172
+ */
173
+ getMintTokenBalance(owner?: PublicKey): Promise<{
174
+ amount: BN;
175
+ uiAmount: number;
176
+ }>;
177
+ isLockupEnabled(): Promise<boolean>;
178
+ fetchGlobalConfig(options?: {
179
+ refresh?: boolean;
180
+ }): Promise<GlobalConfig>;
181
+ fetchAssetMetas(options?: {
182
+ refresh?: boolean;
183
+ }): Promise<PkMap<AssetMeta>>;
184
+ refreshAssetMetaCache(): Promise<PkMap<AssetMeta>>;
185
+ getAssetMeta(assetMint: string | PublicKey, options?: {
186
+ refresh?: boolean;
187
+ }): Promise<AssetMeta>;
188
+ getSolOracle(options?: {
189
+ refresh?: boolean;
190
+ }): Promise<PublicKey>;
191
+ fetchStateAccount(statePda?: PublicKey): Promise<StateAccount>;
192
+ private getMintProgramIdForStateAccount;
193
+ private getMintProgramForStateAccount;
194
+ fetchRequestQueue(requestQueuePda?: PublicKey, mintProgram?: GlamMintProgram): Promise<RequestQueue>;
195
+ /**
196
+ * Builds a StateModel from onchain accounts (state, mint, etc)
197
+ *
198
+ * @param statePda Optional state PDA
199
+ */
200
+ fetchStateModel(statePda?: PublicKey): Promise<StateModel>;
201
+ /**
202
+ * Fetches glam state models and applies filters
203
+ *
204
+ * @param filterOptions Filter options
205
+ */
206
+ fetchGlamStates(filterOptions?: {
207
+ owner?: PublicKey;
208
+ delegate?: PublicKey;
209
+ type?: string;
210
+ }): Promise<StateModel[]>;
211
+ fetchProtocolPolicy<T>(integProgramId: PublicKey, protocolBitflag: number, policyClass: {
212
+ decode(buffer: Buffer, staging?: boolean): T;
213
+ }): Promise<T | null>;
214
+ }
215
+ /**
216
+ * Base transaction builder for sub-clients
217
+ */
218
+ export declare class BaseTxBuilder<T extends {
219
+ base: BaseClient;
220
+ }> {
221
+ readonly client: T;
222
+ constructor(client: T);
223
+ clearProtocolPolicyIx(integrationProgram: PublicKey, protocolBitflag: number, signer?: PublicKey): Promise<TransactionInstruction>;
224
+ clearProtocolPolicyTx(integrationProgram: PublicKey, protocolBitflag: number, txOptions?: TxOptions): Promise<VersionedTransaction>;
225
+ /**
226
+ * Build a legacy transaction with the given instructions.
227
+ * Pre and post instructions in txOptions are preserved.
228
+ */
229
+ build(ixs: TransactionInstruction[], txOptions?: TxOptions): Transaction;
230
+ /**
231
+ * Build a versioned transaction that is ready to be sent.
232
+ */
233
+ buildVersionedTx(ixs: TransactionInstruction[], txOptions?: TxOptions): Promise<VersionedTransaction>;
234
+ }
@@ -0,0 +1,205 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { Keypair, PublicKey, TransactionInstruction, TransactionSignature, VersionedTransaction } from "@solana/web3.js";
3
+ import { BaseClient, BaseTxBuilder, ProtocolPolicyClient, ProtocolPolicyTxBuilder, TxOptions } from "./base";
4
+ import { LayerzeroOftRouteProfile } from "./bridgeRegistry";
5
+ import { LayerzeroOftPolicy, LayerzeroOftRoute, RouteManagementMode } from "../deser/integrationPolicies";
6
+ type BufferLike = Uint8Array | number[] | Buffer;
7
+ type RouteManagementModeArg = RouteManagementMode | number | {
8
+ unmanagedOnly: Record<string, never>;
9
+ } | {
10
+ managedOnly: Record<string, never>;
11
+ } | {
12
+ either: Record<string, never>;
13
+ };
14
+ export type LayerzeroOftRouteInput = Omit<LayerzeroOftRoute, "managementMode"> & {
15
+ managementMode: RouteManagementModeArg;
16
+ };
17
+ export type OftTransferParams = {
18
+ transferId: PublicKey;
19
+ sourceMint: PublicKey;
20
+ sourceAmount: BN;
21
+ providerInstructions: TransactionInstruction[];
22
+ providerReceipt: PublicKey;
23
+ managed?: boolean;
24
+ providerSigners?: Keypair[];
25
+ };
26
+ export type LayerzeroOftSendParams = {
27
+ transferId?: PublicKey;
28
+ sourceMint: PublicKey;
29
+ sourceAmount: BN;
30
+ destinationChain: number;
31
+ destinationRecipient: PublicKey;
32
+ nativeFeeLamports: BN;
33
+ minAmountLd?: BN;
34
+ lzTokenFee?: BN;
35
+ options?: BufferLike;
36
+ composeMsg?: BufferLike | null;
37
+ sourceTokenAccount?: PublicKey;
38
+ nonceAccount?: PublicKey;
39
+ managed?: boolean;
40
+ providerProgram?: PublicKey;
41
+ };
42
+ type BridgeTransferStatusAccount = {
43
+ committed: Record<string, never>;
44
+ } | {
45
+ validated: Record<string, never>;
46
+ } | {
47
+ settled: Record<string, never>;
48
+ };
49
+ type BridgeTransferRecordAccount = {
50
+ glamState: PublicKey;
51
+ transferId: PublicKey;
52
+ protocol: number;
53
+ status: BridgeTransferStatusAccount;
54
+ managed: true;
55
+ receiptVerified: true;
56
+ sourceMint: PublicKey;
57
+ sourceDecimals: number;
58
+ providerProgram: PublicKey;
59
+ providerConfig: PublicKey;
60
+ sourceAmount: BN;
61
+ quotedOutAmount: BN;
62
+ destinationChain: number;
63
+ destinationRecipient: PublicKey;
64
+ providerEmitter: PublicKey;
65
+ providerSequence: BN;
66
+ committedSlot: BN;
67
+ };
68
+ export declare function getActiveRegistryTransfers(registry: {
69
+ managedTransferCount: BN | number;
70
+ transfers: any[];
71
+ }): any[];
72
+ export declare function deriveLayerzeroNoncePda(endpointProgram: PublicKey, sender: PublicKey, destinationChain: number, destinationRecipient: PublicKey): PublicKey;
73
+ export declare function deriveOftAuxiliaryAccountSeed(glamState: PublicKey, transferId: PublicKey): Promise<string>;
74
+ export declare function deriveOftAuxiliaryAccount(glamSigner: PublicKey, glamState: PublicKey, transferId: PublicKey, tokenProgram: PublicKey): Promise<{
75
+ address: PublicKey;
76
+ seed: string;
77
+ }>;
78
+ declare class TxBuilder extends BaseTxBuilder<BridgeClient> implements ProtocolPolicyTxBuilder<LayerzeroOftPolicy> {
79
+ setPolicyIx(policy: LayerzeroOftPolicy, signer?: PublicKey): Promise<TransactionInstruction>;
80
+ setPolicyTx(policy: LayerzeroOftPolicy, txOptions?: TxOptions): Promise<VersionedTransaction>;
81
+ clearPolicyIx(signer?: PublicKey): Promise<TransactionInstruction>;
82
+ clearPolicyTx(txOptions?: TxOptions): Promise<VersionedTransaction>;
83
+ addLayerzeroOftRouteIx(route: LayerzeroOftRouteInput, signer?: PublicKey): Promise<TransactionInstruction>;
84
+ updateLayerzeroOftRouteIx(route: LayerzeroOftRouteInput, signer?: PublicKey): Promise<TransactionInstruction>;
85
+ deleteLayerzeroOftRouteIx(route: LayerzeroOftRouteInput, signer?: PublicKey): Promise<TransactionInstruction>;
86
+ buildOftTransferTx(params: OftTransferParams, txOptions?: TxOptions): Promise<{
87
+ tx: VersionedTransaction;
88
+ additionalSigners: Keypair[];
89
+ sessionPda: PublicKey;
90
+ auxiliaryTokenAccount: PublicKey;
91
+ sourceTokenAccount: PublicKey;
92
+ }>;
93
+ }
94
+ declare class LayerzeroOftBridgeProtocolClient {
95
+ readonly bridge: BridgeClient;
96
+ constructor(bridge: BridgeClient);
97
+ buildSendTx(params: LayerzeroOftSendParams, txOptions?: TxOptions): Promise<{
98
+ auxiliaryTokenAccount: PublicKey;
99
+ nonceAccount: PublicKey;
100
+ routeProfile: LayerzeroOftRouteProfile;
101
+ sendInstruction: TransactionInstruction;
102
+ tx: VersionedTransaction;
103
+ additionalSigners: Keypair[];
104
+ sessionPda: PublicKey;
105
+ sourceTokenAccount: PublicKey;
106
+ }>;
107
+ send(params: LayerzeroOftSendParams, txOptions?: TxOptions): Promise<TransactionSignature>;
108
+ }
109
+ export declare class BridgeClient implements ProtocolPolicyClient<LayerzeroOftPolicy> {
110
+ readonly base: BaseClient;
111
+ readonly txBuilder: TxBuilder;
112
+ readonly oft: LayerzeroOftBridgeProtocolClient;
113
+ constructor(base: BaseClient);
114
+ getRegistryPda(): PublicKey;
115
+ getSessionPda(transferId: PublicKey): PublicKey;
116
+ getLayerzeroNoncePda(endpointProgram: PublicKey, sender: PublicKey, destinationChain: number, destinationRecipient: PublicKey): PublicKey;
117
+ deriveOftAuxiliaryTokenAccount(transferId: PublicKey, sourceMint: PublicKey, signer?: PublicKey): Promise<{
118
+ tokenProgram: PublicKey;
119
+ address: PublicKey;
120
+ seed: string;
121
+ }>;
122
+ private resolveLayerzeroOftRouteProfile;
123
+ private resolveLayerzeroOftNonceAccount;
124
+ private materializeLayerzeroOftRemainingAccounts;
125
+ private buildLayerzeroOftInstructionBaseAccounts;
126
+ private buildLayerzeroOftSendInstruction;
127
+ fetchPolicy(): Promise<LayerzeroOftPolicy | null>;
128
+ fetchLayerzeroOftPolicy(): Promise<LayerzeroOftPolicy | null>;
129
+ setPolicy(policy: LayerzeroOftPolicy, txOptions?: TxOptions): Promise<TransactionSignature>;
130
+ clearPolicy(txOptions?: TxOptions): Promise<TransactionSignature>;
131
+ fetchRegistry(): Promise<{
132
+ glamState: PublicKey;
133
+ managedTransferCount: number;
134
+ reserved: number[];
135
+ transfers: {
136
+ transferId: PublicKey;
137
+ sourceMint: PublicKey;
138
+ destinationRecipient: PublicKey;
139
+ providerProgram: PublicKey;
140
+ providerConfig: PublicKey;
141
+ providerEmitter: PublicKey;
142
+ sourceAmount: BN;
143
+ quotedOutAmount: BN;
144
+ providerSequence: BN;
145
+ committedSlot: BN;
146
+ protocol: number;
147
+ destinationChain: number;
148
+ sourceDecimals: number;
149
+ status: number;
150
+ reserved: number[];
151
+ }[];
152
+ } | null>;
153
+ fetchSession(transferId: PublicKey): Promise<{
154
+ glamState: PublicKey;
155
+ signer: PublicKey;
156
+ transferId: PublicKey;
157
+ protocol: number;
158
+ managed: boolean;
159
+ sourceMint: PublicKey;
160
+ sourceDecimals: number;
161
+ sourceTokenAccount: PublicKey;
162
+ providerProgram: PublicKey;
163
+ providerConfig: PublicKey;
164
+ providerSender: PublicKey;
165
+ providerDelegate: PublicKey;
166
+ providerReceipt: PublicKey;
167
+ providerInstructionHash: number[];
168
+ providerInstructionCount: number;
169
+ sourceAmount: BN;
170
+ quotedOutAmount: BN;
171
+ initialSourceBalance: BN;
172
+ initialProviderSequence: BN;
173
+ destinationChain: number;
174
+ destinationRecipient: PublicKey;
175
+ quoteExpiresAt: BN;
176
+ preparedSlot: BN;
177
+ bump: number;
178
+ } | null>;
179
+ fetchTransferRecordNullable(transferId: PublicKey): Promise<BridgeTransferRecordAccount | null>;
180
+ addLayerzeroOftRoute(route: LayerzeroOftRouteInput, txOptions?: TxOptions): Promise<TransactionSignature>;
181
+ updateLayerzeroOftRoute(route: LayerzeroOftRouteInput, txOptions?: TxOptions): Promise<TransactionSignature>;
182
+ deleteLayerzeroOftRoute(route: LayerzeroOftRouteInput, txOptions?: TxOptions): Promise<TransactionSignature>;
183
+ buildOftTransferTx(params: OftTransferParams, txOptions?: TxOptions): Promise<{
184
+ tx: VersionedTransaction;
185
+ additionalSigners: Keypair[];
186
+ sessionPda: PublicKey;
187
+ auxiliaryTokenAccount: PublicKey;
188
+ sourceTokenAccount: PublicKey;
189
+ }>;
190
+ buildLayerzeroOftSendTx(params: LayerzeroOftSendParams, txOptions?: TxOptions): Promise<{
191
+ auxiliaryTokenAccount: PublicKey;
192
+ nonceAccount: PublicKey;
193
+ routeProfile: LayerzeroOftRouteProfile;
194
+ sendInstruction: TransactionInstruction;
195
+ tx: VersionedTransaction;
196
+ additionalSigners: Keypair[];
197
+ sessionPda: PublicKey;
198
+ sourceTokenAccount: PublicKey;
199
+ }>;
200
+ sendOft(params: OftTransferParams, txOptions?: TxOptions): Promise<TransactionSignature>;
201
+ private extendLookupTables;
202
+ settleManagedTransfer(transferId: PublicKey, txOptions?: TxOptions): Promise<string>;
203
+ validateManagedTransfer(transferId: PublicKey, txOptions?: TxOptions): Promise<string>;
204
+ }
205
+ export {};
@@ -0,0 +1,32 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import { ClusterNetwork } from "../clientConfig";
3
+ export type RouteAccountPlaceholder = "payer" | "nonce";
4
+ export type SerializableRouteAccountMeta = {
5
+ pubkey?: PublicKey;
6
+ placeholder?: RouteAccountPlaceholder;
7
+ isSigner: boolean;
8
+ isWritable: boolean;
9
+ };
10
+ export type LayerzeroOftRouteProfile = {
11
+ sourceMint: PublicKey;
12
+ destinationChain: number;
13
+ providerProgram: PublicKey;
14
+ providerConfig: PublicKey;
15
+ nonceAccount?: PublicKey;
16
+ peerConfig: PublicKey;
17
+ providerSender: PublicKey;
18
+ enforcedOptions: PublicKey;
19
+ tokenEscrow: PublicKey;
20
+ eventAuthority: PublicKey;
21
+ lookupTables?: PublicKey[];
22
+ defaultOptions?: Uint8Array | number[] | Buffer;
23
+ defaultMinAmountBps?: number;
24
+ remainingAccounts: SerializableRouteAccountMeta[];
25
+ quoteRemainingAccounts?: SerializableRouteAccountMeta[];
26
+ };
27
+ export declare function resolveCanonicalLayerzeroOftRouteProfile(params: {
28
+ sourceMint: PublicKey;
29
+ destinationChain: number;
30
+ cluster: ClusterNetwork;
31
+ providerProgram?: PublicKey;
32
+ }): LayerzeroOftRouteProfile | null;