@lidofinance/lsv-cli 1.1.0 → 1.2.0

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 (421) hide show
  1. package/dist/abi/Dashboard.d.ts +23 -3
  2. package/dist/abi/Dashboard.js +8 -3
  3. package/dist/abi/Dashboard.js.map +1 -1
  4. package/dist/abi/LazyOracle.d.ts +364 -0
  5. package/dist/abi/LazyOracle.js +2 -0
  6. package/dist/abi/LazyOracle.js.map +1 -1
  7. package/dist/abi/OperatorGrid.d.ts +24 -0
  8. package/dist/abi/OperatorGrid.js +16 -0
  9. package/dist/abi/OperatorGrid.js.map +1 -1
  10. package/dist/abi/ValidatorConsolidationRequests.d.ts +121 -0
  11. package/dist/abi/ValidatorConsolidationRequests.js +159 -0
  12. package/dist/abi/ValidatorConsolidationRequests.js.map +1 -0
  13. package/dist/abi/VaultFactory.d.ts +16 -0
  14. package/dist/abi/VaultViewer.d.ts +0 -14
  15. package/dist/abi/VaultViewer.js +0 -19
  16. package/dist/abi/VaultViewer.js.map +1 -1
  17. package/dist/abi/defi-wrapper/Distributor.d.ts +40 -2
  18. package/dist/abi/defi-wrapper/Distributor.js +52 -2
  19. package/dist/abi/defi-wrapper/Distributor.js.map +1 -1
  20. package/dist/abi/defi-wrapper/Factory.d.ts +973 -550
  21. package/dist/abi/defi-wrapper/Factory.js +720 -763
  22. package/dist/abi/defi-wrapper/Factory.js.map +1 -1
  23. package/dist/abi/defi-wrapper/StvPool.d.ts +121 -325
  24. package/dist/abi/defi-wrapper/StvPool.js +143 -413
  25. package/dist/abi/defi-wrapper/StvPool.js.map +1 -1
  26. package/dist/abi/defi-wrapper/StvStETHPool.d.ts +398 -381
  27. package/dist/abi/defi-wrapper/StvStETHPool.js +448 -433
  28. package/dist/abi/defi-wrapper/StvStETHPool.js.map +1 -1
  29. package/dist/abi/defi-wrapper/WithdrawalQueue.d.ts +309 -175
  30. package/dist/abi/defi-wrapper/WithdrawalQueue.js +381 -206
  31. package/dist/abi/defi-wrapper/WithdrawalQueue.js.map +1 -1
  32. package/dist/abi/defi-wrapper/index.d.ts +0 -1
  33. package/dist/abi/defi-wrapper/index.js +0 -1
  34. package/dist/abi/defi-wrapper/index.js.map +1 -1
  35. package/dist/abi/index.d.ts +1 -0
  36. package/dist/abi/index.js +1 -0
  37. package/dist/abi/index.js.map +1 -1
  38. package/dist/configs/constants.d.ts +44 -2
  39. package/dist/configs/constants.js +2 -2
  40. package/dist/configs/constants.js.map +1 -1
  41. package/dist/configs/deployed.d.ts +2 -2
  42. package/dist/configs/deployed.js +48 -6
  43. package/dist/configs/deployed.js.map +1 -1
  44. package/dist/configs/utils.d.ts +1 -0
  45. package/dist/configs/utils.js +8 -0
  46. package/dist/configs/utils.js.map +1 -1
  47. package/dist/contracts/dashboard-impl.d.ts +2 -2
  48. package/dist/contracts/dashboard-impl.js +3 -2
  49. package/dist/contracts/dashboard-impl.js.map +1 -1
  50. package/dist/contracts/dashboard.d.ts +2 -2
  51. package/dist/contracts/dashboard.js +3 -2
  52. package/dist/contracts/dashboard.js.map +1 -1
  53. package/dist/contracts/defi-wrapper/distributor.d.ts +1 -1
  54. package/dist/contracts/defi-wrapper/distributor.js +3 -2
  55. package/dist/contracts/defi-wrapper/distributor.js.map +1 -1
  56. package/dist/contracts/defi-wrapper/factory.d.ts +1 -1
  57. package/dist/contracts/defi-wrapper/factory.js +3 -2
  58. package/dist/contracts/defi-wrapper/factory.js.map +1 -1
  59. package/dist/contracts/defi-wrapper/index.d.ts +0 -1
  60. package/dist/contracts/defi-wrapper/index.js +0 -1
  61. package/dist/contracts/defi-wrapper/index.js.map +1 -1
  62. package/dist/contracts/defi-wrapper/stv-pool.d.ts +2 -2
  63. package/dist/contracts/defi-wrapper/stv-pool.js +3 -2
  64. package/dist/contracts/defi-wrapper/stv-pool.js.map +1 -1
  65. package/dist/contracts/defi-wrapper/stv-steth-pool.d.ts +1 -1
  66. package/dist/contracts/defi-wrapper/stv-steth-pool.js +3 -2
  67. package/dist/contracts/defi-wrapper/stv-steth-pool.js.map +1 -1
  68. package/dist/contracts/defi-wrapper/withdrawal-queue.d.ts +1 -1
  69. package/dist/contracts/defi-wrapper/withdrawal-queue.js +3 -2
  70. package/dist/contracts/defi-wrapper/withdrawal-queue.js.map +1 -1
  71. package/dist/contracts/index.d.ts +1 -0
  72. package/dist/contracts/index.js +1 -0
  73. package/dist/contracts/index.js.map +1 -1
  74. package/dist/contracts/lazy-oracle.js +3 -2
  75. package/dist/contracts/lazy-oracle.js.map +1 -1
  76. package/dist/contracts/locator.d.ts +3 -9655
  77. package/dist/contracts/locator.js +4 -3
  78. package/dist/contracts/locator.js.map +1 -1
  79. package/dist/contracts/operator-grid.d.ts +1 -1
  80. package/dist/contracts/operator-grid.js +3 -2
  81. package/dist/contracts/operator-grid.js.map +1 -1
  82. package/dist/contracts/pdg.js +3 -2
  83. package/dist/contracts/pdg.js.map +1 -1
  84. package/dist/contracts/steth.d.ts +54 -54
  85. package/dist/contracts/steth.js +3 -2
  86. package/dist/contracts/steth.js.map +1 -1
  87. package/dist/contracts/validator-consolidation-requests.d.ts +5 -0
  88. package/dist/contracts/validator-consolidation-requests.js +13 -0
  89. package/dist/contracts/validator-consolidation-requests.js.map +1 -0
  90. package/dist/contracts/vault-factory.d.ts +3 -28346
  91. package/dist/contracts/vault-factory.js +4 -3
  92. package/dist/contracts/vault-factory.js.map +1 -1
  93. package/dist/contracts/vault-hub.js +3 -2
  94. package/dist/contracts/vault-hub.js.map +1 -1
  95. package/dist/contracts/vault-viewer.d.ts +3 -9661
  96. package/dist/contracts/vault-viewer.js +9 -7
  97. package/dist/contracts/vault-viewer.js.map +1 -1
  98. package/dist/contracts/vault.d.ts +2 -2
  99. package/dist/contracts/vault.js +3 -2
  100. package/dist/contracts/vault.js.map +1 -1
  101. package/dist/contracts/wsteth.d.ts +3 -24690
  102. package/dist/contracts/wsteth.js +4 -3
  103. package/dist/contracts/wsteth.js.map +1 -1
  104. package/dist/features/consolidation.d.ts +18 -0
  105. package/dist/features/consolidation.js +199 -0
  106. package/dist/features/consolidation.js.map +1 -0
  107. package/dist/features/defi-wrapper/create-vault.d.ts +17 -0
  108. package/dist/features/defi-wrapper/create-vault.js +137 -0
  109. package/dist/features/defi-wrapper/create-vault.js.map +1 -0
  110. package/dist/features/defi-wrapper/defi-wrapper-factory.d.ts +112 -0
  111. package/dist/features/defi-wrapper/defi-wrapper-factory.js +228 -0
  112. package/dist/features/defi-wrapper/defi-wrapper-factory.js.map +1 -0
  113. package/dist/features/defi-wrapper/index.d.ts +3 -0
  114. package/dist/features/defi-wrapper/index.js +4 -0
  115. package/dist/features/defi-wrapper/index.js.map +1 -0
  116. package/dist/features/defi-wrapper/pool-info.d.ts +35 -0
  117. package/dist/features/defi-wrapper/pool-info.js +97 -0
  118. package/dist/features/defi-wrapper/pool-info.js.map +1 -0
  119. package/dist/features/deposits/check-bls-deposits.js +2 -2
  120. package/dist/features/deposits/check-bls-deposits.js.map +1 -1
  121. package/dist/features/deposits/index.d.ts +1 -0
  122. package/dist/features/deposits/index.js +1 -0
  123. package/dist/features/deposits/index.js.map +1 -1
  124. package/dist/features/deposits/make-pdg-proof.js +1 -1
  125. package/dist/features/deposits/make-pdg-proof.js.map +1 -1
  126. package/dist/features/deposits/no-pdg.d.ts +1 -1
  127. package/dist/features/deposits/no-pdg.js +6 -3
  128. package/dist/features/deposits/no-pdg.js.map +1 -1
  129. package/dist/features/deposits/pdg.d.ts +2 -0
  130. package/dist/features/deposits/pdg.js +18 -0
  131. package/dist/features/deposits/pdg.js.map +1 -0
  132. package/dist/features/dev-tools/impersonate.d.ts +14 -0
  133. package/dist/features/dev-tools/impersonate.js +64 -0
  134. package/dist/features/dev-tools/impersonate.js.map +1 -0
  135. package/dist/features/dev-tools/index.d.ts +1 -0
  136. package/dist/features/dev-tools/index.js +2 -0
  137. package/dist/features/dev-tools/index.js.map +1 -0
  138. package/dist/features/index.d.ts +4 -1
  139. package/dist/features/index.js +4 -1
  140. package/dist/features/index.js.map +1 -1
  141. package/dist/features/metrics.d.ts +4 -0
  142. package/dist/features/metrics.js +48 -0
  143. package/dist/features/metrics.js.map +1 -0
  144. package/dist/features/pdg.js +4 -0
  145. package/dist/features/pdg.js.map +1 -1
  146. package/dist/features/utils/get-boolean.d.ts +1 -0
  147. package/dist/features/utils/get-boolean.js +13 -0
  148. package/dist/features/utils/get-boolean.js.map +1 -0
  149. package/dist/features/utils/index.d.ts +1 -0
  150. package/dist/features/utils/index.js +1 -0
  151. package/dist/features/utils/index.js.map +1 -1
  152. package/dist/features/utils/quarantine.js +2 -0
  153. package/dist/features/utils/quarantine.js.map +1 -1
  154. package/dist/features/utils/report-fresh.js +2 -3
  155. package/dist/features/utils/report-fresh.js.map +1 -1
  156. package/dist/features/vault-factory.js +2 -2
  157. package/dist/features/vault-factory.js.map +1 -1
  158. package/dist/features/vault-operations/create-vault.d.ts +4 -2
  159. package/dist/features/vault-operations/create-vault.js +11 -3
  160. package/dist/features/vault-operations/create-vault.js.map +1 -1
  161. package/dist/features/vault-operations/dashboard-by-vault.js +4 -4
  162. package/dist/features/vault-operations/dashboard-by-vault.js.map +1 -1
  163. package/dist/features/vault-operations/vault-info.js +1 -1
  164. package/dist/features/vault-operations/vault-info.js.map +1 -1
  165. package/dist/features/vault-operations/vault-overview.js +1 -1
  166. package/dist/features/vault-operations/vault-overview.js.map +1 -1
  167. package/dist/features/vault-operations/vault-roles.js +3 -0
  168. package/dist/features/vault-operations/vault-roles.js.map +1 -1
  169. package/dist/features/vault-operations/vaults-by-role.js +29 -10
  170. package/dist/features/vault-operations/vaults-by-role.js.map +1 -1
  171. package/dist/features/vault.js +4 -2
  172. package/dist/features/vault.js.map +1 -1
  173. package/dist/index.js +7 -2
  174. package/dist/index.js.map +1 -1
  175. package/dist/programs/account/read.js +1 -1
  176. package/dist/programs/account/read.js.map +1 -1
  177. package/dist/programs/account/write.js +14 -0
  178. package/dist/programs/account/write.js.map +1 -1
  179. package/dist/programs/contracts/dashboard/read.js +7 -7
  180. package/dist/programs/contracts/dashboard/read.js.map +1 -1
  181. package/dist/programs/contracts/dashboard/write.js +42 -42
  182. package/dist/programs/contracts/dashboard/write.js.map +1 -1
  183. package/dist/programs/contracts/hub/config.js +0 -10
  184. package/dist/programs/contracts/hub/config.js.map +1 -1
  185. package/dist/programs/contracts/hub/read.js +63 -2
  186. package/dist/programs/contracts/hub/read.js.map +1 -1
  187. package/dist/programs/contracts/hub/write.js +1 -1
  188. package/dist/programs/contracts/hub/write.js.map +1 -1
  189. package/dist/programs/contracts/pdg/read.js +2 -1
  190. package/dist/programs/contracts/pdg/read.js.map +1 -1
  191. package/dist/programs/contracts/pdg/write.js +37 -3
  192. package/dist/programs/contracts/pdg/write.js.map +1 -1
  193. package/dist/programs/contracts/vault/write.js +16 -16
  194. package/dist/programs/contracts/vault/write.js.map +1 -1
  195. package/dist/programs/contracts/vault-factory/write.js +2 -2
  196. package/dist/programs/contracts/vault-factory/write.js.map +1 -1
  197. package/dist/programs/defi-wrapper/contracts/distributor/read.js +1 -1
  198. package/dist/programs/defi-wrapper/contracts/distributor/read.js.map +1 -1
  199. package/dist/programs/defi-wrapper/contracts/distributor/write.js +3 -3
  200. package/dist/programs/defi-wrapper/contracts/distributor/write.js.map +1 -1
  201. package/dist/programs/defi-wrapper/contracts/factory/read.js +2 -8
  202. package/dist/programs/defi-wrapper/contracts/factory/read.js.map +1 -1
  203. package/dist/programs/defi-wrapper/contracts/factory/write.js +90 -273
  204. package/dist/programs/defi-wrapper/contracts/factory/write.js.map +1 -1
  205. package/dist/programs/defi-wrapper/contracts/index.d.ts +0 -1
  206. package/dist/programs/defi-wrapper/contracts/index.js +0 -1
  207. package/dist/programs/defi-wrapper/contracts/index.js.map +1 -1
  208. package/dist/programs/defi-wrapper/contracts/stv-pool/config.js +22 -32
  209. package/dist/programs/defi-wrapper/contracts/stv-pool/config.js.map +1 -1
  210. package/dist/programs/defi-wrapper/contracts/stv-pool/read.js +17 -24
  211. package/dist/programs/defi-wrapper/contracts/stv-pool/read.js.map +1 -1
  212. package/dist/programs/defi-wrapper/contracts/stv-pool/write.js +25 -174
  213. package/dist/programs/defi-wrapper/contracts/stv-pool/write.js.map +1 -1
  214. package/dist/programs/defi-wrapper/contracts/stv-steth-pool/config.js +0 -90
  215. package/dist/programs/defi-wrapper/contracts/stv-steth-pool/config.js.map +1 -1
  216. package/dist/programs/defi-wrapper/contracts/stv-steth-pool/read.js +16 -23
  217. package/dist/programs/defi-wrapper/contracts/stv-steth-pool/read.js.map +1 -1
  218. package/dist/programs/defi-wrapper/contracts/stv-steth-pool/write.js +34 -231
  219. package/dist/programs/defi-wrapper/contracts/stv-steth-pool/write.js.map +1 -1
  220. package/dist/programs/defi-wrapper/contracts/withdrawal-queue/config.js +1 -91
  221. package/dist/programs/defi-wrapper/contracts/withdrawal-queue/config.js.map +1 -1
  222. package/dist/programs/defi-wrapper/contracts/withdrawal-queue/read.js +8 -27
  223. package/dist/programs/defi-wrapper/contracts/withdrawal-queue/read.js.map +1 -1
  224. package/dist/programs/defi-wrapper/contracts/withdrawal-queue/write.js +55 -24
  225. package/dist/programs/defi-wrapper/contracts/withdrawal-queue/write.js.map +1 -1
  226. package/dist/programs/defi-wrapper/index.d.ts +1 -0
  227. package/dist/programs/defi-wrapper/index.js +1 -0
  228. package/dist/programs/defi-wrapper/index.js.map +1 -1
  229. package/dist/programs/defi-wrapper/use-cases/health/index.js.map +1 -0
  230. package/dist/programs/defi-wrapper/use-cases/health/main.d.ts +1 -0
  231. package/dist/programs/defi-wrapper/use-cases/health/main.js +6 -0
  232. package/dist/programs/defi-wrapper/use-cases/health/main.js.map +1 -0
  233. package/dist/programs/defi-wrapper/use-cases/health/read.js +338 -0
  234. package/dist/programs/defi-wrapper/use-cases/health/read.js.map +1 -0
  235. package/dist/programs/defi-wrapper/use-cases/health/utils.d.ts +56 -0
  236. package/dist/programs/defi-wrapper/use-cases/health/utils.js +389 -0
  237. package/dist/programs/defi-wrapper/use-cases/health/utils.js.map +1 -0
  238. package/dist/programs/defi-wrapper/use-cases/health/write.js +254 -0
  239. package/dist/programs/defi-wrapper/use-cases/health/write.js.map +1 -0
  240. package/dist/programs/defi-wrapper/use-cases/index.d.ts +3 -0
  241. package/dist/programs/defi-wrapper/use-cases/index.js +4 -0
  242. package/dist/programs/defi-wrapper/use-cases/index.js.map +1 -0
  243. package/dist/programs/defi-wrapper/use-cases/main.d.ts +1 -0
  244. package/dist/programs/defi-wrapper/use-cases/main.js +6 -0
  245. package/dist/programs/defi-wrapper/use-cases/main.js.map +1 -0
  246. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/create-pool.d.ts +1 -0
  247. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/create-pool.js +143 -0
  248. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/create-pool.js.map +1 -0
  249. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/index.d.ts +3 -0
  250. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/index.js +5 -0
  251. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/index.js.map +1 -0
  252. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/main.d.ts +1 -0
  253. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/main.js +6 -0
  254. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/main.js.map +1 -0
  255. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/read.d.ts +1 -0
  256. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/read.js +130 -0
  257. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/read.js.map +1 -0
  258. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/write.d.ts +1 -0
  259. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/write.js +13 -0
  260. package/dist/programs/defi-wrapper/use-cases/wrapper-operations/write.js.map +1 -0
  261. package/dist/programs/dev-tools/anvil/index.d.ts +2 -0
  262. package/dist/programs/dev-tools/anvil/index.js +3 -0
  263. package/dist/programs/dev-tools/anvil/index.js.map +1 -0
  264. package/dist/programs/dev-tools/anvil/main.d.ts +1 -0
  265. package/dist/programs/dev-tools/anvil/main.js +5 -0
  266. package/dist/programs/dev-tools/anvil/main.js.map +1 -0
  267. package/dist/programs/dev-tools/anvil/write.d.ts +1 -0
  268. package/dist/programs/dev-tools/anvil/write.js +122 -0
  269. package/dist/programs/dev-tools/anvil/write.js.map +1 -0
  270. package/dist/programs/dev-tools/defi-wrapper/index.d.ts +2 -0
  271. package/dist/programs/dev-tools/defi-wrapper/index.js +3 -0
  272. package/dist/programs/dev-tools/defi-wrapper/index.js.map +1 -0
  273. package/dist/programs/dev-tools/defi-wrapper/main.d.ts +1 -0
  274. package/dist/programs/dev-tools/defi-wrapper/main.js +6 -0
  275. package/dist/programs/dev-tools/defi-wrapper/main.js.map +1 -0
  276. package/dist/programs/dev-tools/defi-wrapper/write.d.ts +1 -0
  277. package/dist/programs/dev-tools/defi-wrapper/write.js +77 -0
  278. package/dist/programs/dev-tools/defi-wrapper/write.js.map +1 -0
  279. package/dist/programs/dev-tools/index.d.ts +3 -0
  280. package/dist/programs/dev-tools/index.js +4 -0
  281. package/dist/programs/dev-tools/index.js.map +1 -0
  282. package/dist/programs/dev-tools/main.d.ts +1 -0
  283. package/dist/programs/dev-tools/main.js +6 -0
  284. package/dist/programs/dev-tools/main.js.map +1 -0
  285. package/dist/programs/index.d.ts +1 -0
  286. package/dist/programs/index.js +1 -0
  287. package/dist/programs/index.js.map +1 -1
  288. package/dist/programs/pdg-helpers.js +19 -15
  289. package/dist/programs/pdg-helpers.js.map +1 -1
  290. package/dist/programs/use-cases/consolidation/index.d.ts +2 -0
  291. package/dist/programs/use-cases/consolidation/index.js +3 -0
  292. package/dist/programs/use-cases/consolidation/index.js.map +1 -0
  293. package/dist/programs/use-cases/consolidation/main.d.ts +1 -0
  294. package/dist/programs/use-cases/consolidation/main.js +5 -0
  295. package/dist/programs/use-cases/consolidation/main.js.map +1 -0
  296. package/dist/programs/use-cases/consolidation/write.d.ts +1 -0
  297. package/dist/programs/use-cases/consolidation/write.js +78 -0
  298. package/dist/programs/use-cases/consolidation/write.js.map +1 -0
  299. package/dist/programs/use-cases/deposits/read.js +4 -0
  300. package/dist/programs/use-cases/deposits/read.js.map +1 -1
  301. package/dist/programs/use-cases/deposits/write.js +41 -11
  302. package/dist/programs/use-cases/deposits/write.js.map +1 -1
  303. package/dist/programs/use-cases/index.d.ts +1 -0
  304. package/dist/programs/use-cases/index.js +1 -0
  305. package/dist/programs/use-cases/index.js.map +1 -1
  306. package/dist/programs/use-cases/metrics/read.js +9 -20
  307. package/dist/programs/use-cases/metrics/read.js.map +1 -1
  308. package/dist/programs/use-cases/vault-operations/create-vault.js +2 -2
  309. package/dist/programs/use-cases/vault-operations/create-vault.js.map +1 -1
  310. package/dist/providers/wallet.d.ts +14539 -63
  311. package/dist/providers/wallet.js +14 -4
  312. package/dist/providers/wallet.js.map +1 -1
  313. package/dist/tests/utils/bigInt.test.d.ts +1 -0
  314. package/dist/tests/utils/bigInt.test.js +61 -0
  315. package/dist/tests/utils/bigInt.test.js.map +1 -0
  316. package/dist/types/config.d.ts +1 -0
  317. package/dist/utils/arguments.d.ts +4 -0
  318. package/dist/utils/arguments.js +40 -1
  319. package/dist/utils/arguments.js.map +1 -1
  320. package/dist/utils/bigInt.d.ts +2 -0
  321. package/dist/utils/bigInt.js +3 -0
  322. package/dist/utils/bigInt.js.map +1 -0
  323. package/dist/utils/bls.d.ts +2 -2
  324. package/dist/utils/bls.js +8 -7
  325. package/dist/utils/bls.js.map +1 -1
  326. package/dist/utils/cache.d.ts +30 -0
  327. package/dist/utils/cache.js +140 -3
  328. package/dist/utils/cache.js.map +1 -1
  329. package/dist/utils/calculate-overview-v2.js +1 -2
  330. package/dist/utils/calculate-overview-v2.js.map +1 -1
  331. package/dist/utils/calculate-overview.js +1 -2
  332. package/dist/utils/calculate-overview.js.map +1 -1
  333. package/dist/utils/charts/blessed/charts-apr.js +8 -18
  334. package/dist/utils/charts/blessed/charts-apr.js.map +1 -1
  335. package/dist/utils/charts/blessed/charts-rewards.js +7 -17
  336. package/dist/utils/charts/blessed/charts-rewards.js.map +1 -1
  337. package/dist/utils/charts/blessed/datasets/prepare-metrics.d.ts +5 -5
  338. package/dist/utils/charts/blessed/datasets/prepare-metrics.js +11 -11
  339. package/dist/utils/charts/blessed/datasets/prepare-metrics.js.map +1 -1
  340. package/dist/utils/charts/simple/simple-charts.js +8 -18
  341. package/dist/utils/charts/simple/simple-charts.js.map +1 -1
  342. package/dist/utils/commands/confirmations.js +1 -1
  343. package/dist/utils/commands/confirmations.js.map +1 -1
  344. package/dist/utils/commands/report.d.ts +1 -1
  345. package/dist/utils/commands/report.js +3 -2
  346. package/dist/utils/commands/report.js.map +1 -1
  347. package/dist/utils/consolidation/checks.d.ts +7 -0
  348. package/dist/utils/consolidation/checks.js +40 -0
  349. package/dist/utils/consolidation/checks.js.map +1 -0
  350. package/dist/utils/consolidation/confirms.d.ts +4 -0
  351. package/dist/utils/consolidation/confirms.js +41 -0
  352. package/dist/utils/consolidation/confirms.js.map +1 -0
  353. package/dist/utils/consolidation/index.d.ts +6 -0
  354. package/dist/utils/consolidation/index.js +7 -0
  355. package/dist/utils/consolidation/index.js.map +1 -0
  356. package/dist/utils/consolidation/logs.d.ts +3 -0
  357. package/dist/utils/consolidation/logs.js +41 -0
  358. package/dist/utils/consolidation/logs.js.map +1 -0
  359. package/dist/utils/consolidation/pubkeys.d.ts +8 -0
  360. package/dist/utils/consolidation/pubkeys.js +40 -0
  361. package/dist/utils/consolidation/pubkeys.js.map +1 -0
  362. package/dist/utils/consolidation/types.d.ts +11 -0
  363. package/dist/utils/consolidation/types.js +2 -0
  364. package/dist/utils/consolidation/types.js.map +1 -0
  365. package/dist/utils/consolidation/validator-info.d.ts +4 -0
  366. package/dist/utils/consolidation/validator-info.js +34 -0
  367. package/dist/utils/consolidation/validator-info.js.map +1 -0
  368. package/dist/utils/consolidation/validators-checks.d.ts +10 -0
  369. package/dist/utils/consolidation/validators-checks.js +58 -0
  370. package/dist/utils/consolidation/validators-checks.js.map +1 -0
  371. package/dist/utils/fetchCL.d.ts +35 -14
  372. package/dist/utils/fetchCL.js +78 -5
  373. package/dist/utils/fetchCL.js.map +1 -1
  374. package/dist/utils/health/health-utils.d.ts +54 -54
  375. package/dist/utils/index.d.ts +1 -0
  376. package/dist/utils/index.js +1 -0
  377. package/dist/utils/index.js.map +1 -1
  378. package/dist/utils/read-programs-by-abi.d.ts +1 -1
  379. package/dist/utils/read-programs-by-abi.js +4 -18
  380. package/dist/utils/read-programs-by-abi.js.map +1 -1
  381. package/dist/utils/report/report.js +1 -1
  382. package/dist/utils/report/report.js.map +1 -1
  383. package/dist/utils/report/statistic-data.js +3 -3
  384. package/dist/utils/report/statistic-data.js.map +1 -1
  385. package/dist/utils/statistic/report-statistic.d.ts +6 -5
  386. package/dist/utils/statistic/report-statistic.js +15 -16
  387. package/dist/utils/statistic/report-statistic.js.map +1 -1
  388. package/dist/utils/transactions/tx-private-key.js +14 -9
  389. package/dist/utils/transactions/tx-private-key.js.map +1 -1
  390. package/dist/utils/transactions/tx-wc.d.ts +5 -3
  391. package/dist/utils/transactions/tx-wc.js +21 -10
  392. package/dist/utils/transactions/tx-wc.js.map +1 -1
  393. package/dist/utils/transactions/types.d.ts +4 -2
  394. package/dist/utils/wallet-connect.js +3 -3
  395. package/dist/utils/wallet-connect.js.map +1 -1
  396. package/dist/version/index.js +1 -1
  397. package/package.json +2 -2
  398. package/dist/abi/defi-wrapper/StvStrategyPool.d.ts +0 -1769
  399. package/dist/abi/defi-wrapper/StvStrategyPool.js +0 -2319
  400. package/dist/abi/defi-wrapper/StvStrategyPool.js.map +0 -1
  401. package/dist/contracts/defi-wrapper/stv-strategy-pool.d.ts +0 -4
  402. package/dist/contracts/defi-wrapper/stv-strategy-pool.js +0 -11
  403. package/dist/contracts/defi-wrapper/stv-strategy-pool.js.map +0 -1
  404. package/dist/features/defi-wrapper-factory.d.ts +0 -18
  405. package/dist/features/defi-wrapper-factory.js +0 -28
  406. package/dist/features/defi-wrapper-factory.js.map +0 -1
  407. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/config.d.ts +0 -3
  408. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/config.js +0 -214
  409. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/config.js.map +0 -1
  410. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/index.js.map +0 -1
  411. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/main.d.ts +0 -1
  412. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/main.js +0 -6
  413. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/main.js.map +0 -1
  414. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/read.js +0 -77
  415. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/read.js.map +0 -1
  416. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/write.js +0 -370
  417. package/dist/programs/defi-wrapper/contracts/stv-strategy-pool/write.js.map +0 -1
  418. /package/dist/programs/defi-wrapper/{contracts/stv-strategy-pool → use-cases/health}/index.d.ts +0 -0
  419. /package/dist/programs/defi-wrapper/{contracts/stv-strategy-pool → use-cases/health}/index.js +0 -0
  420. /package/dist/programs/defi-wrapper/{contracts/stv-strategy-pool → use-cases/health}/read.d.ts +0 -0
  421. /package/dist/programs/defi-wrapper/{contracts/stv-strategy-pool → use-cases/health}/write.d.ts +0 -0
