@lavarage/sdk 6.4.6 → 6.5.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/abi/borrowerOperations.ts +248 -0
- package/abi/tokenHolderAbi.ts +443 -0
- package/dist/index.d.mts +131 -1
- package/dist/index.d.ts +131 -1
- package/dist/index.js +1409 -196
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1423 -198
- package/dist/index.mjs.map +1 -1
- package/evm.ts +318 -0
- package/index.ts +1295 -773
- package/interfaces/evm.ts +42 -0
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +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
4
|
|
|
4
5
|
type Lavarage$1 = {
|
|
5
6
|
"version": "0.1.0";
|
|
@@ -2634,6 +2635,135 @@ declare namespace lavaragev2 {
|
|
|
2634
2635
|
export { lavaragev2_IDL as IDL, type lavaragev2_Lavarage as Lavarage };
|
|
2635
2636
|
}
|
|
2636
2637
|
|
|
2638
|
+
interface Collateral {
|
|
2639
|
+
collateralAddress: string;
|
|
2640
|
+
maxLendPerToken: bigint;
|
|
2641
|
+
interestRate: bigint;
|
|
2642
|
+
active: boolean;
|
|
2643
|
+
minAmount: bigint;
|
|
2644
|
+
}
|
|
2645
|
+
interface Loan {
|
|
2646
|
+
id: bigint;
|
|
2647
|
+
amount: bigint;
|
|
2648
|
+
collateral: Collateral;
|
|
2649
|
+
collateralAmount: bigint;
|
|
2650
|
+
timestamp: bigint;
|
|
2651
|
+
borrower: string;
|
|
2652
|
+
userPaid: bigint;
|
|
2653
|
+
}
|
|
2654
|
+
interface BuyEvent {
|
|
2655
|
+
trader: string;
|
|
2656
|
+
tokenCollateral: string;
|
|
2657
|
+
loanId: bigint;
|
|
2658
|
+
openingPositionSize: bigint;
|
|
2659
|
+
collateralAmount: bigint;
|
|
2660
|
+
initialMargin: bigint;
|
|
2661
|
+
}
|
|
2662
|
+
interface SellEvent {
|
|
2663
|
+
trader: string;
|
|
2664
|
+
tokenCollateral: string;
|
|
2665
|
+
loanId: bigint;
|
|
2666
|
+
closingPositionSize: bigint;
|
|
2667
|
+
profit: bigint;
|
|
2668
|
+
}
|
|
2669
|
+
interface LiquidationEvent {
|
|
2670
|
+
trader: string;
|
|
2671
|
+
tokenCollateral: string;
|
|
2672
|
+
loanId: bigint;
|
|
2673
|
+
closingPositionSize: bigint;
|
|
2674
|
+
liquidatorRepaidAmount: bigint;
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
/**
|
|
2678
|
+
* Opens a trading position on EVM chain
|
|
2679
|
+
* @param signer - Ethers signer
|
|
2680
|
+
* @param borrowerOpsContractAddress - BorrowerOperations contract address
|
|
2681
|
+
* @param params - Trading parameters
|
|
2682
|
+
* @returns Transaction object
|
|
2683
|
+
*/
|
|
2684
|
+
declare const openPositionEvm: (signer: Signer, borrowerOpsContractAddress: string, { buyingCode, tokenCollateral, borrowAmount, tokenHolder, inchRouter, integratorFeeAddress, buyerContribution, }: {
|
|
2685
|
+
buyingCode: string;
|
|
2686
|
+
tokenCollateral: string;
|
|
2687
|
+
borrowAmount: BigNumberish;
|
|
2688
|
+
tokenHolder: string;
|
|
2689
|
+
inchRouter: string;
|
|
2690
|
+
integratorFeeAddress?: string;
|
|
2691
|
+
buyerContribution: BigNumberish;
|
|
2692
|
+
}) => Promise<ContractTransaction>;
|
|
2693
|
+
/**
|
|
2694
|
+
* Closes a trading position on EVM chain
|
|
2695
|
+
* @param signer - Ethers signer
|
|
2696
|
+
* @param borrowerOpsContractAddress - BorrowerOperations contract address
|
|
2697
|
+
* @param params - Trading parameters
|
|
2698
|
+
* @returns Transaction object
|
|
2699
|
+
*/
|
|
2700
|
+
declare const closePositionEvm: (signer: Signer, borrowerOpsContractAddress: string, { loanId, sellingCode, tokenHolder, inchRouter, integratorFeeAddress, }: {
|
|
2701
|
+
loanId: BigNumberish;
|
|
2702
|
+
sellingCode: string;
|
|
2703
|
+
tokenHolder: string;
|
|
2704
|
+
inchRouter: string;
|
|
2705
|
+
integratorFeeAddress?: string;
|
|
2706
|
+
}) => Promise<ContractTransaction>;
|
|
2707
|
+
/**
|
|
2708
|
+
* Get all positions from events
|
|
2709
|
+
* @param provider - Ethers provider
|
|
2710
|
+
* @param borrowerOpsContractAddress - BorrowerOperations contract address
|
|
2711
|
+
* @param fromBlock - Block to start searching from
|
|
2712
|
+
* @returns Array of Buy events representing positions
|
|
2713
|
+
*/
|
|
2714
|
+
declare function getPositionsEvm(provider: Provider, borrowerOpsContractAddress: string, fromBlock?: number): Promise<BuyEvent[]>;
|
|
2715
|
+
/**
|
|
2716
|
+
* Get closed positions from events
|
|
2717
|
+
* @param provider - Ethers provider
|
|
2718
|
+
* @param borrowerOpsContractAddress - BorrowerOperations contract address
|
|
2719
|
+
* @param fromBlock - Block to start searching from
|
|
2720
|
+
* @returns Array of Sell events representing closed positions
|
|
2721
|
+
*/
|
|
2722
|
+
declare function getClosedPositionsEvm(provider: Provider, borrowerOpsContractAddress: string, fromBlock?: number): Promise<SellEvent[]>;
|
|
2723
|
+
/**
|
|
2724
|
+
* Get liquidated positions from events
|
|
2725
|
+
* @param provider - Ethers provider
|
|
2726
|
+
* @param borrowerOpsContractAddress - BorrowerOperations contract address
|
|
2727
|
+
* @param fromBlock - Block to start searching from
|
|
2728
|
+
* @returns Array of Liquidation events representing liquidated positions
|
|
2729
|
+
*/
|
|
2730
|
+
declare function getLiquidatedPositionsEvm(provider: Provider, borrowerOpsContractAddress: string, fromBlock?: number): Promise<LiquidationEvent[]>;
|
|
2731
|
+
/**
|
|
2732
|
+
* Get a loan by its ID from TokenHolder contract
|
|
2733
|
+
* @param provider - Ethers provider
|
|
2734
|
+
* @param tokenHolderContractAddress - Address of the TokenHolder contract
|
|
2735
|
+
* @param loanId - ID of the loan to retrieve
|
|
2736
|
+
* @returns Loan object
|
|
2737
|
+
*/
|
|
2738
|
+
declare function getLoanEvm(provider: Provider, tokenHolderContractAddress: string, loanId: BigNumberish): Promise<Loan>;
|
|
2739
|
+
/**
|
|
2740
|
+
* Get all active loans for a user
|
|
2741
|
+
* @param provider - Ethers provider
|
|
2742
|
+
* @param tokenHolderContractAddress - Address of the TokenHolder contract
|
|
2743
|
+
* @param userAddress - Address of the user to get loans for
|
|
2744
|
+
* @returns Array of loans belonging to the user
|
|
2745
|
+
*/
|
|
2746
|
+
declare function getUserLoansEvm(provider: Provider, tokenHolderContractAddress: string, userAddress: string): Promise<Loan[]>;
|
|
2747
|
+
/**
|
|
2748
|
+
* Get collateral information for a specific token
|
|
2749
|
+
* @param provider - Ethers provider
|
|
2750
|
+
* @param tokenHolderContractAddress - Address of the TokenHolder contract
|
|
2751
|
+
* @param collateralAddress - Address of the collateral token
|
|
2752
|
+
* @returns Collateral object
|
|
2753
|
+
*/
|
|
2754
|
+
declare function getCollateralInfoEvm(provider: Provider, tokenHolderContractAddress: string, collateralAddress: string): Promise<Collateral>;
|
|
2755
|
+
/**
|
|
2756
|
+
* Get all available collateral information
|
|
2757
|
+
* @param provider - Ethers provider
|
|
2758
|
+
* @param tokenHolderContractAddress - Address of the TokenHolder contract
|
|
2759
|
+
* @param collateralAddresses - Array of collateral token addresses
|
|
2760
|
+
* @returns Array of active collaterals
|
|
2761
|
+
*/
|
|
2762
|
+
declare function getOffersEvm(provider: Provider, tokenHolderContractAddress: string, collateralAddresses: string[]): Promise<Array<{
|
|
2763
|
+
address: string;
|
|
2764
|
+
collateral: Collateral;
|
|
2765
|
+
}>>;
|
|
2766
|
+
|
|
2637
2767
|
declare function getPda(seed: Buffer | Buffer[], programId: PublicKey): PublicKey;
|
|
2638
2768
|
declare function getPositionAccountPDA(lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, offer: ProgramAccount, seed: PublicKey): PublicKey;
|
|
2639
2769
|
|
|
@@ -2835,4 +2965,4 @@ declare const mergePositionV2: (lavarageProgram: Program<Lavarage>, position1: P
|
|
|
2835
2965
|
collateralType: PublicKey;
|
|
2836
2966
|
}>, quoteToken: PublicKey) => Promise<VersionedTransaction>;
|
|
2837
2967
|
|
|
2838
|
-
export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closeTradeV1, closeTradeV2, createTpDelegate, getAllPositions, getClosedPositions, getDelegateAccounts, getLiquidatedPositions, getOffers, getOpenPositions, getPda, getPositionAccountPDA, mergePositionV2, modifyTpDelegate, openTradeV1, openTradeV2, partialRepayV1, partialRepayV2, removeTpDelegate, splitPositionV2 };
|
|
2968
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +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
4
|
|
|
4
5
|
type Lavarage$1 = {
|
|
5
6
|
"version": "0.1.0";
|
|
@@ -2634,6 +2635,135 @@ declare namespace lavaragev2 {
|
|
|
2634
2635
|
export { lavaragev2_IDL as IDL, type lavaragev2_Lavarage as Lavarage };
|
|
2635
2636
|
}
|
|
2636
2637
|
|
|
2638
|
+
interface Collateral {
|
|
2639
|
+
collateralAddress: string;
|
|
2640
|
+
maxLendPerToken: bigint;
|
|
2641
|
+
interestRate: bigint;
|
|
2642
|
+
active: boolean;
|
|
2643
|
+
minAmount: bigint;
|
|
2644
|
+
}
|
|
2645
|
+
interface Loan {
|
|
2646
|
+
id: bigint;
|
|
2647
|
+
amount: bigint;
|
|
2648
|
+
collateral: Collateral;
|
|
2649
|
+
collateralAmount: bigint;
|
|
2650
|
+
timestamp: bigint;
|
|
2651
|
+
borrower: string;
|
|
2652
|
+
userPaid: bigint;
|
|
2653
|
+
}
|
|
2654
|
+
interface BuyEvent {
|
|
2655
|
+
trader: string;
|
|
2656
|
+
tokenCollateral: string;
|
|
2657
|
+
loanId: bigint;
|
|
2658
|
+
openingPositionSize: bigint;
|
|
2659
|
+
collateralAmount: bigint;
|
|
2660
|
+
initialMargin: bigint;
|
|
2661
|
+
}
|
|
2662
|
+
interface SellEvent {
|
|
2663
|
+
trader: string;
|
|
2664
|
+
tokenCollateral: string;
|
|
2665
|
+
loanId: bigint;
|
|
2666
|
+
closingPositionSize: bigint;
|
|
2667
|
+
profit: bigint;
|
|
2668
|
+
}
|
|
2669
|
+
interface LiquidationEvent {
|
|
2670
|
+
trader: string;
|
|
2671
|
+
tokenCollateral: string;
|
|
2672
|
+
loanId: bigint;
|
|
2673
|
+
closingPositionSize: bigint;
|
|
2674
|
+
liquidatorRepaidAmount: bigint;
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
/**
|
|
2678
|
+
* Opens a trading position on EVM chain
|
|
2679
|
+
* @param signer - Ethers signer
|
|
2680
|
+
* @param borrowerOpsContractAddress - BorrowerOperations contract address
|
|
2681
|
+
* @param params - Trading parameters
|
|
2682
|
+
* @returns Transaction object
|
|
2683
|
+
*/
|
|
2684
|
+
declare const openPositionEvm: (signer: Signer, borrowerOpsContractAddress: string, { buyingCode, tokenCollateral, borrowAmount, tokenHolder, inchRouter, integratorFeeAddress, buyerContribution, }: {
|
|
2685
|
+
buyingCode: string;
|
|
2686
|
+
tokenCollateral: string;
|
|
2687
|
+
borrowAmount: BigNumberish;
|
|
2688
|
+
tokenHolder: string;
|
|
2689
|
+
inchRouter: string;
|
|
2690
|
+
integratorFeeAddress?: string;
|
|
2691
|
+
buyerContribution: BigNumberish;
|
|
2692
|
+
}) => Promise<ContractTransaction>;
|
|
2693
|
+
/**
|
|
2694
|
+
* Closes a trading position on EVM chain
|
|
2695
|
+
* @param signer - Ethers signer
|
|
2696
|
+
* @param borrowerOpsContractAddress - BorrowerOperations contract address
|
|
2697
|
+
* @param params - Trading parameters
|
|
2698
|
+
* @returns Transaction object
|
|
2699
|
+
*/
|
|
2700
|
+
declare const closePositionEvm: (signer: Signer, borrowerOpsContractAddress: string, { loanId, sellingCode, tokenHolder, inchRouter, integratorFeeAddress, }: {
|
|
2701
|
+
loanId: BigNumberish;
|
|
2702
|
+
sellingCode: string;
|
|
2703
|
+
tokenHolder: string;
|
|
2704
|
+
inchRouter: string;
|
|
2705
|
+
integratorFeeAddress?: string;
|
|
2706
|
+
}) => Promise<ContractTransaction>;
|
|
2707
|
+
/**
|
|
2708
|
+
* Get all positions from events
|
|
2709
|
+
* @param provider - Ethers provider
|
|
2710
|
+
* @param borrowerOpsContractAddress - BorrowerOperations contract address
|
|
2711
|
+
* @param fromBlock - Block to start searching from
|
|
2712
|
+
* @returns Array of Buy events representing positions
|
|
2713
|
+
*/
|
|
2714
|
+
declare function getPositionsEvm(provider: Provider, borrowerOpsContractAddress: string, fromBlock?: number): Promise<BuyEvent[]>;
|
|
2715
|
+
/**
|
|
2716
|
+
* Get closed positions from events
|
|
2717
|
+
* @param provider - Ethers provider
|
|
2718
|
+
* @param borrowerOpsContractAddress - BorrowerOperations contract address
|
|
2719
|
+
* @param fromBlock - Block to start searching from
|
|
2720
|
+
* @returns Array of Sell events representing closed positions
|
|
2721
|
+
*/
|
|
2722
|
+
declare function getClosedPositionsEvm(provider: Provider, borrowerOpsContractAddress: string, fromBlock?: number): Promise<SellEvent[]>;
|
|
2723
|
+
/**
|
|
2724
|
+
* Get liquidated positions from events
|
|
2725
|
+
* @param provider - Ethers provider
|
|
2726
|
+
* @param borrowerOpsContractAddress - BorrowerOperations contract address
|
|
2727
|
+
* @param fromBlock - Block to start searching from
|
|
2728
|
+
* @returns Array of Liquidation events representing liquidated positions
|
|
2729
|
+
*/
|
|
2730
|
+
declare function getLiquidatedPositionsEvm(provider: Provider, borrowerOpsContractAddress: string, fromBlock?: number): Promise<LiquidationEvent[]>;
|
|
2731
|
+
/**
|
|
2732
|
+
* Get a loan by its ID from TokenHolder contract
|
|
2733
|
+
* @param provider - Ethers provider
|
|
2734
|
+
* @param tokenHolderContractAddress - Address of the TokenHolder contract
|
|
2735
|
+
* @param loanId - ID of the loan to retrieve
|
|
2736
|
+
* @returns Loan object
|
|
2737
|
+
*/
|
|
2738
|
+
declare function getLoanEvm(provider: Provider, tokenHolderContractAddress: string, loanId: BigNumberish): Promise<Loan>;
|
|
2739
|
+
/**
|
|
2740
|
+
* Get all active loans for a user
|
|
2741
|
+
* @param provider - Ethers provider
|
|
2742
|
+
* @param tokenHolderContractAddress - Address of the TokenHolder contract
|
|
2743
|
+
* @param userAddress - Address of the user to get loans for
|
|
2744
|
+
* @returns Array of loans belonging to the user
|
|
2745
|
+
*/
|
|
2746
|
+
declare function getUserLoansEvm(provider: Provider, tokenHolderContractAddress: string, userAddress: string): Promise<Loan[]>;
|
|
2747
|
+
/**
|
|
2748
|
+
* Get collateral information for a specific token
|
|
2749
|
+
* @param provider - Ethers provider
|
|
2750
|
+
* @param tokenHolderContractAddress - Address of the TokenHolder contract
|
|
2751
|
+
* @param collateralAddress - Address of the collateral token
|
|
2752
|
+
* @returns Collateral object
|
|
2753
|
+
*/
|
|
2754
|
+
declare function getCollateralInfoEvm(provider: Provider, tokenHolderContractAddress: string, collateralAddress: string): Promise<Collateral>;
|
|
2755
|
+
/**
|
|
2756
|
+
* Get all available collateral information
|
|
2757
|
+
* @param provider - Ethers provider
|
|
2758
|
+
* @param tokenHolderContractAddress - Address of the TokenHolder contract
|
|
2759
|
+
* @param collateralAddresses - Array of collateral token addresses
|
|
2760
|
+
* @returns Array of active collaterals
|
|
2761
|
+
*/
|
|
2762
|
+
declare function getOffersEvm(provider: Provider, tokenHolderContractAddress: string, collateralAddresses: string[]): Promise<Array<{
|
|
2763
|
+
address: string;
|
|
2764
|
+
collateral: Collateral;
|
|
2765
|
+
}>>;
|
|
2766
|
+
|
|
2637
2767
|
declare function getPda(seed: Buffer | Buffer[], programId: PublicKey): PublicKey;
|
|
2638
2768
|
declare function getPositionAccountPDA(lavarageProgram: Program<Lavarage$1> | Program<Lavarage>, offer: ProgramAccount, seed: PublicKey): PublicKey;
|
|
2639
2769
|
|
|
@@ -2835,4 +2965,4 @@ declare const mergePositionV2: (lavarageProgram: Program<Lavarage>, position1: P
|
|
|
2835
2965
|
collateralType: PublicKey;
|
|
2836
2966
|
}>, quoteToken: PublicKey) => Promise<VersionedTransaction>;
|
|
2837
2967
|
|
|
2838
|
-
export { IDL$1 as IDL, lavaragev2 as IDLV2, type Lavarage$1 as Lavarage, closeTradeV1, closeTradeV2, createTpDelegate, getAllPositions, getClosedPositions, getDelegateAccounts, getLiquidatedPositions, getOffers, getOpenPositions, getPda, getPositionAccountPDA, mergePositionV2, modifyTpDelegate, openTradeV1, openTradeV2, partialRepayV1, partialRepayV2, removeTpDelegate, splitPositionV2 };
|
|
2968
|
+
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 };
|