@lavarage/sdk 7.5.5 → 7.5.6
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 +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +31 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -13
- package/dist/index.mjs.map +1 -1
- package/index.ts +38 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Program, ProgramAccount, BN } from '@coral-xyz/anchor';
|
|
2
|
-
import { PublicKey, VersionedTransaction, Keypair } from '@solana/web3.js';
|
|
2
|
+
import { PublicKey, VersionedTransaction, Keypair, AccountInfo } from '@solana/web3.js';
|
|
3
3
|
import { Provider, BigNumberish, ContractTransaction } from 'ethers';
|
|
4
4
|
|
|
5
5
|
type Lavarage$1 = {
|
|
@@ -3771,6 +3771,12 @@ declare namespace lending {
|
|
|
3771
3771
|
export { lending_addToWithdrawalAccessList as addToWithdrawalAccessList, lending_createOffer as createOffer, lending_depositFunds as depositFunds, lending_getNodeWalletPDA as getNodeWalletPDA, lending_getTradingPoolPDA as getTradingPoolPDA, lending_getWithdrawalAccessList as getWithdrawalAccessList, lending_getWithdrawalAccessListPDA as getWithdrawalAccessListPDA, lending_removeFromWithdrawalAccessList as removeFromWithdrawalAccessList, lending_updateInterestRate as updateInterestRate, lending_updateMaxBorrow as updateMaxBorrow, lending_updateMaxExposure as updateMaxExposure, lending_updateOffer as updateOffer, lending_withdrawFunds as withdrawFunds, lending_withdrawFundsV1 as withdrawFundsV1, lending_withdrawFundsV2 as withdrawFundsV2 };
|
|
3772
3772
|
}
|
|
3773
3773
|
|
|
3774
|
+
type OptionalRPCResults = {
|
|
3775
|
+
addressLookupTableAccounts?: AccountInfo<Buffer>[];
|
|
3776
|
+
latestBlockhash?: string;
|
|
3777
|
+
tokenAccountConfirmCreatedAddresses?: PublicKey[];
|
|
3778
|
+
quoteMintAccountInfo?: AccountInfo<Buffer>;
|
|
3779
|
+
};
|
|
3774
3780
|
declare function getPda(seed: Buffer | Buffer[], programId: PublicKey): PublicKey;
|
|
3775
3781
|
declare function getPositionAccountPDA(lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, offer: ProgramAccount, seed: PublicKey): PublicKey;
|
|
3776
3782
|
|
|
@@ -3858,7 +3864,7 @@ declare const openTradeV1: (lavarageProgram: Program<Lavarage$1>, offer: Program
|
|
|
3858
3864
|
swapInstruction: Record<string, unknown>;
|
|
3859
3865
|
addressLookupTableAddresses: string[];
|
|
3860
3866
|
};
|
|
3861
|
-
}, marginSOL: BN, leverage: number, randomSeed: Keypair, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean, discountBps?: number, referralBps?: number) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
3867
|
+
}, marginSOL: BN, leverage: number, randomSeed: Keypair, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean, discountBps?: number, referralBps?: number, optionalRPCResults?: OptionalRPCResults) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
3862
3868
|
declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAccount<{
|
|
3863
3869
|
nodeWallet: PublicKey;
|
|
3864
3870
|
interestRate: number;
|
|
@@ -3869,7 +3875,7 @@ declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAc
|
|
|
3869
3875
|
swapInstruction: Record<string, unknown>;
|
|
3870
3876
|
addressLookupTableAddresses: string[];
|
|
3871
3877
|
};
|
|
3872
|
-
}, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean, discountBps?: number, referralBps?: number) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
3878
|
+
}, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean, discountBps?: number, referralBps?: number, optionalRPCResults?: OptionalRPCResults) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
3873
3879
|
declare const createTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
|
|
3874
3880
|
pool: PublicKey;
|
|
3875
3881
|
seed: PublicKey;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Program, ProgramAccount, BN } from '@coral-xyz/anchor';
|
|
2
|
-
import { PublicKey, VersionedTransaction, Keypair } from '@solana/web3.js';
|
|
2
|
+
import { PublicKey, VersionedTransaction, Keypair, AccountInfo } from '@solana/web3.js';
|
|
3
3
|
import { Provider, BigNumberish, ContractTransaction } from 'ethers';
|
|
4
4
|
|
|
5
5
|
type Lavarage$1 = {
|
|
@@ -3771,6 +3771,12 @@ declare namespace lending {
|
|
|
3771
3771
|
export { lending_addToWithdrawalAccessList as addToWithdrawalAccessList, lending_createOffer as createOffer, lending_depositFunds as depositFunds, lending_getNodeWalletPDA as getNodeWalletPDA, lending_getTradingPoolPDA as getTradingPoolPDA, lending_getWithdrawalAccessList as getWithdrawalAccessList, lending_getWithdrawalAccessListPDA as getWithdrawalAccessListPDA, lending_removeFromWithdrawalAccessList as removeFromWithdrawalAccessList, lending_updateInterestRate as updateInterestRate, lending_updateMaxBorrow as updateMaxBorrow, lending_updateMaxExposure as updateMaxExposure, lending_updateOffer as updateOffer, lending_withdrawFunds as withdrawFunds, lending_withdrawFundsV1 as withdrawFundsV1, lending_withdrawFundsV2 as withdrawFundsV2 };
|
|
3772
3772
|
}
|
|
3773
3773
|
|
|
3774
|
+
type OptionalRPCResults = {
|
|
3775
|
+
addressLookupTableAccounts?: AccountInfo<Buffer>[];
|
|
3776
|
+
latestBlockhash?: string;
|
|
3777
|
+
tokenAccountConfirmCreatedAddresses?: PublicKey[];
|
|
3778
|
+
quoteMintAccountInfo?: AccountInfo<Buffer>;
|
|
3779
|
+
};
|
|
3774
3780
|
declare function getPda(seed: Buffer | Buffer[], programId: PublicKey): PublicKey;
|
|
3775
3781
|
declare function getPositionAccountPDA(lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, offer: ProgramAccount, seed: PublicKey): PublicKey;
|
|
3776
3782
|
|
|
@@ -3858,7 +3864,7 @@ declare const openTradeV1: (lavarageProgram: Program<Lavarage$1>, offer: Program
|
|
|
3858
3864
|
swapInstruction: Record<string, unknown>;
|
|
3859
3865
|
addressLookupTableAddresses: string[];
|
|
3860
3866
|
};
|
|
3861
|
-
}, marginSOL: BN, leverage: number, randomSeed: Keypair, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean, discountBps?: number, referralBps?: number) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
3867
|
+
}, marginSOL: BN, leverage: number, randomSeed: Keypair, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean, discountBps?: number, referralBps?: number, optionalRPCResults?: OptionalRPCResults) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
3862
3868
|
declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAccount<{
|
|
3863
3869
|
nodeWallet: PublicKey;
|
|
3864
3870
|
interestRate: number;
|
|
@@ -3869,7 +3875,7 @@ declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAc
|
|
|
3869
3875
|
swapInstruction: Record<string, unknown>;
|
|
3870
3876
|
addressLookupTableAddresses: string[];
|
|
3871
3877
|
};
|
|
3872
|
-
}, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean, discountBps?: number, referralBps?: number) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
3878
|
+
}, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, platformFeeRecipient?: PublicKey, splitTransactions?: boolean, discountBps?: number, referralBps?: number, optionalRPCResults?: OptionalRPCResults) => Promise<VersionedTransaction | VersionedTransaction[]>;
|
|
3873
3879
|
declare const createTpDelegate: (lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, position: ProgramAccount<{
|
|
3874
3880
|
pool: PublicKey;
|
|
3875
3881
|
seed: PublicKey;
|
package/dist/index.js
CHANGED
|
@@ -5041,7 +5041,7 @@ function getPositionAccountPDA(lavarageProgram, offer, seed) {
|
|
|
5041
5041
|
lavarageProgram.programId
|
|
5042
5042
|
);
|
|
5043
5043
|
}
|
|
5044
|
-
function getTokenAccountOrCreateIfNotExists(lavarageProgram, ownerPublicKey, tokenAddress, tokenProgram) {
|
|
5044
|
+
function getTokenAccountOrCreateIfNotExists(lavarageProgram, ownerPublicKey, tokenAddress, tokenProgram, confirmCreatedAddresses) {
|
|
5045
5045
|
return __async(this, null, function* () {
|
|
5046
5046
|
const associatedTokenAddress = (0, import_spl_token2.getAssociatedTokenAddressSync)(
|
|
5047
5047
|
tokenAddress,
|
|
@@ -5050,6 +5050,14 @@ function getTokenAccountOrCreateIfNotExists(lavarageProgram, ownerPublicKey, tok
|
|
|
5050
5050
|
tokenProgram,
|
|
5051
5051
|
import_spl_token2.ASSOCIATED_TOKEN_PROGRAM_ID
|
|
5052
5052
|
);
|
|
5053
|
+
if (confirmCreatedAddresses == null ? void 0 : confirmCreatedAddresses.includes(associatedTokenAddress)) {
|
|
5054
|
+
return {
|
|
5055
|
+
account: {
|
|
5056
|
+
address: associatedTokenAddress
|
|
5057
|
+
},
|
|
5058
|
+
instruction: void 0
|
|
5059
|
+
};
|
|
5060
|
+
}
|
|
5053
5061
|
const instruction = (0, import_spl_token2.createAssociatedTokenAccountIdempotentInstruction)(
|
|
5054
5062
|
lavarageProgram.provider.publicKey,
|
|
5055
5063
|
associatedTokenAddress,
|
|
@@ -5455,7 +5463,8 @@ var borrowV2 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, quoteTo
|
|
|
5455
5463
|
const tx = new import_web32.VersionedTransaction(messageV0);
|
|
5456
5464
|
return tx;
|
|
5457
5465
|
});
|
|
5458
|
-
var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps) => __async(void 0, null, function* () {
|
|
5466
|
+
var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps, optionalRPCResults) => __async(void 0, null, function* () {
|
|
5467
|
+
var _a;
|
|
5459
5468
|
let partnerFeeMarkupAsPkey;
|
|
5460
5469
|
const referralVaultProgram = new import_anchor2.Program(IDL, REFFERAL_VAULT_PROGRAM_ID, lavarageProgram.provider);
|
|
5461
5470
|
if (partnerFeeMarkup) {
|
|
@@ -5474,19 +5483,22 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
5474
5483
|
lavarageProgram,
|
|
5475
5484
|
lavarageProgram.provider.publicKey,
|
|
5476
5485
|
offer.account.collateralType,
|
|
5477
|
-
tokenProgram
|
|
5486
|
+
tokenProgram,
|
|
5487
|
+
optionalRPCResults == null ? void 0 : optionalRPCResults.tokenAccountConfirmCreatedAddresses
|
|
5478
5488
|
);
|
|
5479
5489
|
const toTokenAccount = yield getTokenAccountOrCreateIfNotExists(
|
|
5480
5490
|
lavarageProgram,
|
|
5481
5491
|
positionAccount,
|
|
5482
5492
|
offer.account.collateralType,
|
|
5483
|
-
tokenProgram
|
|
5493
|
+
tokenProgram,
|
|
5494
|
+
optionalRPCResults == null ? void 0 : optionalRPCResults.tokenAccountConfirmCreatedAddresses
|
|
5484
5495
|
);
|
|
5485
5496
|
const platformFeeRecipientAccount = platformFeeRecipient ? yield getTokenAccountOrCreateIfNotExists(
|
|
5486
5497
|
lavarageProgram,
|
|
5487
5498
|
platformFeeRecipient,
|
|
5488
5499
|
offer.account.collateralType,
|
|
5489
|
-
tokenProgram
|
|
5500
|
+
tokenProgram,
|
|
5501
|
+
optionalRPCResults == null ? void 0 : optionalRPCResults.tokenAccountConfirmCreatedAddresses
|
|
5490
5502
|
) : void 0;
|
|
5491
5503
|
const tokenAccountCreationTx = new import_web32.Transaction();
|
|
5492
5504
|
if (fromTokenAccount.instruction) {
|
|
@@ -5516,7 +5528,8 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
5516
5528
|
});
|
|
5517
5529
|
};
|
|
5518
5530
|
const getAddressLookupTableAccounts = (keys) => __async(void 0, null, function* () {
|
|
5519
|
-
|
|
5531
|
+
var _a2;
|
|
5532
|
+
const addressLookupTableAccountInfos = (_a2 = optionalRPCResults == null ? void 0 : optionalRPCResults.addressLookupTableAccounts) != null ? _a2 : yield lavarageProgram.provider.connection.getMultipleAccountsInfo(
|
|
5520
5533
|
keys.map((key) => new import_web32.PublicKey(key))
|
|
5521
5534
|
);
|
|
5522
5535
|
return addressLookupTableAccountInfos.reduce((acc, accountInfo, index) => {
|
|
@@ -5540,7 +5553,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
5540
5553
|
...addressLookupTableAddresses
|
|
5541
5554
|
])
|
|
5542
5555
|
);
|
|
5543
|
-
const
|
|
5556
|
+
const blockhash = (_a = optionalRPCResults == null ? void 0 : optionalRPCResults.latestBlockhash) != null ? _a : (yield lavarageProgram.provider.connection.getLatestBlockhash("finalized")).blockhash;
|
|
5544
5557
|
const useReferral = discountBps !== void 0 && referralBps !== void 0;
|
|
5545
5558
|
let partnerFeeRecipientCreateIx;
|
|
5546
5559
|
let userVaultPda;
|
|
@@ -5670,7 +5683,8 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
5670
5683
|
const tx = new import_web32.VersionedTransaction(messageV0);
|
|
5671
5684
|
return tx;
|
|
5672
5685
|
});
|
|
5673
|
-
var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps) => __async(void 0, null, function* () {
|
|
5686
|
+
var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps, optionalRPCResults) => __async(void 0, null, function* () {
|
|
5687
|
+
var _a;
|
|
5674
5688
|
let partnerFeeMarkupAsPkey;
|
|
5675
5689
|
const referralVaultProgram = new import_anchor2.Program(IDL, REFFERAL_VAULT_PROGRAM_ID, lavarageProgram.provider);
|
|
5676
5690
|
if (partnerFeeMarkup) {
|
|
@@ -5685,25 +5699,28 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
5685
5699
|
offer,
|
|
5686
5700
|
randomSeed.publicKey
|
|
5687
5701
|
);
|
|
5688
|
-
const quoteMintAccount = yield lavarageProgram.provider.connection.getAccountInfo(quoteToken);
|
|
5702
|
+
const quoteMintAccount = (_a = optionalRPCResults == null ? void 0 : optionalRPCResults.quoteMintAccountInfo) != null ? _a : yield lavarageProgram.provider.connection.getAccountInfo(quoteToken);
|
|
5689
5703
|
const quoteTokenProgram = quoteMintAccount == null ? void 0 : quoteMintAccount.owner;
|
|
5690
5704
|
const fromTokenAccount = yield getTokenAccountOrCreateIfNotExists(
|
|
5691
5705
|
lavarageProgram,
|
|
5692
5706
|
lavarageProgram.provider.publicKey,
|
|
5693
5707
|
offer.account.collateralType,
|
|
5694
|
-
tokenProgram
|
|
5708
|
+
tokenProgram,
|
|
5709
|
+
optionalRPCResults == null ? void 0 : optionalRPCResults.tokenAccountConfirmCreatedAddresses
|
|
5695
5710
|
);
|
|
5696
5711
|
const toTokenAccount = yield getTokenAccountOrCreateIfNotExists(
|
|
5697
5712
|
lavarageProgram,
|
|
5698
5713
|
positionAccount,
|
|
5699
5714
|
offer.account.collateralType,
|
|
5700
|
-
tokenProgram
|
|
5715
|
+
tokenProgram,
|
|
5716
|
+
optionalRPCResults == null ? void 0 : optionalRPCResults.tokenAccountConfirmCreatedAddresses
|
|
5701
5717
|
);
|
|
5702
5718
|
const platformFeeRecipientAccount = platformFeeRecipient ? yield getTokenAccountOrCreateIfNotExists(
|
|
5703
5719
|
lavarageProgram,
|
|
5704
5720
|
platformFeeRecipient,
|
|
5705
5721
|
offer.account.collateralType,
|
|
5706
|
-
tokenProgram
|
|
5722
|
+
tokenProgram,
|
|
5723
|
+
optionalRPCResults == null ? void 0 : optionalRPCResults.tokenAccountConfirmCreatedAddresses
|
|
5707
5724
|
) : void 0;
|
|
5708
5725
|
const tokenAccountCreationTx = new import_web32.Transaction();
|
|
5709
5726
|
if (fromTokenAccount.instruction) {
|
|
@@ -5733,7 +5750,8 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
5733
5750
|
});
|
|
5734
5751
|
};
|
|
5735
5752
|
const getAddressLookupTableAccounts = (keys) => __async(void 0, null, function* () {
|
|
5736
|
-
|
|
5753
|
+
var _a2;
|
|
5754
|
+
const addressLookupTableAccountInfos = (_a2 = optionalRPCResults == null ? void 0 : optionalRPCResults.addressLookupTableAccounts) != null ? _a2 : yield lavarageProgram.provider.connection.getMultipleAccountsInfo(
|
|
5737
5755
|
keys.map((key) => new import_web32.PublicKey(key))
|
|
5738
5756
|
);
|
|
5739
5757
|
return addressLookupTableAccountInfos.reduce((acc, accountInfo, index) => {
|