@gearbox-protocol/sdk 13.7.0-kyc.3 → 14.0.0-next.10

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 (214) hide show
  1. package/dist/cjs/dev/AccountOpener.js +5 -45
  2. package/dist/cjs/dev/RevolverTransport.js +10 -4
  3. package/dist/cjs/dev/index.js +0 -2
  4. package/dist/cjs/dev/logSplitterTransport.js +10 -1
  5. package/dist/cjs/permissionless/utils/create2.js +2 -2
  6. package/dist/cjs/permissionless/utils/price-update/get-price-feeds.js +11 -5
  7. package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +11 -5
  8. package/dist/cjs/permissionless/utils/price-update/get-prices.js +12 -6
  9. package/dist/cjs/sdk/MultichainSDK.js +232 -0
  10. package/dist/cjs/sdk/OnchainSDK.js +478 -0
  11. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +16 -324
  12. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1 -7
  13. package/dist/cjs/sdk/base/TokensMeta.js +42 -22
  14. package/dist/cjs/sdk/base/token-types.js +0 -9
  15. package/dist/cjs/sdk/chain/chains.js +1 -2
  16. package/dist/cjs/sdk/constants/address-provider.js +0 -3
  17. package/dist/cjs/sdk/core/errors.js +77 -0
  18. package/dist/cjs/sdk/core/index.js +2 -0
  19. package/dist/cjs/sdk/index.js +4 -2
  20. package/dist/cjs/sdk/market/MarketRegister.js +116 -70
  21. package/dist/cjs/sdk/market/MarketSuite.js +0 -3
  22. package/dist/cjs/sdk/market/index.js +0 -2
  23. package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
  24. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -11
  25. package/dist/cjs/sdk/market/pool/index.js +0 -2
  26. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +10 -3
  27. package/dist/cjs/sdk/market/pricefeeds/updates/PythAccumulatorUpdateData.js +20 -23
  28. package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +7 -4
  29. package/dist/cjs/sdk/market/pricefeeds/updates/RedstoneUpdater.js +4 -4
  30. package/dist/cjs/sdk/market/pricefeeds/updates/fetchPythPayloads.js +1 -1
  31. package/dist/cjs/sdk/market/pricefeeds/updates/index.js +3 -0
  32. package/dist/cjs/sdk/options.js +24 -52
  33. package/dist/cjs/sdk/plugins/BasePlugin.js +11 -4
  34. package/dist/cjs/sdk/pools/PoolService.js +12 -104
  35. package/dist/cjs/sdk/utils/formatter.js +99 -20
  36. package/dist/cjs/sdk/utils/viem/index.js +3 -3
  37. package/dist/cjs/sdk/utils/viem/watchBlocksAsync.js +76 -0
  38. package/dist/esm/dev/AccountOpener.js +6 -47
  39. package/dist/esm/dev/RevolverTransport.js +10 -4
  40. package/dist/esm/dev/index.js +0 -1
  41. package/dist/esm/dev/logSplitterTransport.js +10 -1
  42. package/dist/esm/permissionless/utils/create2.js +1 -1
  43. package/dist/esm/permissionless/utils/price-update/get-price-feeds.js +12 -6
  44. package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +13 -7
  45. package/dist/esm/permissionless/utils/price-update/get-prices.js +13 -7
  46. package/dist/esm/sdk/MultichainSDK.js +217 -0
  47. package/dist/esm/sdk/OnchainSDK.js +472 -0
  48. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +17 -328
  49. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1 -7
  50. package/dist/esm/sdk/base/TokensMeta.js +44 -22
  51. package/dist/esm/sdk/base/token-types.js +0 -6
  52. package/dist/esm/sdk/chain/chains.js +1 -2
  53. package/dist/esm/sdk/constants/address-provider.js +0 -2
  54. package/dist/esm/sdk/core/errors.js +48 -0
  55. package/dist/esm/sdk/core/index.js +1 -0
  56. package/dist/esm/sdk/index.js +2 -1
  57. package/dist/esm/sdk/market/MarketRegister.js +118 -74
  58. package/dist/esm/sdk/market/MarketSuite.js +0 -3
  59. package/dist/esm/sdk/market/index.js +0 -1
  60. package/dist/esm/sdk/market/pool/PoolSuite.js +0 -3
  61. package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -11
  62. package/dist/esm/sdk/market/pool/index.js +0 -1
  63. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +10 -3
  64. package/dist/esm/sdk/market/pricefeeds/updates/PythAccumulatorUpdateData.js +20 -13
  65. package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +7 -4
  66. package/dist/esm/sdk/market/pricefeeds/updates/RedstoneUpdater.js +4 -4
  67. package/dist/esm/sdk/market/pricefeeds/updates/fetchPythPayloads.js +1 -1
  68. package/dist/esm/sdk/market/pricefeeds/updates/index.js +2 -0
  69. package/dist/esm/sdk/options.js +22 -51
  70. package/dist/esm/sdk/plugins/BasePlugin.js +11 -4
  71. package/dist/esm/sdk/pools/PoolService.js +13 -109
  72. package/dist/esm/sdk/utils/formatter.js +99 -10
  73. package/dist/esm/sdk/utils/viem/index.js +1 -1
  74. package/dist/esm/sdk/utils/viem/watchBlocksAsync.js +52 -0
  75. package/dist/types/dev/RevolverTransport.d.ts +2 -1
  76. package/dist/types/dev/calcLiquidatableLTs.d.ts +2 -2
  77. package/dist/types/dev/claimFromFaucet.d.ts +2 -2
  78. package/dist/types/dev/create2.d.ts +3 -4
  79. package/dist/types/dev/index.d.ts +0 -1
  80. package/dist/types/dev/logSplitterTransport.d.ts +3 -1
  81. package/dist/types/dev/migrateFaucet.d.ts +2 -2
  82. package/dist/types/dev/mint/AbstractMinter.d.ts +2 -2
  83. package/dist/types/dev/mint/FallbackMinter.d.ts +2 -2
  84. package/dist/types/dev/mint/factory.d.ts +2 -2
  85. package/dist/types/dev/replaceStorage.d.ts +1 -1
  86. package/dist/types/permissionless/utils/price-update/get-updatable-feeds.d.ts +2 -2
  87. package/dist/types/plugins/accounts/AccountsPlugin.d.ts +2 -2
  88. package/dist/types/plugins/accounts-counter/AccountsCounterPlugin.d.ts +2 -2
  89. package/dist/types/plugins/adapters/AdaptersPlugin.d.ts +2 -2
  90. package/dist/types/plugins/apy/ApyPlugin.d.ts +2 -2
  91. package/dist/types/plugins/bots/BotsPlugin.d.ts +2 -2
  92. package/dist/types/plugins/bots/PartialLiquidationBotV310Contract.d.ts +2 -2
  93. package/dist/types/plugins/degen-distributors/DegenDistributorsPlugin.d.ts +2 -2
  94. package/dist/types/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.d.ts +2 -2
  95. package/dist/types/sdk/MultichainSDK.d.ts +144 -0
  96. package/dist/types/sdk/OnchainSDK.d.ts +257 -0
  97. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +4 -54
  98. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
  99. package/dist/types/sdk/accounts/createCreditAccountService.d.ts +2 -2
  100. package/dist/types/sdk/accounts/types.d.ts +15 -95
  101. package/dist/types/sdk/base/SDKConstruct.d.ts +4 -4
  102. package/dist/types/sdk/base/TokensMeta.d.ts +3 -14
  103. package/dist/types/sdk/base/token-types.d.ts +4 -44
  104. package/dist/types/sdk/base/types.d.ts +2 -116
  105. package/dist/types/sdk/chain/chains.d.ts +1 -5
  106. package/dist/types/sdk/constants/address-provider.d.ts +0 -1
  107. package/dist/types/sdk/core/createAddressProvider.d.ts +3 -3
  108. package/dist/types/sdk/core/errors.d.ts +51 -0
  109. package/dist/types/sdk/core/index.d.ts +1 -0
  110. package/dist/types/sdk/index.d.ts +2 -1
  111. package/dist/types/sdk/market/MarketRegister.d.ts +11 -8
  112. package/dist/types/sdk/market/MarketSuite.d.ts +2 -4
  113. package/dist/types/sdk/market/adapters/createAdapter.d.ts +2 -2
  114. package/dist/types/sdk/market/credit/CreditConfiguratorV310Contract.d.ts +3 -3
  115. package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +2 -2
  116. package/dist/types/sdk/market/credit/CreditSuite.d.ts +2 -2
  117. package/dist/types/sdk/market/credit/createCreditConfigurator.d.ts +2 -2
  118. package/dist/types/sdk/market/credit/createCreditFacade.d.ts +2 -2
  119. package/dist/types/sdk/market/credit/createCreditManager.d.ts +2 -2
  120. package/dist/types/sdk/market/credit/types.d.ts +1 -1
  121. package/dist/types/sdk/market/index.d.ts +0 -1
  122. package/dist/types/sdk/market/loss-policy/AliasLossPolicyV310Contract.d.ts +3 -3
  123. package/dist/types/sdk/market/loss-policy/createLossPolicy.d.ts +2 -2
  124. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +5 -6
  125. package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +2 -2
  126. package/dist/types/sdk/market/oracle/createPriceOracle.d.ts +2 -2
  127. package/dist/types/sdk/market/oracle/types.d.ts +10 -3
  128. package/dist/types/sdk/market/pool/PoolSuite.d.ts +2 -4
  129. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -6
  130. package/dist/types/sdk/market/pool/createInterestRateModel.d.ts +2 -2
  131. package/dist/types/sdk/market/pool/createPool.d.ts +2 -2
  132. package/dist/types/sdk/market/pool/createPoolQuotaKeeper.d.ts +2 -2
  133. package/dist/types/sdk/market/pool/createRateKeeper.d.ts +2 -2
  134. package/dist/types/sdk/market/pool/index.d.ts +0 -1
  135. package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +8 -3
  136. package/dist/types/sdk/market/pricefeeds/updates/PythAccumulatorUpdateData.d.ts +12 -13
  137. package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +8 -3
  138. package/dist/types/sdk/market/pricefeeds/updates/RedstoneUpdater.d.ts +8 -3
  139. package/dist/types/sdk/market/pricefeeds/updates/index.d.ts +1 -0
  140. package/dist/types/sdk/market/pricefeeds/updates/types.d.ts +4 -0
  141. package/dist/types/sdk/market/types.d.ts +1 -1
  142. package/dist/types/sdk/options.d.ts +15 -16
  143. package/dist/types/sdk/plugins/BasePlugin.d.ts +12 -6
  144. package/dist/types/sdk/plugins/errors.d.ts +2 -2
  145. package/dist/types/sdk/plugins/types.d.ts +16 -6
  146. package/dist/types/sdk/pools/PoolService.d.ts +8 -8
  147. package/dist/types/sdk/pools/types.d.ts +2 -3
  148. package/dist/types/sdk/router/AbstractRouterContract.d.ts +3 -3
  149. package/dist/types/sdk/router/RouterV310Contract.d.ts +2 -2
  150. package/dist/types/sdk/router/createRouter.d.ts +2 -2
  151. package/dist/types/sdk/router/helpers.d.ts +1 -1
  152. package/dist/types/sdk/types/state-human.d.ts +10 -2
  153. package/dist/types/sdk/types/state.d.ts +14 -8
  154. package/dist/types/sdk/utils/filterDust.d.ts +2 -2
  155. package/dist/types/sdk/utils/formatter.d.ts +1 -1
  156. package/dist/types/sdk/utils/isDust.d.ts +2 -2
  157. package/dist/types/sdk/utils/toAddress.d.ts +1 -1
  158. package/dist/types/sdk/utils/viem/getLogsPaginated.d.ts +1 -2
  159. package/dist/types/sdk/utils/viem/getLogsSafe.d.ts +1 -1
  160. package/dist/types/sdk/utils/viem/index.d.ts +1 -1
  161. package/dist/types/sdk/utils/viem/simulateWithPriceUpdates.d.ts +1 -2
  162. package/dist/types/sdk/utils/viem/watchBlocksAsync.d.ts +74 -0
  163. package/package.json +3 -6
  164. package/dist/cjs/abi/kyc/iDSRegistryService.js +0 -70
  165. package/dist/cjs/abi/kyc/iDSToken.js +0 -71
  166. package/dist/cjs/abi/kyc/iKYCCompressor.js +0 -196
  167. package/dist/cjs/abi/kyc/iKYCFactory.js +0 -122
  168. package/dist/cjs/abi/kyc/iKYCUnderlying.js +0 -401
  169. package/dist/cjs/abi/kyc/iSecuritizeDegenNFT.js +0 -326
  170. package/dist/cjs/abi/kyc/iSecuritizeKYCFactory.js +0 -319
  171. package/dist/cjs/dev/CachedStateSubscriber.js +0 -78
  172. package/dist/cjs/sdk/GearboxSDK.js +0 -696
  173. package/dist/cjs/sdk/market/kyc/KYCRegistry.js +0 -269
  174. package/dist/cjs/sdk/market/kyc/index.js +0 -26
  175. package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -244
  176. package/dist/cjs/sdk/market/kyc/securitize/constants.js +0 -28
  177. package/dist/cjs/sdk/market/kyc/securitize/index.js +0 -26
  178. package/dist/cjs/sdk/market/kyc/securitize/types.js +0 -16
  179. package/dist/cjs/sdk/market/kyc/types.js +0 -34
  180. package/dist/cjs/sdk/utils/viem/executeDelegatedMulticalls.js +0 -38
  181. package/dist/esm/abi/kyc/iDSRegistryService.js +0 -46
  182. package/dist/esm/abi/kyc/iDSToken.js +0 -47
  183. package/dist/esm/abi/kyc/iKYCCompressor.js +0 -172
  184. package/dist/esm/abi/kyc/iKYCFactory.js +0 -98
  185. package/dist/esm/abi/kyc/iKYCUnderlying.js +0 -377
  186. package/dist/esm/abi/kyc/iSecuritizeDegenNFT.js +0 -302
  187. package/dist/esm/abi/kyc/iSecuritizeKYCFactory.js +0 -295
  188. package/dist/esm/dev/CachedStateSubscriber.js +0 -54
  189. package/dist/esm/sdk/GearboxSDK.js +0 -689
  190. package/dist/esm/sdk/market/kyc/KYCRegistry.js +0 -253
  191. package/dist/esm/sdk/market/kyc/index.js +0 -3
  192. package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -220
  193. package/dist/esm/sdk/market/kyc/securitize/constants.js +0 -4
  194. package/dist/esm/sdk/market/kyc/securitize/index.js +0 -3
  195. package/dist/esm/sdk/market/kyc/securitize/types.js +0 -0
  196. package/dist/esm/sdk/market/kyc/types.js +0 -9
  197. package/dist/esm/sdk/utils/viem/executeDelegatedMulticalls.js +0 -14
  198. package/dist/types/abi/kyc/iDSRegistryService.d.ts +0 -71
  199. package/dist/types/abi/kyc/iDSToken.d.ts +0 -67
  200. package/dist/types/abi/kyc/iKYCCompressor.d.ts +0 -228
  201. package/dist/types/abi/kyc/iKYCFactory.d.ts +0 -139
  202. package/dist/types/abi/kyc/iKYCUnderlying.d.ts +0 -548
  203. package/dist/types/abi/kyc/iSecuritizeDegenNFT.d.ts +0 -404
  204. package/dist/types/abi/kyc/iSecuritizeKYCFactory.d.ts +0 -376
  205. package/dist/types/dev/CachedStateSubscriber.d.ts +0 -21
  206. package/dist/types/sdk/GearboxSDK.d.ts +0 -324
  207. package/dist/types/sdk/market/kyc/KYCRegistry.d.ts +0 -52
  208. package/dist/types/sdk/market/kyc/index.d.ts +0 -3
  209. package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +0 -428
  210. package/dist/types/sdk/market/kyc/securitize/constants.d.ts +0 -1
  211. package/dist/types/sdk/market/kyc/securitize/index.d.ts +0 -3
  212. package/dist/types/sdk/market/kyc/securitize/types.d.ts +0 -127
  213. package/dist/types/sdk/market/kyc/types.d.ts +0 -170
  214. package/dist/types/sdk/utils/viem/executeDelegatedMulticalls.d.ts +0 -28
