@glamsystems/glam-sdk 0.1.30 → 0.1.32

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": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "description": "TypeScript SDK for the GLAM Protocol",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
@@ -26,7 +26,7 @@
26
26
  "@solana/spl-token": "^0.4.9",
27
27
  "@solana/spl-token-metadata": "^0.1.4",
28
28
  "@solana/web3.js": "^1.98.0",
29
- "sanctum-lst-list": "^0.2.53",
29
+ "@glamsystems/sanctum-lst-list": "^0.2.54",
30
30
  "bs58": "^5.0.0",
31
31
  "buffer": "^6.0.3"
32
32
  },
@@ -25,6 +25,7 @@ export interface AssetMeta {
25
25
  oracle: PublicKey;
26
26
  programId?: PublicKey;
27
27
  isLst?: boolean;
28
+ aggIndex?: number;
28
29
  }
29
30
  export declare const ASSETS_MAINNET: Map<string, AssetMeta>;
30
31
  export declare const ASSETS_TESTS: Map<string, AssetMeta>;
@@ -2,6 +2,36 @@ import { BN } from "@coral-xyz/anchor";
2
2
  import { PublicKey, VersionedTransaction, TransactionSignature, TransactionInstruction, AccountMeta } from "@solana/web3.js";
3
3
  import { BaseClient, TxOptions } from "./base";
4
4
  import { KVaultAllocation, KVaultState } from "../deser/kaminoLayouts";
5
+ interface RefreshObligationAccounts {
6
+ lendingMarket: PublicKey;
7
+ obligation: PublicKey;
8
+ reserves: PublicKey[];
9
+ }
10
+ interface RefreshReserveAccounts {
11
+ reserve: PublicKey;
12
+ lendingMarket: PublicKey;
13
+ pythOracle: PublicKey;
14
+ switchboardPriceOracle: PublicKey;
15
+ switchboardTwapOracle: PublicKey;
16
+ scopePrices: PublicKey;
17
+ }
18
+ interface RefreshObligationFarmsForReserveArgs {
19
+ mode: number;
20
+ }
21
+ interface RefreshObligationFarmsForReserveAccounts {
22
+ crank: PublicKey;
23
+ baseAccounts: {
24
+ obligation: PublicKey;
25
+ lendingMarketAuthority: PublicKey;
26
+ reserve: PublicKey;
27
+ reserveFarmState: PublicKey;
28
+ obligationFarmUserState: PublicKey;
29
+ lendingMarket: PublicKey;
30
+ };
31
+ farmsProgram: PublicKey;
32
+ rent: PublicKey;
33
+ systemProgram: PublicKey;
34
+ }
5
35
  interface ParsedReserve {
6
36
  address: PublicKey;
7
37
  market: PublicKey;
@@ -83,6 +113,10 @@ export declare class KaminoLendingClient {
83
113
  id: number;
84
114
  }): PublicKey;
85
115
  getObligationFarmState(obligation: PublicKey, farm: PublicKey): PublicKey;
116
+ refreshObligationIx(accounts: RefreshObligationAccounts, programId?: PublicKey): TransactionInstruction;
117
+ refreshReserveIx(accounts: RefreshReserveAccounts, programId?: PublicKey): TransactionInstruction;
118
+ refreshObligationFarmsForReserveIx(args: RefreshObligationFarmsForReserveArgs, accounts: RefreshObligationFarmsForReserveAccounts, programId?: PublicKey): TransactionInstruction;
119
+ refreshReservesBatchIx(reserves: PublicKey[], lendingMarkets: PublicKey[], skipPriceUpdates: boolean, programId?: PublicKey): TransactionInstruction;
86
120
  refreshReserveIxs(lendingMarket: PublicKey, reserves: PublicKey[]): TransactionInstruction[];
87
121
  refreshObligationCollateralFarmsForReservesIxs(obligation: PublicKey, lendingMarket: PublicKey, parsedReserves: ParsedReserve[]): TransactionInstruction[];
88
122
  refreshObligationDebtFarmsForReservesIxs(obligation: PublicKey, lendingMarket: PublicKey, parsedReserves: ParsedReserve[]): TransactionInstruction[];
