@gearbox-protocol/sdk 15.1.0-next.1 → 15.1.0-next.11

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 (436) hide show
  1. package/dist/cjs/abi/iExpirable.js +15 -0
  2. package/dist/cjs/common-utils/utils/apy/get-single-quota-borrow-rate.js +2 -0
  3. package/dist/cjs/common-utils/utils/creditAccount/calc-health-factor.js +24 -22
  4. package/dist/cjs/common-utils/utils/creditAccount/calc-quota-borrow-rate.js +2 -0
  5. package/dist/cjs/common-utils/utils/creditAccount/get-time-to-liquidation.js +8 -5
  6. package/dist/cjs/common-utils/utils/creditAccount/liquidation-price.js +21 -11
  7. package/dist/cjs/dev/AccountOpener.js +0 -1
  8. package/dist/cjs/dev/compareOpportunities.js +137 -0
  9. package/dist/cjs/dev/comparePositions.js +183 -0
  10. package/dist/cjs/dev/fieldDiff.js +241 -0
  11. package/dist/cjs/model/charts.js +147 -0
  12. package/dist/cjs/model/charts.schema.js +240 -0
  13. package/dist/cjs/model/index.js +35 -22
  14. package/dist/cjs/model/liquidations.schema.js +1 -1
  15. package/dist/cjs/model/notices.schema.js +25 -0
  16. package/dist/cjs/model/opportunities.schema.js +1 -1
  17. package/dist/cjs/model/positions.schema.js +48 -2
  18. package/dist/cjs/new-sdk/AbstractNamespace.js +34 -4
  19. package/dist/cjs/new-sdk/GearboxSDK.js +72 -3
  20. package/dist/cjs/new-sdk/execute/ExecuteApi.js +95 -0
  21. package/dist/cjs/new-sdk/execute/index.js +3 -0
  22. package/dist/cjs/new-sdk/index.js +7 -0
  23. package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +29 -6
  24. package/dist/cjs/new-sdk/positions/PositionsNamespace.js +3 -6
  25. package/dist/cjs/new-sdk/simulate/SimulateApi.js +361 -0
  26. package/dist/cjs/new-sdk/simulate/index.js +4 -0
  27. package/dist/cjs/new-sdk/utils/index.js +0 -1
  28. package/dist/cjs/offchain/AbstractOffchainNamespace.js +10 -7
  29. package/dist/cjs/offchain/GearboxAPI.js +7 -0
  30. package/dist/cjs/offchain/index.js +3 -0
  31. package/dist/cjs/offchain/notices/OffchainNotices.js +27 -0
  32. package/dist/cjs/offchain/notices/index.js +3 -0
  33. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +4 -8
  34. package/dist/cjs/offchain/positions/OffchainPositions.js +12 -12
  35. package/dist/cjs/preview/preview/CreditAccountState.js +14 -1
  36. package/dist/cjs/preview/preview/buildDelayedPreview.js +16 -6
  37. package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +9 -2
  38. package/dist/cjs/preview/preview/previewOpenCreditAccount.js +11 -3
  39. package/dist/cjs/preview/preview/previewOperation.js +1 -1
  40. package/dist/cjs/sdk/MultichainSDK.js +3 -4
  41. package/dist/cjs/sdk/OnchainSDK.js +42 -13
  42. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +2 -8
  43. package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +2 -90
  44. package/dist/cjs/sdk/accounts/index.js +5 -2
  45. package/dist/cjs/sdk/accounts/intents/guards.js +114 -0
  46. package/dist/cjs/sdk/accounts/intents/index.js +216 -358
  47. package/dist/cjs/sdk/accounts/intents/math.js +56 -0
  48. package/dist/cjs/sdk/accounts/intents/open-strategy.js +133 -0
  49. package/dist/cjs/sdk/accounts/intents/operations.js +165 -0
  50. package/dist/cjs/sdk/accounts/intents/plan.js +373 -0
  51. package/dist/cjs/sdk/accounts/intents/realize.js +301 -0
  52. package/dist/cjs/sdk/accounts/intents/testing/delayed.js +50 -0
  53. package/dist/cjs/sdk/accounts/intents/testing/market.js +166 -0
  54. package/dist/cjs/sdk/accounts/intents/testing/sdk-mock.js +194 -35
  55. package/dist/cjs/sdk/accounts/intents/tests/add-collateral.fixtures.js +123 -0
  56. package/dist/cjs/sdk/accounts/intents/tests/adjust-leverage.fixtures.js +254 -0
  57. package/dist/cjs/sdk/accounts/intents/tests/deposit.fixtures.js +324 -0
  58. package/dist/cjs/sdk/accounts/intents/tests/finish-decrease-leverage.fixtures.js +242 -0
  59. package/dist/cjs/sdk/accounts/intents/tests/finish-withdraw.fixtures.js +383 -0
  60. package/dist/cjs/sdk/accounts/intents/tests/open-strategy.fixtures.js +133 -0
  61. package/dist/cjs/sdk/accounts/intents/tests/withdraw-asset.fixtures.js +131 -0
  62. package/dist/cjs/sdk/accounts/intents/tests/withdraw.fixtures.js +426 -0
  63. package/dist/cjs/sdk/accounts/intents/types.js +16 -0
  64. package/dist/cjs/sdk/accounts/intents/utils/adjust-state-to-snapshot.js +18 -0
  65. package/dist/cjs/sdk/accounts/intents/utils/credit-account-slice.js +45 -0
  66. package/dist/cjs/sdk/accounts/intents/utils/index.js +17 -8
  67. package/dist/cjs/sdk/accounts/intents/utils/ledger.js +94 -0
  68. package/dist/cjs/sdk/accounts/intents/utils/pick-token.js +72 -0
  69. package/dist/cjs/sdk/accounts/intents/utils/quotas-for-update.js +27 -0
  70. package/dist/cjs/sdk/accounts/intents/utils/router-path.js +86 -0
  71. package/dist/cjs/sdk/accounts/intents/view.js +38 -0
  72. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +0 -3
  73. package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +29 -18
  74. package/dist/cjs/sdk/base/BaseContract.js +1 -1
  75. package/dist/cjs/sdk/base/TokensMeta.js +78 -27
  76. package/dist/cjs/sdk/index.js +30 -7
  77. package/dist/cjs/sdk/market/MarketRegister.js +16 -7
  78. package/dist/cjs/sdk/market/ZapperRegister.js +56 -25
  79. package/dist/cjs/sdk/market/credit/CreditManagerV310Contract.js +1 -12
  80. package/dist/cjs/sdk/market/credit/CreditSuite.js +28 -9
  81. package/dist/cjs/sdk/market/credit/index.js +3 -0
  82. package/dist/cjs/sdk/market/credit/isStrategyCollateral.js +50 -0
  83. package/dist/cjs/sdk/market/index.js +17 -0
  84. package/dist/cjs/sdk/market/math.js +65 -45
  85. package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +10 -3
  86. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +15 -1
  87. package/dist/cjs/sdk/market/rwa/RWARegistry.js +22 -0
  88. package/dist/cjs/sdk/opportunities/index.js +0 -13
  89. package/dist/cjs/sdk/options.js +1 -5
  90. package/dist/cjs/sdk/pools/PoolService.js +133 -4
  91. package/dist/cjs/sdk/pools/index.js +2 -0
  92. package/dist/cjs/sdk/positions/PositionsService.js +218 -1
  93. package/dist/cjs/sdk/positions/calcBorrowRate.js +43 -0
  94. package/dist/cjs/sdk/positions/calcHealthFactor.js +52 -0
  95. package/dist/cjs/sdk/positions/calcLiquidationPrice.js +23 -0
  96. package/dist/cjs/sdk/positions/calcLiquidationPriceForTarget.js +30 -0
  97. package/dist/cjs/sdk/positions/calcTimeToLiquidationMs.js +19 -0
  98. package/dist/cjs/sdk/positions/index.js +12 -1
  99. package/dist/cjs/sdk/positions/types.js +31 -0
  100. package/dist/cjs/sdk/utils/abi-decode.js +2 -2
  101. package/dist/cjs/sdk/utils/viem/executeMulticallBatches.js +32 -0
  102. package/dist/cjs/sdk/utils/viem/index.js +2 -0
  103. package/dist/esm/abi/iExpirable.js +14 -0
  104. package/dist/esm/common-utils/utils/apy/get-single-quota-borrow-rate.js +2 -0
  105. package/dist/esm/common-utils/utils/creditAccount/calc-health-factor.js +24 -22
  106. package/dist/esm/common-utils/utils/creditAccount/calc-quota-borrow-rate.js +2 -0
  107. package/dist/esm/common-utils/utils/creditAccount/get-time-to-liquidation.js +8 -5
  108. package/dist/esm/common-utils/utils/creditAccount/liquidation-price.js +21 -11
  109. package/dist/esm/dev/AccountOpener.js +0 -1
  110. package/dist/esm/dev/compareOpportunities.js +135 -0
  111. package/dist/esm/dev/comparePositions.js +181 -0
  112. package/dist/esm/dev/fieldDiff.js +224 -0
  113. package/dist/esm/model/charts.js +140 -0
  114. package/dist/esm/model/charts.schema.js +226 -0
  115. package/dist/esm/model/index.js +9 -7
  116. package/dist/esm/model/liquidations.schema.js +1 -1
  117. package/dist/esm/model/notices.schema.js +23 -0
  118. package/dist/esm/model/opportunities.schema.js +1 -1
  119. package/dist/esm/model/positions.schema.js +46 -4
  120. package/dist/esm/new-sdk/AbstractNamespace.js +34 -4
  121. package/dist/esm/new-sdk/GearboxSDK.js +72 -4
  122. package/dist/esm/new-sdk/execute/ExecuteApi.js +94 -0
  123. package/dist/esm/new-sdk/execute/index.js +2 -0
  124. package/dist/esm/new-sdk/index.js +6 -2
  125. package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +29 -6
  126. package/dist/esm/new-sdk/positions/PositionsNamespace.js +3 -6
  127. package/dist/esm/new-sdk/simulate/SimulateApi.js +360 -0
  128. package/dist/esm/new-sdk/simulate/index.js +3 -0
  129. package/dist/esm/new-sdk/utils/index.js +0 -1
  130. package/dist/esm/offchain/AbstractOffchainNamespace.js +10 -7
  131. package/dist/esm/offchain/GearboxAPI.js +7 -0
  132. package/dist/esm/offchain/index.js +3 -1
  133. package/dist/esm/offchain/notices/OffchainNotices.js +26 -0
  134. package/dist/esm/offchain/notices/index.js +2 -0
  135. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +4 -8
  136. package/dist/esm/offchain/positions/OffchainPositions.js +12 -12
  137. package/dist/esm/preview/preview/CreditAccountState.js +14 -1
  138. package/dist/esm/preview/preview/buildDelayedPreview.js +16 -6
  139. package/dist/esm/preview/preview/previewAdjustCreditAccount.js +9 -2
  140. package/dist/esm/preview/preview/previewOpenCreditAccount.js +11 -3
  141. package/dist/esm/preview/preview/previewOperation.js +1 -1
  142. package/dist/esm/sdk/MultichainSDK.js +3 -4
  143. package/dist/esm/sdk/OnchainSDK.js +42 -13
  144. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -8
  145. package/dist/esm/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +2 -90
  146. package/dist/esm/sdk/accounts/index.js +3 -2
  147. package/dist/esm/sdk/accounts/intents/guards.js +108 -0
  148. package/dist/esm/sdk/accounts/intents/index.js +214 -358
  149. package/dist/esm/sdk/accounts/intents/math.js +51 -0
  150. package/dist/esm/sdk/accounts/intents/open-strategy.js +132 -0
  151. package/dist/esm/sdk/accounts/intents/operations.js +153 -0
  152. package/dist/esm/sdk/accounts/intents/plan.js +361 -0
  153. package/dist/esm/sdk/accounts/intents/realize.js +300 -0
  154. package/dist/esm/sdk/accounts/intents/testing/delayed.js +38 -0
  155. package/dist/esm/sdk/accounts/intents/testing/market.js +148 -0
  156. package/dist/esm/sdk/accounts/intents/testing/sdk-mock.js +194 -35
  157. package/dist/esm/sdk/accounts/intents/tests/add-collateral.fixtures.js +110 -0
  158. package/dist/esm/sdk/accounts/intents/tests/adjust-leverage.fixtures.js +234 -0
  159. package/dist/esm/sdk/accounts/intents/tests/deposit.fixtures.js +302 -0
  160. package/dist/esm/sdk/accounts/intents/tests/finish-decrease-leverage.fixtures.js +220 -0
  161. package/dist/esm/sdk/accounts/intents/tests/finish-withdraw.fixtures.js +355 -0
  162. package/dist/esm/sdk/accounts/intents/tests/open-strategy.fixtures.js +119 -0
  163. package/dist/esm/sdk/accounts/intents/tests/withdraw-asset.fixtures.js +117 -0
  164. package/dist/esm/sdk/accounts/intents/tests/withdraw.fixtures.js +402 -0
  165. package/dist/esm/sdk/accounts/intents/types.js +16 -1
  166. package/dist/esm/sdk/accounts/intents/utils/adjust-state-to-snapshot.js +17 -0
  167. package/dist/esm/sdk/accounts/intents/utils/credit-account-slice.js +43 -0
  168. package/dist/esm/sdk/accounts/intents/utils/index.js +9 -7
  169. package/dist/esm/sdk/accounts/intents/utils/ledger.js +93 -0
  170. package/dist/esm/sdk/accounts/intents/utils/pick-token.js +68 -0
  171. package/dist/esm/sdk/accounts/intents/utils/quotas-for-update.js +27 -1
  172. package/dist/esm/sdk/accounts/intents/utils/router-path.js +85 -0
  173. package/dist/esm/sdk/accounts/intents/view.js +37 -0
  174. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +0 -3
  175. package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +29 -18
  176. package/dist/esm/sdk/base/BaseContract.js +1 -1
  177. package/dist/esm/sdk/base/TokensMeta.js +78 -27
  178. package/dist/esm/sdk/index.js +13 -4
  179. package/dist/esm/sdk/market/MarketRegister.js +16 -7
  180. package/dist/esm/sdk/market/ZapperRegister.js +56 -25
  181. package/dist/esm/sdk/market/credit/CreditManagerV310Contract.js +2 -13
  182. package/dist/esm/sdk/market/credit/CreditSuite.js +29 -10
  183. package/dist/esm/sdk/market/credit/index.js +2 -1
  184. package/dist/esm/sdk/market/credit/isStrategyCollateral.js +48 -0
  185. package/dist/esm/sdk/market/index.js +3 -1
  186. package/dist/esm/sdk/market/math.js +60 -41
  187. package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +10 -3
  188. package/dist/esm/sdk/market/pool/PoolV310Contract.js +16 -2
  189. package/dist/esm/sdk/market/rwa/RWARegistry.js +22 -0
  190. package/dist/esm/sdk/opportunities/index.js +1 -2
  191. package/dist/esm/sdk/options.js +1 -5
  192. package/dist/esm/sdk/pools/PoolService.js +133 -6
  193. package/dist/esm/sdk/pools/index.js +2 -2
  194. package/dist/esm/sdk/positions/PositionsService.js +218 -1
  195. package/dist/esm/sdk/positions/calcBorrowRate.js +42 -0
  196. package/dist/esm/sdk/positions/calcHealthFactor.js +51 -0
  197. package/dist/esm/sdk/positions/calcLiquidationPrice.js +22 -0
  198. package/dist/esm/sdk/positions/calcLiquidationPriceForTarget.js +29 -0
  199. package/dist/esm/sdk/positions/calcTimeToLiquidationMs.js +18 -0
  200. package/dist/esm/sdk/positions/index.js +7 -2
  201. package/dist/esm/sdk/positions/types.js +31 -1
  202. package/dist/esm/sdk/utils/abi-decode.js +2 -2
  203. package/dist/esm/sdk/utils/viem/executeMulticallBatches.js +31 -0
  204. package/dist/esm/sdk/utils/viem/index.js +2 -1
  205. package/dist/types/abi/iExpirable.d.ts +14 -0
  206. package/dist/types/common-utils/utils/apy/get-single-quota-borrow-rate.d.ts +2 -0
  207. package/dist/types/common-utils/utils/creditAccount/calc-health-factor.d.ts +3 -0
  208. package/dist/types/common-utils/utils/creditAccount/calc-quota-borrow-rate.d.ts +2 -0
  209. package/dist/types/common-utils/utils/creditAccount/get-time-to-liquidation.d.ts +6 -1
  210. package/dist/types/common-utils/utils/creditAccount/liquidation-price.d.ts +3 -0
  211. package/dist/types/dev/compareOpportunities.d.ts +105 -0
  212. package/dist/types/dev/comparePositions.d.ts +149 -0
  213. package/dist/types/dev/fieldDiff.d.ts +167 -0
  214. package/dist/types/model/charts.d.ts +349 -0
  215. package/dist/types/model/charts.schema.d.ts +364 -0
  216. package/dist/types/model/index.d.ts +8 -6
  217. package/dist/types/model/notices.d.ts +29 -0
  218. package/dist/types/model/notices.schema.d.ts +23 -0
  219. package/dist/types/model/opportunities.d.ts +9 -9
  220. package/dist/types/model/positions.d.ts +133 -7
  221. package/dist/types/model/positions.schema.d.ts +128 -1
  222. package/dist/types/new-sdk/AbstractNamespace.d.ts +15 -2
  223. package/dist/types/new-sdk/GearboxSDK.d.ts +14 -2
  224. package/dist/types/new-sdk/execute/ExecuteApi.d.ts +108 -0
  225. package/dist/types/new-sdk/execute/index.d.ts +2 -0
  226. package/dist/types/new-sdk/index.d.ts +8 -4
  227. package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +19 -7
  228. package/dist/types/new-sdk/opportunities/types.d.ts +30 -9
  229. package/dist/types/new-sdk/positions/PositionsNamespace.d.ts +4 -5
  230. package/dist/types/new-sdk/positions/types.d.ts +9 -9
  231. package/dist/types/new-sdk/simulate/SimulateApi.d.ts +90 -0
  232. package/dist/types/new-sdk/simulate/index.d.ts +3 -0
  233. package/dist/types/new-sdk/simulate/types.d.ts +508 -0
  234. package/dist/types/new-sdk/types.d.ts +35 -1
  235. package/dist/types/new-sdk/utils/index.d.ts +1 -2
  236. package/dist/types/offchain/AbstractOffchainNamespace.d.ts +5 -21
  237. package/dist/types/offchain/GearboxAPI.d.ts +6 -0
  238. package/dist/types/offchain/index.d.ts +4 -2
  239. package/dist/types/offchain/notices/OffchainNotices.d.ts +19 -0
  240. package/dist/types/offchain/notices/index.d.ts +2 -0
  241. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +8 -4
  242. package/dist/types/offchain/positions/OffchainPositions.d.ts +8 -6
  243. package/dist/types/preview/preview/CreditAccountState.d.ts +6 -0
  244. package/dist/types/preview/preview/buildDelayedPreview.d.ts +5 -1
  245. package/dist/types/preview/preview/types.d.ts +4 -2
  246. package/dist/types/sdk/MultichainSDK.d.ts +0 -5
  247. package/dist/types/sdk/OnchainSDK.d.ts +1 -5
  248. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -7
  249. package/dist/types/sdk/accounts/credit-account-compressor/CreditAccountCompressor.d.ts +3 -12
  250. package/dist/types/sdk/accounts/credit-account-compressor/index.d.ts +2 -2
  251. package/dist/types/sdk/accounts/credit-account-compressor/types.d.ts +1 -19
  252. package/dist/types/sdk/accounts/index.d.ts +7 -5
  253. package/dist/types/sdk/accounts/intents/guards.d.ts +72 -0
  254. package/dist/types/sdk/accounts/intents/index.d.ts +130 -15
  255. package/dist/types/sdk/accounts/intents/math.d.ts +46 -0
  256. package/dist/types/sdk/accounts/intents/open-strategy.d.ts +64 -0
  257. package/dist/types/sdk/accounts/intents/operations.d.ts +215 -0
  258. package/dist/types/sdk/accounts/intents/plan.d.ts +189 -0
  259. package/dist/types/sdk/accounts/intents/realize.d.ts +35 -0
  260. package/dist/types/sdk/accounts/intents/testing/delayed.d.ts +50 -0
  261. package/dist/types/sdk/accounts/intents/testing/expect.d.ts +17 -21
  262. package/dist/types/sdk/accounts/intents/testing/market.d.ts +91 -0
  263. package/dist/types/sdk/accounts/intents/testing/sdk-mock.d.ts +64 -16
  264. package/dist/types/sdk/accounts/intents/tests/add-collateral.fixtures.d.ts +45 -0
  265. package/dist/types/sdk/accounts/intents/tests/adjust-leverage.fixtures.d.ts +56 -0
  266. package/dist/types/sdk/accounts/intents/tests/deposit.fixtures.d.ts +64 -0
  267. package/dist/types/sdk/accounts/intents/tests/finish-decrease-leverage.fixtures.d.ts +107 -0
  268. package/dist/types/sdk/accounts/intents/tests/finish-withdraw.fixtures.d.ts +136 -0
  269. package/dist/types/sdk/accounts/intents/tests/open-strategy.fixtures.d.ts +56 -0
  270. package/dist/types/sdk/accounts/intents/tests/withdraw-asset.fixtures.d.ts +60 -0
  271. package/dist/types/sdk/accounts/intents/tests/withdraw.fixtures.d.ts +79 -0
  272. package/dist/types/sdk/accounts/intents/types.d.ts +369 -43
  273. package/dist/types/sdk/accounts/intents/utils/adjust-state-to-snapshot.d.ts +13 -0
  274. package/dist/types/sdk/accounts/intents/utils/assemble-operation-calls.d.ts +1 -1
  275. package/dist/types/sdk/accounts/intents/utils/credit-account-slice.d.ts +29 -0
  276. package/dist/types/sdk/accounts/intents/utils/index.d.ts +7 -5
  277. package/dist/types/sdk/accounts/intents/utils/ledger.d.ts +41 -0
  278. package/dist/types/sdk/accounts/intents/utils/pick-token.d.ts +55 -0
  279. package/dist/types/sdk/accounts/intents/utils/quotas-for-update.d.ts +15 -4
  280. package/dist/types/sdk/accounts/intents/utils/router-path.d.ts +70 -0
  281. package/dist/types/sdk/accounts/intents/view.d.ts +15 -0
  282. package/dist/types/sdk/accounts/types.d.ts +17 -14
  283. package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +6 -0
  284. package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +18 -0
  285. package/dist/types/sdk/base/TokensMeta.d.ts +44 -1
  286. package/dist/types/sdk/base/index.d.ts +2 -2
  287. package/dist/types/sdk/base/token-types.d.ts +12 -1
  288. package/dist/types/sdk/index.d.ts +28 -19
  289. package/dist/types/sdk/market/MarketRegister.d.ts +7 -3
  290. package/dist/types/sdk/market/ZapperRegister.d.ts +20 -2
  291. package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +0 -4
  292. package/dist/types/sdk/market/credit/CreditSuite.d.ts +6 -3
  293. package/dist/types/sdk/market/credit/index.d.ts +2 -1
  294. package/dist/types/sdk/market/credit/isStrategyCollateral.d.ts +74 -0
  295. package/dist/types/sdk/market/credit/types.d.ts +2 -9
  296. package/dist/types/sdk/market/index.d.ts +4 -2
  297. package/dist/types/sdk/market/math.d.ts +46 -34
  298. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +6 -2
  299. package/dist/types/sdk/market/oracle/types.d.ts +10 -2
  300. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +5 -0
  301. package/dist/types/sdk/market/pool/types.d.ts +5 -0
  302. package/dist/types/sdk/market/rwa/RWARegistry.d.ts +13 -0
  303. package/dist/types/sdk/market/types.d.ts +5 -1
  304. package/dist/types/sdk/opportunities/index.d.ts +1 -2
  305. package/dist/types/sdk/options.d.ts +0 -1
  306. package/dist/types/sdk/pools/PoolService.d.ts +32 -2
  307. package/dist/types/sdk/pools/index.d.ts +3 -3
  308. package/dist/types/sdk/pools/types.d.ts +109 -4
  309. package/dist/types/sdk/positions/PositionsService.d.ts +33 -2
  310. package/dist/types/sdk/positions/calcBorrowRate.d.ts +40 -0
  311. package/dist/types/sdk/positions/calcHealthFactor.d.ts +55 -0
  312. package/dist/types/sdk/positions/calcLiquidationPrice.d.ts +12 -0
  313. package/dist/types/sdk/positions/calcLiquidationPriceForTarget.d.ts +43 -0
  314. package/dist/types/sdk/positions/calcTimeToLiquidationMs.d.ts +16 -0
  315. package/dist/types/sdk/positions/index.d.ts +7 -2
  316. package/dist/types/sdk/positions/types.d.ts +58 -1
  317. package/dist/types/sdk/types/state.d.ts +6 -0
  318. package/dist/types/sdk/utils/viem/executeMulticallBatches.d.ts +39 -0
  319. package/dist/types/sdk/utils/viem/index.d.ts +3 -2
  320. package/package.json +2 -1
  321. package/dist/cjs/model/history.js +0 -53
  322. package/dist/cjs/model/history.schema.js +0 -128
  323. package/dist/cjs/sdk/accounts/intents/intents/index.js +0 -14
  324. package/dist/cjs/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.js +0 -121
  325. package/dist/cjs/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.js +0 -15
  326. package/dist/cjs/sdk/accounts/intents/intents/resume/close/close.fixtures.js +0 -108
  327. package/dist/cjs/sdk/accounts/intents/intents/resume/close/close.js +0 -51
  328. package/dist/cjs/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.fixtures.js +0 -130
  329. package/dist/cjs/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.js +0 -83
  330. package/dist/cjs/sdk/accounts/intents/intents/resume/deposit/deposit.fixtures.js +0 -117
  331. package/dist/cjs/sdk/accounts/intents/intents/resume/deposit/deposit.js +0 -15
  332. package/dist/cjs/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.fixtures.js +0 -95
  333. package/dist/cjs/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.js +0 -15
  334. package/dist/cjs/sdk/accounts/intents/intents/resume/index.js +0 -13
  335. package/dist/cjs/sdk/accounts/intents/intents/resume/withdraw/withdraw.fixtures.js +0 -138
  336. package/dist/cjs/sdk/accounts/intents/intents/resume/withdraw/withdraw.js +0 -161
  337. package/dist/cjs/sdk/accounts/intents/operations/add-collateral/index.js +0 -17
  338. package/dist/cjs/sdk/accounts/intents/operations/claim-delayed/index.js +0 -54
  339. package/dist/cjs/sdk/accounts/intents/operations/close-credit-account/index.js +0 -26
  340. package/dist/cjs/sdk/accounts/intents/operations/decrease-debt/index.js +0 -12
  341. package/dist/cjs/sdk/accounts/intents/operations/increase-debt/index.js +0 -12
  342. package/dist/cjs/sdk/accounts/intents/operations/index.js +0 -27
  343. package/dist/cjs/sdk/accounts/intents/operations/quota-update/index.js +0 -22
  344. package/dist/cjs/sdk/accounts/intents/operations/repay-credit-account/index.js +0 -22
  345. package/dist/cjs/sdk/accounts/intents/operations/start-delayed-withdrawal/index.js +0 -18
  346. package/dist/cjs/sdk/accounts/intents/operations/swap/index.js +0 -18
  347. package/dist/cjs/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +0 -27
  348. package/dist/cjs/sdk/accounts/intents/operations/withdraw-collateral/index.js +0 -43
  349. package/dist/cjs/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +0 -27
  350. package/dist/cjs/sdk/accounts/intents/quoters/close.js +0 -58
  351. package/dist/cjs/sdk/accounts/intents/quoters/index.js +0 -7
  352. package/dist/cjs/sdk/accounts/intents/quoters/swap.js +0 -79
  353. package/dist/cjs/sdk/accounts/intents/testing/expect.js +0 -167
  354. package/dist/cjs/sdk/accounts/intents/testing/resume.js +0 -172
  355. package/dist/cjs/sdk/accounts/intents/utils/simulate-adjust-state.js +0 -39
  356. package/dist/cjs/sdk/accounts/intents/utils/simulate-assets.js +0 -69
  357. package/dist/cjs/sdk/accounts/intents/utils/with-quota-update.js +0 -13
  358. package/dist/esm/model/history.js +0 -49
  359. package/dist/esm/model/history.schema.js +0 -116
  360. package/dist/esm/sdk/accounts/intents/intents/index.js +0 -8
  361. package/dist/esm/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.js +0 -107
  362. package/dist/esm/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.js +0 -14
  363. package/dist/esm/sdk/accounts/intents/intents/resume/close/close.fixtures.js +0 -94
  364. package/dist/esm/sdk/accounts/intents/intents/resume/close/close.js +0 -50
  365. package/dist/esm/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.fixtures.js +0 -114
  366. package/dist/esm/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.js +0 -82
  367. package/dist/esm/sdk/accounts/intents/intents/resume/deposit/deposit.fixtures.js +0 -110
  368. package/dist/esm/sdk/accounts/intents/intents/resume/deposit/deposit.js +0 -14
  369. package/dist/esm/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.fixtures.js +0 -88
  370. package/dist/esm/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.js +0 -14
  371. package/dist/esm/sdk/accounts/intents/intents/resume/index.js +0 -7
  372. package/dist/esm/sdk/accounts/intents/intents/resume/withdraw/withdraw.fixtures.js +0 -121
  373. package/dist/esm/sdk/accounts/intents/intents/resume/withdraw/withdraw.js +0 -160
  374. package/dist/esm/sdk/accounts/intents/operations/add-collateral/index.js +0 -16
  375. package/dist/esm/sdk/accounts/intents/operations/claim-delayed/index.js +0 -52
  376. package/dist/esm/sdk/accounts/intents/operations/close-credit-account/index.js +0 -25
  377. package/dist/esm/sdk/accounts/intents/operations/decrease-debt/index.js +0 -11
  378. package/dist/esm/sdk/accounts/intents/operations/increase-debt/index.js +0 -11
  379. package/dist/esm/sdk/accounts/intents/operations/index.js +0 -14
  380. package/dist/esm/sdk/accounts/intents/operations/quota-update/index.js +0 -21
  381. package/dist/esm/sdk/accounts/intents/operations/repay-credit-account/index.js +0 -21
  382. package/dist/esm/sdk/accounts/intents/operations/start-delayed-withdrawal/index.js +0 -17
  383. package/dist/esm/sdk/accounts/intents/operations/swap/index.js +0 -17
  384. package/dist/esm/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +0 -26
  385. package/dist/esm/sdk/accounts/intents/operations/withdraw-collateral/index.js +0 -42
  386. package/dist/esm/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +0 -26
  387. package/dist/esm/sdk/accounts/intents/quoters/close.js +0 -56
  388. package/dist/esm/sdk/accounts/intents/quoters/index.js +0 -3
  389. package/dist/esm/sdk/accounts/intents/quoters/swap.js +0 -77
  390. package/dist/esm/sdk/accounts/intents/testing/expect.js +0 -162
  391. package/dist/esm/sdk/accounts/intents/testing/resume.js +0 -157
  392. package/dist/esm/sdk/accounts/intents/utils/simulate-adjust-state.js +0 -38
  393. package/dist/esm/sdk/accounts/intents/utils/simulate-assets.js +0 -68
  394. package/dist/esm/sdk/accounts/intents/utils/with-quota-update.js +0 -12
  395. package/dist/types/model/history.d.ts +0 -153
  396. package/dist/types/model/history.schema.d.ts +0 -95
  397. package/dist/types/new-sdk/utils/history.d.ts +0 -18
  398. package/dist/types/sdk/accounts/intents/intents/index.d.ts +0 -8
  399. package/dist/types/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.d.ts +0 -13
  400. package/dist/types/sdk/accounts/intents/intents/resume/add-collateral/add-collateral.fixtures.d.ts +0 -38
  401. package/dist/types/sdk/accounts/intents/intents/resume/close/close.d.ts +0 -26
  402. package/dist/types/sdk/accounts/intents/intents/resume/close/close.fixtures.d.ts +0 -63
  403. package/dist/types/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.d.ts +0 -26
  404. package/dist/types/sdk/accounts/intents/intents/resume/decrease-leverage/decrease-leverage.fixtures.d.ts +0 -86
  405. package/dist/types/sdk/accounts/intents/intents/resume/deposit/deposit.d.ts +0 -13
  406. package/dist/types/sdk/accounts/intents/intents/resume/deposit/deposit.fixtures.d.ts +0 -48
  407. package/dist/types/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.d.ts +0 -13
  408. package/dist/types/sdk/accounts/intents/intents/resume/increase-leverage/increase-leverage.fixtures.d.ts +0 -46
  409. package/dist/types/sdk/accounts/intents/intents/resume/index.d.ts +0 -7
  410. package/dist/types/sdk/accounts/intents/intents/resume/withdraw/withdraw.d.ts +0 -33
  411. package/dist/types/sdk/accounts/intents/intents/resume/withdraw/withdraw.fixtures.d.ts +0 -68
  412. package/dist/types/sdk/accounts/intents/operations/add-collateral/index.d.ts +0 -23
  413. package/dist/types/sdk/accounts/intents/operations/claim-delayed/index.d.ts +0 -55
  414. package/dist/types/sdk/accounts/intents/operations/close-credit-account/index.d.ts +0 -22
  415. package/dist/types/sdk/accounts/intents/operations/decrease-debt/index.d.ts +0 -18
  416. package/dist/types/sdk/accounts/intents/operations/increase-debt/index.d.ts +0 -18
  417. package/dist/types/sdk/accounts/intents/operations/index.d.ts +0 -14
  418. package/dist/types/sdk/accounts/intents/operations/quota-update/index.d.ts +0 -24
  419. package/dist/types/sdk/accounts/intents/operations/repay-credit-account/index.d.ts +0 -31
  420. package/dist/types/sdk/accounts/intents/operations/start-delayed-withdrawal/index.d.ts +0 -23
  421. package/dist/types/sdk/accounts/intents/operations/swap/index.d.ts +0 -28
  422. package/dist/types/sdk/accounts/intents/operations/types.d.ts +0 -21
  423. package/dist/types/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.d.ts +0 -30
  424. package/dist/types/sdk/accounts/intents/operations/withdraw-collateral/index.d.ts +0 -36
  425. package/dist/types/sdk/accounts/intents/operations/wrap-rwa-collateral/index.d.ts +0 -30
  426. package/dist/types/sdk/accounts/intents/quoters/close.d.ts +0 -43
  427. package/dist/types/sdk/accounts/intents/quoters/index.d.ts +0 -3
  428. package/dist/types/sdk/accounts/intents/quoters/swap.d.ts +0 -43
  429. package/dist/types/sdk/accounts/intents/testing/resume.d.ts +0 -84
  430. package/dist/types/sdk/accounts/intents/utils/simulate-adjust-state.d.ts +0 -19
  431. package/dist/types/sdk/accounts/intents/utils/simulate-assets.d.ts +0 -21
  432. package/dist/types/sdk/accounts/intents/utils/with-quota-update.d.ts +0 -16
  433. /package/dist/cjs/{new-sdk/utils/history.js → model/notices.js} +0 -0
  434. /package/dist/cjs/{sdk/accounts/intents/operations → new-sdk/simulate}/types.js +0 -0
  435. /package/dist/esm/{new-sdk/utils/history.js → model/notices.js} +0 -0
  436. /package/dist/esm/{sdk/accounts/intents/operations → new-sdk/simulate}/types.js +0 -0
