@gearbox-protocol/sdk 14.1.1 → 14.2.1
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/cjs/dev/claimDSToken.js +208 -0
- package/dist/cjs/plugins/accounts/AccountsPlugin.js +1 -2
- package/dist/cjs/sdk/OnchainSDK.js +12 -0
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1448 -23
- package/dist/cjs/sdk/accounts/index.js +0 -4
- package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +6 -0
- package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +19 -2
- package/dist/cjs/sdk/market/kyc/securitize/types.js +20 -0
- package/dist/cjs/sdk/market/oracle/PriceOracleV310Contract.js +26 -0
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -0
- package/dist/esm/dev/claimDSToken.js +187 -0
- package/dist/esm/plugins/accounts/AccountsPlugin.js +2 -7
- package/dist/esm/sdk/OnchainSDK.js +14 -0
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1466 -23
- package/dist/esm/sdk/accounts/index.js +0 -2
- package/dist/esm/sdk/accounts/multicall-utils.js +1 -5
- package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +6 -0
- package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +21 -2
- package/dist/esm/sdk/market/kyc/securitize/types.js +12 -0
- package/dist/esm/sdk/market/oracle/PriceOracleV310Contract.js +26 -0
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -0
- package/dist/types/dev/claimDSToken.d.ts +34 -0
- package/dist/types/sdk/OnchainSDK.d.ts +10 -0
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +181 -3
- package/dist/types/sdk/accounts/index.d.ts +0 -2
- package/dist/types/sdk/accounts/types.d.ts +56 -0
- package/dist/types/sdk/market/credit/CreditFacadeV310Contract.d.ts +2 -0
- package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +1 -1
- package/dist/types/sdk/market/kyc/securitize/types.d.ts +37 -22
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +5 -0
- package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +4 -0
- package/dist/types/sdk/market/oracle/types.d.ts +9 -0
- package/dist/types/sdk/pools/types.d.ts +19 -0
- package/package.json +1 -1
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +0 -1411
- package/dist/cjs/sdk/accounts/createCreditAccountService.js +0 -35
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +0 -1405
- package/dist/esm/sdk/accounts/createCreditAccountService.js +0 -11
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +0 -226
- package/dist/types/sdk/accounts/createCreditAccountService.d.ts +0 -9
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isV310 } from "../constants/index.js";
|
|
2
|
-
import { CreditAccountServiceV310 } from "./CreditAccountsServiceV310.js";
|
|
3
|
-
function createCreditAccountService(sdk, version, options) {
|
|
4
|
-
if (isV310(version)) {
|
|
5
|
-
return new CreditAccountServiceV310(sdk, options);
|
|
6
|
-
}
|
|
7
|
-
throw new Error(`Unsupported Credit Account Service version ${version}`);
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
createCreditAccountService
|
|
11
|
-
};
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type { CreditAccountData } from "../base/index.js";
|
|
3
|
-
import { SDKConstruct } from "../base/index.js";
|
|
4
|
-
import type { CreditSuite, KYCOperationParams } from "../market/index.js";
|
|
5
|
-
import { type PriceUpdate, type UpdatePriceFeedsResult } from "../market/index.js";
|
|
6
|
-
import { type KYCOpenAccountRequirements } from "../market/kyc/index.js";
|
|
7
|
-
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
8
|
-
import { type Asset, type RouterCASlice } from "../router/index.js";
|
|
9
|
-
import type { MultiCall, RawTx } from "../types/index.js";
|
|
10
|
-
import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CloseOptions, CreditAccountOperationResult, CreditAccountTokensSlice, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, Rewards, StartDelayedWithdrawalProps, UpdateQuotasProps } from "./types.js";
|
|
11
|
-
/**
|
|
12
|
-
* Options for configuring the credit account service.
|
|
13
|
-
**/
|
|
14
|
-
export interface CreditAccountServiceOptions {
|
|
15
|
-
/**
|
|
16
|
-
* Maximum number of credit accounts to fetch per compressor call.
|
|
17
|
-
* When set, accounts are loaded in batches of this size until all are fetched.
|
|
18
|
-
**/
|
|
19
|
-
batchSize?: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Returns the withdrawal compressor contract address for the given chain, or `undefined` if none is configured.
|
|
23
|
-
* @param chainId - Numeric chain ID.
|
|
24
|
-
* @returns Withdrawal compressor address, or `undefined`.
|
|
25
|
-
**/
|
|
26
|
-
export declare function getWithdrawalCompressorAddress(chainId: number): `0x${string}`;
|
|
27
|
-
/**
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
|
-
export declare abstract class AbstractCreditAccountService extends SDKConstruct {
|
|
31
|
-
#private;
|
|
32
|
-
constructor(sdk: OnchainSDK, options?: CreditAccountServiceOptions);
|
|
33
|
-
/**
|
|
34
|
-
* {@inheritDoc ICreditAccountsService.getCreditAccountData}
|
|
35
|
-
**/
|
|
36
|
-
getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData<true> | undefined>;
|
|
37
|
-
/**
|
|
38
|
-
* {@inheritDoc ICreditAccountsService.getCreditAccounts}
|
|
39
|
-
**/
|
|
40
|
-
getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData>>;
|
|
41
|
-
/**
|
|
42
|
-
* {@inheritDoc ICreditAccountsService.getBorrowerCreditAccounts}
|
|
43
|
-
**/
|
|
44
|
-
getBorrowerCreditAccounts(borrower: Address, options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData<true>>>;
|
|
45
|
-
/**
|
|
46
|
-
* {@inheritDoc ICreditAccountsService.getRewards}
|
|
47
|
-
**/
|
|
48
|
-
getRewards(creditAccount: Address): Promise<Array<Rewards>>;
|
|
49
|
-
/**
|
|
50
|
-
* {@inheritDoc ICreditAccountsService.getConnectedBots}
|
|
51
|
-
**/
|
|
52
|
-
getConnectedBots(accountsToCheck: Array<AccountToCheck>, legacyMigrationBot: Address | undefined, additionalBots: Array<Address>): Promise<{
|
|
53
|
-
legacy: GetConnectedBotsResult;
|
|
54
|
-
legacyMigration: GetConnectedMigrationBotsResult;
|
|
55
|
-
additionalBots: Array<Omit<NonNullable<GetConnectedMigrationBotsResult>, "botAddress">>;
|
|
56
|
-
}>;
|
|
57
|
-
/**
|
|
58
|
-
* {@inheritDoc ICreditAccountsService.fullyLiquidate}
|
|
59
|
-
**/
|
|
60
|
-
fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
|
|
61
|
-
/**
|
|
62
|
-
* {@inheritDoc ICreditAccountsService.closeCreditAccount}
|
|
63
|
-
**/
|
|
64
|
-
closeCreditAccount({ operation, assetsToWithdraw, creditAccount: ca, to, slippage, closePath, }: CloseCreditAccountProps): Promise<CloseCreditAccountResult>;
|
|
65
|
-
/**
|
|
66
|
-
* {@inheritDoc ICreditAccountsService.updateQuotas}
|
|
67
|
-
**/
|
|
68
|
-
updateQuotas({ minQuota, averageQuota, creditAccount, }: UpdateQuotasProps): Promise<CreditAccountOperationResult>;
|
|
69
|
-
/**
|
|
70
|
-
* {@inheritDoc ICreditAccountsService.addCollateral}
|
|
71
|
-
**/
|
|
72
|
-
addCollateral({ creditAccount, asset, permit, ethAmount, minQuota, averageQuota, }: AddCollateralProps): Promise<CreditAccountOperationResult>;
|
|
73
|
-
/**
|
|
74
|
-
* {@inheritDoc ICreditAccountsService.changeDebt}
|
|
75
|
-
**/
|
|
76
|
-
changeDebt({ creditAccount, amount, collateral, }: ChangeDeptProps): Promise<CreditAccountOperationResult>;
|
|
77
|
-
/**
|
|
78
|
-
* {@inheritDoc ICreditAccountsService.executeSwap}
|
|
79
|
-
**/
|
|
80
|
-
executeSwap({ creditAccount, calls: swapCalls, minQuota, averageQuota, }: ExecuteSwapProps): Promise<CreditAccountOperationResult>;
|
|
81
|
-
/**
|
|
82
|
-
* {@inheritDoc ICreditAccountsService.previewDelayedWithdrawal}
|
|
83
|
-
**/
|
|
84
|
-
previewDelayedWithdrawal({ creditAccount, amount, token, }: PreviewDelayedWithdrawalProps): Promise<PreviewDelayedWithdrawalResult>;
|
|
85
|
-
/**
|
|
86
|
-
* {@inheritDoc ICreditAccountsService.getPendingWithdrawals}
|
|
87
|
-
**/
|
|
88
|
-
getPendingWithdrawals({ creditAccount, }: GetPendingWithdrawalsProps): Promise<GetPendingWithdrawalsResult>;
|
|
89
|
-
/**
|
|
90
|
-
* {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
|
|
91
|
-
**/
|
|
92
|
-
startDelayedWithdrawal({ creditAccount, minQuota, averageQuota, preview, }: StartDelayedWithdrawalProps): Promise<CreditAccountOperationResult>;
|
|
93
|
-
/**
|
|
94
|
-
* {@inheritDoc ICreditAccountsService.claimDelayed}
|
|
95
|
-
**/
|
|
96
|
-
claimDelayed({ creditAccount, minQuota, averageQuota, claimableNow, }: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
|
|
97
|
-
/**
|
|
98
|
-
* {@inheritDoc ICreditAccountsService.getApprovalAddress}
|
|
99
|
-
**/
|
|
100
|
-
getApprovalAddress(options: GetApprovalAddressProps): Promise<Address>;
|
|
101
|
-
/**
|
|
102
|
-
* {@inheritDoc ICreditAccountsService.getOpenAccountRequirements}
|
|
103
|
-
*/
|
|
104
|
-
getOpenAccountRequirements(borrower: Address, creditManager: Address, props: GetOpenAccountRequirementsProps): Promise<KYCOpenAccountRequirements | undefined>;
|
|
105
|
-
/**
|
|
106
|
-
* {@inheritDoc ICreditAccountsService.openCA}
|
|
107
|
-
**/
|
|
108
|
-
openCA(props: OpenCAProps): Promise<CreditAccountOperationResult>;
|
|
109
|
-
/**
|
|
110
|
-
* {@inheritDoc ICreditAccountsService.getBorrowRate}
|
|
111
|
-
**/
|
|
112
|
-
getBorrowRate(ca: CreditAccountData): bigint;
|
|
113
|
-
/**
|
|
114
|
-
* {@inheritDoc ICreditAccountsService.getOptimalHFForPartialLiquidation}
|
|
115
|
-
**/
|
|
116
|
-
getOptimalHFForPartialLiquidation(ca: CreditAccountData): bigint;
|
|
117
|
-
/**
|
|
118
|
-
* Returns multicall entries to redeem (unwrap) KYC ERC-4626 vault shares into underlying for the given credit manager.
|
|
119
|
-
* Used when withdrawing debt from a KYC market: redeems adapter vault shares so the underlying can be withdrawn.
|
|
120
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
121
|
-
* @param amount - Number of vault shares (adapter tokens) to redeem
|
|
122
|
-
* @param creditManager - Credit manager address
|
|
123
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
124
|
-
*/
|
|
125
|
-
getKYCUnwrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
126
|
-
/**
|
|
127
|
-
* Returns multicall entries to deposit (wrap) underlying into KYC ERC-4626 vault shares for the given credit manager.
|
|
128
|
-
* Used when adding debt on a KYC market: deposits underlying into the adapter vault so shares are minted on the account.
|
|
129
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
130
|
-
* @param amount - Amount of underlying assets to deposit into the vault (in underlying decimals)
|
|
131
|
-
* @param creditManager - Credit manager address
|
|
132
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
133
|
-
*/
|
|
134
|
-
getKYCWrapCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
135
|
-
/**
|
|
136
|
-
* Returns multicall entries to call redeemDiff on the KYC ERC-4626 adapter for the given credit manager.
|
|
137
|
-
* Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess KYC vault tokens.
|
|
138
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
139
|
-
* @param amount - Leftover vault share amount to redeem (in adapter/vault decimals)
|
|
140
|
-
* @param creditManager - Credit manager address
|
|
141
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
142
|
-
*/
|
|
143
|
-
getRedeemDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
144
|
-
/**
|
|
145
|
-
* Returns multicall entries to call depositDiff on the KYC ERC-4626 adapter for the given credit manager.
|
|
146
|
-
* Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
|
|
147
|
-
* Only applies when the credit manager's underlying is KYC-gated and has an ERC-4626 adapter configured.
|
|
148
|
-
* @param amount - Leftover underlying amount to deposit into the vault (in underlying decimals)
|
|
149
|
-
* @param creditManager - Credit manager address
|
|
150
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not KYC or no adapter is configured
|
|
151
|
-
*/
|
|
152
|
-
getDepositDiffCalls(amount: bigint, creditManager: Address): Promise<Array<MultiCall> | undefined>;
|
|
153
|
-
/**
|
|
154
|
-
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
155
|
-
* {@inheritDoc ICreditAccountsService.getOnDemandPriceUpdates}
|
|
156
|
-
**/
|
|
157
|
-
getOnDemandPriceUpdates(account: CreditAccountTokensSlice, ignoreReservePrices?: boolean): Promise<PriceUpdate[]>;
|
|
158
|
-
/**
|
|
159
|
-
* Analyzes a multicall array and prepends necessary on-demand price feed updates.
|
|
160
|
-
*
|
|
161
|
-
* Deduplicates existing `onDemandPriceUpdates` calls
|
|
162
|
-
*
|
|
163
|
-
* @param creditManager - Address of the credit manager
|
|
164
|
-
* @param calls - The multicall array to prepend price updates to
|
|
165
|
-
* @param ca - Credit account slice, undefined when opening a new account
|
|
166
|
-
* @param options - Optional settings for price update generation
|
|
167
|
-
* @returns A new array with a single consolidated price update call prepended,
|
|
168
|
-
* followed by the non-price-update calls in their original order
|
|
169
|
-
*/
|
|
170
|
-
protected prependPriceUpdates(creditManager: Address, calls: MultiCall[], ca?: RouterCASlice, options?: {
|
|
171
|
-
ignoreReservePrices?: boolean;
|
|
172
|
-
}): Promise<MultiCall[]>;
|
|
173
|
-
protected getUpdateForAccount(account: CreditAccountTokensSlice, ignoreReservePrices?: boolean): Promise<UpdatePriceFeedsResult>;
|
|
174
|
-
/**
|
|
175
|
-
* {@inheritDoc ICreditAccountsService.multicall}
|
|
176
|
-
*/
|
|
177
|
-
multicall(creditAccount: RouterCASlice, calls: MultiCall[], options?: {
|
|
178
|
-
ignoreReservePrices?: boolean;
|
|
179
|
-
}): Promise<RawTx>;
|
|
180
|
-
/**
|
|
181
|
-
* {@inheritDoc ICreditAccountsService.botMulticall}
|
|
182
|
-
*/
|
|
183
|
-
botMulticall(creditAccount: RouterCASlice, calls: MultiCall[], options?: {
|
|
184
|
-
ignoreReservePrices?: boolean;
|
|
185
|
-
}): Promise<RawTx>;
|
|
186
|
-
protected prepareDisableQuotas(ca: RouterCASlice): Array<MultiCall>;
|
|
187
|
-
protected prepareUpdateQuotas(creditFacade: Address, { averageQuota, minQuota }: PrepareUpdateQuotasProps): Array<MultiCall>;
|
|
188
|
-
protected prepareDecreaseDebt(ca: RouterCASlice): Array<MultiCall>;
|
|
189
|
-
protected prepareWithdrawToken(creditFacade: Address, token: Address, amount: bigint, to: Address): MultiCall;
|
|
190
|
-
protected prepareAddCollateral(creditFacade: Address, assets: Array<Asset>, permits: Record<string, PermitResult>): Array<MultiCall>;
|
|
191
|
-
/**
|
|
192
|
-
* Returns addresses of market configurators
|
|
193
|
-
*/
|
|
194
|
-
private get marketConfigurators();
|
|
195
|
-
private get rewardCompressor();
|
|
196
|
-
private get peripheryCompressor();
|
|
197
|
-
/**
|
|
198
|
-
* Wrapper that selects between credit facade and KYC factory
|
|
199
|
-
* @param suite
|
|
200
|
-
* @param to
|
|
201
|
-
* @param calls
|
|
202
|
-
* @param referralCode
|
|
203
|
-
* @param kycOptions
|
|
204
|
-
* @returns
|
|
205
|
-
*/
|
|
206
|
-
protected openCreditAccountTx(suite: CreditSuite, to: Address, calls: MultiCall[], referralCode?: bigint, kycOptions?: KYCOperationParams): Promise<RawTx>;
|
|
207
|
-
/**
|
|
208
|
-
* Wrapper that selects between credit facade and KYC factory
|
|
209
|
-
* @param suite
|
|
210
|
-
* @param creditAccount
|
|
211
|
-
* @param calls
|
|
212
|
-
* @param kycOptions
|
|
213
|
-
* @returns
|
|
214
|
-
*/
|
|
215
|
-
protected multicallTx(suite: CreditSuite, creditAccount: Address, calls: MultiCall[], kycOptions?: KYCOperationParams): Promise<RawTx>;
|
|
216
|
-
/**
|
|
217
|
-
* Wrapper that selects between credit facade and KYC factory
|
|
218
|
-
* @param suite
|
|
219
|
-
* @param creditAccount
|
|
220
|
-
* @param calls
|
|
221
|
-
* @param operation
|
|
222
|
-
* @param kycOptions
|
|
223
|
-
* @returns
|
|
224
|
-
*/
|
|
225
|
-
protected closeCreditAccountTx(suite: CreditSuite, creditAccount: Address, calls: MultiCall[], operation: CloseOptions, kycOptions?: KYCOperationParams): Promise<RawTx>;
|
|
226
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { OnchainSDK } from "../OnchainSDK.js";
|
|
2
|
-
import type { CreditAccountServiceOptions } from "./AbstractCreditAccountsService.js";
|
|
3
|
-
import type { ICreditAccountsService } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* @sdk
|
|
6
|
-
* @version version of desired credit facade
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
export declare function createCreditAccountService(sdk: OnchainSDK, version: number, options?: CreditAccountServiceOptions): ICreditAccountsService;
|