@carrot-protocol/clend-rpc 0.1.26-p-withdraw-dev-e12dfc4 → 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/idl/clend.d.ts +4 -1
- package/dist/idl/clend.js +4 -1
- package/dist/idl/clend.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.ts +4 -3
- package/dist/instructions.js +31 -4
- package/dist/instructions.js.map +1 -1
- package/dist/rpc.d.ts +27 -34
- package/dist/rpc.js +282 -160
- package/dist/rpc.js.map +1 -1
- package/dist/state.d.ts +16 -1
- package/dist/state.js +11 -2
- package/dist/state.js.map +1 -1
- package/dist/swapper/index.d.ts +3 -0
- package/dist/swapper/index.js +8 -0
- package/dist/swapper/index.js.map +1 -0
- package/dist/swapper/interface.d.ts +58 -0
- package/dist/swapper/interface.js +3 -0
- package/dist/swapper/interface.js.map +1 -0
- package/dist/swapper/jupiterSwapper.d.ts +15 -0
- package/dist/swapper/jupiterSwapper.js +85 -0
- package/dist/swapper/jupiterSwapper.js.map +1 -0
- package/dist/swapper/mockJupiterSwapper.d.ts +19 -0
- package/dist/swapper/mockJupiterSwapper.js +89 -0
- package/dist/swapper/mockJupiterSwapper.js.map +1 -0
- package/dist/utils.d.ts +29 -0
- package/dist/utils.js +67 -0
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/jupiterUtils.d.ts +0 -65
- package/dist/jupiterUtils.js +0 -174
- package/dist/jupiterUtils.js.map +0 -1
- package/dist/mockJupiterUtils.d.ts +0 -54
- package/dist/mockJupiterUtils.js +0 -75
- package/dist/mockJupiterUtils.js.map +0 -1
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
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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
|
|
67
|
-
|
|
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,15 +85,19 @@ 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
|
|
91
|
+
debtMintDecimals: number, collateralMintDecimals: number, initialUserDebtContributionForSwap: BN, finalLoopBorrowAmount: BN, slippageBps: number, additionalIxnCount: number, // For JIT liquidity, etc.
|
|
92
|
+
swapperOverride?: ISwapper): Promise<{
|
|
93
|
+
clendAccount: web3.PublicKey;
|
|
103
94
|
ixns: web3.TransactionInstruction[];
|
|
104
95
|
luts: web3.PublicKey[];
|
|
105
96
|
additionalSigners: web3.Keypair[];
|
|
106
97
|
}>;
|
|
107
|
-
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
|
|
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<{
|
|
100
|
+
clendAccount: web3.PublicKey;
|
|
108
101
|
ixns: web3.TransactionInstruction[];
|
|
109
102
|
luts: web3.PublicKey[];
|
|
110
103
|
additionalSigners: web3.Keypair[];
|
|
@@ -137,34 +130,34 @@ export declare class ClendClient {
|
|
|
137
130
|
getDepositLeverageFromDebtParams(clendGroup: web3.PublicKey, collateralMint: web3.PublicKey, // The asset being leveraged (e.g., JLP)
|
|
138
131
|
debtMint: web3.PublicKey, // The asset provided initially by the user (e.g., USDC)
|
|
139
132
|
initialUserDebtContributionForSwap: BN, // User's initial DEBT token for the swap
|
|
140
|
-
targetLeverage: number, slippageBps: number): Promise<{
|
|
133
|
+
targetLeverage: number, slippageBps: number, swapperOverride?: ISwapper): Promise<{
|
|
141
134
|
borrowAmount: BN;
|
|
142
135
|
totalDepositAmount: BN;
|
|
143
136
|
debtBankData: Bank;
|
|
144
137
|
collateralBankData: Bank;
|
|
145
138
|
}>;
|
|
146
|
-
withdrawLeverage(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, selectedMint: web3.PublicKey, collateralMint: web3.PublicKey, debtMint: web3.PublicKey, withdrawAmount: BN, withdrawAll: boolean, slippageBps: number): Promise<string>;
|
|
147
|
-
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<{
|
|
148
141
|
ixns: web3.TransactionInstruction[];
|
|
149
142
|
luts: web3.PublicKey[];
|
|
150
143
|
}>;
|
|
151
|
-
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<{
|
|
152
145
|
ixns: web3.TransactionInstruction[];
|
|
153
146
|
luts: web3.PublicKey[];
|
|
154
147
|
}>;
|
|
155
|
-
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<{
|
|
156
149
|
debtToRepay: BN;
|
|
157
150
|
collateralToWithdraw: BN;
|
|
158
151
|
collateralBankData: Bank;
|
|
159
152
|
debtBankData: Bank;
|
|
160
153
|
}>;
|
|
161
|
-
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<{
|
|
162
155
|
debtToRepay: BN;
|
|
163
156
|
collateralToWithdraw: BN;
|
|
164
157
|
collateralBankData: Bank;
|
|
165
158
|
debtBankData: Bank;
|
|
166
159
|
}>;
|
|
167
|
-
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>;
|
|
168
161
|
/**
|
|
169
162
|
* Calculates the required changes in debt and collateral to reach a target leverage.
|
|
170
163
|
* Adjusts the deltas for fees, slippage, and interest buffers as appropriate.
|
|
@@ -209,7 +202,7 @@ export declare class ClendClient {
|
|
|
209
202
|
*/
|
|
210
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
|
|
211
204
|
finalCollateralDeltaUi: number, // Use the final adjusted value from getAdjustLeverageParams
|
|
212
|
-
slippageBps: number, additionalIxnCount: number): Promise<{
|
|
205
|
+
slippageBps: number, additionalIxnCount: number, swapperOverride?: ISwapper): Promise<{
|
|
213
206
|
ixns: web3.TransactionInstruction[];
|
|
214
207
|
luts: web3.PublicKey[];
|
|
215
208
|
}>;
|