@@ -1,6 +1,7 @@
1
- import { Position } from "../../model/positions.js";
1
+ import { Bps } from "../../model/primitives.js";
2
+ import { BorrowRateBreakdown, Position, StrategyPosition } from "../../model/positions.js";
2
3
  import "../../model/index.js";
3
- import { ListPositionsProps } from "./types.js";
4
+ import { AccountSnapshot, ListPositionsProps, ListStrategyPositionsProps } from "./types.js";
4
5
  import { SDKConstruct } from "../base/SDKConstruct.js";
5
6
  import "../base/index.js";
6
7
  //#region src/sdk/positions/PositionsService.d.ts
@@ -10,6 +11,7 @@ import "../base/index.js";
10
11
  * took over by liquidating.
11
12
  **/
12
13
  declare class PositionsService extends SDKConstruct {
14
+ #private;
13
15
  /**
14
16
  * Every position of a wallet on this chain, optionally narrowed by
15
17
  * {@link PositionFilter} (see {@link matchesPositionFilter} for what each
@@ -17,6 +19,35 @@ declare class PositionsService extends SDKConstruct {
17
19
  * the call rather than the SDK's loaded snapshot.
18
20
  **/
19
21
  list(props: ListPositionsProps): Promise<Position[]>;
22
+ /**
23
+ * Describes all credit accounts of a wallet as strategy positions.
24
+ *
25
+ * @param props - {@link ListStrategyPositionsProps}
26
+ **/
27
+ listStrategyPositions(props: ListStrategyPositionsProps): Promise<StrategyPosition[]>;
28
+ /**
29
+ * Health factor of an account state, in basis points (`10000` = 1.0).
30
+ **/
31
+ healthFactor(snapshot: AccountSnapshot, options?: {
32
+ safePrices?: boolean;
33
+ }): Bps;
34
+ /**
35
+ * Cost of an account state's debt, broken down into the pool's base rate
36
+ * and per-token quota rates.
37
+ **/
38
+ borrowRate(snapshot: AccountSnapshot): BorrowRateBreakdown;
39
+ /**
40
+ * Estimated milliseconds until the account's health factor decays to
41
+ * `10000` under its current borrow rate, or `null` when the debt carries
42
+ * no rate (or the account is already liquidatable).
43
+ **/
44
+ timeToLiquidation(snapshot: AccountSnapshot): bigint | null;
45
+ /**
46
+ * Price of the single non-underlying collateral at which the account
47
+ * becomes liquidatable, or `null` when the account holds zero or several
48
+ * non-underlying assets.
49
+ **/
50
+ liquidationPrice(snapshot: AccountSnapshot): bigint | null;
20
51
  }
