@lavarage/sdk 6.7.0 → 6.7.2

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.
@@ -221,7 +221,7 @@ export const borrowerOperationsAbi = [
221
221
  ],
222
222
  name: "sell",
223
223
  outputs: [],
224
- stateMutability: "nonpayable",
224
+ stateMutability: "payable",
225
225
  type: "function",
226
226
  },
227
227
  {
@@ -233,6 +233,8 @@ export const tokenHolderAbi = [
233
233
  { internalType: "uint256", name: "interestRate", type: "uint256" },
234
234
  { internalType: "bool", name: "active", type: "bool" },
235
235
  { internalType: "uint256", name: "minAmount", type: "uint256" },
236
+ { internalType: "uint256", name: "maxExposure", type: "uint256" },
237
+ { internalType: "uint256", name: "currentExposure", type: "uint256" },
236
238
  ],
237
239
  stateMutability: "view",
238
240
  type: "function",
@@ -324,6 +326,8 @@ export const tokenHolderAbi = [
324
326
  { internalType: "uint256", name: "interestRate", type: "uint256" },
325
327
  { internalType: "bool", name: "active", type: "bool" },
326
328
  { internalType: "uint256", name: "minAmount", type: "uint256" },
329
+ { internalType: "uint256", name: "maxExposure", type: "uint256" },
330
+ { internalType: "uint256", name: "currentExposure", type: "uint256" },
327
331
  ],
328
332
  internalType: "struct Collateral",
329
333
  name: "collateral",
@@ -440,4 +444,216 @@ export const tokenHolderAbi = [
440
444
  stateMutability: "nonpayable",
441
445
  type: "function",
442
446
  },
447
+ {
448
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
449
+ name: "activeLoanIds",
450
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
451
+ stateMutability: "view",
452
+ type: "function",
453
+ },
454
+ {
455
+ inputs: [],
456
+ name: "getActiveLoanCount",
457
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
458
+ stateMutability: "view",
459
+ type: "function",
460
+ },
461
+ {
462
+ inputs: [
463
+ { internalType: "uint256", name: "startIndex", type: "uint256" },
464
+ { internalType: "uint256", name: "batchSize", type: "uint256" },
465
+ ],
466
+ name: "getActiveLoansBatch",
467
+ outputs: [
468
+ {
469
+ components: [
470
+ { internalType: "uint256", name: "id", type: "uint256" },
471
+ { internalType: "uint256", name: "amount", type: "uint256" },
472
+ {
473
+ components: [
474
+ {
475
+ internalType: "address",
476
+ name: "collateralAddress",
477
+ type: "address",
478
+ },
479
+ {
480
+ internalType: "uint256",
481
+ name: "maxLendPerToken",
482
+ type: "uint256",
483
+ },
484
+ {
485
+ internalType: "uint256",
486
+ name: "interestRate",
487
+ type: "uint256",
488
+ },
489
+ { internalType: "bool", name: "active", type: "bool" },
490
+ { internalType: "uint256", name: "minAmount", type: "uint256" },
491
+ { internalType: "uint256", name: "maxExposure", type: "uint256" },
492
+ {
493
+ internalType: "uint256",
494
+ name: "currentExposure",
495
+ type: "uint256",
496
+ },
497
+ ],
498
+ internalType: "struct Collateral",
499
+ name: "collateral",
500
+ type: "tuple",
501
+ },
502
+ {
503
+ internalType: "uint256",
504
+ name: "collateralAmount",
505
+ type: "uint256",
506
+ },
507
+ { internalType: "uint256", name: "timestamp", type: "uint256" },
508
+ { internalType: "address", name: "borrower", type: "address" },
509
+ { internalType: "uint256", name: "userPaid", type: "uint256" },
510
+ ],
511
+ internalType: "struct Loan[]",
512
+ name: "",
513
+ type: "tuple[]",
514
+ },
515
+ ],
516
+ stateMutability: "view",
517
+ type: "function",
518
+ },
519
+ {
520
+ inputs: [{ internalType: "address", name: "borrower", type: "address" }],
521
+ name: "getLoansByBorrower",
522
+ outputs: [
523
+ {
524
+ components: [
525
+ { internalType: "uint256", name: "id", type: "uint256" },
526
+ { internalType: "uint256", name: "amount", type: "uint256" },
527
+ {
528
+ components: [
529
+ {
530
+ internalType: "address",
531
+ name: "collateralAddress",
532
+ type: "address",
533
+ },
534
+ {
535
+ internalType: "uint256",
536
+ name: "maxLendPerToken",
537
+ type: "uint256",
538
+ },
539
+ {
540
+ internalType: "uint256",
541
+ name: "interestRate",
542
+ type: "uint256",
543
+ },
544
+ { internalType: "bool", name: "active", type: "bool" },
545
+ { internalType: "uint256", name: "minAmount", type: "uint256" },
546
+ { internalType: "uint256", name: "maxExposure", type: "uint256" },
547
+ {
548
+ internalType: "uint256",
549
+ name: "currentExposure",
550
+ type: "uint256",
551
+ },
552
+ ],
553
+ internalType: "struct Collateral",
554
+ name: "collateral",
555
+ type: "tuple",
556
+ },
557
+ {
558
+ internalType: "uint256",
559
+ name: "collateralAmount",
560
+ type: "uint256",
561
+ },
562
+ { internalType: "uint256", name: "timestamp", type: "uint256" },
563
+ { internalType: "address", name: "borrower", type: "address" },
564
+ { internalType: "uint256", name: "userPaid", type: "uint256" },
565
+ ],
566
+ internalType: "struct Loan[]",
567
+ name: "",
568
+ type: "tuple[]",
569
+ },
570
+ ],
571
+ stateMutability: "view",
572
+ type: "function",
573
+ },
574
+ {
575
+ inputs: [
576
+ { internalType: "address", name: "collateralAddress", type: "address" },
577
+ ],
578
+ name: "getCollateralExposure",
579
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
580
+ stateMutability: "view",
581
+ type: "function",
582
+ },
583
+ {
584
+ inputs: [
585
+ { internalType: "address", name: "collateralAddress", type: "address" },
586
+ ],
587
+ name: "getAvailableExposure",
588
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
589
+ stateMutability: "view",
590
+ type: "function",
591
+ },
592
+ {
593
+ inputs: [
594
+ { internalType: "address", name: "collateralAddress", type: "address" },
595
+ { internalType: "uint256", name: "_interestRate", type: "uint256" },
596
+ { internalType: "uint256", name: "maxLendPerToken", type: "uint256" },
597
+ { internalType: "uint256", name: "minAmount", type: "uint256" },
598
+ { internalType: "uint256", name: "maxExposure", type: "uint256" },
599
+ ],
600
+ name: "addCollateral",
601
+ outputs: [],
602
+ stateMutability: "nonpayable",
603
+ type: "function",
604
+ },
605
+ {
606
+ inputs: [
607
+ { internalType: "address", name: "collateralAddress", type: "address" },
608
+ { internalType: "uint256", name: "newMaxExposure", type: "uint256" },
609
+ ],
610
+ name: "updateMaxExposure",
611
+ outputs: [],
612
+ stateMutability: "nonpayable",
613
+ type: "function",
614
+ },
615
+ {
616
+ anonymous: false,
617
+ inputs: [
618
+ {
619
+ indexed: false,
620
+ internalType: "address",
621
+ name: "collateralAddress",
622
+ type: "address",
623
+ },
624
+ {
625
+ indexed: false,
626
+ internalType: "uint256",
627
+ name: "currentExposure",
628
+ type: "uint256",
629
+ },
630
+ ],
631
+ name: "ExposureUpdated",
632
+ type: "event",
633
+ },
634
+ {
635
+ anonymous: false,
636
+ inputs: [
637
+ {
638
+ indexed: false,
639
+ internalType: "address",
640
+ name: "collateralAddress",
641
+ type: "address",
642
+ },
643
+ {
644
+ indexed: false,
645
+ internalType: "uint256",
646
+ name: "oldMaxExposure",
647
+ type: "uint256",
648
+ },
649
+ {
650
+ indexed: false,
651
+ internalType: "uint256",
652
+ name: "newMaxExposure",
653
+ type: "uint256",
654
+ },
655
+ ],
656
+ name: "MaxExposureUpdated",
657
+ type: "event",
658
+ },
443
659
  ];
