@lavarage/sdk 7.5.8 → 7.5.9
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +68 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -3
- package/dist/index.mjs.map +1 -1
- package/index.ts +155 -64
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5187,7 +5187,7 @@ declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: Pro
|
|
|
5187
5187
|
tokenLedgerInstruction?: Record<string, unknown>;
|
|
5188
5188
|
};
|
|
5189
5189
|
quoteResponse: any;
|
|
5190
|
-
}, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
5190
|
+
}, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean, discountBps?: number, referralBps?: number) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
5191
5191
|
/**
|
|
5192
5192
|
* Closes a trading position on Lavarage V2
|
|
5193
5193
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -5187,7 +5187,7 @@ declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: Pro
|
|
|
5187
5187
|
tokenLedgerInstruction?: Record<string, unknown>;
|
|
5188
5188
|
};
|
|
5189
5189
|
quoteResponse: any;
|
|
5190
|
-
}, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
5190
|
+
}, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean, discountBps?: number, referralBps?: number) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
5191
5191
|
/**
|
|
5192
5192
|
* Closes a trading position on Lavarage V2
|
|
5193
5193
|
*
|
package/dist/index.js
CHANGED
|
@@ -6284,9 +6284,10 @@ var partialRepayV2 = (lavarageProgram, position, repaymentBps) => __async(void 0
|
|
|
6284
6284
|
}).compileToV0Message();
|
|
6285
6285
|
return new import_web32.VersionedTransaction(messageV0);
|
|
6286
6286
|
});
|
|
6287
|
-
var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions) => __async(void 0, null, function* () {
|
|
6287
|
+
var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps) => __async(void 0, null, function* () {
|
|
6288
6288
|
var _a, _b;
|
|
6289
6289
|
let partnerFeeMarkupAsPkey;
|
|
6290
|
+
const referralVaultProgram = new import_anchor2.Program(IDL, REFFERAL_VAULT_PROGRAM_ID, lavarageProgram.provider);
|
|
6290
6291
|
if (partnerFeeMarkup) {
|
|
6291
6292
|
const feeBuffer = Buffer.alloc(8);
|
|
6292
6293
|
feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
|
|
@@ -6354,6 +6355,24 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
6354
6355
|
});
|
|
6355
6356
|
const addressLookupTableAccounts = [];
|
|
6356
6357
|
const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
6358
|
+
const useReferral = discountBps !== void 0 && referralBps !== void 0;
|
|
6359
|
+
let partnerFeeRecipientCreateIx;
|
|
6360
|
+
let userVaultPda;
|
|
6361
|
+
if (partnerFeeRecipient && referralBps !== void 0 && referralVaultProgram) {
|
|
6362
|
+
[userVaultPda] = import_web32.PublicKey.findProgramAddressSync(
|
|
6363
|
+
[Buffer.from("user_vault"), new import_web32.PublicKey(partnerFeeRecipient).toBuffer()],
|
|
6364
|
+
referralVaultProgram.programId
|
|
6365
|
+
);
|
|
6366
|
+
const vaultAccountInfo = yield lavarageProgram.provider.connection.getAccountInfo(userVaultPda);
|
|
6367
|
+
if (!vaultAccountInfo) {
|
|
6368
|
+
partnerFeeRecipientCreateIx = yield referralVaultProgram.methods.initializeVault().accountsStrict({
|
|
6369
|
+
userVault: userVaultPda,
|
|
6370
|
+
user: partnerFeeRecipient,
|
|
6371
|
+
funder: lavarageProgram.provider.publicKey,
|
|
6372
|
+
systemProgram: import_web32.SystemProgram.programId
|
|
6373
|
+
}).instruction();
|
|
6374
|
+
}
|
|
6375
|
+
}
|
|
6357
6376
|
const closePositionIx = yield lavarageProgram.methods.tradingCloseBorrowCollateral().accountsStrict({
|
|
6358
6377
|
tradingPool: poolPubKey,
|
|
6359
6378
|
instructions: import_web32.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
@@ -6370,7 +6389,29 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
6370
6389
|
let repaySolIx = null;
|
|
6371
6390
|
let jupiterIxs = [];
|
|
6372
6391
|
if (jupInstruction.instructions == void 0) {
|
|
6373
|
-
repaySolIx = yield lavarageProgram.methods.
|
|
6392
|
+
repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
|
|
6393
|
+
new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
|
|
6394
|
+
new import_anchor2.BN(9997),
|
|
6395
|
+
new import_anchor2.BN(discountBps),
|
|
6396
|
+
new import_anchor2.BN(referralBps)
|
|
6397
|
+
).accountsStrict({
|
|
6398
|
+
nodeWallet: pool.account.nodeWallet,
|
|
6399
|
+
positionAccount: positionAccountPDA,
|
|
6400
|
+
tradingPool: poolPubKey,
|
|
6401
|
+
trader: lavarageProgram.provider.publicKey,
|
|
6402
|
+
systemProgram: import_web32.SystemProgram.programId,
|
|
6403
|
+
clock: import_web32.SYSVAR_CLOCK_PUBKEY,
|
|
6404
|
+
randomAccountAsId: position.account.seed,
|
|
6405
|
+
feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF"
|
|
6406
|
+
}).remainingAccounts(
|
|
6407
|
+
partnerFeeRecipient && partnerFeeMarkupAsPkey && userVaultPda ? [
|
|
6408
|
+
{
|
|
6409
|
+
pubkey: userVaultPda,
|
|
6410
|
+
isSigner: false,
|
|
6411
|
+
isWritable: true
|
|
6412
|
+
}
|
|
6413
|
+
] : []
|
|
6414
|
+
).instruction() : yield lavarageProgram.methods.tradingCloseRepaySol(
|
|
6374
6415
|
new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
|
|
6375
6416
|
new import_anchor2.BN(9997)
|
|
6376
6417
|
).accountsStrict({
|
|
@@ -6397,7 +6438,29 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
6397
6438
|
] : []
|
|
6398
6439
|
).instruction();
|
|
6399
6440
|
} else {
|
|
6400
|
-
repaySolIx = yield lavarageProgram.methods.
|
|
6441
|
+
repaySolIx = useReferral ? yield lavarageProgram.methods.tradingCloseRepaySolWithReferral(
|
|
6442
|
+
new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
|
|
6443
|
+
new import_anchor2.BN(9998),
|
|
6444
|
+
new import_anchor2.BN(discountBps),
|
|
6445
|
+
new import_anchor2.BN(referralBps)
|
|
6446
|
+
).accountsStrict({
|
|
6447
|
+
nodeWallet: pool.account.nodeWallet,
|
|
6448
|
+
positionAccount: positionAccountPDA,
|
|
6449
|
+
tradingPool: poolPubKey,
|
|
6450
|
+
trader: lavarageProgram.provider.publicKey,
|
|
6451
|
+
systemProgram: import_web32.SystemProgram.programId,
|
|
6452
|
+
clock: import_web32.SYSVAR_CLOCK_PUBKEY,
|
|
6453
|
+
randomAccountAsId: position.account.seed,
|
|
6454
|
+
feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF"
|
|
6455
|
+
}).remainingAccounts(
|
|
6456
|
+
partnerFeeRecipient && partnerFeeMarkupAsPkey && userVaultPda ? [
|
|
6457
|
+
{
|
|
6458
|
+
pubkey: userVaultPda,
|
|
6459
|
+
isSigner: false,
|
|
6460
|
+
isWritable: true
|
|
6461
|
+
}
|
|
6462
|
+
] : []
|
|
6463
|
+
).instruction() : yield lavarageProgram.methods.tradingCloseRepaySol(
|
|
6401
6464
|
new import_anchor2.BN(jupInstruction.quoteResponse.outAmount),
|
|
6402
6465
|
new import_anchor2.BN(9998)
|
|
6403
6466
|
).accountsStrict({
|
|
@@ -6454,6 +6517,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
6454
6517
|
});
|
|
6455
6518
|
if (splitTransactions) {
|
|
6456
6519
|
const setUpInstructions = [
|
|
6520
|
+
partnerFeeRecipientCreateIx,
|
|
6457
6521
|
jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null,
|
|
6458
6522
|
createAssociatedTokenAccountInstruction2
|
|
6459
6523
|
].filter((i) => !!i);
|
|
@@ -6481,6 +6545,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
6481
6545
|
return [tx2, tx22];
|
|
6482
6546
|
}
|
|
6483
6547
|
const allInstructions = [
|
|
6548
|
+
partnerFeeRecipientCreateIx,
|
|
6484
6549
|
jupInstruction.instructions && (platformFeeRecipientAccount == null ? void 0 : platformFeeRecipientAccount.instruction) ? platformFeeRecipientAccount.instruction : null,
|
|
6485
6550
|
createAssociatedTokenAccountInstruction2,
|
|
6486
6551
|
((_b = jupInstruction.instructions) == null ? void 0 : _b.tokenLedgerInstruction) ? deserializeInstruction(
|