@gearbox-protocol/sdk 13.3.2 → 13.3.4

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.
Files changed (92) hide show
  1. package/dist/cjs/rewards/rewards/api.js +4 -124
  2. package/dist/cjs/rewards/rewards/extra-apy.js +5 -7
  3. package/dist/cjs/rewards/rewards/index.js +1 -5
  4. package/dist/cjs/sdk/GearboxSDK.js +135 -20
  5. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +40 -141
  6. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +5 -5
  7. package/dist/cjs/sdk/base/BaseContract.js +26 -6
  8. package/dist/cjs/sdk/base/ChainContractsRegister.js +39 -2
  9. package/dist/cjs/sdk/base/Construct.js +15 -3
  10. package/dist/cjs/sdk/base/TokensMeta.js +23 -0
  11. package/dist/cjs/sdk/constants/address-provider.js +0 -22
  12. package/dist/cjs/sdk/core/AbstractAddressProviderContract.js +15 -0
  13. package/dist/cjs/sdk/market/MarketRegister.js +74 -3
  14. package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +31 -50
  15. package/dist/cjs/sdk/market/pricefeeds/PriceFeedRef.js +16 -0
  16. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +55 -12
  17. package/dist/cjs/sdk/options.js +30 -24
  18. package/dist/cjs/sdk/plugins/BasePlugin.js +24 -0
  19. package/dist/cjs/sdk/pools/AbstractPoolService.js +6 -0
  20. package/dist/cjs/sdk/router/AbstractRouterContract.js +4 -1
  21. package/dist/cjs/sdk/router/RouterV310Contract.js +20 -15
  22. package/dist/cjs/sdk/utils/AddressMap.js +53 -17
  23. package/dist/cjs/sdk/utils/AddressSet.js +9 -0
  24. package/dist/cjs/sdk/utils/viem/sendRawTx.js +16 -0
  25. package/dist/esm/rewards/rewards/api.js +4 -124
  26. package/dist/esm/rewards/rewards/extra-apy.js +4 -6
  27. package/dist/esm/rewards/rewards/index.js +0 -2
  28. package/dist/esm/sdk/GearboxSDK.js +135 -20
  29. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +40 -141
  30. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +5 -5
  31. package/dist/esm/sdk/base/BaseContract.js +26 -6
  32. package/dist/esm/sdk/base/ChainContractsRegister.js +39 -2
  33. package/dist/esm/sdk/base/Construct.js +15 -3
  34. package/dist/esm/sdk/base/TokensMeta.js +23 -0
  35. package/dist/esm/sdk/constants/address-provider.js +0 -21
  36. package/dist/esm/sdk/core/AbstractAddressProviderContract.js +15 -0
  37. package/dist/esm/sdk/market/MarketRegister.js +74 -3
  38. package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +31 -50
  39. package/dist/esm/sdk/market/pricefeeds/PriceFeedRef.js +16 -0
  40. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +55 -12
  41. package/dist/esm/sdk/options.js +30 -24
  42. package/dist/esm/sdk/plugins/BasePlugin.js +24 -0
  43. package/dist/esm/sdk/pools/AbstractPoolService.js +6 -0
  44. package/dist/esm/sdk/router/AbstractRouterContract.js +4 -1
  45. package/dist/esm/sdk/router/RouterV310Contract.js +20 -15
  46. package/dist/esm/sdk/utils/AddressMap.js +53 -17
  47. package/dist/esm/sdk/utils/AddressSet.js +9 -0
  48. package/dist/esm/sdk/utils/viem/sendRawTx.js +19 -1
  49. package/dist/types/rewards/rewards/api.d.ts +5 -28
  50. package/dist/types/rewards/rewards/extra-apy.d.ts +1 -1
  51. package/dist/types/rewards/rewards/index.d.ts +0 -2
  52. package/dist/types/sdk/GearboxSDK.d.ts +236 -34
  53. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +55 -141
  54. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +14 -5
  55. package/dist/types/sdk/accounts/types.d.ts +219 -17
  56. package/dist/types/sdk/base/BaseContract.d.ts +67 -6
  57. package/dist/types/sdk/base/ChainContractsRegister.d.ts +51 -2
  58. package/dist/types/sdk/base/Construct.d.ts +31 -0
  59. package/dist/types/sdk/base/PlaceholderContract.d.ts +3 -0
  60. package/dist/types/sdk/base/SDKConstruct.d.ts +10 -0
  61. package/dist/types/sdk/base/TokensMeta.d.ts +59 -2
  62. package/dist/types/sdk/base/types.d.ts +185 -25
  63. package/dist/types/sdk/chain/chains.d.ts +78 -18
  64. package/dist/types/sdk/chain/detectNetwork.d.ts +7 -0
  65. package/dist/types/sdk/constants/address-provider.d.ts +4 -3
  66. package/dist/types/sdk/core/AbstractAddressProviderContract.d.ts +23 -0
  67. package/dist/types/sdk/core/types.d.ts +46 -0
  68. package/dist/types/sdk/market/MarketRegister.d.ts +81 -0
  69. package/dist/types/sdk/market/adapters/PlaceholderAdapterContracts.d.ts +3 -0
  70. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +40 -50
  71. package/dist/types/sdk/market/oracle/types.d.ts +76 -57
  72. package/dist/types/sdk/market/pricefeeds/AbstractLPPriceFeed.d.ts +3 -0
  73. package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +3 -0
  74. package/dist/types/sdk/market/pricefeeds/PriceFeedRef.d.ts +22 -2
  75. package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +77 -13
  76. package/dist/types/sdk/market/pricefeeds/types.d.ts +70 -10
  77. package/dist/types/sdk/options.d.ts +13 -4
  78. package/dist/types/sdk/plugins/BasePlugin.d.ts +39 -0
  79. package/dist/types/sdk/plugins/types.d.ts +73 -43
  80. package/dist/types/sdk/pools/AbstractPoolService.d.ts +12 -0
  81. package/dist/types/sdk/pools/types.d.ts +75 -6
  82. package/dist/types/sdk/router/AbstractRouterContract.d.ts +21 -2
  83. package/dist/types/sdk/router/RouterV310Contract.d.ts +27 -15
  84. package/dist/types/sdk/router/types.d.ts +51 -69
  85. package/dist/types/sdk/types/state.d.ts +32 -3
  86. package/dist/types/sdk/utils/AddressMap.d.ts +61 -17
  87. package/dist/types/sdk/utils/AddressSet.d.ts +15 -0
  88. package/dist/types/sdk/utils/viem/sendRawTx.d.ts +5 -1
  89. package/package.json +4 -2
  90. package/dist/cjs/rewards/rewards/apy.js +0 -177
  91. package/dist/esm/rewards/rewards/apy.js +0 -160
  92. package/dist/types/rewards/rewards/apy.d.ts +0 -44
