@lavarage/sdk 6.5.0 → 6.7.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 +15 -11
- package/dist/index.d.ts +15 -11
- package/dist/index.js +40 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -32
- package/dist/index.mjs.map +1 -1
- package/evm.ts +57 -27
- package/index.ts +2 -10
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3399,51 +3399,64 @@ var tokenHolderAbi = [
|
|
|
3399
3399
|
];
|
|
3400
3400
|
|
|
3401
3401
|
// evm.ts
|
|
3402
|
-
var openPositionEvm = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (
|
|
3402
|
+
var openPositionEvm = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (provider, borrowerOpsContractAddress, {
|
|
3403
3403
|
buyingCode,
|
|
3404
3404
|
tokenCollateral,
|
|
3405
3405
|
borrowAmount,
|
|
3406
3406
|
tokenHolder,
|
|
3407
3407
|
inchRouter,
|
|
3408
3408
|
integratorFeeAddress = ZeroAddress,
|
|
3409
|
-
buyerContribution
|
|
3409
|
+
buyerContribution,
|
|
3410
|
+
gasLimit,
|
|
3411
|
+
gasPrice
|
|
3410
3412
|
}) {
|
|
3411
3413
|
const contract = new Contract(
|
|
3412
3414
|
borrowerOpsContractAddress,
|
|
3413
3415
|
borrowerOperationsAbi,
|
|
3414
|
-
|
|
3416
|
+
provider
|
|
3415
3417
|
);
|
|
3416
|
-
|
|
3418
|
+
const txOptions = {
|
|
3419
|
+
value: buyerContribution
|
|
3420
|
+
};
|
|
3421
|
+
if (gasLimit) txOptions.gasLimit = gasLimit;
|
|
3422
|
+
if (gasPrice) txOptions.gasPrice = gasPrice;
|
|
3423
|
+
return contract.buy.populateTransaction(
|
|
3417
3424
|
buyingCode,
|
|
3418
3425
|
tokenCollateral,
|
|
3419
3426
|
borrowAmount,
|
|
3420
3427
|
tokenHolder,
|
|
3421
3428
|
inchRouter,
|
|
3422
3429
|
integratorFeeAddress,
|
|
3423
|
-
|
|
3430
|
+
txOptions
|
|
3424
3431
|
);
|
|
3425
3432
|
});
|
|
3426
|
-
var closePositionEvm = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (
|
|
3433
|
+
var closePositionEvm = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (provider, borrowerOpsContractAddress, {
|
|
3427
3434
|
loanId,
|
|
3428
3435
|
sellingCode,
|
|
3429
3436
|
tokenHolder,
|
|
3430
3437
|
inchRouter,
|
|
3431
|
-
integratorFeeAddress = ZeroAddress
|
|
3438
|
+
integratorFeeAddress = ZeroAddress,
|
|
3439
|
+
gasLimit,
|
|
3440
|
+
gasPrice
|
|
3432
3441
|
}) {
|
|
3433
3442
|
const contract = new Contract(
|
|
3434
3443
|
borrowerOpsContractAddress,
|
|
3435
3444
|
borrowerOperationsAbi,
|
|
3436
|
-
|
|
3445
|
+
provider
|
|
3437
3446
|
);
|
|
3438
|
-
|
|
3447
|
+
const txOptions = {};
|
|
3448
|
+
if (gasLimit) txOptions.gasLimit = gasLimit;
|
|
3449
|
+
if (gasPrice) txOptions.gasPrice = gasPrice;
|
|
3450
|
+
return contract.sell.populateTransaction(
|
|
3439
3451
|
loanId,
|
|
3440
3452
|
sellingCode,
|
|
3441
3453
|
tokenHolder,
|
|
3442
3454
|
inchRouter,
|
|
3443
|
-
integratorFeeAddress
|
|
3455
|
+
integratorFeeAddress,
|
|
3456
|
+
Object.keys(txOptions).length > 0 ? txOptions : {}
|
|
3444
3457
|
);
|
|
3445
3458
|
});
|
|
3446
|
-
function getPositionsEvm(provider, borrowerOpsContractAddress, fromBlock =
|
|
3459
|
+
function getPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 42960845) {
|
|
3447
3460
|
return __async(this, null, function* () {
|
|
3448
3461
|
const contract = new Contract(
|
|
3449
3462
|
borrowerOpsContractAddress,
|
|
@@ -3454,7 +3467,7 @@ function getPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 0) {
|
|
|
3454
3467
|
const events = yield contract.queryFilter(filter, fromBlock);
|
|
3455
3468
|
return events.map((event) => {
|
|
3456
3469
|
const {
|
|
3457
|
-
|
|
3470
|
+
buyer,
|
|
3458
3471
|
tokenCollateral,
|
|
3459
3472
|
loanId,
|
|
3460
3473
|
openingPositionSize,
|
|
@@ -3462,17 +3475,18 @@ function getPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 0) {
|
|
|
3462
3475
|
initialMargin
|
|
3463
3476
|
} = event.args;
|
|
3464
3477
|
return {
|
|
3465
|
-
trader,
|
|
3478
|
+
trader: buyer,
|
|
3466
3479
|
tokenCollateral,
|
|
3467
3480
|
loanId,
|
|
3468
3481
|
openingPositionSize,
|
|
3469
3482
|
collateralAmount,
|
|
3470
|
-
initialMargin
|
|
3483
|
+
initialMargin,
|
|
3484
|
+
transactionHash: event.transactionHash
|
|
3471
3485
|
};
|
|
3472
3486
|
});
|
|
3473
3487
|
});
|
|
3474
3488
|
}
|
|
3475
|
-
function getClosedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock =
|
|
3489
|
+
function getClosedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 42960845) {
|
|
3476
3490
|
return __async(this, null, function* () {
|
|
3477
3491
|
const contract = new Contract(
|
|
3478
3492
|
borrowerOpsContractAddress,
|
|
@@ -3482,18 +3496,19 @@ function getClosedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock =
|
|
|
3482
3496
|
const filter = contract.filters.Sell();
|
|
3483
3497
|
const events = yield contract.queryFilter(filter, fromBlock);
|
|
3484
3498
|
return events.map((event) => {
|
|
3485
|
-
const {
|
|
3499
|
+
const { buyer, tokenCollateral, loanId, closingPositionSize, profit } = event.args;
|
|
3486
3500
|
return {
|
|
3487
|
-
trader,
|
|
3501
|
+
trader: buyer,
|
|
3488
3502
|
tokenCollateral,
|
|
3489
3503
|
loanId,
|
|
3490
3504
|
closingPositionSize,
|
|
3491
|
-
profit
|
|
3505
|
+
profit,
|
|
3506
|
+
transactionHash: event.transactionHash
|
|
3492
3507
|
};
|
|
3493
3508
|
});
|
|
3494
3509
|
});
|
|
3495
3510
|
}
|
|
3496
|
-
function getLiquidatedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock =
|
|
3511
|
+
function getLiquidatedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 42960845) {
|
|
3497
3512
|
return __async(this, null, function* () {
|
|
3498
3513
|
const contract = new Contract(
|
|
3499
3514
|
borrowerOpsContractAddress,
|
|
@@ -3504,18 +3519,19 @@ function getLiquidatedPositionsEvm(provider, borrowerOpsContractAddress, fromBlo
|
|
|
3504
3519
|
const events = yield contract.queryFilter(filter, fromBlock);
|
|
3505
3520
|
return events.map((event) => {
|
|
3506
3521
|
const {
|
|
3507
|
-
|
|
3522
|
+
borrower,
|
|
3508
3523
|
tokenCollateral,
|
|
3509
3524
|
loanId,
|
|
3510
3525
|
closingPositionSize,
|
|
3511
3526
|
liquidatorRepaidAmount
|
|
3512
3527
|
} = event.args;
|
|
3513
3528
|
return {
|
|
3514
|
-
trader,
|
|
3529
|
+
trader: borrower,
|
|
3515
3530
|
tokenCollateral,
|
|
3516
3531
|
loanId,
|
|
3517
3532
|
closingPositionSize,
|
|
3518
|
-
liquidatorRepaidAmount
|
|
3533
|
+
liquidatorRepaidAmount,
|
|
3534
|
+
transactionHash: event.transactionHash
|
|
3519
3535
|
};
|
|
3520
3536
|
});
|
|
3521
3537
|
});
|
|
@@ -3691,7 +3707,7 @@ var getLiquidatedPositions = (lavarageProgram) => {
|
|
|
3691
3707
|
var getAllPositions = (lavarageProgram) => {
|
|
3692
3708
|
return lavarageProgram.account.position.all([{ dataSize: 178 }]);
|
|
3693
3709
|
};
|
|
3694
|
-
var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
|
|
3710
|
+
var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, tokenProgram, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
|
|
3695
3711
|
let partnerFeeMarkupAsPkey;
|
|
3696
3712
|
if (partnerFeeMarkup) {
|
|
3697
3713
|
const feeBuffer = Buffer.alloc(8);
|
|
@@ -3705,10 +3721,6 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
3705
3721
|
offer,
|
|
3706
3722
|
randomSeed.publicKey
|
|
3707
3723
|
);
|
|
3708
|
-
const mintAccount = yield lavarageProgram.provider.connection.getAccountInfo(
|
|
3709
|
-
offer.account.collateralType
|
|
3710
|
-
);
|
|
3711
|
-
const tokenProgram = mintAccount == null ? void 0 : mintAccount.owner;
|
|
3712
3724
|
const fromTokenAccount = yield getTokenAccountOrCreateIfNotExists(
|
|
3713
3725
|
lavarageProgram,
|
|
3714
3726
|
lavarageProgram.provider.publicKey,
|
|
@@ -3826,7 +3838,7 @@ var openTradeV1 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
3826
3838
|
const tx = new VersionedTransaction(messageV0);
|
|
3827
3839
|
return tx;
|
|
3828
3840
|
});
|
|
3829
|
-
var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
|
|
3841
|
+
var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage, randomSeed, quoteToken, tokenProgram, partnerFeeRecipient, partnerFeeMarkup) => __async(void 0, null, function* () {
|
|
3830
3842
|
let partnerFeeMarkupAsPkey;
|
|
3831
3843
|
if (partnerFeeMarkup) {
|
|
3832
3844
|
const feeBuffer = Buffer.alloc(8);
|
|
@@ -3840,10 +3852,6 @@ var openTradeV2 = (lavarageProgram, offer, jupInstruction, marginSOL, leverage,
|
|
|
3840
3852
|
offer,
|
|
3841
3853
|
randomSeed.publicKey
|
|
3842
3854
|
);
|
|
3843
|
-
const mintAccount = yield lavarageProgram.provider.connection.getAccountInfo(
|
|
3844
|
-
offer.account.collateralType
|
|
3845
|
-
);
|
|
3846
|
-
const tokenProgram = mintAccount == null ? void 0 : mintAccount.owner;
|
|
3847
3855
|
const quoteMintAccount = yield lavarageProgram.provider.connection.getAccountInfo(quoteToken);
|
|
3848
3856
|
const quoteTokenProgram = quoteMintAccount == null ? void 0 : quoteMintAccount.owner;
|
|
3849
3857
|
const fromTokenAccount = yield getTokenAccountOrCreateIfNotExists(
|