@lavarage/sdk 6.1.9 → 6.3.0
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 +106 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -32
- package/dist/index.mjs.map +1 -1
- package/index.ts +104 -53
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2440,7 +2440,7 @@ declare const openTradeV1: (lavarageProgram: Program<Lavarage$1>, offer: Program
|
|
|
2440
2440
|
swapInstruction: Record<string, unknown>;
|
|
2441
2441
|
addressLookupTableAddresses: string[];
|
|
2442
2442
|
};
|
|
2443
|
-
}, marginSOL: BN, leverage: number, randomSeed: Keypair, partnerFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
|
|
2443
|
+
}, marginSOL: BN, leverage: number, randomSeed: Keypair, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
|
|
2444
2444
|
declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAccount<{
|
|
2445
2445
|
nodeWallet: PublicKey;
|
|
2446
2446
|
interestRate: number;
|
|
@@ -2451,7 +2451,7 @@ declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAc
|
|
|
2451
2451
|
swapInstruction: Record<string, unknown>;
|
|
2452
2452
|
addressLookupTableAddresses: string[];
|
|
2453
2453
|
};
|
|
2454
|
-
}, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
|
|
2454
|
+
}, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
|
|
2455
2455
|
declare const createTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
|
|
2456
2456
|
pool: PublicKey;
|
|
2457
2457
|
seed: PublicKey;
|
|
@@ -2499,7 +2499,7 @@ declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: Pro
|
|
|
2499
2499
|
addressLookupTableAddresses: string[];
|
|
2500
2500
|
};
|
|
2501
2501
|
quoteResponse: any;
|
|
2502
|
-
}, partnerFeeRecipient?: PublicKey,
|
|
2502
|
+
}, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
|
|
2503
2503
|
declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: ProgramAccount<{
|
|
2504
2504
|
pool: PublicKey;
|
|
2505
2505
|
seed: PublicKey;
|
|
@@ -2517,7 +2517,7 @@ declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: Progr
|
|
|
2517
2517
|
addressLookupTableAddresses: string[];
|
|
2518
2518
|
};
|
|
2519
2519
|
quoteResponse: any;
|
|
2520
|
-
}, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey,
|
|
2520
|
+
}, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
|
|
2521
2521
|
declare const getDelegateAccounts: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, userPubKey?: PublicKey) => Promise<{
|
|
2522
2522
|
parsed: {
|
|
2523
2523
|
tpPrice: any;
|
package/dist/index.d.ts
CHANGED
|
@@ -2440,7 +2440,7 @@ declare const openTradeV1: (lavarageProgram: Program<Lavarage$1>, offer: Program
|
|
|
2440
2440
|
swapInstruction: Record<string, unknown>;
|
|
2441
2441
|
addressLookupTableAddresses: string[];
|
|
2442
2442
|
};
|
|
2443
|
-
}, marginSOL: BN, leverage: number, randomSeed: Keypair, partnerFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
|
|
2443
|
+
}, marginSOL: BN, leverage: number, randomSeed: Keypair, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
|
|
2444
2444
|
declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAccount<{
|
|
2445
2445
|
nodeWallet: PublicKey;
|
|
2446
2446
|
interestRate: number;
|
|
@@ -2451,7 +2451,7 @@ declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAc
|
|
|
2451
2451
|
swapInstruction: Record<string, unknown>;
|
|
2452
2452
|
addressLookupTableAddresses: string[];
|
|
2453
2453
|
};
|
|
2454
|
-
}, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey) => Promise<VersionedTransaction>;
|
|
2454
|
+
}, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
|
|
2455
2455
|
declare const createTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
|
|
2456
2456
|
pool: PublicKey;
|
|
2457
2457
|
seed: PublicKey;
|
|
@@ -2499,7 +2499,7 @@ declare const closeTradeV1: (lavarageProgram: Program<Lavarage$1>, position: Pro
|
|
|
2499
2499
|
addressLookupTableAddresses: string[];
|
|
2500
2500
|
};
|
|
2501
2501
|
quoteResponse: any;
|
|
2502
|
-
}, partnerFeeRecipient?: PublicKey,
|
|
2502
|
+
}, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
|
|
2503
2503
|
declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: ProgramAccount<{
|
|
2504
2504
|
pool: PublicKey;
|
|
2505
2505
|
seed: PublicKey;
|
|
@@ -2517,7 +2517,7 @@ declare const closeTradeV2: (lavarageProgram: Program<Lavarage>, position: Progr
|
|
|
2517
2517
|
addressLookupTableAddresses: string[];
|
|
2518
2518
|
};
|
|
2519
2519
|
quoteResponse: any;
|
|
2520
|
-
}, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey,
|
|
2520
|
+
}, quoteToken: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number) => Promise<VersionedTransaction>;
|
|
2521
2521
|
declare const getDelegateAccounts: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, userPubKey?: PublicKey) => Promise<{
|
|
2522
2522
|
parsed: {
|
|
2523
2523
|
tpPrice: any;
|
package/dist/index.js
CHANGED
|
@@ -2559,7 +2559,15 @@ var getAllPositions = (lavarageProgram) => {
|
|
|
2559
2559
|
{ dataSize: 178 }
|
|
2560
2560
|
]);
|
|
2561
2561
|
};
|
|
2562
|
-
var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, partnerFeeRecipient) => __async(void 0, null, function* () {
|
|
2562
|
+
var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
|
|
2563
|
+
let partnerFeeMarkupAsPkey;
|
|
2564
|
+
if (partnerFeeMarkup) {
|
|
2565
|
+
const feeBuffer = Buffer.alloc(8);
|
|
2566
|
+
feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
|
|
2567
|
+
const feeBuffer32 = Buffer.alloc(32);
|
|
2568
|
+
feeBuffer32.set(feeBuffer, 0);
|
|
2569
|
+
partnerFeeMarkupAsPkey = new import_web3.PublicKey(feeBuffer32);
|
|
2570
|
+
}
|
|
2563
2571
|
const positionAccount = getPositionAccountPDA(lavarageProgram, offer, randomSeed.publicKey);
|
|
2564
2572
|
const mintAccount = yield lavarageProgram.provider.connection.getAccountInfo(offer.account.collateralType);
|
|
2565
2573
|
const tokenProgram = mintAccount == null ? void 0 : mintAccount.owner;
|
|
@@ -2600,7 +2608,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
2600
2608
|
}, new Array());
|
|
2601
2609
|
});
|
|
2602
2610
|
const addressLookupTableAccounts = [];
|
|
2603
|
-
addressLookupTableAccounts.push(...yield getAddressLookupTableAccounts(addressLookupTableAddresses));
|
|
2611
|
+
addressLookupTableAccounts.push(...yield getAddressLookupTableAccounts(["5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi", ...addressLookupTableAddresses]));
|
|
2604
2612
|
const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
2605
2613
|
const tradingOpenBorrowInstruction = yield lavarageProgram.methods.tradingOpenBorrow(new import_anchor.BN((marginSOL.toNumber() * leverage).toFixed(0)), marginSOL).accountsStrict({
|
|
2606
2614
|
nodeWallet: offer.account.nodeWallet,
|
|
@@ -2612,7 +2620,15 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
2612
2620
|
clock: import_web3.SYSVAR_CLOCK_PUBKEY,
|
|
2613
2621
|
randomAccountAsId: randomSeed.publicKey.toBase58(),
|
|
2614
2622
|
feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF"
|
|
2615
|
-
}).
|
|
2623
|
+
}).remainingAccounts(partnerFeeRecipient && partnerFeeMarkupAsPkey ? [{
|
|
2624
|
+
pubkey: partnerFeeRecipient,
|
|
2625
|
+
isSigner: false,
|
|
2626
|
+
isWritable: true
|
|
2627
|
+
}, {
|
|
2628
|
+
pubkey: partnerFeeMarkupAsPkey,
|
|
2629
|
+
isSigner: false,
|
|
2630
|
+
isWritable: false
|
|
2631
|
+
}] : []).instruction();
|
|
2616
2632
|
const openAddCollateralInstruction = yield lavarageProgram.methods.tradingOpenAddCollateral(offer.account.interestRate).accountsStrict({
|
|
2617
2633
|
tradingPool: offer.publicKey,
|
|
2618
2634
|
trader: lavarageProgram.provider.publicKey,
|
|
@@ -2641,7 +2657,15 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
2641
2657
|
const tx = new import_web3.VersionedTransaction(messageV0);
|
|
2642
2658
|
return tx;
|
|
2643
2659
|
});
|
|
2644
|
-
var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, partnerFeeRecipient) => __async(void 0, null, function* () {
|
|
2660
|
+
var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
|
|
2661
|
+
let partnerFeeMarkupAsPkey;
|
|
2662
|
+
if (partnerFeeMarkup) {
|
|
2663
|
+
const feeBuffer = Buffer.alloc(8);
|
|
2664
|
+
feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
|
|
2665
|
+
const feeBuffer32 = Buffer.alloc(32);
|
|
2666
|
+
feeBuffer32.set(feeBuffer, 0);
|
|
2667
|
+
partnerFeeMarkupAsPkey = new import_web3.PublicKey(feeBuffer32);
|
|
2668
|
+
}
|
|
2645
2669
|
const positionAccount = getPositionAccountPDA(lavarageProgram, offer, randomSeed.publicKey);
|
|
2646
2670
|
const mintAccount = yield lavarageProgram.provider.connection.getAccountInfo(offer.account.collateralType);
|
|
2647
2671
|
const tokenProgram = mintAccount == null ? void 0 : mintAccount.owner;
|
|
@@ -2684,7 +2708,7 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
2684
2708
|
}, new Array());
|
|
2685
2709
|
});
|
|
2686
2710
|
const addressLookupTableAccounts = [];
|
|
2687
|
-
addressLookupTableAccounts.push(...yield getAddressLookupTableAccounts(addressLookupTableAddresses));
|
|
2711
|
+
addressLookupTableAccounts.push(...yield getAddressLookupTableAccounts([...addressLookupTableAddresses, getQuoteCurrencySpecificAddressLookupTable(quoteToken.toBase58()), "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi"]));
|
|
2688
2712
|
const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
2689
2713
|
const tradingOpenBorrowInstruction = yield lavarageProgram.methods.tradingOpenBorrow(new import_anchor.BN((marginSOL.toNumber() * leverage).toFixed(0)), marginSOL).accountsStrict({
|
|
2690
2714
|
nodeWallet: offer.account.nodeWallet,
|
|
@@ -2699,7 +2723,15 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
2699
2723
|
toTokenAccount: (0, import_spl_token.getAssociatedTokenAddressSync)(quoteToken, lavarageProgram.provider.publicKey, true, quoteTokenProgram),
|
|
2700
2724
|
tokenProgram,
|
|
2701
2725
|
fromTokenAccount: (0, import_spl_token.getAssociatedTokenAddressSync)(quoteToken, offer.account.nodeWallet, true, tokenProgram)
|
|
2702
|
-
}).
|
|
2726
|
+
}).remainingAccounts(partnerFeeRecipient && partnerFeeMarkupAsPkey ? [{
|
|
2727
|
+
pubkey: partnerFeeRecipient,
|
|
2728
|
+
isSigner: false,
|
|
2729
|
+
isWritable: true
|
|
2730
|
+
}, {
|
|
2731
|
+
pubkey: partnerFeeMarkupAsPkey,
|
|
2732
|
+
isSigner: false,
|
|
2733
|
+
isWritable: false
|
|
2734
|
+
}] : []).instruction();
|
|
2703
2735
|
const openAddCollateralInstruction = yield lavarageProgram.methods.tradingOpenAddCollateral(offer.account.interestRate).accountsStrict({
|
|
2704
2736
|
tradingPool: offer.publicKey,
|
|
2705
2737
|
trader: lavarageProgram.provider.publicKey,
|
|
@@ -2854,7 +2886,15 @@ var partialRepayV2 = (lavarageProgram, position, repaymentBps) => __async(void 0
|
|
|
2854
2886
|
}).compileToV0Message();
|
|
2855
2887
|
return new import_web3.VersionedTransaction(messageV0);
|
|
2856
2888
|
});
|
|
2857
|
-
var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient,
|
|
2889
|
+
var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
|
|
2890
|
+
let partnerFeeMarkupAsPkey;
|
|
2891
|
+
if (partnerFeeMarkup) {
|
|
2892
|
+
const feeBuffer = Buffer.alloc(8);
|
|
2893
|
+
feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
|
|
2894
|
+
const feeBuffer32 = Buffer.alloc(32);
|
|
2895
|
+
feeBuffer32.set(feeBuffer, 0);
|
|
2896
|
+
partnerFeeMarkupAsPkey = new import_web3.PublicKey(feeBuffer32);
|
|
2897
|
+
}
|
|
2858
2898
|
if (position.account.pool.toBase58() != offer.publicKey.toBase58()) throw "Mismatch offer";
|
|
2859
2899
|
const pool = offer;
|
|
2860
2900
|
const poolPubKey = offer.publicKey;
|
|
@@ -2917,7 +2957,15 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
2917
2957
|
clock: import_web3.SYSVAR_CLOCK_PUBKEY,
|
|
2918
2958
|
randomAccountAsId: position.account.seed,
|
|
2919
2959
|
feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF"
|
|
2920
|
-
}).
|
|
2960
|
+
}).remainingAccounts(partnerFeeRecipient && partnerFeeMarkupAsPkey ? [{
|
|
2961
|
+
pubkey: partnerFeeRecipient,
|
|
2962
|
+
isSigner: false,
|
|
2963
|
+
isWritable: true
|
|
2964
|
+
}, {
|
|
2965
|
+
pubkey: partnerFeeMarkupAsPkey,
|
|
2966
|
+
isSigner: false,
|
|
2967
|
+
isWritable: false
|
|
2968
|
+
}] : []).instruction();
|
|
2921
2969
|
} else {
|
|
2922
2970
|
repaySolIx = yield lavarageProgram.methods.tradingCloseRepaySol(new import_anchor.BN(jupInstruction.quoteResponse.outAmount), new import_anchor.BN(9998)).accountsStrict({
|
|
2923
2971
|
nodeWallet: pool.account.nodeWallet,
|
|
@@ -2928,28 +2976,29 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
2928
2976
|
clock: import_web3.SYSVAR_CLOCK_PUBKEY,
|
|
2929
2977
|
randomAccountAsId: position.account.seed,
|
|
2930
2978
|
feeReceipient: "6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF"
|
|
2931
|
-
}).
|
|
2979
|
+
}).remainingAccounts(partnerFeeRecipient && partnerFeeMarkupAsPkey ? [{
|
|
2980
|
+
pubkey: partnerFeeRecipient,
|
|
2981
|
+
isSigner: false,
|
|
2982
|
+
isWritable: true
|
|
2983
|
+
}, {
|
|
2984
|
+
pubkey: partnerFeeMarkupAsPkey,
|
|
2985
|
+
isSigner: false,
|
|
2986
|
+
isWritable: false
|
|
2987
|
+
}] : []).instruction();
|
|
2932
2988
|
const { setupInstructions, swapInstruction: swapInstructionPayload, cleanupInstruction, addressLookupTableAddresses } = jupiterSellIx;
|
|
2933
2989
|
jupiterIxs = [
|
|
2934
2990
|
...setupInstructions.map(deserializeInstruction),
|
|
2935
2991
|
deserializeInstruction(swapInstructionPayload),
|
|
2936
2992
|
deserializeInstruction(cleanupInstruction)
|
|
2937
2993
|
];
|
|
2938
|
-
addressLookupTableAccounts.push(...yield getAddressLookupTableAccounts(addressLookupTableAddresses));
|
|
2994
|
+
addressLookupTableAccounts.push(...yield getAddressLookupTableAccounts(["5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi", ...addressLookupTableAddresses]));
|
|
2939
2995
|
}
|
|
2940
2996
|
const profit = new import_anchor.BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
|
|
2941
2997
|
const allInstructions = [
|
|
2942
2998
|
toTokenAccount.instruction,
|
|
2943
2999
|
closePositionIx,
|
|
2944
3000
|
...jupiterIxs,
|
|
2945
|
-
repaySolIx
|
|
2946
|
-
profitFeeMarkup && partnerFeeRecipient ? import_web3.SystemProgram.transfer(
|
|
2947
|
-
{
|
|
2948
|
-
fromPubkey: lavarageProgram.provider.publicKey,
|
|
2949
|
-
toPubkey: partnerFeeRecipient,
|
|
2950
|
-
lamports: profit.toNumber() > 0 ? profit.mul(new import_anchor.BN(profitFeeMarkup * 1e4)).div(new import_anchor.BN(1e4)).toNumber() : 0
|
|
2951
|
-
}
|
|
2952
|
-
) : null
|
|
3001
|
+
repaySolIx
|
|
2953
3002
|
].filter((i) => !!i);
|
|
2954
3003
|
const messageV0 = new import_web3.TransactionMessage({
|
|
2955
3004
|
payerKey: lavarageProgram.provider.publicKey,
|
|
@@ -2959,7 +3008,15 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
2959
3008
|
const tx = new import_web3.VersionedTransaction(messageV0);
|
|
2960
3009
|
return tx;
|
|
2961
3010
|
});
|
|
2962
|
-
var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken, partnerFeeRecipient,
|
|
3011
|
+
var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
|
|
3012
|
+
let partnerFeeMarkupAsPkey;
|
|
3013
|
+
if (partnerFeeMarkup) {
|
|
3014
|
+
const feeBuffer = Buffer.alloc(8);
|
|
3015
|
+
feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
|
|
3016
|
+
const feeBuffer32 = Buffer.alloc(32);
|
|
3017
|
+
feeBuffer32.set(feeBuffer, 0);
|
|
3018
|
+
partnerFeeMarkupAsPkey = new import_web3.PublicKey(feeBuffer32);
|
|
3019
|
+
}
|
|
2963
3020
|
if (position.account.pool.toBase58() != offer.publicKey.toBase58()) throw "Mismatch offer";
|
|
2964
3021
|
const pool = offer;
|
|
2965
3022
|
const poolPubKey = offer.publicKey;
|
|
@@ -3028,7 +3085,15 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
|
|
|
3028
3085
|
tokenProgram: quoteTokenProgram,
|
|
3029
3086
|
toTokenAccount: (0, import_spl_token.getAssociatedTokenAddressSync)(quoteToken, pool.account.nodeWallet, true, quoteTokenProgram),
|
|
3030
3087
|
mint: quoteToken
|
|
3031
|
-
}).
|
|
3088
|
+
}).remainingAccounts(partnerFeeRecipient && partnerFeeMarkupAsPkey ? [{
|
|
3089
|
+
pubkey: partnerFeeRecipient,
|
|
3090
|
+
isSigner: false,
|
|
3091
|
+
isWritable: true
|
|
3092
|
+
}, {
|
|
3093
|
+
pubkey: partnerFeeMarkupAsPkey,
|
|
3094
|
+
isSigner: false,
|
|
3095
|
+
isWritable: false
|
|
3096
|
+
}] : []).instruction();
|
|
3032
3097
|
} else {
|
|
3033
3098
|
repaySolIx = yield lavarageProgram.methods.tradingCloseRepaySol(new import_anchor.BN(jupInstruction.quoteResponse.outAmount), new import_anchor.BN(9998)).accountsStrict({
|
|
3034
3099
|
nodeWallet: pool.account.nodeWallet,
|
|
@@ -3043,29 +3108,29 @@ var closeTradeV2 = (lavarageProgram, position, offer, jupInstruction, quoteToken
|
|
|
3043
3108
|
tokenProgram: quoteTokenProgram,
|
|
3044
3109
|
toTokenAccount: (0, import_spl_token.getAssociatedTokenAddressSync)(quoteToken, pool.account.nodeWallet, true, quoteTokenProgram),
|
|
3045
3110
|
mint: quoteToken
|
|
3046
|
-
}).
|
|
3111
|
+
}).remainingAccounts(partnerFeeRecipient && partnerFeeMarkupAsPkey ? [{
|
|
3112
|
+
pubkey: partnerFeeRecipient,
|
|
3113
|
+
isSigner: false,
|
|
3114
|
+
isWritable: true
|
|
3115
|
+
}, {
|
|
3116
|
+
pubkey: partnerFeeMarkupAsPkey,
|
|
3117
|
+
isSigner: false,
|
|
3118
|
+
isWritable: false
|
|
3119
|
+
}] : []).instruction();
|
|
3047
3120
|
const { setupInstructions, swapInstruction: swapInstructionPayload, cleanupInstruction, addressLookupTableAddresses } = jupiterSellIx;
|
|
3048
3121
|
jupiterIxs = [
|
|
3049
3122
|
...setupInstructions.filter((i) => !!i).map(deserializeInstruction),
|
|
3050
3123
|
swapInstructionPayload ? deserializeInstruction(swapInstructionPayload) : null,
|
|
3051
3124
|
cleanupInstruction ? deserializeInstruction(cleanupInstruction) : null
|
|
3052
3125
|
].filter((i) => !!i);
|
|
3053
|
-
addressLookupTableAccounts.push(...yield getAddressLookupTableAccounts(addressLookupTableAddresses));
|
|
3126
|
+
addressLookupTableAccounts.push(...yield getAddressLookupTableAccounts([...addressLookupTableAddresses, getQuoteCurrencySpecificAddressLookupTable(quoteToken.toBase58()), "5LEAB3owNUSKvECm7vkr58tDtQpzbngQ2NYpc7qmRFdi"]));
|
|
3054
3127
|
}
|
|
3055
3128
|
const profit = new import_anchor.BN(jupInstruction.quoteResponse.outAmount).sub(position.account.amount).sub(position.account.userPaid);
|
|
3056
3129
|
const allInstructions = [
|
|
3057
3130
|
toTokenAccount.instruction,
|
|
3058
3131
|
closePositionIx,
|
|
3059
3132
|
...jupiterIxs,
|
|
3060
|
-
repaySolIx
|
|
3061
|
-
profitFeeMarkup && partnerFeeRecipient ? (0, import_spl_token.createTransferInstruction)(
|
|
3062
|
-
(0, import_spl_token.getAssociatedTokenAddressSync)(quoteToken, lavarageProgram.provider.publicKey, false, quoteTokenProgram),
|
|
3063
|
-
partnerFeeRecipient,
|
|
3064
|
-
lavarageProgram.provider.publicKey,
|
|
3065
|
-
profit.toNumber() > 0 ? profit.mul(new import_anchor.BN(profitFeeMarkup * 1e3)).div(new import_anchor.BN(1e3)).toNumber() : 0,
|
|
3066
|
-
[],
|
|
3067
|
-
quoteTokenProgram
|
|
3068
|
-
) : null
|
|
3133
|
+
repaySolIx
|
|
3069
3134
|
].filter((i) => !!i);
|
|
3070
3135
|
const messageV0 = new import_web3.TransactionMessage({
|
|
3071
3136
|
payerKey: lavarageProgram.provider.publicKey,
|
|
@@ -3089,6 +3154,16 @@ var getDelegateAccounts = (lavarageProgram, userPubKey) => __async(void 0, null,
|
|
|
3089
3154
|
}
|
|
3090
3155
|
}));
|
|
3091
3156
|
});
|
|
3157
|
+
var getQuoteCurrencySpecificAddressLookupTable = (quoteCurrency) => {
|
|
3158
|
+
switch (quoteCurrency) {
|
|
3159
|
+
case "J9BcrQfX4p9D1bvLzRNCbMDv8f44a9LFdeqNE4Yk2WMD":
|
|
3160
|
+
return "2EdNtwVhyjkEgkKDC7GShfSSczZYMKLuJraeoJzG4E4R";
|
|
3161
|
+
case "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v":
|
|
3162
|
+
return "CxLE1LRaZg2eYygzFfVRhgmSACsvqzyhySDrMHq3QSab";
|
|
3163
|
+
default:
|
|
3164
|
+
return "2EdNtwVhyjkEgkKDC7GShfSSczZYMKLuJraeoJzG4E4R";
|
|
3165
|
+
}
|
|
3166
|
+
};
|
|
3092
3167
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3093
3168
|
0 && (module.exports = {
|
|
3094
3169
|
IDL,
|