@@ -13,100 +13,302 @@ import { type PluginsMap } from "./plugins/index.js";
13
13
  import { type IRouterContract } from "./router/index.js";
14
14
  import type { GearboxState, GearboxStateHuman } from "./types/index.js";
15
15
  /**
16
- * State version, checked duryng hydration
17
- */
16
+ * Serialised state format version, checked during hydration to detect
17
+ * incompatible snapshots.
18
+ **/
18
19
  export declare const STATE_VERSION = 1;
20
+ /**
21
+ * Explicit network identity, required when working with forked testnets
22
+ * whose chain IDs differ from the canonical mainnet/testnet values.
23
+ **/
19
24
  export interface NetworkOptions {
20
25
  /**
21
- * Chain Id needs to be set, because we sometimemes use forked testnets with different chain ids
22
- */
26
+ * EVM chain ID.
27
+ * Must be set explicitly for forked testnets whose chain ID differs
28
+ * from the canonical network.
29
+ **/
23
30
  chainId: number;
24
31
  /**
25
- * NetworkType needs to be set, because we sometimemes use forked testnets with different chain ids
26
- */
32
+ * Gearbox network type (e.g. `"Mainnet"`, `"Arbitrum"`).
33
+ * Must be set explicitly for forked testnets whose chain ID differs
34
+ * from the canonical network.
35
+ **/
27
36
  networkType: NetworkType;
28
37
  }
38
+ /**
39
+ * Connection options for the underlying JSON-RPC provider.
40
+ *
41
+ * Supply **one** of the three variants:
42
+ * - `rpcURLs` — the SDK creates a viem transport internally (with optional
43
+ * fallback when multiple URLs are given).
44
+ * - `transport` — bring your own viem `Transport`.
45
+ * - `client` — bring your own fully-configured viem `PublicClient`.
46
+ * When using this variant, the client is responsible for carrying the
47
+ * correct `networkType` and `chainId`.
48
+ *
49
+ * ### Network detection
50
+ *
51
+ * For the `rpcURLs` and `transport` variants, `networkType` and `chainId` are
52
+ * resolved as follows (see {@link NetworkOptions}):
53
+ * - If `networkType` is provided, it is used directly; `chainId` defaults to
54
+ * the canonical chain ID for that network when omitted.
55
+ * - If `networkType` is **not** provided, it is detected automatically using {@link detectNetwork}.
56
+ * When `chainId` is also omitted it is fetched via `eth_chainId`.
57
+ *
58
+ **/
29
59
  export type ClientOptions = {
30
60
  /**
31
- * RPC URL (and fallbacks) to use.
32
- */
61
+ * One or more JSON-RPC endpoint URLs.
62
+ * When more than one URL is provided, a viem `fallback` transport is created.
63
+ **/
33
64
  rpcURLs: string[];
34
65
  /**
35
- * RPC client timeout in milliseconds
36
- */
66
+ * Per-request timeout in milliseconds.
67
+ **/
37
68
  timeout?: number;
38
69
  /**
39
- * Retry count for RPC
40
- */
70
+ * Number of automatic retries per RPC call.
71
+ **/
41
72
  retryCount?: number;
73
+ /**
74
+ * Low-level options forwarded to the viem HTTP transport.
75
+ **/
42
76
  httpTransportOptions?: HttpRpcClientOptions | undefined;
43
77
  } | {
44
78
  /**
45
- * Alternatively, can pass viem transport
46
- */
79
+ * Pre-built viem transport.
80
+ **/
47
81
  transport: Transport;
48
82
  } | {
49
83
  /**
50
- * Alternatively, can pass entire viem client
51
- * If you bring your own client, it is responsible for defining networkType and chainId
52
- */
84
+ * Pre-built viem public client.
85
+ * Must already carry a {@link GearboxChain} definition with `networkType`
86
+ * and `chainId`.
87
+ **/
53
88
  client: PublicClient<Transport, GearboxChain>;
54
89
  };
