@gearbox-protocol/sdk 18.1.0-next.1 → 18.2.0-aave.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/dist/cjs/abi/310/iKillSwitchProxy.js +130 -0
  2. package/dist/cjs/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.js +179 -0
  3. package/dist/cjs/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.js +534 -0
  4. package/dist/cjs/abi/router/treehouseWorker.js +885 -0
  5. package/dist/cjs/model/aave.js +1 -0
  6. package/dist/cjs/model/index.js +1 -0
  7. package/dist/cjs/onchain/accounts/intents/index.js +1 -0
  8. package/dist/cjs/onchain/accounts/intents/operations.js +21 -0
  9. package/dist/cjs/onchain/accounts/intents/plan.js +33 -0
  10. package/dist/cjs/onchain/accounts/intents/realize.js +44 -0
  11. package/dist/cjs/onchain/accounts/intents/testing/market.js +1 -0
  12. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +2 -1
  13. package/dist/cjs/onchain/accounts/intents/utils/ledger.js +8 -0
  14. package/dist/cjs/onchain/chain/chains.js +4 -0
  15. package/dist/cjs/onchain/index.js +30 -0
  16. package/dist/cjs/onchain/market/adapters/abi/aave/iAaveHorizonBridge.js +94 -0
  17. package/dist/cjs/onchain/market/adapters/abi/aave/iAaveV3Pool.js +112 -0
  18. package/dist/cjs/onchain/market/adapters/abi/aave/index.js +5 -0
  19. package/dist/cjs/onchain/market/adapters/abi/actionAbi.js +2 -0
  20. package/dist/cjs/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +197 -0
  21. package/dist/cjs/onchain/market/adapters/abi/adapters/iAaveV3PoolAdapter.js +177 -0
  22. package/dist/cjs/onchain/market/adapters/abi/adapters/iTreehouseFastlaneAdapter.js +113 -0
  23. package/dist/cjs/onchain/market/adapters/abi/adapters/iTreehouseRedemptionGatewayAdapter.js +258 -0
  24. package/dist/cjs/onchain/market/adapters/abi/adapters/iTreehouseRouterAdapter.js +161 -0
  25. package/dist/cjs/onchain/market/adapters/abi/adapters/index.js +10 -0
  26. package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +5 -0
  27. package/dist/cjs/onchain/market/adapters/abi/index.js +22 -0
  28. package/dist/cjs/onchain/market/adapters/abi/treehouse/iTreehouseFastlane.js +39 -0
  29. package/dist/cjs/onchain/market/adapters/abi/treehouse/iTreehouseRedemptionGateway.js +230 -0
  30. package/dist/cjs/onchain/market/adapters/abi/treehouse/iTreehouseRouter.js +29 -0
  31. package/dist/cjs/onchain/market/adapters/abi/treehouse/index.js +7 -0
  32. package/dist/cjs/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +130 -0
  33. package/dist/cjs/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +205 -0
  34. package/dist/cjs/onchain/market/adapters/contracts/AbstractAdapter.js +8 -0
  35. package/dist/cjs/onchain/market/adapters/contracts/TreehouseFastlaneAdapterContract.js +72 -0
  36. package/dist/cjs/onchain/market/adapters/contracts/TreehouseRedemptionGatewayAdapterContract.js +117 -0
  37. package/dist/cjs/onchain/market/adapters/contracts/TreehouseRouterAdapterContract.js +61 -0
  38. package/dist/cjs/onchain/market/adapters/contracts/index.js +10 -0
  39. package/dist/cjs/onchain/market/adapters/createAdapter.js +10 -0
  40. package/dist/cjs/onchain/market/adapters/index.js +30 -0
  41. package/dist/cjs/onchain/market/adapters/types.js +5 -0
  42. package/dist/cjs/onchain/market/index.js +30 -0
  43. package/dist/cjs/onchain/positions/projectAavePosition.js +40 -0
  44. package/dist/cjs/onchain/preview/preview/loadAdapterReplayState.js +17 -0
  45. package/dist/cjs/onchain/preview/preview/previewOperation.js +2 -0
  46. package/dist/cjs/permissionless/api/GearboxPermissionless.js +12 -5
  47. package/dist/cjs/permissionless/api/analytics/PermissionlessAnalytics.js +50 -0
  48. package/dist/cjs/permissionless/api/analytics/index.js +4 -0
  49. package/dist/cjs/permissionless/api/analytics/schemas.js +27 -0
  50. package/dist/cjs/permissionless/api/analytics/types.js +1 -0
  51. package/dist/cjs/permissionless/api/index.js +34 -0
  52. package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +715 -27
  53. package/dist/cjs/permissionless/api/oracles/enrich.js +99 -0
  54. package/dist/cjs/permissionless/api/oracles/index.js +33 -0
  55. package/dist/cjs/permissionless/api/oracles/onchain-feed.js +25 -0
  56. package/dist/cjs/permissionless/api/oracles/schemas.js +119 -16
  57. package/dist/cjs/permissionless/api/oracles/score/formula.js +56 -0
  58. package/dist/cjs/permissionless/api/oracles/score/index.js +11 -0
  59. package/dist/cjs/permissionless/api/oracles/score/run.js +252 -0
  60. package/dist/cjs/permissionless/api/oracles/score/types.js +1 -0
  61. package/dist/cjs/permissionless/api/oracles/stress/classify.js +258 -0
  62. package/dist/cjs/permissionless/api/oracles/stress/index.js +24 -0
  63. package/dist/cjs/permissionless/api/oracles/stress/override.js +125 -0
  64. package/dist/cjs/permissionless/api/oracles/stress/run.js +485 -0
  65. package/dist/cjs/permissionless/api/oracles/stress/score.js +98 -0
  66. package/dist/cjs/permissionless/api/oracles/stress/types.js +1 -0
  67. package/dist/cjs/permissionless/api/schemas.js +0 -3
  68. package/dist/cjs/permissionless/api/transactions/InstanceOwnerTransactions.js +14 -3
  69. package/dist/cjs/permissionless/api/transactions/lp-price-feeds.js +10 -4
  70. package/dist/cjs/permissionless/bindings/bytecode-repository.js +8 -0
  71. package/dist/cjs/permissionless/bindings/governance/governor.js +1 -1
  72. package/dist/cjs/permissionless/bindings/index.js +8 -3
  73. package/dist/cjs/permissionless/bindings/kill-switch-proxy.js +188 -0
  74. package/dist/cjs/permissionless/bindings/market-configurator-factory.js +39 -1
  75. package/dist/cjs/permissionless/bindings/market-configurator.js +142 -0
  76. package/dist/cjs/permissionless/index.js +44 -3
  77. package/dist/cjs/permissionless/utils/index.js +3 -0
  78. package/dist/cjs/permissionless/utils/literals.js +2 -0
  79. package/dist/cjs/permissionless/utils/price-update/get-prices.js +64 -0
  80. package/dist/cjs/permissionless/utils/price-update/index.js +2 -0
  81. package/dist/cjs/sdk/prepare/PrepareApi.js +39 -0
  82. package/dist/cjs/sdk/preview/PreviewNamespace.js +33 -0
  83. package/dist/cjs/testnets/TestnetsAPI.js +179 -0
  84. package/dist/cjs/testnets/errors/TestnetNotFoundError.js +15 -0
  85. package/dist/cjs/testnets/errors/TestnetRequestFailedError.js +24 -0
  86. package/dist/cjs/testnets/errors/TestnetStatusError.js +19 -0
  87. package/dist/cjs/testnets/errors/TestnetValidationError.js +24 -0
  88. package/dist/cjs/testnets/errors/TestnetWaitTimeoutError.js +30 -0
  89. package/dist/cjs/testnets/errors/TestnetsError.js +34 -0
  90. package/dist/cjs/testnets/errors/index.js +13 -0
  91. package/dist/cjs/testnets/index.js +32 -0
  92. package/dist/cjs/testnets/package.json +1 -0
  93. package/dist/cjs/testnets/schemas.js +242 -0
  94. package/dist/cjs/testnets/types.js +1 -0
  95. package/dist/esm/abi/310/iKillSwitchProxy.js +129 -0
  96. package/dist/esm/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.js +178 -0
  97. package/dist/esm/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.js +533 -0
  98. package/dist/esm/abi/router/treehouseWorker.js +884 -0
  99. package/dist/esm/model/aave.js +1 -0
  100. package/dist/esm/model/index.js +1 -0
  101. package/dist/esm/onchain/accounts/intents/index.js +2 -1
  102. package/dist/esm/onchain/accounts/intents/operations.js +20 -1
  103. package/dist/esm/onchain/accounts/intents/plan.js +33 -1
  104. package/dist/esm/onchain/accounts/intents/realize.js +46 -2
  105. package/dist/esm/onchain/accounts/intents/testing/market.js +1 -0
  106. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +2 -1
  107. package/dist/esm/onchain/accounts/intents/utils/ledger.js +8 -0
  108. package/dist/esm/onchain/chain/chains.js +4 -0
  109. package/dist/esm/onchain/index.js +16 -1
  110. package/dist/esm/onchain/market/adapters/abi/aave/iAaveHorizonBridge.js +93 -0
  111. package/dist/esm/onchain/market/adapters/abi/aave/iAaveV3Pool.js +111 -0
  112. package/dist/esm/onchain/market/adapters/abi/aave/index.js +3 -0
  113. package/dist/esm/onchain/market/adapters/abi/actionAbi.js +2 -0
  114. package/dist/esm/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.js +196 -0
  115. package/dist/esm/onchain/market/adapters/abi/adapters/iAaveV3PoolAdapter.js +176 -0
  116. package/dist/esm/onchain/market/adapters/abi/adapters/iTreehouseFastlaneAdapter.js +112 -0
  117. package/dist/esm/onchain/market/adapters/abi/adapters/iTreehouseRedemptionGatewayAdapter.js +257 -0
  118. package/dist/esm/onchain/market/adapters/abi/adapters/iTreehouseRouterAdapter.js +160 -0
  119. package/dist/esm/onchain/market/adapters/abi/adapters/index.js +6 -1
  120. package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +5 -0
  121. package/dist/esm/onchain/market/adapters/abi/index.js +13 -1
  122. package/dist/esm/onchain/market/adapters/abi/treehouse/iTreehouseFastlane.js +38 -0
  123. package/dist/esm/onchain/market/adapters/abi/treehouse/iTreehouseRedemptionGateway.js +229 -0
  124. package/dist/esm/onchain/market/adapters/abi/treehouse/iTreehouseRouter.js +28 -0
  125. package/dist/esm/onchain/market/adapters/abi/treehouse/index.js +4 -0
  126. package/dist/esm/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.js +129 -0
  127. package/dist/esm/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.js +204 -0
  128. package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +8 -0
  129. package/dist/esm/onchain/market/adapters/contracts/TreehouseFastlaneAdapterContract.js +71 -0
  130. package/dist/esm/onchain/market/adapters/contracts/TreehouseRedemptionGatewayAdapterContract.js +116 -0
  131. package/dist/esm/onchain/market/adapters/contracts/TreehouseRouterAdapterContract.js +60 -0
  132. package/dist/esm/onchain/market/adapters/contracts/index.js +6 -1
  133. package/dist/esm/onchain/market/adapters/createAdapter.js +10 -0
  134. package/dist/esm/onchain/market/adapters/index.js +16 -1
  135. package/dist/esm/onchain/market/adapters/types.js +5 -0
  136. package/dist/esm/onchain/market/index.js +16 -1
  137. package/dist/esm/onchain/positions/projectAavePosition.js +39 -0
  138. package/dist/esm/onchain/preview/preview/loadAdapterReplayState.js +16 -0
  139. package/dist/esm/onchain/preview/preview/previewOperation.js +2 -0
  140. package/dist/esm/permissionless/api/GearboxPermissionless.js +12 -5
  141. package/dist/esm/permissionless/api/analytics/PermissionlessAnalytics.js +49 -0
  142. package/dist/esm/permissionless/api/analytics/index.js +2 -0
  143. package/dist/esm/permissionless/api/analytics/schemas.js +25 -0
  144. package/dist/esm/permissionless/api/analytics/types.js +1 -0
  145. package/dist/esm/permissionless/api/index.js +9 -1
  146. package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +717 -29
  147. package/dist/esm/permissionless/api/oracles/enrich.js +94 -0
  148. package/dist/esm/permissionless/api/oracles/index.js +10 -1
  149. package/dist/esm/permissionless/api/oracles/onchain-feed.js +24 -0
  150. package/dist/esm/permissionless/api/oracles/schemas.js +109 -17
  151. package/dist/esm/permissionless/api/oracles/score/formula.js +51 -0
  152. package/dist/esm/permissionless/api/oracles/score/index.js +4 -0
  153. package/dist/esm/permissionless/api/oracles/score/run.js +250 -0
  154. package/dist/esm/permissionless/api/oracles/score/types.js +1 -0
  155. package/dist/esm/permissionless/api/oracles/stress/classify.js +256 -0
  156. package/dist/esm/permissionless/api/oracles/stress/index.js +6 -0
  157. package/dist/esm/permissionless/api/oracles/stress/override.js +119 -0
  158. package/dist/esm/permissionless/api/oracles/stress/run.js +478 -0
  159. package/dist/esm/permissionless/api/oracles/stress/score.js +95 -0
  160. package/dist/esm/permissionless/api/oracles/stress/types.js +1 -0
  161. package/dist/esm/permissionless/api/schemas.js +2 -4
  162. package/dist/esm/permissionless/api/transactions/InstanceOwnerTransactions.js +14 -3
  163. package/dist/esm/permissionless/api/transactions/lp-price-feeds.js +10 -4
  164. package/dist/esm/permissionless/bindings/bytecode-repository.js +8 -0
  165. package/dist/esm/permissionless/bindings/governance/governor.js +1 -1
  166. package/dist/esm/permissionless/bindings/index.js +5 -4
  167. package/dist/esm/permissionless/bindings/kill-switch-proxy.js +184 -0
  168. package/dist/esm/permissionless/bindings/market-configurator-factory.js +37 -0
  169. package/dist/esm/permissionless/bindings/market-configurator.js +143 -1
  170. package/dist/esm/permissionless/index.js +14 -6
  171. package/dist/esm/permissionless/utils/index.js +3 -3
  172. package/dist/esm/permissionless/utils/literals.js +2 -1
  173. package/dist/esm/permissionless/utils/price-update/get-prices.js +63 -1
  174. package/dist/esm/permissionless/utils/price-update/index.js +2 -2
  175. package/dist/esm/sdk/GearboxSDK.js +2 -2
  176. package/dist/esm/sdk/prepare/PrepareApi.js +39 -0
  177. package/dist/esm/sdk/preview/PreviewNamespace.js +33 -0
  178. package/dist/esm/testnets/TestnetsAPI.js +178 -0
  179. package/dist/esm/testnets/errors/TestnetNotFoundError.js +14 -0
  180. package/dist/esm/testnets/errors/TestnetRequestFailedError.js +23 -0
  181. package/dist/esm/testnets/errors/TestnetStatusError.js +18 -0
  182. package/dist/esm/testnets/errors/TestnetValidationError.js +23 -0
  183. package/dist/esm/testnets/errors/TestnetWaitTimeoutError.js +29 -0
  184. package/dist/esm/testnets/errors/TestnetsError.js +33 -0
  185. package/dist/esm/testnets/errors/index.js +7 -0
  186. package/dist/esm/testnets/index.js +11 -0
  187. package/dist/esm/testnets/package.json +1 -0
  188. package/dist/esm/testnets/schemas.js +228 -0
  189. package/dist/esm/testnets/types.js +1 -0
  190. package/dist/types/abi/310/iKillSwitchProxy.d.ts +114 -0
  191. package/dist/types/abi/compressors/subcompressors/liquidation/treehouseLiquidationSubcompressor.d.ts +148 -0
  192. package/dist/types/abi/compressors/subcompressors/withdrawal/treehouseWithdrawalSubcompressor.d.ts +440 -0
  193. package/dist/types/abi/router/treehouseWorker.d.ts +728 -0
  194. package/dist/types/model/aave.d.ts +32 -0
  195. package/dist/types/model/analytics.d.ts +2 -2
  196. package/dist/types/model/index.d.ts +6 -5
  197. package/dist/types/model/opportunities.d.ts +1 -1
  198. package/dist/types/model/positions.d.ts +1 -1
  199. package/dist/types/model/previews.d.ts +15 -0
  200. package/dist/types/offchain/AbstractOffchainNamespace.d.ts +1 -1
  201. package/dist/types/offchain/analytics/OffchainAnalytics.d.ts +1 -1
  202. package/dist/types/offchain/analytics/types.d.ts +1 -1
  203. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -1
  204. package/dist/types/offchain/opportunities/types.d.ts +1 -1
  205. package/dist/types/offchain/positions/OffchainPositions.d.ts +1 -1
  206. package/dist/types/offchain/positions/types.d.ts +1 -1
  207. package/dist/types/onchain/accounts/intents/operations.d.ts +37 -1
  208. package/dist/types/onchain/accounts/intents/plan.d.ts +26 -1
  209. package/dist/types/onchain/accounts/intents/testing/market.d.ts +4 -0
  210. package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +4 -0
  211. package/dist/types/onchain/accounts/intents/types.d.ts +20 -1
  212. package/dist/types/onchain/index.d.ts +16 -1
  213. package/dist/types/onchain/market/adapters/abi/aave/iAaveHorizonBridge.d.ts +83 -0
  214. package/dist/types/onchain/market/adapters/abi/aave/iAaveV3Pool.d.ts +90 -0
  215. package/dist/types/onchain/market/adapters/abi/aave/index.d.ts +3 -0
  216. package/dist/types/onchain/market/adapters/abi/adapters/iAaveHorizonBridgeAdapter.d.ts +186 -0
  217. package/dist/types/onchain/market/adapters/abi/adapters/iAaveV3PoolAdapter.d.ts +172 -0
  218. package/dist/types/onchain/market/adapters/abi/adapters/iTreehouseFastlaneAdapter.d.ts +101 -0
  219. package/dist/types/onchain/market/adapters/abi/adapters/iTreehouseRedemptionGatewayAdapter.d.ts +237 -0
  220. package/dist/types/onchain/market/adapters/abi/adapters/iTreehouseRouterAdapter.d.ts +146 -0
  221. package/dist/types/onchain/market/adapters/abi/adapters/index.d.ts +6 -1
  222. package/dist/types/onchain/market/adapters/abi/index.d.ts +13 -1
  223. package/dist/types/onchain/market/adapters/abi/treehouse/iTreehouseFastlane.d.ts +33 -0
  224. package/dist/types/onchain/market/adapters/abi/treehouse/iTreehouseRedemptionGateway.d.ts +207 -0
  225. package/dist/types/onchain/market/adapters/abi/treehouse/iTreehouseRouter.d.ts +27 -0
  226. package/dist/types/onchain/market/adapters/abi/treehouse/index.d.ts +4 -0
  227. package/dist/types/onchain/market/adapters/contracts/AaveHorizonBridgeAdapterContract.d.ts +312 -0
  228. package/dist/types/onchain/market/adapters/contracts/AaveV3PoolAdapterContract.d.ts +312 -0
  229. package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +8 -0
  230. package/dist/types/onchain/market/adapters/contracts/TreehouseFastlaneAdapterContract.d.ts +156 -0
  231. package/dist/types/onchain/market/adapters/contracts/TreehouseRedemptionGatewayAdapterContract.d.ts +481 -0
  232. package/dist/types/onchain/market/adapters/contracts/TreehouseRouterAdapterContract.d.ts +193 -0
  233. package/dist/types/onchain/market/adapters/contracts/index.d.ts +6 -1
  234. package/dist/types/onchain/market/adapters/index.d.ts +16 -1
  235. package/dist/types/onchain/market/adapters/types.d.ts +6 -1
  236. package/dist/types/onchain/market/index.d.ts +16 -1
  237. package/dist/types/onchain/positions/projectAavePosition.d.ts +16 -0
  238. package/dist/types/onchain/preview/preview/loadAdapterReplayState.d.ts +13 -0
  239. package/dist/types/permissionless/api/GearboxPermissionless.d.ts +11 -5
  240. package/dist/types/permissionless/api/analytics/PermissionlessAnalytics.d.ts +38 -0
  241. package/dist/types/permissionless/api/analytics/index.d.ts +3 -0
  242. package/dist/types/permissionless/api/analytics/schemas.d.ts +32 -0
  243. package/dist/types/permissionless/api/analytics/types.d.ts +38 -0
  244. package/dist/types/permissionless/api/index.d.ts +13 -2
  245. package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +303 -22
  246. package/dist/types/permissionless/api/oracles/enrich.d.ts +59 -0
  247. package/dist/types/permissionless/api/oracles/index.d.ts +12 -2
  248. package/dist/types/permissionless/api/oracles/onchain-feed.d.ts +15 -0
  249. package/dist/types/permissionless/api/oracles/schemas.d.ts +249 -7
  250. package/dist/types/permissionless/api/oracles/score/formula.d.ts +36 -0
  251. package/dist/types/permissionless/api/oracles/score/index.d.ts +4 -0
  252. package/dist/types/permissionless/api/oracles/score/run.d.ts +42 -0
  253. package/dist/types/permissionless/api/oracles/score/types.d.ts +118 -0
  254. package/dist/types/permissionless/api/oracles/stress/classify.d.ts +57 -0
  255. package/dist/types/permissionless/api/oracles/stress/index.d.ts +6 -0
  256. package/dist/types/permissionless/api/oracles/stress/override.d.ts +59 -0
  257. package/dist/types/permissionless/api/oracles/stress/run.d.ts +100 -0
  258. package/dist/types/permissionless/api/oracles/stress/score.d.ts +57 -0
  259. package/dist/types/permissionless/api/oracles/stress/types.d.ts +272 -0
  260. package/dist/types/permissionless/api/oracles/types.d.ts +468 -22
  261. package/dist/types/permissionless/api/schemas.d.ts +0 -2
  262. package/dist/types/permissionless/api/transactions/lp-price-feeds.d.ts +9 -1
  263. package/dist/types/permissionless/bindings/bytecode-repository.d.ts +10 -1
  264. package/dist/types/permissionless/bindings/index.d.ts +4 -3
  265. package/dist/types/permissionless/bindings/kill-switch-proxy.d.ts +205 -0
  266. package/dist/types/permissionless/bindings/market-configurator-factory.d.ts +30 -0
  267. package/dist/types/permissionless/bindings/market-configurator.d.ts +30 -1
  268. package/dist/types/permissionless/bindings/types.d.ts +27 -0
  269. package/dist/types/permissionless/index.d.ts +17 -6
  270. package/dist/types/permissionless/utils/index.d.ts +3 -3
  271. package/dist/types/permissionless/utils/literals.d.ts +1 -0
  272. package/dist/types/permissionless/utils/price-update/get-prices.d.ts +33 -0
  273. package/dist/types/permissionless/utils/price-update/index.d.ts +2 -2
  274. package/dist/types/sdk/analytics/AnalyticsNamespace.d.ts +1 -1
  275. package/dist/types/sdk/analytics/types.d.ts +1 -1
  276. package/dist/types/sdk/index.d.ts +2 -2
  277. package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +1 -1
  278. package/dist/types/sdk/opportunities/types.d.ts +1 -1
  279. package/dist/types/sdk/positions/PositionsNamespace.d.ts +1 -1
  280. package/dist/types/sdk/positions/types.d.ts +1 -1
  281. package/dist/types/sdk/prepare/PrepareApi.d.ts +11 -3
  282. package/dist/types/sdk/prepare/index.d.ts +2 -2
  283. package/dist/types/sdk/prepare/types.d.ts +56 -1
  284. package/dist/types/sdk/preview/PreviewNamespace.d.ts +5 -1
  285. package/dist/types/sdk/preview/types.d.ts +10 -1
  286. package/dist/types/testnets/TestnetsAPI.d.ts +108 -0
  287. package/dist/types/testnets/errors/TestnetNotFoundError.d.ts +12 -0
  288. package/dist/types/testnets/errors/TestnetRequestFailedError.d.ts +11 -0
  289. package/dist/types/testnets/errors/TestnetStatusError.d.ts +15 -0
  290. package/dist/types/testnets/errors/TestnetValidationError.d.ts +16 -0
  291. package/dist/types/testnets/errors/TestnetWaitTimeoutError.d.ts +21 -0
  292. package/dist/types/testnets/errors/TestnetsError.d.ts +47 -0
  293. package/dist/types/testnets/errors/index.d.ts +7 -0
  294. package/dist/types/testnets/index.d.ts +11 -0
  295. package/dist/types/testnets/schemas.d.ts +554 -0
  296. package/dist/types/testnets/types.d.ts +717 -0
  297. package/package.json +9 -3
