@carrot-protocol/clend-rpc 0.1.26 → 0.1.27-group-refactor1-dev-5488543

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/rpc.d.ts CHANGED
@@ -1,38 +1,26 @@
1
1
  import { AnchorProvider, Wallet, web3, BN } from "@coral-xyz/anchor";
2
- import Decimal from "decimal.js";
3
2
  import { Instructions, GroupConfig } from "./instructions";
4
- import { BankConfigCompact, ClendGroup, Bank, ClendAccount, FeeState, InterestRateConfigCompact, InterestRateConfigOpt, BankOperationalState } from "./state";
5
- import { IJupiterUtils, SwapInputs, SwapQuote, SwapIxs } from "./jupiterUtils";
6
- import { QuoteResponse, SwapMode } from "@jup-ag/api";
3
+ import { BankConfigCompact, ClendGroup, Bank, ClendAccount, FeeState, InterestRateConfigCompact, InterestRateConfigOpt, BankOperationalState, OracleSetupArgs } from "./state";
7
4
  import { ClendEvents } from "./events";
5
+ import { ISwapper } from "./swapper";
8
6
  export declare class ClendClient {
9
7
  readonly connection: web3.Connection;
10
8
  readonly instructions: Instructions;
11
9
  readonly events: ClendEvents;
12
10
  readonly provider: AnchorProvider;
13
- private jupiterUtils;
11
+ private swapper;
14
12
  private dryRun;
15
13
  private cuFeeInMicroLamports;
16
14
  private mintOracleMapping;
17
- constructor(connection: web3.Connection, wallet: Wallet, skipPreflight: boolean, cuFeeInMicroLamports: number, jupiterUtils?: IJupiterUtils, dryRun?: boolean, mintOracleMapping?: Map<string, string>);
15
+ constructor(connection: web3.Connection, wallet: Wallet, skipPreflight: boolean, cuFeeInMicroLamports: number, defaultSwapper?: ISwapper, dryRun?: boolean, mintOracleMapping?: Map<string, string>);
18
16
  address(): web3.PublicKey;
19
- /**
20
- * Get Jupiter price for a token pair
21
- */
22
- getJupiterPrice(mint: web3.PublicKey): Promise<number>;
17
+ getOraclePrice(mint: web3.PublicKey): Promise<number>;
23
18
  /**
24
19
  * Get pyth oracle price for a token
25
20
  */
26
- getOraclePrice(mint: web3.PublicKey): Promise<number>;
21
+ getPythOraclePrice(mint: web3.PublicKey): Promise<number>;
22
+ getSBOraclePrice(mint: web3.PublicKey): Promise<number>;
27
23
  getOracle(mint: web3.PublicKey): web3.PublicKey;
28
- /**
29
- * Get Jupiter quote for a swap
30
- */
31
- getJupiterQuote(inputMint: web3.PublicKey, outputMint: web3.PublicKey, inputMintDecimals: number, outputMintDecimals: number, inputAmountLamports: Decimal, slippageBps: number, swapMode?: SwapMode): Promise<SwapQuote<QuoteResponse>>;
32
- /**
33
- * Get Jupiter swap instructions
34
- */
35
- getJupiterSwap(payer: web3.PublicKey, inputs: SwapInputs, quote: SwapQuote<QuoteResponse>): Promise<SwapIxs>;
36
24
  send(ixns: web3.TransactionInstruction[], additionalSigners?: web3.Signer[], additionalLuts?: web3.PublicKey[]): Promise<string>;
37
25
  confirmTx(txSig: string): Promise<void>;
38
26
  initializeGroup(clendGroup?: web3.Keypair): Promise<{
@@ -41,7 +29,7 @@ export declare class ClendClient {
41
29
  }>;
42
30
  configureGroup(clendGroup: web3.PublicKey, config: GroupConfig): Promise<string>;
43
31
  initGlobalFeeState(feeWallet: web3.PublicKey, bankInitFlatSolFee: number, programFeeFixed: BN, programFeeRate: BN): Promise<string>;
44
- addBank(clendGroup: web3.PublicKey, bankMint: web3.PublicKey, pythOracle: web3.PublicKey, pythOracleFeedId: web3.PublicKey, bankConfig: BankConfigCompact, interestRateConfig: InterestRateConfigCompact): Promise<{
32
+ addBank(clendGroup: web3.PublicKey, bankMint: web3.PublicKey, oracleSetupArgs: OracleSetupArgs, bankConfig: BankConfigCompact, interestRateConfig: InterestRateConfigCompact): Promise<{
45
33
  bank: web3.PublicKey;
46
34
  txSig: string;
47
35
  }>;
@@ -63,8 +51,9 @@ export declare class ClendClient {
63
51
  editGlobalFeeState(clendGroup: web3.PublicKey, newGlobalFeeWallet: web3.PublicKey | null, newBankInitFlatSolFee: number | null, newProgramFeeFixed: number | null, newProgramFeeRate: number | null): Promise<string>;
64
52
  collectBankFees(clendGroup: web3.PublicKey, mint: web3.PublicKey): Promise<string>;
65
53
  resetBankFees(bank: web3.PublicKey): Promise<string>;
66
- liquidateClendAccountWithFlashLoan(liquidatorClendAccount: ClendAccount, liquidateeClendAccount: ClendAccount, assetBankData: Bank, liabBankData: Bank, targetOnChainMaintenanceHealthValue: number, slippageBps: number, marginfiLiabFlashLoanBank: web3.PublicKey, liquidatorMarginfiAccount: web3.PublicKey, additionalIxnCount?: number): Promise<string | undefined>;
67
- liquidateClendAccount(liquidatorClendAccount: ClendAccount, liquidateeClendAccount: ClendAccount, assetBankData: Bank, liabBankData: Bank, targetOnChainMaintenanceHealthValue: number, slippageBps: number): Promise<string | undefined>;
54
+ liquidateClendAccountWithFlashLoan(liquidatorClendAccount: ClendAccount, liquidateeClendAccount: ClendAccount, assetBankData: Bank, liabBankData: Bank, targetOnChainMaintenanceHealthValue: number, slippageBps: number, marginfiLiabFlashLoanBank: web3.PublicKey, liquidatorMarginfiAccount: web3.PublicKey, additionalIxnCount?: number, // used to calculate the end flash loan index
55
+ swapperOverride?: ISwapper): Promise<string | undefined>;
56
+ liquidateClendAccount(liquidatorClendAccount: ClendAccount, liquidateeClendAccount: ClendAccount, assetBankData: Bank, liabBankData: Bank, targetOnChainMaintenanceHealthValue: number, slippageBps: number, swapperOverride?: ISwapper): Promise<string | undefined>;
68
57
  /**
69
58
  * Creates instructions to liquidate an unhealthy Clend account.
70
59
  * Aims to bring the liquidatee's on-chain maintenance health to the targetOnChainMaintenanceHealthValue.
@@ -83,7 +72,7 @@ export declare class ClendClient {
83
72
  * Must be <= 0.
84
73
  * returns: instructions, luts, deposit amount (libaility token)
85
74
  */
86
- getLiquidateClendAccountIxns(liquidatorClendAccount: ClendAccount, liquidateeClendAccount: ClendAccount, assetBankData: Bank, liabBankData: Bank, targetOnChainMaintenanceHealthValue: number, slippageBps: number): Promise<{
75
+ getLiquidateClendAccountIxns(liquidatorClendAccount: ClendAccount, liquidateeClendAccount: ClendAccount, assetBankData: Bank, liabBankData: Bank, targetOnChainMaintenanceHealthValue: number, slippageBps: number, swapperOverride?: ISwapper): Promise<{
87
76
  ixns: web3.TransactionInstruction[];
88
77
  luts: web3.PublicKey[];
89
78
  depositAmount: BN;
@@ -96,16 +85,18 @@ export declare class ClendClient {
96
85
  configureBankOracleMaxAge(clendGroup: web3.PublicKey, bank: web3.PublicKey, maxAge: number): Promise<string>;
97
86
  configureBankOracle(bank: web3.PublicKey, pythOracle: web3.PublicKey, pythOracleFeed: web3.PublicKey): Promise<string>;
98
87
  setBankOperationalState(clendGroup: web3.PublicKey, bank: web3.PublicKey, operationalState: BankOperationalState): Promise<string>;
99
- depositLeverage(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey | null, selectedMint: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, depositAmount: BN, targetLeverage: number, slippageBps: number): Promise<string>;
88
+ depositLeverage(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey | null, selectedMint: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, depositAmount: BN, targetLeverage: number, slippageBps: number, swapperOverride?: ISwapper): Promise<string>;
100
89
  getDepositLeverageFromDebtIxns(clendGroup: web3.PublicKey, user: web3.PublicKey, clendAccount: web3.PublicKey | null, collateralMint: web3.PublicKey, // e.g., JLP
101
90
  debtMint: web3.PublicKey, // e.g., USDC
102
- debtMintDecimals: number, collateralMintDecimals: number, initialUserDebtContributionForSwap: BN, finalLoopBorrowAmount: BN, slippageBps: number, additionalIxnCount: number): Promise<{
91
+ debtMintDecimals: number, collateralMintDecimals: number, initialUserDebtContributionForSwap: BN, finalLoopBorrowAmount: BN, slippageBps: number, additionalIxnCount: number, // For JIT liquidity, etc.
92
+ swapperOverride?: ISwapper): Promise<{
103
93
  clendAccount: web3.PublicKey;
104
94
  ixns: web3.TransactionInstruction[];
105
95
  luts: web3.PublicKey[];
106
96
  additionalSigners: web3.Keypair[];
107
97
  }>;
108
- getDepositLeverageFromCollateralIxns(clendGroup: web3.PublicKey, user: web3.PublicKey, clendAccount: web3.PublicKey | null, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, debtMintDecimals: number, collateralMintDecimals: number, borrowAmount: BN, depositAmount: BN, slippageBps: number, additionalIxnCount: number): Promise<{
98
+ getDepositLeverageFromCollateralIxns(clendGroup: web3.PublicKey, user: web3.PublicKey, clendAccount: web3.PublicKey | null, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, debtMintDecimals: number, collateralMintDecimals: number, borrowAmount: BN, depositAmount: BN, slippageBps: number, additionalIxnCount: number, // used to correctly offset the flash loan index
99
+ swapperOverride?: ISwapper): Promise<{
109
100
  clendAccount: web3.PublicKey;
110
101
  ixns: web3.TransactionInstruction[];
111
102
  luts: web3.PublicKey[];
@@ -139,34 +130,34 @@ export declare class ClendClient {
139
130
  getDepositLeverageFromDebtParams(clendGroup: web3.PublicKey, collateralMint: web3.PublicKey, // The asset being leveraged (e.g., JLP)
140
131
  debtMint: web3.PublicKey, // The asset provided initially by the user (e.g., USDC)
141
132
  initialUserDebtContributionForSwap: BN, // User's initial DEBT token for the swap
142
- targetLeverage: number, slippageBps: number): Promise<{
133
+ targetLeverage: number, slippageBps: number, swapperOverride?: ISwapper): Promise<{
143
134
  borrowAmount: BN;
144
135
  totalDepositAmount: BN;
145
136
  debtBankData: Bank;
146
137
  collateralBankData: Bank;
147
138
  }>;
148
- withdrawLeverage(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, selectedMint: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, withdrawAmount: BN, withdrawAll: boolean, slippageBps: number): Promise<string>;
149
- getWithdrawLeverageCollateralIxns(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, collateralDecimals: number, debtDecimals: number, withdrawAll: boolean, debtToRepay: BN, collateralToWithdraw: BN, slippageBps: number, additionalIxnCount: number): Promise<{
139
+ withdrawLeverage(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, selectedMint: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, withdrawAmount: BN, withdrawAll: boolean, slippageBps: number, swapperOverride?: ISwapper): Promise<string>;
140
+ getWithdrawLeverageCollateralIxns(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, collateralDecimals: number, debtDecimals: number, withdrawAll: boolean, debtToRepay: BN, collateralToWithdraw: BN, slippageBps: number, additionalIxnCount: number, swapperOverride?: ISwapper): Promise<{
150
141
  ixns: web3.TransactionInstruction[];
151
142
  luts: web3.PublicKey[];
152
143
  }>;
153
- getWithdrawLeverageDebtIxns(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, collateralDecimals: number, debtDecimals: number, withdrawAll: boolean, debtToRepay: BN, collateralToWithdraw: BN, desiredNetDebtToReceive: BN, slippageBps: number, additionalIxnCount: number): Promise<{
144
+ getWithdrawLeverageDebtIxns(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, collateralDecimals: number, debtDecimals: number, withdrawAll: boolean, debtToRepay: BN, collateralToWithdraw: BN, desiredNetDebtToReceive: BN, slippageBps: number, additionalIxnCount: number, swapperOverride?: ISwapper): Promise<{
154
145
  ixns: web3.TransactionInstruction[];
155
146
  luts: web3.PublicKey[];
156
147
  }>;
157
- getNetWithdrawLeverageCollateralParams(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, desiredNetWithdraw: BN, withdrawAll: boolean, slippageBps: number): Promise<{
148
+ getNetWithdrawLeverageCollateralParams(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, desiredNetWithdraw: BN, withdrawAll: boolean, slippageBps: number, swapperOverride?: ISwapper): Promise<{
158
149
  debtToRepay: BN;
159
150
  collateralToWithdraw: BN;
160
151
  collateralBankData: Bank;
161
152
  debtBankData: Bank;
162
153
  }>;
163
- getNetWithdrawLeverageDebtParams(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, desiredNetWithdraw: BN, withdrawAll: boolean, slippageBps: number): Promise<{
154
+ getNetWithdrawLeverageDebtParams(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, desiredNetWithdraw: BN, withdrawAll: boolean, slippageBps: number, swapperOverride?: ISwapper): Promise<{
164
155
  debtToRepay: BN;
165
156
  collateralToWithdraw: BN;
166
157
  collateralBankData: Bank;
167
158
  debtBankData: Bank;
168
159
  }>;
169
- adjustLeverage(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, targetLeverage: number, slippageBps: number): Promise<string>;
160
+ adjustLeverage(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, targetLeverage: number, slippageBps: number, swapperOverride?: ISwapper): Promise<string>;
170
161
  /**
171
162
  * Calculates the required changes in debt and collateral to reach a target leverage.
172
163
  * Adjusts the deltas for fees, slippage, and interest buffers as appropriate.
@@ -211,7 +202,7 @@ export declare class ClendClient {
211
202
  */
212
203
  getAdjustLeverageIxns(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, user: web3.PublicKey, debtBankData: Bank, collateralBankData: Bank, isIncrease: boolean, finalDebtDeltaUi: number, // Use the final adjusted value from getAdjustLeverageParams
213
204
  finalCollateralDeltaUi: number, // Use the final adjusted value from getAdjustLeverageParams
214
- slippageBps: number, additionalIxnCount: number): Promise<{
205
+ slippageBps: number, additionalIxnCount: number, swapperOverride?: ISwapper): Promise<{
215
206
  ixns: web3.TransactionInstruction[];
216
207
  luts: web3.PublicKey[];
217
208
  }>;