90
+ /**
91
+ * Options accepted by {@link GearboxSDK.hydrate}.
92
+ *
93
+ * Same as {@link SDKOptions} but without fields that are already captured
94
+ * inside the serialised {@link GearboxState} (`blockNumber`,
95
+ * `addressProvider`, `marketConfigurators`).
96
+ *
97
+ * @typeParam Plugins - Map of plugin names to plugin instances.
98
+ **/
55
99
  export type HydrateOptions<Plugins extends PluginsMap> = Omit<SDKOptions<Plugins>, "blockNumber" | "addressProvider" | "marketConfigurators">;
100
+ /**
101
+ * Options for {@link GearboxSDK.syncState}, controlling which block to
102
+ * sync to and whether updatable price feeds should be refreshed.
103
+ **/
56
104
  export interface SyncStateOptions {
105
+ /**
106
+ * Target block number to sync to.
107
+ **/
57
108
  blockNumber: bigint;
109
+ /**
110
+ * Block timestamp corresponding to `blockNumber`.
111
+ **/
58
112
  timestamp: bigint;
113
+ /**
114
+ * When `true`, skip refreshing updatable price feeds during this sync.
115
+ **/
59
116
  ignoreUpdateablePrices?: boolean;
60
117
  }
118
+ /**
119
+ * Hook event map for the SDK lifecycle.
120
+ *
121
+ * Register listeners via {@link GearboxSDK.addHook} and remove them
122
+ * with {@link GearboxSDK.removeHook}.
123
+ *
124
+ * - `syncState` — fired after {@link GearboxSDK.syncState} completes.
125
+ * - `rehydrate` — fired after {@link GearboxSDK.rehydrate} completes.
126
+ **/
61
127
  export type SDKHooks = {
62
128
  syncState: [SyncStateOptions];
63
129
  rehydrate: [SyncStateOptions];
64
130
  };