@@ -4,6 +4,7 @@ import { CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, Ins
4
4
  import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError } from "../../model/errors/prepare-errors.js";
5
5
  import { PoolOpportunityKey, StrategyOpportunityKey } from "../../model/opportunities.js";
6
6
  import { Position, PositionCollateral, StrategyPosition, StrategyPositionKey } from "../../model/positions.js";
7
+ import { AavePositionProjection } from "../../model/aave.js";
7
8
  import { SDKReturn } from "../../model/result.js";
8
9
  import { PositionClaimableWithdrawal } from "../../model/withdrawals.js";
9
10
  import "../../model/index.js";
@@ -44,6 +45,11 @@ export interface MaxWithdrawCollateralOptions {
44
45
  export type AccountFlowError = CreditManagerPausedError | MarketExpiredError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientCollateralError | ReservePriceLimitedError | InsufficientBalanceError | CreditAccountNotFoundError | UnexpectedFailureError;
45
46
  /** Same guards for the account-less open flow. */
46
47
  export type OpenFlowError = CreditManagerPausedError | MarketExpiredError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientCollateralError | InsufficientBalanceError | UnexpectedFailureError;
48
+ /**
49
+ * What opening a leveraged position can answer with: the open-flow guards plus
50
+ * the opening's own codes.
51
+ **/
52
+ export type OpenStrategyError = OpenFlowError | DebtOutOfRangeError | LeverageOutOfRangeError | UnsupportedTokenPairError | InsufficientPoolLiquidityError | NoStrategyTargetCollateralError | CreditAccountNotFoundError | CreditAccountNotEmptyError;
47
53
  /**
48
54
  * What every error of a two-route request carries on top of its own code,
49
55
  * see {@link StrategyRoutesResult}.
@@ -246,6 +252,22 @@ export interface OpenStrategyResult {
246
252
  /** Unix seconds of {@link blockNumber}. */
247
253
  timestamp: Timestamp;
248
254
  }
