@lavarage/sdk 7.5.8 → 7.5.10
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/.github/workflows/npm-publish.yml +33 -0
- package/docs/functions/borrowV1.html +1 -1
- package/docs/functions/borrowV2.html +1 -1
- package/docs/functions/closePositionEvm.html +2 -2
- package/docs/functions/closeTradeV1.html +7 -3
- package/docs/functions/closeTradeV2.html +7 -3
- package/docs/functions/createTpDelegate.html +2 -2
- package/docs/functions/getActiveLoanCountEvm.html +2 -2
- package/docs/functions/getActiveLoansBatchEvm.html +2 -2
- package/docs/functions/getAllPositions.html +2 -2
- package/docs/functions/getAvailableExposureEvm.html +2 -2
- package/docs/functions/getClosedPositions.html +2 -2
- package/docs/functions/getClosedPositionsEvm.html +2 -2
- package/docs/functions/getCollateralExposureEvm.html +2 -2
- package/docs/functions/getCollateralInfoEvm.html +2 -2
- package/docs/functions/getDelegateAccounts.html +2 -2
- package/docs/functions/getLiquidatedPositions.html +2 -2
- package/docs/functions/getLiquidatedPositionsEvm.html +2 -2
- package/docs/functions/getLoanEvm.html +2 -2
- package/docs/functions/getLoansByBorrowerEvm.html +2 -2
- package/docs/functions/getOffers.html +2 -2
- package/docs/functions/getOffersEvm.html +2 -2
- package/docs/functions/getOpenPositions.html +2 -2
- package/docs/functions/getOpeningFeeEvm.html +2 -2
- package/docs/functions/getPda.html +2 -2
- package/docs/functions/getPositionAccountPDA.html +2 -2
- package/docs/functions/getPositionsEvm.html +2 -2
- package/docs/functions/getProfitFeeEvm.html +2 -2
- package/docs/functions/getTokenBalanceEvm.html +2 -2
- package/docs/functions/getUserLoansEvm.html +2 -2
- package/docs/functions/lending.addToWithdrawalAccessList.html +1 -1
- package/docs/functions/lending.createOffer.html +2 -2
- package/docs/functions/lending.depositFunds.html +2 -2
- package/docs/functions/lending.getNodeWalletPDA.html +2 -2
- package/docs/functions/lending.getTradingPoolPDA.html +2 -2
- package/docs/functions/lending.getWithdrawalAccessList.html +1 -1
- package/docs/functions/lending.getWithdrawalAccessListPDA.html +1 -1
- package/docs/functions/lending.removeFromWithdrawalAccessList.html +1 -1
- package/docs/functions/lending.updateInterestRate.html +2 -2
- package/docs/functions/lending.updateMaxBorrow.html +2 -2
- package/docs/functions/lending.updateMaxExposure.html +2 -2
- package/docs/functions/lending.updateOffer.html +2 -2
- package/docs/functions/lending.withdrawFunds.html +2 -2
- package/docs/functions/lending.withdrawFundsV1.html +2 -2
- package/docs/functions/lending.withdrawFundsV2.html +2 -2
- package/docs/functions/liquidatePositionEvm.html +2 -2
- package/docs/functions/mergePositionV2.html +2 -2
- package/docs/functions/modifyTpDelegate.html +2 -2
- package/docs/functions/openPositionEvm.html +2 -2
- package/docs/functions/openTradeV1.html +8 -3
- package/docs/functions/openTradeV2.html +8 -3
- package/docs/functions/partialRepayV1.html +2 -2
- package/docs/functions/partialRepayV2.html +2 -2
- package/docs/functions/removeTpDelegate.html +2 -2
- package/docs/functions/splitPositionV2.html +2 -2
- package/docs/functions/updateMaxLendPerTokenBatchEvm.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +2 -2
- package/docs/modules/IDLV2.html +2 -2
- package/docs/modules/lending.html +1 -1
- package/docs/modules.html +2 -2
- package/docs/types/IDLV2.Lavarage.html +2 -2
- package/docs/types/Lavarage.html +2 -2
- package/docs/variables/IDL.html +1 -1
- package/docs/variables/IDLV2.IDL.html +1 -1
- package/index.ts +182 -71
- package/package.json +1 -1
- package/.DS_Store +0 -0
- package/dist/index.d.mts +0 -5390
- package/dist/index.d.ts +0 -5390
- package/dist/index.js +0 -7138
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -7103
- package/dist/index.mjs.map +0 -1
package/docs/variables/IDL.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>IDL | Lavarage SDK Documentation - v7.5.
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>IDL | Lavarage SDK Documentation - v7.5.9</title><meta name="description" content="Documentation for Lavarage SDK Documentation"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Lavarage SDK Documentation - v7.5.9</a><div id="tsd-toolbar-links"><a href="https://www.npmjs.com/package/@lavarage/sdk">NPM</a></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="" aria-current="page">IDL</a></li></ul><h1>Variable IDL<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">IDL</span><span class="tsd-signature-symbol">:</span> <a href="../types/Lavarage.html" class="tsd-signature-type tsd-kind-type-alias">Lavarage</a><span class="tsd-signature-symbol"> = ...</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/pinedefi/lavarage-sdk/blob/b2e66083b3ffd1c5b3fd8d8c6ce37856566b763b/idl/lavarage.ts#L1658">idl/lavarage.ts:1658</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://www.npmjs.com/package/@lavarage/sdk" class="tsd-nav-link">NPM</a></nav><nav class="tsd-navigation"><a href="../modules.html">Lavarage SDK Documentation - v7.5.9</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>IDL | Lavarage SDK Documentation - v7.5.
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>IDL | Lavarage SDK Documentation - v7.5.9</title><meta name="description" content="Documentation for Lavarage SDK Documentation"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">Lavarage SDK Documentation - v7.5.9</a><div id="tsd-toolbar-links"><a href="https://www.npmjs.com/package/@lavarage/sdk">NPM</a></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/IDLV2.html">IDLV2</a></li><li><a href="" aria-current="page">IDL</a></li></ul><h1>Variable IDL<code class="tsd-tag">Const</code></h1></div><div class="tsd-signature"><span class="tsd-kind-variable">IDL</span><span class="tsd-signature-symbol">:</span> <a href="../modules/IDLV2.html" class="tsd-signature-type tsd-kind-namespace">IDLV2</a><span class="tsd-signature-symbol">.</span><a href="../types/IDLV2.Lavarage.html" class="tsd-signature-type tsd-kind-type-alias">Lavarage</a><span class="tsd-signature-symbol"> = ...</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/pinedefi/lavarage-sdk/blob/b2e66083b3ffd1c5b3fd8d8c6ce37856566b763b/idl/lavaragev2.ts#L1771">idl/lavaragev2.ts:1771</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav id="tsd-sidebar-links" class="tsd-navigation"><a href="https://www.npmjs.com/package/@lavarage/sdk" class="tsd-nav-link">NPM</a></nav><nav class="tsd-navigation"><a href="../modules.html">Lavarage SDK Documentation - v7.5.9</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
package/index.ts
CHANGED
|
@@ -864,6 +864,11 @@ export const borrowV2 = async (
|
|
|
864
864
|
* @param partnerFeeRecipient - Optional wallet to receive partner fees
|
|
865
865
|
* @param partnerFeeMarkup - Optional partner fee amount in basis points
|
|
866
866
|
* @param computeBudgetMicroLamports - Optional compute budget for priority fees
|
|
867
|
+
* @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
|
|
868
|
+
* @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
|
|
869
|
+
* @param discountBps - Optional discount basis points for the referral program
|
|
870
|
+
* @param referralBps - Optional referral basis points for the referral program
|
|
871
|
+
* @param optionalRPCResults - Optional RPC results to use for the transaction (speeds up the transaction building)
|
|
867
872
|
*
|
|
868
873
|
* @returns A versioned transaction ready to be signed and sent
|
|
869
874
|
*
|
|
@@ -1223,6 +1228,11 @@ export const openTradeV1 = async (
|
|
|
1223
1228
|
* @param partnerFeeRecipient - Optional wallet to receive partner fees
|
|
1224
1229
|
* @param partnerFeeMarkup - Optional partner fee amount in basis points
|
|
1225
1230
|
* @param computeBudgetMicroLamports - Optional compute budget for priority fees
|
|
1231
|
+
* @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
|
|
1232
|
+
* @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
|
|
1233
|
+
* @param discountBps - Optional discount basis points for the referral program
|
|
1234
|
+
* @param referralBps - Optional referral basis points for the referral program
|
|
1235
|
+
* @param optionalRPCResults - Optional RPC results to use for the transaction (speeds up the transaction building)
|
|
1226
1236
|
*
|
|
1227
1237
|
* @returns A versioned transaction ready to be signed and sent
|
|
1228
1238
|
*
|
|
@@ -1454,6 +1464,13 @@ export const openTradeV2 = async (
|
|
|
1454
1464
|
}
|
|
1455
1465
|
}
|
|
1456
1466
|
|
|
1467
|
+
const partnerDirectAta = partnerFeeRecipient ? getAssociatedTokenAddressSync(
|
|
1468
|
+
quoteToken,
|
|
1469
|
+
partnerFeeRecipient,
|
|
1470
|
+
true,
|
|
1471
|
+
quoteTokenProgram
|
|
1472
|
+
) : undefined;
|
|
1473
|
+
|
|
1457
1474
|
const tradingOpenBorrowInstruction = useReferral
|
|
1458
1475
|
? await lavarageProgram.methods
|
|
1459
1476
|
.tradingOpenBorrowWithReferral(
|
|
@@ -1543,15 +1560,10 @@ export const openTradeV2 = async (
|
|
|
1543
1560
|
),
|
|
1544
1561
|
})
|
|
1545
1562
|
.remainingAccounts(
|
|
1546
|
-
partnerFeeRecipient && partnerFeeMarkupAsPkey &&
|
|
1563
|
+
partnerFeeRecipient && partnerFeeMarkupAsPkey && partnerDirectAta
|
|
1547
1564
|
? [
|
|
1548
1565
|
{
|
|
1549
|
-
pubkey:
|
|
1550
|
-
quoteToken,
|
|
1551
|
-
userVaultPda,
|
|
1552
|
-
true, // allowOwnerOffCurve for PDA
|
|
1553
|
-
quoteTokenProgram
|
|
1554
|
-
),
|
|
1566
|
+
pubkey: partnerDirectAta,
|
|
1555
1567
|
isSigner: false,
|
|
1556
1568
|
isWritable: true,
|
|
1557
1569
|
},
|
|
@@ -2079,6 +2091,10 @@ export const partialRepayV2 = async (
|
|
|
2079
2091
|
* @param partnerFeeRecipient - Optional wallet to receive partner fees
|
|
2080
2092
|
* @param partnerFeeMarkup - Optional partner fee amount in basis points
|
|
2081
2093
|
* @param computeBudgetMicroLamports - Optional compute budget for priority fees
|
|
2094
|
+
* @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
|
|
2095
|
+
* @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
|
|
2096
|
+
* @param discountBps - Optional discount basis points for the referral program
|
|
2097
|
+
* @param referralBps - Optional referral basis points for the referral program
|
|
2082
2098
|
*
|
|
2083
2099
|
* @returns Transaction to close the position
|
|
2084
2100
|
*
|
|
@@ -2128,8 +2144,12 @@ export const closeTradeV1 = async (
|
|
|
2128
2144
|
computeBudgetMicroLamports?: number,
|
|
2129
2145
|
platformFeeRecipient?: PublicKey,
|
|
2130
2146
|
splitTransactions?: boolean,
|
|
2147
|
+
discountBps?: number,
|
|
2148
|
+
referralBps?: number,
|
|
2131
2149
|
) => {
|
|
2132
2150
|
let partnerFeeMarkupAsPkey;
|
|
2151
|
+
const referralVaultProgram = new Program<UserVault>(userVaultIDL, REFFERAL_VAULT_PROGRAM_ID, lavarageProgram.provider);
|
|
2152
|
+
|
|
2133
2153
|
if (partnerFeeMarkup) {
|
|
2134
2154
|
const feeBuffer = Buffer.alloc(8);
|
|
2135
2155
|
feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
|
|
@@ -2216,6 +2236,31 @@ export const closeTradeV1 = async (
|
|
|
2216
2236
|
const { blockhash } =
|
|
2217
2237
|
await lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
2218
2238
|
|
|
2239
|
+
const useReferral = discountBps !== undefined && referralBps !== undefined;
|
|
2240
|
+
|
|
2241
|
+
// Check if partner fee recipient vault needs to be initialized via referralVaultProgram
|
|
2242
|
+
let partnerFeeRecipientCreateIx: TransactionInstruction | undefined;
|
|
2243
|
+
let userVaultPda: PublicKey | undefined;
|
|
2244
|
+
if (partnerFeeRecipient && referralBps !== undefined && referralVaultProgram) {
|
|
2245
|
+
[userVaultPda] = PublicKey.findProgramAddressSync(
|
|
2246
|
+
[Buffer.from("user_vault"), new PublicKey(partnerFeeRecipient).toBuffer()],
|
|
2247
|
+
referralVaultProgram.programId
|
|
2248
|
+
);
|
|
2249
|
+
const vaultAccountInfo = await lavarageProgram.provider.connection.getAccountInfo(userVaultPda);
|
|
2250
|
+
if (!vaultAccountInfo) {
|
|
2251
|
+
// Initialize the vault using referralVaultProgram
|
|
2252
|
+
partnerFeeRecipientCreateIx = await referralVaultProgram.methods
|
|
2253
|
+
.initializeVault()
|
|
2254
|
+
.accountsStrict({
|
|
2255
|
+
userVault: userVaultPda,
|
|
2256
|
+
user: partnerFeeRecipient!,
|
|
2257
|
+
funder: lavarageProgram.provider.publicKey!,
|
|
2258
|
+
systemProgram: SystemProgram.programId,
|
|
2259
|
+
})
|
|
2260
|
+
.instruction();
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2219
2264
|
const closePositionIx = await lavarageProgram.methods
|
|
2220
2265
|
.tradingCloseBorrowCollateral()
|
|
2221
2266
|
.accountsStrict({
|
|
@@ -2236,71 +2281,131 @@ export const closeTradeV1 = async (
|
|
|
2236
2281
|
let repaySolIx: TransactionInstruction | null = null;
|
|
2237
2282
|
let jupiterIxs: TransactionInstruction[] = [];
|
|
2238
2283
|
if (jupInstruction.instructions == undefined) {
|
|
2239
|
-
repaySolIx =
|
|
2240
|
-
.
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2284
|
+
repaySolIx = useReferral
|
|
2285
|
+
? await lavarageProgram.methods
|
|
2286
|
+
.tradingCloseRepaySolWithReferral(
|
|
2287
|
+
new BN(jupInstruction.quoteResponse.outAmount),
|
|
2288
|
+
new BN(9997),
|
|
2289
|
+
new BN(discountBps),
|
|
2290
|
+
new BN(referralBps)
|
|
2291
|
+
)
|
|
2292
|
+
.accountsStrict({
|
|
2293
|
+
nodeWallet: pool.account.nodeWallet,
|
|
2294
|
+
positionAccount: positionAccountPDA,
|
|
2295
|
+
tradingPool: poolPubKey,
|
|
2296
|
+
trader: lavarageProgram.provider.publicKey!,
|
|
2297
|
+
systemProgram: SystemProgram.programId,
|
|
2298
|
+
clock: SYSVAR_CLOCK_PUBKEY,
|
|
2299
|
+
randomAccountAsId: position.account.seed,
|
|
2300
|
+
feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF",
|
|
2301
|
+
})
|
|
2302
|
+
.remainingAccounts(
|
|
2303
|
+
partnerFeeRecipient && partnerFeeMarkupAsPkey && userVaultPda
|
|
2304
|
+
? [
|
|
2305
|
+
{
|
|
2306
|
+
pubkey: userVaultPda,
|
|
2307
|
+
isSigner: false,
|
|
2308
|
+
isWritable: true,
|
|
2309
|
+
}
|
|
2310
|
+
]
|
|
2311
|
+
: []
|
|
2312
|
+
)
|
|
2313
|
+
.instruction()
|
|
2314
|
+
: await lavarageProgram.methods
|
|
2315
|
+
.tradingCloseRepaySol(
|
|
2316
|
+
new BN(jupInstruction.quoteResponse.outAmount),
|
|
2317
|
+
new BN(9997)
|
|
2318
|
+
)
|
|
2319
|
+
.accountsStrict({
|
|
2320
|
+
nodeWallet: pool.account.nodeWallet,
|
|
2321
|
+
positionAccount: positionAccountPDA,
|
|
2322
|
+
tradingPool: poolPubKey,
|
|
2323
|
+
trader: lavarageProgram.provider.publicKey!,
|
|
2324
|
+
systemProgram: SystemProgram.programId,
|
|
2325
|
+
clock: SYSVAR_CLOCK_PUBKEY,
|
|
2326
|
+
randomAccountAsId: position.account.seed,
|
|
2327
|
+
feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF",
|
|
2328
|
+
})
|
|
2329
|
+
.remainingAccounts(
|
|
2330
|
+
partnerFeeRecipient && partnerFeeMarkupAsPkey
|
|
2331
|
+
? [
|
|
2332
|
+
{
|
|
2333
|
+
pubkey: partnerFeeRecipient,
|
|
2334
|
+
isSigner: false,
|
|
2335
|
+
isWritable: true,
|
|
2336
|
+
},
|
|
2337
|
+
{
|
|
2338
|
+
pubkey: partnerFeeMarkupAsPkey,
|
|
2339
|
+
isSigner: false,
|
|
2340
|
+
isWritable: false,
|
|
2341
|
+
},
|
|
2342
|
+
]
|
|
2343
|
+
: []
|
|
2344
|
+
)
|
|
2345
|
+
.instruction();
|
|
2271
2346
|
} else {
|
|
2272
|
-
repaySolIx =
|
|
2273
|
-
.
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2347
|
+
repaySolIx = useReferral
|
|
2348
|
+
? await lavarageProgram.methods
|
|
2349
|
+
.tradingCloseRepaySolWithReferral(
|
|
2350
|
+
new BN(jupInstruction.quoteResponse.outAmount),
|
|
2351
|
+
new BN(9998),
|
|
2352
|
+
new BN(discountBps),
|
|
2353
|
+
new BN(referralBps)
|
|
2354
|
+
)
|
|
2355
|
+
.accountsStrict({
|
|
2356
|
+
nodeWallet: pool.account.nodeWallet,
|
|
2357
|
+
positionAccount: positionAccountPDA,
|
|
2358
|
+
tradingPool: poolPubKey,
|
|
2359
|
+
trader: lavarageProgram.provider.publicKey!,
|
|
2360
|
+
systemProgram: SystemProgram.programId,
|
|
2361
|
+
clock: SYSVAR_CLOCK_PUBKEY,
|
|
2362
|
+
randomAccountAsId: position.account.seed,
|
|
2363
|
+
feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF",
|
|
2364
|
+
})
|
|
2365
|
+
.remainingAccounts(
|
|
2366
|
+
partnerFeeRecipient && partnerFeeMarkupAsPkey && userVaultPda
|
|
2367
|
+
? [
|
|
2368
|
+
{
|
|
2369
|
+
pubkey: userVaultPda,
|
|
2370
|
+
isSigner: false,
|
|
2371
|
+
isWritable: true,
|
|
2372
|
+
}
|
|
2373
|
+
]
|
|
2374
|
+
: []
|
|
2375
|
+
)
|
|
2376
|
+
.instruction()
|
|
2377
|
+
: await lavarageProgram.methods
|
|
2378
|
+
.tradingCloseRepaySol(
|
|
2379
|
+
new BN(jupInstruction.quoteResponse.outAmount),
|
|
2380
|
+
new BN(9998)
|
|
2381
|
+
)
|
|
2382
|
+
.accountsStrict({
|
|
2383
|
+
nodeWallet: pool.account.nodeWallet,
|
|
2384
|
+
positionAccount: positionAccountPDA,
|
|
2385
|
+
tradingPool: poolPubKey,
|
|
2386
|
+
trader: lavarageProgram.provider.publicKey!,
|
|
2387
|
+
systemProgram: SystemProgram.programId,
|
|
2388
|
+
clock: SYSVAR_CLOCK_PUBKEY,
|
|
2389
|
+
randomAccountAsId: position.account.seed,
|
|
2390
|
+
feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF",
|
|
2391
|
+
})
|
|
2392
|
+
.remainingAccounts(
|
|
2393
|
+
partnerFeeRecipient && partnerFeeMarkupAsPkey
|
|
2394
|
+
? [
|
|
2395
|
+
{
|
|
2396
|
+
pubkey: partnerFeeRecipient,
|
|
2397
|
+
isSigner: false,
|
|
2398
|
+
isWritable: true,
|
|
2399
|
+
},
|
|
2400
|
+
{
|
|
2401
|
+
pubkey: partnerFeeMarkupAsPkey,
|
|
2402
|
+
isSigner: false,
|
|
2403
|
+
isWritable: false,
|
|
2404
|
+
},
|
|
2405
|
+
]
|
|
2406
|
+
: []
|
|
2407
|
+
)
|
|
2408
|
+
.instruction();
|
|
2304
2409
|
|
|
2305
2410
|
const {
|
|
2306
2411
|
setupInstructions,
|
|
@@ -2339,6 +2444,7 @@ export const closeTradeV1 = async (
|
|
|
2339
2444
|
|
|
2340
2445
|
if (splitTransactions) {
|
|
2341
2446
|
const setUpInstructions = [
|
|
2447
|
+
partnerFeeRecipientCreateIx,
|
|
2342
2448
|
jupInstruction.instructions && platformFeeRecipientAccount?.instruction ? platformFeeRecipientAccount.instruction : null,
|
|
2343
2449
|
createAssociatedTokenAccountInstruction
|
|
2344
2450
|
].filter((i) => !!i);
|
|
@@ -2375,6 +2481,7 @@ export const closeTradeV1 = async (
|
|
|
2375
2481
|
}
|
|
2376
2482
|
|
|
2377
2483
|
const allInstructions = [
|
|
2484
|
+
partnerFeeRecipientCreateIx,
|
|
2378
2485
|
jupInstruction.instructions && platformFeeRecipientAccount?.instruction ? platformFeeRecipientAccount.instruction : null,
|
|
2379
2486
|
createAssociatedTokenAccountInstruction,
|
|
2380
2487
|
jupInstruction.instructions?.tokenLedgerInstruction
|
|
@@ -2413,6 +2520,10 @@ export const closeTradeV1 = async (
|
|
|
2413
2520
|
* @param partnerFeeRecipient - Optional wallet to receive partner fees
|
|
2414
2521
|
* @param partnerFeeMarkup - Optional partner fee amount in basis points
|
|
2415
2522
|
* @param computeBudgetMicroLamports - Optional compute budget for priority fees
|
|
2523
|
+
* @param platformFeeRecipient - Optional wallet to receive platform fees (jup, okx)
|
|
2524
|
+
* @param splitTransactions - Optional boolean to split the transaction into multiple transactions (jito bundle)
|
|
2525
|
+
* @param discountBps - Optional discount basis points for the referral program
|
|
2526
|
+
* @param referralBps - Optional referral basis points for the referral program
|
|
2416
2527
|
*
|
|
2417
2528
|
* @returns Transaction to close the position
|
|
2418
2529
|
*
|
package/package.json
CHANGED
package/.DS_Store
DELETED
|
Binary file
|