@glamsystems/glam-sdk 0.1.4

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/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@glamsystems/glam-sdk",
3
+ "version": "0.1.4",
4
+ "description": "TypeScript SDK for GLAM Protocol",
5
+ "main": "./index.cjs.js",
6
+ "module": "./index.esm.js",
7
+ "homepage": "https://www.glam.systems",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git@github.com:glamsystems/glam.git"
11
+ },
12
+ "keywords": [
13
+ "glam-protocol",
14
+ "solana"
15
+ ],
16
+ "license": "Apache-2.0",
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "dependencies": {
21
+ "@coral-xyz/anchor": "^0.30.1",
22
+ "@drift-labs/sdk": "2.96.0-beta.14",
23
+ "@marinade.finance/marinade-ts-sdk": "^5.0.15",
24
+ "@pythnetwork/client": "^2.21.1",
25
+ "@solana/spl-stake-pool": "^1.1.5",
26
+ "@solana/spl-token": "^0.4.9",
27
+ "@solana/spl-token-metadata": "^0.1.4",
28
+ "@solana/web3.js": "^1.98.0",
29
+ "bs58": "^5.0.0",
30
+ "buffer": "^6.0.3"
31
+ },
32
+ "engines": {
33
+ "node": ">=20.18.0"
34
+ },
35
+ "devDependencies": {
36
+ "@rollup/plugin-terser": "^0.4.4",
37
+ "rollup-plugin-javascript-obfuscator": "^1.0.4"
38
+ },
39
+ "pnpm": {
40
+ "overrides": {
41
+ "@solana/web3.js@>=0.0.1": "^1.98.0",
42
+ "@solana/spl-token@>=0.0.1": "^0.3.9",
43
+ "@solana/spl-stake-pool@>=0.0.1": "^1.1.5",
44
+ "typescript@>=0.0.1": "^5.5.3",
45
+ "solana-bankrun@>=0.0.1": "^0.3.0"
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,18 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ /**
3
+ * Metadata for an asset for pricing
4
+ */
5
+ export declare class AssetMeta {
6
+ pricingAccount?: PublicKey;
7
+ stateAccount?: PublicKey;
8
+ priceFeed?: string;
9
+ programId?: PublicKey;
10
+ }
11
+ /**
12
+ * We use sponsored feed listed on https://docs.pyth.network/price-feeds/sponsored-feeds/solana for popular tokens.
13
+ *
14
+ * For PYUSD, we use the price feed from Drift.
15
+ * For LSTs, we use the state account to calculate the price based on the number of SOLs locked.
16
+ */
17
+ export declare const ASSETS_MAINNET: Map<string, AssetMeta>;
18
+ export declare const ASSETS_TESTS: Map<string, AssetMeta>;
@@ -0,0 +1,100 @@
1
+ import * as anchor from "@coral-xyz/anchor";
2
+ import { Wallet } from "@coral-xyz/anchor";
3
+ import { AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, Keypair, PublicKey, Transaction, TransactionInstruction, TransactionSignature, VersionedTransaction } from "@solana/web3.js";
4
+ import { Mint } from "@solana/spl-token";
5
+ import { GlamProgram } from "../glamExports";
6
+ import { ClusterNetwork, GlamClientConfig } from "../clientConfig";
7
+ import { StateAccount, MetadataAccount, StateModel } from "../models";
8
+ import { AssetMeta } from "./assets";
9
+ import { BlockhashWithCache } from "../utils/blockhash";
10
+ export declare const JUPITER_API_DEFAULT = "https://quote-api.jup.ag/v6";
11
+ export declare const JITO_TIP_DEFAULT: anchor.web3.PublicKey;
12
+ export declare const isBrowser: string | boolean;
13
+ export type TxOptions = {
14
+ signer?: PublicKey;
15
+ computeUnitLimit?: number;
16
+ getPriorityFeeMicroLamports?: (tx: VersionedTransaction) => Promise<number>;
17
+ jitoTipLamports?: number;
18
+ preInstructions?: TransactionInstruction[];
19
+ };
20
+ export type TokenAccount = {
21
+ owner: PublicKey;
22
+ pubkey: PublicKey;
23
+ mint: PublicKey;
24
+ programId: PublicKey;
25
+ decimals: number;
26
+ amount: string;
27
+ uiAmount: number;
28
+ frozen: boolean;
29
+ };
30
+ export declare class BaseClient {
31
+ cluster: ClusterNetwork;
32
+ provider: anchor.Provider;
33
+ program: GlamProgram;
34
+ jupiterApi: string;
35
+ blockhashWithCache: BlockhashWithCache;
36
+ constructor(config?: GlamClientConfig);
37
+ isMainnet(): boolean;
38
+ isPhantom(): boolean;
39
+ /**
40
+ * Get metadata of an asset for pricing
41
+ *
42
+ * @param assetMint Token mint of the asset
43
+ * @returns Metadata of the asset
44
+ */
45
+ getAssetMeta(assetMint: string): AssetMeta;
46
+ intoVersionedTransaction({ tx, lookupTables, signer, computeUnitLimit, getPriorityFeeMicroLamports, jitoTipLamports, latestBlockhash, }: {
47
+ tx: Transaction;
48
+ lookupTables?: Array<AddressLookupTableAccount> | [];
49
+ signer?: PublicKey;
50
+ computeUnitLimit?: number;
51
+ getPriorityFeeMicroLamports?: (tx: VersionedTransaction) => Promise<number>;
52
+ jitoTipLamports?: number;
53
+ latestBlockhash?: BlockhashWithExpiryBlockHeight;
54
+ }): Promise<VersionedTransaction>;
55
+ sendAndConfirm(tx: VersionedTransaction | Transaction, signerOverride?: Keypair): Promise<TransactionSignature>;
56
+ parseProgramLogs(logs?: null | string[]): string;
57
+ getWallet(): Wallet;
58
+ getSigner(): PublicKey;
59
+ getAta(mint: PublicKey, owner?: PublicKey, tokenProgram?: anchor.web3.PublicKey): PublicKey;
60
+ getStatePda(stateModel: Partial<StateModel>): PublicKey;
61
+ getVaultPda(statePda: PublicKey): PublicKey;
62
+ getVaultAta(statePda: PublicKey, mint: PublicKey, programId?: PublicKey): PublicKey;
63
+ /**
64
+ * Fetch all the token accounts (including token program and token 2022 program) owned by a public key.
65
+ *
66
+ * @param owner
67
+ * @returns
68
+ */
69
+ getTokenAccountsByOwner(owner: PublicKey): Promise<TokenAccount[]>;
70
+ getVaultBalance(statePda: PublicKey): Promise<number>;
71
+ getVaultTokenBalance(statePda: PublicKey, mint: PublicKey, programId?: PublicKey): Promise<number>;
72
+ fetchMintWithOwner(asset: PublicKey): Promise<{
73
+ mint: Mint;
74
+ tokenProgram: anchor.web3.PublicKey;
75
+ }>;
76
+ getOpenfundsPda(statePda: PublicKey): PublicKey;
77
+ getShareClassPda(statePda: PublicKey, mintIdx?: number): PublicKey;
78
+ getShareClassAta(user: PublicKey, shareClassPDA: PublicKey): PublicKey;
79
+ getName(stateModel: Partial<StateModel>): string;
80
+ fetchStateAccount(statePda: PublicKey): Promise<StateAccount>;
81
+ fetchMetadataAccount(state: PublicKey): Promise<MetadataAccount>;
82
+ fetchShareClassAccount(state: PublicKey, mintIdx: number): Promise<Mint>;
83
+ /**
84
+ * Generates instructions to wrap SOL into wSOL if the vault doesn't have enough wSOL
85
+ *
86
+ * @param lamports Desired amount of wSOL
87
+ * @returns
88
+ */
89
+ maybeWrapSol(state: PublicKey, amount: number | anchor.BN, signer?: PublicKey): Promise<TransactionInstruction | null>;
90
+ getAssetIdFromCurrency(currency: string): string;
91
+ listGlamStates(): Promise<PublicKey[]>;
92
+ /**
93
+ * Fetch glam state from onchain accounts and build a StateModel
94
+ *
95
+ * @param statePda
96
+ * @returns
97
+ */
98
+ fetchState(statePda: PublicKey): Promise<StateModel>;
99
+ fetchAllGlamStates(): Promise<StateModel[]>;
100
+ }
@@ -0,0 +1,92 @@
1
+ import * as anchor from "@coral-xyz/anchor";
2
+ import { PublicKey, VersionedTransaction, TransactionSignature } from "@solana/web3.js";
3
+ import { MarketType, OrderParams, PositionDirection, SpotPosition, PerpPosition } from "@drift-labs/sdk";
4
+ import { BaseClient, TxOptions } from "./base";
5
+ import { AccountMeta } from "@solana/web3.js";
6
+ import { StateModel } from "../models";
7
+ interface OrderConstants {
8
+ perpBaseScale: number;
9
+ quoteScale: number;
10
+ }
11
+ export interface PerpMarketConfig {
12
+ fullName: string;
13
+ categories: string[];
14
+ symbol: string;
15
+ baseAsset: string;
16
+ marketIndex: number;
17
+ launchTs: string;
18
+ oracle: string;
19
+ oracleSource: string;
20
+ pythPullOraclePDA: string;
21
+ pythFeedId: string;
22
+ marketPDA: string;
23
+ }
24
+ export interface SpotMarketConfig {
25
+ symbol: string;
26
+ decimals: number;
27
+ marketIndex: number;
28
+ launchTs?: string;
29
+ oracle: string;
30
+ oracleSource: string;
31
+ pythPullOraclePDA: string;
32
+ pythFeedId: string;
33
+ marketPDA: string;
34
+ mint: string;
35
+ serumMarket?: string;
36
+ phoenixMarket?: string;
37
+ openBookMarket?: string;
38
+ vaultPDA: string;
39
+ }
40
+ export interface DriftMarketConfigs {
41
+ orderConstants: OrderConstants;
42
+ perp: PerpMarketConfig[];
43
+ spot: SpotMarketConfig[];
44
+ }
45
+ export interface GlamDriftUser {
46
+ delegate: string;
47
+ name: string;
48
+ spotPositions: SpotPosition[];
49
+ perpPositions: PerpPosition[];
50
+ marginMode: string;
51
+ subAccountId: number;
52
+ isMarginTradingEnabled: boolean;
53
+ }
54
+ export declare class DriftClient {
55
+ readonly base: BaseClient;
56
+ constructor(base: BaseClient);
57
+ initialize(statePda: PublicKey): Promise<TransactionSignature>;
58
+ updateUserCustomMarginRatio(statePda: PublicKey, maxLeverage: number, // 1=1x, 2=2x ... 50=50x leverage
59
+ subAccountId?: number): Promise<TransactionSignature>;
60
+ updateUserMarginTradingEnabled(statePda: PublicKey, marginTradingEnabled: boolean, subAccountId?: number): Promise<TransactionSignature>;
61
+ updateUserDelegate(statePda: PublicKey, delegate: PublicKey, subAccountId?: number): Promise<TransactionSignature>;
62
+ deposit(statePda: PublicKey, amount: anchor.BN, marketIndex: number, subAccountId: number, marketConfigs: DriftMarketConfigs, txOptions?: TxOptions): Promise<TransactionSignature>;
63
+ withdraw(statePda: PublicKey, amount: anchor.BN, marketIndex: number, subAccountId: number, marketConfigs: DriftMarketConfigs, txOptions?: TxOptions): Promise<TransactionSignature>;
64
+ placeOrder(statePda: PublicKey, orderParams: OrderParams, subAccountId: number, marketConfigs: DriftMarketConfigs, txOptions?: TxOptions): Promise<TransactionSignature>;
65
+ cancelOrders(statePda: PublicKey, marketType: MarketType, marketIndex: number, direction: PositionDirection, subAccountId: number, marketConfigs: DriftMarketConfigs, txOptions?: TxOptions): Promise<TransactionSignature>;
66
+ DRIFT_PROGRAM: anchor.web3.PublicKey;
67
+ getUser(statePda: PublicKey, subAccountId?: number): PublicKey[];
68
+ getPositions(statePda: PublicKey, subAccountId?: number): Promise<{
69
+ spotPositions: SpotPosition[];
70
+ perpPositions: PerpPosition[];
71
+ }>;
72
+ fetchPolicyConfig(glamState: StateModel): Promise<{
73
+ driftAccessControl: number;
74
+ driftDelegatedAccount: any;
75
+ driftMarketIndexesPerp: number[];
76
+ driftOrderTypes: number[];
77
+ driftMaxLeverage: number;
78
+ driftEnableSpot: any;
79
+ driftMarketIndexesSpot: number[];
80
+ }>;
81
+ composeRemainingAccounts(glamState: PublicKey, subAccountId: number, marketType: MarketType, marketIndex: number, marketConfigs: DriftMarketConfigs): Promise<AccountMeta[]>;
82
+ initializeTx(statePda: PublicKey, txOptions?: TxOptions): Promise<VersionedTransaction>;
83
+ updateUserCustomMarginRatioTx(statePda: PublicKey, maxLeverage: number, // 1=1x, 2=2x ... 50=50x leverage
84
+ subAccountId?: number, txOptions?: TxOptions): Promise<VersionedTransaction>;
85
+ updateUserMarginTradingEnabledTx(statePda: PublicKey, marginTradingEnabled: boolean, subAccountId?: number, txOptions?: TxOptions): Promise<VersionedTransaction>;
86
+ updateUserDelegateTx(statePda: PublicKey, delegate: PublicKey, subAccountId?: number, txOptions?: TxOptions): Promise<VersionedTransaction>;
87
+ depositTx(statePda: PublicKey, amount: anchor.BN, marketIndex: number, subAccountId: number, marketConfigs: DriftMarketConfigs, txOptions?: TxOptions): Promise<VersionedTransaction>;
88
+ withdrawTx(statePda: PublicKey, amount: anchor.BN, marketIndex: number, subAccountId: number, marketConfigs: DriftMarketConfigs, txOptions?: TxOptions): Promise<VersionedTransaction>;
89
+ placeOrderTx(statePda: PublicKey, orderParams: OrderParams, subAccountId: number, marketConfigs: DriftMarketConfigs, txOptions?: TxOptions): Promise<VersionedTransaction>;
90
+ cancelOrdersTx(glamState: PublicKey, marketType: MarketType, marketIndex: number, direction: PositionDirection, subAccountId: number, marketConfigs: DriftMarketConfigs, txOptions?: TxOptions): Promise<VersionedTransaction>;
91
+ }
92
+ export {};
@@ -0,0 +1,12 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { PublicKey, TransactionSignature, VersionedTransaction } from "@solana/web3.js";
3
+ import { BaseClient, TxOptions } from "./base";
4
+ import { StateModel } from "../models";
5
+ export declare class InvestorClient {
6
+ readonly base: BaseClient;
7
+ constructor(base: BaseClient);
8
+ subscribe(statePda: PublicKey, asset: PublicKey, amount: BN, stateModel?: StateModel, shareClassId?: number, skipState?: boolean, txOptions?: TxOptions): Promise<TransactionSignature>;
9
+ redeem(statePda: PublicKey, amount: BN, inKind?: boolean, stateModel?: StateModel, shareClassId?: number, skipState?: boolean, txOptions?: TxOptions): Promise<TransactionSignature>;
10
+ subscribeTx(statePda: PublicKey, asset: PublicKey, amount: BN, stateModel?: StateModel, shareClassId?: number, skipState?: boolean, txOptions?: TxOptions): Promise<VersionedTransaction>;
11
+ redeemTx(statePda: PublicKey, amount: BN, inKind?: boolean, stateModel?: StateModel, shareClassId?: number, skipState?: boolean, txOptions?: TxOptions): Promise<VersionedTransaction>;
12
+ }
@@ -0,0 +1,84 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { AddressLookupTableAccount, PublicKey, TransactionInstruction, TransactionSignature, VersionedTransaction } from "@solana/web3.js";
3
+ import { BaseClient, TxOptions } from "./base";
4
+ export type QuoteParams = {
5
+ inputMint: string;
6
+ outputMint: string;
7
+ amount: number;
8
+ autoSlippage?: boolean;
9
+ autoSlippageCollisionUsdValue?: number;
10
+ slippageBps?: number;
11
+ swapMode?: string;
12
+ onlyDirectRoutes?: boolean;
13
+ asLegacyTransaction?: boolean;
14
+ maxAccounts?: number;
15
+ dexes?: string[];
16
+ excludeDexes?: string[];
17
+ };
18
+ export type QuoteResponse = {
19
+ inputMint: string;
20
+ inAmount: number | string;
21
+ outputMint: string;
22
+ outAmount: number | string;
23
+ otherAmountThreshold: number | string;
24
+ swapMode: string;
25
+ slippageBps: number;
26
+ platformFee: number | null;
27
+ priceImpactPct: number | string;
28
+ routePlan: any[];
29
+ contextSlot: number;
30
+ timeTaken: number;
31
+ };
32
+ type JsonAccountMeta = {
33
+ pubkey: string;
34
+ isSigner: boolean;
35
+ isWritable: boolean;
36
+ };
37
+ type InstructionFromJupiter = {
38
+ programId: string;
39
+ accounts: JsonAccountMeta[];
40
+ data: string;
41
+ };
42
+ type SwapInstructions = {
43
+ tokenLedgerInstruction?: InstructionFromJupiter | null;
44
+ otherInstructions?: InstructionFromJupiter[];
45
+ computeBudgetInstructions: InstructionFromJupiter[];
46
+ setupInstructions?: InstructionFromJupiter[];
47
+ swapInstruction: InstructionFromJupiter;
48
+ cleanupInstruction?: InstructionFromJupiter;
49
+ addressLookupTableAddresses: string[];
50
+ };
51
+ export declare class JupiterClient {
52
+ readonly base: BaseClient;
53
+ constructor(base: BaseClient);
54
+ swap(statePda: PublicKey, quoteParams?: QuoteParams, quoteResponse?: QuoteResponse, swapInstructions?: SwapInstructions, txOptions?: TxOptions): Promise<TransactionSignature>;
55
+ /**
56
+ * Stake JUP. The escrow account will be created if it doesn't exist.
57
+ *
58
+ * @param statePda
59
+ * @param amount
60
+ * @param txOptions
61
+ * @returns
62
+ */
63
+ stakeJup(statePda: PublicKey, amount: BN, txOptions?: TxOptions): Promise<TransactionSignature>;
64
+ unstakeJup(statePda: PublicKey, txOptions?: TxOptions): Promise<string>;
65
+ /**
66
+ * Vote on a proposal. The vote account will be created if it doesn't exist.
67
+ *
68
+ * @param statePda
69
+ * @param proposal
70
+ * @param governor
71
+ * @param side
72
+ * @param txOptions
73
+ * @returns
74
+ */
75
+ voteOnProposal(statePda: PublicKey, proposal: PublicKey, governor: PublicKey, side: number, txOptions?: TxOptions): Promise<TransactionSignature>;
76
+ swapTx(statePda: PublicKey, quoteParams?: QuoteParams, quoteResponse?: QuoteResponse, swapInstructions?: SwapInstructions, txOptions?: TxOptions): Promise<VersionedTransaction>;
77
+ getPreInstructions: (statePda: PublicKey, signer: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, inputTokenProgram?: PublicKey, outputTokenProgram?: PublicKey) => Promise<TransactionInstruction[]>;
78
+ getTokenProgram: (mint: PublicKey) => Promise<PublicKey>;
79
+ toTransactionInstruction: (ixPayload: InstructionFromJupiter) => TransactionInstruction;
80
+ getAdressLookupTableAccounts: (keys?: string[]) => Promise<AddressLookupTableAccount[]>;
81
+ getQuoteResponse(quoteParams: QuoteParams): Promise<any>;
82
+ getSwapInstructions(quoteResponse: any, from: PublicKey): Promise<any>;
83
+ }
84
+ export {};
@@ -0,0 +1,27 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { PublicKey, VersionedTransaction, TransactionSignature } from "@solana/web3.js";
3
+ import { BaseClient, TxOptions } from "./base";
4
+ export declare class MarinadeClient {
5
+ readonly base: BaseClient;
6
+ constructor(base: BaseClient);
7
+ depositSol(statePda: PublicKey, amount: BN): Promise<TransactionSignature>;
8
+ depositStake(statePda: PublicKey, stakeAccount: PublicKey): Promise<TransactionSignature>;
9
+ liquidUnstake(statePda: PublicKey, amount: BN): Promise<TransactionSignature>;
10
+ delayedUnstake(statePda: PublicKey, amount: BN): Promise<TransactionSignature>;
11
+ claimTickets(statePda: PublicKey, tickets: PublicKey[]): Promise<TransactionSignature>;
12
+ getMarinadeTicketPda(state: PublicKey, ticketId: string): [PublicKey, number];
13
+ getExistingTickets(state: PublicKey): Promise<PublicKey[]>;
14
+ getTickets(state: PublicKey): Promise<{
15
+ address: PublicKey;
16
+ lamports: number;
17
+ createdEpoch: number;
18
+ isDue: boolean;
19
+ }[]>;
20
+ getMarinadeState(): any;
21
+ getParsedStakeAccountInfo(stakeAccount: PublicKey): Promise<any>;
22
+ depositSolTx(statePda: PublicKey, amount: BN, txOptions: TxOptions): Promise<VersionedTransaction>;
23
+ depositStakeTx(statePda: PublicKey, stakeAccount: PublicKey, txOptions: TxOptions): Promise<any>;
24
+ delayedUnstakeTx(state: PublicKey, amount: BN, txOptions: TxOptions): Promise<VersionedTransaction>;
25
+ claimTicketsTx(state: PublicKey, tickets: PublicKey[], txOptions: TxOptions): Promise<VersionedTransaction>;
26
+ liquidUnstakeTx(statePda: PublicKey, amount: BN, txOptions: TxOptions): Promise<VersionedTransaction>;
27
+ }
@@ -0,0 +1,44 @@
1
+ import * as anchor from "@coral-xyz/anchor";
2
+ import { PublicKey, TransactionSignature } from "@solana/web3.js";
3
+ import { BaseClient, TokenAccount, TxOptions } from "./base";
4
+ export declare class ShareClassClient {
5
+ readonly base: BaseClient;
6
+ constructor(base: BaseClient);
7
+ getHolders(state: PublicKey, shareClassId?: number): Promise<TokenAccount[]>;
8
+ closeShareClassIx(state: PublicKey, shareClassId?: number): Promise<anchor.web3.TransactionInstruction>;
9
+ closeShareClass(state: PublicKey, shareClassId?: number, txOptions?: TxOptions): Promise<string>;
10
+ /**
11
+ * Create a share class token account for a specific user
12
+ *
13
+ * @param state
14
+ * @param owner
15
+ * @param shareClassId
16
+ * @param txOptions
17
+ * @returns
18
+ */
19
+ createTokenAccount(state: PublicKey, owner: PublicKey, shareClassId?: number, setFrozen?: boolean, txOptions?: TxOptions): Promise<string>;
20
+ /**
21
+ * Freeze or thaw token accounts of a share class
22
+ *
23
+ * @param state
24
+ * @param shareClassId
25
+ * @param frozen
26
+ * @param txOptions
27
+ * @returns
28
+ */
29
+ setTokenAccountsStates(state: PublicKey, shareClassId: number, tokenAccounts: PublicKey[], frozen: boolean, txOptions?: TxOptions): Promise<string>;
30
+ /**
31
+ * Mint share to recipient
32
+ *
33
+ * @param state
34
+ * @param shareClassId
35
+ * @param recipient Recipient's wallet address
36
+ * @param amount Amount of shares to mint
37
+ * @param forceThaw If true, force thaw token account before minting
38
+ * @param txOptions
39
+ * @returns Transaction signature
40
+ */
41
+ mintShare(state: PublicKey, shareClassId: number, recipient: PublicKey, amount: anchor.BN, forceThaw?: boolean, txOptions?: TxOptions): Promise<TransactionSignature>;
42
+ burnShare(state: PublicKey, shareClassId: number, amount: anchor.BN, from: PublicKey, forceThaw?: boolean, txOptions?: TxOptions): Promise<TransactionSignature>;
43
+ forceTransferShare(state: PublicKey, shareClassId: number, amount: anchor.BN, from: PublicKey, to: PublicKey, forceThaw?: boolean, txOptions?: TxOptions): Promise<TransactionSignature>;
44
+ }
@@ -0,0 +1,58 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { PublicKey, VersionedTransaction, TransactionSignature } from "@solana/web3.js";
3
+ import { BaseClient, TxOptions } from "./base";
4
+ import { MarinadeClient } from "./marinade";
5
+ interface StakePoolAccountData {
6
+ programId: PublicKey;
7
+ depositAuthority: PublicKey;
8
+ withdrawAuthority: PublicKey;
9
+ poolMint: PublicKey;
10
+ feeAccount: PublicKey;
11
+ reserveStake: PublicKey;
12
+ tokenProgramId: PublicKey;
13
+ validatorList: PublicKey;
14
+ }
15
+ type StakeAccountInfo = {
16
+ address: PublicKey;
17
+ lamports: number;
18
+ state: string;
19
+ voter?: PublicKey;
20
+ };
21
+ export declare class StakingClient {
22
+ readonly base: BaseClient;
23
+ readonly marinade: MarinadeClient;
24
+ constructor(base: BaseClient, marinade: MarinadeClient);
25
+ unstake(statePda: PublicKey, asset: PublicKey, amount: number | BN, txOptions?: TxOptions): Promise<TransactionSignature>;
26
+ stakePoolDepositSol(statePda: PublicKey, stakePool: PublicKey, amount: BN, txOptions?: TxOptions): Promise<TransactionSignature>;
27
+ stakePoolDepositStake(statePda: PublicKey, stakePool: PublicKey, stakeAccount: PublicKey): Promise<TransactionSignature>;
28
+ stakePoolWithdrawStake(statePda: PublicKey, stakePool: PublicKey, amount: BN): Promise<TransactionSignature>;
29
+ initializeAndDelegateStake(statePda: PublicKey, vote: PublicKey, amount: BN): Promise<TransactionSignature>;
30
+ deactivateStakeAccounts(statePda: PublicKey, stakeAccounts: PublicKey[]): Promise<TransactionSignature>;
31
+ withdrawFromStakeAccounts(statePda: PublicKey, stakeAccounts: PublicKey[]): Promise<TransactionSignature>;
32
+ mergeStakeAccounts(statePda: PublicKey, toStake: PublicKey, fromStake: PublicKey): Promise<TransactionSignature>;
33
+ splitStakeAccount(statePda: PublicKey, existingStake: PublicKey, lamports: BN): Promise<{
34
+ newStake: PublicKey;
35
+ txSig: TransactionSignature;
36
+ }>;
37
+ redelegateStake(statePda: PublicKey, existingStake: PublicKey, vote: PublicKey): Promise<{
38
+ newStake: PublicKey;
39
+ txSig: TransactionSignature;
40
+ }>;
41
+ getStakeAccountPda(state: PublicKey, accountId: string): [PublicKey, number];
42
+ getStakePoolWithdrawAuthority(programId: PublicKey, stakePool: PublicKey): PublicKey;
43
+ getStakePoolDepositAuthority(programId: PublicKey, stakePool: PublicKey): PublicKey;
44
+ getStakeAccounts(withdrawAuthority: PublicKey): Promise<PublicKey[]>;
45
+ getStakeAccountsWithStates(withdrawAuthority: PublicKey): Promise<StakeAccountInfo[]>;
46
+ getStakeAccountVoter(stakeAccount: PublicKey): Promise<PublicKey | null>;
47
+ getStakePoolAccountData(stakePool: PublicKey): Promise<StakePoolAccountData>;
48
+ stakePoolDepositSolTx(statePda: PublicKey, stakePool: PublicKey, amount: BN, txOptions?: TxOptions): Promise<VersionedTransaction>;
49
+ stakePoolDepositStakeTx(statePda: PublicKey, stakePool: PublicKey, stakeAccount: PublicKey, txOptions?: TxOptions): Promise<VersionedTransaction>;
50
+ stakePoolWithdrawStakeTx(statePda: PublicKey, stakePool: PublicKey, amount: BN, deactivate?: boolean, txOptions?: TxOptions): Promise<VersionedTransaction>;
51
+ initializeAndDelegateStakeTx(statePda: PublicKey, vote: PublicKey, amount: BN, txOptions?: TxOptions): Promise<VersionedTransaction>;
52
+ deactivateStakeAccountsTx(statePda: PublicKey, stakeAccounts: PublicKey[], txOptions?: TxOptions): Promise<VersionedTransaction>;
53
+ withdrawFromStakeAccountsTx(statePda: PublicKey, stakeAccounts: PublicKey[], txOptions?: TxOptions): Promise<VersionedTransaction>;
54
+ mergeStakeAccountsTx(statePda: PublicKey, toStake: PublicKey, fromStake: PublicKey, txOptions?: TxOptions): Promise<VersionedTransaction>;
55
+ splitStakeAccountTx(state: PublicKey, existingStake: PublicKey, lamports: BN, newStake: PublicKey, newStakeAccountId: string, newStakeAccountBump: number, txOptions?: TxOptions): Promise<VersionedTransaction>;
56
+ redelegateStakeTx(statePda: PublicKey, existingStake: PublicKey, vote: PublicKey, newStake: PublicKey, newStakeAccountId: string, newStakeAccountBump: number, txOptions?: TxOptions): Promise<VersionedTransaction>;
57
+ }
58
+ export {};
@@ -0,0 +1,41 @@
1
+ import { PublicKey, VersionedTransaction, TransactionInstruction, TransactionSignature } from "@solana/web3.js";
2
+ import { BN } from "@coral-xyz/anchor";
3
+ import { BaseClient, TxOptions } from "./base";
4
+ import { DelegateAcl, StateModel } from "../models";
5
+ export declare class StateClient {
6
+ readonly base: BaseClient;
7
+ constructor(base: BaseClient);
8
+ createState(partialStateModel: Partial<StateModel>, singleTx?: boolean, txOptions?: TxOptions): Promise<[TransactionSignature, PublicKey]>;
9
+ updateState(statePda: PublicKey, updated: Partial<StateModel>, txOptions?: TxOptions): Promise<TransactionSignature>;
10
+ closeState(statePda: PublicKey, txOptions?: TxOptions): Promise<TransactionSignature>;
11
+ /**
12
+ * Create a full state model from a partial state model
13
+ */
14
+ enrichStateModel(partialStateModel: Partial<StateModel>): StateModel;
15
+ /**
16
+ * Delete delegates' access to the fund
17
+ *
18
+ * @param statePda
19
+ * @param delegates Public keys of delegates to be deleted
20
+ * @returns
21
+ */
22
+ deleteDelegateAcls(statePda: PublicKey, delegates: PublicKey[], txOptions?: TxOptions): Promise<TransactionSignature>;
23
+ upsertDelegateAcls(statePda: PublicKey, delegateAcls: DelegateAcl[], txOptions?: TxOptions): Promise<TransactionSignature>;
24
+ setSubscribeRedeemEnabled(statePda: PublicKey, enabled: boolean, txOptions?: TxOptions): Promise<TransactionSignature>;
25
+ closeTokenAccounts(statePda: PublicKey, tokenAccounts: PublicKey[], txOptions?: TxOptions): Promise<TransactionSignature>;
26
+ /**
27
+ * Close fund treasury's token accounts
28
+ *
29
+ * @param statePda
30
+ * @param tokenAccounts
31
+ * @param txOptions
32
+ * @returns
33
+ */
34
+ closeTokenAccountsIx(statePda: PublicKey, tokenAccounts: PublicKey[]): Promise<TransactionInstruction>;
35
+ closeTokenAccountsTx(statePda: PublicKey, tokenAccounts: PublicKey[], txOptions: TxOptions): Promise<VersionedTransaction>;
36
+ deposit(statePda: PublicKey, asset: PublicKey, amount: number | BN, txOptions?: TxOptions): Promise<TransactionSignature>;
37
+ withdraw(statePda: PublicKey, asset: PublicKey, amount: number | BN, txOptions?: TxOptions): Promise<TransactionSignature>;
38
+ depositTx(statePda: PublicKey, asset: PublicKey, amount: number | BN, txOptions: TxOptions): Promise<VersionedTransaction>;
39
+ withdrawIxs(statePda: PublicKey, asset: PublicKey, amount: number | BN, txOptions: TxOptions): Promise<TransactionInstruction[]>;
40
+ withdrawTx(statePda: PublicKey, asset: PublicKey, amount: number | BN, txOptions: TxOptions): Promise<VersionedTransaction>;
41
+ }
@@ -0,0 +1,11 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { PublicKey, VersionedTransaction, TransactionSignature } from "@solana/web3.js";
3
+ import { BaseClient, TxOptions } from "./base";
4
+ export declare class WSolClient {
5
+ readonly base: BaseClient;
6
+ constructor(base: BaseClient);
7
+ wrap(statePda: PublicKey, amount: BN, txOptions?: TxOptions): Promise<TransactionSignature>;
8
+ unwrap(statePda: PublicKey, txOptions?: TxOptions): Promise<TransactionSignature>;
9
+ wrapTx(statePda: PublicKey, amount: BN, txOptions: TxOptions): Promise<VersionedTransaction>;
10
+ unwrapTx(statePda: PublicKey, txOptions: TxOptions): Promise<VersionedTransaction>;
11
+ }
@@ -0,0 +1,35 @@
1
+ import { GlamClientConfig } from "./clientConfig";
2
+ import { BaseClient } from "./client/base";
3
+ import { DriftClient } from "./client/drift";
4
+ import { InvestorClient } from "./client/investor";
5
+ import { JupiterClient } from "./client/jupiter";
6
+ import { MarinadeClient } from "./client/marinade";
7
+ import { WSolClient } from "./client/wsol";
8
+ import { StakingClient } from "./client/staking";
9
+ import { StateClient } from "./client/state";
10
+ import { ShareClassClient } from "./client/shareclass";
11
+ export { JUPITER_API_DEFAULT } from "./client/base";
12
+ /**
13
+ * Main entrypoint for the GLAM SDK
14
+ *
15
+ * Lazy loads each client/module at first use
16
+ */
17
+ export declare class GlamClient extends BaseClient {
18
+ private _drift?;
19
+ private _investor?;
20
+ private _jupiter?;
21
+ private _marinade?;
22
+ private _wsol?;
23
+ private _staking?;
24
+ private _state?;
25
+ private _shareClass?;
26
+ constructor(config?: GlamClientConfig);
27
+ get drift(): DriftClient;
28
+ get investor(): InvestorClient;
29
+ get jupiter(): JupiterClient;
30
+ get marinade(): MarinadeClient;
31
+ get wsol(): WSolClient;
32
+ get staking(): StakingClient;
33
+ get state(): StateClient;
34
+ get shareClass(): ShareClassClient;
35
+ }
@@ -0,0 +1,13 @@
1
+ import { Provider, Wallet } from "@coral-xyz/anchor";
2
+ export declare enum ClusterNetwork {
3
+ Mainnet = "mainnet-beta",
4
+ Testnet = "testnet",
5
+ Devnet = "devnet",
6
+ Custom = "custom"
7
+ }
8
+ export type GlamClientConfig = {
9
+ provider?: Provider;
10
+ wallet?: Wallet;
11
+ cluster?: ClusterNetwork;
12
+ jupiterApi?: string;
13
+ };
@@ -0,0 +1,31 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ /**
3
+ * Token mints. If no devnet version is defined, assume mainnet and devnet addresses are the same.
4
+ *
5
+ * Unless otherwise noted, all mints have 9 decimals.
6
+ */
7
+ export declare const WSOL: PublicKey;
8
+ export declare const MSOL: PublicKey;
9
+ export declare const JITOSOL: PublicKey;
10
+ export declare const USDC: PublicKey;
11
+ export declare const WETH: PublicKey;
12
+ export declare const WBTC: PublicKey;
13
+ export declare const JUP: PublicKey;
14
+ /**
15
+ * Program IDs
16
+ */
17
+ export declare const MARINADE_PROGRAM_ID: PublicKey;
18
+ export declare const DRIFT_PROGRAM_ID: PublicKey;
19
+ export declare const JUPITER_PROGRAM_ID: PublicKey;
20
+ export declare const SANCTUM_STAKE_POOL_PROGRAM_ID: PublicKey;
21
+ export declare const GOVERNANCE_PROGRAM_ID: PublicKey;
22
+ /**
23
+ * Stake pools
24
+ */
25
+ export declare const JITO_STAKE_POOL: PublicKey;
26
+ export declare const JUPSOL_STAKE_POOL: PublicKey;
27
+ /**
28
+ * JUP staking & voting
29
+ */
30
+ export declare const JUP_STAKE_LOCKER: PublicKey;
31
+ export declare const JUP_VOTE_PROGRAM: PublicKey;
package/src/error.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { TransactionError } from "@solana/web3.js";
2
+ export declare class GlamError extends Error {
3
+ message: string;
4
+ rawError?: TransactionError;
5
+ programLogs?: string[];
6
+ constructor(message: string, rawError?: TransactionError, programLogs?: string[]);
7
+ }
@@ -0,0 +1,11 @@
1
+ import { Program } from "@coral-xyz/anchor";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import type { ClusterNetwork } from "./clientConfig";
4
+ import type { Glam } from "../target/types/glam";
5
+ import GlamIDLJson from "../target/idl/glam.json";
6
+ declare const GlamIDL: Glam;
7
+ export { Glam, GlamIDL, GlamIDLJson };
8
+ export type GlamProgram = Program<Glam>;
9
+ export declare const GLAM_PROGRAM_ID_DEV: PublicKey;
10
+ export declare const GLAM_PROGRAM_ID_MAINNET: PublicKey;
11
+ export declare function getGlamProgramId(cluster: ClusterNetwork): PublicKey;
package/src/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ export * from "./glamExports";
2
+ export * from "./models";
3
+ export * from "./clientConfig";
4
+ export * from "./client";
5
+ export * from "./client/jupiter";
6
+ export * from "./client/drift";
7
+ export * from "./utils/helpers";
8
+ export * from "./utils/priorityfee";
9
+ export * from "./constants";
10
+ export * from "./error";