@jup-ag/lend 0.0.100 → 0.0.102

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.
@@ -3,7 +3,7 @@ import BN from 'bn.js';
3
3
  import { Program, AnchorProvider } from '@coral-xyz/anchor';
4
4
  import { l as liquidity } from '../shared/lend.CioR9-te.mjs';
5
5
  import { getAssociatedTokenAddressSync, ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token';
6
- import { g as getTickHasDebt, v as vaults, a as getPosition, c as getTick, d as getTickIdLiquidation, e as getVaultConfig, f as getBranch, h as getVaultState, i as getVaultMetadata, j as getLiquidity, k as getRateModel, l as getUserBorrowPosition, m as getUserSupplyPosition, n as getLiquidityReserve, o as getPositionTokenAccount, p as getPositionMetadata, q as getPositionMint, r as getVaultAdmin, s as getClaimAccount } from '../shared/lend.qfqiaCtm.mjs';
6
+ import { g as getTickHasDebt, v as vaults, a as getPosition, c as getTick, d as getTickIdLiquidation, e as getVaultConfig, f as getBranch, h as getVaultState, i as getVaultMetadata, j as getLiquidity, k as getRateModel, l as getUserBorrowPosition, m as getUserSupplyPosition, n as getLiquidityReserve, o as getPositionTokenAccount, p as getPositionMetadata, q as getPositionMint, r as getVaultAdmin, s as getClaimAccount } from '../shared/lend.BWTZqUUK.mjs';
7
7
  import { e as getReserve } from '../shared/lend.BzG5ldOV.mjs';
8
8
 
9
9
  const address = "jupnw4B6Eqs7ft6rxpzYLJZYSnrpRgPcr589n5Kv4oc";
@@ -234,6 +234,35 @@ const instructions = [
234
234
  }
235
235
  ]
236
236
  },