21
52
  //#endregion
22
53
  export { PositionsService };
@@ -0,0 +1,40 @@
1
+ import { Bps } from "../../model/primitives.js";
2
+ import { BorrowRateBreakdown } from "../../model/positions.js";
3
+ import "../../model/index.js";
4
+ import { AccountSnapshot } from "./types.js";
5
+ import { Address } from "viem";
6
+ //#region src/sdk/positions/calcBorrowRate.d.ts
7
+ /**
8
+ * Inputs of {@link calcBorrowRate}.
9
+ **/
10
+ interface CalcBorrowRateProps {
11
+ snapshot: AccountSnapshot;
12
+ /**
13
+ * Pool base interest rate in ray.
14
+ **/
15
+ baseInterestRate: bigint;
16
+ /**
17
+ * Credit manager interest fee in basis points.
18
+ **/
19
+ feeInterest: number;
20
+ /**
21
+ * Active quota rates in basis points. Missing keys are treated as inactive
22
+ * (zero contribution), but a per-token entry is still reported.
23
+ **/
24
+ quotaRates: Record<Address, Bps>;
25
+ }
26
+ /**
27
+ * Cost of an account state's debt, broken down into the pool's base rate and
28
+ * per-token quota rates.
29
+ *
30
+ * The base rate is the market's current borrow APY (the pool's base rate plus
31
+ * the credit manager's interest fee) — the same value `borrowApy` reports on
32
+ * a position; it is not recomputed for the projected pool liquidity. Quota
33
+ * contributions are `quotaBalance * quotaRate` with the interest fee on top,
34
+ * normalized against the total value (`total`, `quotas`) and against the
35
+ * debt (`totalOnDebt`, the rate the debt itself grows at). Formulas are in
36
+ * parity with the frontend's `BorrowRateUtils`.
37
+ **/
38
+ declare function calcBorrowRate(props: CalcBorrowRateProps): BorrowRateBreakdown;
39
+ //#endregion
40
+ export { CalcBorrowRateProps, calcBorrowRate };
@@ -0,0 +1,55 @@
1
+ import { Bps } from "../../model/primitives.js";
2
+ import "../../model/index.js";
3
+ import { AccountSnapshot } from "./types.js";
4
+ import { Address } from "viem";
5
+ //#region src/sdk/positions/calcHealthFactor.d.ts
6
+ /**
7
+ * Inputs of {@link calcHealthFactor}.
8
+ **/
9
+ interface CalcHealthFactorProps {
10
+ snapshot: AccountSnapshot;
11
+ /**
12
+ * Market underlying. Debt and quota balances are valued in this token.
13
+ **/
14
+ underlying: Address;
15
+ /**
16
+ * Token decimals. Missing keys default to 18.
17
+ **/
18
+ decimals: Record<Address, number>;
19
+ /**
20
+ * Oracle main-feed prices in 8-decimal (`PRICE_DECIMALS`) fixed point. A
21
+ * missing key is an unpriceable token and contributes nothing.
22
+ **/
23
+ prices: Record<Address, bigint>;
24
+ /**
25
+ * Oracle reserve-feed prices, when available. Used with {@link safePrices}
26
+ * to value collateral at the lower of the two feeds.
27
+ **/
28
+ reservePrices?: Record<Address, bigint>;
29
+ /**
30
+ * Value collateral at safe prices — the lower of each token's main and
31
+ * reserve feeds. Debt and quota balances always use the main feed.
32
+ **/
33
+ safePrices?: boolean;
34
+ /**
35
+ * Liquidation thresholds in basis points. Missing keys are treated as 0.
36
+ **/
37
+ liquidationThresholds: Record<Address, Bps>;
38
+ /**
39
+ * Whether each token's quota is currently active. Missing keys are inactive.
40
+ **/
41
+ activeQuotas: Record<Address, boolean>;
42
+ }
43
+ /**
44
+ * Health factor of an account state, in basis points (`10000` = 1.0).
45
+ *
46
+ * Collateral is valued under liquidation thresholds, with quoted tokens
47
+ * capped by their quota, and compared against the debt's value. An account
48
+ * with no debt reports `65535` (`MAX_UINT16`), the contract's own sentinel
49
+ * scaled down. Formulas are in parity with the legacy `calcHealthFactor`.
50
+ * Tokens with no price in {@link CalcHealthFactorProps.prices} contribute
51
+ * nothing.
52
+ **/
53
+ declare function calcHealthFactor(props: CalcHealthFactorProps): Bps;
54
+ //#endregion
55
+ export { CalcHealthFactorProps, calcHealthFactor };
@@ -0,0 +1,12 @@
1
+ import { CalcLiquidationPriceProps } from "./calcLiquidationPriceForTarget.js";
2
+ //#region src/sdk/positions/calcLiquidationPrice.d.ts
3
+ /**
4
+ * Liquidation price of an account state's target collateral, in the oracle's
5
+ * 8-decimal (`PRICE_DECIMALS`) fixed point.
6
+ *
7
+ * As the frontend does, a liquidation price only exists when the account
8
+ * holds exactly one non-dust non-underlying asset; otherwise `null`.
9
+ **/
10
+ declare function calcLiquidationPrice(props: CalcLiquidationPriceProps): bigint | null;
11
+ //#endregion
12
+ export { calcLiquidationPrice };
@@ -0,0 +1,43 @@
1
+ import { Bps } from "../../model/primitives.js";
2
+ import "../../model/index.js";
3
+ import { AccountSnapshot } from "./types.js";
4
+ import { Address } from "viem";
5
+ //#region src/sdk/positions/calcLiquidationPriceForTarget.d.ts
6
+ /**
7
+ * Shared market-side inputs of a liquidation-price calculation.
8
+ **/
9
+ interface CalcLiquidationPriceProps {
10
+ snapshot: AccountSnapshot;
11
+ /**
12
+ * Market underlying. Its balance under its LT is subtracted from the debt.
13
+ **/
14
+ underlying: Address;
15
+ /**
16
+ * Token decimals. Missing keys default to 18.
17
+ **/
18
+ decimals: Record<Address, number>;
19
+ /**
20
+ * Liquidation thresholds in basis points. Missing keys are treated as 0.
21
+ **/
22
+ liquidationThresholds: Record<Address, Bps>;
23
+ }
24
+ /**
25
+ * Inputs of {@link calcLiquidationPriceForTarget}.
26
+ **/
27
+ interface CalcLiquidationPriceForTargetProps extends CalcLiquidationPriceProps {
28
+ /**
29
+ * Collateral token whose liquidation price to compute.
30
+ **/
31
+ targetToken: Address;
32
+ }
33
+ /**
34
+ * Liquidation price of an explicitly named collateral token, in
35
+ * `PRICE_DECIMALS` fixed point; `0n` when the account holds none of it or the
36
+ * token has no liquidation threshold. Formula is in parity with the legacy
37
+ * `liquidationPrice`: the effective debt (debt less the underlying balance's
38
+ * contribution under its threshold) over the threshold-weighted target
39
+ * balance.
40
+ **/
41
+ declare function calcLiquidationPriceForTarget(props: CalcLiquidationPriceForTargetProps): bigint;
42
+ //#endregion
43
+ export { CalcLiquidationPriceForTargetProps, CalcLiquidationPriceProps, calcLiquidationPriceForTarget };
@@ -0,0 +1,16 @@
1
+ import { Bps } from "../../model/primitives.js";
2
+ import "../../model/index.js";
3
+ //#region src/sdk/positions/calcTimeToLiquidationMs.d.ts
4
+ /**
5
+ * Estimated milliseconds until `healthFactorBps` decays to `10000` (1.0)
6
+ * while the debt grows at `totalBorrowRateOnDebt`, in the same `Bps` scale
7
+ * (`10000` = 100%) as {@link BorrowRateBreakdown.totalOnDebt} reports it —
8
+ * not the legacy `PERCENTAGE_FACTOR_1KK` (`1_000_000` = 100%) scale the
9
+ * pre-rewrite frontend fed into its own `getTimeToLiquidation`.
10
+ *
11
+ * `null` when the account is already at or under the liquidation threshold,
12
+ * or when the debt carries no borrow rate at all.
13
+ **/
14
+ declare function calcTimeToLiquidationMs(healthFactorBps: Bps, totalBorrowRateOnDebt: bigint): bigint | null;
15
+ //#endregion
16
+ export { calcTimeToLiquidationMs };
@@ -1,4 +1,9 @@
1
- import { ListPositionsProps, ListPositionsPropsBase } from "./types.js";
1
+ import { AccountSnapshot, ListPositionsProps, ListPositionsPropsBase, ListStrategyPositionsProps, accountSnapshotFromCreditAccountData } from "./types.js";
2
+ import { CalcBorrowRateProps, calcBorrowRate } from "./calcBorrowRate.js";
3
+ import { CalcHealthFactorProps, calcHealthFactor } from "./calcHealthFactor.js";
4
+ import { CalcLiquidationPriceForTargetProps, CalcLiquidationPriceProps, calcLiquidationPriceForTarget } from "./calcLiquidationPriceForTarget.js";
5
+ import { calcLiquidationPrice } from "./calcLiquidationPrice.js";
6
+ import { calcTimeToLiquidationMs } from "./calcTimeToLiquidationMs.js";
2
7
  import { MultichainPositionsService } from "./MultichainPositionsService.js";
