@glamsystems/glam-cli 1.0.14-alpha.3 → 1.0.14-alpha.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.
Files changed (2) hide show
  1. package/main.js +19 -4
  2. package/package.json +2 -2
package/main.js CHANGED
@@ -3642,7 +3642,7 @@ class GlamClient extends base_1.BaseClient {
3642
3642
  }
3643
3643
  get jupiterSwap() {
3644
3644
  if (!this._jupiterSwap) {
3645
- this._jupiterSwap = new jupiter_1.JupiterSwapClient(this, this.vault);
3645
+ this._jupiterSwap = new jupiter_1.JupiterSwapClient(this, this.vault, this.kaminoLending);
3646
3646
  }
3647
3647
  return this._jupiterSwap;
3648
3648
  }
@@ -4673,7 +4673,12 @@ class TxBuilder extends base_1.BaseTxBuilder {
4673
4673
  const inputStakePool = assets_1.STAKE_POOLS_MAP.get(inputMint.toBase58())?.poolState || null;
4674
4674
  const outputStakePool = assets_1.STAKE_POOLS_MAP.get(outputMint.toBase58())?.poolState || null;
4675
4675
  const preInstructions = await this.getPreInstructions(glamSigner, inputMint, outputMint, amount, outputTokenProgram);
4676
- // glam_config is auto-resolved by Anchor via its PDA seeds declaration.
4676
+ if (oracleAccounts?.kaminoReservesToRefresh &&
4677
+ oracleAccounts.kaminoReservesToRefresh.length > 0) {
4678
+ const reserves = await this.client.klend.fetchAndParseReserves(oracleAccounts.kaminoReservesToRefresh);
4679
+ const refreshReservesIx = this.client.klend.txBuilder.refreshReservesBatchIx(reserves, false);
4680
+ preInstructions.push(refreshReservesIx);
4681
+ }
4677
4682
  const ix = await this.client.base.protocolProgram.methods
4678
4683
  .jupiterSwapV2(skipQuotePriceCheck, swapIx.data)
4679
4684
  .accounts({
@@ -4701,9 +4706,10 @@ class TxBuilder extends base_1.BaseTxBuilder {
4701
4706
  }
4702
4707
  }
4703
4708
  class JupiterSwapClient {
4704
- constructor(base, vault) {
4709
+ constructor(base, vault, klend) {
4705
4710
  this.base = base;
4706
4711
  this.vault = vault;
4712
+ this.klend = klend;
4707
4713
  this.txBuilder = new TxBuilder(this);
4708
4714
  this.jupApi =
4709
4715
  this.base.jupiterApiClient ||
@@ -47649,10 +47655,19 @@ async function getJupiterSwapV2OracleAccounts(context, tokenFrom, tokenTo, optio
47649
47655
  outputAssetMeta = await context.glamClient.getAssetMeta(tokenTo.address);
47650
47656
  }
47651
47657
  catch { }
47658
+ // input and output asset metas might be kaminoReserve
47659
+ const kaminoReservesToRefresh = [];
47660
+ if (inputAssetMeta?.oracleSource === "KaminoReserve") {
47661
+ kaminoReservesToRefresh.push(inputAssetMeta.oracle);
47662
+ }
47663
+ if (outputAssetMeta?.oracleSource === "KaminoReserve") {
47664
+ kaminoReservesToRefresh.push(outputAssetMeta.oracle);
47665
+ }
47652
47666
  const oracleAccounts = {
47653
47667
  solUsdOracle: await context.glamClient.getSolOracle(),
47654
47668
  inputTokenOracle: inputAssetMeta?.oracle,
47655
47669
  outputTokenOracle: outputAssetMeta?.oracle,
47670
+ kaminoReservesToRefresh,
47656
47671
  };
47657
47672
  if (!options.skipQuotePriceCheck &&
47658
47673
  (!oracleAccounts.inputTokenOracle || !oracleAccounts.outputTokenOracle)) {
@@ -50326,7 +50341,7 @@ program
50326
50341
  initialize(config, skipSimulation);
50327
50342
  await (0, idl_1.idlCheck)(context.glamClient);
50328
50343
  })
50329
- .version("1.0.14-alpha.3");
50344
+ .version("1.0.14-alpha.4");
50330
50345
  program
50331
50346
  .command("env")
50332
50347
  .description("Display current environment setup")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glamsystems/glam-cli",
3
- "version": "1.0.14-alpha.3",
3
+ "version": "1.0.14-alpha.4",
4
4
  "description": "CLI for interacting with the GLAM Protocol",
5
5
  "main": "./main.js",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  "node": ">=20.20.0"
22
22
  },
23
23
  "dependencies": {
24
- "@glamsystems/glam-sdk": "1.0.14-alpha.3",
24
+ "@glamsystems/glam-sdk": "1.0.14-alpha.4",
25
25
  "@switchboard-xyz/common": "^3.0.0",
26
26
  "commander": "^11.1.0",
27
27
  "decimal.js": "^10.6.0",