@jup-ag/lend 0.0.100 → 0.0.101
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.
- package/dist/borrow/index.d.mts +3 -1
- package/dist/borrow/index.d.ts +3 -1
- package/dist/borrow/index.mjs +22 -9
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/borrow/index.d.mts
CHANGED
|
@@ -4031,6 +4031,7 @@ declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurr
|
|
|
4031
4031
|
dustDebtRaw: BN;
|
|
4032
4032
|
isSupplyOnlyPosition: boolean;
|
|
4033
4033
|
userLiquidationStatus: boolean;
|
|
4034
|
+
postLiquidationBranchId: number;
|
|
4034
4035
|
}>;
|
|
4035
4036
|
declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurrentPositionStateParams) => Promise<{
|
|
4036
4037
|
tick: number;
|
|
@@ -4041,6 +4042,7 @@ declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurr
|
|
|
4041
4042
|
dustDebtRaw: BN;
|
|
4042
4043
|
isSupplyOnlyPosition: boolean;
|
|
4043
4044
|
userLiquidationStatus: boolean;
|
|
4045
|
+
postLiquidationBranchId: number;
|
|
4044
4046
|
}>;
|
|
4045
4047
|
declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
|
|
4046
4048
|
vaultId: number;
|
|
@@ -4059,7 +4061,7 @@ declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDe
|
|
|
4059
4061
|
finalAmount: BN;
|
|
4060
4062
|
isSupplyOnlyPosition: boolean;
|
|
4061
4063
|
}>;
|
|
4062
|
-
declare function loadRelevantBranches(vaultId: number, vaultState: VaultState, liquidationStatus: boolean, program: Program<Vaults>): Promise<number[]>;
|
|
4064
|
+
declare function loadRelevantBranches(vaultId: number, vaultState: VaultState, liquidationStatus: boolean, postLiquidationBranchId: number, program: Program<Vaults>): Promise<number[]>;
|
|
4063
4065
|
declare function loadRelevantTicksHasDebtArrays(vaultId: number, topTick: number, existingPositionTick: number, finalTick: number): Promise<PublicKey[]>;
|
|
4064
4066
|
declare function loadRelevantTicksHasDebtArraysLiquidate(vaultId: number, topTick: number, nextTick: number, program: Program<Vaults>): Promise<{
|
|
4065
4067
|
vaultId: number;
|
package/dist/borrow/index.d.ts
CHANGED
|
@@ -4031,6 +4031,7 @@ declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurr
|
|
|
4031
4031
|
dustDebtRaw: BN;
|
|
4032
4032
|
isSupplyOnlyPosition: boolean;
|
|
4033
4033
|
userLiquidationStatus: boolean;
|
|
4034
|
+
postLiquidationBranchId: number;
|
|
4034
4035
|
}>;
|
|
4035
4036
|
declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurrentPositionStateParams) => Promise<{
|
|
4036
4037
|
tick: number;
|
|
@@ -4041,6 +4042,7 @@ declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurr
|
|
|
4041
4042
|
dustDebtRaw: BN;
|
|
4042
4043
|
isSupplyOnlyPosition: boolean;
|
|
4043
4044
|
userLiquidationStatus: boolean;
|
|
4045
|
+
postLiquidationBranchId: number;
|
|
4044
4046
|
}>;
|
|
4045
4047
|
declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
|
|
4046
4048
|
vaultId: number;
|
|
@@ -4059,7 +4061,7 @@ declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDe
|
|
|
4059
4061
|
finalAmount: BN;
|
|
4060
4062
|
isSupplyOnlyPosition: boolean;
|
|
4061
4063
|
}>;
|
|
4062
|
-
declare function loadRelevantBranches(vaultId: number, vaultState: VaultState, liquidationStatus: boolean, program: Program<Vaults>): Promise<number[]>;
|
|
4064
|
+
declare function loadRelevantBranches(vaultId: number, vaultState: VaultState, liquidationStatus: boolean, postLiquidationBranchId: number, program: Program<Vaults>): Promise<number[]>;
|
|
4063
4065
|
declare function loadRelevantTicksHasDebtArrays(vaultId: number, topTick: number, existingPositionTick: number, finalTick: number): Promise<PublicKey[]>;
|
|
4064
4066
|
declare function loadRelevantTicksHasDebtArraysLiquidate(vaultId: number, topTick: number, nextTick: number, program: Program<Vaults>): Promise<{
|
|
4065
4067
|
vaultId: number;
|
package/dist/borrow/index.mjs
CHANGED
|
@@ -939,7 +939,8 @@ const getCurrentPositionState = async ({
|
|
|
939
939
|
debtRaw: new BN(0),
|
|
940
940
|
dustDebtRaw: new BN(0),
|
|
941
941
|
isSupplyOnlyPosition: true,
|
|
942
|
-
userLiquidationStatus: false
|
|
942
|
+
userLiquidationStatus: false,
|
|
943
|
+
postLiquidationBranchId: 0
|
|
943
944
|
};
|
|
944
945
|
}
|
|
945
946
|
const colRaw = new BN(position.supplyAmount.toString());
|
|
@@ -953,6 +954,7 @@ const getCurrentPositionState = async ({
|
|
|
953
954
|
debtRaw = new BN(0);
|
|
954
955
|
}
|
|
955
956
|
let userLiquidationStatus = false;
|
|
957
|
+
let postLiquidationBranchId = 0;
|
|
956
958
|
if (positionTick > MIN_TICK) {
|
|
957
959
|
const tickData = await program.account.tick.fetch(
|
|
958
960
|
getTick(vaultId, positionTick)
|
|
@@ -986,6 +988,7 @@ const getCurrentPositionState = async ({
|
|
|
986
988
|
};
|
|
987
989
|
}
|
|
988
990
|
const { isFullyLiquidated, branchId, connectionFactor } = getLiquidationStatus(position.tickId, tickData, tickIdData);
|
|
991
|
+
postLiquidationBranchId = branchId;
|
|
989
992
|
if (isFullyLiquidated) {
|
|
990
993
|
return {
|
|
991
994
|
tick: MIN_TICK,
|
|
@@ -995,12 +998,13 @@ const getCurrentPositionState = async ({
|
|
|
995
998
|
dustDebtRaw: new BN(0),
|
|
996
999
|
finalAmount: new BN(0),
|
|
997
1000
|
isSupplyOnlyPosition: true,
|
|
998
|
-
userLiquidationStatus: true
|
|
1001
|
+
userLiquidationStatus: true,
|
|
1002
|
+
postLiquidationBranchId: 0
|
|
999
1003
|
};
|
|
1000
1004
|
}
|
|
1001
1005
|
const { finalTick, finalColRaw, finalDebtRaw } = processLiquidatedPosition({
|
|
1002
1006
|
branches,
|
|
1003
|
-
branchId,
|
|
1007
|
+
branchId: postLiquidationBranchId,
|
|
1004
1008
|
initialConnectionFactor: connectionFactor,
|
|
1005
1009
|
initialDebtRaw: debtRaw
|
|
1006
1010
|
});
|
|
@@ -1013,7 +1017,8 @@ const getCurrentPositionState = async ({
|
|
|
1013
1017
|
dustDebtRaw,
|
|
1014
1018
|
finalAmount: netDebtRaw2.gt(new BN(0)) ? finalColRaw : new BN(0),
|
|
1015
1019
|
isSupplyOnlyPosition: finalTick === MIN_TICK,
|
|
1016
|
-
userLiquidationStatus
|
|
1020
|
+
userLiquidationStatus,
|
|
1021
|
+
postLiquidationBranchId
|
|
1017
1022
|
};
|
|
1018
1023
|
}
|
|
1019
1024
|
}
|
|
@@ -1026,7 +1031,8 @@ const getCurrentPositionState = async ({
|
|
|
1026
1031
|
dustDebtRaw,
|
|
1027
1032
|
finalAmount: netDebtRaw.gt(new BN(0)) ? colRaw : new BN(0),
|
|
1028
1033
|
isSupplyOnlyPosition: positionTick === MIN_TICK,
|
|
1029
|
-
userLiquidationStatus
|
|
1034
|
+
userLiquidationStatus,
|
|
1035
|
+
postLiquidationBranchId
|
|
1030
1036
|
};
|
|
1031
1037
|
};
|
|
1032
1038
|
async function getAllBranches({
|
|
@@ -1219,9 +1225,9 @@ const getFinalPosition = async ({
|
|
|
1219
1225
|
isSupplyOnlyPosition
|
|
1220
1226
|
};
|
|
1221
1227
|
};
|
|
1222
|
-
async function loadRelevantBranches(vaultId, vaultState, liquidationStatus, program) {
|
|
1228
|
+
async function loadRelevantBranches(vaultId, vaultState, liquidationStatus, postLiquidationBranchId, program) {
|
|
1223
1229
|
const addedBranchIds = /* @__PURE__ */ new Set();
|
|
1224
|
-
const currentBranchId = vaultState.currentBranchId;
|
|
1230
|
+
const currentBranchId = postLiquidationBranchId > 0 ? postLiquidationBranchId : vaultState.currentBranchId;
|
|
1225
1231
|
let connectedBranchId = 0;
|
|
1226
1232
|
if (currentBranchId > 0) {
|
|
1227
1233
|
try {
|
|
@@ -1506,13 +1512,19 @@ async function getOtherInstructionsOperate(vaultId, vaultState, currentPosition,
|
|
|
1506
1512
|
const tickHelper = (tickValue) => {
|
|
1507
1513
|
return tickValue === 0 ? INIT_TICK : tickValue;
|
|
1508
1514
|
};
|
|
1509
|
-
async function getRemainingAccountsOperate(vaultId, vaultState, vaultConfig, finalPositionTick, existingPositionTick, liquidationStatus, program) {
|
|
1515
|
+
async function getRemainingAccountsOperate(vaultId, vaultState, vaultConfig, finalPositionTick, existingPositionTick, liquidationStatus, postLiquidationBranchId, program) {
|
|
1510
1516
|
const remainingAccounts = [];
|
|
1511
1517
|
const oracleProgram = new Program(oracle, program.provider);
|
|
1512
1518
|
const [oracleData, branches, tickHasDebt] = await Promise.all([
|
|
1513
1519
|
oracleProgram.account.oracle.fetch(new PublicKey(vaultConfig.oracle)),
|
|
1514
1520
|
// Add branch accounts (next 10 remaining accounts)
|
|
1515
|
-
loadRelevantBranches(
|
|
1521
|
+
loadRelevantBranches(
|
|
1522
|
+
vaultId,
|
|
1523
|
+
vaultState,
|
|
1524
|
+
liquidationStatus,
|
|
1525
|
+
postLiquidationBranchId,
|
|
1526
|
+
program
|
|
1527
|
+
),
|
|
1516
1528
|
loadRelevantTicksHasDebtArrays(
|
|
1517
1529
|
vaultId,
|
|
1518
1530
|
tickHelper(vaultState.topmostTick),
|
|
@@ -1632,6 +1644,7 @@ async function getOperateContext({
|
|
|
1632
1644
|
finalPosition.tick,
|
|
1633
1645
|
existingPositionTick,
|
|
1634
1646
|
currentPosition.userLiquidationStatus,
|
|
1647
|
+
currentPosition.postLiquidationBranchId,
|
|
1635
1648
|
program
|
|
1636
1649
|
);
|
|
1637
1650
|
const accounts = {
|
package/dist/index.mjs
CHANGED