@lavarage/sdk 7.0.1 → 7.0.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/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +44 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -8
- package/dist/index.mjs.map +1 -1
- package/index.ts +46 -4
- package/lending.ts +7 -2
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -196,7 +196,8 @@ export const openTradeV1 = async (
|
|
|
196
196
|
tokenProgram: PublicKey,
|
|
197
197
|
partnerFeeRecipient?: PublicKey,
|
|
198
198
|
partnerFeeMarkup?: number,
|
|
199
|
-
computeBudgetMicroLamports?: number
|
|
199
|
+
computeBudgetMicroLamports?: number,
|
|
200
|
+
platformFeeRecipient?: PublicKey,
|
|
200
201
|
) => {
|
|
201
202
|
let partnerFeeMarkupAsPkey;
|
|
202
203
|
if (partnerFeeMarkup) {
|
|
@@ -227,6 +228,13 @@ export const openTradeV1 = async (
|
|
|
227
228
|
tokenProgram
|
|
228
229
|
);
|
|
229
230
|
|
|
231
|
+
const platformFeeRecipientAccount = platformFeeRecipient ? await getTokenAccountOrCreateIfNotExists(
|
|
232
|
+
lavarageProgram,
|
|
233
|
+
platformFeeRecipient,
|
|
234
|
+
offer.account.collateralType,
|
|
235
|
+
tokenProgram
|
|
236
|
+
) : undefined;
|
|
237
|
+
|
|
230
238
|
const tokenAccountCreationTx = new Transaction();
|
|
231
239
|
|
|
232
240
|
if (fromTokenAccount.instruction) {
|
|
@@ -237,6 +245,10 @@ export const openTradeV1 = async (
|
|
|
237
245
|
tokenAccountCreationTx.add(toTokenAccount.instruction);
|
|
238
246
|
}
|
|
239
247
|
|
|
248
|
+
if (platformFeeRecipientAccount?.instruction) {
|
|
249
|
+
tokenAccountCreationTx.add(platformFeeRecipientAccount.instruction);
|
|
250
|
+
}
|
|
251
|
+
|
|
240
252
|
const instructionsJup = jupInstruction.instructions;
|
|
241
253
|
|
|
242
254
|
const {
|
|
@@ -391,7 +403,8 @@ export const openTradeV2 = async (
|
|
|
391
403
|
tokenProgram: PublicKey,
|
|
392
404
|
partnerFeeRecipient?: PublicKey,
|
|
393
405
|
partnerFeeMarkup?: number,
|
|
394
|
-
computeBudgetMicroLamports?: number
|
|
406
|
+
computeBudgetMicroLamports?: number,
|
|
407
|
+
platformFeeRecipient?: PublicKey,
|
|
395
408
|
) => {
|
|
396
409
|
let partnerFeeMarkupAsPkey;
|
|
397
410
|
if (partnerFeeMarkup) {
|
|
@@ -426,6 +439,13 @@ export const openTradeV2 = async (
|
|
|
426
439
|
tokenProgram
|
|
427
440
|
);
|
|
428
441
|
|
|
442
|
+
const platformFeeRecipientAccount = platformFeeRecipient ? await getTokenAccountOrCreateIfNotExists(
|
|
443
|
+
lavarageProgram,
|
|
444
|
+
platformFeeRecipient,
|
|
445
|
+
offer.account.collateralType,
|
|
446
|
+
tokenProgram
|
|
447
|
+
) : undefined;
|
|
448
|
+
|
|
429
449
|
const tokenAccountCreationTx = new Transaction();
|
|
430
450
|
|
|
431
451
|
if (fromTokenAccount.instruction) {
|
|
@@ -436,6 +456,10 @@ export const openTradeV2 = async (
|
|
|
436
456
|
tokenAccountCreationTx.add(toTokenAccount.instruction);
|
|
437
457
|
}
|
|
438
458
|
|
|
459
|
+
if (platformFeeRecipientAccount?.instruction) {
|
|
460
|
+
tokenAccountCreationTx.add(platformFeeRecipientAccount.instruction);
|
|
461
|
+
}
|
|
462
|
+
|
|
439
463
|
const instructionsJup = jupInstruction.instructions;
|
|
440
464
|
|
|
441
465
|
const {
|
|
@@ -885,7 +909,8 @@ export const closeTradeV1 = async (
|
|
|
885
909
|
},
|
|
886
910
|
partnerFeeRecipient?: PublicKey,
|
|
887
911
|
partnerFeeMarkup?: number,
|
|
888
|
-
computeBudgetMicroLamports?: number
|
|
912
|
+
computeBudgetMicroLamports?: number,
|
|
913
|
+
platformFeeRecipient?: PublicKey,
|
|
889
914
|
) => {
|
|
890
915
|
let partnerFeeMarkupAsPkey;
|
|
891
916
|
if (partnerFeeMarkup) {
|
|
@@ -923,6 +948,13 @@ export const closeTradeV1 = async (
|
|
|
923
948
|
tokenProgram
|
|
924
949
|
);
|
|
925
950
|
|
|
951
|
+
const platformFeeRecipientAccount = platformFeeRecipient ? await getTokenAccountOrCreateIfNotExists(
|
|
952
|
+
lavarageProgram,
|
|
953
|
+
platformFeeRecipient,
|
|
954
|
+
offer.account.collateralType,
|
|
955
|
+
tokenProgram
|
|
956
|
+
) : undefined;
|
|
957
|
+
|
|
926
958
|
const jupiterSellIx = jupInstruction!.instructions;
|
|
927
959
|
|
|
928
960
|
const deserializeInstruction = (instruction: any) => {
|
|
@@ -1090,6 +1122,7 @@ export const closeTradeV1 = async (
|
|
|
1090
1122
|
});
|
|
1091
1123
|
|
|
1092
1124
|
const allInstructions = [
|
|
1125
|
+
jupInstruction.instructions && platformFeeRecipientAccount?.instruction ? platformFeeRecipientAccount.instruction : null,
|
|
1093
1126
|
jupInstruction.instructions?.tokenLedgerInstruction
|
|
1094
1127
|
? createAssociatedTokenAccountInstruction
|
|
1095
1128
|
: null,
|
|
@@ -1142,7 +1175,8 @@ export const closeTradeV2 = async (
|
|
|
1142
1175
|
quoteToken: PublicKey,
|
|
1143
1176
|
partnerFeeRecipient?: PublicKey,
|
|
1144
1177
|
partnerFeeMarkup?: number,
|
|
1145
|
-
computeBudgetMicroLamports?: number
|
|
1178
|
+
computeBudgetMicroLamports?: number,
|
|
1179
|
+
platformFeeRecipient?: PublicKey,
|
|
1146
1180
|
) => {
|
|
1147
1181
|
let partnerFeeMarkupAsPkey;
|
|
1148
1182
|
if (partnerFeeMarkup) {
|
|
@@ -1184,6 +1218,13 @@ export const closeTradeV2 = async (
|
|
|
1184
1218
|
tokenProgram
|
|
1185
1219
|
);
|
|
1186
1220
|
|
|
1221
|
+
const platformFeeRecipientAccount = platformFeeRecipient ? await getTokenAccountOrCreateIfNotExists(
|
|
1222
|
+
lavarageProgram,
|
|
1223
|
+
platformFeeRecipient,
|
|
1224
|
+
offer.account.collateralType,
|
|
1225
|
+
tokenProgram
|
|
1226
|
+
) : undefined;
|
|
1227
|
+
|
|
1187
1228
|
const jupiterSellIx = jupInstruction!.instructions;
|
|
1188
1229
|
|
|
1189
1230
|
const deserializeInstruction = (instruction: any) => {
|
|
@@ -1395,6 +1436,7 @@ export const closeTradeV2 = async (
|
|
|
1395
1436
|
});
|
|
1396
1437
|
|
|
1397
1438
|
const allInstructions = [
|
|
1439
|
+
jupInstruction.instructions && platformFeeRecipientAccount?.instruction ? platformFeeRecipientAccount.instruction : null,
|
|
1398
1440
|
jupInstruction.instructions?.tokenLedgerInstruction
|
|
1399
1441
|
? createAssociatedTokenAccountInstruction
|
|
1400
1442
|
: null,
|
package/lending.ts
CHANGED
|
@@ -211,12 +211,15 @@ export async function withdrawFundsV1(
|
|
|
211
211
|
const { blockhash } =
|
|
212
212
|
await lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
213
213
|
|
|
214
|
+
const withdrawalAccessList = getWithdrawalAccessListPDA(lavarageProgram.programId);
|
|
215
|
+
|
|
214
216
|
const instruction = await lavarageProgram.methods
|
|
215
217
|
.lpOperatorWithdrawFromNodeWallet(new BN(params.amount))
|
|
216
|
-
.
|
|
218
|
+
.accountsStrict({
|
|
217
219
|
nodeWallet: params.nodeWallet,
|
|
218
220
|
funder: params.funder,
|
|
219
221
|
systemProgram: SystemProgram.programId,
|
|
222
|
+
withdrawalAccessList: withdrawalAccessList,
|
|
220
223
|
})
|
|
221
224
|
.instruction();
|
|
222
225
|
|
|
@@ -257,10 +260,11 @@ export async function withdrawFundsV2(
|
|
|
257
260
|
const toTokenAccount =
|
|
258
261
|
params.toTokenAccount ||
|
|
259
262
|
getAssociatedTokenAddressSync(mintPubkey, params.funder);
|
|
263
|
+
const withdrawalAccessList = getWithdrawalAccessListPDA(lavarageProgram.programId);
|
|
260
264
|
|
|
261
265
|
const instruction = await lavarageProgram.methods
|
|
262
266
|
.lpOperatorWithdrawFromNodeWallet(new BN(params.amount))
|
|
263
|
-
.
|
|
267
|
+
.accountsStrict({
|
|
264
268
|
nodeWallet: params.nodeWallet,
|
|
265
269
|
funder: params.funder,
|
|
266
270
|
systemProgram: SystemProgram.programId,
|
|
@@ -268,6 +272,7 @@ export async function withdrawFundsV2(
|
|
|
268
272
|
fromTokenAccount,
|
|
269
273
|
toTokenAccount,
|
|
270
274
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
275
|
+
withdrawalAccessList: withdrawalAccessList,
|
|
271
276
|
})
|
|
272
277
|
.instruction();
|
|
273
278
|
|