package/dist/index.d.mts CHANGED
@@ -2641,6 +2641,8 @@ interface Collateral {
2641
2641
  interestRate: bigint;
2642
2642
  active: boolean;
2643
2643
  minAmount: bigint;
2644
+ maxExposure: bigint;
2645
+ currentExposure: bigint;
2644
2646
  }
2645
2647
  interface Loan {
2646
2648
  id: bigint;
@@ -2658,6 +2660,8 @@ interface BuyEvent {
2658
2660
  openingPositionSize: bigint;
2659
2661
  collateralAmount: bigint;
2660
2662
  initialMargin: bigint;
2663
+ transactionHash: string;
2664
+ timestamp: number;
2661
2665
  }
2662
2666
  interface SellEvent {
2663
2667
  trader: string;
@@ -2665,6 +2669,8 @@ interface SellEvent {
2665
2669
  loanId: bigint;
2666
2670
  closingPositionSize: bigint;
2667
2671
  profit: bigint;
2672
+ transactionHash: string;
2673
+ timestamp: number;
2668
2674
  }
2669
2675
  interface LiquidationEvent {
2670
2676
  trader: string;
@@ -2672,6 +2678,8 @@ interface LiquidationEvent {
2672
2678
  loanId: bigint;
2673
2679
  closingPositionSize: bigint;
2674
2680
  liquidatorRepaidAmount: bigint;
2681
+ transactionHash: string;
2682
+ timestamp: number;
2675
2683
  }
2676
2684
 
2677
2685
  /**
@@ -2767,6 +2775,67 @@ declare function getOffersEvm(provider: Provider, tokenHolderContractAddress: st
2767
2775
  address: string;
2768
2776
  collateral: Collateral;
2769
2777
  }>>;
2778
+ /**
2779
+ * Get the opening fee percentage
2780
+ * @param provider - Ethers provider
2781
+ * @param borrowerOpsContractAddress - BorrowerOperations contract address
2782
+ * @returns Opening fee as a BigNumber
2783
+ */
2784
+ declare function getOpeningFeeEvm(provider: Provider, borrowerOpsContractAddress: string): Promise<bigint>;
2785
+ /**
2786
+ * Get the profit fee percentage
2787
+ * @param provider - Ethers provider
2788
+ * @param borrowerOpsContractAddress - BorrowerOperations contract address
2789
+ * @returns Profit fee as a BigNumber
2790
+ */
2791
+ declare function getProfitFeeEvm(provider: Provider, borrowerOpsContractAddress: string): Promise<bigint>;
2792
+ /**
2793
+ * Get the token balance of the token holder contract
2794
+ * @param provider - Ethers provider
2795
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2796
+ * @returns Token balance as a BigNumber
2797
+ */
2798
+ declare function getTokenBalanceEvm(provider: Provider, tokenHolderContractAddress: string): Promise<bigint>;
2799
+ /**
2800
+ * Get the active loan count
2801
+ * @param provider - Ethers provider
2802
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2803
+ * @returns Number of active loans
2804
+ */
2805
+ declare function getActiveLoanCountEvm(provider: Provider, tokenHolderContractAddress: string): Promise<bigint>;
2806
+ /**
2807
+ * Get a batch of active loans
2808
+ * @param provider - Ethers provider
2809
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2810
+ * @param startIndex - Starting index in the activeLoanIds array
2811
+ * @param batchSize - Number of loans to retrieve
2812
+ * @returns Array of active loans
2813
+ */
2814
+ declare function getActiveLoansBatchEvm(provider: Provider, tokenHolderContractAddress: string, startIndex: BigNumberish, batchSize: BigNumberish): Promise<Loan[]>;
2815
+ /**
2816
+ * Get all loans for a specific borrower
2817
+ * @param provider - Ethers provider
2818
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2819
+ * @param borrowerAddress - Address of the borrower
2820
+ * @returns Array of loans belonging to the borrower
2821
+ */
2822
+ declare function getLoansByBorrowerEvm(provider: Provider, tokenHolderContractAddress: string, borrowerAddress: string): Promise<Loan[]>;
2823
+ /**
2824
+ * Get current exposure for a collateral
2825
+ * @param provider - Ethers provider
2826
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2827
+ * @param collateralAddress - Address of the collateral token
2828
+ * @returns Current exposure as a BigNumber
2829
+ */
2830
+ declare function getCollateralExposureEvm(provider: Provider, tokenHolderContractAddress: string, collateralAddress: string): Promise<bigint>;
2831
+ /**
2832
+ * Get available exposure for a collateral
2833
+ * @param provider - Ethers provider
2834
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2835
+ * @param collateralAddress - Address of the collateral token
2836
+ * @returns Available exposure as a BigNumber
2837
+ */
2838
+ declare function getAvailableExposureEvm(provider: Provider, tokenHolderContractAddress: string, collateralAddress: string): Promise<bigint>;
2770
2839
 
2771
2840
  declare function getPda(seed: Buffer | Buffer[], programId: PublicKey): PublicKey;
2772
2841
  declare function getPositionAccountPDA(lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, offer: ProgramAccount, seed: PublicKey): PublicKey;
@@ -2969,4 +3038,4 @@ declare const mergePositionV2: (lavarageProgram: Program<Lavarage>, position1: P
2969
3038
  collateralType: PublicKey;
2970
3039
  }>, quoteToken: PublicKey) => Promise<VersionedTransaction>;
2971
3040
 
2972
- export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closePositionEvm, closeTradeV1, closeTradeV2, createTpDelegate, getAllPositions, getClosedPositions, getClosedPositionsEvm, getCollateralInfoEvm, getDelegateAccounts, getLiquidatedPositions, getLiquidatedPositionsEvm, getLoanEvm, getOffers, getOffersEvm, getOpenPositions, getPda, getPositionAccountPDA, getPositionsEvm, getUserLoansEvm, mergePositionV2, modifyTpDelegate, openPositionEvm, openTradeV1, openTradeV2, partialRepayV1, partialRepayV2, removeTpDelegate, splitPositionV2 };
3041
+ export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closePositionEvm, closeTradeV1, closeTradeV2, createTpDelegate, getActiveLoanCountEvm, getActiveLoansBatchEvm, getAllPositions, getAvailableExposureEvm, getClosedPositions, getClosedPositionsEvm, getCollateralExposureEvm, getCollateralInfoEvm, getDelegateAccounts, getLiquidatedPositions, getLiquidatedPositionsEvm, getLoanEvm, getLoansByBorrowerEvm, getOffers, getOffersEvm, getOpenPositions, getOpeningFeeEvm, getPda, getPositionAccountPDA, getPositionsEvm, getProfitFeeEvm, getTokenBalanceEvm, getUserLoansEvm, mergePositionV2, modifyTpDelegate, openPositionEvm, openTradeV1, openTradeV2, partialRepayV1, partialRepayV2, removeTpDelegate, splitPositionV2 };
package/dist/index.d.ts CHANGED
@@ -2641,6 +2641,8 @@ interface Collateral {
2641
2641
  interestRate: bigint;
2642
2642
  active: boolean;
2643
2643
  minAmount: bigint;
2644
+ maxExposure: bigint;
2645
+ currentExposure: bigint;
2644
2646
  }