255
+ /**
256
+ * Where an Aave Horizon opening arrives: the credit account the position is
257
+ * built in while the mint settles, as {@link OpenStrategyState} describes it,
258
+ * and the position it becomes on Aave after that.
259
+ **/
260
+ export interface OpenAavePositionState extends OpenStrategyState {
261
+ /** The position once it has moved to Aave. */
262
+ aave: AavePositionProjection;
263
+ }
264
+ /**
265
+ * What opening a leveraged position on Aave Horizon comes to: the transaction
266
+ * is the same opening, so it is built from this result the same way.
267
+ **/
268
+ export interface OpenAavePositionResult extends OpenStrategyResult {
269
+ state: OpenAavePositionState;
270
+ }
249
271
  /**
250
272
  * What taking a loan against collateral comes to.
251
273
  *
@@ -366,6 +388,10 @@ export interface RepayStrategyParams extends PrepareOptions {
366
388
  /** Native value to attach when paying a wrapped-native market in the coin. */
367
389
  value?: bigint;
368
390
  }
391
+ export interface MoveToAaveParams {
392
+ /** RWA collateral on the account; its whole balance moves to Aave. */
393
+ token: Address;
394
+ }
369
395
  export interface AdjustLeverageParams extends PrepareOptions {
370
396
  /**
371
397
  * Target total leverage scaled by `LEVERAGE_DECIMALS` (300n = 3x); 100n means
@@ -615,7 +641,16 @@ export interface IOpportunitiesPrepare {
615
641
  * `creditAccount` puts the position on an account the wallet already holds
616
642
  * rather than creating one.
617
643
  **/
618
- openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<SDKReturn<OpenStrategyResult, (OpenFlowError | DebtOutOfRangeError | LeverageOutOfRangeError | UnsupportedTokenPairError | InsufficientPoolLiquidityError | NoStrategyTargetCollateralError | CreditAccountNotFoundError | CreditAccountNotEmptyError) & WithPartialState<OpenStrategyState>>>;
644
+ openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<SDKReturn<OpenStrategyResult, OpenStrategyError & WithPartialState<OpenStrategyState>>>;
645
+ /**
646
+ * Opening a leveraged position on Aave Horizon from wallet collateral.
647
+ *
648
+ * The RWA collateral is minted asynchronously, so the opening itself is the
649
+ * one {@link openNewStrategy} prepares: a Gearbox credit account borrows and
650
+ * subscribes to the mint. Once the mint settles the position moves to Aave,
651
+ * and `state.aave` describes it there.
652
+ **/
653
+ openAavePosition(strategy: StrategyInput, params: OpenStrategyParams): Promise<SDKReturn<OpenAavePositionResult, OpenStrategyError & WithPartialState<OpenAavePositionState>>>;
619
654
  /**
620
655
  * Handing a wallet an account that holds nothing: no collateral, no debt, no
621
656
  * quotas and no route quoted. It exists so a wallet can hold an account
@@ -736,6 +771,26 @@ export interface IOpportunitiesPrepare {
736
771
  * the SDK does not hold.
737
772
  **/
738
773
  maxRepay(position: PositionInput): Promise<bigint>;
774
+ /**
775
+ * The second half of an {@link openAavePosition}: once the RWA collateral
776
+ * has been minted, the position leaves the credit account for Aave Horizon.
777
+ *
778
+ * One transaction: the whole balance of `token` is supplied to the Aave
779
+ * pool, the aTokens go to the account owner through the Horizon bridge,
780
+ * which borrows the underlying on the owner's behalf into the account, and
781
+ * the Gearbox loan is repaid in full with its quotas. Aave lends the debt
782
+ * plus a 10bps margin for the interest still to come; whatever the facade
783
+ * does not take stays on the account. The state answered is the credit
784
+ * account's: owing nothing, holding that remainder.
785
+ *
786
+ * The bridge borrows as the owner, so the transaction reverts unless the
787
+ * owner has delegated credit on Aave's variable debt token to the bridge.
788
+ *
789
+ * Refused with `unsupportedCollateralToken` when `token` is not on the
790
+ * account or the credit manager has no Aave adapters that take it, and with
791
+ * `debtOutOfRange` when the account owes nothing.
792
+ **/
793
+ moveToAave(position: PositionInput, params: MoveToAaveParams): Promise<SDKReturn<StrategyResult, (AccountFlowError | DebtOutOfRangeError | UnsupportedCollateralTokenError) & WithPartialState<OperationState>>>;
739
794
  /**
740
795
  * Retargeting leverage at fixed collateral: debt moves, own funds do not.
741
796
  *
@@ -1,4 +1,4 @@
1
- import { OperationPreview, PreviewOperationInput, PreviewOperationOptions } from "../../model/previews.js";
1
+ import { OpenAavePositionPreview, OperationPreview, PreviewOperationInput, PreviewOperationOptions } from "../../model/previews.js";
2
2
  import { SDKReturn } from "../../model/result.js";
3
3
  import "../../model/index.js";
4
4
  import { MultichainSDK } from "../../onchain/MultichainSDK.js";
@@ -20,6 +20,10 @@ export declare class PreviewNamespace implements IPreview {
20
20
  * {@inheritDoc IPreview.previewOperation}
21
21
  **/
22
22
  previewOperation(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview, PreviewOperationError>>;
23
+ /**
24
+ * {@inheritDoc IPreview.openAavePosition}
25
+ **/
26
+ openAavePosition(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OpenAavePositionPreview, PreviewOperationError>>;
23
27
  /**
24
28
  * {@inheritDoc IPreview.checkOperation}
25
29
  **/
@@ -1,5 +1,5 @@
1
1
  import { ChainId } from "../../model/primitives.js";
2
- import { OperationPreview, PreviewOperationInput, PreviewOperationOptions } from "../../model/previews.js";
2
+ import { OpenAavePositionPreview, OperationPreview, PreviewOperationInput, PreviewOperationOptions } from "../../model/previews.js";
3
3
  import { SDKReturn } from "../../model/result.js";
4
4
  import "../../model/index.js";
5
5
  import { PreviewOperationError } from "../../onchain/preview/preview/previewOperation.js";
@@ -26,6 +26,15 @@ export interface IPreview {
26
26
  * human-displayable preview.
27
27
  **/
28
28
  previewOperation(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OperationPreview, PreviewOperationError>>;
29
+ /**
30
+ * Decodes an Aave Horizon opening and reports both halves of it: the
31
+ * credit account the position is built in while the mint settles, and the
32
+ * position it becomes on Aave after that.
33
+ *
34
+ * Calldata that is not an account opening is refused with
35
+ * `unsupportedOperation`.
36
+ **/
37
+ openAavePosition(input: PreviewOperationInput, options?: PreviewOperationOptions): Promise<SDKReturn<OpenAavePositionPreview, PreviewOperationError>>;
29
38
  /**
30
39
  * Whether a parsed operation may be signed by `sender`: protocol state first,
31
40
  * then what the wallet has to approve, hold or sign.
@@ -0,0 +1,108 @@
1
+ import { ILogger } from "../onchain/types/logger.js";
2
+ import { CreateTestnetRequest, Testnet, TestnetFiles, TestnetStatus } from "./types.js";
3
+ //#region src/testnets/TestnetsAPI.d.ts
4
+ /**
5
+ * Options of a {@link TestnetsAPI}.
6
+ **/
7
+ export interface TestnetsAPIOptions {
8
+ /**
9
+ * Base URL of anvil-manager.
10
+ *
11
+ * @defaultValue `"https://anvil.gearbox.foundation"`
12
+ **/
13
+ baseUrl?: string;
14
+ /**
15
+ * API key sent as a bearer token with every request. Without it the private
16
+ * routes (create, kill) answer 401, which surfaces as a
17
+ * {@link TestnetStatusError}.
18
+ **/
19
+ apiKey?: string;
20
+ /**
21
+ * Timeout of one request, in milliseconds.
22
+ *
23
+ * @defaultValue `30_000`
24
+ **/
25
+ timeout?: number;
26
+ logger?: ILogger;
27
+ }
28
+ /**
29
+ * Options of {@link TestnetsAPI.waitUntilReady}.
30
+ **/
31
+ export interface WaitUntilReadyOptions {
32
+ /**
33
+ * How long to wait for the testnet to become ready, in milliseconds.
34
+ *
35
+ * @defaultValue `600_000` (10 minutes)
36
+ **/
37
+ timeout?: number;
38
+ /**
39
+ * Pause between two status polls, in milliseconds.
40
+ *
41
+ * @defaultValue `5_000`
42
+ **/
43
+ interval?: number;
44
+ }
45
+ /**
46
+ * Client for anvil-manager, which runs the anvil forks Gearbox calls
47
+ * testnets. It manages non-persistent testnets only, addressed by their
48
+ * execution id.
49
+ *
50
+ * ```ts
51
+ * const testnets = new TestnetsAPI({ apiKey: process.env.ANVIL_MANAGER_API_KEY });
52
+ * const { executionId } = await testnets.create({ network: "Mainnet", timeout: "2h" });
53
+ * const status = await testnets.waitUntilReady(executionId);
54
+ * // ... use status.rpcUrl ...
55
+ * await testnets.kill(executionId);
56
+ * ```
57
+ *
58
+ * Every method throws a {@link TestnetsError} subclass when it fails, except
59
+ * when a response body is not JSON: then it rejects with the error of
60
+ * `response.json()`.
61
+ **/
62
+ export declare class TestnetsAPI {
63
+ #private;
64
+ protected readonly logger?: ILogger;
65
+ constructor(options?: TestnetsAPIOptions);
66
+ /**
67
+ * Base URL every request of this client is sent to.
68
+ **/
69
+ get baseUrl(): string;
70
+ /**
71
+ * Every testnet anvil-manager knows of, persistent ones included.
72
+ **/
73
+ list(): Promise<Testnet[]>;
74
+ /**
75
+ * Status of one testnet.
76
+ *
77
+ * @param id - Execution id of the testnet.
78
+ * @throws {@link TestnetNotFoundError} when there is no such testnet.
79
+ **/
80
+ get(id: string): Promise<TestnetStatus>;
81
+ /**
82
+ * Starts a testnet. It answers as soon as the testnet is created, long
83
+ * before it is {@link TestnetStatus.ready}.
84
+ *
85
+ * @param files - Saved in the testnet's shared dir, where scripts and tasks
86
+ * can read them.
87
+ **/
88
+ create(request: CreateTestnetRequest, files?: TestnetFiles): Promise<TestnetStatus>;
89
+ /**
90
+ * Stops a testnet. Stopping one that is already stopped succeeds.
91
+ *
92
+ * @param id - Execution id of the testnet.
93
+ * @throws {@link TestnetNotFoundError} when there is no such testnet.
94
+ * @throws {@link TestnetStatusError} with status 400 when the testnet is
95
+ * persistent.
96
+ **/
97
+ kill(id: string): Promise<void>;
98
+ /**
99
+ * Polls a testnet's status until it is {@link TestnetStatus.ready}.
100
+ *
101
+ * @param id - Execution id of the testnet.
102
+ * @returns The first status that is ready.
103
+ * @throws {@link TestnetWaitTimeoutError} when the testnet is not ready in
104
+ * time. Any error of a poll is thrown as is, without retrying.
105
+ **/
106
+ waitUntilReady(id: string, options?: WaitUntilReadyOptions): Promise<TestnetStatus>;
107
+ }
108
+ //#endregion
@@ -0,0 +1,12 @@
1
+ import { TestnetStatusError } from "./TestnetStatusError.js";
2
+ //#region src/testnets/errors/TestnetNotFoundError.d.ts
3
+ /**
4
+ * Thrown when anvil-manager answered 404: there is no testnet with that
5
+ * execution id.
6
+ **/
7
+ export declare class TestnetNotFoundError extends TestnetStatusError {
8
+ name: string;
9
+ readonly status: 404;
10
+ constructor(url: string, details?: string);
11
+ }
12
+ //#endregion
@@ -0,0 +1,11 @@
1
+ import { TestnetsError } from "./TestnetsError.js";
2
+ //#region src/testnets/errors/TestnetRequestFailedError.d.ts
3
+ /**
4
+ * Thrown when a request to anvil-manager never completed: the network was
5
+ * down, or it took longer than the client's timeout.
6
+ **/
7
+ export declare class TestnetRequestFailedError extends TestnetsError {
8
+ name: string;
9
+ constructor(url: string, cause: unknown);
10
+ }
11
+ //#endregion
@@ -0,0 +1,15 @@
1
+ import { TestnetsError } from "./TestnetsError.js";
2
+ //#region src/testnets/errors/TestnetStatusError.d.ts
3
+ /**
4
+ * Thrown when anvil-manager answered with a status outside the 2xx range. What
5
+ * it said about it, when it said anything, is the `details` of the error.
6
+ **/
7
+ export declare class TestnetStatusError extends TestnetsError {
8
+ name: string;
9
+ /**
10
+ * Status anvil-manager answered with.
11
+ **/
12
+ readonly status: number;
13
+ constructor(url: string, status: number, details?: string);
14
+ }
15
+ //#endregion
@@ -0,0 +1,16 @@
1
+ import { TestnetsError } from "./TestnetsError.js";
2
+ import { z } from "zod/v4";
3
+ //#region src/testnets/errors/TestnetValidationError.d.ts
4
+ /**
5
+ * Thrown when anvil-manager answered, but with a payload the testnet schemas
6
+ * do not describe, i.e. the two are of different versions.
7
+ **/
8
+ export declare class TestnetValidationError extends TestnetsError {
9
+ name: string;
10
+ /**
11
+ * The zod failure itself, e.g. for `z.treeifyError(error.zodError)`.
12
+ **/
13
+ readonly zodError: z.core.$ZodError;
14
+ constructor(url: string, zodError: z.core.$ZodError);
15
+ }
16
+ //#endregion
@@ -0,0 +1,21 @@
1
+ import { TestnetsError } from "./TestnetsError.js";
2
+ //#region src/testnets/errors/TestnetWaitTimeoutError.d.ts
3
+ /**
4
+ * Thrown when a testnet did not become ready before the wait for it ran out.
5
+ **/
6
+ export declare class TestnetWaitTimeoutError extends TestnetsError {
7
+ name: string;
8
+ /**
9
+ * Execution id of the testnet that was waited for.
10
+ **/
11
+ readonly id: string;
12
+ /**
13
+ * How long the wait lasted, in milliseconds.
14
+ **/
15
+ readonly timeout: number;
16
+ /**
17
+ * @param url - Status URL that was polled.
18
+ **/
19
+ constructor(url: string, id: string, timeout: number);
20
+ }
21
+ //#endregion
@@ -0,0 +1,47 @@
1
+ import { BaseError } from "viem";
2
+ //#region src/testnets/errors/TestnetsError.d.ts
3
+ /**
4
+ * What every failure of a testnet API call names, see {@link TestnetsError}.
5
+ **/
6
+ export interface TestnetsErrorParams {
7
+ /**
8
+ * URL that was requested.
9
+ **/
10
+ url: string;
11
+ /**
12
+ * Status anvil-manager answered with, absent when the request never
13
+ * completed.
14
+ **/
15
+ status?: number;
16
+ /**
17
+ * Value that was caught. An `Error` becomes the `cause`, anything else is
18
+ * stringified into the details.
19
+ **/
20
+ cause?: unknown;
21
+ /**
22
+ * What anvil-manager itself said. Used only when there is no {@link cause},
23
+ * whose message viem reports instead.
24
+ **/
25
+ details?: string;
26
+ /**
27
+ * Extra lines reported after the URL and status.
28
+ **/
29
+ metaMessages?: string[];
30
+ }
31
+ /**
32
+ * Thrown by every testnet API call that fails. Its subclasses say how it
33
+ * failed; catch this one to catch all of them.
34
+ **/
35
+ export declare abstract class TestnetsError extends BaseError {
36
+ /**
37
+ * URL that was requested.
38
+ **/
39
+ readonly url: string;
40
+ /**
41
+ * Status anvil-manager answered with, absent when the request never
42
+ * completed.
43
+ **/
44
+ readonly status?: number;
45
+ protected constructor(summary: string, params: TestnetsErrorParams);
46
+ }
47
+ //#endregion
@@ -0,0 +1,7 @@
1
+ import { TestnetsError, TestnetsErrorParams } from "./TestnetsError.js";
2
+ import { TestnetStatusError } from "./TestnetStatusError.js";
3
+ import { TestnetNotFoundError } from "./TestnetNotFoundError.js";
4
+ import { TestnetRequestFailedError } from "./TestnetRequestFailedError.js";
5
+ import { TestnetValidationError } from "./TestnetValidationError.js";
6
+ import { TestnetWaitTimeoutError } from "./TestnetWaitTimeoutError.js";
7
+ export { TestnetNotFoundError, TestnetRequestFailedError, TestnetStatusError, TestnetValidationError, TestnetWaitTimeoutError, TestnetsError, TestnetsErrorParams };
@@ -0,0 +1,11 @@
1
+ import { CreateTestnetRequest, Testnet, TestnetBackendOptions, TestnetBackendState, TestnetBackendStatus, TestnetBlock, TestnetFiles, TestnetOptions, TestnetScript, TestnetScriptBlock, TestnetScriptOptions, TestnetScriptRequest, TestnetStageStatus, TestnetStatus, TestnetTask, TestnetTaskDefinition, TestnetTaskDefinitionRequest, TestnetTaskProgress } from "./types.js";
2
+ import { TestnetsAPI, TestnetsAPIOptions, WaitUntilReadyOptions } from "./TestnetsAPI.js";
3
+ import { TestnetsError, TestnetsErrorParams } from "./errors/TestnetsError.js";
4
+ import { TestnetStatusError } from "./errors/TestnetStatusError.js";
5
+ import { TestnetNotFoundError } from "./errors/TestnetNotFoundError.js";
6
+ import { TestnetRequestFailedError } from "./errors/TestnetRequestFailedError.js";
7
+ import { TestnetValidationError } from "./errors/TestnetValidationError.js";
8
+ import { TestnetWaitTimeoutError } from "./errors/TestnetWaitTimeoutError.js";
9
+ import "./errors/index.js";
10
+ import { testnetBackendOptionsSchema, testnetBackendStateSchema, testnetBackendStatusSchema, testnetBlockSchema, testnetOptionsSchema, testnetSchema, testnetScriptBlockSchema, testnetScriptOptionsSchema, testnetScriptSchema, testnetStageStatusSchema, testnetStatusSchema, testnetTaskDefinitionSchema, testnetTaskProgressSchema, testnetTaskSchema } from "./schemas.js";
11
+ export { CreateTestnetRequest, Testnet, TestnetBackendOptions, TestnetBackendState, TestnetBackendStatus, TestnetBlock, TestnetFiles, TestnetNotFoundError, TestnetOptions, TestnetRequestFailedError, TestnetScript, TestnetScriptBlock, TestnetScriptOptions, TestnetScriptRequest, TestnetStageStatus, TestnetStatus, TestnetStatusError, TestnetTask, TestnetTaskDefinition, TestnetTaskDefinitionRequest, TestnetTaskProgress, TestnetValidationError, TestnetWaitTimeoutError, TestnetsAPI, TestnetsAPIOptions, TestnetsError, TestnetsErrorParams, WaitUntilReadyOptions, testnetBackendOptionsSchema, testnetBackendStateSchema, testnetBackendStatusSchema, testnetBlockSchema, testnetOptionsSchema, testnetSchema, testnetScriptBlockSchema, testnetScriptOptionsSchema, testnetScriptSchema, testnetStageStatusSchema, testnetStatusSchema, testnetTaskDefinitionSchema, testnetTaskProgressSchema, testnetTaskSchema };