@jup-ag/lend 0.0.25 → 0.0.27

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.
@@ -3709,13 +3709,14 @@ declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurr
3709
3709
  dustDebtRaw: BN;
3710
3710
  isSupplyOnlyPosition: boolean;
3711
3711
  }>;
3712
- declare const calculateFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, }: {
3712
+ declare const calculateFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
3713
3713
  vaultId: number;
3714
3714
  currentPosition: Awaited<ReturnType<typeof getCurrentPositionState>>;
3715
3715
  newColAmount: BN;
3716
3716
  newDebtAmount: BN;
3717
3717
  program: Program<Vaults>;
3718
3718
  connection: Connection;
3719
+ signer: PublicKey;
3719
3720
  }) => Promise<{
3720
3721
  tick: number;
3721
3722
  tickId: number;
@@ -3709,13 +3709,14 @@ declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurr
3709
3709
  dustDebtRaw: BN;
3710
3710
  isSupplyOnlyPosition: boolean;
3711
3711
  }>;
3712
- declare const calculateFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, }: {
3712
+ declare const calculateFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
3713
3713
  vaultId: number;
3714
3714
  currentPosition: Awaited<ReturnType<typeof getCurrentPositionState>>;
3715
3715
  newColAmount: BN;
3716
3716
  newDebtAmount: BN;
3717
3717
  program: Program<Vaults>;
3718
3718
  connection: Connection;
3719
+ signer: PublicKey;
3719
3720
  }) => Promise<{
3720
3721
  tick: number;
3721
3722
  tickId: number;
@@ -1,6 +1,6 @@
1
- import { Keypair, PublicKey, SystemProgram } from '@solana/web3.js';
1
+ import { Transaction, PublicKey, SystemProgram } from '@solana/web3.js';
2
2
  import BN from 'bn.js';
3
- import { Program, AnchorProvider, Wallet } from '@coral-xyz/anchor';
3
+ import { Program } from '@coral-xyz/anchor';
4
4
  import { g as getTick, a as getTickIdLiquidation, c as getVaultConfig, d as getBranch, e as getTickHasDebt, f as getVaultState, v as vaults, h as getVaultMetadata, i as getPosition, j as getLiquidity, k as getClaimAccount, l as getRateModel, m as getUserBorrowPosition, n as getUserSupplyPosition, o as getLiquidityReserve, p as getPositionTokenAccount, q as getPositionMint, r as getVaultAdmin } from '../shared/lend.ByEareGr.mjs';
5
5
  import { h as getReserve, e as liquidity } from '../shared/lend.Byg4n7y5.mjs';
6
6
  import { getMint, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token';
@@ -876,7 +876,8 @@ const calculateFinalPosition = async ({
876
876
  newColAmount,
877
877
  newDebtAmount,
878
878
  program,
879
- connection
879
+ connection,
880
+ signer
880
881
  }) => {
881
882
  const [vaultConfig] = await Promise.all([
882
883
  program.account.vaultConfig.fetch(getVaultConfig(vaultId))
@@ -884,7 +885,7 @@ const calculateFinalPosition = async ({
884
885
  const {
885
886
  vaultSupplyExchangePrice: supplyExPrice,
886
887
  vaultBorrowExchangePrice: borrowExPrice
887
- } = await getExchangePrices({ vaultId, vaultConfig, connection });
888
+ } = await getExchangePrices({ vaultId, vaultConfig, connection, signer });
888
889
  const borrowFee = vaultConfig.borrowFee;
889
890
  let { colRaw, debtRaw, dustDebtRaw } = currentPosition;
890
891
  if (newColAmount.gt(new BN(0))) {
@@ -1033,19 +1034,24 @@ async function loadRelevantTicksHasDebtArrays(vaultId, program) {
1033
1034
  async function getExchangePrices({
1034
1035
  vaultId,
1035
1036
  vaultConfig,
1036
- connection
1037
+ connection,
1038
+ signer
1037
1039
  }) {
1038
- const program = new Program(
1039
- vaults,
1040
- new AnchorProvider(connection, new Wallet(Keypair.generate()))
1041
- );
1042
- const { raw } = await program.methods.getExchangePrices().accounts({
1040
+ const program = new Program(vaults, { connection });
1041
+ const ix = await program.methods.getExchangePrices().accounts({
1043
1042
  vaultState: getVaultState(vaultId),
1044
1043
  vaultConfig: getVaultConfig(vaultId),
1045
1044
  supplyTokenReserves: getReserve(vaultConfig.supplyToken),
1046
1045
  borrowTokenReserves: getReserve(vaultConfig.borrowToken)
1047
- }).simulate();
1048
- const returnLog = raw?.find((log) => log.startsWith("Program return:"));
1046
+ }).instruction();
1047
+ const transaction = new Transaction().add(ix);
1048
+ const latestBlockHash = await connection.getLatestBlockhash();
1049
+ transaction.recentBlockhash = latestBlockHash.blockhash;
1050
+ transaction.feePayer = signer;
1051
+ const raw = await connection.simulateTransaction(transaction);
1052
+ const returnLog = raw.value.logs?.find(
1053
+ (log) => log.startsWith("Program return:")
1054
+ );
1049
1055
  if (!returnLog) {
1050
1056
  throw new Error("No return data found in logs");
1051
1057
  }
@@ -1264,7 +1270,8 @@ async function getOperateContext({
1264
1270
  newColAmount: newCol,
1265
1271
  newDebtAmount: newDebt,
1266
1272
  program,
1267
- connection
1273
+ connection,
1274
+ signer
1268
1275
  });
1269
1276
  const { otherIxs, newBranchPda, currentTickIdDataPda, finalTickIdDataPda } = await getOtherInstructionsOperate(
1270
1277
  vaultId,
package/dist/index.mjs CHANGED
@@ -5,6 +5,6 @@ import '@solana/web3.js';
5
5
  import '@solana/spl-token';
6
6
  import 'bn.js';
7
7
 
8
- const version = "0.0.25";
8
+ const version = "0.0.27";
9
9
 
10
10
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jup-ag/lend",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "type": "module",