@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
@@ -4,35 +4,35 @@ import type { AddLiquidityProps, DepositMetadata, IPoolsService, PoolServiceCall
4
4
  export declare class PoolService extends SDKConstruct implements IPoolsService {
5
5
  #private;
6
6
  /**
7
- * {@inheritDoc IPoolsService.getDepositTokensIn}
7
+ * @inheritdoc IPoolsService.getDepositTokensIn
8
8
  */
9
9
  getDepositTokensIn(pool: Address): Address[];
10
10
  /**
11
- * {@inheritDoc IPoolsService.getDepositTokensOut}
11
+ * @inheritdoc IPoolsService.getDepositTokensOut
12
12
  */
13
13
  getDepositTokensOut(pool: Address, tokenIn: Address): Address[];
14
14
  /**
15
- * {@inheritDoc IPoolsService.getDepositMetadata}
15
+ * @inheritdoc IPoolsService.getDepositMetadata
16
16
  */
17
17
  getDepositMetadata(pool: Address, tokenIn: Address, tokenOut?: Address): DepositMetadata;
18
18
  /**
19
- * {@inheritDoc IPoolsService.addLiquidity}
19
+ * @inheritdoc IPoolsService.addLiquidity
20
20
  */
21
21
  addLiquidity(props: AddLiquidityProps): PoolServiceCall | undefined;
22
22
  /**
23
- * {@inheritDoc IPoolsService.getWithdrawalTokensIn}
23
+ * @inheritdoc IPoolsService.getWithdrawalTokensIn
24
24
  */
25
25
  getWithdrawalTokensIn(pool: Address): Address[];
26
26
  /**
27
- * {@inheritDoc IPoolsService.getWithdrawalTokensOut}
27
+ * @inheritdoc IPoolsService.getWithdrawalTokensOut
28
28
  */
29
29
  getWithdrawalTokensOut(pool: Address, tokenIn: Address): Address[];
30
30
  /**
31
- * {@inheritDoc IPoolsService.removeLiquidity}
31
+ * @inheritdoc IPoolsService.removeLiquidity
32
32
  */
33
33
  removeLiquidity(props: RemoveLiquidityProps): PoolServiceCall;
34
34
  /**
35
- * {@inheritDoc IPoolsService.getWithdrawalMetadata}
35
+ * @inheritdoc IPoolsService.getWithdrawalMetadata
36
36
  */
37
37
  getWithdrawalMetadata(pool: Address, tokenIn: Address, tokenOut?: Address): WithdrawalMetadata;
38
38
  }
@@ -1,5 +1,4 @@
1
- import type { Abi } from "abitype";
2
- import type { Address, ContractFunctionArgs, ContractFunctionName } from "viem";
1
+ import type { Abi, Address, ContractFunctionArgs, ContractFunctionName } from "viem";
3
2
  import type { ZapperData } from "../market/index.js";
4
3
  import type { Asset } from "../router/index.js";
5
4
  interface PermitResult {
@@ -53,7 +52,7 @@ export interface RemoveLiquidityProps {
53
52
  permit: PermitResult | undefined;
54
53
  meta: WithdrawalMetadata;
55
54
  }
56
- export type MarketType = "kyc-on-demand" | "kyc-default" | "classic";
55
+ export type MarketType = "classic";
57
56
  export interface DepositMetadata {
58
57
  /**
59
58
  * Zapper that will perform the deposit, undefined in case of direct pool underlying deposit
@@ -1,7 +1,7 @@
1
1
  import type { Abi, Address } from "viem";
2
2
  import { BaseContract, type BaseContractArgs } from "../base/index.js";
3
- import type { GearboxSDK } from "../GearboxSDK.js";
4
3
  import type { IPriceOracleContract } from "../market/index.js";
4
+ import type { OnchainSDK } from "../OnchainSDK.js";
5
5
  import { AddressMap, AddressSet } from "../utils/index.js";
6
6
  import type { Asset, RouterCASlice, RouterCMSlice } from "./types.js";
7
7
  export interface ExpectedAndLeftoverOptions {
@@ -29,8 +29,8 @@ export declare abstract class AbstractRouterContract<abi extends Abi | readonly
29
29
  /**
30
30
  * Reference to the parent SDK instance.
31
31
  **/
32
- readonly sdk: GearboxSDK;
33
- constructor(sdk: GearboxSDK, args: BaseContractArgs<abi>);
32
+ readonly sdk: OnchainSDK;
33
+ constructor(sdk: OnchainSDK, args: BaseContractArgs<abi>);
34
34
  protected getExpectedAndLeftover(ca: RouterCASlice, cm: RouterCMSlice, options?: ExpectedAndLeftoverOptions): Leftovers;
35
35
  protected getDefaultExpectedAndLeftover(ca: RouterCASlice, keepAssets?: Address[], debtOnly?: boolean): Leftovers;
36
36
  /**
@@ -1,5 +1,5 @@
1
1
  import { type Address } from "viem";
2
- import type { GearboxSDK } from "../GearboxSDK.js";
2
+ import type { OnchainSDK } from "../OnchainSDK.js";
3
3
  import { AbstractRouterContract } from "./AbstractRouterContract.js";
4
4
  import type { FindBestClosePathProps, FindClaimAllRewardsProps, FindOneTokenPathProps, FindOpenStrategyPathProps, IRouterContract, OpenStrategyResult, RouterCloseResult, RouterResult, RouterRewardsResult } from "./types.js";
5
5
  declare const abi: readonly [{
@@ -893,7 +893,7 @@ type abi = typeof abi;
893
893
  **/
894
894
  export declare class RouterV310Contract extends AbstractRouterContract<abi> implements IRouterContract {
895
895
  #private;
896
- constructor(sdk: GearboxSDK, address: Address, version: number);
896
+ constructor(sdk: OnchainSDK, address: Address, version: number);
897
897
  /**
898
898
  * {@inheritDoc IRouterContract.findOneTokenPath}
899
899
  **/
@@ -1,4 +1,4 @@
1
1
  import type { Address } from "viem";
2
- import type { GearboxSDK } from "../GearboxSDK.js";
2
+ import type { OnchainSDK } from "../OnchainSDK.js";
3
3
  import type { IRouterContract } from "./types.js";
4
- export declare function createRouter(sdk: GearboxSDK, address: Address, version: number): IRouterContract;
4
+ export declare function createRouter(sdk: OnchainSDK, address: Address, version: number): IRouterContract;
@@ -1,4 +1,4 @@
1
- import type { Address } from "abitype";
1
+ import type { Address } from "viem";
2
2
  import { AddressMap } from "../utils/index.js";
3
3
  import type { Asset } from "./types.js";
4
4
  export declare function balancesMap(assets: Array<Asset>): AddressMap<bigint>;
@@ -1,7 +1,6 @@
1
1
  import type { Address } from "viem";
2
2
  import type { TokenMetaData } from "../base/index.js";
3
3
  import type { PriceFeedContractType } from "../market/index.js";
4
- import type { KYCStateHuman } from "../market/kyc/index.js";
5
4
  export interface BaseContractStateHuman {
6
5
  address: string;
7
6
  version: number;
@@ -194,11 +193,20 @@ export interface MarketStateHuman {
194
193
  emergencyLiquidators: string[];
195
194
  }
196
195
  export interface GearboxStateHuman {
196
+ network: string;
197
197
  block: number;
198
198
  timestamp: string;
199
199
  core: CoreStateHuman;
200
200
  markets: MarketStateHuman[];
201
201
  plugins: Record<string, unknown>;
202
202
  tokens: TokenMetaData[];
203
- kyc: KYCStateHuman;
203
+ }
204
+ /**
205
+ * Human-readable state for all chains managed by {@link MultichainSDK}.
206
+ **/
207
+ export interface MultichainStateHuman {
208
+ /** State format version. */
209
+ version: number;
210
+ /** Per-chain human-readable state. */
211
+ chains: GearboxStateHuman[];
204
212
  }
@@ -1,13 +1,12 @@
1
1
  import type { MarketData } from "../base/index.js";
2
2
  import type { NetworkType } from "../chain/chains.js";
3
3
  import type { AddressProviderState } from "../core/index.js";
4
- import type { KYCState } from "../market/kyc/index.js";
5
4
  import type { PluginStatesMap, PluginsMap } from "../plugins/index.js";
6
5
  /**
7
- * Complete serialisable snapshot of the Gearbox SDK state.
6
+ * Complete serialisable snapshot of the SDK state for a single chain.
8
7
  *
9
- * Produced by {@link GearboxSDK.state} and consumed by
10
- * {@link GearboxSDK.hydrate} for instant offline restoration.
8
+ * Produced by {@link OnchainSDK.state} and consumed by
9
+ * {@link OnchainSDK.hydrate} for instant offline restoration.
11
10
  *
12
11
  * @typeParam Plugins - Map of plugin names to plugin instances.
13
12
  **/
@@ -41,12 +40,19 @@ export interface GearboxState<Plugins extends PluginsMap = {}> {
41
40
  * All loaded market data.
42
41
  **/
43
42
  markets: MarketData[];
44
- /**
45
- * KYC compressor state snapshot, if KYC factories were loaded.
46
- **/
47
- kyc?: KYCState;
48
43
  /**
49
44
  * Per-plugin serialised state.
50
45
  **/
51
46
  plugins: PluginStatesMap<Plugins>;
52
47
  }
48
+ /**
49
+ * Serialised state for all chains managed by {@link MultichainSDK}.
50
+ *
51
+ * @typeParam Plugins - Map of plugin names to plugin instances.
52
+ **/
53
+ export interface MultichainState<Plugins extends PluginsMap = {}> {
54
+ /** State format version. */
55
+ version: number;
56
+ /** Per-chain serialised state. */
57
+ chains: GearboxState<Plugins>[];
58
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Address } from "viem";
2
2
  import type { CreditAccountData } from "../base/index.js";
3
- import type { GearboxSDK } from "../GearboxSDK.js";
3
+ import type { OnchainSDK } from "../OnchainSDK.js";
4
4
  /**
5
5
  * Helper function to filter out low-balance assets
6
6
  * @param account
@@ -8,7 +8,7 @@ import type { GearboxSDK } from "../GearboxSDK.js";
8
8
  */
9
9
  export declare function filterDust(account: CreditAccountData): Record<Address, bigint>;
10
10
  export interface FilterDustUSDOptions {
11
- sdk: GearboxSDK;
11
+ sdk: OnchainSDK;
12
12
  account: CreditAccountData;
13
13
  /**
14
14
  * Dust threshold in USD, without decimals
@@ -12,10 +12,10 @@ export declare function formatNumberToString_(value: bigint | number): string;
12
12
  export declare function formatTimestamp(timestamp: number, raw?: boolean): string;
13
13
  type BigNumberish = bigint | number | string;
14
14
  export declare function rayToNumber(num: BigNumberish): number;
15
- export declare function toSignificant(num: bigint, decimals: number, precision?: number): string;
16
15
  export declare function toBN(num: string, decimals: number): bigint;
17
16
  export declare function shortAddress(address?: string): string;
18
17
  export declare function shortHash(address?: string): string;
19
18
  export declare function formatPercentage(healthFactor: number, decimals?: number): string;
20
19
  export declare function formatLeverage(leverage: number, decimals?: number): string;
20
+ export declare function toSignificant(num: bigint, decimals: number, precision?: number): string;
21
21
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { Address } from "viem";
2
- import type { GearboxSDK } from "../GearboxSDK.js";
2
+ import type { OnchainSDK } from "../OnchainSDK.js";
3
3
  export interface IsDustOptions {
4
- sdk: GearboxSDK;
4
+ sdk: OnchainSDK;
5
5
  token: Address;
6
6
  balance: bigint;
7
7
  creditManager: Address;
@@ -1,3 +1,3 @@
1
- import type { Address } from "abitype";
1
+ import type { Address } from "viem";
2
2
  import type { BaseState, IBaseContract } from "../base/index.js";
3
3
  export declare function toAddress(value: Address | BaseState | IBaseContract): Address;
@@ -1,5 +1,4 @@
1
- import type { AbiEvent } from "abitype";
2
- import type { BlockNumber, Chain, Client, GetLogsParameters, GetLogsReturnType, MaybeAbiEventName, Transport } from "viem";
1
+ import type { AbiEvent, BlockNumber, Chain, Client, GetLogsParameters, GetLogsReturnType, MaybeAbiEventName, Transport } from "viem";
3
2
  export type GetLogsPaginatedParameters<abiEvent extends AbiEvent | undefined = undefined, abiEvents extends readonly AbiEvent[] | readonly unknown[] | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined, _eventName extends string | undefined = MaybeAbiEventName<abiEvent>> = GetLogsParameters<abiEvent, abiEvents, strict, BlockNumber, BlockNumber, _eventName> & {
4
3
  pageSize: bigint;
5
4
  };
@@ -1,3 +1,3 @@
1
- import type { AbiEvent } from "abitype";
1
+ import type { AbiEvent } from "viem";
2
2
  import { type BlockNumber, type Chain, type Client, type GetLogsParameters, type GetLogsReturnType, type Transport } from "viem";
3
3
  export declare function getLogsSafe<chain extends Chain | undefined, const abiEvent extends AbiEvent | undefined = undefined, const abiEvents extends readonly AbiEvent[] | readonly unknown[] | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined, strict extends boolean | undefined = undefined>(client: Client<Transport, chain>, params?: GetLogsParameters<abiEvent, abiEvents, strict, BlockNumber, BlockNumber>): Promise<GetLogsReturnType<abiEvent, abiEvents, strict, BlockNumber, BlockNumber>>;
@@ -1,7 +1,7 @@
1
1
  export * from "./cast.js";
2
- export * from "./executeDelegatedMulticalls.js";
3
2
  export * from "./getLogsPaginated.js";
4
3
  export * from "./getLogsSafe.js";
5
4
  export * from "./sendRawTx.js";
6
5
  export * from "./simulateMulticall.js";
7
6
  export * from "./simulateWithPriceUpdates.js";
7
+ export * from "./watchBlocksAsync.js";
@@ -1,5 +1,4 @@
1
- import type { Narrow } from "abitype";
2
- import type { CallParameters, Chain, Client, ContractFunctionParameters, MulticallContracts, MulticallReturnType, Transport } from "viem";
1
+ import type { CallParameters, Chain, Client, ContractFunctionParameters, MulticallContracts, MulticallReturnType, Narrow, Transport } from "viem";
3
2
  import { BaseError } from "viem";
4
3
  import type { IPriceUpdateTx } from "../../types/index.js";
5
4
  import type { SimulateMulticallParameters } from "./simulateMulticall.js";
@@ -0,0 +1,74 @@
1
+ import type { Chain, Client, Transport } from "viem";
2
+ import { type GetBlockReturnType } from "viem/actions";
3
+ type Block<chain extends Chain | undefined = Chain> = GetBlockReturnType<chain>;
4
+ /**
5
+ * Parameters for {@link watchBlocksAsync}.
6
+ *
7
+ * @typeParam chain - The chain type, derived from the client.
8
+ */
9
+ export interface WatchBlocksAsyncParameters<chain extends Chain | undefined = Chain> {
10
+ /**
11
+ * Async callback invoked when a new block is received.
12
+ * If the handler is still running when the next block arrives, the new block
13
+ * is silently dropped and {@link WatchBlocksAsyncParameters.onDrop | onDrop}
14
+ * is called instead.
15
+ */
16
+ onBlock: (block: Block<chain>, prevBlock: Block<chain> | undefined) => Promise<void>;
17
+ /** Callback invoked when `getBlock` or `onBlock` throws. */
18
+ onError?: ((error: Error) => void) | undefined;
19
+ /**
20
+ * Synchronous callback invoked when a new block is dropped because the
21
+ * previous {@link WatchBlocksAsyncParameters.onBlock | onBlock} handler has
22
+ * not yet resolved.
23
+ */
24
+ onDrop?: ((block: Block<chain>) => void) | undefined;
25
+ /**
26
+ * Polling frequency in milliseconds.
27
+ * @defaultValue `client.pollingInterval`
28
+ */
29
+ pollingInterval?: number | undefined;
30
+ }
31
+ /** Unwatch function returned by {@link watchBlocksAsync}. */
32
+ export type WatchBlocksAsyncReturnType = () => void;
33
+ /**
34
+ * Polls for new blocks over HTTP and invokes an **async** `onBlock` handler.
35
+ *
36
+ * Unlike viem's built-in `watchBlocks`, the handler is awaited. If a new block
37
+ * arrives while the previous handler is still running, the block is silently
38
+ * dropped and the optional `onDrop` callback is invoked synchronously.
39
+ *
40
+ * Only HTTP transports are supported (no WebSocket / IPC).
41
+ *
42
+ * @param client - A viem {@link Client} configured with an HTTP transport.
43
+ * @param parameters - {@link WatchBlocksAsyncParameters}
44
+ * @returns A function that stops polling when called. {@link WatchBlocksAsyncReturnType}
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { createPublicClient, http } from "viem";
49
+ * import { mainnet } from "viem/chains";
50
+ * import { watchBlocksAsync } from "./watchBlocksAsync.js";
51
+ *
52
+ * const client = createPublicClient({
53
+ * chain: mainnet,
54
+ * transport: http(),
55
+ * });
56
+ *
57
+ * const unwatch = watchBlocksAsync(client, {
58
+ * onBlock: async (block, prevBlock) => {
59
+ * console.log("new block", block.number);
60
+ * },
61
+ * onDrop: (block) => {
62
+ * console.log("dropped block", block.number);
63
+ * },
64
+ * onError: (err) => {
65
+ * console.error(err);
66
+ * },
67
+ * });
68
+ *
69
+ * // later
70
+ * unwatch();
71
+ * ```
72
+ */
73
+ export declare function watchBlocksAsync<chain extends Chain | undefined>(client: Client<Transport, chain>, parameters: WatchBlocksAsyncParameters<chain>): WatchBlocksAsyncReturnType;
74
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "13.7.0-kyc.3",
3
+ "version": "14.0.0-next.10",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -79,20 +79,17 @@
79
79
  "@redstone-finance/protocol": "^0.9.0",
80
80
  "@redstone-finance/sdk": "^0.9.0",
81
81
  "@redstone-finance/utils": "^0.9.0",
82
- "@types/bn.js": "^5.2.0",
83
82
  "abitype": "^1.2.3",
84
- "bn.js": "^5.2.3",
85
83
  "buffer": "^6.0.3",
86
84
  "date-fns": "^4.1.0",
87
- "decimal.js-light": "^2.5.1",
88
85
  "viem": ">=2.23.15 <3.0.0",
89
86
  "zod": "^4.3.6"
90
87
  },
91
88
  "devDependencies": {
92
- "@biomejs/biome": "^2.4.11",
89
+ "@biomejs/biome": "^2.4.12",
93
90
  "@commitlint/cli": "^20.5.0",
94
91
  "@commitlint/config-conventional": "^20.5.0",
95
- "@gearbox-protocol/biome-config": "^1.0.26",
92
+ "@gearbox-protocol/biome-config": "^1.0.27",
96
93
  "@types/cross-spawn": "^6.0.6",
97
94
  "axios": "^1.15.0",
98
95
  "cross-spawn": "^7.0.6",
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var iDSRegistryService_exports = {};
20
- __export(iDSRegistryService_exports, {
21
- iDSRegistryServiceAbi: () => iDSRegistryServiceAbi
22
- });
23
- module.exports = __toCommonJS(iDSRegistryService_exports);
24
- const iDSRegistryServiceAbi = [
25
- {
26
- type: "function",
27
- name: "addWallet",
28
- inputs: [
29
- { name: "wallet", type: "address", internalType: "address" },
30
- { name: "investorId", type: "string", internalType: "string" }
31
- ],
32
- outputs: [],
33
- stateMutability: "nonpayable"
34
- },
35
- {
36
- type: "function",
37
- name: "getInvestor",
38
- inputs: [{ name: "wallet", type: "address", internalType: "address" }],
39
- outputs: [{ name: "", type: "string", internalType: "string" }],
40
- stateMutability: "view"
41
- },
42
- {
43
- type: "function",
44
- name: "isInvestor",
45
- inputs: [{ name: "investorId", type: "string", internalType: "string" }],
46
- outputs: [{ name: "", type: "bool", internalType: "bool" }],
47
- stateMutability: "view"
48
- },
49
- {
50
- type: "function",
51
- name: "isWallet",
52
- inputs: [{ name: "wallet", type: "address", internalType: "address" }],
53
- outputs: [{ name: "", type: "bool", internalType: "bool" }],
54
- stateMutability: "view"
55
- },
56
- {
57
- type: "function",
58
- name: "registerInvestor",
59
- inputs: [
60
- { name: "investorId", type: "string", internalType: "string" },
61
- { name: "collisionHash", type: "string", internalType: "string" }
62
- ],
63
- outputs: [],
64
- stateMutability: "nonpayable"
65
- }
66
- ];
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- iDSRegistryServiceAbi
70
- });
@@ -1,71 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var iDSToken_exports = {};
20
- __export(iDSToken_exports, {
21
- iDSTokenAbi: () => iDSTokenAbi
22
- });
23
- module.exports = __toCommonJS(iDSToken_exports);
24
- const iDSTokenAbi = [
25
- {
26
- type: "function",
27
- name: "REGISTRY_SERVICE",
28
- inputs: [],
29
- outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
30
- stateMutability: "view"
31
- },
32
- {
33
- type: "function",
34
- name: "TRUST_SERVICE",
35
- inputs: [],
36
- outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
37
- stateMutability: "view"
38
- },
39
- {
40
- type: "function",
41
- name: "burn",
42
- inputs: [
43
- { name: "from", type: "address", internalType: "address" },
44
- { name: "amount", type: "uint256", internalType: "uint256" },
45
- { name: "reason", type: "string", internalType: "string" }
46
- ],
47
- outputs: [],
48
- stateMutability: "nonpayable"
49
- },
50
- {
51
- type: "function",
52
- name: "getDSService",
53
- inputs: [{ name: "serviceId", type: "uint256", internalType: "uint256" }],
54
- outputs: [{ name: "", type: "address", internalType: "address" }],
55
- stateMutability: "view"
56
- },
57
- {
58
- type: "function",
59
- name: "issueTokens",
60
- inputs: [
61
- { name: "to", type: "address", internalType: "address" },
62
- { name: "amount", type: "uint256", internalType: "uint256" }
63
- ],
64
- outputs: [],
65
- stateMutability: "nonpayable"
66
- }
67
- ];
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- iDSTokenAbi
71
- });