237
+ {
238
+ name: "update_authority",
239
+ discriminator: [
240
+ 32,
241
+ 46,
242
+ 64,
243
+ 28,
244
+ 149,
245
+ 75,
246
+ 243,
247
+ 88
248
+ ],
249
+ accounts: [
250
+ {
251
+ name: "authority",
252
+ signer: true
253
+ },
254
+ {
255
+ name: "oracle_admin",
256
+ writable: true
257
+ }
258
+ ],
259
+ args: [
260
+ {
261
+ name: "new_authority",
262
+ type: "pubkey"
263
+ }
264
+ ]
265
+ },
237
266
  {
238
267
  name: "update_auths",
239
268
  discriminator: [
@@ -299,6 +328,19 @@ const accounts = [
299
328
  }
300
329
  ];
301
330
  const events = [
331
+ {
332
+ name: "LogStakePoolHighFeeDetected",
333
+ discriminator: [
334
+ 198,
335
+ 106,
336
+ 149,
337
+ 7,
338
+ 25,
339
+ 83,
340
+ 39,
341
+ 155
342
+ ]
343
+ },
302
344
  {
303
345
  name: "LogUpdateAuthority",
304
346
  discriminator: [
@@ -401,6 +443,26 @@ const errors = [
401
443
  code: 6014,
402
444
  name: "InvalidPrice",
403
445
  msg: "INVALID_PRICE"
446
+ },
447
+ {
448
+ code: 6015,
449
+ name: "FeeTooHigh",
450
+ msg: "FEE_TOO_HIGH"
451
+ },
452
+ {
453
+ code: 6016,
454
+ name: "RedstonePriceOverflow",
455
+ msg: "REDSTONE_PRICE_OVERFLOW"
456
+ },
457
+ {
458
+ code: 6017,
459
+ name: "TimestampExpected",
460
+ msg: "TIMESTAMP_EXPECTED"
461
+ },
462
+ {
463
+ code: 6018,
464
+ name: "ChainlinkPriceReadError",
465
+ msg: "CHAINLINK_PRICE_READ_ERROR"
404
466
  }
405
467
  ];
406
468
  const types = [
@@ -420,6 +482,22 @@ const types = [
420
482
  ]
421
483
  }
422
484
  },
485
+ {
486
+ name: "LogStakePoolHighFeeDetected",
487
+ type: {
488
+ kind: "struct",
489
+ fields: [
490
+ {
491
+ name: "stake_pool",
492
+ type: "pubkey"
493
+ },
494
+ {
495
+ name: "epoch",
496
+ type: "u64"
497
+ }
498
+ ]
499
+ }
500
+ },
423
501
  {
424
502
  name: "LogUpdateAuthority",
425
503
  type: {
@@ -504,6 +582,15 @@ const types = [
504
582
  },
505
583
  {
506
584
  name: "StakePool"
585
+ },
586
+ {
587
+ name: "MsolPool"
588
+ },
589
+ {
590
+ name: "Redstone"
591
+ },
592
+ {
593
+ name: "Chainlink"
507
594
  }
508
595
  ]
509
596
  }
@@ -939,7 +1026,8 @@ const getCurrentPositionState = async ({
939
1026
  debtRaw: new BN(0),
940
1027
  dustDebtRaw: new BN(0),
941
1028
  isSupplyOnlyPosition: true,
942
- userLiquidationStatus: false
1029
+ userLiquidationStatus: false,
1030
+ postLiquidationBranchId: 0
943
1031
  };
944
1032
  }
945
1033
  const colRaw = new BN(position.supplyAmount.toString());
@@ -953,6 +1041,7 @@ const getCurrentPositionState = async ({
953
1041
  debtRaw = new BN(0);
954
1042
  }
955
1043
  let userLiquidationStatus = false;
1044
+ let postLiquidationBranchId = 0;
956
1045
  if (positionTick > MIN_TICK) {
957
1046
  const tickData = await program.account.tick.fetch(
958
1047
  getTick(vaultId, positionTick)
@@ -986,6 +1075,7 @@ const getCurrentPositionState = async ({
986
1075
  };
987
1076
  }
988
1077
  const { isFullyLiquidated, branchId, connectionFactor } = getLiquidationStatus(position.tickId, tickData, tickIdData);
1078
+ postLiquidationBranchId = branchId;
989
1079
  if (isFullyLiquidated) {
990
1080
  return {
991
1081
  tick: MIN_TICK,
@@ -995,12 +1085,13 @@ const getCurrentPositionState = async ({
995
1085
  dustDebtRaw: new BN(0),
996
1086
  finalAmount: new BN(0),
997
1087
  isSupplyOnlyPosition: true,
998
- userLiquidationStatus: true
1088
+ userLiquidationStatus: true,
1089
+ postLiquidationBranchId: 0
999
1090
  };
1000
1091
  }
1001
1092
  const { finalTick, finalColRaw, finalDebtRaw } = processLiquidatedPosition({
1002
1093
  branches,
1003
- branchId,
1094
+ branchId: postLiquidationBranchId,
1004
1095
  initialConnectionFactor: connectionFactor,
1005
1096
  initialDebtRaw: debtRaw
1006
1097
  });
@@ -1013,7 +1104,8 @@ const getCurrentPositionState = async ({
1013
1104
  dustDebtRaw,
1014
1105
  finalAmount: netDebtRaw2.gt(new BN(0)) ? finalColRaw : new BN(0),
1015
1106
  isSupplyOnlyPosition: finalTick === MIN_TICK,
1016
- userLiquidationStatus
1107
+ userLiquidationStatus,
1108
+ postLiquidationBranchId
1017
1109
  };
1018
1110
  }
1019
1111
  }
@@ -1026,7 +1118,8 @@ const getCurrentPositionState = async ({
1026
1118
  dustDebtRaw,
1027
1119
  finalAmount: netDebtRaw.gt(new BN(0)) ? colRaw : new BN(0),
1028
1120
  isSupplyOnlyPosition: positionTick === MIN_TICK,
1029
- userLiquidationStatus
1121
+ userLiquidationStatus,
1122
+ postLiquidationBranchId
1030
1123
  };
1031
1124
  };
1032
1125
  async function getAllBranches({
@@ -1219,9 +1312,9 @@ const getFinalPosition = async ({
1219
1312
  isSupplyOnlyPosition
1220
1313
  };
1221
1314
  };
1222
- async function loadRelevantBranches(vaultId, vaultState, liquidationStatus, program) {
1315
+ async function loadRelevantBranches(vaultId, vaultState, liquidationStatus, postLiquidationBranchId, program) {
1223
1316
  const addedBranchIds = /* @__PURE__ */ new Set();
1224
- const currentBranchId = vaultState.currentBranchId;
1317
+ const currentBranchId = postLiquidationBranchId > 0 ? postLiquidationBranchId : vaultState.currentBranchId;
1225
1318
  let connectedBranchId = 0;
1226
1319
  if (currentBranchId > 0) {
1227
1320
  try {
@@ -1506,13 +1599,19 @@ async function getOtherInstructionsOperate(vaultId, vaultState, currentPosition,
1506
1599
  const tickHelper = (tickValue) => {
1507
1600
  return tickValue === 0 ? INIT_TICK : tickValue;
1508
1601
  };
1509
- async function getRemainingAccountsOperate(vaultId, vaultState, vaultConfig, finalPositionTick, existingPositionTick, liquidationStatus, program) {
1602
+ async function getRemainingAccountsOperate(vaultId, vaultState, vaultConfig, finalPositionTick, existingPositionTick, liquidationStatus, postLiquidationBranchId, program) {
1510
1603
  const remainingAccounts = [];
1511
1604
  const oracleProgram = new Program(oracle, program.provider);
1512
1605
  const [oracleData, branches, tickHasDebt] = await Promise.all([
1513
1606
  oracleProgram.account.oracle.fetch(new PublicKey(vaultConfig.oracle)),
1514
1607
  // Add branch accounts (next 10 remaining accounts)
1515
- loadRelevantBranches(vaultId, vaultState, liquidationStatus, program),
1608
+ loadRelevantBranches(
1609
+ vaultId,
1610
+ vaultState,
1611
+ liquidationStatus,
1612
+ postLiquidationBranchId,
1613
+ program
1614
+ ),
1516
1615
  loadRelevantTicksHasDebtArrays(
1517
1616
  vaultId,
1518
1617
  tickHelper(vaultState.topmostTick),
@@ -1632,6 +1731,7 @@ async function getOperateContext({
1632
1731
  finalPosition.tick,
1633
1732
  existingPositionTick,
1634
1733
  currentPosition.userLiquidationStatus,
1734
+ currentPosition.postLiquidationBranchId,
1635
1735
  program
1636
1736
  );
1637
1737
  const accounts = {