@jup-ag/lend 0.2.0-beta.2 → 0.2.0-beta.4
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 +153 -14
- package/dist/earn/index.d.ts +153 -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.siYu8A-9.mjs → lend.BFWi2x2e.mjs} +30 -8
- package/dist/shared/lend.BR8HvUg-.mjs +2330 -0
- package/dist/shared/{lend.BT41yQVJ.d.mts → lend.CZaDpI67.d.mts} +169 -475
- package/dist/shared/{lend.BT41yQVJ.d.ts → lend.CZaDpI67.d.ts} +169 -475
- package/dist/shared/{lend.DcHJFKzT.mjs → lend.TR2SYmUo.mjs} +237 -451
- package/package.json +1 -1
|
@@ -35,7 +35,6 @@ declare function getFlashloanContext({ signer, asset, connection, market, }: Fla
|
|
|
35
35
|
liquidity: PublicKey;
|
|
36
36
|
liquidityProgram: PublicKey;
|
|
37
37
|
tokenProgram: PublicKey;
|
|
38
|
-
associatedTokenProgram: PublicKey;
|
|
39
38
|
systemProgram: PublicKey;
|
|
40
39
|
instructionSysvar: PublicKey;
|
|
41
40
|
}>;
|
|
@@ -35,7 +35,6 @@ declare function getFlashloanContext({ signer, asset, connection, market, }: Fla
|
|
|
35
35
|
liquidity: PublicKey;
|
|
36
36
|
liquidityProgram: PublicKey;
|
|
37
37
|
tokenProgram: PublicKey;
|
|
38
|
-
associatedTokenProgram: PublicKey;
|
|
39
38
|
systemProgram: PublicKey;
|
|
40
39
|
instructionSysvar: PublicKey;
|
|
41
40
|
}>;
|
package/dist/flashloan/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { SYSVAR_INSTRUCTIONS_PUBKEY, SystemProgram, PublicKey } from '@solana/web3.js';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getAssociatedTokenAddressSync } from '@solana/spl-token';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import { g as getLiquidity, a as getRateModel, b as getFlashloanBorrowPosition, c as getLiquidityReserve, d as getFlashloanAdmin } from '../shared/lend.BXNM1zms.mjs';
|
|
6
6
|
|
|
7
7
|
const address = "jupgfSgfuAXv4B6R2Uxu85Z1qdzgju79s6MfZekN6XS";
|
|
8
8
|
const metadata = {
|
|
9
9
|
name: "flashloan",
|
|
10
|
-
version: "0.1.
|
|
10
|
+
version: "0.1.4",
|
|
11
11
|
spec: "0.1.0",
|
|
12
12
|
description: "Created with Anchor"
|
|
13
13
|
};
|
|
@@ -61,60 +61,7 @@ const instructions = [
|
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
name: "signer_borrow_token_account",
|
|
64
|
-
writable: true
|
|
65
|
-
pda: {
|
|
66
|
-
seeds: [
|
|
67
|
-
{
|
|
68
|
-
kind: "account",
|
|
69
|
-
path: "signer"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
kind: "account",
|
|
73
|
-
path: "token_program"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
kind: "account",
|
|
77
|
-
path: "mint"
|
|
78
|
-
}
|
|
79
|
-
],
|
|
80
|
-
program: {
|
|
81
|
-
kind: "const",
|
|
82
|
-
value: [
|
|
83
|
-
140,
|
|
84
|
-
151,
|
|
85
|
-
37,
|
|
86
|
-
143,
|
|
87
|
-
78,
|
|
88
|
-
36,
|
|
89
|
-
137,
|
|
90
|
-
241,
|
|
91
|
-
187,
|
|
92
|
-
61,
|
|
93
|
-
16,
|
|
94
|
-
41,
|
|
95
|
-
20,
|
|
96
|
-
142,
|
|
97
|
-
13,
|
|
98
|
-
131,
|
|
99
|
-
11,
|
|
100
|
-
90,
|
|
101
|
-
19,
|
|
102
|
-
153,
|
|
103
|
-
218,
|
|
104
|
-
255,
|
|
105
|
-
16,
|
|
106
|
-
132,
|
|
107
|
-
4,
|
|
108
|
-
142,
|
|
109
|
-
123,
|
|
110
|
-
216,
|
|
111
|
-
219,
|
|
112
|
-
233,
|
|
113
|
-
248,
|
|
114
|
-
89
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
}
|
|
64
|
+
writable: true
|
|
118
65
|
},
|
|
119
66
|
{
|
|
120
67
|
name: "mint"
|
|
@@ -148,6 +95,7 @@ const instructions = [
|
|
|
148
95
|
},
|
|
149
96
|
{
|
|
150
97
|
name: "associated_token_program",
|
|
98
|
+
optional: true,
|
|
151
99
|
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
152
100
|
},
|
|
153
101
|
{
|
|
@@ -190,60 +138,7 @@ const instructions = [
|
|
|
190
138
|
},
|
|
191
139
|
{
|
|
192
140
|
name: "signer_borrow_token_account",
|
|
193
|
-
writable: true
|
|
194
|
-
pda: {
|
|
195
|
-
seeds: [
|
|
196
|
-
{
|
|
197
|
-
kind: "account",
|
|
198
|
-
path: "signer"
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
kind: "account",
|
|
202
|
-
path: "token_program"
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
kind: "account",
|
|
206
|
-
path: "mint"
|
|
207
|
-
}
|
|
208
|
-
],
|
|
209
|
-
program: {
|
|
210
|
-
kind: "const",
|
|
211
|
-
value: [
|
|
212
|
-
140,
|
|
213
|
-
151,
|
|
214
|
-
37,
|
|
215
|
-
143,
|
|
216
|
-
78,
|
|
217
|
-
36,
|
|
218
|
-
137,
|
|
219
|
-
241,
|
|
220
|
-
187,
|
|
221
|
-
61,
|
|
222
|
-
16,
|
|
223
|
-
41,
|
|
224
|
-
20,
|
|
225
|
-
142,
|
|
226
|
-
13,
|
|
227
|
-
131,
|
|
228
|
-
11,
|
|
229
|
-
90,
|
|
230
|
-
19,
|
|
231
|
-
153,
|
|
232
|
-
218,
|
|
233
|
-
255,
|
|
234
|
-
16,
|
|
235
|
-
132,
|
|
236
|
-
4,
|
|
237
|
-
142,
|
|
238
|
-
123,
|
|
239
|
-
216,
|
|
240
|
-
219,
|
|
241
|
-
233,
|
|
242
|
-
248,
|
|
243
|
-
89
|
|
244
|
-
]
|
|
245
|
-
}
|
|
246
|
-
}
|
|
141
|
+
writable: true
|
|
247
142
|
},
|
|
248
143
|
{
|
|
249
144
|
name: "mint"
|
|
@@ -277,6 +172,7 @@ const instructions = [
|
|
|
277
172
|
},
|
|
278
173
|
{
|
|
279
174
|
name: "associated_token_program",
|
|
175
|
+
optional: true,
|
|
280
176
|
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
281
177
|
},
|
|
282
178
|
{
|
|
@@ -736,7 +632,6 @@ async function getFlashloanContext({
|
|
|
736
632
|
liquidity: getLiquidity(market),
|
|
737
633
|
liquidityProgram: getLiquidityProgramId(market),
|
|
738
634
|
tokenProgram,
|
|
739
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
740
635
|
systemProgram: SystemProgram.programId,
|
|
741
636
|
instructionSysvar: SYSVAR_INSTRUCTIONS_PUBKEY
|
|
742
637
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
-
import { O as OperateContextParams } from '../shared/lend.
|
|
3
|
+
import { O as OperateContextParams } from '../shared/lend.CZaDpI67.mjs';
|
|
4
4
|
import 'bn.js';
|
|
5
5
|
import '@coral-xyz/anchor';
|
|
6
6
|
|
|
@@ -40,7 +40,6 @@ declare function getRefinanceIx(params: OperateContextParams): Promise<{
|
|
|
40
40
|
oracleProgram: PublicKey;
|
|
41
41
|
supplyTokenProgram: PublicKey;
|
|
42
42
|
borrowTokenProgram: PublicKey;
|
|
43
|
-
associatedTokenProgram: PublicKey;
|
|
44
43
|
systemProgram: PublicKey;
|
|
45
44
|
};
|
|
46
45
|
remainingAccounts: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
-
import { O as OperateContextParams } from '../shared/lend.
|
|
3
|
+
import { O as OperateContextParams } from '../shared/lend.CZaDpI67.js';
|
|
4
4
|
import 'bn.js';
|
|
5
5
|
import '@coral-xyz/anchor';
|
|
6
6
|
|
|
@@ -40,7 +40,6 @@ declare function getRefinanceIx(params: OperateContextParams): Promise<{
|
|
|
40
40
|
oracleProgram: PublicKey;
|
|
41
41
|
supplyTokenProgram: PublicKey;
|
|
42
42
|
borrowTokenProgram: PublicKey;
|
|
43
|
-
associatedTokenProgram: PublicKey;
|
|
44
43
|
systemProgram: PublicKey;
|
|
45
44
|
};
|
|
46
45
|
remainingAccounts: {
|
package/dist/refinance/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as getOperateIx } from '../shared/lend.
|
|
1
|
+
import { C as vaultsIdl } from '../shared/lend.TR2SYmUo.mjs';
|
|
2
|
+
import { e as getOperateIx } from '../shared/lend.BFWi2x2e.mjs';
|
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import 'bn.js';
|
|
6
6
|
import '../shared/lend.a53XYkl5.mjs';
|
|
7
7
|
import '@solana/spl-token';
|
|
8
8
|
import '../shared/lend.C3XdrR6R.mjs';
|
|
9
|
+
import '../shared/lend.BR8HvUg-.mjs';
|
|
9
10
|
|
|
10
11
|
const address = "jup8QcdtqecBGw1iXHW3hQAsHQbTgEqbLbNMvvULmeK";
|
|
11
12
|
const metadata = {
|
|
@@ -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.TR2SYmUo.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.BR8HvUg-.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
|
}
|