3
8
  import { PositionsService } from "./PositionsService.js";
4
- export { ListPositionsProps, ListPositionsPropsBase, MultichainPositionsService, PositionsService };
9
+ export { AccountSnapshot, CalcBorrowRateProps, CalcHealthFactorProps, CalcLiquidationPriceForTargetProps, CalcLiquidationPriceProps, ListPositionsProps, ListPositionsPropsBase, ListStrategyPositionsProps, MultichainPositionsService, PositionsService, accountSnapshotFromCreditAccountData, calcBorrowRate, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcTimeToLiquidationMs };
@@ -1,7 +1,9 @@
1
1
  import { WithBlock } from "../types/multichain.js";
2
+ import { Asset, CreditAccountData } from "../base/types.js";
2
3
  import { PositionFilter } from "../../model/positions.js";
3
4
  import "../../model/index.js";
4
5
  import "../types/index.js";
6
+ import "../base/index.js";
5
7
  import { Address } from "viem";
6
8
  //#region src/sdk/positions/types.d.ts
7
9
  /**
@@ -30,5 +32,60 @@ interface ListPositionsPropsBase {
30
32
  * {@link MultichainPositionsService.list}.
31
33
  **/
32
34
  type ListPositionsProps<Multichain extends boolean = false> = ListPositionsPropsBase & WithBlock<Multichain>;
