@jup-ag/lend 0.0.80 → 0.0.82

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.
@@ -4011,6 +4011,7 @@ declare const getVaultsProgram: ({ connection, signer, }: {
4011
4011
  connection: Connection;
4012
4012
  signer: PublicKey;
4013
4013
  }) => Program<Vaults>;
4014
+ declare const INIT_TICK = -2147483648;
4014
4015
  declare const getAccountOwner: (account: PublicKey, connection: Connection) => Promise<PublicKey>;
4015
4016
  declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurrentPositionParams) => Promise<{
4016
4017
  tick: number;
@@ -4067,7 +4068,7 @@ declare function loadRelevantBranches(vaultId: number, vaultState: VaultState, p
4067
4068
  connectedBranchId: number;
4068
4069
  connectedMinimaTick: number;
4069
4070
  } | undefined)[]>;
4070
- declare function loadRelevantTicksHasDebtArrays(vaultId: number, program: Program<Vaults>): Promise<{
4071
+ declare function loadRelevantTicksHasDebtArrays(vaultId: number, topTick: number, program: Program<Vaults>): Promise<{
4071
4072
  vaultId: number;
4072
4073
  index: number;
4073
4074
  tickHasDebt: {
@@ -4145,5 +4146,5 @@ declare const getAllLiquidations: (params: Omit<LiquidateParams, "debtAmount" |
4145
4146
  }[];
4146
4147
  }[]>;
4147
4148
 
4148
- export { MAX_TICK, MIN_TICK, TICKS_PER_TICK_HAS_DEBT, TICK_HAS_DEBT_ARRAY_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, TOTAL_INDICES_NEEDED, ZERO_TICK_SCALED_RATIO, findNextTickWithDebt, getAccountOwner, getAllLiquidations, getCurrentPosition, getCurrentPositionState, getFinalPosition, getFirstTickForIndex, getInitPositionContext, getLiquidateContext, getLiquidateIx, getLiquidations, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
4149
+ export { INIT_TICK, MAX_TICK, MIN_TICK, TICKS_PER_TICK_HAS_DEBT, TICK_HAS_DEBT_ARRAY_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, TOTAL_INDICES_NEEDED, ZERO_TICK_SCALED_RATIO, findNextTickWithDebt, getAccountOwner, getAllLiquidations, getCurrentPosition, getCurrentPositionState, getFinalPosition, getFirstTickForIndex, getInitPositionContext, getLiquidateContext, getLiquidateIx, getLiquidations, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
4149
4150
  export type { ConnectionParams, LiquidateContextParams, LiquidateParams, OperateContextParams, OperateParams };
@@ -4011,6 +4011,7 @@ declare const getVaultsProgram: ({ connection, signer, }: {
4011
4011
  connection: Connection;
4012
4012
  signer: PublicKey;
4013
4013
  }) => Program<Vaults>;
4014
+ declare const INIT_TICK = -2147483648;
4014
4015
  declare const getAccountOwner: (account: PublicKey, connection: Connection) => Promise<PublicKey>;
4015
4016
  declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurrentPositionParams) => Promise<{
4016
4017
  tick: number;
@@ -4067,7 +4068,7 @@ declare function loadRelevantBranches(vaultId: number, vaultState: VaultState, p
4067
4068
  connectedBranchId: number;
4068
4069
  connectedMinimaTick: number;
4069
4070
  } | undefined)[]>;
4070
- declare function loadRelevantTicksHasDebtArrays(vaultId: number, program: Program<Vaults>): Promise<{
4071
+ declare function loadRelevantTicksHasDebtArrays(vaultId: number, topTick: number, program: Program<Vaults>): Promise<{
4071
4072
  vaultId: number;
4072
4073
  index: number;
4073
4074
  tickHasDebt: {
@@ -4145,5 +4146,5 @@ declare const getAllLiquidations: (params: Omit<LiquidateParams, "debtAmount" |
4145
4146
  }[];
4146
4147
  }[]>;
4147
4148
 
4148
- export { MAX_TICK, MIN_TICK, TICKS_PER_TICK_HAS_DEBT, TICK_HAS_DEBT_ARRAY_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, TOTAL_INDICES_NEEDED, ZERO_TICK_SCALED_RATIO, findNextTickWithDebt, getAccountOwner, getAllLiquidations, getCurrentPosition, getCurrentPositionState, getFinalPosition, getFirstTickForIndex, getInitPositionContext, getLiquidateContext, getLiquidateIx, getLiquidations, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
4149
+ export { INIT_TICK, MAX_TICK, MIN_TICK, TICKS_PER_TICK_HAS_DEBT, TICK_HAS_DEBT_ARRAY_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, TOTAL_INDICES_NEEDED, ZERO_TICK_SCALED_RATIO, findNextTickWithDebt, getAccountOwner, getAllLiquidations, getCurrentPosition, getCurrentPositionState, getFinalPosition, getFirstTickForIndex, getInitPositionContext, getLiquidateContext, getLiquidateIx, getLiquidations, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
4149
4150
  export type { ConnectionParams, LiquidateContextParams, LiquidateParams, OperateContextParams, OperateParams };
@@ -1219,10 +1219,11 @@ async function loadRelevantBranches(vaultId, vaultState, program) {
1219
1219
  }
1220
1220
  return branches.slice(0, 10);
1221
1221
  }
1222
- async function loadRelevantTicksHasDebtArrays(vaultId, program) {
1222
+ async function loadRelevantTicksHasDebtArrays(vaultId, topTick, program) {
1223
+ const { arrayIndex: topTickIndex } = getTickIndices(topTick);
1223
1224
  return await Promise.all(
1224
1225
  Array.from(
1225
- { length: 16 },
1226
+ { length: topTickIndex },
1226
1227
  (_, i) => program.account.tickHasDebtArray.fetch(
1227
1228
  getTickHasDebt(vaultId, 15 - i)
1228
1229
  )
@@ -1460,14 +1461,22 @@ async function getOtherInstructionsOperate(vaultId, vaultState, currentPosition,
1460
1461
  finalTickIdDataPda
1461
1462
  };
1462
1463
  }
1463
- async function getRemainingAccountsOperate(vaultId, vaultState, vaultConfig, program) {
1464
+ const tickHelper = (tickValue) => {
1465
+ return tickValue === 0 ? INIT_TICK : tickValue;
1466
+ };
1467
+ async function getRemainingAccountsOperate(vaultId, vaultState, vaultConfig, finalPositionTick, program) {
1464
1468
  const remainingAccounts = [];
1465
1469
  const oracleProgram = new Program(oracle, program.provider);
1466
1470
  const [oracleData, branches, tickHasDebt] = await Promise.all([
1467
1471
  oracleProgram.account.oracle.fetch(new PublicKey(vaultConfig.oracle)),
1468
1472
  // Add branch accounts (next 10 remaining accounts)
1469
1473
  loadRelevantBranches(vaultId, vaultState, program),
1470
- loadRelevantTicksHasDebtArrays(vaultId, program)
1474
+ loadRelevantTicksHasDebtArrays(
1475
+ vaultId,
1476
+ Math.max(finalPositionTick, tickHelper(vaultState.topmostTick)),
1477
+ // max of both ticks
1478
+ program
1479
+ )
1471
1480
  ]);
1472
1481
  const sourceLength = oracleData.sources.length;
1473
1482
  for (const source of oracleData.sources)
@@ -1579,6 +1588,7 @@ async function getOperateContext({
1579
1588
  vaultId,
1580
1589
  vaultState,
1581
1590
  vaultConfig,
1591
+ finalPosition.tick,
1582
1592
  program
1583
1593
  );
1584
1594
  const accounts = {
@@ -2133,15 +2143,18 @@ function parseVaultLiquidations(logs) {
2133
2143
  const match = log.match(/VaultLiquidationResult: \[([^\]]+)\]/);
2134
2144
  if (match && match[1]) {
2135
2145
  const values = match[1].split(", ").map((v) => v.trim());
2136
- results.push({
2137
- amtOut: values[0] || "0",
2138
- amtIn: values[1] || "0",
2139
- topTick: values[2] || "undefined"
2140
- });
2146
+ const [amtOut, amtIn, topTick] = values;
2147
+ if (amtIn && amtIn != "0" && amtOut && amtOut != "0" && topTick) {
2148
+ results.push({
2149
+ amtOut,
2150
+ amtIn,
2151
+ topTick
2152
+ });
2153
+ }
2141
2154
  }
2142
2155
  }
2143
2156
  }
2144
2157
  return results;
2145
2158
  }
2146
2159
 
2147
- export { MAX_TICK$1 as MAX_TICK, MIN_TICK$1 as MIN_TICK, TICKS_PER_TICK_HAS_DEBT, TICK_HAS_DEBT_ARRAY_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, TOTAL_INDICES_NEEDED, ZERO_TICK_SCALED_RATIO$1 as ZERO_TICK_SCALED_RATIO, findNextTickWithDebt, getAccountOwner, getAllLiquidations, getCurrentPosition, getCurrentPositionState, getFinalPosition, getFirstTickForIndex, getInitPositionContext, getLiquidateContext, getLiquidateIx, getLiquidations, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
2160
+ export { INIT_TICK, MAX_TICK$1 as MAX_TICK, MIN_TICK$1 as MIN_TICK, TICKS_PER_TICK_HAS_DEBT, TICK_HAS_DEBT_ARRAY_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE, TICK_HAS_DEBT_CHILDREN_SIZE_IN_BITS, TOTAL_INDICES_NEEDED, ZERO_TICK_SCALED_RATIO$1 as ZERO_TICK_SCALED_RATIO, findNextTickWithDebt, getAccountOwner, getAllLiquidations, getCurrentPosition, getCurrentPositionState, getFinalPosition, getFirstTickForIndex, getInitPositionContext, getLiquidateContext, getLiquidateIx, getLiquidations, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
package/dist/index.mjs CHANGED
@@ -8,6 +8,6 @@ import './shared/lend.CioR9-te.mjs';
8
8
  import '@solana/spl-token';
9
9
  import 'bn.js';
10
10
 
11
- const version = "0.0.80";
11
+ const version = "0.0.82";
12
12
 
13
13
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jup-ag/lend",
3
- "version": "0.0.80",
3
+ "version": "0.0.82",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "type": "module",