@glamsystems/glam-cli 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.
Files changed (2) hide show
  1. package/main.js +57 -9
  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 ||
@@ -6263,11 +6269,7 @@ class Reserve extends base_1.Decodable {
6263
6269
  return this.config.tokenInfo.scopeConfiguration.priceFeed;
6264
6270
  }
6265
6271
  get liquidityFeeReceiver() {
6266
- return web3_js_1.PublicKey.findProgramAddressSync([
6267
- Buffer.from("fee_receiver"),
6268
- this.lendingMarket.toBuffer(),
6269
- this.liquidity.mintPubkey.toBuffer(),
6270
- ], constants_1.KAMINO_LENDING_PROGRAM)[0];
6272
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fee_receiver"), this._address.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM)[0];
6271
6273
  }
6272
6274
  get farmDebtNullable() {
6273
6275
  return this.farmDebt.equals(web3_js_1.PublicKey.default) ? null : this.farmDebt;
@@ -47649,10 +47651,19 @@ async function getJupiterSwapV2OracleAccounts(context, tokenFrom, tokenTo, optio
47649
47651
  outputAssetMeta = await context.glamClient.getAssetMeta(tokenTo.address);
47650
47652
  }
47651
47653
  catch { }
47654
+ // input and output asset metas might be kaminoReserve
47655
+ const kaminoReservesToRefresh = [];
47656
+ if (inputAssetMeta?.oracleSource === "KaminoReserve") {
47657
+ kaminoReservesToRefresh.push(inputAssetMeta.oracle);
47658
+ }
47659
+ if (outputAssetMeta?.oracleSource === "KaminoReserve") {
47660
+ kaminoReservesToRefresh.push(outputAssetMeta.oracle);
47661
+ }
47652
47662
  const oracleAccounts = {
47653
47663
  solUsdOracle: await context.glamClient.getSolOracle(),
47654
47664
  inputTokenOracle: inputAssetMeta?.oracle,
47655
47665
  outputTokenOracle: outputAssetMeta?.oracle,
47666
+ kaminoReservesToRefresh,
47656
47667
  };
47657
47668
  if (!options.skipQuotePriceCheck &&
47658
47669
  (!oracleAccounts.inputTokenOracle || !oracleAccounts.outputTokenOracle)) {
@@ -48554,6 +48565,43 @@ function installVaultCommands(program, context) {
48554
48565
  message: `Confirm removing ${asset} from allowlist?`,
48555
48566
  }, (txSig) => `${asset} removed from allowlist: ${txSig}`);
48556
48567
  });
48568
+ program
48569
+ .command("allowlist-borrowable-asset")
48570
+ .argument("<asset>", "Borrowable asset mint public key", utils_1.validatePublicKey)
48571
+ .option("-y, --yes", "Skip confirmation prompt", false)
48572
+ .description("Add a borrowable asset to the global borrowable allowlist")
48573
+ .action(async (asset, options) => {
48574
+ const stateModel = await context.glamClient.fetchStateModel();
48575
+ const borrowableSet = new glam_sdk_1.PkSet(stateModel.borrowable || []);
48576
+ if (borrowableSet.has(asset)) {
48577
+ console.error(`Borrowable asset ${asset} already allowlisted`);
48578
+ process.exit(1);
48579
+ }
48580
+ const borrowable = Array.from(borrowableSet.add(asset));
48581
+ await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.state.update({ borrowable }, context.txOptions), {
48582
+ skip: options?.yes,
48583
+ message: `Confirm adding ${asset} to global borrowable allowlist?`,
48584
+ }, (txSig) => `${asset} added to global borrowable allowlist: ${txSig}`);
48585
+ });
48586
+ program
48587
+ .command("remove-borrowable-asset")
48588
+ .argument("<asset>", "Borrowable asset mint public key", utils_1.validatePublicKey)
48589
+ .option("-y, --yes", "Skip confirmation prompt", false)
48590
+ .description("Remove a borrowable asset from the global borrowable allowlist")
48591
+ .action(async (asset, options) => {
48592
+ const stateModel = await context.glamClient.fetchStateModel();
48593
+ const borrowableSet = new glam_sdk_1.PkSet(stateModel.borrowable || []);
48594
+ const removed = borrowableSet.delete(asset);
48595
+ if (!removed) {
48596
+ console.error(`${asset} not found in global borrowable allowlist, nothing to remove`);
48597
+ process.exit(1);
48598
+ }
48599
+ const borrowable = Array.from(borrowableSet);
48600
+ await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.state.update({ borrowable }, context.txOptions), {
48601
+ skip: options?.yes,
48602
+ message: `Confirm removing ${asset} from global borrowable allowlist?`,
48603
+ }, (txSig) => `${asset} removed from global borrowable allowlist: ${txSig}`);
48604
+ });
48557
48605
  program
48558
48606
  .command("holdings")
48559
48607
  .description("Get all vault holdings")
@@ -50326,7 +50374,7 @@ program
50326
50374
  initialize(config, skipSimulation);
50327
50375
  await (0, idl_1.idlCheck)(context.glamClient);
50328
50376
  })
50329
- .version("1.0.14-alpha.3");
50377
+ .version("1.0.14-alpha.5");
50330
50378
  program
50331
50379
  .command("env")
50332
50380
  .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.5",
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.5",
25
25
  "@switchboard-xyz/common": "^3.0.0",
26
26
  "commander": "^11.1.0",
27
27
  "decimal.js": "^10.6.0",