@jup-ag/lend 0.0.39 → 0.0.40

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.
@@ -4453,6 +4453,10 @@ type GetCurrentPositionStateParams = {
4453
4453
  position: PositionData;
4454
4454
  program: Program<Vaults>;
4455
4455
  };
4456
+ declare const getVaultsProgram: ({ connection, signer, }: {
4457
+ connection: Connection;
4458
+ signer: PublicKey;
4459
+ }) => Program<Vaults>;
4456
4460
  declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurrentPositionParams) => Promise<{
4457
4461
  tick: number;
4458
4462
  tickId: number;
@@ -4471,12 +4475,12 @@ declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurr
4471
4475
  dustDebtRaw: BN;
4472
4476
  isSupplyOnlyPosition: boolean;
4473
4477
  }>;
4474
- declare const calculateFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
4478
+ declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
4475
4479
  vaultId: number;
4476
4480
  currentPosition: Awaited<ReturnType<typeof getCurrentPositionState>>;
4477
4481
  newColAmount: BN;
4478
4482
  newDebtAmount: BN;
4479
- program: Program<Vaults>;
4483
+ program?: Program<Vaults>;
4480
4484
  connection: Connection;
4481
4485
  signer: PublicKey;
4482
4486
  }) => Promise<{
@@ -4519,5 +4523,5 @@ declare function loadRelevantTicksHasDebtArrays(vaultId: number, program: Progra
4519
4523
  declare function getRatioAtTick(tick: number): BN;
4520
4524
  declare function getTickAtRatio(ratioX48: BN): number;
4521
4525
 
4522
- export { calculateFinalPosition, getCurrentPosition, getCurrentPositionState, getInitPositionContext, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, loadRelevantBranches, loadRelevantTicksHasDebtArrays };
4526
+ export { getCurrentPosition, getCurrentPositionState, getFinalPosition, getInitPositionContext, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getVaultsProgram, loadRelevantBranches, loadRelevantTicksHasDebtArrays };
4523
4527
  export type { ConnectionParams, OperateContextParams, OperateParams };
@@ -4453,6 +4453,10 @@ type GetCurrentPositionStateParams = {
4453
4453
  position: PositionData;
4454
4454
  program: Program<Vaults>;
4455
4455
  };
4456
+ declare const getVaultsProgram: ({ connection, signer, }: {
4457
+ connection: Connection;
4458
+ signer: PublicKey;
4459
+ }) => Program<Vaults>;
4456
4460
  declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurrentPositionParams) => Promise<{
4457
4461
  tick: number;
4458
4462
  tickId: number;
@@ -4471,12 +4475,12 @@ declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurr
4471
4475
  dustDebtRaw: BN;
4472
4476
  isSupplyOnlyPosition: boolean;
4473
4477
  }>;
4474
- declare const calculateFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
4478
+ declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
4475
4479
  vaultId: number;
4476
4480
  currentPosition: Awaited<ReturnType<typeof getCurrentPositionState>>;
4477
4481
  newColAmount: BN;
4478
4482
  newDebtAmount: BN;
4479
- program: Program<Vaults>;
4483
+ program?: Program<Vaults>;
4480
4484
  connection: Connection;
4481
4485
  signer: PublicKey;
4482
4486
  }) => Promise<{
@@ -4519,5 +4523,5 @@ declare function loadRelevantTicksHasDebtArrays(vaultId: number, program: Progra
4519
4523
  declare function getRatioAtTick(tick: number): BN;
4520
4524
  declare function getTickAtRatio(ratioX48: BN): number;
4521
4525
 
4522
- export { calculateFinalPosition, getCurrentPosition, getCurrentPositionState, getInitPositionContext, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, loadRelevantBranches, loadRelevantTicksHasDebtArrays };
4526
+ export { getCurrentPosition, getCurrentPositionState, getFinalPosition, getInitPositionContext, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getVaultsProgram, loadRelevantBranches, loadRelevantTicksHasDebtArrays };
4523
4527
  export type { ConnectionParams, OperateContextParams, OperateParams };
@@ -1,9 +1,9 @@
1
1
  import { Transaction, PublicKey, SystemProgram } from '@solana/web3.js';
2
2
  import BN from 'bn.js';
3
3
  import { Program } from '@coral-xyz/anchor';
4
- import { v as vaults, g as getPosition, a as getTick, c as getTickIdLiquidation, d as getVaultConfig, e as getBranch, f as getTickHasDebt, h as getVaultState, i as getVaultMetadata, 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.OZiWki0F.mjs';
5
4
  import { h as getReserve, e as liquidity } from '../shared/lend.BpBbTaiH.mjs';
6
5
  import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token';
6
+ import { v as vaults, g as getPosition, a as getTick, c as getTickIdLiquidation, d as getVaultConfig, e as getBranch, f as getTickHasDebt, h as getVaultState, i as getVaultMetadata, 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.OZiWki0F.mjs';
7
7
 
8
8
  const address = "jupnw4B6Eqs7ft6rxpzYLJZYSnrpRgPcr589n5Kv4oc";
9
9
  const metadata = {
@@ -668,6 +668,13 @@ function mulBigNumber(bigNumber1, bigNumber2) {
668
668
  return adjustedCoefficient.shln(EXPONENT_SIZE_DEBT_FACTOR).or(finalExponent);
669
669
  }
670
670
 
671
+ const getVaultsProgram = ({
672
+ connection,
673
+ signer
674
+ }) => new Program(vaults, {
675
+ connection,
676
+ publicKey: signer
677
+ });
671
678
  const INIT_TICK = -2147483648;
672
679
  const MIN_TICK = -16383;
673
680
  const MAX_TICK = 16383;
@@ -885,7 +892,7 @@ async function processLiquidatedPosition({
885
892
  finalDebtRaw: positionDebtRaw
886
893
  };
887
894
  }
888
- const calculateFinalPosition = async ({
895
+ const getFinalPosition = async ({
889
896
  vaultId,
890
897
  currentPosition,
891
898
  newColAmount,
@@ -894,6 +901,7 @@ const calculateFinalPosition = async ({
894
901
  connection,
895
902
  signer
896
903
  }) => {
904
+ program = program ?? getVaultsProgram({ connection, signer });
897
905
  const [vaultConfig] = await Promise.all([
898
906
  program.account.vaultConfig.fetch(getVaultConfig(vaultId))
899
907
  ]);
@@ -1090,13 +1098,6 @@ async function getExchangePrices({
1090
1098
  }
1091
1099
 
1092
1100
  const LIQUIDITY_PROGRAM_ID = new PublicKey(liquidity.address);
1093
- const getVaultsProgram = ({
1094
- connection,
1095
- signer
1096
- }) => new Program(vaults, {
1097
- connection,
1098
- publicKey: signer
1099
- });
1100
1101
  const MIN_I128 = new BN("170141183460469231731687303715884105728").neg();
1101
1102
  async function getOtherInstructionsOperate(vaultId, vaultState, currentPosition, finalPosition, currentTick, program, signer) {
1102
1103
  const otherIxs = [];
@@ -1286,7 +1287,7 @@ async function getOperateContext({
1286
1287
  vaultId,
1287
1288
  existingPositionTick
1288
1289
  );
1289
- const finalPosition = await calculateFinalPosition({
1290
+ const finalPosition = await getFinalPosition({
1290
1291
  vaultId,
1291
1292
  currentPosition,
1292
1293
  newColAmount: newCol,
@@ -1505,4 +1506,4 @@ async function getInitTickIdLiquidationContext(vaultId, tick, signer, program) {
1505
1506
  };
1506
1507
  }
1507
1508
 
1508
- export { calculateFinalPosition, getCurrentPosition, getCurrentPositionState, getInitPositionContext, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, loadRelevantBranches, loadRelevantTicksHasDebtArrays };
1509
+ export { getCurrentPosition, getCurrentPositionState, getFinalPosition, getInitPositionContext, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getVaultsProgram, loadRelevantBranches, loadRelevantTicksHasDebtArrays };
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.39";
8
+ const version = "0.0.40";
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.39",
3
+ "version": "0.0.40",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "type": "module",