@lavarage/sdk 6.5.0 → 6.6.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Program, ProgramAccount, BN } from '@coral-xyz/anchor';
2
2
  import { PublicKey, Keypair, VersionedTransaction } from '@solana/web3.js';
3
- import { Signer, BigNumberish, ContractTransaction, Provider } from 'ethers';
3
+ import { Provider, BigNumberish, ContractTransaction } from 'ethers';
4
4
 
5
5
  type Lavarage$1 = {
6
6
  "version": "0.1.0";
@@ -2675,13 +2675,13 @@ interface LiquidationEvent {
2675
2675
  }
2676
2676
 
2677
2677
  /**
2678
- * Opens a trading position on EVM chain
2679
- * @param signer - Ethers signer
2678
+ * Creates an unsigned transaction to open a trading position on EVM chain
2679
+ * @param provider - Ethers provider
2680
2680
  * @param borrowerOpsContractAddress - BorrowerOperations contract address
2681
2681
  * @param params - Trading parameters
2682
- * @returns Transaction object
2682
+ * @returns Unsigned transaction object
2683
2683
  */
2684
- declare const openPositionEvm: (signer: Signer, borrowerOpsContractAddress: string, { buyingCode, tokenCollateral, borrowAmount, tokenHolder, inchRouter, integratorFeeAddress, buyerContribution, }: {
2684
+ declare const openPositionEvm: (provider: Provider, borrowerOpsContractAddress: string, { buyingCode, tokenCollateral, borrowAmount, tokenHolder, inchRouter, integratorFeeAddress, buyerContribution, gasLimit, gasPrice, }: {
2685
2685
  buyingCode: string;
2686
2686
  tokenCollateral: string;
2687
2687
  borrowAmount: BigNumberish;
@@ -2689,20 +2689,24 @@ declare const openPositionEvm: (signer: Signer, borrowerOpsContractAddress: stri
2689
2689
  inchRouter: string;
2690
2690
  integratorFeeAddress?: string;
2691
2691
  buyerContribution: BigNumberish;
2692
+ gasLimit?: string | number;
2693
+ gasPrice?: string | number;
2692
2694
  }) => Promise<ContractTransaction>;
2693
2695
  /**
2694
- * Closes a trading position on EVM chain
2695
- * @param signer - Ethers signer
2696
+ * Creates an unsigned transaction to close a trading position on EVM chain
2697
+ * @param provider - Ethers provider
2696
2698
  * @param borrowerOpsContractAddress - BorrowerOperations contract address
2697
2699
  * @param params - Trading parameters
2698
- * @returns Transaction object
2700
+ * @returns Unsigned transaction object
2699
2701
  */
2700
- declare const closePositionEvm: (signer: Signer, borrowerOpsContractAddress: string, { loanId, sellingCode, tokenHolder, inchRouter, integratorFeeAddress, }: {
2702
+ declare const closePositionEvm: (provider: Provider, borrowerOpsContractAddress: string, { loanId, sellingCode, tokenHolder, inchRouter, integratorFeeAddress, gasLimit, gasPrice, }: {
2701
2703
  loanId: BigNumberish;
2702
2704
  sellingCode: string;
2703
2705
  tokenHolder: string;
2704
2706
  inchRouter: string;
2705
2707
  integratorFeeAddress?: string;
2708
+ gasLimit?: string | number;
2709
+ gasPrice?: string | number;
2706
2710
  }) => Promise<ContractTransaction>;
2707
2711
  /**
2708
2712
  * Get all positions from events
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Program, ProgramAccount, BN } from '@coral-xyz/anchor';
2
2
  import { PublicKey, Keypair, VersionedTransaction } from '@solana/web3.js';
3
- import { Signer, BigNumberish, ContractTransaction, Provider } from 'ethers';
3
+ import { Provider, BigNumberish, ContractTransaction } from 'ethers';
4
4
 
5
5
  type Lavarage$1 = {
6
6
  "version": "0.1.0";
@@ -2675,13 +2675,13 @@ interface LiquidationEvent {
2675
2675
  }
2676
2676
 
2677
2677
  /**
2678
- * Opens a trading position on EVM chain
2679
- * @param signer - Ethers signer
2678
+ * Creates an unsigned transaction to open a trading position on EVM chain
2679
+ * @param provider - Ethers provider
2680
2680
  * @param borrowerOpsContractAddress - BorrowerOperations contract address
2681
2681
  * @param params - Trading parameters
2682
- * @returns Transaction object
2682
+ * @returns Unsigned transaction object
2683
2683
  */
2684
- declare const openPositionEvm: (signer: Signer, borrowerOpsContractAddress: string, { buyingCode, tokenCollateral, borrowAmount, tokenHolder, inchRouter, integratorFeeAddress, buyerContribution, }: {
2684
+ declare const openPositionEvm: (provider: Provider, borrowerOpsContractAddress: string, { buyingCode, tokenCollateral, borrowAmount, tokenHolder, inchRouter, integratorFeeAddress, buyerContribution, gasLimit, gasPrice, }: {
2685
2685
  buyingCode: string;
2686
2686
  tokenCollateral: string;
2687
2687
  borrowAmount: BigNumberish;
@@ -2689,20 +2689,24 @@ declare const openPositionEvm: (signer: Signer, borrowerOpsContractAddress: stri
2689
2689
  inchRouter: string;
2690
2690
  integratorFeeAddress?: string;
2691
2691
  buyerContribution: BigNumberish;
2692
+ gasLimit?: string | number;
2693
+ gasPrice?: string | number;
2692
2694
  }) => Promise<ContractTransaction>;
2693
2695
  /**
2694
- * Closes a trading position on EVM chain
2695
- * @param signer - Ethers signer
2696
+ * Creates an unsigned transaction to close a trading position on EVM chain
2697
+ * @param provider - Ethers provider
2696
2698
  * @param borrowerOpsContractAddress - BorrowerOperations contract address
2697
2699
  * @param params - Trading parameters
2698
- * @returns Transaction object
2700
+ * @returns Unsigned transaction object
2699
2701
  */
2700
- declare const closePositionEvm: (signer: Signer, borrowerOpsContractAddress: string, { loanId, sellingCode, tokenHolder, inchRouter, integratorFeeAddress, }: {
2702
+ declare const closePositionEvm: (provider: Provider, borrowerOpsContractAddress: string, { loanId, sellingCode, tokenHolder, inchRouter, integratorFeeAddress, gasLimit, gasPrice, }: {
2701
2703
  loanId: BigNumberish;
2702
2704
  sellingCode: string;
2703
2705
  tokenHolder: string;
2704
2706
  inchRouter: string;
2705
2707
  integratorFeeAddress?: string;
2708
+ gasLimit?: string | number;
2709
+ gasPrice?: string | number;
2706
2710
  }) => Promise<ContractTransaction>;
2707
2711
  /**
2708
2712
  * Get all positions from events
package/dist/index.js CHANGED
@@ -3434,51 +3434,64 @@ var tokenHolderAbi = [
3434
3434
  ];
3435
3435
 
3436
3436
  // evm.ts
3437
- var openPositionEvm = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (signer, borrowerOpsContractAddress, {
3437
+ var openPositionEvm = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (provider, borrowerOpsContractAddress, {
3438
3438
  buyingCode,
3439
3439
  tokenCollateral,
3440
3440
  borrowAmount,
3441
3441
  tokenHolder,
3442
3442
  inchRouter,
3443
3443
  integratorFeeAddress = import_ethers.ZeroAddress,
3444
- buyerContribution
3444
+ buyerContribution,
3445
+ gasLimit,
3446
+ gasPrice
3445
3447
  }) {
3446
3448
  const contract = new import_ethers.Contract(
3447
3449
  borrowerOpsContractAddress,
3448
3450
  borrowerOperationsAbi,
3449
- signer
3451
+ provider
3450
3452
  );
3451
- return contract.buy(
3453
+ const txOptions = {
3454
+ value: buyerContribution
3455
+ };
3456
+ if (gasLimit) txOptions.gasLimit = gasLimit;
3457
+ if (gasPrice) txOptions.gasPrice = gasPrice;
3458
+ return contract.buy.populateTransaction(
3452
3459
  buyingCode,
3453
3460
  tokenCollateral,
3454
3461
  borrowAmount,
3455
3462
  tokenHolder,
3456
3463
  inchRouter,
3457
3464
  integratorFeeAddress,
3458
- { value: buyerContribution }
3465
+ txOptions
3459
3466
  );
3460
3467
  });
3461
- var closePositionEvm = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (signer, borrowerOpsContractAddress, {
3468
+ var closePositionEvm = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (provider, borrowerOpsContractAddress, {
3462
3469
  loanId,
3463
3470
  sellingCode,
3464
3471
  tokenHolder,
3465
3472
  inchRouter,
3466
- integratorFeeAddress = import_ethers.ZeroAddress
3473
+ integratorFeeAddress = import_ethers.ZeroAddress,
3474
+ gasLimit,
3475
+ gasPrice
3467
3476
  }) {
3468
3477
  const contract = new import_ethers.Contract(
3469
3478
  borrowerOpsContractAddress,
3470
3479
  borrowerOperationsAbi,
3471
- signer
3480
+ provider
3472
3481
  );
3473
- return contract.sell(
3482
+ const txOptions = {};
3483
+ if (gasLimit) txOptions.gasLimit = gasLimit;
3484
+ if (gasPrice) txOptions.gasPrice = gasPrice;
3485
+ return contract.sell.populateTransaction(
3474
3486
  loanId,
3475
3487
  sellingCode,
3476
3488
  tokenHolder,
3477
3489
  inchRouter,
3478
- integratorFeeAddress
3490
+ integratorFeeAddress,
3491
+ Object.keys(txOptions).length > 0 ? txOptions : {}
3479
3492
  );
3480
3493
  });
3481
- function getPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 0) {
3494
+ function getPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 42960845) {
3482
3495
  return __async(this, null, function* () {
3483
3496
  const contract = new import_ethers.Contract(
3484
3497
  borrowerOpsContractAddress,
@@ -3489,7 +3502,7 @@ function getPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 0) {
3489
3502
  const events = yield contract.queryFilter(filter, fromBlock);
3490
3503
  return events.map((event) => {
3491
3504
  const {
3492
- trader,
3505
+ buyer,
3493
3506
  tokenCollateral,
3494
3507
  loanId,
3495
3508
  openingPositionSize,
@@ -3497,7 +3510,7 @@ function getPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 0) {
3497
3510
  initialMargin
3498
3511
  } = event.args;
3499
3512
  return {
3500
- trader,
3513
+ trader: buyer,
3501
3514
  tokenCollateral,
3502
3515
  loanId,
3503
3516
  openingPositionSize,
@@ -3507,7 +3520,7 @@ function getPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 0) {
3507
3520
  });
3508
3521
  });
3509
3522
  }
3510
- function getClosedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 0) {
3523
+ function getClosedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 42960845) {
3511
3524
  return __async(this, null, function* () {
3512
3525
  const contract = new import_ethers.Contract(
3513
3526
  borrowerOpsContractAddress,
@@ -3517,9 +3530,15 @@ function getClosedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock =
3517
3530
  const filter = contract.filters.Sell();
3518
3531
  const events = yield contract.queryFilter(filter, fromBlock);
3519
3532
  return events.map((event) => {
3520
- const { trader, tokenCollateral, loanId, closingPositionSize, profit } = event.args;
3533
+ const {
3534
+ buyer,
3535
+ tokenCollateral,
3536
+ loanId,
3537
+ closingPositionSize,
3538
+ profit
3539
+ } = event.args;
3521
3540
  return {
3522
- trader,
3541
+ trader: buyer,
3523
3542
  tokenCollateral,
3524
3543
  loanId,
3525
3544
  closingPositionSize,
@@ -3528,7 +3547,7 @@ function getClosedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock =
3528
3547
  });
3529
3548
  });
3530
3549
  }
3531
- function getLiquidatedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 0) {
3550
+ function getLiquidatedPositionsEvm(provider, borrowerOpsContractAddress, fromBlock = 42960845) {
3532
3551
  return __async(this, null, function* () {
3533
3552
  const contract = new import_ethers.Contract(
3534
3553
  borrowerOpsContractAddress,
@@ -3539,14 +3558,14 @@ function getLiquidatedPositionsEvm(provider, borrowerOpsContractAddress, fromBlo
3539
3558
  const events = yield contract.queryFilter(filter, fromBlock);
3540
3559
  return events.map((event) => {
3541
3560
  const {
3542
- trader,
3561
+ borrower,
3543
3562
  tokenCollateral,
3544
3563
  loanId,
3545
3564
  closingPositionSize,
3546
3565
  liquidatorRepaidAmount
3547
3566
  } = event.args;
3548
3567
  return {
3549
- trader,
3568
+ trader: borrower,
3550
3569
  tokenCollateral,
3551
3570
  loanId,
3552
3571
  closingPositionSize,