35
+ /**
36
+ * Props for {@link PositionsService.listStrategyPositions}.
37
+ **/
38
+ interface ListStrategyPositionsProps {
39
+ /**
40
+ * Wallet whose credit accounts to describe. RWA accounts are resolved from
41
+ * the investor EOA, see {@link ICreditAccountsService.getBorrowerCreditAccounts}.
42
+ **/
43
+ owner: Address;
44
+ /**
45
+ * Whether to include accounts that carry no debt.
46
+ **/
47
+ includeZeroDebt: boolean;
48
+ /**
49
+ * Block to read at. Defaults to the latest block.
50
+ **/
51
+ blockNumber?: bigint;
52
+ }
53
+ /**
54
+ * The one input every position-metric function takes: a credit account's
55
+ * state — its credit manager, token balances, quota holdings, total debt and
56
+ * total value in the market's underlying — actual or projected.
57
+ *
58
+ * Everything else (decimals, prices, liquidation thresholds, quota rates,
59
+ * the pool's base rate) is supplied at the calculation site.
60
+ **/
61
+ interface AccountSnapshot {
62
+ /**
63
+ * Credit manager the account is (or will be) opened in.
64
+ **/
65
+ creditManager: Address;
66
+ /**
67
+ * Token balances of the account.
68
+ **/
69
+ assets: Asset[];
70
+ /**
71
+ * Quota holdings of the account: quota balances are denominated in the
72
+ * market's underlying.
73
+ **/
74
+ quotas: Asset[];
75
+ /**
76
+ * Debt principal plus accrued interest and fees, in underlying.
77
+ **/
78
+ totalDebt: bigint;
79
+ /**
80
+ * Total account value in underlying.
81
+ **/
82
+ totalValue: bigint;
83
+ }
84
+ /**
85
+ * Builds an {@link AccountSnapshot} from on-chain credit account data: the
86
+ * enabled, above-dust tokens become assets and quotas, and `totalDebt` is
87
+ * principal plus accrued interest and fees.
88
+ **/
89
+ declare function accountSnapshotFromCreditAccountData(ca: CreditAccountData): AccountSnapshot;
33
90
  //#endregion