@@ -0,0 +1,389 @@
1
+ import { zeroAddress } from 'viem';
2
+ import { getPublicClient } from '../../../../providers/index.js';
3
+ import { logInfo, logError, getIndexedEventsFromCache, callReadMethodSilent, confirmOperation, logCancel, } from '../../../../utils/index.js';
4
+ import { grantRoleFromImpersonatedAccount, callMethodFromImpersonatedAccount, } from '../../../../features/index.js';
5
+ import { getStvStethPoolContract } from '../../../../contracts/defi-wrapper/index.js';
6
+ const TOTAL_BASIS_POINTS = 10000n;
7
+ const fetchEventsForBlocks = async ({ blocks, poolAddress, batchSize = 30000, }) => {
8
+ const publicClient = await getPublicClient();
9
+ const eventsMap = new Map();
10
+ // Initialize empty events for each block
11
+ for (const block of blocks) {
12
+ eventsMap.set(block, {
13
+ transfer: [],
14
+ minted: [],
15
+ burned: [],
16
+ });
17
+ }
18
+ if (blocks.length === 0)
19
+ return eventsMap;
20
+ // Split blocks into batches based on block range
21
+ const batches = [];
22
+ let currentBatch = [];
23
+ let batchStartBlock = blocks[0];
24
+ for (const block of blocks) {
25
+ // If block is within batch size range from start, add to current batch
26
+ if (block - batchStartBlock < batchSize) {
27
+ currentBatch.push(block);
28
+ }
29
+ else {
30
+ // Start new batch
31
+ batches.push(currentBatch);
32
+ currentBatch = [block];
33
+ batchStartBlock = block;
34
+ }
35
+ }
36
+ if (currentBatch.length > 0) {
37
+ batches.push(currentBatch);
38
+ }
39
+ logInfo(`Fetching events for ${blocks.length} blocks in ${batches.length} batch(es) (max ${batchSize} blocks per batch)...`);
40
+ // Fetch each batch
41
+ for (let i = 0; i < batches.length; i++) {
42
+ const batch = batches[i];
43
+ if (!batch || batch.length === 0)
44
+ continue;
45
+ const blocksSet = new Set(batch);
46
+ const minBlock = batch[0];
47
+ const maxBlock = batch[batch.length - 1];
48
+ logInfo(`Batch ${i + 1}/${batches.length}: fetching blocks ${minBlock} to ${maxBlock} (${batch.length} blocks)...`);
49
+ try {
50
+ // Fetch all events in parallel for this batch
51
+ const [transferLogs, mintedLogs, burnedLogs] = await Promise.all([
52
+ publicClient.getLogs({
53
+ address: poolAddress,
54
+ event: {
55
+ type: 'event',
56
+ name: 'Transfer',
57
+ inputs: [
58
+ { indexed: true, name: 'from', type: 'address' },
59
+ { indexed: true, name: 'to', type: 'address' },
60
+ { indexed: false, name: 'value', type: 'uint256' },
61
+ ],
62
+ },
63
+ fromBlock: minBlock,
64
+ toBlock: maxBlock,
65
+ }),
66
+ publicClient.getLogs({
67
+ address: poolAddress,
68
+ event: {
69
+ type: 'event',
70
+ name: 'StethSharesMinted',
71
+ inputs: [
72
+ { indexed: true, name: 'account', type: 'address' },
73
+ { indexed: false, name: 'stethShares', type: 'uint256' },
74
+ ],
75
+ },
76
+ fromBlock: minBlock,
77
+ toBlock: maxBlock,
78
+ }),
79
+ publicClient.getLogs({
80
+ address: poolAddress,
81
+ event: {
82
+ type: 'event',
83
+ name: 'StethSharesBurned',
84
+ inputs: [
85
+ { indexed: true, name: 'account', type: 'address' },
86
+ { indexed: false, name: 'stethShares', type: 'uint256' },
87
+ ],
88
+ },
89
+ fromBlock: minBlock,
90
+ toBlock: maxBlock,
91
+ }),
92
+ ]);
93
+ logInfo(` Found ${transferLogs.length} Transfer, ${mintedLogs.length} Minted, ${burnedLogs.length} Burned events`);
94
+ // Group Transfer events by block
95
+ for (const log of transferLogs) {
96
+ const blockNumber = log.blockNumber;
97
+ if (blockNumber && blocksSet.has(blockNumber) && log.args) {
98
+ const blockEvents = eventsMap.get(blockNumber);
99
+ if (blockEvents) {
100
+ const args = log.args;
101
+ if (args.from && args.to && args.value !== undefined) {
102
+ blockEvents.transfer.push({
103
+ blockNumber: blockNumber.toString(),
104
+ from: args.from,
105
+ to: args.to,
106
+ value: args.value.toString(),
107
+ });
108
+ }
109
+ }
110
+ }
111
+ }
112
+ // Group Minted events by block
113
+ for (const log of mintedLogs) {
114
+ const blockNumber = log.blockNumber;
115
+ if (blockNumber && blocksSet.has(blockNumber) && log.args) {
116
+ const blockEvents = eventsMap.get(blockNumber);
117
+ if (blockEvents) {
118
+ const args = log.args;
119
+ if (args.account && args.stethShares !== undefined) {
120
+ blockEvents.minted.push({
121
+ blockNumber: blockNumber.toString(),
122
+ account: args.account,
123
+ stethShares: args.stethShares.toString(),
124
+ });
125
+ }
126
+ }
127
+ }
128
+ }
129
+ // Group Burned events by block
130
+ for (const log of burnedLogs) {
131
+ const blockNumber = log.blockNumber;
132
+ if (blockNumber && blocksSet.has(blockNumber) && log.args) {
133
+ const blockEvents = eventsMap.get(blockNumber);
134
+ if (blockEvents) {
135
+ const args = log.args;
136
+ if (args.account && args.stethShares !== undefined) {
137
+ blockEvents.burned.push({
138
+ blockNumber: blockNumber.toString(),
139
+ account: args.account,
140
+ stethShares: args.stethShares.toString(),
141
+ });
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+ catch (error) {
148
+ logError(error, `Error fetching events for batch ${i + 1}: ${error}`);
149
+ throw new Error(`Failed to fetch events for batch ${i + 1}: ${error}`);
150
+ }
151
+ }
152
+ logInfo(`Processed events for ${eventsMap.size} blocks`);
153
+ return eventsMap;
154
+ };
155
+ /**
156
+ * Replicates the contract's _isThresholdBreached logic
157
+ * @param assets - STV assets value in ETH (from previewRedeem)
158
+ * @param stethShares - debt in stETH shares
159
+ * @param debtInEth - debt in ETH (from getPooledEthBySharesRoundUp)
160
+ * @param forcedRebalanceThresholdBP - threshold in basis points
161
+ * @returns true if threshold is breached (position is unhealthy)
162
+ */
163
+ export const isThresholdBreached = ({ assets, stethShares, debtInEth, forcedRebalanceThresholdBP, verbose, }) => {
164
+ // If no debt, position is healthy
165
+ if (stethShares === 0n)
166
+ return false;
167
+ // Calculate assetsThreshold using the same formula as contract:
168
+ // assetsThreshold = mulDiv(
169
+ // getPooledEthBySharesRoundUp(_stethShares),
170
+ // TOTAL_BASIS_POINTS,
171
+ // TOTAL_BASIS_POINTS - forcedRebalanceThresholdBP(),
172
+ // Ceil
173
+ // )
174
+ const numerator = debtInEth * TOTAL_BASIS_POINTS;
175
+ const denominator = TOTAL_BASIS_POINTS - forcedRebalanceThresholdBP;
176
+ // mulDiv with ceiling rounding
177
+ const assetsThreshold = numerator / denominator + (numerator % denominator > 0n ? 1n : 0n);
178
+ if (verbose) {
179
+ logInfo(` [isThresholdBreached]
180
+ numerator: ${numerator.toString()}
181
+ denominator: ${denominator.toString()}
182
+ assetsThreshold: ${assetsThreshold.toString()}
183
+ assets: ${assets.toString()}
184
+ breached: ${assets < assetsThreshold} (${assets} < ${assetsThreshold})
185
+ `);
186
+ }
187
+ // Position is unhealthy if assets < assetsThreshold
188
+ return assets < assetsThreshold;
189
+ };
190
+ /**
191
+ * Calculate the "effective LTV ratio" for display purposes
192
+ * This shows how close the position is to the threshold
193
+ * Returns basis points (10000 = 100%)
194
+ */
195
+ export const calculateEffectiveLTV = ({ assets, debtInEth, }) => {
196
+ if (assets === 0n)
197
+ return 0;
198
+ // Simple debt/collateral ratio in basis points
199
+ return Number((debtInEth * 10000n) / assets);
200
+ };
201
+ /**
202
+ * Calculate how much the position exceeds the threshold
203
+ * Returns basis points of how much over threshold (negative if healthy)
204
+ */
205
+ export const calculateThresholdExcess = ({ assets, stethShares, debtInEth, forcedRebalanceThresholdBP, verbose, }) => {
206
+ if (stethShares === 0n)
207
+ return 0;
208
+ const numerator = debtInEth * TOTAL_BASIS_POINTS;
209
+ const denominator = TOTAL_BASIS_POINTS - forcedRebalanceThresholdBP;
210
+ const assetsThreshold = numerator / denominator + (numerator % denominator > 0n ? 1n : 0n);
211
+ // How much short of threshold? (negative means healthy margin)
212
+ const shortfall = assetsThreshold - assets;
213
+ if (verbose) {
214
+ logInfo(` [calculateThresholdExcess]
215
+ assetsThreshold: ${assetsThreshold.toString()}
216
+ assets: ${assets.toString()}
217
+ shortfall: ${shortfall.toString()} (threshold - assets)
218
+ `);
219
+ }
220
+ // Convert to percentage of assets
221
+ if (assets === 0n)
222
+ return 0;
223
+ const excessBP = Number((shortfall * 10000n) / assets);
224
+ if (verbose) {
225
+ logInfo(` excessBP: ${excessBP} (${(excessBP / 100).toFixed(2)}%)`);
226
+ }
227
+ return excessBP;
228
+ };
229
+ // Helper function to index accounts from events
230
+ export const indexAccountsFromEvents = async ({ poolAddress, fromBlock, toBlock, batchSize, }) => {
231
+ const publicClient = await getPublicClient();
232
+ const from = fromBlock ? BigInt(fromBlock) : undefined;
233
+ const to = toBlock ? BigInt(toBlock) : await publicClient.getBlockNumber();
234
+ // Calculate block range
235
+ const startBlock = from || (to - 10000n > 0n ? to - 10000n : 0n);
236
+ logInfo(`Scanning blocks ${startBlock} to ${to}...`);
237
+ // Get events from cache or fetch from blockchain
238
+ const events = await getIndexedEventsFromCache({
239
+ poolAddress,
240
+ startBlock,
241
+ endBlock: to,
242
+ fetchEventsForBlocks: (blocks) => fetchEventsForBlocks({ blocks, poolAddress, batchSize }),
243
+ });
244
+ // Extract unique accounts from cached events
245
+ const accounts = new Set();
246
+ for (const event of events.transfer) {
247
+ if (event.from && event.from !== zeroAddress)
248
+ accounts.add(event.from);
249
+ if (event.to && event.to !== zeroAddress)
250
+ accounts.add(event.to);
251
+ }
252
+ for (const event of events.minted) {
253
+ if (event.account) {
254
+ accounts.add(event.account);
255
+ }
256
+ }
257
+ for (const event of events.burned) {
258
+ if (event.account) {
259
+ accounts.add(event.account);
260
+ }
261
+ }
262
+ logInfo(`Found ${accounts.size} unique accounts in range`);
263
+ return accounts;
264
+ };
265
+ /**
266
+ * Calculate account balances from indexed events
267
+ */
268
+ export const calculateBalancesFromEvents = async ({ poolAddress, fromBlock, toBlock, batchSize, }) => {
269
+ const publicClient = await getPublicClient();
270
+ const balances = new Map();
271
+ const from = fromBlock ? BigInt(fromBlock) : undefined;
272
+ const to = toBlock ? BigInt(toBlock) : await publicClient.getBlockNumber();
273
+ // Calculate block range
274
+ const startBlock = from || (to - 50000n > 0n ? to - 50000n : 0n);
275
+ logInfo(`Calculating balances from events in blocks ${startBlock} to ${to}...`);
276
+ // Use the same indexing approach as indexAccountsFromEvents (with cache)
277
+ const events = await getIndexedEventsFromCache({
278
+ poolAddress,
279
+ startBlock,
280
+ endBlock: to,
281
+ fetchEventsForBlocks: (blocks) => fetchEventsForBlocks({ blocks, poolAddress, batchSize }),
282
+ });
283
+ logInfo(`Found ${events.transfer.length} Transfer, ${events.minted.length} Minted, ${events.burned.length} Burned events`);
284
+ // Helper to get or create balance entry
285
+ const getBalance = (address) => {
286
+ let balance = balances.get(address);
287
+ if (!balance) {
288
+ balance = { stvBalance: 0n, debtShares: 0n };
289
+ balances.set(address, balance);
290
+ }
291
+ return balance;
292
+ };
293
+ // Process Transfer events (STV balance changes)
294
+ for (const event of events.transfer) {
295
+ if (!event.from || !event.to || !event.value) {
296
+ logInfo(`Skipping invalid Transfer event: ${JSON.stringify(event)}`);
297
+ continue;
298
+ }
299
+ const from = event.from;
300
+ const to = event.to;
301
+ const value = BigInt(event.value);
302
+ // Minting (from zero address)
303
+ if (from === zeroAddress) {
304
+ const balance = getBalance(to);
305
+ balance.stvBalance += value;
306
+ }
307
+ // Burning (to zero address)
308
+ else if (to === zeroAddress) {
309
+ const balance = getBalance(from);
310
+ balance.stvBalance -= value;
311
+ if (balance.stvBalance < 0n) {
312
+ logInfo(`Warning: Negative STV balance for ${from}: ${balance.stvBalance}`);
313
+ }
314
+ }
315
+ // Transfer between accounts
316
+ else {
317
+ const fromBalance = getBalance(from);
318
+ const toBalance = getBalance(to);
319
+ fromBalance.stvBalance -= value;
320
+ toBalance.stvBalance += value;
321
+ if (fromBalance.stvBalance < 0n) {
322
+ logInfo(`Warning: Negative STV balance for ${from}: ${fromBalance.stvBalance}`);
323
+ }
324
+ }
325
+ }
326
+ // Process StethSharesMinted events (debt increases)
327
+ for (const event of events.minted) {
328
+ if (!event.account || !event.stethShares) {
329
+ logInfo(`Skipping invalid Minted event: ${JSON.stringify(event)}`);
330
+ continue;
331
+ }
332
+ const account = event.account;
333
+ const stethShares = BigInt(event.stethShares);
334
+ const balance = getBalance(account);
335
+ balance.debtShares += stethShares;
336
+ }
337
+ // Process StethSharesBurned events (debt decreases)
338
+ for (const event of events.burned) {
339
+ if (!event.account || !event.stethShares) {
340
+ logInfo(`Skipping invalid Burned event: ${JSON.stringify(event)}`);
341
+ continue;
342
+ }
343
+ const account = event.account;
344
+ const stethShares = BigInt(event.stethShares);
345
+ const balance = getBalance(account);
346
+ balance.debtShares -= stethShares;
347
+ if (balance.debtShares < 0n) {
348
+ logInfo(`Warning: Negative debt shares for ${account}: ${balance.debtShares}`);
349
+ }
350
+ }
351
+ logInfo(`Calculated balances for ${balances.size} accounts`);
352
+ return balances;
353
+ };
354
+ const TIME_LOCKER_ACCOUNT = '0x5513fd2E0770eA3f670944d2B36a1F0a10689B2d';
355
+ export const grantLossSocializerRole = async (address, currentAccount) => {
356
+ const poolContract = await getStvStethPoolContract(address);
357
+ const LOSS_SOCIALIZER_ROLE = await callReadMethodSilent(poolContract, 'LOSS_SOCIALIZER_ROLE');
358
+ const roleMembers = await callReadMethodSilent(poolContract, 'getRoleMembers', [LOSS_SOCIALIZER_ROLE]);
359
+ if (!roleMembers.includes(currentAccount)) {
360
+ logInfo(`Address ${currentAccount} does not have the LOSS_SOCIALIZER_ROLE role`);
361
+ const confirm = await confirmOperation(`Do you want set LOSS_SOCIALIZER_ROLE role for ${currentAccount}? Works only on Forked network like Anvil`);
362
+ if (!confirm) {
363
+ logCancel('Operation cancelled.');
364
+ return;
365
+ }
366
+ }
367
+ await grantRoleFromImpersonatedAccount({
368
+ currentAccount,
369
+ contract: poolContract,
370
+ impersonateAccount: TIME_LOCKER_ACCOUNT,
371
+ role: LOSS_SOCIALIZER_ROLE,
372
+ roleName: 'LOSS_SOCIALIZER_ROLE',
373
+ });
374
+ };
375
+ export const setMaxLossSocializationBP = async (address) => {
376
+ const poolContract = await getStvStethPoolContract(address);
377
+ const confirm = await confirmOperation(`Do you want set maxLossSocializationBP to 10000? Works only on Forked network like Anvil`);
378
+ if (!confirm) {
379
+ logCancel('Operation cancelled.');
380
+ return;
381
+ }
382
+ await callMethodFromImpersonatedAccount({
383
+ contract: poolContract,
384
+ impersonateAccount: TIME_LOCKER_ACCOUNT,
385
+ functionName: 'setMaxLossSocializationBP',
386
+ args: [10000],
387
+ });
388
+ };
389
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../programs/defi-wrapper/use-cases/health/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,WAAW,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC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C,MAAM,yBAAyB,GAAG,KAAK,EAAE,OAAgB,EAAE,EAAE;IAClE,MAAM,YAAY,GAAG,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,MAAM,gBAAgB,CACpC,0FAA0F,CAC3F,CAAC;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,SAAS,CAAC,sBAAsB,CAAC,CAAC;QAClC,OAAO;IACT,CAAC;IAED,MAAM,iCAAiC,CAAC;QACtC,QAAQ,EAAE,YAAY;QACtB,kBAAkB,EAAE,mBAAmB;QACvC,YAAY,EAAE,2BAA2B;QACzC,IAAI,EAAE,CAAC,KAAK,CAAC;KACd,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,254 @@
1
+ import { formatEther, formatUnits } from 'viem';
2
+ import { health } from './main.js';
3
+ import { getStvStethPoolContract } from '../../../../contracts/defi-wrapper/index.js';
4
+ import { getStethContract } from '../../../../contracts/index.js';
5
+ import { stringToAddress, logInfo, logTable, callReadMethodSilent, callWriteMethodWithReceipt, confirmOperation, } from '../../../../utils/index.js';
6
+ import { getAccount } from '../../../../providers/wallet.js';
7
+ import { grantLossSocializerRole, setMaxLossSocializationBP } from './utils.js';
8
+ const healthWrite = health
9
+ .command('write')
10
+ .aliases(['w'])
11
+ .description('health write commands');
12
+ healthWrite
13
+ .command('force-rebalance')
14
+ .description('force rebalance an unhealthy position')
15
+ .argument('<address>', 'stv-steth-pool address', stringToAddress)
16
+ .argument('<account>', 'account address to rebalance', stringToAddress)
17
+ .option('--dry-run', 'preview without executing transaction')
18
+ .action(async (address, account, options) => {
19
+ const poolContract = await getStvStethPoolContract(address);
20
+ const stethContract = await getStethContract();
21
+ logInfo('Checking position health...\n');
22
+ // Check if position is unhealthy
23
+ const [isHealthy, stvBalance] = await Promise.all([
24
+ callReadMethodSilent(poolContract, 'isHealthyOf', [account]),
25
+ callReadMethodSilent(poolContract, 'balanceOf', [account]),
26
+ ]);
27
+ if (isHealthy) {
28
+ logInfo(`✅ Account ${account} position is healthy. No rebalance needed.`);
29
+ return;
30
+ }
31
+ if (stvBalance === 0n) {
32
+ logInfo(`⚠️ Account ${account} has no STV balance. Cannot rebalance.`);
33
+ return;
34
+ }
35
+ // Preview rebalance
36
+ logInfo('Fetching rebalance preview...\n');
37
+ const [stethShares, stvToBurn, isUndercollateralized] = await callReadMethodSilent(poolContract, 'previewForceRebalance', [
38
+ account,
39
+ ]);
40
+ const stethInEth = await callReadMethodSilent(stethContract, 'getPooledEthBySharesRoundUp', [stethShares]);
41
+ // Display preview
42
+ logInfo('═'.repeat(70));
43
+ logInfo('FORCE REBALANCE PREVIEW');
44
+ logInfo('═'.repeat(70) + '\n');
45
+ logTable({
46
+ data: [
47
+ ['Pool', address],
48
+ ['Account', account],
49
+ ['', ''],
50
+ ['STV to be Burned', `${formatUnits(stvToBurn, 27)} STV`],
51
+ ['stETH Shares to Unlock', `${formatEther(stethShares)} shares`],
52
+ ['stETH Value', `~${formatEther(stethInEth)} ETH`],
53
+ ['', ''],
54
+ [
55
+ 'Is Undercollateralized',
56
+ isUndercollateralized ? '⚠️ YES - Cannot proceed!' : '✅ NO',
57
+ ],
58
+ [
59
+ 'Transaction Status',
60
+ isUndercollateralized ? '❌ WILL REVERT' : '✅ Should succeed',
61
+ ],
62
+ ],
63
+ });
64
+ if (isUndercollateralized) {
65
+ logInfo('\n' + '⚠️ '.repeat(35));
66
+ logInfo('⚠️ ERROR: Account is undercollateralized! Regular force rebalance will revert.');
67
+ logInfo('⚠️ Use force-rebalance-and-socialize-loss instead (requires LOSS_SOCIALIZER_ROLE)');
68
+ logInfo('⚠️ '.repeat(35) + '\n');
69
+ return;
70
+ }
71
+ if (options.dryRun) {
72
+ logInfo('\n🔍 Dry run mode - no transaction will be executed.\n');
73
+ return;
74
+ }
75
+ // Warning message
76
+ logInfo('\n' + '⚠️ '.repeat(35));
77
+ logInfo('⚠️ WARNING: This action will permanently burn user STV tokens!');
78
+ logInfo('⚠️ Make sure you have the authority to perform this operation.');
79
+ logInfo('⚠️ '.repeat(35) + '\n');
80
+ const confirm = await confirmOperation(`Execute force rebalance for account ${account}?\nThis will burn ${formatUnits(stvToBurn, 27)} STV tokens.`);
81
+ if (!confirm) {
82
+ logInfo('Operation cancelled.');
83
+ return;
84
+ }
85
+ // Execute rebalance
86
+ logInfo('\nExecuting force rebalance...\n');
87
+ try {
88
+ const result = await callWriteMethodWithReceipt({
89
+ contract: poolContract,
90
+ methodName: 'forceRebalance',
91
+ payload: [account],
92
+ });
93
+ logInfo('✅ Force rebalance executed successfully!\n');
94
+ logTable({
95
+ data: [
96
+ ['Transaction Hash', result.receipt?.transactionHash || 'N/A'],
97
+ ['Block Number', result.receipt?.blockNumber?.toString() || 'N/A'],
98
+ ['Gas Used', result.receipt?.gasUsed?.toString() || 'N/A'],
99
+ ],
100
+ });
101
+ }
102
+ catch (error) {
103
+ logInfo(`❌ Force rebalance failed: ${error}\n`);
104
+ throw error;
105
+ }
106
+ });
107
+ healthWrite
108
+ .command('force-rebalance-and-socialize-loss')
109
+ .description('force rebalance an undercollateralized position with loss socialization (requires LOSS_SOCIALIZER_ROLE)')
110
+ .argument('<address>', 'stv-steth-pool address', stringToAddress)
111
+ .argument('<account>', 'account address to rebalance', stringToAddress)
112
+ .option('--dry-run', 'preview without executing transaction')
113
+ .action(async (address, account, options) => {
114
+ const poolContract = await getStvStethPoolContract(address);
115
+ const stethContract = await getStethContract();
116
+ const currentAccount = await getAccount();
117
+ await grantLossSocializerRole(address, currentAccount.address);
118
+ await setMaxLossSocializationBP(address);
119
+ logInfo('Checking position health and permissions...\n');
120
+ // Check LOSS_SOCIALIZER_ROLE
121
+ const LOSS_SOCIALIZER_ROLE = await callReadMethodSilent(poolContract, 'LOSS_SOCIALIZER_ROLE');
122
+ const hasRole = await callReadMethodSilent(poolContract, 'hasRole', [
123
+ LOSS_SOCIALIZER_ROLE,
124
+ currentAccount.address,
125
+ ]);
126
+ if (!hasRole) {
127
+ logInfo(`❌ Error: Your account ${currentAccount.address} does not have LOSS_SOCIALIZER_ROLE`);
128
+ logInfo(`Required role: ${LOSS_SOCIALIZER_ROLE}\n`);
129
+ return;
130
+ }
131
+ // Check if position is unhealthy
132
+ const [isHealthy, stvBalance] = await Promise.all([
133
+ callReadMethodSilent(poolContract, 'isHealthyOf', [account]),
134
+ callReadMethodSilent(poolContract, 'balanceOf', [account]),
135
+ ]);
136
+ if (isHealthy) {
137
+ logInfo(`✅ Account ${account} position is healthy. No rebalance needed.`);
138
+ return;
139
+ }
140
+ if (stvBalance === 0n) {
141
+ logInfo(`⚠️ Account ${account} has no STV balance. Cannot rebalance.`);
142
+ return;
143
+ }
144
+ // Preview rebalance
145
+ logInfo('Fetching rebalance preview...\n');
146
+ const [stethShares, stvToBurn, isUndercollateralized] = await callReadMethodSilent(poolContract, 'previewForceRebalance', [
147
+ account,
148
+ ]);
149
+ const [stethInEth, maxLossSocializationBP, totalSupply] = await Promise.all([
150
+ callReadMethodSilent(stethContract, 'getPooledEthBySharesRoundUp', [
151
+ stethShares,
152
+ ]),
153
+ callReadMethodSilent(poolContract, 'maxLossSocializationBP'),
154
+ callReadMethodSilent(poolContract, 'totalSupply'),
155
+ ]);
156
+ // Calculate estimated loss
157
+ const stvValueInEth = await callReadMethodSilent(poolContract, 'previewRedeem', [stvToBurn]);
158
+ const estimatedLoss = stethInEth > stvValueInEth ? stethInEth - stvValueInEth : 0n;
159
+ const lossPercentage = totalSupply > 0n ? Number((estimatedLoss * 10000n) / totalSupply) : 0;
160
+ // Display preview
161
+ logInfo('═'.repeat(70));
162
+ logInfo('FORCE REBALANCE WITH LOSS SOCIALIZATION PREVIEW');
163
+ logInfo('═'.repeat(70) + '\n');
164
+ if (!isUndercollateralized) {
165
+ logInfo('⚠️ NOTE: Account is NOT undercollateralized.');
166
+ logInfo('⚠️ Consider using regular force-rebalance instead to avoid loss socialization.\n');
167
+ }
168
+ logTable({
169
+ data: [
170
+ ['Pool', address],
171
+ ['Account', account],
172
+ ['Operator', currentAccount.address],
173
+ ['', ''],
174
+ ['STV to be Burned', `${formatUnits(stvToBurn, 27)} STV`],
175
+ ['STV Value (ETH)', `${formatEther(stvValueInEth)} ETH`],
176
+ ['stETH Shares to Unlock', `${formatEther(stethShares)} shares`],
177
+ ['stETH Value (ETH)', `${formatEther(stethInEth)} ETH`],
178
+ ['', ''],
179
+ [
180
+ 'Is Undercollateralized',
181
+ isUndercollateralized ? '⚠️ YES' : '✅ NO',
182
+ ],
183
+ ['Estimated Loss', `~${formatEther(estimatedLoss)} ETH`],
184
+ ['Loss % of Total Supply', `${(lossPercentage / 100).toFixed(4)}%`],
185
+ ['', ''],
186
+ [
187
+ 'Max Loss Socialization BP',
188
+ `${maxLossSocializationBP} (${(Number(maxLossSocializationBP) / 100).toFixed(2)}%)`,
189
+ ],
190
+ [
191
+ 'Loss Within Limits',
192
+ lossPercentage <= Number(maxLossSocializationBP)
193
+ ? '✅ YES'
194
+ : '❌ NO',
195
+ ],
196
+ ],
197
+ });
198
+ if (lossPercentage > Number(maxLossSocializationBP)) {
199
+ logInfo('\n❌ ERROR: Estimated loss exceeds maxLossSocializationBP!');
200
+ logInfo('Transaction will revert.\n');
201
+ return;
202
+ }
203
+ if (options.dryRun) {
204
+ logInfo('\n🔍 Dry run mode - no transaction will be executed.\n');
205
+ return;
206
+ }
207
+ // Critical warning message
208
+ logInfo('\n' + '🚨 '.repeat(35));
209
+ logInfo('🚨 CRITICAL WARNING:');
210
+ logInfo('🚨 This action will:');
211
+ logInfo('🚨 1. Permanently burn user STV tokens');
212
+ logInfo('🚨 2. Socialize losses across ALL pool participants');
213
+ logInfo('🚨 3. Reduce the share rate for ALL users');
214
+ logInfo('🚨 4. Cannot be undone');
215
+ logInfo('🚨 '.repeat(35) + '\n');
216
+ const confirm = await confirmOperation(`Execute force rebalance with loss socialization for account ${account}?\n` +
217
+ `This will burn ${formatEther(stvToBurn)} STV and socialize ~${formatEther(estimatedLoss)} ETH loss.\n` +
218
+ `Type 'yes' to confirm:`);
219
+ if (!confirm) {
220
+ logInfo('Operation cancelled.');
221
+ return;
222
+ }
223
+ // Double confirmation
224
+ const doubleConfirm = await confirmOperation('Are you ABSOLUTELY sure? This is your last chance to cancel. Type "CONFIRM" to proceed:');
225
+ if (!doubleConfirm) {
226
+ logInfo('Operation cancelled.');
227
+ return;
228
+ }
229
+ // Execute rebalance with loss socialization
230
+ logInfo('\nExecuting force rebalance with loss socialization...\n');
231
+ try {
232
+ const result = await callWriteMethodWithReceipt({
233
+ contract: poolContract,
234
+ methodName: 'forceRebalanceAndSocializeLoss',
235
+ payload: [account],
236
+ });
237
+ logInfo('✅ Force rebalance with loss socialization executed successfully!\n');
238
+ logTable({
239
+ data: [
240
+ ['Transaction Hash', result.receipt?.transactionHash || 'N/A'],
241
+ ['Block Number', result.receipt?.blockNumber?.toString() || 'N/A'],
242
+ ['Gas Used', result.receipt?.gasUsed?.toString() || 'N/A'],
243
+ ['', ''],
244
+ ['⚠️ Loss Socialized', `~${formatEther(estimatedLoss)} ETH`],
245
+ ['⚠️ All pool users affected', 'Share rate reduced'],
246
+ ],
247
+ });
248
+ }
249
+ catch (error) {
250
+ logInfo(`❌ Force rebalance with loss socialization failed: ${error}\n`);
251
+ throw error;
252
+ }
253
+ });
254
+ //# sourceMappingURL=write.js.map