@jup-ag/lend 0.0.99 → 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 +14 -3
- package/dist/borrow/index.d.ts +14 -3
- package/dist/borrow/index.mjs +39 -10
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/borrow/index.d.mts
CHANGED
|
@@ -3835,6 +3835,15 @@ declare function getOperateContext({ vaultId, positionId, program, connection, s
|
|
|
3835
3835
|
remainingAccountsIndices: number[];
|
|
3836
3836
|
lookupTable: PublicKey;
|
|
3837
3837
|
}>;
|
|
3838
|
+
type InitPositionIxParams = {
|
|
3839
|
+
vaultId: number;
|
|
3840
|
+
connection: Connection;
|
|
3841
|
+
signer: PublicKey;
|
|
3842
|
+
};
|
|
3843
|
+
declare function getInitPositionIx({ vaultId, connection, signer, }: InitPositionIxParams): Promise<{
|
|
3844
|
+
ix: TransactionInstruction;
|
|
3845
|
+
nftId: number;
|
|
3846
|
+
}>;
|
|
3838
3847
|
declare function getInitPositionContext(vaultId: number, positionId: number, signer: PublicKey): {
|
|
3839
3848
|
signer: PublicKey;
|
|
3840
3849
|
vaultAdmin: PublicKey;
|
|
@@ -4022,6 +4031,7 @@ declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurr
|
|
|
4022
4031
|
dustDebtRaw: BN;
|
|
4023
4032
|
isSupplyOnlyPosition: boolean;
|
|
4024
4033
|
userLiquidationStatus: boolean;
|
|
4034
|
+
postLiquidationBranchId: number;
|
|
4025
4035
|
}>;
|
|
4026
4036
|
declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurrentPositionStateParams) => Promise<{
|
|
4027
4037
|
tick: number;
|
|
@@ -4032,6 +4042,7 @@ declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurr
|
|
|
4032
4042
|
dustDebtRaw: BN;
|
|
4033
4043
|
isSupplyOnlyPosition: boolean;
|
|
4034
4044
|
userLiquidationStatus: boolean;
|
|
4045
|
+
postLiquidationBranchId: number;
|
|
4035
4046
|
}>;
|
|
4036
4047
|
declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
|
|
4037
4048
|
vaultId: number;
|
|
@@ -4050,7 +4061,7 @@ declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDe
|
|
|
4050
4061
|
finalAmount: BN;
|
|
4051
4062
|
isSupplyOnlyPosition: boolean;
|
|
4052
4063
|
}>;
|
|
4053
|
-
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[]>;
|
|
4054
4065
|
declare function loadRelevantTicksHasDebtArrays(vaultId: number, topTick: number, existingPositionTick: number, finalTick: number): Promise<PublicKey[]>;
|
|
4055
4066
|
declare function loadRelevantTicksHasDebtArraysLiquidate(vaultId: number, topTick: number, nextTick: number, program: Program<Vaults>): Promise<{
|
|
4056
4067
|
vaultId: number;
|
|
@@ -4129,5 +4140,5 @@ declare const getAllLiquidations: (params: Omit<LiquidateParams, "debtAmount" |
|
|
|
4129
4140
|
}[];
|
|
4130
4141
|
}[]>;
|
|
4131
4142
|
|
|
4132
|
-
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 };
|
|
4133
|
-
export type { ConnectionParams, LiquidateContextParams, LiquidateParams, OperateContextParams, OperateParams };
|
|
4143
|
+
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, getInitPositionIx, getLiquidateContext, getLiquidateIx, getLiquidations, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
|
|
4144
|
+
export type { ConnectionParams, InitPositionIxParams, LiquidateContextParams, LiquidateParams, OperateContextParams, OperateParams };
|
package/dist/borrow/index.d.ts
CHANGED
|
@@ -3835,6 +3835,15 @@ declare function getOperateContext({ vaultId, positionId, program, connection, s
|
|
|
3835
3835
|
remainingAccountsIndices: number[];
|
|
3836
3836
|
lookupTable: PublicKey;
|
|
3837
3837
|
}>;
|
|
3838
|
+
type InitPositionIxParams = {
|
|
3839
|
+
vaultId: number;
|
|
3840
|
+
connection: Connection;
|
|
3841
|
+
signer: PublicKey;
|
|
3842
|
+
};
|
|
3843
|
+
declare function getInitPositionIx({ vaultId, connection, signer, }: InitPositionIxParams): Promise<{
|
|
3844
|
+
ix: TransactionInstruction;
|
|
3845
|
+
nftId: number;
|
|
3846
|
+
}>;
|
|
3838
3847
|
declare function getInitPositionContext(vaultId: number, positionId: number, signer: PublicKey): {
|
|
3839
3848
|
signer: PublicKey;
|
|
3840
3849
|
vaultAdmin: PublicKey;
|
|
@@ -4022,6 +4031,7 @@ declare const getCurrentPosition: ({ vaultId, positionId, connection, }: GetCurr
|
|
|
4022
4031
|
dustDebtRaw: BN;
|
|
4023
4032
|
isSupplyOnlyPosition: boolean;
|
|
4024
4033
|
userLiquidationStatus: boolean;
|
|
4034
|
+
postLiquidationBranchId: number;
|
|
4025
4035
|
}>;
|
|
4026
4036
|
declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurrentPositionStateParams) => Promise<{
|
|
4027
4037
|
tick: number;
|
|
@@ -4032,6 +4042,7 @@ declare const getCurrentPositionState: ({ vaultId, position, program, }: GetCurr
|
|
|
4032
4042
|
dustDebtRaw: BN;
|
|
4033
4043
|
isSupplyOnlyPosition: boolean;
|
|
4034
4044
|
userLiquidationStatus: boolean;
|
|
4045
|
+
postLiquidationBranchId: number;
|
|
4035
4046
|
}>;
|
|
4036
4047
|
declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDebtAmount, program, connection, signer, }: {
|
|
4037
4048
|
vaultId: number;
|
|
@@ -4050,7 +4061,7 @@ declare const getFinalPosition: ({ vaultId, currentPosition, newColAmount, newDe
|
|
|
4050
4061
|
finalAmount: BN;
|
|
4051
4062
|
isSupplyOnlyPosition: boolean;
|
|
4052
4063
|
}>;
|
|
4053
|
-
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[]>;
|
|
4054
4065
|
declare function loadRelevantTicksHasDebtArrays(vaultId: number, topTick: number, existingPositionTick: number, finalTick: number): Promise<PublicKey[]>;
|
|
4055
4066
|
declare function loadRelevantTicksHasDebtArraysLiquidate(vaultId: number, topTick: number, nextTick: number, program: Program<Vaults>): Promise<{
|
|
4056
4067
|
vaultId: number;
|
|
@@ -4129,5 +4140,5 @@ declare const getAllLiquidations: (params: Omit<LiquidateParams, "debtAmount" |
|
|
|
4129
4140
|
}[];
|
|
4130
4141
|
}[]>;
|
|
4131
4142
|
|
|
4132
|
-
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 };
|
|
4133
|
-
export type { ConnectionParams, LiquidateContextParams, LiquidateParams, OperateContextParams, OperateParams };
|
|
4143
|
+
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, getInitPositionIx, getLiquidateContext, getLiquidateIx, getLiquidations, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
|
|
4144
|
+
export type { ConnectionParams, InitPositionIxParams, LiquidateContextParams, LiquidateParams, OperateContextParams, OperateParams };
|
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 = {
|
|
@@ -1727,6 +1740,22 @@ async function getOperateContext({
|
|
|
1727
1740
|
lookupTable: vaultMetadata.lookupTable
|
|
1728
1741
|
};
|
|
1729
1742
|
}
|
|
1743
|
+
async function getInitPositionIx({
|
|
1744
|
+
vaultId,
|
|
1745
|
+
connection,
|
|
1746
|
+
signer
|
|
1747
|
+
}) {
|
|
1748
|
+
const program = getVaultsProgram({ connection, signer });
|
|
1749
|
+
const vaultState = await program.account.vaultState.fetch(
|
|
1750
|
+
getVaultState(vaultId)
|
|
1751
|
+
);
|
|
1752
|
+
return {
|
|
1753
|
+
ix: await program.methods.initPosition(vaultId, vaultState.nextPositionId).accounts(
|
|
1754
|
+
getInitPositionContext(vaultId, vaultState.nextPositionId, signer)
|
|
1755
|
+
).instruction(),
|
|
1756
|
+
nftId: vaultState.nextPositionId
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1730
1759
|
function getInitPositionContext(vaultId, positionId, signer) {
|
|
1731
1760
|
return {
|
|
1732
1761
|
signer,
|
|
@@ -2200,4 +2229,4 @@ function parseVaultLiquidations(logs) {
|
|
|
2200
2229
|
return results;
|
|
2201
2230
|
}
|
|
2202
2231
|
|
|
2203
|
-
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 };
|
|
2232
|
+
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, getInitPositionIx, getLiquidateContext, getLiquidateIx, getLiquidations, getOperateContext, getOperateIx, getRatioAtTick, getTickAtRatio, getTickIndices, getVaultsProgram, loadRelevantBranches, loadRelevantBranchesForLiquidate, loadRelevantTicksHasDebtArrays, loadRelevantTicksHasDebtArraysLiquidate, readOraclePrice, readTickHasDebtArray, simulateLiquidate };
|
package/dist/index.mjs
CHANGED