@glamsystems/glam-sdk 1.0.14-alpha.3 → 1.0.14-alpha.5

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/index.cjs.js CHANGED
@@ -47360,7 +47360,11 @@ let TxBuilder$g = class TxBuilder extends BaseTxBuilder {
47360
47360
  const inputStakePool = STAKE_POOLS_MAP.get(inputMint.toBase58())?.poolState || null;
47361
47361
  const outputStakePool = STAKE_POOLS_MAP.get(outputMint.toBase58())?.poolState || null;
47362
47362
  const preInstructions = await this.getPreInstructions(glamSigner, inputMint, outputMint, amount, outputTokenProgram);
47363
- // glam_config is auto-resolved by Anchor via its PDA seeds declaration.
47363
+ if (oracleAccounts?.kaminoReservesToRefresh && oracleAccounts.kaminoReservesToRefresh.length > 0) {
47364
+ const reserves = await this.client.klend.fetchAndParseReserves(oracleAccounts.kaminoReservesToRefresh);
47365
+ const refreshReservesIx = this.client.klend.txBuilder.refreshReservesBatchIx(reserves, false);
47366
+ preInstructions.push(refreshReservesIx);
47367
+ }
47364
47368
  const ix = await this.client.base.protocolProgram.methods.jupiterSwapV2(skipQuotePriceCheck, swapIx.data).accounts({
47365
47369
  glamState: this.client.base.statePda,
47366
47370
  glamSigner,
@@ -47430,9 +47434,10 @@ class JupiterSwapClient {
47430
47434
  const tx = await this.txBuilder.swapV2Tx(options, txOptions);
47431
47435
  return await this.base.sendAndConfirm(tx);
47432
47436
  }
47433
- constructor(base, vault){
47437
+ constructor(base, vault, klend){
47434
47438
  this.base = base;
47435
47439
  this.vault = vault;
47440
+ this.klend = klend;
47436
47441
  this.txBuilder = new TxBuilder$g(this);
47437
47442
  this.jupApi = this.base.jupiterApiClient || new JupiterApiClient({
47438
47443
  apiKey: this.base.jupiterApiKey
@@ -48175,8 +48180,7 @@ class Reserve extends Decodable {
48175
48180
  get liquidityFeeReceiver() {
48176
48181
  return web3_js.PublicKey.findProgramAddressSync([
48177
48182
  Buffer.from("fee_receiver"),
48178
- this.lendingMarket.toBuffer(),
48179
- this.liquidity.mintPubkey.toBuffer()
48183
+ this._address.toBuffer()
48180
48184
  ], KAMINO_LENDING_PROGRAM)[0];
48181
48185
  }
48182
48186
  get farmDebtNullable() {
@@ -54170,7 +54174,7 @@ class EpiClient {
54170
54174
  }
54171
54175
  get jupiterSwap() {
54172
54176
  if (!this._jupiterSwap) {
54173
- this._jupiterSwap = new JupiterSwapClient(this, this.vault);
54177
+ this._jupiterSwap = new JupiterSwapClient(this, this.vault, this.kaminoLending);
54174
54178
  }
54175
54179
  return this._jupiterSwap;
54176
54180
  }
package/index.esm.js CHANGED
@@ -47340,7 +47340,11 @@ let TxBuilder$g = class TxBuilder extends BaseTxBuilder {
47340
47340
  const inputStakePool = STAKE_POOLS_MAP.get(inputMint.toBase58())?.poolState || null;
47341
47341
  const outputStakePool = STAKE_POOLS_MAP.get(outputMint.toBase58())?.poolState || null;
47342
47342
  const preInstructions = await this.getPreInstructions(glamSigner, inputMint, outputMint, amount, outputTokenProgram);
47343
- // glam_config is auto-resolved by Anchor via its PDA seeds declaration.
47343
+ if (oracleAccounts?.kaminoReservesToRefresh && oracleAccounts.kaminoReservesToRefresh.length > 0) {
47344
+ const reserves = await this.client.klend.fetchAndParseReserves(oracleAccounts.kaminoReservesToRefresh);
47345
+ const refreshReservesIx = this.client.klend.txBuilder.refreshReservesBatchIx(reserves, false);
47346
+ preInstructions.push(refreshReservesIx);
47347
+ }
47344
47348
  const ix = await this.client.base.protocolProgram.methods.jupiterSwapV2(skipQuotePriceCheck, swapIx.data).accounts({
47345
47349
  glamState: this.client.base.statePda,
47346
47350
  glamSigner,
@@ -47410,9 +47414,10 @@ class JupiterSwapClient {
47410
47414
  const tx = await this.txBuilder.swapV2Tx(options, txOptions);
47411
47415
  return await this.base.sendAndConfirm(tx);
47412
47416
  }
47413
- constructor(base, vault){
47417
+ constructor(base, vault, klend){
47414
47418
  this.base = base;
47415
47419
  this.vault = vault;
47420
+ this.klend = klend;
47416
47421
  this.txBuilder = new TxBuilder$g(this);
47417
47422
  this.jupApi = this.base.jupiterApiClient || new JupiterApiClient({
47418
47423
  apiKey: this.base.jupiterApiKey
@@ -48155,8 +48160,7 @@ class Reserve extends Decodable {
48155
48160
  get liquidityFeeReceiver() {
48156
48161
  return PublicKey.findProgramAddressSync([
48157
48162
  Buffer.from("fee_receiver"),
48158
- this.lendingMarket.toBuffer(),
48159
- this.liquidity.mintPubkey.toBuffer()
48163
+ this._address.toBuffer()
48160
48164
  ], KAMINO_LENDING_PROGRAM)[0];
48161
48165
  }
48162
48166
  get farmDebtNullable() {
@@ -54150,7 +54154,7 @@ class EpiClient {
54150
54154
  }
54151
54155
  get jupiterSwap() {
54152
54156
  if (!this._jupiterSwap) {
54153
- this._jupiterSwap = new JupiterSwapClient(this, this.vault);
54157
+ this._jupiterSwap = new JupiterSwapClient(this, this.vault, this.kaminoLending);
54154
54158
  }
54155
54159
  return this._jupiterSwap;
54156
54160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glamsystems/glam-sdk",
3
- "version": "1.0.14-alpha.3",
3
+ "version": "1.0.14-alpha.5",
4
4
  "description": "TypeScript SDK for the GLAM Protocol",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
@@ -3,6 +3,7 @@ import { PublicKey, TransactionInstruction, TransactionSignature, VersionedTrans
3
3
  import { BaseClient, BaseTxBuilder, TxOptions } from "./base";
4
4
  import { VaultClient } from "./vault";
5
5
  import { JupiterApiClient, JupiterInstruction, QuoteParams, QuoteResponse, SwapInstructions } from "../utils/jupiterApi";
6
+ import { KaminoLendingClient } from "./kamino";
6
7
  export type JupiterSwapOptions = {
7
8
  quoteParams?: QuoteParams;
8
9
  quoteResponse?: QuoteResponse;
@@ -13,6 +14,7 @@ export type JupiterSwapV2OracleAccounts = {
13
14
  solUsdOracle?: PublicKey;
14
15
  inputTokenOracle?: PublicKey;
15
16
  outputTokenOracle?: PublicKey;
17
+ kaminoReservesToRefresh: PublicKey[];
16
18
  };
17
19
  export type JupiterSwapV2Options = JupiterSwapOptions & {
18
20
  skipQuotePriceCheck?: boolean;
@@ -33,9 +35,10 @@ declare class TxBuilder extends BaseTxBuilder<JupiterSwapClient> {
33
35
  export declare class JupiterSwapClient {
34
36
  readonly base: BaseClient;
35
37
  readonly vault: VaultClient;
38
+ readonly klend: KaminoLendingClient;
36
39
  readonly txBuilder: TxBuilder;
37
40
  readonly jupApi: JupiterApiClient;
38
- constructor(base: BaseClient, vault: VaultClient);
41
+ constructor(base: BaseClient, vault: VaultClient, klend: KaminoLendingClient);
39
42
  swap(options: JupiterSwapOptions, txOptions?: TxOptions): Promise<TransactionSignature>;
40
43
  swapV2(options: JupiterSwapV2Options, txOptions?: TxOptions): Promise<TransactionSignature>;
41
44
  }