@@ -1,324 +0,0 @@
1
- import type { Address } from "viem";
2
- import { type PublicClient, type Transport } from "viem";
3
- import type { HttpRpcClientOptions } from "viem/utils";
4
- import type { BaseState, IBaseContract } from "./base/index.js";
5
- import { ChainContractsRegister } from "./base/index.js";
6
- import type { GearboxChain, NetworkType } from "./chain/chains.js";
7
- import type { VersionRange } from "./constants/index.js";
8
- import type { IAddressProviderContract } from "./core/index.js";
9
- import { KYCRegistry } from "./market/kyc/index.js";
10
- import { MarketRegister } from "./market/MarketRegister.js";
11
- import { PriceFeedRegister } from "./market/pricefeeds/index.js";
12
- import type { SDKOptions } from "./options.js";
13
- import { type PluginsMap } from "./plugins/index.js";
14
- import { type IRouterContract } from "./router/index.js";
15
- import type { GearboxState, GearboxStateHuman } from "./types/index.js";
16
- /**
17
- * Serialised state format version, checked during hydration to detect
18
- * incompatible snapshots.
19
- **/
20
- export declare const STATE_VERSION = 1;
21
- /**
22
- * Explicit network identity, required when working with forked testnets
23
- * whose chain IDs differ from the canonical mainnet/testnet values.
24
- **/
25
- export interface NetworkOptions {
26
- /**
27
- * EVM chain ID.
28
- * Must be set explicitly for forked testnets whose chain ID differs
29
- * from the canonical network.
30
- **/
31
- chainId: number;
32
- /**
33
- * Gearbox network type (e.g. `"Mainnet"`, `"Arbitrum"`).
34
- * Must be set explicitly for forked testnets whose chain ID differs
35
- * from the canonical network.
36
- **/
37
- networkType: NetworkType;
38
- }
39
- /**
40
- * Connection options for the underlying JSON-RPC provider.
41
- *
42
- * Supply **one** of the three variants:
43
- * - `rpcURLs` — the SDK creates a viem transport internally (with optional
44
- * fallback when multiple URLs are given).
45
- * - `transport` — bring your own viem `Transport`.
46
- * - `client` — bring your own fully-configured viem `PublicClient`.
47
- * When using this variant, the client is responsible for carrying the
48
- * correct `networkType` and `chainId`.
49
- *
50
- * ### Network detection
51
- *
52
- * For the `rpcURLs` and `transport` variants, `networkType` and `chainId` are
53
- * resolved as follows (see {@link NetworkOptions}):
54
- * - If `networkType` is provided, it is used directly; `chainId` defaults to
55
- * the canonical chain ID for that network when omitted.
56
- * - If `networkType` is **not** provided, it is detected automatically using {@link detectNetwork}.
57
- * When `chainId` is also omitted it is fetched via `eth_chainId`.
58
- *
59
- **/
60
- export type ClientOptions = {
61
- /**
62
- * One or more JSON-RPC endpoint URLs.
63
- * When more than one URL is provided, a viem `fallback` transport is created.
64
- **/
65
- rpcURLs: string[];
66
- /**
67
- * Per-request timeout in milliseconds.
68
- **/
69
- timeout?: number;
70
- /**
71
- * Number of automatic retries per RPC call.
72
- **/
73
- retryCount?: number;
74
- /**
75
- * Low-level options forwarded to the viem HTTP transport.
76
- **/
77
- httpTransportOptions?: HttpRpcClientOptions | undefined;
78
- } | {
79
- /**
80
- * Pre-built viem transport.
81
- **/
82
- transport: Transport;
83
- } | {
84
- /**
85
- * Pre-built viem public client.
86
- * Must already carry a {@link GearboxChain} definition with `networkType`
87
- * and `chainId`.
88
- **/
89
- client: PublicClient<Transport, GearboxChain>;
90
- };
91
- /**
92
- * Options accepted by {@link GearboxSDK.hydrate}.
93
- *
94
- * Same as {@link SDKOptions} but without fields that are already captured
95
- * inside the serialised {@link GearboxState} (`blockNumber`,
96
- * `addressProvider`, `marketConfigurators`).
97
- *
98
- * @typeParam Plugins - Map of plugin names to plugin instances.
99
- **/
100
- export type HydrateOptions<Plugins extends PluginsMap> = Omit<SDKOptions<Plugins>, "blockNumber" | "addressProvider" | "marketConfigurators">;
101
- /**
102
- * Options for {@link GearboxSDK.syncState}, controlling which block to
103
- * sync to and whether updatable price feeds should be refreshed.
104
- **/
105
- export interface SyncStateOptions {
106
- /**
107
- * Target block number to sync to.
108
- **/
109
- blockNumber: bigint;
110
- /**
111
- * Block timestamp corresponding to `blockNumber`.
112
- **/
113
- timestamp: bigint;
114
- /**
115
- * When `true`, skip refreshing updatable price feeds during this sync.
116
- **/
117
- ignoreUpdateablePrices?: boolean;
118
- }
119
- /**
120
- * Hook event map for the SDK lifecycle.
121
- *
122
- * Register listeners via {@link GearboxSDK.addHook} and remove them
123
- * with {@link GearboxSDK.removeHook}.
124
- *
125
- * - `syncState` — fired after {@link GearboxSDK.syncState} completes.
126
- * - `rehydrate` — fired after {@link GearboxSDK.rehydrate} completes.
127
- **/
128
- export type SDKHooks = {
129
- syncState: [SyncStateOptions];
130
- rehydrate: [SyncStateOptions];
131
- };
132
- /**
133
- * Main entry point for the Gearbox SDK.
134
- *
135
- * `GearboxSDK` aggregates on-chain state for the Gearbox protocol — markets,
136
- * credit managers, pools, price oracles, and price feeds — into a single
137
- * queryable object that can be kept up-to-date via {@link syncState} or
138
- * serialised/restored via {@link state}/{@link hydrate}.
139
- *
140
- * It represents on-chain state using instances of js classes that provide convenient methods
141
- * to read state and prepare transactions to interact with the protocol.
142
- *
143
- * Create an instance with the static {@link GearboxSDK.attach | attach}
144
- * (reads live chain data) or {@link GearboxSDK.hydrate | hydrate}
145
- * (restores from a saved snapshot) factory methods.
146
- *
147
- * @typeParam Plugins - Map of plugin names to plugin instances that extend
148
- * the SDK with additional domain-specific functionality.
149
- **/
150
- export declare class GearboxSDK<const Plugins extends PluginsMap = {}> extends ChainContractsRegister {
151
- #private;
152
- /**
153
- * Registered plugin instances, keyed by plugin name.
154
- **/
155
- readonly plugins: Plugins;
156
- /**
157
- * Gas limit applied to read-only `eth_call` requests.
158
- * `undefined` means that gas limit will not be set on read-only calls,
159
- * leaving it to rpc provider to decide.
160
- **/
161
- readonly gasLimit: bigint | undefined;
162
- /**
163
- * When `true`, the SDK throws on unrecognised contract types instead of
164
- * falling back to a generic contract wrapper.
165
- **/
166
- readonly strictContractTypes: boolean;
167
- /**
168
- * Registers a callback for an SDK lifecycle event.
169
- *
170
- * @see {@link SDKHooks} for available event names.
171
- **/
172
- addHook: <K extends keyof SDKHooks>(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
173
- /**
174
- * Removes a previously registered lifecycle callback.
175
- *
176
- * @see {@link SDKHooks} for available event names.
177
- **/
178
- removeHook: <K extends keyof SDKHooks>(hookName: K, fn: (...args: SDKHooks[K]) => void | Promise<void>) => void;
179
- /**
180
- * Creates and initialises a new SDK instance by reading live on-chain state.
181
- *
182
- * This is the primary way to bootstrap the SDK. The method connects to the
183
- * chain, discovers the address provider and all configured markets, and
184
- * attaches any supplied plugins.
185
- *
186
- * @param options - Combined SDK, client, and (optional) network options.
187
- * @returns A fully initialised SDK instance.
188
- **/
189
- static attach<const Plugins extends PluginsMap>(options: SDKOptions<Plugins> & ClientOptions & Partial<NetworkOptions>): Promise<GearboxSDK<Plugins>>;
190
- /**
191
- * Creates a new SDK instance from a previously serialised {@link GearboxState}
192
- * snapshot, without making any on-chain calls.
193
- *
194
- * Use this for fast startup when a recent state snapshot is available
195
- * (e.g. loaded from a file or received from a backend service).
196
- *
197
- * @param options - SDK and client options (block number and address provider
198
- * are taken from the snapshot).
199
- * @param state - Serialised state obtained from {@link GearboxSDK.state}.
200
- * @returns A fully initialised SDK instance.
201
- * @throws If the snapshot's {@link STATE_VERSION} does not match.
202
- **/
203
- static hydrate<const Plugins extends PluginsMap>(options: HydrateOptions<Plugins> & ClientOptions, state: GearboxState<Plugins>): GearboxSDK<Plugins>;
204
- private constructor();
205
- /**
206
- * Re-attaches the SDK using the same configuration, discarding all cached
207
- * state and re-reading everything from the chain.
208
- *
209
- * Useful when the SDK needs a full refresh (e.g. after a protocol upgrade).
210
- * Note that if the original `blockNumber` was pinned, the same block is
211
- * re-used — call {@link syncState} instead if you want to advance.
212
- *
213
- * @throws If the SDK has not been attached yet.
214
- **/
215
- reattach(): Promise<void>;
216
- /**
217
- * Replaces the SDK's in-memory state with a new serialised snapshot
218
- * without re-creating the instance.
219
- *
220
- * After hydration the `rehydrate` hook is triggered so that listeners
221
- * can react to the state change.
222
- *
223
- * @param state - Serialised state obtained from {@link GearboxSDK.state}.
224
- * @throws If the SDK has not been attached or hydrated yet.
225
- **/
226
- rehydrate(state: GearboxState<Plugins>): Promise<void>;
227
- /**
228
- * Gearbox network type the SDK is connected to (e.g. `"Mainnet"`, `"Arbitrum"`).
229
- **/
230
- get networkType(): NetworkType;
231
- /**
232
- * Returns a human-readable snapshot of the entire SDK state, suitable
233
- * for logging or diagnostic inspection.
234
- *
235
- * @param raw - When `true`, include raw numeric values alongside
236
- * formatted ones.
237
- * @default true
238
- **/
239
- stateHuman(raw?: boolean): GearboxStateHuman;
240
- /**
241
- * Serialisable snapshot of the current SDK state.
242
- *
243
- * The returned object can be persisted (e.g. written to a file) and later
244
- * passed to {@link GearboxSDK.hydrate} for instant restoration without
245
- * on-chain reads.
246
- **/
247
- get state(): GearboxState<Plugins>;
248
- /**
249
- * Incrementally updates the SDK state by replaying on-chain events from the
250
- * last processed block up to the target block (defaults to `latest`).
251
- *
252
- * Use the to periodically update sdk state on cron, or subscribe to new blocks
253
- * using viem's `watchBlocks`
254
- *
255
- * On failure the SDK reverts to the previous block/timestamp so that
256
- * subsequent calls can retry.
257
- *
258
- * @param opts - Target block and sync behaviour. When omitted the latest
259
- * block is fetched automatically.
260
- * @returns `true` if the sync completed successfully, `false` if it was
261
- * skipped or failed.
262
- **/
263
- syncState(opts?: SyncStateOptions): Promise<boolean>;
264
- /**
265
- * Block number that the SDK state corresponds to.
266
- *
267
- * @throws If the SDK has not been attached or hydrated yet.
268
- **/
269
- get currentBlock(): bigint;
270
- /**
271
- * Block timestamp (Unix epoch seconds) corresponding to {@link currentBlock}.
272
- *
273
- * @throws If the SDK has not been attached or hydrated yet.
274
- **/
275
- get timestamp(): bigint;
276
- /**
277
- * Global registry of all price feeds known to the SDK (on all markets).
278
- *
279
- * Unlike per-oracle price feed references, this register does not carry
280
- * oracle-specific metadata (staleness period, main/reserve designation, etc.).
281
- *
282
- * @throws If the SDK has not been attached or hydrated yet.
283
- **/
284
- get priceFeeds(): PriceFeedRegister;
285
- /**
286
- * Address of the GEAR governance token on this chain, or `undefined`
287
- * if the address provider does not list it.
288
- **/
289
- get gear(): Address | undefined;
290
- /**
291
- * The chain's address provider contract, the central directory for all
292
- * protocol-wide Gearbox protocol addresses.
293
- *
294
- * @throws If the SDK has not been attached or hydrated yet.
295
- **/
296
- get addressProvider(): IAddressProviderContract;
297
- /**
298
- * Registry of all loaded markets (pools, credit managers, oracles, etc.).
299
- *
300
- * @throws If the SDK has not been attached or hydrated yet.
301
- **/
302
- get marketRegister(): MarketRegister;
303
- /**
304
- * KYC register for KYC-wrapped underlying tokens and factories.
305
- *
306
- * @throws If the SDK has not been attached or hydrated yet.
307
- **/
308
- get kyc(): KYCRegistry;
309
- /**
310
- * Resolves the appropriate router contract for a given credit manager,
311
- * credit facade, or explicit version range.
312
- *
313
- * @param params - Identifies the context: a credit manager address/state,
314
- * a credit facade address/state, or a {@link VersionRange}.
315
- * @returns The matching router contract instance.
316
- * @throws If the credit facade version is unsupported or no router is
317
- * registered for the resolved version range.
318
- **/
319
- routerFor(params: {
320
- creditManager: Address | BaseState | IBaseContract;
321
- } | {
322
- creditFacade: Address | BaseState | IBaseContract;
323
- } | VersionRange): IRouterContract;
324
- }
@@ -1,52 +0,0 @@
1
- import type { Address } from "abitype";
2
- import { SDKConstruct } from "../../base/index.js";
3
- import type { DelegatedMulticall } from "../../utils/viem/index.js";
4
- import { SecuritizeKYCFactory } from "./securitize/index.js";
5
- import type { InvestorData, KYCCompressorResponse, KYCState, KYCStateHuman } from "./types.js";
6
- /**
7
- * Registry of KYC underlying tokens and KYC factory contracts.
8
- *
9
- * Populated from the on-chain {@link https://github.com/Gearbox-protocol/periphery-v3 KYCCompressor}
10
- * during SDK attach/hydrate. Provides methods to query investor-level data and
11
- * to resolve KYC factory instances by address.
12
- **/
13
- export declare class KYCRegistry extends SDKConstruct {
14
- #private;
15
- /**
16
- * @internal
17
- *
18
- * Returns delegated multicalls for loading all KYC underlying tokens from the on-chain KYC compressor.
19
- * Used by the SDK to compose batched RPC calls.
20
- *
21
- * @param configurators - Market configurators to query.
22
- * @param kycFactories - KYC factory contracts to query.
23
- */
24
- getLoadMulticalls(configurators: Address[], kycFactories?: Address[]): DelegatedMulticall[];
25
- /**
26
- * Fetches decoded investor data from the on-chain KYC compressor.
27
- *
28
- * Each factory produces its own investor data (e.g. registered tokens,
29
- * cached signatures, EIP-712 messages to sign).
30
- *
31
- * @param investor - Investor EOA address.
32
- * @param factories_ - Optional subset of factory addresses to query.
33
- * When omitted, all loaded factories are used.
34
- */
35
- getInvestorData(investor: Address, factories_?: Address[]): Promise<InvestorData[]>;
36
- /** All loaded KYC factory instances. */
37
- get factories(): SecuritizeKYCFactory[];
38
- /** Raw KYC compressor response, or `undefined` before attach/hydrate. */
39
- get state(): KYCState | undefined;
40
- /**
41
- * Returns a human-readable snapshot of the KYC state.
42
- */
43
- stateHuman(raw?: boolean): KYCStateHuman;
44
- /**
45
- * @internal
46
- *
47
- * Replaces the internal state with a new KYC compressor response.
48
- * Rebuilds token metadata for KYC underlyings and re-instantiates factory
49
- * wrappers.
50
- */
51
- setState(resp?: KYCCompressorResponse): void;
52
- }
@@ -1,3 +0,0 @@
1
- export * from "./KYCRegistry.js";
2
- export * from "./securitize/index.js";
3
- export * from "./types.js";