@@ -1,7 +1,7 @@
1
1
  import { AccountMeta, PublicKey, TransactionInstruction } from "@solana/web3.js";
2
2
  import { KaminoLendingClient, KaminoVaultsClient } from "./kamino";
3
3
  import { BaseClient } from "./base";
4
- import { PriceDenom } from "../models";
4
+ import { PriceDenom, StateModel } from "../models";
5
5
  import { DriftClient, DriftVaultsClient } from "./drift";
6
6
  export declare class PriceClient {
7
7
  readonly base: BaseClient;
@@ -9,7 +9,14 @@ export declare class PriceClient {
9
9
  readonly kvaults: KaminoVaultsClient;
10
10
  readonly drift: DriftClient;
11
11
  readonly dvaults: DriftVaultsClient;
12
+ private _stateModel;
13
+ private _lookupTables;
14
+ private _kaminoVaults;
12
15
  constructor(base: BaseClient, klend: KaminoLendingClient, kvaults: KaminoVaultsClient, drift: DriftClient, dvaults: DriftVaultsClient);
16
+ get stateModel(): StateModel;
17
+ set stateModel(stateModel: StateModel);
18
+ get lookupTables(): PublicKey[];
19
+ get kaminoVaults(): PublicKey[];
13
20
  /**
14
21
  * !! This is a convenience method that calculates the AUM of the vault based on priced assets.
15
22
  * !! It doesn't reflect the actual AUM of the vault.
package/src/models.d.ts CHANGED
@@ -218,6 +218,11 @@ export declare class PriceDenom {
218
218
  } | {
219
219
  asset6: {};
220
220
  };
221
+ static fromString(str: string): {
222
+ sol: {};
223
+ } | {
224
+ usd: {};
225
+ };
221
226
  }
222
227
  export declare class TimeUnit {
223
228
  static readonly Slot: {
@@ -18,7 +18,6 @@ interface GlamProviderContext {
18
18
  glamStatesList: GlamStateCache[];
19
19
  delegateAcls: DelegateAcl[];
20
20
  allGlamStates: StateModel[];
21
- userWallet: UserWallet;
22
21
  prices: TokenPrice[];
23
22
  jupTokenList?: TokenListItem[];
24
23
  driftMarketConfigs: DriftMarketConfigs;
@@ -26,13 +25,6 @@ interface GlamProviderContext {
26
25
  refresh: () => Promise<void>;
27
26
  refetchGlamStates: () => Promise<void>;
28
27
  }
29
- export interface UserWallet {
30
- queryKey: string[];
31
- pubkey?: PublicKey;
32
- balanceLamports: number;
33
- uiAmount: number;
34
- tokenAccounts: TokenAccount[];
35
- }
36
28
  export interface Vault {
37
29
  pubkey: PublicKey;
38
30
  balanceLamports: number;
@@ -1,10 +1,20 @@
1
1
  import { Connection, PublicKey, TransactionInstruction, AddressLookupTableAccount } from "@solana/web3.js";
2
+ import { type TokenAccount } from "../client/base";
2
3
  export type StakeAccountInfo = {
3
4
  address: PublicKey;
4
5
  lamports: number;
5
6
  state: string;
6
7
  voter?: PublicKey;
7
8
  };
9
+ /**
10
+ * Fetches all the token accounts owned by the specified pubkey.
11
+ */
12
+ export declare function getTokenAccountsByOwner(connection: Connection, owner: PublicKey): Promise<TokenAccount[]>;
13
+ export declare function getSolAndTokenBalances(connection: Connection, owner: PublicKey): Promise<{
14
+ balanceLamports: number;
15
+ uiAmount: number;
16
+ tokenAccounts: TokenAccount[];
17
+ }>;
8
18
  export declare const findStakeAccounts: (connection: Connection, withdrawAuthority: PublicKey) => Promise<PublicKey[]>;
9
19
  export declare const getStakeAccountsWithStates: (connection: Connection, withdrawAuthority: PublicKey) => Promise<StakeAccountInfo[]>;
10
20
  export declare const fetchMeteoraPositions: (connection: Connection, owner: PublicKey) => Promise<PublicKey[]>;
@@ -2,7 +2,7 @@
2
2
  "address": "GLAMbTqav9N9witRjswJ8enwp9vv5G8bsSJ2kPJ4rcyc",
3
3
  "metadata": {
4
4
  "name": "glam_protocol",
5
- "version": "0.4.35",
5
+ "version": "0.4.36",
6
6
  "spec": "0.1.0",
7
7
  "description": "Glam Protocol"
8
8
  },
@@ -975,7 +975,7 @@
975
975
  98,
976
976
  97,
977
977
  108,
978
- 95,
978
+ 45,
979
979
  99,
980
980
  111,
981
981
  110,
@@ -6798,7 +6798,7 @@
6798
6798
  98,
6799
6799
  97,
6800
6800
  108,
6801
- 95,
6801
+ 45,
6802
6802
  99,
6803
6803
  111,
6804
6804
  110,
@@ -6929,7 +6929,7 @@
6929
6929
  98,
6930
6930
  97,
6931
6931
  108,
6932
- 95,
6932
+ 45,
6933
6933
  99,
6934
6934
  111,
6935
6935
  110,
@@ -7065,7 +7065,7 @@
7065
7065
  98,
7066
7066
  97,
7067
7067
  108,
7068
- 95,
7068
+ 45,
7069
7069
  99,
7070
7070
  111,
7071
7071
  110,
@@ -7211,7 +7211,7 @@
7211
7211
  98,
7212
7212
  97,
7213
7213
  108,
7214
- 95,
7214
+ 45,
7215
7215
  99,
7216
7216
  111,
7217
7217
  110,
@@ -7335,7 +7335,7 @@
7335
7335
  98,
7336
7336
  97,
7337
7337
  108,
7338
- 95,
7338
+ 45,
7339
7339
  99,
7340
7340
  111,
7341
7341
  110,
@@ -7455,7 +7455,7 @@
7455
7455
  98,
7456
7456
  97,
7457
7457
  108,
7458
- 95,
7458
+ 45,
7459
7459
  99,
7460
7460
  111,
7461
7461
  110,
@@ -7521,8 +7521,11 @@
7521
7521
  "docs": [
7522
7522
  "Price vault SOL balance and tokens it holds.",
7523
7523
  "",
7524
+ "If aggregation oracle is used for token #`i`, `agg_indexes[i]` must be set to its index in the oracle mapping account.",
7525
+ "",
7524
7526
  "Extra accounts for pricing N tokens:",
7525
- "- (ata, mint, oracle) x N"
7527
+ "- (ata, mint, oracle) x N",
7528
+ "- optional oracle mapping (only add it if any token uses an agg oracle)"
7526
7529
  ],
7527
7530
  "discriminator": [
7528
7531
  54,
@@ -7581,7 +7584,7 @@
7581
7584
  98,
7582
7585
  97,
7583
7586
  108,
7584
- 95,
7587
+ 45,
7585
7588
  99,
7586
7589
  111,
7587
7590
  110,
@@ -7639,6 +7642,12 @@
7639
7642
  "name": "PriceDenom"
7640
7643
  }
7641
7644
  }
7645
+ },
7646
+ {
7647
+ "name": "agg_indexes",
7648
+ "type": {
7649
+ "vec": "i16"
7650
+ }
7642
7651
  }