2645
2647
  interface Loan {
2646
2648
  id: bigint;
@@ -2658,6 +2660,8 @@ interface BuyEvent {
2658
2660
  openingPositionSize: bigint;
2659
2661
  collateralAmount: bigint;
2660
2662
  initialMargin: bigint;
2663
+ transactionHash: string;
2664
+ timestamp: number;
2661
2665
  }
2662
2666
  interface SellEvent {
2663
2667
  trader: string;
@@ -2665,6 +2669,8 @@ interface SellEvent {
2665
2669
  loanId: bigint;
2666
2670
  closingPositionSize: bigint;
2667
2671
  profit: bigint;
2672
+ transactionHash: string;
2673
+ timestamp: number;
2668
2674
  }
2669
2675
  interface LiquidationEvent {
2670
2676
  trader: string;
@@ -2672,6 +2678,8 @@ interface LiquidationEvent {
2672
2678
  loanId: bigint;
2673
2679
  closingPositionSize: bigint;
2674
2680
  liquidatorRepaidAmount: bigint;
2681
+ transactionHash: string;
2682
+ timestamp: number;
2675
2683
  }
2676
2684
 
2677
2685
  /**
@@ -2767,6 +2775,67 @@ declare function getOffersEvm(provider: Provider, tokenHolderContractAddress: st
2767
2775
  address: string;
2768
2776
  collateral: Collateral;
2769
2777
  }>>;
2778
+ /**
2779
+ * Get the opening fee percentage
2780
+ * @param provider - Ethers provider
2781
+ * @param borrowerOpsContractAddress - BorrowerOperations contract address
2782
+ * @returns Opening fee as a BigNumber
2783
+ */
2784
+ declare function getOpeningFeeEvm(provider: Provider, borrowerOpsContractAddress: string): Promise<bigint>;
2785
+ /**
2786
+ * Get the profit fee percentage
2787
+ * @param provider - Ethers provider
2788
+ * @param borrowerOpsContractAddress - BorrowerOperations contract address
2789
+ * @returns Profit fee as a BigNumber
2790
+ */
2791
+ declare function getProfitFeeEvm(provider: Provider, borrowerOpsContractAddress: string): Promise<bigint>;
2792
+ /**
2793
+ * Get the token balance of the token holder contract
2794
+ * @param provider - Ethers provider
2795
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2796
+ * @returns Token balance as a BigNumber
2797
+ */
2798
+ declare function getTokenBalanceEvm(provider: Provider, tokenHolderContractAddress: string): Promise<bigint>;
2799
+ /**
2800
+ * Get the active loan count
2801
+ * @param provider - Ethers provider
2802
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2803
+ * @returns Number of active loans
2804
+ */
2805
+ declare function getActiveLoanCountEvm(provider: Provider, tokenHolderContractAddress: string): Promise<bigint>;
2806
+ /**
2807
+ * Get a batch of active loans
2808
+ * @param provider - Ethers provider
2809
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2810
+ * @param startIndex - Starting index in the activeLoanIds array
2811
+ * @param batchSize - Number of loans to retrieve
2812
+ * @returns Array of active loans
2813
+ */
2814
+ declare function getActiveLoansBatchEvm(provider: Provider, tokenHolderContractAddress: string, startIndex: BigNumberish, batchSize: BigNumberish): Promise<Loan[]>;
2815
+ /**
2816
+ * Get all loans for a specific borrower
2817
+ * @param provider - Ethers provider
2818
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2819
+ * @param borrowerAddress - Address of the borrower
2820
+ * @returns Array of loans belonging to the borrower
2821
+ */
2822
+ declare function getLoansByBorrowerEvm(provider: Provider, tokenHolderContractAddress: string, borrowerAddress: string): Promise<Loan[]>;
2823
+ /**
2824
+ * Get current exposure for a collateral
2825
+ * @param provider - Ethers provider
2826
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2827
+ * @param collateralAddress - Address of the collateral token
2828
+ * @returns Current exposure as a BigNumber
2829
+ */
2830
+ declare function getCollateralExposureEvm(provider: Provider, tokenHolderContractAddress: string, collateralAddress: string): Promise<bigint>;
2831
+ /**
2832
+ * Get available exposure for a collateral
2833
+ * @param provider - Ethers provider
2834
+ * @param tokenHolderContractAddress - Address of the TokenHolder contract
2835
+ * @param collateralAddress - Address of the collateral token
2836
+ * @returns Available exposure as a BigNumber
2837
+ */
2838
+ declare function getAvailableExposureEvm(provider: Provider, tokenHolderContractAddress: string, collateralAddress: string): Promise<bigint>;
2770
2839
 
2771
2840
  declare function getPda(seed: Buffer | Buffer[], programId: PublicKey): PublicKey;
2772
2841
  declare function getPositionAccountPDA(lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, offer: ProgramAccount, seed: PublicKey): PublicKey;
@@ -2969,4 +3038,4 @@ declare const mergePositionV2: (lavarageProgram: Program<Lavarage>, position1: P
2969
3038
  collateralType: PublicKey;
2970
3039
  }>, quoteToken: PublicKey) => Promise<VersionedTransaction>;
2971
3040
 
2972
- export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closePositionEvm, closeTradeV1, closeTradeV2, createTpDelegate, getAllPositions, getClosedPositions, getClosedPositionsEvm, getCollateralInfoEvm, getDelegateAccounts, getLiquidatedPositions, getLiquidatedPositionsEvm, getLoanEvm, getOffers, getOffersEvm, getOpenPositions, getPda, getPositionAccountPDA, getPositionsEvm, getUserLoansEvm, mergePositionV2, modifyTpDelegate, openPositionEvm, openTradeV1, openTradeV2, partialRepayV1, partialRepayV2, removeTpDelegate, splitPositionV2 };
3041
+ export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closePositionEvm, closeTradeV1, closeTradeV2, createTpDelegate, getActiveLoanCountEvm, getActiveLoansBatchEvm, getAllPositions, getAvailableExposureEvm, getClosedPositions, getClosedPositionsEvm, getCollateralExposureEvm, getCollateralInfoEvm, getDelegateAccounts, getLiquidatedPositions, getLiquidatedPositionsEvm, getLoanEvm, getLoansByBorrowerEvm, getOffers, getOffersEvm, getOpenPositions, getOpeningFeeEvm, getPda, getPositionAccountPDA, getPositionsEvm, getProfitFeeEvm, getTokenBalanceEvm, getUserLoansEvm, mergePositionV2, modifyTpDelegate, openPositionEvm, openTradeV1, openTradeV2, partialRepayV1, partialRepayV2, removeTpDelegate, splitPositionV2 };