34
- export { ListPositionsProps, ListPositionsPropsBase };
91
+ export { AccountSnapshot, ListPositionsProps, ListPositionsPropsBase, ListStrategyPositionsProps, accountSnapshotFromCreditAccountData };
@@ -7,6 +7,7 @@ import { RWAState } from "../market/rwa/types.js";
7
7
  import "../market/rwa/index.js";
8
8
  import { ZapperData } from "../market/types.js";
9
9
  import "../market/index.js";
10
+ import { TokensMetaState } from "../base/TokensMeta.js";
10
11
  import { AddressProviderState } from "../core/types.js";
11
12
  import "../core/index.js";
12
13
  import "../base/index.js";
@@ -49,6 +50,11 @@ interface GearboxState<Plugins extends PluginsMap = {}> {
49
50
  * All loaded market data.
50
51
  **/
51
52
  markets: MarketData[];
53
+ /**
54
+ * Metadata of all known tokens, including the extended data (contract types,
55
+ * serialized params) that has no compressor of its own.
56
+ **/
57
+ tokens?: TokensMetaState;
52
58
  /**
53
59
  * RWA compressor state snapshot, if RWA factories were loaded.
54
60
  **/
@@ -0,0 +1,39 @@
1
+ import { Chain, ContractFunctionParameters, MulticallResponse, PublicClient, Transport } from "viem";
2
+ //#region src/sdk/utils/viem/executeMulticallBatches.d.ts
3
+ /**
4
+ * A group of contract calls owned by a single registry, paired with a callback
5
+ * that receives the results of exactly this group, in the same order.
6
+ *
7
+ * Unlike {@link DelegatedMulticall}, which maps one call to one result, a batch
8
+ * maps N calls to one handler: some loaders need all their results at once
9
+ * (e.g. two calls per token, or a map rebuilt only after every market answered).
10
+ **/
11
+ interface MulticallBatch {
12
+ /** Contract calls of this batch. */
13
+ contracts: ContractFunctionParameters[];
14
+ /** Callback invoked with the results of this batch's calls, in order. */
15
+ onResults: (resps: MulticallResponse[]) => void;
16
+ }
17
+ /**
18
+ * Options for {@link executeMulticallBatches}.
19
+ **/
20
+ interface ExecuteMulticallBatchesOptions {
21
+ /** Block to read at, defaults to the latest block. */
22
+ blockNumber?: bigint;
23
+ }
24
+ /**
25
+ * Executes the calls of several {@link MulticallBatch}es as a single multicall
26
+ * aggregate and dispatches each batch its own slice of the results.
27
+ *
28
+ * Failures are allowed per call: loaders in a batch decide themselves how to
29
+ * treat a reverted call (e.g. `contractType()` reverting on a plain ERC-20 is
30
+ * expected). Use {@link executeDelegatedMulticalls} instead when the calls need
31
+ * price updates applied first.
32
+ *
33
+ * @param client - Viem public client.
34
+ * @param batches - Batches to execute together, empty ones are allowed.
35
+ * @param opts - Block number forwarded to the multicall.
36
+ **/
37
+ declare function executeMulticallBatches(client: PublicClient<Transport, Chain>, batches: MulticallBatch[], opts?: ExecuteMulticallBatchesOptions): Promise<void>;
38
+ //#endregion
39
+ export { ExecuteMulticallBatchesOptions, MulticallBatch, executeMulticallBatches };
@@ -1,8 +1,9 @@
1
- import { SimulateCallOptions, SimulateCallParameters, SimulateCallReturnType, SimulationError, SimulationErrorType, simulateCall } from "./simulateCall.js";
2
1
  import { generateCastTraceCall, getCastTraceArgs } from "./cast.js";
3
2
  import { DelegatedMulticall, executeDelegatedMulticalls } from "./executeDelegatedMulticalls.js";
3
+ import { ExecuteMulticallBatchesOptions, MulticallBatch, executeMulticallBatches } from "./executeMulticallBatches.js";
4
4
  import { EstimateRawTxGasParameters, SendRawTxParameters, estimateRawTxGas, sendRawTx } from "./sendRawTx.js";
5
+ import { SimulateCallOptions, SimulateCallParameters, SimulateCallReturnType, SimulationError, SimulationErrorType, simulateCall } from "./simulateCall.js";
5
6
  import { SimulateMulticallParameters, SimulateMulticallReturnType, simulateMulticall } from "./simulateMulticall.js";
6
7
  import { SimulateWithPriceUpdatesError, SimulateWithPriceUpdatesErrorParams, SimulateWithPriceUpdatesErrorType, SimulateWithPriceUpdatesParameters, SimulateWithPriceUpdatesReturnType, getSimulateWithPriceUpdatesError, simulateWithPriceUpdates } from "./simulateWithPriceUpdates.js";
7
8
  import { WatchBlocksAsyncParameters, WatchBlocksAsyncReturnType, watchBlocksAsync } from "./watchBlocksAsync.js";
8
- export { DelegatedMulticall, EstimateRawTxGasParameters, SendRawTxParameters, SimulateCallOptions, SimulateCallParameters, SimulateCallReturnType, SimulateMulticallParameters, SimulateMulticallReturnType, SimulateWithPriceUpdatesError, SimulateWithPriceUpdatesErrorParams, SimulateWithPriceUpdatesErrorType, SimulateWithPriceUpdatesParameters, SimulateWithPriceUpdatesReturnType, SimulationError, SimulationErrorType, WatchBlocksAsyncParameters, WatchBlocksAsyncReturnType, estimateRawTxGas, executeDelegatedMulticalls, generateCastTraceCall, getCastTraceArgs, getSimulateWithPriceUpdatesError, sendRawTx, simulateCall, simulateMulticall, simulateWithPriceUpdates, watchBlocksAsync };
9
+ export { DelegatedMulticall, EstimateRawTxGasParameters, ExecuteMulticallBatchesOptions, MulticallBatch, SendRawTxParameters, SimulateCallOptions, SimulateCallParameters, SimulateCallReturnType, SimulateMulticallParameters, SimulateMulticallReturnType, SimulateWithPriceUpdatesError, SimulateWithPriceUpdatesErrorParams, SimulateWithPriceUpdatesErrorType, SimulateWithPriceUpdatesParameters, SimulateWithPriceUpdatesReturnType, SimulationError, SimulationErrorType, WatchBlocksAsyncParameters, WatchBlocksAsyncReturnType, estimateRawTxGas, executeDelegatedMulticalls, executeMulticallBatches, generateCastTraceCall, getCastTraceArgs, getSimulateWithPriceUpdatesError, sendRawTx, simulateCall, simulateMulticall, simulateWithPriceUpdates, watchBlocksAsync };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "15.1.0-next.1",
3
+ "version": "15.1.0-next.11",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -147,5 +147,6 @@
147
147
  "biome check --no-errors-on-unmatched --write"
148
148
  ]