7643
7652
  ]
7644
7653
  },
@@ -8047,7 +8056,7 @@
8047
8056
  98,
8048
8057
  97,
8049
8058
  108,
8050
- 95,
8059
+ 45,
8051
8060
  99,
8052
8061
  111,
8053
8062
  110,
@@ -9993,7 +10002,8 @@
9993
10002
  ],
9994
10003
  "accounts": [
9995
10004
  {
9996
- "name": "glam_state"
10005
+ "name": "glam_state",
10006
+ "writable": true
9997
10007
  },
9998
10008
  {
9999
10009
  "name": "glam_vault",
@@ -11193,6 +11203,23 @@
11193
11203
  "name": "OracleSource"
11194
11204
  }
11195
11205
  }
11206
+ },
11207
+ {
11208
+ "name": "max_age_seconds",
11209
+ "type": "u16"
11210
+ },
11211
+ {
11212
+ "name": "priority",
11213
+ "type": "u8"
11214
+ },
11215
+ {
11216
+ "name": "padding",
11217
+ "type": {
11218
+ "array": [
11219
+ "u8",
11220
+ 3
11221
+ ]
11222
+ }
11196
11223
  }
11197
11224
  ]
11198
11225
  }
@@ -12293,8 +12320,7 @@
12293
12320
  {
12294
12321
  "name": "fee_authority",
12295
12322
  "docs": [
12296
- "The authority that can modify fee structure of individual glam state",
12297
- "and claim protocol fees"
12323
+ "The authority that can modify fee structure of individual glam state and claim protocol fees"
12298
12324
  ],
12299
12325
  "type": "pubkey"
12300
12326
  },
