@lavarage/sdk 4.5.2 → 5.0.1
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 +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +100 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -3
- package/dist/index.mjs.map +1 -1
- package/index.ts +123 -2
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
27
27
|
// index.ts
|
|
28
28
|
import { BN } from "@coral-xyz/anchor";
|
|
29
29
|
import bs58 from "bs58";
|
|
30
|
-
import { AddressLookupTableAccount, PublicKey, SystemProgram, SYSVAR_CLOCK_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, Transaction, TransactionInstruction, TransactionMessage, VersionedTransaction } from "@solana/web3.js";
|
|
30
|
+
import { AddressLookupTableAccount, ComputeBudgetProgram, PublicKey, SystemProgram, SYSVAR_CLOCK_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, Transaction, TransactionInstruction, TransactionMessage, VersionedTransaction } from "@solana/web3.js";
|
|
31
31
|
import { ASSOCIATED_TOKEN_PROGRAM_ID, createAssociatedTokenAccountInstruction, getAccount, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, TokenAccountNotFoundError, TokenInvalidAccountOwnerError } from "@solana/spl-token";
|
|
32
32
|
|
|
33
33
|
// idl/lavarage.ts
|
|
@@ -2682,6 +2682,9 @@ var getClosedPositions = (lavarageProgram) => __async(void 0, null, function* ()
|
|
|
2682
2682
|
const value2 = BigInt(9998);
|
|
2683
2683
|
const valueBuffer2 = Buffer.alloc(8);
|
|
2684
2684
|
valueBuffer2.writeBigUInt64LE(value2);
|
|
2685
|
+
const value3 = BigInt(9996);
|
|
2686
|
+
const valueBuffer3 = Buffer.alloc(8);
|
|
2687
|
+
valueBuffer3.writeBigUInt64LE(value3);
|
|
2685
2688
|
return (yield lavarageProgram.account.position.all([
|
|
2686
2689
|
{ dataSize: 178 },
|
|
2687
2690
|
{
|
|
@@ -2698,6 +2701,14 @@ var getClosedPositions = (lavarageProgram) => __async(void 0, null, function* ()
|
|
|
2698
2701
|
bytes: bs58.encode(Uint8Array.from(valueBuffer2))
|
|
2699
2702
|
}
|
|
2700
2703
|
}
|
|
2704
|
+
])).concat(yield lavarageProgram.account.position.all([
|
|
2705
|
+
{ dataSize: 178 },
|
|
2706
|
+
{
|
|
2707
|
+
memcmp: {
|
|
2708
|
+
offset: 40,
|
|
2709
|
+
bytes: bs58.encode(Uint8Array.from(valueBuffer3))
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2701
2712
|
]));
|
|
2702
2713
|
});
|
|
2703
2714
|
var getLiquidatedPositions = (lavarageProgram) => {
|
|
@@ -2890,6 +2901,86 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
2890
2901
|
const tx = new VersionedTransaction(messageV0);
|
|
2891
2902
|
return tx;
|
|
2892
2903
|
});
|
|
2904
|
+
var createTpDelegate = (lavarageProgram, position, tpPrice, tpTolerence, prioFee, quoteToken, partnerFeeRecipient) => __async(void 0, null, function* () {
|
|
2905
|
+
const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
2906
|
+
const ix = yield lavarageProgram.methods.tradingCreateTpDelegate(tpPrice, tpTolerence, new PublicKey("6dA5GTDPWxnw3gvjoy3vYBDyY7iETxcTJzt8RqF9i9MV"), new BN(1e4)).accountsStrict({
|
|
2907
|
+
delegate: getPda([Buffer.from("delegate"), position.publicKey.toBuffer()], lavarageProgram.programId),
|
|
2908
|
+
originalOperator: lavarageProgram.provider.publicKey,
|
|
2909
|
+
delegatedAccount: position.publicKey,
|
|
2910
|
+
systemProgram: SystemProgram.programId
|
|
2911
|
+
}).remainingAccounts(partnerFeeRecipient ? [{
|
|
2912
|
+
pubkey: quoteToken.toBase58() == "So11111111111111111111111111111111111111112" ? partnerFeeRecipient : getAssociatedTokenAddressSync(quoteToken, partnerFeeRecipient, true),
|
|
2913
|
+
isSigner: false,
|
|
2914
|
+
isWritable: true
|
|
2915
|
+
}] : []).instruction();
|
|
2916
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
2917
|
+
microLamports: prioFee.toNumber()
|
|
2918
|
+
});
|
|
2919
|
+
const messageV0 = new TransactionMessage({
|
|
2920
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
2921
|
+
recentBlockhash: blockhash,
|
|
2922
|
+
instructions: [
|
|
2923
|
+
ix,
|
|
2924
|
+
computeFeeIx
|
|
2925
|
+
].filter(Boolean)
|
|
2926
|
+
}).compileToV0Message();
|
|
2927
|
+
return new VersionedTransaction(messageV0);
|
|
2928
|
+
});
|
|
2929
|
+
var modifyTpDelegate = (lavarageProgram, position, tpPrice, tpTolerence, prioFee, quoteToken, partnerFeeRecipient) => __async(void 0, null, function* () {
|
|
2930
|
+
const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
2931
|
+
const delegatePda = getPda([Buffer.from("delegate"), position.publicKey.toBuffer()], lavarageProgram.programId);
|
|
2932
|
+
const removeIx = yield lavarageProgram.methods.tradingRemoveTpDelegate().accountsStrict({
|
|
2933
|
+
delegate: delegatePda,
|
|
2934
|
+
originalOperator: lavarageProgram.provider.publicKey,
|
|
2935
|
+
delegatedAccount: position.publicKey,
|
|
2936
|
+
systemProgram: SystemProgram.programId
|
|
2937
|
+
}).instruction();
|
|
2938
|
+
const ix = yield lavarageProgram.methods.tradingCreateTpDelegate(tpPrice, tpTolerence, new PublicKey("6dA5GTDPWxnw3gvjoy3vYBDyY7iETxcTJzt8RqF9i9MV"), new BN(1e4)).accountsStrict({
|
|
2939
|
+
delegate: delegatePda,
|
|
2940
|
+
originalOperator: lavarageProgram.provider.publicKey,
|
|
2941
|
+
delegatedAccount: position.publicKey,
|
|
2942
|
+
systemProgram: SystemProgram.programId
|
|
2943
|
+
}).remainingAccounts(partnerFeeRecipient ? [{
|
|
2944
|
+
pubkey: quoteToken.toBase58() == "So11111111111111111111111111111111111111112" ? partnerFeeRecipient : getAssociatedTokenAddressSync(quoteToken, partnerFeeRecipient, true),
|
|
2945
|
+
isSigner: false,
|
|
2946
|
+
isWritable: true
|
|
2947
|
+
}] : []).instruction();
|
|
2948
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
2949
|
+
microLamports: prioFee.toNumber()
|
|
2950
|
+
});
|
|
2951
|
+
const messageV0 = new TransactionMessage({
|
|
2952
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
2953
|
+
recentBlockhash: blockhash,
|
|
2954
|
+
instructions: [
|
|
2955
|
+
removeIx,
|
|
2956
|
+
ix,
|
|
2957
|
+
computeFeeIx
|
|
2958
|
+
].filter(Boolean)
|
|
2959
|
+
}).compileToV0Message();
|
|
2960
|
+
return new VersionedTransaction(messageV0);
|
|
2961
|
+
});
|
|
2962
|
+
var removeTpDelegate = (lavarageProgram, position, prioFee) => __async(void 0, null, function* () {
|
|
2963
|
+
const { blockhash } = yield lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
2964
|
+
const delegatePda = getPda([Buffer.from("delegate"), position.publicKey.toBuffer()], lavarageProgram.programId);
|
|
2965
|
+
const removeIx = yield lavarageProgram.methods.tradingRemoveTpDelegate().accountsStrict({
|
|
2966
|
+
delegate: delegatePda,
|
|
2967
|
+
originalOperator: lavarageProgram.provider.publicKey,
|
|
2968
|
+
delegatedAccount: position.publicKey,
|
|
2969
|
+
systemProgram: SystemProgram.programId
|
|
2970
|
+
}).instruction();
|
|
2971
|
+
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
2972
|
+
microLamports: prioFee.toNumber()
|
|
2973
|
+
});
|
|
2974
|
+
const messageV0 = new TransactionMessage({
|
|
2975
|
+
payerKey: lavarageProgram.provider.publicKey,
|
|
2976
|
+
recentBlockhash: blockhash,
|
|
2977
|
+
instructions: [
|
|
2978
|
+
removeIx,
|
|
2979
|
+
computeFeeIx
|
|
2980
|
+
].filter(Boolean)
|
|
2981
|
+
}).compileToV0Message();
|
|
2982
|
+
return new VersionedTransaction(messageV0);
|
|
2983
|
+
});
|
|
2893
2984
|
var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFeeRecipient, profitFeeMarkup) => __async(void 0, null, function* () {
|
|
2894
2985
|
if (position.account.pool.toBase58() != offer.publicKey.toBase58()) throw "Mismatch offer";
|
|
2895
2986
|
const pool = offer;
|
|
@@ -2989,7 +3080,7 @@ var closeTradeV1 = (lavarageProgram, position, offer, jupInstruction, partnerFee
|
|
|
2989
3080
|
{
|
|
2990
3081
|
fromPubkey: lavarageProgram.provider.publicKey,
|
|
2991
3082
|
toPubkey: partnerFeeRecipient,
|
|
2992
|
-
lamports: profit.toNumber() > 0 ? profit.mul(new BN(profitFeeMarkup *
|
|
3083
|
+
lamports: profit.toNumber() > 0 ? profit.mul(new BN(profitFeeMarkup * 1e4)).div(new BN(1e4)).toNumber() : 0
|
|
2993
3084
|
}
|
|
2994
3085
|
) : null
|
|
2995
3086
|
].filter((i) => !!i);
|
|
@@ -3125,6 +3216,7 @@ export {
|
|
|
3125
3216
|
lavaragev2_exports as IDLV2,
|
|
3126
3217
|
closeTradeV1,
|
|
3127
3218
|
closeTradeV2,
|
|
3219
|
+
createTpDelegate,
|
|
3128
3220
|
getAllPositions,
|
|
3129
3221
|
getClosedPositions,
|
|
3130
3222
|
getLiquidatedPositions,
|
|
@@ -3132,7 +3224,9 @@ export {
|
|
|
3132
3224
|
getOpenPositions,
|
|
3133
3225
|
getPda,
|
|
3134
3226
|
getPositionAccountPDA,
|
|
3227
|
+
modifyTpDelegate,
|
|
3135
3228
|
openTradeV1,
|
|
3136
|
-
openTradeV2
|
|
3229
|
+
openTradeV2,
|
|
3230
|
+
removeTpDelegate
|
|
3137
3231
|
};
|
|
3138
3232
|
//# sourceMappingURL=index.mjs.map
|