@lavarage/sdk 7.3.0 → 7.4.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/evm.ts CHANGED
@@ -535,6 +535,49 @@ export async function getAvailableExposureEvm(
535
535
  return contract.getAvailableExposure(collateralAddress);
536
536
  }
537
537
 
538
+ /**
539
+ * Creates an unsigned transaction to liquidate a trading position on EVM chain
540
+ * @param provider - Ethers provider
541
+ * @param borrowerOpsContractAddress - BorrowerOperations contract address
542
+ * @param params - Liquidation parameters
543
+ * @returns Unsigned transaction object
544
+ */
545
+ export const liquidatePositionEvm = async (
546
+ provider: Provider,
547
+ borrowerOpsContractAddress: string,
548
+ {
549
+ loanId,
550
+ tokenHolder,
551
+ closingPositionSize,
552
+ gasLimit,
553
+ gasPrice,
554
+ }: {
555
+ loanId: BigNumberish;
556
+ tokenHolder: string;
557
+ closingPositionSize: BigNumberish;
558
+ gasLimit?: string | number;
559
+ gasPrice?: string | number;
560
+ }
561
+ ): Promise<ContractTransaction> => {
562
+ const contract = new Contract(
563
+ borrowerOpsContractAddress,
564
+ borrowerOperationsAbi,
565
+ provider
566
+ );
567
+
568
+ const txOptions: { gasLimit?: BigNumberish; gasPrice?: BigNumberish } = {};
569
+
570
+ if (gasLimit) txOptions.gasLimit = gasLimit;
571
+ if (gasPrice) txOptions.gasPrice = gasPrice;
572
+
573
+ return contract.liquidate.populateTransaction(
574
+ loanId,
575
+ tokenHolder,
576
+ closingPositionSize,
577
+ Object.keys(txOptions).length > 0 ? txOptions : {}
578
+ );
579
+ };
580
+
538
581
  /**
539
582
  * Update max lend per token for multiple collaterals in batch
540
583
  * @param provider - Ethers provider
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lavarage/sdk",
3
- "version": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "description": "Lavarage SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",