@lavarage/sdk 8.0.10 → 8.0.12
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 +2 -6
- package/dist/index.d.ts +2 -6
- package/dist/index.js +3 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -66
- package/dist/index.mjs.map +1 -1
- package/idl/lavarageUSDC.json +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -7501,10 +7501,6 @@ type UserVault = {
|
|
|
7501
7501
|
];
|
|
7502
7502
|
};
|
|
7503
7503
|
|
|
7504
|
-
type ApiKeys = {
|
|
7505
|
-
birdeyeApiKey: string;
|
|
7506
|
-
};
|
|
7507
|
-
|
|
7508
7504
|
interface Collateral {
|
|
7509
7505
|
collateralAddress: string;
|
|
7510
7506
|
maxLendPerToken: bigint;
|
|
@@ -8794,7 +8790,7 @@ declare const borrowV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAccou
|
|
|
8794
8790
|
interestRate: number;
|
|
8795
8791
|
collateralType: PublicKey;
|
|
8796
8792
|
feedId: number[];
|
|
8797
|
-
}>, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey,
|
|
8793
|
+
}>, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, discountBps?: number, referralBps?: number, referralVaultProgram?: Program<UserVault>) => Promise<VersionedTransaction>;
|
|
8798
8794
|
/**
|
|
8799
8795
|
* Opens a leveraged trading position on Lavarage V1
|
|
8800
8796
|
*
|
|
@@ -8932,7 +8928,7 @@ declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAc
|
|
|
8932
8928
|
swapInstruction: Record<string, unknown>;
|
|
8933
8929
|
addressLookupTableAddresses: string[];
|
|
8934
8930
|
};
|
|
8935
|
-
}, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey,
|
|
8931
|
+
}, 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[]>;
|
|
8936
8932
|
/**
|
|
8937
8933
|
* Creates a take-profit delegate for automated position closing
|
|
8938
8934
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -7501,10 +7501,6 @@ type UserVault = {
|
|
|
7501
7501
|
];
|
|
7502
7502
|
};
|
|
7503
7503
|
|
|
7504
|
-
type ApiKeys = {
|
|
7505
|
-
birdeyeApiKey: string;
|
|
7506
|
-
};
|
|
7507
|
-
|
|
7508
7504
|
interface Collateral {
|
|
7509
7505
|
collateralAddress: string;
|
|
7510
7506
|
maxLendPerToken: bigint;
|
|
@@ -8794,7 +8790,7 @@ declare const borrowV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAccou
|
|
|
8794
8790
|
interestRate: number;
|
|
8795
8791
|
collateralType: PublicKey;
|
|
8796
8792
|
feedId: number[];
|
|
8797
|
-
}>, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey,
|
|
8793
|
+
}>, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey, partnerFeeRecipient?: PublicKey, partnerFeeMarkup?: number, computeBudgetMicroLamports?: number, discountBps?: number, referralBps?: number, referralVaultProgram?: Program<UserVault>) => Promise<VersionedTransaction>;
|
|
8798
8794
|
/**
|
|
8799
8795
|
* Opens a leveraged trading position on Lavarage V1
|
|
8800
8796
|
*
|
|
@@ -8932,7 +8928,7 @@ declare const openTradeV2: (lavarageProgram: Program<Lavarage>, offer: ProgramAc
|
|
|
8932
8928
|
swapInstruction: Record<string, unknown>;
|
|
8933
8929
|
addressLookupTableAddresses: string[];
|
|
8934
8930
|
};
|
|
8935
|
-
}, marginSOL: BN, leverage: number, randomSeed: Keypair, quoteToken: PublicKey, tokenProgram: PublicKey,
|
|
8931
|
+
}, 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[]>;
|
|
8936
8932
|
/**
|
|
8937
8933
|
* Creates a take-profit delegate for automated position closing
|
|
8938
8934
|
*
|
package/dist/index.js
CHANGED
|
@@ -361,7 +361,7 @@ var userVault_default = {
|
|
|
361
361
|
|
|
362
362
|
// idl/lavarageUSDC.json
|
|
363
363
|
var lavarageUSDC_default = {
|
|
364
|
-
address: "
|
|
364
|
+
address: "8AD6AnnkdD3MMqQE2v3V7HLaxocSr8kZb1uHNX19PnwF",
|
|
365
365
|
metadata: {
|
|
366
366
|
name: "lavarage",
|
|
367
367
|
version: "0.1.0",
|
|
@@ -7612,23 +7612,6 @@ var lavarageSOL_default = {
|
|
|
7612
7612
|
};
|
|
7613
7613
|
|
|
7614
7614
|
// utils.ts
|
|
7615
|
-
function retryWithBackoff(fn, maxRetries = 5, initialDelay = 1e3) {
|
|
7616
|
-
return __async(this, null, function* () {
|
|
7617
|
-
let lastError;
|
|
7618
|
-
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
7619
|
-
try {
|
|
7620
|
-
return yield fn();
|
|
7621
|
-
} catch (error) {
|
|
7622
|
-
lastError = error;
|
|
7623
|
-
if (attempt < maxRetries - 1) {
|
|
7624
|
-
const delay = initialDelay * Math.pow(2, attempt);
|
|
7625
|
-
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
7626
|
-
}
|
|
7627
|
-
}
|
|
7628
|
-
}
|
|
7629
|
-
throw lastError;
|
|
7630
|
-
});
|
|
7631
|
-
}
|
|
7632
7615
|
function u8ArrayToString(input) {
|
|
7633
7616
|
const end = input.indexOf(0);
|
|
7634
7617
|
const bytes = new Uint8Array(end === -1 ? input : input.slice(0, end));
|
|
@@ -7657,32 +7640,6 @@ var SURGE_FEEDS = [
|
|
|
7657
7640
|
}
|
|
7658
7641
|
];
|
|
7659
7642
|
var crossbarClient = new import_common.CrossbarClient("https://crossbar.switchboard.xyz");
|
|
7660
|
-
function getVariableOverrides(apiKeys) {
|
|
7661
|
-
return {
|
|
7662
|
-
BIRDEYE_API_KEY: apiKeys.birdeyeApiKey
|
|
7663
|
-
};
|
|
7664
|
-
}
|
|
7665
|
-
function getUpdateOracleIxs(program, feedId, payer, apiKeys) {
|
|
7666
|
-
return __async(this, null, function* () {
|
|
7667
|
-
const queue = yield (0, import_on_demand2.getQueue)({
|
|
7668
|
-
// @ts-expect-error @coral-xyz/anchor versions mismatch
|
|
7669
|
-
program,
|
|
7670
|
-
queueAddress: (yield (0, import_on_demand2.isMainnetConnection)(program.provider.connection)) ? import_on_demand2.ON_DEMAND_MAINNET_QUEUE : import_on_demand2.ON_DEMAND_DEVNET_QUEUE
|
|
7671
|
-
});
|
|
7672
|
-
return yield retryWithBackoff(() => __async(null, null, function* () {
|
|
7673
|
-
return yield queue.fetchManagedUpdateIxs(
|
|
7674
|
-
crossbarClient,
|
|
7675
|
-
[feedId],
|
|
7676
|
-
{
|
|
7677
|
-
numSignatures: 1,
|
|
7678
|
-
variableOverrides: getVariableOverrides(apiKeys),
|
|
7679
|
-
instructionIdx: 0,
|
|
7680
|
-
payer
|
|
7681
|
-
}
|
|
7682
|
-
);
|
|
7683
|
-
}));
|
|
7684
|
-
});
|
|
7685
|
-
}
|
|
7686
7643
|
|
|
7687
7644
|
// switchboard.ts
|
|
7688
7645
|
function getOracleQuoteForFeedId(feedId) {
|
|
@@ -9511,7 +9468,7 @@ var borrowV1 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, tokenPr
|
|
|
9511
9468
|
const tx = new import_web33.VersionedTransaction(messageV0);
|
|
9512
9469
|
return tx;
|
|
9513
9470
|
});
|
|
9514
|
-
var borrowV2 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, quoteToken, tokenProgram,
|
|
9471
|
+
var borrowV2 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, discountBps, referralBps, referralVaultProgram) => __async(null, null, function* () {
|
|
9515
9472
|
let partnerFeeMarkupAsPkey;
|
|
9516
9473
|
if (partnerFeeMarkup) {
|
|
9517
9474
|
const feeBuffer = Buffer.alloc(8);
|
|
@@ -9579,13 +9536,6 @@ var borrowV2 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, quoteTo
|
|
|
9579
9536
|
);
|
|
9580
9537
|
}
|
|
9581
9538
|
}
|
|
9582
|
-
const updateOracleInstructions = yield getUpdateOracleIxs(
|
|
9583
|
-
// @ts-expect-error IDL mismatch
|
|
9584
|
-
lavarageProgram,
|
|
9585
|
-
u8ArrayToString(offer.account.feedId),
|
|
9586
|
-
lavarageProgram.provider.publicKey,
|
|
9587
|
-
apiKeys
|
|
9588
|
-
);
|
|
9589
9539
|
const tradingOpenBorrowInstruction = useReferral ? yield lavarageProgram.methods.tradingOpenBorrow(
|
|
9590
9540
|
new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
|
|
9591
9541
|
marginSOL,
|
|
@@ -9720,8 +9670,6 @@ var borrowV2 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, quoteTo
|
|
|
9720
9670
|
microLamports: computeBudgetMicroLamports != null ? computeBudgetMicroLamports : 1e5
|
|
9721
9671
|
});
|
|
9722
9672
|
const allInstructions = [
|
|
9723
|
-
// must be the first instruction in the transaction
|
|
9724
|
-
...updateOracleInstructions,
|
|
9725
9673
|
fromTokenAccount.instruction,
|
|
9726
9674
|
partnerFeeRecipientVaultCreateIx,
|
|
9727
9675
|
partnerFeeRecipientTokenAccountCreateIx,
|
|
@@ -9969,7 +9917,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
9969
9917
|
const tx = new import_web33.VersionedTransaction(messageV0);
|
|
9970
9918
|
return tx;
|
|
9971
9919
|
});
|
|
9972
|
-
var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram,
|
|
9920
|
+
var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup, computeBudgetMicroLamports, platformFeeRecipient, splitTransactions, discountBps, referralBps, optionalRPCResults) => __async(null, null, function* () {
|
|
9973
9921
|
var _a;
|
|
9974
9922
|
let partnerFeeMarkupAsPkey;
|
|
9975
9923
|
const referralVaultProgram = new import_anchor2.Program(userVault_default, lavarageProgram.provider);
|
|
@@ -10123,13 +10071,6 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
10123
10071
|
);
|
|
10124
10072
|
}
|
|
10125
10073
|
}
|
|
10126
|
-
const updateOracleInstructions = yield getUpdateOracleIxs(
|
|
10127
|
-
// @ts-expect-error IDL mismatch
|
|
10128
|
-
program,
|
|
10129
|
-
u8ArrayToString(offer.account.feedId),
|
|
10130
|
-
program.provider.publicKey,
|
|
10131
|
-
apiKeys
|
|
10132
|
-
);
|
|
10133
10074
|
const tradingOpenBorrowInstruction = useReferral ? yield program.methods.tradingOpenBorrow(
|
|
10134
10075
|
new import_anchor2.BN((marginSOL.toNumber() * leverage).toFixed(0)),
|
|
10135
10076
|
marginSOL,
|
|
@@ -10265,8 +10206,6 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
10265
10206
|
const setUpInstructions = [
|
|
10266
10207
|
// fromTokenAccount.instruction!,
|
|
10267
10208
|
// toTokenAccount.instruction!,
|
|
10268
|
-
// must be the first instruction in the transaction
|
|
10269
|
-
...updateOracleInstructions,
|
|
10270
10209
|
partnerFeeRecipientVaultCreateIx,
|
|
10271
10210
|
partnerFeeRecipientTokenAccountCreateIx,
|
|
10272
10211
|
...setupInstructions.map(deserializeInstruction)
|
|
@@ -10295,8 +10234,6 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
10295
10234
|
const allInstructions = [
|
|
10296
10235
|
// fromTokenAccount.instruction!,
|
|
10297
10236
|
// toTokenAccount.instruction!,
|
|
10298
|
-
// must be the first instruction in the transaction
|
|
10299
|
-
...updateOracleInstructions,
|
|
10300
10237
|
partnerFeeRecipientVaultCreateIx,
|
|
10301
10238
|
partnerFeeRecipientTokenAccountCreateIx,
|
|
10302
10239
|
tradingOpenBorrowInstruction,
|