@@ -13205,6 +13231,9 @@
13205
13231
  {
13206
13232
  "name": "PythLazerStableCoin"
13207
13233
  },
13234
+ {
13235
+ "name": "NotSet"
13236
+ },
13208
13237
  {
13209
13238
  "name": "LstPoolState"
13210
13239
  },
@@ -13213,6 +13242,9 @@
13213
13242
  },
13214
13243
  {
13215
13244
  "name": "BaseAsset"
13245
+ },
13246
+ {
13247
+ "name": "ChainlinkRWA"
13216
13248
  }
13217
13249
  ]
13218
13250
  }
@@ -13540,6 +13572,9 @@
13540
13572
  },
13541
13573
  {
13542
13574
  "name": "Fulfill"
13575
+ },
13576
+ {
13577
+ "name": "ClaimFees"
13543
13578
  }
13544
13579
  ]
13545
13580
  }
@@ -8,7 +8,7 @@ export type GlamProtocol = {
8
8
  "address": "GLAMbTqav9N9witRjswJ8enwp9vv5G8bsSJ2kPJ4rcyc";
9
9
  "metadata": {
10
10
  "name": "glamProtocol";
11
- "version": "0.4.35";
11
+ "version": "0.4.36";
12
12
  "spec": "0.1.0";
13
13
  "description": "Glam Protocol";
14
14
  };
@@ -981,7 +981,7 @@ export type GlamProtocol = {
981
981
  98,
982
982
  97,
983
983
  108,
984
- 95,
984
+ 45,
985
985
  99,
986
986
  111,
987
987
  110,
@@ -6804,7 +6804,7 @@ export type GlamProtocol = {
6804
6804
  98,
6805
6805
  97,
6806
6806
  108,
6807
- 95,
6807
+ 45,
6808
6808
  99,
6809
6809
  111,
6810
6810
  110,
@@ -6935,7 +6935,7 @@ export type GlamProtocol = {
6935
6935
  98,
6936
6936
  97,
6937
6937
  108,
6938
- 95,
6938
+ 45,
6939
6939
  99,
6940
6940
  111,
6941
6941
  110,
@@ -7071,7 +7071,7 @@ export type GlamProtocol = {
7071
7071
  98,
7072
7072
  97,
7073
7073
  108,
7074
- 95,
7074
+ 45,
7075
7075
  99,
7076
7076
  111,
7077
7077
  110,
@@ -7217,7 +7217,7 @@ export type GlamProtocol = {
7217
7217
  98,
7218
7218
  97,
7219
7219
  108,
7220
- 95,
7220
+ 45,
7221
7221
  99,
7222
7222
  111,
7223
7223
  110,
@@ -7341,7 +7341,7 @@ export type GlamProtocol = {
7341
7341
  98,
7342
7342
  97,
7343
7343
  108,
7344
- 95,
7344
+ 45,
7345
7345
  99,
7346
7346
  111,
7347
7347
  110,
@@ -7461,7 +7461,7 @@ export type GlamProtocol = {
7461
7461
  98,
7462
7462
  97,
7463
7463
  108,
7464
- 95,
7464
+ 45,
7465
7465
  99,
7466
7466
  111,
7467
7467
  110,
@@ -7527,8 +7527,11 @@ export type GlamProtocol = {
7527
7527
  "docs": [
7528
7528
  "Price vault SOL balance and tokens it holds.",
7529
7529
  "",
7530
+ "If aggregation oracle is used for token #`i`, `agg_indexes[i]` must be set to its index in the oracle mapping account.",
7531
+ "",
7530
7532
  "Extra accounts for pricing N tokens:",
7531
- "- (ata, mint, oracle) x N"
7533
+ "- (ata, mint, oracle) x N",
7534
+ "- optional oracle mapping (only add it if any token uses an agg oracle)"
7532
7535
  ];
7533
7536
  "discriminator": [
7534
7537
  54,
@@ -7587,7 +7590,7 @@ export type GlamProtocol = {
7587
7590
  98,
7588
7591
  97,
7589
7592
  108,
7590
- 95,
7593
+ 45,
7591
7594
  99,
7592
7595
  111,
7593
7596
  110,
@@ -7645,6 +7648,12 @@ export type GlamProtocol = {
7645
7648
  "name": "priceDenom";
7646
7649
  };
7647
7650
  };
7651
+ },
7652
+ {
7653
+ "name": "aggIndexes";
7654
+ "type": {
7655
+ "vec": "i16";
7656
+ };
7648
7657
  }
7649
7658
  ];
7650
7659
  },
@@ -8053,7 +8062,7 @@ export type GlamProtocol = {
8053
8062
  98,
8054
8063
  97,
8055
8064
  108,
8056
- 95,
8065
+ 45,
8057
8066
  99,
8058
8067
  111,
8059
8068
  110,
@@ -10000,6 +10009,7 @@ export type GlamProtocol = {
10000
10009
  "accounts": [
10001
10010
  {
10002
10011
  "name": "glamState";
10012
+ "writable": true;
10003
10013
  },
10004
10014
  {
10005
10015
  "name": "glamVault";
@@ -11199,6 +11209,23 @@ export type GlamProtocol = {
11199
11209
  "name": "oracleSource";
11200
11210
  };
11201
11211
  };
11212
+ },
11213
+ {
11214
+ "name": "maxAgeSeconds";
11215
+ "type": "u16";
11216
+ },
11217
+ {
11218
+ "name": "priority";
11219
+ "type": "u8";
11220
+ },
11221
+ {
11222
+ "name": "padding";
11223
+ "type": {
11224
+ "array": [
11225
+ "u8",
11226
+ 3
11227
+ ];
11228
+ };
11202
11229
  }
11203
11230
  ];
11204
11231
  };
@@ -12299,8 +12326,7 @@ export type GlamProtocol = {
12299
12326
  {
12300
12327
  "name": "feeAuthority";
12301
12328
  "docs": [
12302
- "The authority that can modify fee structure of individual glam state",
12303
- "and claim protocol fees"
12329
+ "The authority that can modify fee structure of individual glam state and claim protocol fees"
12304
12330
  ];
12305
12331
  "type": "pubkey";
12306
12332
  },
@@ -13211,6 +13237,9 @@ export type GlamProtocol = {
13211
13237
  {
13212
13238
  "name": "pythLazerStableCoin";
13213
13239
  },
13240
+ {
13241
+ "name": "notSet";
13242
+ },
13214
13243
  {
13215
13244
  "name": "lstPoolState";
13216
13245
  },
@@ -13219,6 +13248,9 @@ export type GlamProtocol = {
13219
13248
  },
13220
13249
  {
13221
13250
  "name": "baseAsset";
13251
+ },
13252
+ {
13253
+ "name": "chainlinkRwa";
13222
13254
  }
13223
13255
  ];
13224
13256
  };
@@ -13546,6 +13578,9 @@ export type GlamProtocol = {
13546
13578
  },
13547
13579
  {
13548
13580
  "name": "fulfill";
13581
+ },
13582
+ {
13583
+ "name": "claimFees";
13549
13584
  }
13550
13585
  ];
13551
13586
  };