@glamsystems/glam-sdk 1.0.5 → 1.0.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glamsystems/glam-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "TypeScript SDK for the GLAM Protocol",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
@@ -31,6 +31,7 @@ export declare class BaseClient {
31
31
  cluster: ClusterNetwork;
32
32
  provider: anchor.Provider;
33
33
  blockhashWithCache: BlockhashWithCache;
34
+ jupiterApiKey?: string;
34
35
  private _protocolProgram?;
35
36
  private _mintProgram?;
36
37
  private _extSplProgram?;
@@ -12,6 +12,7 @@ export declare class CctpBridgeEvent {
12
12
  readonly status: string;
13
13
  readonly txHash: string;
14
14
  readonly uiAmount: number;
15
+ slot?: number;
15
16
  constructor(amount: BN, sourceDomain: number, sourceAddress: string, destinationDomain: number, destinationAddress: string, attestation: string, nonce: string, status: string, txHash: string);
16
17
  }
17
18
  declare class TxBuilder extends BaseTxBuilder<CctpClient> {
@@ -1,3 +1,2 @@
1
- export * from "./types";
2
1
  export * from "./protocol-v2";
3
2
  export * from "./vaults";
@@ -4,7 +4,17 @@ import { MarketType, OrderParams, PositionDirection, ModifyOrderParams } from ".
4
4
  import { DriftPerpMarket, DriftSpotMarket, DriftUser } from "../../deser/driftLayouts";
5
5
  import { BaseClient, BaseTxBuilder, TxOptions } from "../base";
6
6
  import { VaultClient } from "../vault";
7
- import { DriftMarketConfigs } from "./types";
7
+ export declare const DRIFT_SIGNER: anchor.web3.PublicKey;
8
+ export declare const DRIFT_MARGIN_PRECISION = 10000;
9
+ export interface OrderConstants {
10
+ perpBaseScale: number;
11
+ quoteScale: number;
12
+ }
13
+ export interface DriftMarketConfigs {
14
+ orderConstants: OrderConstants;
15
+ perpMarkets: DriftPerpMarket[];
16
+ spotMarkets: DriftSpotMarket[];
17
+ }
8
18
  declare class TxBuilder extends BaseTxBuilder<DriftProtocolClient> {
9
19
  initializeUserStatsIx(glamSigner: PublicKey): Promise<TransactionInstruction>;
10
20
  initializeUserIx(glamSigner: PublicKey, subAccountId: number): Promise<TransactionInstruction>;
@@ -1,6 +1,5 @@
1
1
  import { PublicKey, VersionedTransaction, TransactionSignature, AccountMeta, Commitment } from "@solana/web3.js";
2
- import { SpotPosition, PerpPosition } from "../../utils/drift/types";
3
- import { DriftVault } from "../../deser/driftLayouts";
2
+ import { DriftVault, PerpPosition, SpotPosition } from "../../deser/driftLayouts";
4
3
  import { BaseClient, BaseTxBuilder, TxOptions } from "../base";
5
4
  import { BN } from "@coral-xyz/anchor";
6
5
  import { DriftProtocolClient } from "./protocol-v2";
@@ -60,7 +60,7 @@ export declare class PriceClient {
60
60
  getKaminoVaultStates(externalPositionsSet: PkSet, commitment?: Commitment): Promise<PkMap<KVaultState>>;
61
61
  getPubkeysForKaminoHoldings(commitment?: Commitment): Promise<PkMap<PkSet>>;
62
62
  getTokenHoldings(tokenAccountPubkeys: PublicKey[], accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
63
- getDriftSpotHoldings(userPubkeys: Iterable<PublicKey>, spotMarketsMap: PkMap<DriftSpotMarket>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
63
+ getDriftHoldings(userPubkeys: Iterable<PublicKey>, spotMarketsMap: PkMap<DriftSpotMarket>, perpMarketsMap: PkMap<DriftPerpMarket>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
64
64
  getDriftVaultsHoldings(dvaultDepositorsAndVaults: PkMap<DriftVault>, dvaultDepositorsMap: PkMap<DriftVaultDepositor>, spotMarketsMap: PkMap<DriftSpotMarket>, perpMarketsMap: PkMap<DriftPerpMarket>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
65
65
  getKaminoLendHoldings(obligationPubkeys: Iterable<PublicKey>, reservesMap: PkMap<Reserve>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
66
66
  getKaminoVaultsHoldings(kvaultAtasAndStates: PkMap<KVaultState>, reservesMap: PkMap<Reserve>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
@@ -22,4 +22,5 @@ export type GlamClientConfig = {
22
22
  wallet?: Wallet;
23
23
  cluster?: ClusterNetwork;
24
24
  statePda?: PublicKey;
25
+ jupiterApiKey?: string;
25
26
  };
@@ -3,7 +3,48 @@ import { BN } from "@coral-xyz/anchor";
3
3
  import { PublicKey } from "@solana/web3.js";
4
4
  import { Decodable } from "./base";
5
5
  import { PkMap } from "../utils";
6
- import { MarginMode, MarketType, OracleSource, Order, PerpPosition, SpotBalanceType, SpotPosition } from "../utils/drift/types";
6
+ import { MarginMode, MarketType, OracleSource, Order, SpotBalanceType } from "../utils/drift/types";
7
+ export declare class SpotPosition {
8
+ marketIndex: number;
9
+ balanceType: SpotBalanceType;
10
+ scaledBalance: BN;
11
+ openOrders: number;
12
+ openBids: BN;
13
+ openAsks: BN;
14
+ cumulativeDeposits: BN;
15
+ constructor(data: any);
16
+ get marketPda(): PublicKey;
17
+ calcBalance(decimals: number, cumulativeDepositInterest: BN, cumulativeBorrowInterest: BN): {
18
+ amount: number;
19
+ uiAmount: number;
20
+ };
21
+ calcBalanceBn(decimals: number, cumulativeDepositInterest: BN, cumulativeBorrowInterest: BN): BN;
22
+ _interest(cumulativeDepositInterest: BN, cumulativeBorrowInterest: BN): BN;
23
+ get direction(): "borrow" | "deposit";
24
+ }
25
+ export declare class PerpPosition {
26
+ baseAssetAmount: BN;
27
+ lastCumulativeFundingRate: BN;
28
+ marketIndex: number;
29
+ quoteAssetAmount: BN;
30
+ quoteEntryAmount: BN;
31
+ quoteBreakEvenAmount: BN;
32
+ openOrders: number;
33
+ openBids: BN;
34
+ openAsks: BN;
35
+ settledPnl: BN;
36
+ lpShares: BN;
37
+ remainderBaseAssetAmount: number;
38
+ lastBaseAssetAmountPerLp: BN;
39
+ lastQuoteAssetAmountPerLp: BN;
40
+ perLpBase: number;
41
+ constructor(data: any);
42
+ get marketPda(): PublicKey;
43
+ baseAssetValue(oraclePrice: BN): BN;
44
+ unrealizedPnl(oraclePrice: BN): BN;
45
+ getUsdValueScaled(oraclePrice: BN, cumulativeFundingRateLong: BN, cumulativeFundingRateShort: BN): BN;
46
+ calcFundingPayment(cumulativeFundingRateLong: BN, cumulativeFundingRateShort: BN): BN;
47
+ }
7
48
  export declare class DriftVaultDepositor extends Decodable {
8
49
  discriminator: number[];
9
50
  vault: PublicKey;
@@ -27,6 +68,7 @@ export declare class DriftVaultDepositor extends Decodable {
27
68
  fuelAmount: BN;
28
69
  padding: BN[];
29
70
  static _layout: any;
71
+ get netShares(): BN;
30
72
  }
31
73
  export declare class DriftVault extends Decodable {
32
74
  discriminator: number[];
@@ -145,12 +187,6 @@ export declare class DriftSpotMarket extends Decodable {
145
187
  get name(): string;
146
188
  get oracleSource(): OracleSource;
147
189
  get tokenProgramId(): PublicKey;
148
- calcSpotBalance(scaledBalance: BN, scaledBalanceType: SpotBalanceType): {
149
- amount: number;
150
- uiAmount: number;
151
- };
152
- calcSpotBalanceBn(scaledBalance: BN, scaledBalanceType: SpotBalanceType): BN;
153
- _interest(balanceType: SpotBalanceType): BN;
154
190
  }
155
191
  export declare class DriftPerpMarket extends Decodable {
156
192
  discriminator: number[];
@@ -174,5 +210,4 @@ export declare class DriftPerpMarket extends Decodable {
174
210
  static _layout: any;
175
211
  get name(): string;
176
212
  get oracleSource(): OracleSource;
177
- calcFundingPayment(perpPosition: PerpPosition): BN;
178
213
  }
@@ -87,4 +87,11 @@ export declare class StateAccountType {
87
87
  mint: {};
88
88
  };
89
89
  static equals(a: StateAccountType, b: StateAccountType): boolean;
90
+ static from(s: string): {
91
+ vault: {};
92
+ } | {
93
+ tokenizedVault: {};
94
+ } | {
95
+ mint: {};
96
+ };
90
97
  }
@@ -1,5 +1,2 @@
1
1
  export * from "./types";
2
2
  export * from "./orderParams";
3
- import { BN } from "@coral-xyz/anchor";
4
- export declare function readUnsignedBigInt64LE(buffer: Buffer, offset: number): BN;
5
- export declare function readSignedBigInt64LE(buffer: Buffer, offset: number): BN;