@jup-ag/lend 0.2.0-beta.2 → 0.2.0-beta.3
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 +91 -24
- package/dist/borrow/index.d.ts +91 -24
- package/dist/borrow/index.mjs +5 -4
- package/dist/dex/index.mjs +1 -1
- package/dist/earn/index.d.mts +23 -14
- package/dist/earn/index.d.ts +23 -14
- package/dist/earn/index.mjs +48 -2215
- package/dist/flashloan/index.d.mts +0 -1
- package/dist/flashloan/index.d.ts +0 -1
- package/dist/flashloan/index.mjs +6 -111
- package/dist/index.mjs +1 -1
- package/dist/refinance/index.d.mts +1 -2
- package/dist/refinance/index.d.ts +1 -2
- package/dist/refinance/index.mjs +3 -2
- package/dist/shared/lend.B80NmXTG.mjs +2184 -0
- package/dist/shared/{lend.siYu8A-9.mjs → lend.CS-bkwRq.mjs} +30 -8
- package/dist/shared/{lend.DcHJFKzT.mjs → lend.CVtn-ehf.mjs} +235 -449
- package/dist/shared/{lend.BT41yQVJ.d.mts → lend.CdoFqRFx.d.mts} +168 -474
- package/dist/shared/{lend.BT41yQVJ.d.ts → lend.CdoFqRFx.d.ts} +168 -474
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SYSVAR_RENT_PUBKEY, PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY, SystemProgram } from '@solana/web3.js';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
3
|
import { Program } from '@coral-xyz/anchor';
|
|
4
|
-
import { g as getVaultsProgram, k as getAccountOwner,
|
|
4
|
+
import { g as getVaultsProgram, k as getAccountOwner, u as getTickIndices, p as getLiquidityProgramId, c as MIN_I128, m as getCurrentPositionState, n as getFinalPosition, z as readOraclePrice, t as getTickAtRatio, w as loadRelevantBranchesForLiquidate, y as loadRelevantTicksHasDebtArraysLiquidate, D as oracle, v as loadRelevantBranches, x as loadRelevantTicksHasDebtArrays, d as MIN_TICK, j as findNextTickWithDebt, I as INIT_TICK } from './lend.CVtn-ehf.mjs';
|
|
5
5
|
import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, NATIVE_MINT } from '@solana/spl-token';
|
|
6
|
+
import { c as getOrCreateATAInstruction } from './lend.B80NmXTG.mjs';
|
|
6
7
|
import { a as getPositionMetadata, c as getPositionTokenAccount, d as getPositionMint, e as getPosition, f as getVaultState, g as getVaultAdmin, h as getVaultConfig, i as getVaultMetadata, j as getLiquidity, k as getClaimAccount, l as getRateModel, m as getUserBorrowPosition, n as getUserSupplyPosition, o as getLiquidityReserve, p as getTickHasDebt, q as getTick, r as getBranch, s as getTickIdLiquidation } from './lend.a53XYkl5.mjs';
|
|
7
8
|
|
|
8
9
|
const MPL_TOKEN_METADATA_PROGRAM_ID = new PublicKey(
|
|
@@ -225,7 +226,8 @@ async function getOperateContext({
|
|
|
225
226
|
vaultId,
|
|
226
227
|
position: positionData,
|
|
227
228
|
program,
|
|
228
|
-
market
|
|
229
|
+
market,
|
|
230
|
+
borrowMintDecimals: vaultBorrowDecimals
|
|
229
231
|
});
|
|
230
232
|
if (existingPositionTick === -2147483648) {
|
|
231
233
|
existingPositionTick = currentPosition.tick;
|
|
@@ -351,7 +353,6 @@ async function getOperateContext({
|
|
|
351
353
|
oracleProgram: new PublicKey(vaultConfig.oracleProgram),
|
|
352
354
|
supplyTokenProgram,
|
|
353
355
|
borrowTokenProgram,
|
|
354
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
355
356
|
systemProgram: SystemProgram.programId
|
|
356
357
|
};
|
|
357
358
|
return {
|
|
@@ -424,7 +425,8 @@ const getOperateIx = async ({
|
|
|
424
425
|
signer,
|
|
425
426
|
recipient,
|
|
426
427
|
positionOwner,
|
|
427
|
-
market = "main"
|
|
428
|
+
market = "main",
|
|
429
|
+
includeATASetup = false
|
|
428
430
|
}) => {
|
|
429
431
|
const program = getVaultsProgram({ connection, signer, market });
|
|
430
432
|
const {
|
|
@@ -467,6 +469,16 @@ const getOperateIx = async ({
|
|
|
467
469
|
).accounts(accounts).remainingAccounts(remainingAccounts).instruction(),
|
|
468
470
|
connection.getAddressLookupTable(lookupTable)
|
|
469
471
|
]);
|
|
472
|
+
let preIxs = [];
|
|
473
|
+
if (includeATASetup) {
|
|
474
|
+
const owners = !recipient || recipient.equals(signer) ? [signer] : [signer, recipient];
|
|
475
|
+
const mints = [accounts.supplyToken, accounts.borrowToken];
|
|
476
|
+
preIxs = await Promise.all(
|
|
477
|
+
owners.flatMap(
|
|
478
|
+
(owner) => mints.map((mint) => getOrCreateATAInstruction(owner, mint, connection))
|
|
479
|
+
)
|
|
480
|
+
).then((ixs) => ixs.flat());
|
|
481
|
+
}
|
|
470
482
|
return {
|
|
471
483
|
nftId,
|
|
472
484
|
accounts,
|
|
@@ -474,7 +486,7 @@ const getOperateIx = async ({
|
|
|
474
486
|
remainingAccountsIndices,
|
|
475
487
|
addressLookupTableAddresses: lookupTable ? [lookupTable] : [],
|
|
476
488
|
addressLookupTableAccounts: addressLookupTable.value ? [addressLookupTable.value] : [],
|
|
477
|
-
ixs: initPositionIx ? [initPositionIx, ...otherIxs, operateIx] : [...otherIxs, operateIx]
|
|
489
|
+
ixs: initPositionIx ? [initPositionIx, ...preIxs, ...otherIxs, operateIx] : [...preIxs, ...otherIxs, operateIx]
|
|
478
490
|
};
|
|
479
491
|
};
|
|
480
492
|
function getInitBranchContext(vaultId, branchId, signer, market) {
|
|
@@ -637,8 +649,7 @@ async function getLiquidateContext({
|
|
|
637
649
|
oracleProgram: new PublicKey(vaultConfig.oracleProgram),
|
|
638
650
|
supplyTokenProgram,
|
|
639
651
|
borrowTokenProgram,
|
|
640
|
-
systemProgram: SystemProgram.programId
|
|
641
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID
|
|
652
|
+
systemProgram: SystemProgram.programId
|
|
642
653
|
},
|
|
643
654
|
remainingAccounts,
|
|
644
655
|
otherIxs: finalOtherIxs,
|
|
@@ -654,7 +665,8 @@ const getLiquidateIx = async ({
|
|
|
654
665
|
signer,
|
|
655
666
|
to = signer,
|
|
656
667
|
connection,
|
|
657
|
-
market
|
|
668
|
+
market,
|
|
669
|
+
includeATASetup = false
|
|
658
670
|
}) => {
|
|
659
671
|
const program = getVaultsProgram({ connection, signer, market });
|
|
660
672
|
const {
|
|
@@ -672,6 +684,16 @@ const getLiquidateIx = async ({
|
|
|
672
684
|
market
|
|
673
685
|
});
|
|
674
686
|
const ixs = [];
|
|
687
|
+
if (includeATASetup) {
|
|
688
|
+
const owners = !to || to.equals(signer) ? [signer] : [signer, to];
|
|
689
|
+
const mints = [accounts.supplyToken, accounts.borrowToken];
|
|
690
|
+
const preIxs = await Promise.all(
|
|
691
|
+
owners.flatMap(
|
|
692
|
+
(owner) => mints.map((mint) => getOrCreateATAInstruction(owner, mint, connection))
|
|
693
|
+
)
|
|
694
|
+
).then((ixs2) => ixs2.flat());
|
|
695
|
+
ixs.push(...preIxs);
|
|
696
|
+
}
|
|
675
697
|
if (otherIxs.length > 0) {
|
|
676
698
|
ixs.push(...otherIxs);
|
|
677
699
|
}
|