131
+ /**
132
+ * Main entry point for the Gearbox SDK.
133
+ *
134
+ * `GearboxSDK` aggregates on-chain state for the Gearbox protocol — markets,
135
+ * credit managers, pools, price oracles, and price feeds — into a single
136
+ * queryable object that can be kept up-to-date via {@link syncState} or
137
+ * serialised/restored via {@link state}/{@link hydrate}.
138
+ *
139
+ * It represents on-chain state using instances of js classes that provide convenient methods
140
+ * to read state and prepare transactions to interact with the protocol.
141
+ *
142
+ * Create an instance with the static {@link GearboxSDK.attach | attach}
143
+ * (reads live chain data) or {@link GearboxSDK.hydrate | hydrate}
144
+ * (restores from a saved snapshot) factory methods.
145
+ *
146
+ * @typeParam Plugins - Map of plugin names to plugin instances that extend
147
+ * the SDK with additional domain-specific functionality.
148
+ **/
65
149
  export declare class GearboxSDK<const Plugins extends PluginsMap = {}> extends ChainContractsRegister {
66
150
  #private;
151
+ /**
152
+ * Registered plugin instances, keyed by plugin name.
153
+ **/
67
154
  readonly plugins: Plugins;
155
+ /**
156
+ * Gas limit applied to read-only `eth_call` requests.
157
+ * `undefined` means that gas limit will not be set on read-only calls,
158
+ * leaving it to rpc provider to decide.
159
+ **/
68
160
  readonly gasLimit: bigint | undefined;
69
161
  /**
70
- * Will throw an error if contract type is not supported, otherwise will try to use generic contract first, if possible
71
- */
162
+ * When `true`, the SDK throws on unrecognised contract types instead of
163
+ * falling back to a generic contract wrapper.
164
+ **/
72
165
  readonly strictContractTypes: boolean;
166
+ /**
167
+ * Registers a callback for an SDK lifecycle event.
168
+ *
169
+ * @see {@link SDKHooks} for available event names.
170
+ **/
73
171
  addHook: <K extends keyof SDKHooks>(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
172
+ /**
173
+ * Removes a previously registered lifecycle callback.
174
+ *
175
+ * @see {@link SDKHooks} for available event names.
176
+ **/
74
177
  removeHook: <K extends keyof SDKHooks>(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
178
+ /**
179
+ * Creates and initialises a new SDK instance by reading live on-chain state.
180
+ *
181
+ * This is the primary way to bootstrap the SDK. The method connects to the
182
+ * chain, discovers the address provider and all configured markets, and
183
+ * attaches any supplied plugins.
184
+ *
185
+ * @param options - Combined SDK, client, and (optional) network options.
186
+ * @returns A fully initialised SDK instance.
187
+ **/
75
188
  static attach<const Plugins extends PluginsMap>(options: SDKOptions<Plugins> & ClientOptions & Partial<NetworkOptions>): Promise<GearboxSDK<Plugins>>;
189
+ /**
190
+ * Creates a new SDK instance from a previously serialised {@link GearboxState}
191
+ * snapshot, without making any on-chain calls.
192
+ *
193
+ * Use this for fast startup when a recent state snapshot is available
194
+ * (e.g. loaded from a file or received from a backend service).
195
+ *
196
+ * @param options - SDK and client options (block number and address provider
197
+ * are taken from the snapshot).
198
+ * @param state - Serialised state obtained from {@link GearboxSDK.state}.
199
+ * @returns A fully initialised SDK instance.
200
+ * @throws If the snapshot's {@link STATE_VERSION} does not match.
201
+ **/
76
202
  static hydrate<const Plugins extends PluginsMap>(options: HydrateOptions<Plugins> & ClientOptions, state: GearboxState<Plugins>): GearboxSDK<Plugins>;
77
203
  private constructor();
78
204
  /**
79
- * Reattach SDK with the same config as before, without re-creating instance. Will load all state from scratch
80
- * Be mindful of block number, for example
81
- */
205
+ * Re-attaches the SDK using the same configuration, discarding all cached
206
+ * state and re-reading everything from the chain.
207
+ *
208
+ * Useful when the SDK needs a full refresh (e.g. after a protocol upgrade).
209
+ * Note that if the original `blockNumber` was pinned, the same block is
210
+ * re-used — call {@link syncState} instead if you want to advance.
211
+ *
212
+ * @throws If the SDK has not been attached yet.
213
+ **/
82
214
  reattach(): Promise<void>;
83
215
  /**
84
- * Rehydrate existing SDK from new state without re-creating instance
85
- */
216
+ * Replaces the SDK's in-memory state with a new serialised snapshot
217
+ * without re-creating the instance.
218
+ *
219
+ * After hydration the `rehydrate` hook is triggered so that listeners
220
+ * can react to the state change.
221
+ *
222
+ * @param state - Serialised state obtained from {@link GearboxSDK.state}.
223
+ * @throws If the SDK has not been attached or hydrated yet.
224
+ **/
86
225
  rehydrate(state: GearboxState<Plugins>): Promise<void>;
226
+ /**
227
+ * Gearbox network type the SDK is connected to (e.g. `"Mainnet"`, `"Arbitrum"`).
228
+ **/
87
229
  get networkType(): NetworkType;
230
+ /**
231
+ * Returns a human-readable snapshot of the entire SDK state, suitable
232
+ * for logging or diagnostic inspection.
233
+ *
234
+ * @param raw - When `true`, include raw numeric values alongside
235
+ * formatted ones.
236
+ * @default true
237
+ **/
88
238
  stateHuman(raw?: boolean): GearboxStateHuman;
239
+ /**
240
+ * Serialisable snapshot of the current SDK state.
241
+ *
242
+ * The returned object can be persisted (e.g. written to a file) and later
243
+ * passed to {@link GearboxSDK.hydrate} for instant restoration without
244
+ * on-chain reads.
245
+ **/
89
246
  get state(): GearboxState<Plugins>;
90
247
  /**
91
- * Reloads markets states based on events from last processed block to new block (defaults to latest block)
92
- * @param opts
93
- * @returns true if successful, false if was skipped or failed
94
- */
248
+ * Incrementally updates the SDK state by replaying on-chain events from the
249
+ * last processed block up to the target block (defaults to `latest`).
250
+ *
251
+ * Use the to periodically update sdk state on cron, or subscribe to new blocks
252
+ * using viem's `watchBlocks`
253
+ *
254
+ * On failure the SDK reverts to the previous block/timestamp so that
255
+ * subsequent calls can retry.
256
+ *
257
+ * @param opts - Target block and sync behaviour. When omitted the latest
258
+ * block is fetched automatically.
259
+ * @returns `true` if the sync completed successfully, `false` if it was
260
+ * skipped or failed.
261
+ **/
95
262
  syncState(opts?: SyncStateOptions): Promise<boolean>;
263
+ /**
264
+ * Block number that the SDK state corresponds to.
265
+ *
266
+ * @throws If the SDK has not been attached or hydrated yet.
267
+ **/
96
268
  get currentBlock(): bigint;
269
+ /**
270
+ * Block timestamp (Unix epoch seconds) corresponding to {@link currentBlock}.
271
+ *
272
+ * @throws If the SDK has not been attached or hydrated yet.
273
+ **/
97
274
  get timestamp(): bigint;
98
275
  /**
99
- * All price feeds known to sdk, without oracle-related data (stalenessPeriod, main/reserve, etc.)
100
- */
276
+ * Global registry of all price feeds known to the SDK (on all markets).
277
+ *
278
+ * Unlike per-oracle price feed references, this register does not carry
279
+ * oracle-specific metadata (staleness period, main/reserve designation, etc.).
280
+ *
281
+ * @throws If the SDK has not been attached or hydrated yet.
282
+ **/
101
283
  get priceFeeds(): PriceFeedRegister;
284
+ /**
285
+ * Address of the GEAR governance token on this chain, or `undefined`
286
+ * if the address provider does not list it.
287
+ **/
102
288
  get gear(): Address | undefined;
289
+ /**
290
+ * The chain's address provider contract, the central directory for all
291
+ * protocol-wide Gearbox protocol addresses.
292
+ *
293
+ * @throws If the SDK has not been attached or hydrated yet.
294
+ **/
103
295
  get addressProvider(): IAddressProviderContract;
296
+ /**
297
+ * Registry of all loaded markets (pools, credit managers, oracles, etc.).
298
+ *
299
+ * @throws If the SDK has not been attached or hydrated yet.
300
+ **/
104
301
  get marketRegister(): MarketRegister;
105
302
  /**
106
- * Returns router contract that will work for given credit manager or credit facade, or simply version range
107
- * @param params
108
- * @returns
109
- */
303
+ * Resolves the appropriate router contract for a given credit manager,
304
+ * credit facade, or explicit version range.
305
+ *
306
+ * @param params - Identifies the context: a credit manager address/state,
307
+ * a credit facade address/state, or a {@link VersionRange}.
308
+ * @returns The matching router contract instance.
309
+ * @throws If the credit facade version is unsupported or no router is
310
+ * registered for the resolved version range.
311
+ **/
110
312
  routerFor(params: {
111
313
  creditManager: Address | BaseState | IBaseContract;
112
314
  } | {
@@ -6,43 +6,43 @@ import type { OnDemandPriceUpdates, UpdatePriceFeedsResult } from "../market/ind
6
6
  import { type Asset, type RouterCASlice } from "../router/index.js";
7
7
  import type { MultiCall } from "../types/index.js";
8
8
  import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, PriceUpdatesOptions, Rewards, StartDelayedWithdrawalProps, UpdateQuotasProps } from "./types.js";
9
+ /**
10
+ * Options for configuring the credit account service.
11
+ **/
9
12
  export interface CreditAccountServiceOptions {
13
+ /**
14
+ * Maximum number of credit accounts to fetch per compressor call.
15
+ * When set, accounts are loaded in batches of this size until all are fetched.
16
+ **/
10
17
  batchSize?: number;
11
18
  }
19
+ /**
20
+ * Returns the withdrawal compressor contract address for the given chain, or `undefined` if none is configured.
21
+ * @param chainId - Numeric chain ID.
22
+ * @returns Withdrawal compressor address, or `undefined`.
23
+ **/
12
24
  export declare function getWithdrawalCompressorAddress(chainId: number): `0x${string}`;
25
+ /**
26
+ * @internal
27
+ */
13
28
  export declare abstract class AbstractCreditAccountService extends SDKConstruct {
14
29
  #private;
15
30
  constructor(sdk: GearboxSDK, options?: CreditAccountServiceOptions);
16
31
  /**
17
- * Returns single credit account data, or undefined if it's not found
18
- * Performs all necessary price feed updates under the hood
19
- * @param account
20
- * @param blockNumber
21
- * @returns
22
- */
32
+ * {@inheritDoc ICreditAccountsService.getCreditAccountData}
33
+ **/
23
34
  getCreditAccountData(account: Address, blockNumber?: bigint): Promise<CreditAccountData | undefined>;
24
35
  /**
25
- * Methods to get all credit accounts with some optional filtering
26
- * Performs all necessary price feed updates under the hood
27
- *
28
- * @param options
29
- * @param blockNumber
30
- * @returns returned credit accounts are sorted by health factor in ascending order
31
- */
36
+ * {@inheritDoc ICreditAccountsService.getCreditAccounts}
37
+ **/
32
38
  getCreditAccounts(options?: GetCreditAccountsOptions, blockNumber?: bigint): Promise<Array<CreditAccountData>>;
33
39
  /**
34
- * Method to get all claimable rewards for credit account (ex. stkUSDS SKY rewards)
35
- Assosiates rewards by adapter + stakedPhantomToken
36
- * @param {Address} creditAccount - address of credit account to get rewards for
37
- * @returns {Array<Rewards>} list of {@link Rewards} that can be claimed
38
- */
40
+ * {@inheritDoc ICreditAccountsService.getRewards}
41
+ **/
39
42
  getRewards(creditAccount: Address): Promise<Array<Rewards>>;
40
43
  /**
41
- * Method to get all connected bots for credit account
42
- * @param {Array<AccountToCheck>} accountsToCheck - list of credit accounts
43
- and their credit managers to check connected bots on
44
- * @returns call result of getConnectedBots for each credit account
45
- */
44
+ * {@inheritDoc ICreditAccountsService.getConnectedBots}
45
+ **/
46
46
  getConnectedBots(accountsToCheck: Array<AccountToCheck>, legacyMigrationBot: Address | undefined, additionalBots: Array<Address>): Promise<{
47
47
  legacy: GetConnectedBotsResult;
48
48
  legacyMigration: GetConnectedMigrationBotsResult;
@@ -51,155 +51,69 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
51
51
  private getActiveBots;
52
52
  private getActiveMigrationBots;
53
53
  /**
54
- * Generates transaction to liquidate credit account
55
- * @param props - {@link FullyLiquidateProps}
56
- * @returns
57
- */
54
+ * {@inheritDoc ICreditAccountsService.fullyLiquidate}
55
+ **/
58
56
  fullyLiquidate(props: FullyLiquidateProps): Promise<FullyLiquidateResult>;
59
57
  /**
60
- * Closes credit account or closes credit account and keeps it open with zero debt.
61
- - Ca is closed in the following order: price update -> close path to swap all tokens into underlying ->
62
- -> disable quotas of exiting tokens -> decrease debt -> disable exiting tokens tokens -> withdraw underlying tokenz
63
- * @param {CloseOptions} operation - {@link CloseOptions}: close or zeroDebt
64
- * @param {RouterCASlice} creditAccount - minimal credit account data {@link RouterCASlice} on which operation is performed
65
- * @param {Array<Address>} assetsToWithdraw - tokens to withdraw from credit account.
66
- For credit account closing this is the underlying token, because during the closure,
67
- all tokens on account are swapped into the underlying,
68
- and only the underlying token will remain on the credit account
69
- * @param {Address} to - Wallet address to withdraw underlying to
70
- * @param {number} slippage - Slippage in PERCENTAGE_FORMAT (100% = 10_000) per operation
71
- * @default 50n
72
- * @param {RouterCloseResult | undefined} closePath - result of findBestClosePath method from router; if omited, calls marketRegister.findCreditManager {@link RouterCloseResult}
73
- * @returns All necessary data to execute the transaction (call, credit facade)
74
- */
58
+ * {@inheritDoc ICreditAccountsService.closeCreditAccount}
59
+ **/
75
60
  closeCreditAccount({ operation, assetsToWithdraw, creditAccount: ca, to, slippage, closePath, }: CloseCreditAccountProps): Promise<CloseCreditAccountResult>;
76
61
  /**
77
- * Updates quota of credit account.
78
- - CA quota updated in the following order: price update -> update quotas
79
- * @param {RouterCASlice} creditAccount - minimal credit account data {@link RouterCASlice} on which operation is performed
80
- * @param {Array<Asset>} averageQuota - average quota for desired tokens {@link Asset}
81
- * @param {Array<Asset>} minQuota - minimum quota for desired tokens {@link Asset}
82
- * @returns All necessary data to execute the transaction (call, credit facade)
83
- */
62
+ * {@inheritDoc ICreditAccountsService.updateQuotas}
63
+ **/
84
64
  updateQuotas({ minQuota, averageQuota, creditAccount, }: UpdateQuotasProps): Promise<CreditAccountOperationResult>;
85
65
  /**
86
- * Adds a single collateral to credit account and updates quotas
87
- - Collateral is added in the following order: price update -> add collateral (with permit) -> update quotas
88
- * @param {RouterCASlice} creditAccount - minimal credit account data {@link RouterCASlice} on which operation is performed
89
- * @param {Array<Asset>} averageQuota - average quota for desired token {@link Asset}
90
- * @param {Array<Asset>} minQuota - minimum quota for desired token {@link Asset}
91
- * @param {Asset} asset - asset to add as collateral {@link Asset}
92
- * @param {PermitResult | undefined} permits - permits of collateral asset if it is permittable {@link PermitResult}
93
- * @param {bigint} ethAmount - native token amount to attach to tx
94
- * @returns All necessary data to execute the transaction (call, credit facade)
95
- */
66
+ * {@inheritDoc ICreditAccountsService.addCollateral}
67
+ **/
96
68
  addCollateral({ creditAccount, asset, permit, ethAmount, minQuota, averageQuota, }: AddCollateralProps): Promise<CreditAccountOperationResult>;
97
69
  /**
98
- * Increases or decreases debt of credit account; debt decrease uses token ON CREDIT ACCOUNT
99
- - Debt is changed in the following order: price update -> (enables underlying if it was disabled) -> change debt
100
- * @param {RouterCASlice} creditAccount - minimal credit account data {@link RouterCASlice} on which operation is performed
101
- * @param {bigint} amount - amount to change debt by;
102
- 0 - prohibited value;
103
- negative value for debt decrease;
104
- positive value for debt increase.
105
- * @returns All necessary data to execute the transaction (call, credit facade)
106
- */
70
+ * {@inheritDoc ICreditAccountsService.changeDebt}
71
+ **/
107
72
  changeDebt({ creditAccount, amount, addCollateral, }: ChangeDeptProps): Promise<CreditAccountOperationResult>;
108
73
  /**
109
- * Executes swap specified by given calls, update quotas of affected tokens
110
- - Swap is executed in the following order: price update -> execute swap path -> update quotas
111
- * @param {RouterCASlice} creditAccount - minimal credit account data {@link RouterCASlice} on which operation is performed
112
- * @param {Array<Asset>} averageQuota - average quota for desired token {@link Asset}
113
- * @param {Array<Asset>} minQuota - minimum quota for desired token {@link Asset}
114
- * @param {Array<MultiCall>} calls - array of MultiCall from router methods getSingleSwap or getAllSwaps {@link MultiCall}
115
- * @returns All necessary data to execute the transaction (call, credit facade)
116
- */
74
+ * {@inheritDoc ICreditAccountsService.executeSwap}
75
+ **/
117
76
  executeSwap({ creditAccount, calls: swapCalls, minQuota, averageQuota, }: ExecuteSwapProps): Promise<CreditAccountOperationResult>;
118
77
  /**
119
- * Preview delayed withdrawal for given token
120
- * @param props - {@link PreviewDelayedWithdrawalProps}
121
- * @returns
122
- */
78
+ * {@inheritDoc ICreditAccountsService.previewDelayedWithdrawal}
79
+ **/
123
80
  previewDelayedWithdrawal({ creditAccount, amount, token, }: PreviewDelayedWithdrawalProps): Promise<PreviewDelayedWithdrawalResult>;
124
81
  /**
125
- * Get claimable and pending withdrawals of an account
126
- * @param props - {@link GetPendingWithdrawalsProps}
127
- * @returns
128
- */
82
+ * {@inheritDoc ICreditAccountsService.getPendingWithdrawals}
83
+ **/
129
84
  getPendingWithdrawals({ creditAccount, }: GetPendingWithdrawalsProps): Promise<GetPendingWithdrawalsResult>;
130
85
  /**
131
- * Start delayed withdrawal for given token
132
- - Withdrawal is executed in the following order: price update -> execute withdraw calls -> update quotas
133
- * @param props - {@link StartDelayedWithdrawalProps}
134
- * @returns
135
- */
86
+ * {@inheritDoc ICreditAccountsService.startDelayedWithdrawal}
87
+ **/
136
88
  startDelayedWithdrawal({ creditAccount, minQuota, averageQuota, preview, }: StartDelayedWithdrawalProps): Promise<CreditAccountOperationResult>;
137
89
  /**
138
- * Claim tokens with delayed withdrawal
139
- - Claim is executed in the following order: price update -> execute claim calls -> update quotas
140
- * @param props - {@link ClaimDelayedProps}
141
- * @returns
142
- */
90
+ * {@inheritDoc ICreditAccountsService.claimDelayed}
91
+ **/
143
92
  claimDelayed({ creditAccount, minQuota, averageQuota, claimableNow, }: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
144
93
  /**
145
- * Executes swap specified by given calls, update quotas of affected tokens
146
- - Open credit account is executed in the following order: price update -> increase debt -> add collateral ->
147
- -> update quotas -> (optionally: execute swap path for trading/strategy) ->
148
- -> (optionally: withdraw debt for lending)
149
- - Basic open credit account: price update -> increase debt -> add collateral -> update quotas
150
- - Lending: price update -> increase debt -> add collateral -> update quotas -> withdraw debt
151
- - Strategy/trading: price update -> increase debt -> add collateral -> update quotas -> execute swap path
152
- - In strategy is possible situation when collateral is added, but not swapped; the only swapped value in this case will be debt
153
- * @param {bigint} ethAmount - native token amount to attach to tx
154
- * @param {Address} creditManager - address of credit manager to open credit account on
155
- * @param {Array<Asset>} collateral - array of collateral which can be just directly added or swapped using the path {@link Asset}
156
- * @param {Record<Address, PermitResult>} permits - permits of collateral tokens (in any permittable token is present) {@link PermitResult}
157
- * @param {bigint} debt - debt to open credit account with
158
- * @param {boolean} withdrawDebt - flag to withdraw debt to wallet after opening credit account;
159
- used for borrowing functionality
160
- * @param {bigint} referralCode - referral code to open credit account with
161
- * @param {Address} to - wallet address to transfer credit account to\
162
- * @param {Array<MultiCall>} calls - array of MultiCall from router methods findOpenStrategyPath {@link MultiCall}.
163
- Used for trading and strategy functionality
164
- * @param {Array<Asset>} averageQuota - average quota for tokens after open {@link Asset}
165
- * @param {Array<Asset>} minQuota - minimum quota for tokens after open {@link Asset}
166
- * @returns All necessary data to execute the transaction (call, credit facade)
167
- */
94
+ * {@inheritDoc ICreditAccountsService.openCA}
95
+ **/
168
96
  openCA({ ethAmount, creditManager, collateral, permits, debt, withdrawDebt, referralCode, to, calls: openPathCalls, minQuota, averageQuota, }: OpenCAProps): Promise<CreditAccountOperationResult>;
169
97
  /**
170
- * Returns borrow rate with 4 digits precision (10000 = 100%)
171
- * @param ca
172
- * @returns
173
- */
98
+ * {@inheritDoc ICreditAccountsService.getBorrowRate}
99
+ **/
174
100
  getBorrowRate(ca: CreditAccountData): bigint;
175
101
  /**
176
- * Returns optimal HF for partial liquidation with 4 digits precision (10000 = 100%)
177
- * @param ca
178
- */
102
+ * {@inheritDoc ICreditAccountsService.getOptimalHFForPartialLiquidation}
103
+ **/
179
104
  getOptimalHFForPartialLiquidation(ca: CreditAccountData): bigint;
180
105
  /**
181
- * Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
182
- *
183
- * This can be used by batch liquidator
184
- * @param accounts
185
- * @returns
186
- */
106
+ * {@inheritDoc ICreditAccountsService.getUpdateForAccounts}
107
+ **/
187
108
  getUpdateForAccounts(accounts: Array<RouterCASlice>): Promise<UpdatePriceFeedsResult>;
188
109
  protected getUpdateForAccount(options: PriceUpdatesOptions): Promise<UpdatePriceFeedsResult>;
189
110
  /**
190
- * Returns account price updates that can be used in credit facade multicall or liquidator calls
191
- * @param options
192
- * @returns
193
- */
111
+ * {@inheritDoc ICreditAccountsService.getOnDemandPriceUpdates}
112
+ **/
194
113
  getOnDemandPriceUpdates(options: PriceUpdatesOptions): Promise<OnDemandPriceUpdates>;
195
114
  /**
196
- * Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...).
197
- * - If there are desiredQuotas and creditAccount update quotaBalance > 0 || (balance > 10n && isEnabled). Is used when account has both: balances and quota buys.
198
- * - If there is creditAccount update balance > 10n && isEnabled. Is used in credit account actions when quota is not being bought.
199
- * - If there is desiredQuotas update quotaBalance > 0. Is used on credit account opening, when quota is bought for the first time.
200
- * @param acc
201
- * @returns
202
- */
115
+ * {@inheritDoc ICreditAccountsService.getPriceUpdatesForFacade}
116
+ **/
203
117
  getPriceUpdatesForFacade(options: PriceUpdatesOptions): Promise<Array<MultiCall>>;
204
118
  protected prepareDisableQuotas(ca: RouterCASlice): Array<MultiCall>;
205
119
  protected prepareUpdateQuotas(creditFacade: Address, { averageQuota, minQuota }: PrepareUpdateQuotasProps): Array<MultiCall>;
@@ -1,24 +1,33 @@
1
1
  import { AbstractCreditAccountService } from "./AbstractCreditAccountsService.js";
2
2
  import type { ClaimFarmRewardsProps, CreditAccountOperationResult, CreditManagerOperationResult, ICreditAccountsService, LlamathenaProportionalWithdrawProps, PreviewWithdrawLlamathenaProportionallyProps, PreviewWithdrawLlamathenaProportionallyResult, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, SetBotProps, WithdrawCollateralProps } from "./types.js";
3
+ /**
4
+ * Service for querying and operating on Gearbox credit accounts.
5
+ *
6
+ * Provides methods to fetch account data, build transactions for common operations
7
+ * (open, close, liquidate, swap, manage collateral/debt/quotas), and generate
8
+ * the price feed updates required by the credit facade.
9
+ *
10
+ * @see {@link ICreditAccountsService}
11
+ **/
3
12
  export declare class CreditAccountServiceV310 extends AbstractCreditAccountService implements ICreditAccountsService {
4
13
  /**
5
- * Implements {@link ICreditAccountsService.setBot}
14
+ * {@inheritDoc ICreditAccountsService.setBot}
6
15
  */
7
16
  setBot({ botAddress, permissions: defaultPermissions, targetContract, }: SetBotProps): Promise<CreditAccountOperationResult | CreditManagerOperationResult>;
8
17
  /**
9
- * Implements {@link ICreditAccountsService.withdrawCollateral}
18
+ * {@inheritDoc ICreditAccountsService.withdrawCollateral}
10
19
  */
11
20
  withdrawCollateral({ creditAccount, assetsToWithdraw, to, minQuota, averageQuota, }: WithdrawCollateralProps): Promise<CreditAccountOperationResult>;
12
21
  /**
13
- * Implements {@link ICreditAccountsService.repayCreditAccount}
22
+ * {@inheritDoc ICreditAccountsService.repayCreditAccount}
14
23
  */
15
24
  repayCreditAccount({ operation, collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to, tokensToClaim, }: RepayCreditAccountProps): Promise<CreditAccountOperationResult>;
16
25
  /**
17
- * Implements {@link ICreditAccountsService.repayAndLiquidateCreditAccount}
26
+ * {@inheritDoc ICreditAccountsService.repayAndLiquidateCreditAccount}
18
27
  */
19
28
  repayAndLiquidateCreditAccount({ collateralAssets, assetsToWithdraw, creditAccount: ca, permits, to, tokensToClaim, }: RepayAndLiquidateCreditAccountProps): Promise<CreditAccountOperationResult>;
20
29
  /**
21
- * Implements {@link ICreditAccountsService.claimFarmRewards}
30
+ * {@inheritDoc ICreditAccountsService.claimFarmRewards}
22
31
  */
23
32
  claimFarmRewards({ calls: externalCalls, creditAccount: ca, minQuota, averageQuota, tokensToClaim, }: ClaimFarmRewardsProps): Promise<CreditAccountOperationResult>;
24
33
  previewWithdrawLlamathenaProportionally(_: PreviewWithdrawLlamathenaProportionallyProps): Promise<PreviewWithdrawLlamathenaProportionallyResult>;