149
149
  },
150
+ "foundryVersion": "1.7.1",
150
151
  "packageManager": "pnpm@11.7.0"
151
152
  }
@@ -1,53 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/model/history.ts
3
- /**
4
- * Every {@link PoolHistoryMetric}, for callers that enumerate them.
5
- **/
6
- const POOL_HISTORY_METRICS = [
7
- "depositApy",
8
- "borrowApy",
9
- "dieselRate",
10
- "supplied",
11
- "borrowed",
12
- "availableLiquidity"
13
- ];
14
- /**
15
- * Every {@link StrategyHistoryMetric}, for callers that enumerate them.
16
- **/
17
- const STRATEGY_HISTORY_METRICS = [
18
- "netApy",
19
- "borrowApy",
20
- "collateralApy",
21
- "tvl",
22
- "collateralPrice",
23
- "collateralUsdPrice",
24
- "underlyingUsdPrice"
25
- ];
26
- /**
27
- * Every {@link PoolPositionHistoryMetric}, for callers that enumerate them.
28
- **/
29
- const POOL_POSITION_HISTORY_METRICS = [
30
- "depositApy",
31
- "borrowApy",
32
- "dieselRate",
33
- "supplied",
34
- "borrowed",
35
- "availableLiquidity"
36
- ];
37
- /**
38
- * Every {@link StrategyPositionHistoryMetric}, for callers that enumerate them.
39
- **/
40
- const STRATEGY_POSITION_HISTORY_METRICS = [
41
- "netApy",
42
- "borrowApy",
43
- "collateralApy",
44
- "tvl",
45
- "collateralPrice",
46
- "collateralUsdPrice",
47
- "underlyingUsdPrice"
48
- ];
49
- //#endregion
50
- exports.POOL_HISTORY_METRICS = POOL_HISTORY_METRICS;
51
- exports.POOL_POSITION_HISTORY_METRICS = POOL_POSITION_HISTORY_METRICS;
52
- exports.STRATEGY_HISTORY_METRICS = STRATEGY_HISTORY_METRICS;
53
- exports.STRATEGY_POSITION_HISTORY_METRICS = STRATEGY_POSITION_HISTORY_METRICS;
@@ -1,128 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_model_primitives_schema = require("./primitives.schema.js");
3
- const require_model_opportunities_schema = require("./opportunities.schema.js");
4
- const require_model_positions_schema = require("./positions.schema.js");
5
- let zod_v4 = require("zod/v4");
6
- //#region src/model/history.schema.ts
7
- /**
8
- * Runtime schemas for {@link ./history.js}, see the note in
9
- * `primitives.schema.ts` on why they are written by hand.
10
- **/
11
- /**
12
- * {@link HistoryRange}
13
- **/
14
- const historyRangeSchema = zod_v4.z.union([
15
- zod_v4.z.literal("1d"),
16
- zod_v4.z.literal("1w"),
17
- zod_v4.z.literal("1m"),
18
- zod_v4.z.literal("1y"),
19
- zod_v4.z.literal("max")
20
- ]);
21
- /**
22
- * {@link PoolHistoryMetric}
23
- **/
24
- const poolHistoryMetricSchema = zod_v4.z.union([
25
- zod_v4.z.literal("depositApy"),
26
- zod_v4.z.literal("borrowApy"),
27
- zod_v4.z.literal("dieselRate"),
28
- zod_v4.z.literal("supplied"),
29
- zod_v4.z.literal("borrowed"),
30
- zod_v4.z.literal("availableLiquidity")
31
- ]);
32
- /**
33
- * {@link StrategyHistoryMetric}
34
- **/
35
- const strategyHistoryMetricSchema = zod_v4.z.union([
36
- zod_v4.z.literal("netApy"),
37
- zod_v4.z.literal("borrowApy"),
38
- zod_v4.z.literal("collateralApy"),
39
- zod_v4.z.literal("tvl"),
40
- zod_v4.z.literal("collateralPrice"),
41
- zod_v4.z.literal("collateralUsdPrice"),
42
- zod_v4.z.literal("underlyingUsdPrice")
43
- ]);
44
- /**
45
- * {@link PoolPositionHistoryMetric}
46
- **/
47
- const poolPositionHistoryMetricSchema = zod_v4.z.union([
48
- zod_v4.z.literal("depositApy"),
49
- zod_v4.z.literal("borrowApy"),
50
- zod_v4.z.literal("dieselRate"),
51
- zod_v4.z.literal("supplied"),
52
- zod_v4.z.literal("borrowed"),
53
- zod_v4.z.literal("availableLiquidity")
54
- ]);
55
- /**
56
- * {@link StrategyPositionHistoryMetric}
57
- **/
58
- const strategyPositionHistoryMetricSchema = zod_v4.z.union([
59
- zod_v4.z.literal("netApy"),
60
- zod_v4.z.literal("borrowApy"),
61
- zod_v4.z.literal("collateralApy"),
62
- zod_v4.z.literal("tvl"),
63
- zod_v4.z.literal("collateralPrice"),
64
- zod_v4.z.literal("collateralUsdPrice"),
65
- zod_v4.z.literal("underlyingUsdPrice")
66
- ]);
67
- /**
68
- * {@link PositionHistoryMetric}
69
- **/
70
- const positionHistoryMetricSchema = zod_v4.z.union([poolPositionHistoryMetricSchema, strategyPositionHistoryMetricSchema]);
71
- /**
72
- * {@link HistoryMetric}
73
- **/
74
- const historyMetricSchema = zod_v4.z.union([
75
- poolHistoryMetricSchema,
76
- strategyHistoryMetricSchema,
77
- positionHistoryMetricSchema
78
- ]);
79
- /**
80
- * {@link HistoryPoint}
81
- **/
82
- const historyPointSchema = zod_v4.z.object({
83
- timestamp: require_model_primitives_schema.timestampSchema,
84
- value: zod_v4.z.number()
85
- });
86
- /**
87
- * {@link HistoryChartMetadata}
88
- *
89
- * TODO: empty until the backend specifies the payload.
90
- **/
91
- const historyChartMetadataSchema = zod_v4.z.object({});
92
- /**
93
- * {@link HistorySeries}
94
- **/
95
- const historySeriesSchema = zod_v4.z.object({
96
- metric: historyMetricSchema,
97
- points: zod_v4.z.array(historyPointSchema),
98
- metadata: historyChartMetadataSchema
99
- });
100
- /**
101
- * {@link OpportunityHistoryQuery}
102
- **/
103
- const opportunityHistoryQuerySchema = zod_v4.z.object({
104
- opportunity: require_model_opportunities_schema.opportunityKeySchema,
105
- range: historyRangeSchema,
106
- metric: historyMetricSchema
107
- });
108
- /**
109
- * {@link PositionHistoryQuery}
110
- **/
111
- const positionHistoryQuerySchema = zod_v4.z.object({
112
- position: require_model_positions_schema.positionKeySchema,
113
- range: historyRangeSchema,
114
- metric: positionHistoryMetricSchema
115
- });
116
- //#endregion
117
- exports.historyChartMetadataSchema = historyChartMetadataSchema;
118
- exports.historyMetricSchema = historyMetricSchema;
119
- exports.historyPointSchema = historyPointSchema;
120
- exports.historyRangeSchema = historyRangeSchema;
121
- exports.historySeriesSchema = historySeriesSchema;
122
- exports.opportunityHistoryQuerySchema = opportunityHistoryQuerySchema;
123
- exports.poolHistoryMetricSchema = poolHistoryMetricSchema;
124
- exports.poolPositionHistoryMetricSchema = poolPositionHistoryMetricSchema;
125
- exports.positionHistoryMetricSchema = positionHistoryMetricSchema;
126
- exports.positionHistoryQuerySchema = positionHistoryQuerySchema;
127
- exports.strategyHistoryMetricSchema = strategyHistoryMetricSchema;
128
- exports.strategyPositionHistoryMetricSchema = strategyPositionHistoryMetricSchema;
@@ -1,14 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sdk_accounts_intents_intents_resume_add_collateral_add_collateral = require("./resume/add-collateral/add-collateral.js");
3
- const require_sdk_accounts_intents_intents_resume_close_close = require("./resume/close/close.js");
4
- const require_sdk_accounts_intents_intents_resume_decrease_leverage_decrease_leverage = require("./resume/decrease-leverage/decrease-leverage.js");
5
- const require_sdk_accounts_intents_intents_resume_deposit_deposit = require("./resume/deposit/deposit.js");
6
- const require_sdk_accounts_intents_intents_resume_increase_leverage_increase_leverage = require("./resume/increase-leverage/increase-leverage.js");
7
- const require_sdk_accounts_intents_intents_resume_withdraw_withdraw = require("./resume/withdraw/withdraw.js");
8
- require("./resume/index.js");
9
- exports.buildResumeAddCollateralOperations = require_sdk_accounts_intents_intents_resume_add_collateral_add_collateral.buildResumeAddCollateralOperations;
10
- exports.buildResumeCloseOperations = require_sdk_accounts_intents_intents_resume_close_close.buildResumeCloseOperations;
11
- exports.buildResumeDecreaseLeverageOperations = require_sdk_accounts_intents_intents_resume_decrease_leverage_decrease_leverage.buildResumeDecreaseLeverageOperations;
12
- exports.buildResumeDepositOperations = require_sdk_accounts_intents_intents_resume_deposit_deposit.buildResumeDepositOperations;
13
- exports.buildResumeIncreaseLeverageOperations = require_sdk_accounts_intents_intents_resume_increase_leverage_increase_leverage.buildResumeIncreaseLeverageOperations;
14
- exports.buildResumeWithdrawOperations = require_sdk_accounts_intents_intents_resume_withdraw_withdraw.buildResumeWithdrawOperations;