@jup-ag/lend 0.0.61 → 0.0.63
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 +16 -1
- package/dist/borrow/index.d.ts +16 -1
- package/dist/borrow/index.mjs +62 -2
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/borrow/index.d.mts
CHANGED
|
@@ -4829,5 +4829,20 @@ declare function readTickHasDebtArray({ vaultId, index, program, }: {
|
|
|
4829
4829
|
}>;
|
|
4830
4830
|
declare function findNextTickWithDebt(vaultId: number, startTick: number, program: Program<Vaults>): Promise<number>;
|
|
4831
4831
|
|
|
4832
|
-
|
|
4832
|
+
declare const simulateLiquidate: (params: LiquidateParams) => Promise<_solana_web3_js.SimulatedTransactionResponse>;
|
|
4833
|
+
declare const getLiquidations: (params: Omit<LiquidateParams, "debtAmount">) => Promise<{
|
|
4834
|
+
amtOut: string;
|
|
4835
|
+
amtIn: string;
|
|
4836
|
+
topTick: string;
|
|
4837
|
+
}[]>;
|
|
4838
|
+
declare const getAllLiquidations: (params: Omit<LiquidateParams, "debtAmount" | "vaultId">) => Promise<{
|
|
4839
|
+
vaultId: number;
|
|
4840
|
+
liquidations: never[] | {
|
|
4841
|
+
amtOut: string;
|
|
4842
|
+
amtIn: string;
|
|
4843
|
+
topTick: string;
|
|
4844
|
+
}[];
|
|
4845
|
+
}[]>;
|
|
4846
|
+
|
|
4847
|
+
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, readTickHasDebtArray, simulateLiquidate };
|
|
4833
4848
|
export type { ConnectionParams, LiquidateContextParams, LiquidateParams, OperateContextParams, OperateParams };
|
package/dist/borrow/index.d.ts
CHANGED
|
@@ -4829,5 +4829,20 @@ declare function readTickHasDebtArray({ vaultId, index, program, }: {
|
|
|
4829
4829
|
}>;
|
|
4830
4830
|
declare function findNextTickWithDebt(vaultId: number, startTick: number, program: Program<Vaults>): Promise<number>;
|
|
4831
4831
|
|
|
4832
|
-
|
|
4832
|
+
declare const simulateLiquidate: (params: LiquidateParams) => Promise<_solana_web3_js.SimulatedTransactionResponse>;
|
|
4833
|
+
declare const getLiquidations: (params: Omit<LiquidateParams, "debtAmount">) => Promise<{
|
|
4834
|
+
amtOut: string;
|
|
4835
|
+
amtIn: string;
|
|
4836
|
+
topTick: string;
|
|
4837
|
+
}[]>;
|
|
4838
|
+
declare const getAllLiquidations: (params: Omit<LiquidateParams, "debtAmount" | "vaultId">) => Promise<{
|
|
4839
|
+
vaultId: number;
|
|
4840
|
+
liquidations: never[] | {
|
|
4841
|
+
amtOut: string;
|
|
4842
|
+
amtIn: string;
|
|
4843
|
+
topTick: string;
|
|
4844
|
+
}[];
|
|
4845
|
+
}[]>;
|
|
4846
|
+
|
|
4847
|
+
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, readTickHasDebtArray, simulateLiquidate };
|
|
4833
4848
|
export type { ConnectionParams, LiquidateContextParams, LiquidateParams, OperateContextParams, OperateParams };
|
package/dist/borrow/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction, PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY } from '@solana/web3.js';
|
|
1
|
+
import { Transaction, PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, TransactionMessage, ComputeBudgetProgram, VersionedTransaction } from '@solana/web3.js';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
3
|
import { Program } from '@coral-xyz/anchor';
|
|
4
4
|
import { h as getReserve, e as liquidity } from '../shared/lend.BpBbTaiH.mjs';
|
|
@@ -1983,4 +1983,64 @@ async function getRemainingAccountsLiquidate(vaultId, vaultState, otherIxs, orac
|
|
|
1983
1983
|
};
|
|
1984
1984
|
}
|
|
1985
1985
|
|
|
1986
|
-
|
|
1986
|
+
const simulateLiquidate = async (params) => {
|
|
1987
|
+
const { connection, signer } = params;
|
|
1988
|
+
const { ixs, addressLookupTableAccounts } = await getLiquidateIx(params);
|
|
1989
|
+
const latestBlockhash = await connection.getLatestBlockhash();
|
|
1990
|
+
const messageV0 = new TransactionMessage({
|
|
1991
|
+
payerKey: signer,
|
|
1992
|
+
recentBlockhash: latestBlockhash.blockhash,
|
|
1993
|
+
instructions: [
|
|
1994
|
+
ComputeBudgetProgram.setComputeUnitLimit({
|
|
1995
|
+
units: 1e6
|
|
1996
|
+
}),
|
|
1997
|
+
...ixs
|
|
1998
|
+
]
|
|
1999
|
+
}).compileToV0Message(addressLookupTableAccounts);
|
|
2000
|
+
const transaction = new VersionedTransaction(messageV0);
|
|
2001
|
+
const raw = await connection.simulateTransaction(transaction);
|
|
2002
|
+
return raw.value;
|
|
2003
|
+
};
|
|
2004
|
+
const getLiquidations = async (params) => {
|
|
2005
|
+
const simulation = await simulateLiquidate({
|
|
2006
|
+
...params,
|
|
2007
|
+
debtAmount: new BN(2).pow(new BN(64)).sub(new BN(1))
|
|
2008
|
+
});
|
|
2009
|
+
return parseVaultLiquidations(simulation.logs || []);
|
|
2010
|
+
};
|
|
2011
|
+
const getAllLiquidations = async (params) => {
|
|
2012
|
+
const program = getVaultsProgram({
|
|
2013
|
+
connection: params.connection,
|
|
2014
|
+
signer: params.signer
|
|
2015
|
+
});
|
|
2016
|
+
const { nextVaultId: totalVaults } = await program.account.vaultAdmin.fetch(
|
|
2017
|
+
getVaultAdmin()
|
|
2018
|
+
);
|
|
2019
|
+
return await Promise.all(
|
|
2020
|
+
Array.from({ length: totalVaults - 1 }, async (_, i) => ({
|
|
2021
|
+
vaultId: i + 1,
|
|
2022
|
+
liquidations: await getLiquidations({ ...params, vaultId: i + 1 }).catch(
|
|
2023
|
+
() => []
|
|
2024
|
+
)
|
|
2025
|
+
}))
|
|
2026
|
+
);
|
|
2027
|
+
};
|
|
2028
|
+
function parseVaultLiquidations(logs) {
|
|
2029
|
+
const results = [];
|
|
2030
|
+
for (const log of logs) {
|
|
2031
|
+
if (log.includes("VaultLiquidationResult:")) {
|
|
2032
|
+
const match = log.match(/VaultLiquidationResult: \[([^\]]+)\]/);
|
|
2033
|
+
if (match && match[1]) {
|
|
2034
|
+
const values = match[1].split(", ").map((v) => v.trim());
|
|
2035
|
+
results.push({
|
|
2036
|
+
amtOut: values[0] || "0",
|
|
2037
|
+
amtIn: values[1] || "0",
|
|
2038
|
+
topTick: values[2] || "undefined"
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
return results;
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
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, readTickHasDebtArray, simulateLiquidate };
|
package/dist/index.mjs
CHANGED