@lavarage/sdk 8.0.6 → 8.0.8
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/crossbar.ts +2 -2
- package/dist/index.js +10 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -61
- package/dist/index.mjs.map +1 -1
- package/index.ts +9 -70
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -7598,12 +7598,12 @@ function isSolProgram(program) {
|
|
|
7598
7598
|
var SURGE_FEEDS = [
|
|
7599
7599
|
{
|
|
7600
7600
|
address: NATIVE_MINT.toBase58(),
|
|
7601
|
-
feedId: "
|
|
7601
|
+
feedId: "0x822512ee9add93518eca1c105a38422841a76c590db079eebb283deb2c14caa9",
|
|
7602
7602
|
label: "SOL-USD"
|
|
7603
7603
|
},
|
|
7604
7604
|
{
|
|
7605
7605
|
address: USDC_MINT.toBase58(),
|
|
7606
|
-
feedId: "
|
|
7606
|
+
feedId: "0x883ea8295f70ae506e894679d124196bb07064ea530cefd835b58c33a5ab6549",
|
|
7607
7607
|
label: "USDC-USD"
|
|
7608
7608
|
}
|
|
7609
7609
|
];
|
|
@@ -9229,26 +9229,6 @@ function getPda(seed, programId) {
|
|
|
9229
9229
|
const seedsBuffer = Array.isArray(seed) ? seed : [seed];
|
|
9230
9230
|
return PublicKey3.findProgramAddressSync(seedsBuffer, programId)[0];
|
|
9231
9231
|
}
|
|
9232
|
-
function idlAccountNamesToCamelCase(idl) {
|
|
9233
|
-
if (idl === null || idl === void 0) return idl;
|
|
9234
|
-
if (Array.isArray(idl)) return idl.map(idlAccountNamesToCamelCase);
|
|
9235
|
-
if (typeof idl === "string") return idl;
|
|
9236
|
-
if (typeof idl === "object") {
|
|
9237
|
-
const out = {};
|
|
9238
|
-
for (const [k, v] of Object.entries(idl)) {
|
|
9239
|
-
let newV = idlAccountNamesToCamelCase(v);
|
|
9240
|
-
if ((k === "name" || k === "path") && typeof newV === "string" && newV.includes("_")) {
|
|
9241
|
-
newV = newV.split(".").map((s) => s.replace(/_([a-z])/g, (_, c) => c.toUpperCase())).join(".");
|
|
9242
|
-
}
|
|
9243
|
-
out[k] = newV;
|
|
9244
|
-
}
|
|
9245
|
-
return out;
|
|
9246
|
-
}
|
|
9247
|
-
return idl;
|
|
9248
|
-
}
|
|
9249
|
-
var LAVARAGE_USDC_IDL_CAMEL = idlAccountNamesToCamelCase(
|
|
9250
|
-
lavarageUSDC_default
|
|
9251
|
-
);
|
|
9252
9232
|
function getPositionAccountPDA(lavarageProgram, offer, seed) {
|
|
9253
9233
|
return getPda(
|
|
9254
9234
|
[
|
|
@@ -9629,7 +9609,9 @@ var borrowV2 = (lavarageProgram, offer, marginSOL, leverage, randomSeed, quoteTo
|
|
|
9629
9609
|
] : []
|
|
9630
9610
|
).instruction() : yield lavarageProgram.methods.tradingOpenBorrow(
|
|
9631
9611
|
new BN2((marginSOL.toNumber() * leverage).toFixed(0)),
|
|
9632
|
-
marginSOL
|
|
9612
|
+
marginSOL,
|
|
9613
|
+
null,
|
|
9614
|
+
null
|
|
9633
9615
|
).accountsStrict({
|
|
9634
9616
|
nodeWallet: offer.account.nodeWallet,
|
|
9635
9617
|
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
@@ -9958,7 +9940,7 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
9958
9940
|
var _a;
|
|
9959
9941
|
let partnerFeeMarkupAsPkey;
|
|
9960
9942
|
const referralVaultProgram = new Program2(userVault_default, lavarageProgram.provider);
|
|
9961
|
-
const program = new Program2(
|
|
9943
|
+
const program = new Program2(lavarageUSDC_default, lavarageProgram.provider);
|
|
9962
9944
|
if (partnerFeeMarkup) {
|
|
9963
9945
|
const feeBuffer = Buffer.alloc(8);
|
|
9964
9946
|
feeBuffer.writeBigUInt64LE(BigInt(partnerFeeMarkup));
|
|
@@ -9971,7 +9953,6 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
9971
9953
|
offer,
|
|
9972
9954
|
randomSeed.publicKey
|
|
9973
9955
|
);
|
|
9974
|
-
console.log("SDK: positionAccount", positionAccount.toBase58());
|
|
9975
9956
|
const quoteMintAccount = (_a = optionalRPCResults == null ? void 0 : optionalRPCResults.quoteMintAccountInfo) != null ? _a : yield program.provider.connection.getAccountInfo(quoteToken);
|
|
9976
9957
|
const quoteTokenProgram = quoteMintAccount == null ? void 0 : quoteMintAccount.owner;
|
|
9977
9958
|
const fromTokenAccount = yield getTokenAccountOrCreateIfNotExists(
|
|
@@ -10109,41 +10090,6 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
10109
10090
|
);
|
|
10110
10091
|
}
|
|
10111
10092
|
}
|
|
10112
|
-
console.log("SDK: tradingOpenBorrowInstruction accounts", {
|
|
10113
|
-
nodeWallet: offer.account.nodeWallet,
|
|
10114
|
-
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
10115
|
-
tradingPool: offer.publicKey,
|
|
10116
|
-
positionAccount,
|
|
10117
|
-
trader: program.provider.publicKey,
|
|
10118
|
-
systemProgram: SystemProgram2.programId,
|
|
10119
|
-
clock: SYSVAR_CLOCK_PUBKEY,
|
|
10120
|
-
randomAccountAsId: randomSeed.publicKey.toBase58(),
|
|
10121
|
-
feeTokenAccount: getAssociatedTokenAddressSync2(
|
|
10122
|
-
quoteToken,
|
|
10123
|
-
new PublicKey3("6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF"),
|
|
10124
|
-
true,
|
|
10125
|
-
quoteTokenProgram
|
|
10126
|
-
),
|
|
10127
|
-
toTokenAccount: getAssociatedTokenAddressSync2(
|
|
10128
|
-
quoteToken,
|
|
10129
|
-
program.provider.publicKey,
|
|
10130
|
-
true,
|
|
10131
|
-
quoteTokenProgram
|
|
10132
|
-
),
|
|
10133
|
-
tokenProgram: quoteTokenProgram,
|
|
10134
|
-
fromTokenAccount: getAssociatedTokenAddressSync2(
|
|
10135
|
-
quoteToken,
|
|
10136
|
-
offer.account.nodeWallet,
|
|
10137
|
-
true,
|
|
10138
|
-
quoteTokenProgram
|
|
10139
|
-
),
|
|
10140
|
-
positionTokenAccount: toTokenAccount.account.address,
|
|
10141
|
-
collateralTokenProgram: tokenProgram,
|
|
10142
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
10143
|
-
collateralMint: offer.account.collateralType,
|
|
10144
|
-
quoteMint: quoteToken,
|
|
10145
|
-
feeRecipient: new PublicKey3("6JfTobDvwuwZxZP6FR5JPmjdvQ4h4MovkEVH2FPsMSrF")
|
|
10146
|
-
});
|
|
10147
10093
|
const updateOracleInstructions = yield getUpdateOracleIxs(
|
|
10148
10094
|
// @ts-expect-error IDL mismatch
|
|
10149
10095
|
program,
|
|
@@ -10206,7 +10152,9 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
10206
10152
|
] : []
|
|
10207
10153
|
).instruction() : yield program.methods.tradingOpenBorrow(
|
|
10208
10154
|
new BN2((marginSOL.toNumber() * leverage).toFixed(0)),
|
|
10209
|
-
marginSOL
|
|
10155
|
+
marginSOL,
|
|
10156
|
+
null,
|
|
10157
|
+
null
|
|
10210
10158
|
).accountsStrict({
|
|
10211
10159
|
nodeWallet: offer.account.nodeWallet,
|
|
10212
10160
|
instructions: SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
@@ -10315,6 +10263,7 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
10315
10263
|
// toTokenAccount.instruction!,
|
|
10316
10264
|
partnerFeeRecipientVaultCreateIx,
|
|
10317
10265
|
partnerFeeRecipientTokenAccountCreateIx,
|
|
10266
|
+
...updateOracleInstructions,
|
|
10318
10267
|
tradingOpenBorrowInstruction,
|
|
10319
10268
|
...jupiterIxs,
|
|
10320
10269
|
openAddCollateralInstruction,
|