@symmio/trading-core 2.0.0 → 3.0.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 (325) hide show
  1. package/README.md +2 -2
  2. package/dist/balance-history/get-balance-history/types.d.ts +1 -1
  3. package/dist/balance-history/get-balance-history/types.js.map +1 -1
  4. package/dist/core/chains/actions/get-chain-config.d.ts +1 -1
  5. package/dist/core/chains/actions/get-chain-config.js.map +1 -1
  6. package/dist/core/chains/actions/get-default-solver.d.ts +1 -1
  7. package/dist/core/chains/actions/get-default-solver.js.map +1 -1
  8. package/dist/core/chains/actions/list-supported-chains.js.map +1 -1
  9. package/dist/core/chains/registry.d.ts.map +1 -1
  10. package/dist/core/chains/registry.js +52 -50
  11. package/dist/core/chains/registry.js.map +1 -1
  12. package/dist/core/chains/supported-chains.d.ts +3 -3
  13. package/dist/core/chains/supported-chains.d.ts.map +1 -1
  14. package/dist/core/chains/supported-chains.js +1 -1
  15. package/dist/core/chains/supported-chains.js.map +1 -1
  16. package/dist/core/chains/types.d.ts +18 -4
  17. package/dist/core/chains/types.d.ts.map +1 -1
  18. package/dist/core/chains/types.js.map +1 -1
  19. package/dist/core/config/create-config.d.ts +7 -7
  20. package/dist/core/config/create-config.d.ts.map +1 -1
  21. package/dist/core/config/create-config.js +39 -38
  22. package/dist/core/config/create-config.js.map +1 -1
  23. package/dist/core/config/merge-chain-config.js +1 -0
  24. package/dist/core/config/merge-chain-config.js.map +1 -1
  25. package/dist/index.d.ts +18 -9
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +318 -316
  28. package/dist/margin/calculate-margin-risk.d.ts +1 -1
  29. package/dist/margin/calculate-margin-risk.js.map +1 -1
  30. package/dist/notifications/types.d.ts +1 -1
  31. package/dist/notifications/types.d.ts.map +1 -1
  32. package/dist/quotes/close-planning/min-remaining-quantity.d.ts +1 -1
  33. package/dist/quotes/close-planning/min-remaining-quantity.js.map +1 -1
  34. package/dist/quotes/get-quote-history/query-document.d.ts +1 -1
  35. package/dist/quotes/get-quote-history/query-document.js.map +1 -1
  36. package/dist/quotes/get-quote-history/types.d.ts +2 -2
  37. package/dist/quotes/get-quote-history/types.js.map +1 -1
  38. package/dist/quotes/grouping/aggregate-metrics.d.ts +1 -1
  39. package/dist/quotes/grouping/aggregate-metrics.js.map +1 -1
  40. package/dist/quotes/open-price.d.ts +10 -10
  41. package/dist/quotes/open-price.d.ts.map +1 -1
  42. package/dist/quotes/open-price.js +1 -1
  43. package/dist/quotes/open-price.js.map +1 -1
  44. package/dist/quotes/upnl/calculate-quote-leverage.d.ts +8 -6
  45. package/dist/quotes/upnl/calculate-quote-leverage.d.ts.map +1 -1
  46. package/dist/quotes/upnl/calculate-quote-leverage.js.map +1 -1
  47. package/dist/shared/utils/query.d.ts +2 -2
  48. package/dist/shared/utils/query.js.map +1 -1
  49. package/dist/solvers/force-close/force-close-position.js +1 -1
  50. package/dist/solvers/force-close/force-close-position.js.map +1 -1
  51. package/dist/solvers/force-close/get-force-close-params.js +1 -1
  52. package/dist/solvers/force-close/get-force-close-params.js.map +1 -1
  53. package/dist/solvers/instant-close/shared/calldata.js +1 -1
  54. package/dist/solvers/instant-close/shared/calldata.js.map +1 -1
  55. package/dist/solvers/instant-open/get-instant-open-fees/get-instant-open-fees.d.ts +129 -0
  56. package/dist/solvers/instant-open/get-instant-open-fees/get-instant-open-fees.d.ts.map +1 -0
  57. package/dist/solvers/instant-open/get-instant-open-fees/get-instant-open-fees.js +115 -0
  58. package/dist/solvers/instant-open/get-instant-open-fees/get-instant-open-fees.js.map +1 -0
  59. package/dist/solvers/instant-open/get-instant-open-fees/index.d.ts +3 -0
  60. package/dist/solvers/instant-open/get-instant-open-fees/index.d.ts.map +1 -0
  61. package/dist/solvers/instant-open/get-instant-open-fees/query.d.ts +34 -0
  62. package/dist/solvers/instant-open/get-instant-open-fees/query.d.ts.map +1 -0
  63. package/dist/solvers/instant-open/get-instant-open-fees/query.js +33 -0
  64. package/dist/solvers/instant-open/get-instant-open-fees/query.js.map +1 -0
  65. package/dist/solvers/instant-open/index.d.ts +1 -0
  66. package/dist/solvers/instant-open/index.d.ts.map +1 -1
  67. package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.d.ts.map +1 -1
  68. package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.js +58 -55
  69. package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.js.map +1 -1
  70. package/dist/solvers/instant-open/instant-open/types.d.ts +14 -4
  71. package/dist/solvers/instant-open/instant-open/types.d.ts.map +1 -1
  72. package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.d.ts +45 -10
  73. package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.d.ts.map +1 -1
  74. package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.js +157 -72
  75. package/dist/solvers/instant-open/prepare-instant-open-params/prepare-instant-open-params.js.map +1 -1
  76. package/dist/solvers/instant-open/shared/calldata.d.ts +35 -7
  77. package/dist/solvers/instant-open/shared/calldata.d.ts.map +1 -1
  78. package/dist/solvers/instant-open/shared/calldata.js +56 -14
  79. package/dist/solvers/instant-open/shared/calldata.js.map +1 -1
  80. package/dist/solvers/instant-open/shared/index.d.ts +1 -0
  81. package/dist/solvers/instant-open/shared/index.d.ts.map +1 -1
  82. package/dist/solvers/instant-open/shared/open-estimate-guard.d.ts +89 -0
  83. package/dist/solvers/instant-open/shared/open-estimate-guard.d.ts.map +1 -0
  84. package/dist/solvers/instant-open/shared/open-estimate-guard.js +52 -0
  85. package/dist/solvers/instant-open/shared/open-estimate-guard.js.map +1 -0
  86. package/dist/solvers/instant-open/shared/selectors.d.ts +46 -7
  87. package/dist/solvers/instant-open/shared/selectors.d.ts.map +1 -1
  88. package/dist/solvers/instant-open/shared/selectors.js +12 -5
  89. package/dist/solvers/instant-open/shared/selectors.js.map +1 -1
  90. package/dist/solvers/instant-open/shared/trade-math.d.ts +112 -8
  91. package/dist/solvers/instant-open/shared/trade-math.d.ts.map +1 -1
  92. package/dist/solvers/instant-open/shared/trade-math.js +59 -25
  93. package/dist/solvers/instant-open/shared/trade-math.js.map +1 -1
  94. package/dist/solvers/instant-open/shared/types.d.ts +32 -0
  95. package/dist/solvers/instant-open/shared/types.d.ts.map +1 -1
  96. package/dist/solvers/instant-open/shared/types.js.map +1 -1
  97. package/dist/solvers/markets/adapters/enigma-markets.d.ts.map +1 -1
  98. package/dist/solvers/markets/adapters/enigma-markets.js +38 -32
  99. package/dist/solvers/markets/adapters/enigma-markets.js.map +1 -1
  100. package/dist/solvers/markets/types.d.ts +15 -0
  101. package/dist/solvers/markets/types.d.ts.map +1 -1
  102. package/dist/solvers/revenue/get-solver-revenue.d.ts +11 -11
  103. package/dist/solvers/revenue/get-solver-revenue.d.ts.map +1 -1
  104. package/dist/solvers/revenue/get-solver-revenue.js +12 -12
  105. package/dist/solvers/revenue/get-solver-revenue.js.map +1 -1
  106. package/dist/solvers/revenue/query.d.ts +2 -2
  107. package/dist/solvers/revenue/query.d.ts.map +1 -1
  108. package/dist/solvers/revenue/query.js +1 -1
  109. package/dist/solvers/revenue/query.js.map +1 -1
  110. package/dist/solvers/revenue/to-solver-revenue.d.ts +3 -2
  111. package/dist/solvers/revenue/to-solver-revenue.d.ts.map +1 -1
  112. package/dist/solvers/revenue/to-solver-revenue.js.map +1 -1
  113. package/dist/solvers/shared/index.d.ts +1 -0
  114. package/dist/solvers/shared/index.d.ts.map +1 -1
  115. package/dist/solvers/shared/resolvers/resolve-market.d.ts +36 -5
  116. package/dist/solvers/shared/resolvers/resolve-market.d.ts.map +1 -1
  117. package/dist/solvers/shared/resolvers/resolve-market.js +30 -8
  118. package/dist/solvers/shared/resolvers/resolve-market.js.map +1 -1
  119. package/dist/solvers/shared/resolvers/types.d.ts +14 -0
  120. package/dist/solvers/shared/resolvers/types.d.ts.map +1 -1
  121. package/dist/solvers/shared/solver-close-fee.d.ts +76 -0
  122. package/dist/solvers/shared/solver-close-fee.d.ts.map +1 -0
  123. package/dist/solvers/shared/solver-close-fee.js +26 -0
  124. package/dist/solvers/shared/solver-close-fee.js.map +1 -0
  125. package/dist/solvers/symbols/to-solver-symbol.d.ts.map +1 -1
  126. package/dist/solvers/symbols/to-solver-symbol.js +36 -30
  127. package/dist/solvers/symbols/to-solver-symbol.js.map +1 -1
  128. package/dist/solvers/symbols/types.d.ts +22 -1
  129. package/dist/solvers/symbols/types.d.ts.map +1 -1
  130. package/dist/solvers/types/generated/enigma-solver.d.ts +8 -99
  131. package/dist/solvers/types/generated/enigma-solver.d.ts.map +1 -1
  132. package/dist/solvers/types/generated/enigma-solver.js +5 -11
  133. package/dist/solvers/types/generated/enigma-solver.js.map +1 -1
  134. package/dist/solvers/types/generated/rasa-solver.js +2 -2
  135. package/dist/solvers/types/generated/rasa-solver.js.map +1 -1
  136. package/dist/symmio-contracts/abi/index.d.ts +4 -4
  137. package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/account-layer.d.ts +499 -132
  138. package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/account-layer.d.ts.map +1 -1
  139. package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/account-layer.js +591 -149
  140. package/dist/symmio-contracts/abi/v0.8.6/account-layer.js.map +1 -0
  141. package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/index.d.ts.map +1 -1
  142. package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/instant-layer.d.ts +24 -24
  143. package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/instant-layer.d.ts.map +1 -1
  144. package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/instant-layer.js +28 -28
  145. package/dist/symmio-contracts/abi/v0.8.6/instant-layer.js.map +1 -0
  146. package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/symmio.d.ts +4724 -1019
  147. package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/symmio.d.ts.map +1 -1
  148. package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/symmio.js +12750 -8308
  149. package/dist/symmio-contracts/abi/v0.8.6/symmio.js.map +1 -0
  150. package/dist/symmio-contracts/account-layer/actions/add-margin.js +1 -1
  151. package/dist/symmio-contracts/account-layer/actions/add-margin.js.map +1 -1
  152. package/dist/symmio-contracts/account-layer/actions/cancel-registration.js +1 -1
  153. package/dist/symmio-contracts/account-layer/actions/cancel-registration.js.map +1 -1
  154. package/dist/symmio-contracts/account-layer/actions/create-sub-accounts.js +1 -1
  155. package/dist/symmio-contracts/account-layer/actions/create-sub-accounts.js.map +1 -1
  156. package/dist/symmio-contracts/account-layer/actions/delete-sub-account.js +1 -1
  157. package/dist/symmio-contracts/account-layer/actions/delete-sub-account.js.map +1 -1
  158. package/dist/symmio-contracts/account-layer/actions/deposit-and-allocate-for-account.js +1 -1
  159. package/dist/symmio-contracts/account-layer/actions/deposit-and-allocate-for-account.js.map +1 -1
  160. package/dist/symmio-contracts/account-layer/actions/deposit-for-account.js +1 -1
  161. package/dist/symmio-contracts/account-layer/actions/deposit-for-account.js.map +1 -1
  162. package/dist/symmio-contracts/account-layer/actions/edit-account-name.js +1 -1
  163. package/dist/symmio-contracts/account-layer/actions/edit-account-name.js.map +1 -1
  164. package/dist/symmio-contracts/account-layer/actions/generate-account-manager-address.js +1 -1
  165. package/dist/symmio-contracts/account-layer/actions/generate-account-manager-address.js.map +1 -1
  166. package/dist/symmio-contracts/account-layer/actions/get-account-balance-info.js +1 -1
  167. package/dist/symmio-contracts/account-layer/actions/get-account-balance-info.js.map +1 -1
  168. package/dist/symmio-contracts/account-layer/actions/get-account-balance-of.js +1 -1
  169. package/dist/symmio-contracts/account-layer/actions/get-account-balance-of.js.map +1 -1
  170. package/dist/symmio-contracts/account-layer/actions/get-affiliate-state.js +1 -1
  171. package/dist/symmio-contracts/account-layer/actions/get-affiliate-state.js.map +1 -1
  172. package/dist/symmio-contracts/account-layer/actions/get-sub-account-virtual-nonce.js +1 -1
  173. package/dist/symmio-contracts/account-layer/actions/get-sub-account-virtual-nonce.js.map +1 -1
  174. package/dist/symmio-contracts/account-layer/actions/get-sub-account.js +1 -1
  175. package/dist/symmio-contracts/account-layer/actions/get-sub-account.js.map +1 -1
  176. package/dist/symmio-contracts/account-layer/actions/get-sub-accounts-count-of-user.js +1 -1
  177. package/dist/symmio-contracts/account-layer/actions/get-sub-accounts-count-of-user.js.map +1 -1
  178. package/dist/symmio-contracts/account-layer/actions/get-user-sub-accounts-addresses.js +1 -1
  179. package/dist/symmio-contracts/account-layer/actions/get-user-sub-accounts-addresses.js.map +1 -1
  180. package/dist/symmio-contracts/account-layer/actions/get-user-sub-accounts.js +1 -1
  181. package/dist/symmio-contracts/account-layer/actions/get-user-sub-accounts.js.map +1 -1
  182. package/dist/symmio-contracts/account-layer/actions/get-virtual-account.d.ts +1 -1
  183. package/dist/symmio-contracts/account-layer/actions/get-virtual-account.js +1 -1
  184. package/dist/symmio-contracts/account-layer/actions/get-virtual-account.js.map +1 -1
  185. package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-addresses-of-sub-account.js +1 -1
  186. package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-addresses-of-sub-account.js.map +1 -1
  187. package/dist/symmio-contracts/account-layer/actions/predict-next-virtual-account.js +1 -1
  188. package/dist/symmio-contracts/account-layer/actions/predict-next-virtual-account.js.map +1 -1
  189. package/dist/symmio-contracts/account-layer/actions/remove-margin.js +1 -1
  190. package/dist/symmio-contracts/account-layer/actions/remove-margin.js.map +1 -1
  191. package/dist/symmio-contracts/account-layer/actions/request-to-register-affiliate.js +1 -1
  192. package/dist/symmio-contracts/account-layer/actions/request-to-register-affiliate.js.map +1 -1
  193. package/dist/symmio-contracts/account-layer/actions/simulate-add-margin.d.ts +1 -1
  194. package/dist/symmio-contracts/account-layer/actions/simulate-add-margin.js +1 -1
  195. package/dist/symmio-contracts/account-layer/actions/simulate-add-margin.js.map +1 -1
  196. package/dist/symmio-contracts/account-layer/actions/simulate-cancel-registration.d.ts +1 -1
  197. package/dist/symmio-contracts/account-layer/actions/simulate-cancel-registration.js +1 -1
  198. package/dist/symmio-contracts/account-layer/actions/simulate-cancel-registration.js.map +1 -1
  199. package/dist/symmio-contracts/account-layer/actions/simulate-create-sub-accounts.d.ts +1 -1
  200. package/dist/symmio-contracts/account-layer/actions/simulate-create-sub-accounts.js +1 -1
  201. package/dist/symmio-contracts/account-layer/actions/simulate-create-sub-accounts.js.map +1 -1
  202. package/dist/symmio-contracts/account-layer/actions/simulate-delete-sub-account.d.ts +1 -1
  203. package/dist/symmio-contracts/account-layer/actions/simulate-delete-sub-account.js +1 -1
  204. package/dist/symmio-contracts/account-layer/actions/simulate-delete-sub-account.js.map +1 -1
  205. package/dist/symmio-contracts/account-layer/actions/simulate-deposit-and-allocate-for-account.d.ts +1 -1
  206. package/dist/symmio-contracts/account-layer/actions/simulate-deposit-and-allocate-for-account.js +1 -1
  207. package/dist/symmio-contracts/account-layer/actions/simulate-deposit-and-allocate-for-account.js.map +1 -1
  208. package/dist/symmio-contracts/account-layer/actions/simulate-deposit-for-account.d.ts +1 -1
  209. package/dist/symmio-contracts/account-layer/actions/simulate-deposit-for-account.js +1 -1
  210. package/dist/symmio-contracts/account-layer/actions/simulate-deposit-for-account.js.map +1 -1
  211. package/dist/symmio-contracts/account-layer/actions/simulate-edit-account-name.d.ts +1 -1
  212. package/dist/symmio-contracts/account-layer/actions/simulate-edit-account-name.js +1 -1
  213. package/dist/symmio-contracts/account-layer/actions/simulate-edit-account-name.js.map +1 -1
  214. package/dist/symmio-contracts/account-layer/actions/simulate-remove-margin.d.ts +1 -1
  215. package/dist/symmio-contracts/account-layer/actions/simulate-remove-margin.js +1 -1
  216. package/dist/symmio-contracts/account-layer/actions/simulate-remove-margin.js.map +1 -1
  217. package/dist/symmio-contracts/account-layer/actions/simulate-request-to-register-affiliate.d.ts +1 -1
  218. package/dist/symmio-contracts/account-layer/actions/simulate-request-to-register-affiliate.js +1 -1
  219. package/dist/symmio-contracts/account-layer/actions/simulate-request-to-register-affiliate.js.map +1 -1
  220. package/dist/symmio-contracts/account-layer/types.d.ts +10 -10
  221. package/dist/symmio-contracts/account-layer/types.js.map +1 -1
  222. package/dist/symmio-contracts/instant-layer/actions/get-delegation-expiry.js +1 -1
  223. package/dist/symmio-contracts/instant-layer/actions/get-delegation-expiry.js.map +1 -1
  224. package/dist/symmio-contracts/instant-layer/actions/get-is-delegation-active.js +1 -1
  225. package/dist/symmio-contracts/instant-layer/actions/get-is-delegation-active.js.map +1 -1
  226. package/dist/symmio-contracts/instant-layer/actions/grant-delegation.js +1 -1
  227. package/dist/symmio-contracts/instant-layer/actions/grant-delegation.js.map +1 -1
  228. package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegation.d.ts +1 -1
  229. package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegation.js +1 -1
  230. package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegation.js.map +1 -1
  231. package/dist/symmio-contracts/symmio/actions/allocate.js +1 -1
  232. package/dist/symmio-contracts/symmio/actions/allocate.js.map +1 -1
  233. package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.d.ts +1 -1
  234. package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.js +1 -1
  235. package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.js.map +1 -1
  236. package/dist/symmio-contracts/symmio/actions/deallocate.js +1 -1
  237. package/dist/symmio-contracts/symmio/actions/deallocate.js.map +1 -1
  238. package/dist/symmio-contracts/symmio/actions/finalize-withdraw-request.js +1 -1
  239. package/dist/symmio-contracts/symmio/actions/finalize-withdraw-request.js.map +1 -1
  240. package/dist/symmio-contracts/symmio/actions/force-cancel-close-request.js +1 -1
  241. package/dist/symmio-contracts/symmio/actions/force-cancel-close-request.js.map +1 -1
  242. package/dist/symmio-contracts/symmio/actions/force-cancel-quote.js +1 -1
  243. package/dist/symmio-contracts/symmio/actions/force-cancel-quote.js.map +1 -1
  244. package/dist/symmio-contracts/symmio/actions/get-cool-downs-of-ma.js +1 -1
  245. package/dist/symmio-contracts/symmio/actions/get-cool-downs-of-ma.js.map +1 -1
  246. package/dist/symmio-contracts/symmio/actions/get-fee-for-user.js +1 -1
  247. package/dist/symmio-contracts/symmio/actions/get-fee-for-user.js.map +1 -1
  248. package/dist/symmio-contracts/symmio/actions/get-last-withdraw-request-id.js +1 -1
  249. package/dist/symmio-contracts/symmio/actions/get-last-withdraw-request-id.js.map +1 -1
  250. package/dist/symmio-contracts/symmio/actions/get-onchain-contract-markets.js +1 -1
  251. package/dist/symmio-contracts/symmio/actions/get-onchain-contract-markets.js.map +1 -1
  252. package/dist/symmio-contracts/symmio/actions/get-party-a-open-positions.js +1 -1
  253. package/dist/symmio-contracts/symmio/actions/get-party-a-open-positions.js.map +1 -1
  254. package/dist/symmio-contracts/symmio/actions/get-party-a-pending-quotes.js +1 -1
  255. package/dist/symmio-contracts/symmio/actions/get-party-a-pending-quotes.js.map +1 -1
  256. package/dist/symmio-contracts/symmio/actions/get-pending-quotes.js +1 -1
  257. package/dist/symmio-contracts/symmio/actions/get-pending-quotes.js.map +1 -1
  258. package/dist/symmio-contracts/symmio/actions/get-pending-withdraw-requests.d.ts.map +1 -1
  259. package/dist/symmio-contracts/symmio/actions/get-pending-withdraw-requests.js +10 -9
  260. package/dist/symmio-contracts/symmio/actions/get-pending-withdraw-requests.js.map +1 -1
  261. package/dist/symmio-contracts/symmio/actions/get-quote.js +1 -1
  262. package/dist/symmio-contracts/symmio/actions/get-quote.js.map +1 -1
  263. package/dist/symmio-contracts/symmio/actions/get-withdraw-requests.d.ts.map +1 -1
  264. package/dist/symmio-contracts/symmio/actions/get-withdraw-requests.js +9 -8
  265. package/dist/symmio-contracts/symmio/actions/get-withdraw-requests.js.map +1 -1
  266. package/dist/symmio-contracts/symmio/actions/get-withdrawable-time.js +1 -1
  267. package/dist/symmio-contracts/symmio/actions/get-withdrawable-time.js.map +1 -1
  268. package/dist/symmio-contracts/symmio/actions/initiate-withdraw.d.ts +1 -1
  269. package/dist/symmio-contracts/symmio/actions/initiate-withdraw.js +1 -1
  270. package/dist/symmio-contracts/symmio/actions/initiate-withdraw.js.map +1 -1
  271. package/dist/symmio-contracts/symmio/actions/request-cancel-withdraw.js +1 -1
  272. package/dist/symmio-contracts/symmio/actions/request-cancel-withdraw.js.map +1 -1
  273. package/dist/symmio-contracts/symmio/actions/request-to-cancel-close-request.js +1 -1
  274. package/dist/symmio-contracts/symmio/actions/request-to-cancel-close-request.js.map +1 -1
  275. package/dist/symmio-contracts/symmio/actions/request-to-cancel-quote.js +1 -1
  276. package/dist/symmio-contracts/symmio/actions/request-to-cancel-quote.js.map +1 -1
  277. package/dist/symmio-contracts/symmio/actions/simulate-allocate.js +1 -1
  278. package/dist/symmio-contracts/symmio/actions/simulate-allocate.js.map +1 -1
  279. package/dist/symmio-contracts/symmio/actions/simulate-deallocate-and-initiate-withdraw.js +1 -1
  280. package/dist/symmio-contracts/symmio/actions/simulate-deallocate-and-initiate-withdraw.js.map +1 -1
  281. package/dist/symmio-contracts/symmio/actions/simulate-deallocate.js +1 -1
  282. package/dist/symmio-contracts/symmio/actions/simulate-deallocate.js.map +1 -1
  283. package/dist/symmio-contracts/symmio/actions/simulate-finalize-withdraw-request.d.ts +1 -1
  284. package/dist/symmio-contracts/symmio/actions/simulate-finalize-withdraw-request.js +1 -1
  285. package/dist/symmio-contracts/symmio/actions/simulate-finalize-withdraw-request.js.map +1 -1
  286. package/dist/symmio-contracts/symmio/actions/simulate-initiate-withdraw.js +1 -1
  287. package/dist/symmio-contracts/symmio/actions/simulate-initiate-withdraw.js.map +1 -1
  288. package/dist/symmio-contracts/symmio/actions/simulate-request-cancel-withdraw.js +1 -1
  289. package/dist/symmio-contracts/symmio/actions/simulate-request-cancel-withdraw.js.map +1 -1
  290. package/dist/symmio-contracts/symmio/actions/withdraw.d.ts +1 -1
  291. package/dist/symmio-contracts/symmio/actions/withdraw.js.map +1 -1
  292. package/dist/symmio-contracts/symmio/internal/call-as-sub-account.js +1 -1
  293. package/dist/symmio-contracts/symmio/internal/call-as-sub-account.js.map +1 -1
  294. package/dist/symmio-contracts/symmio/internal/simulate-call-as-sub-account.d.ts +1 -1
  295. package/dist/symmio-contracts/symmio/internal/simulate-call-as-sub-account.js +1 -1
  296. package/dist/symmio-contracts/symmio/internal/simulate-call-as-sub-account.js.map +1 -1
  297. package/dist/symmio-contracts/symmio/internal/withdraw-requests-v0-8-5.d.ts +214 -0
  298. package/dist/symmio-contracts/symmio/internal/withdraw-requests-v0-8-5.d.ts.map +1 -0
  299. package/dist/symmio-contracts/symmio/internal/withdraw-requests-v0-8-5.js +248 -0
  300. package/dist/symmio-contracts/symmio/internal/withdraw-requests-v0-8-5.js.map +1 -0
  301. package/dist/symmio-contracts/symmio/parts.d.ts +1 -1
  302. package/dist/symmio-contracts/symmio/parts.js.map +1 -1
  303. package/dist/symmio-contracts/symmio/types.d.ts +29 -19
  304. package/dist/symmio-contracts/symmio/types.d.ts.map +1 -1
  305. package/dist/symmio-contracts/symmio/types.js.map +1 -1
  306. package/dist/tpsl/grouping/notional.js +6 -6
  307. package/dist/websocket/tpsl/parse-tpsl-frame.d.ts +1 -1
  308. package/dist/websocket/tpsl/parse-tpsl-frame.js.map +1 -1
  309. package/dist/websocket/tpsl/watch-tpsl-notifications.d.ts +1 -1
  310. package/dist/websocket/tpsl/watch-tpsl-notifications.js.map +1 -1
  311. package/package.json +1 -1
  312. package/dist/solvers/add-solver-whitelist/add-solver-whitelist.d.ts +0 -27
  313. package/dist/solvers/add-solver-whitelist/add-solver-whitelist.d.ts.map +0 -1
  314. package/dist/solvers/add-solver-whitelist/add-solver-whitelist.js +0 -25
  315. package/dist/solvers/add-solver-whitelist/add-solver-whitelist.js.map +0 -1
  316. package/dist/solvers/add-solver-whitelist/index.d.ts +0 -3
  317. package/dist/solvers/add-solver-whitelist/index.d.ts.map +0 -1
  318. package/dist/solvers/add-solver-whitelist/query.d.ts +0 -19
  319. package/dist/solvers/add-solver-whitelist/query.d.ts.map +0 -1
  320. package/dist/solvers/add-solver-whitelist/query.js +0 -12
  321. package/dist/solvers/add-solver-whitelist/query.js.map +0 -1
  322. package/dist/symmio-contracts/abi/v0.8.5/account-layer.js.map +0 -1
  323. package/dist/symmio-contracts/abi/v0.8.5/instant-layer.js.map +0 -1
  324. package/dist/symmio-contracts/abi/v0.8.5/symmio.js.map +0 -1
  325. /package/dist/symmio-contracts/abi/{v0.8.5 → v0.8.6}/index.d.ts +0 -0
@@ -60,7 +60,7 @@ export interface MarginRiskMetrics {
60
60
  /**
61
61
  * `remainingToLiquidation < 0n` — bit-for-bit the on-chain predicate
62
62
  * `allocatedBalance − (cva + lf) + upnl < 0` from
63
- * `LibAccount.partyAAvailableBalanceForLiquidation` (perps-core v0.8.5).
63
+ * `LibAccount.partyAAvailableBalanceForLiquidation` (perps-core v0.8.6).
64
64
  *
65
65
  * Prefer this over a threshold on {@link liquidationBufferPercent}: that
66
66
  * percent is a styling signal and can be `undefined`, while this is the
@@ -1 +1 @@
1
- {"version":3,"file":"calculate-margin-risk.js","names":[],"sources":["../../src/margin/calculate-margin-risk.ts"],"sourcesContent":["import { sharePercent } from \"../shared/utils/percent\";\n\n/**\n * Inputs for {@link calculateMarginRisk}. Every field is 18-decimal wei `bigint`.\n *\n * The four balance fields come straight off `balanceInfoOfPartyA(account)` — an\n * `AccountBalanceInfo` spreads in as-is.\n */\nexport interface CalculateMarginRiskInputs {\n /** Account's allocated collateral, from `balanceInfoOfPartyA`. */\n allocatedBalance: bigint;\n /** Account's locked CVA, from `balanceInfoOfPartyA`. */\n lockedCVA: bigint;\n /** Account's locked LF, from `balanceInfoOfPartyA`. */\n lockedLF: bigint;\n /** Account's locked PartyA maintenance margin, from `balanceInfoOfPartyA`. */\n lockedPartyAMM: bigint;\n /**\n * **Signed** unrealized PnL of this **whole account** at the current mark\n * price (positive = in profit). Pass the uPnL of the same liquidation domain\n * the balance fields describe — a subset (say one group of a multi-group\n * account) understates `equity` and every figure derived from it. Pass `0n`\n * for a flat book.\n */\n upnl: bigint;\n}\n\n/**\n * Margin and liquidation-risk state of one account, as {@link calculateMarginRisk}\n * computes it. All amounts are 18-decimal wei `bigint` and may be negative where\n * the arithmetic allows it.\n */\nexport interface MarginRiskMetrics {\n /** Collateral allocated to the account — `allocatedBalance`. */\n totalMargin: bigint;\n /** `lockedCVA + lockedLF` — the level `equity` liquidates at. */\n maintenanceMargin: bigint;\n /**\n * `lockedPartyAMM + maintenanceMargin` — every leg partyA has locked. Matches\n * the contract's `LockedValuesOps.totalForPartyA()` (`cva + lf + partyAmm`).\n * These are live locked values, so the figure shrinks on a partial close.\n */\n initialMargin: bigint;\n /** `totalMargin + upnl` — the account's mark-to-market value. */\n equity: bigint;\n /**\n * `equity − maintenanceMargin` — the cushion left before liquidation.\n * **Negative means already liquidatable** (see {@link isLiquidatable}).\n */\n remainingToLiquidation: bigint;\n /**\n * `remainingToLiquidation / (totalMargin − maintenanceMargin) × 100` as an\n * 18-decimal fixed-point percent: how much of the account's zero-uPnL cushion\n * is still intact.\n *\n * Exceeds `100%` on a profitable book and goes negative once liquidatable —\n * **not clamped**; clamp at the render layer if you draw a bar. `undefined`\n * when the zero-uPnL cushion is not positive, because the ratio is genuinely\n * undefined there — read {@link remainingToLiquidation} and\n * {@link isLiquidatable} instead of treating it as `0`.\n */\n liquidationBufferPercent?: bigint;\n /**\n * `remainingToLiquidation < 0n` — bit-for-bit the on-chain predicate\n * `allocatedBalance − (cva + lf) + upnl < 0` from\n * `LibAccount.partyAAvailableBalanceForLiquidation` (perps-core v0.8.5).\n *\n * Prefer this over a threshold on {@link liquidationBufferPercent}: that\n * percent is a styling signal and can be `undefined`, while this is the\n * protocol's own test.\n */\n isLiquidatable: boolean;\n}\n\n/**\n * Margin and liquidation-risk state for one account (sub-account or Virtual\n * Account), from its `balanceInfoOfPartyA` fields and its unrealized PnL:\n *\n * ```\n * totalMargin = allocatedBalance\n * maintenanceMargin = lockedCVA + lockedLF\n * initialMargin = lockedPartyAMM + maintenanceMargin\n * equity = totalMargin + upnl\n * remainingToLiquidation = equity − maintenanceMargin\n * zeroUpnlBuffer = totalMargin − maintenanceMargin\n * liquidationBufferPercent = remainingToLiquidation / zeroUpnlBuffer × 100\n * isLiquidatable = remainingToLiquidation < 0\n * ```\n *\n * The liquidation condition is `equity < maintenanceMargin`, which expands to\n * the contract's own `allocatedBalance − (cva + lf) + upnl < 0`. The **price**\n * at which that happens is `calculateLiquidationPrice`.\n *\n * **Single account only.** Every figure describes one liquidation domain: each\n * Virtual Account is liquidated independently. Do not pass sums across accounts —\n * the totals would be additive but the buffer would not, and a blend hides an\n * account that is about to be liquidated behind a comfortable-looking average.\n *\n * Pure `bigint`, no IO, no rounding drift.\n *\n * @param inputs - One account's balance fields plus its signed uPnL.\n * @returns The account's margin & risk figures.\n *\n * @example\n * ```ts\n * const balance = await getAccountBalanceInfo(config, { account: virtualAccount });\n * const metrics = calculateMarginRisk({ ...balance, upnl: groupUpnl });\n * if (metrics.isLiquidatable) warn();\n * ```\n */\nexport function calculateMarginRisk(inputs: CalculateMarginRiskInputs): MarginRiskMetrics {\n const totalMargin = inputs.allocatedBalance;\n const maintenanceMargin = inputs.lockedCVA + inputs.lockedLF;\n const initialMargin = inputs.lockedPartyAMM + maintenanceMargin;\n const equity = totalMargin + inputs.upnl;\n const remainingToLiquidation = equity - maintenanceMargin;\n\n /** The same cushion measured at zero uPnL — the denominator the buffer is a share of. */\n const zeroUpnlBuffer = totalMargin - maintenanceMargin;\n\n return {\n totalMargin,\n maintenanceMargin,\n initialMargin,\n equity,\n remainingToLiquidation,\n /** `sharePercent` already yields `undefined` for a non-positive denominator. */\n liquidationBufferPercent: sharePercent(remainingToLiquidation, zeroUpnlBuffer),\n isLiquidatable: remainingToLiquidation < 0n,\n };\n}\n"],"mappings":";;AA8GA,SAAgB,EAAoB,GAAsD;CACxF,IAAM,IAAc,EAAO,kBACrB,IAAoB,EAAO,YAAY,EAAO,UAC9C,IAAgB,EAAO,iBAAiB,GACxC,IAAS,IAAc,EAAO,MAC9B,IAAyB,IAAS;CAKxC,OAAO;EACL;EACA;EACA;EACA;EACA;EAEA,0BAA0B,EAAa,GATlB,IAAc,CAS0C;EAC7E,gBAAgB,IAAyB;CAC3C;AACF"}
1
+ {"version":3,"file":"calculate-margin-risk.js","names":[],"sources":["../../src/margin/calculate-margin-risk.ts"],"sourcesContent":["import { sharePercent } from \"../shared/utils/percent\";\n\n/**\n * Inputs for {@link calculateMarginRisk}. Every field is 18-decimal wei `bigint`.\n *\n * The four balance fields come straight off `balanceInfoOfPartyA(account)` — an\n * `AccountBalanceInfo` spreads in as-is.\n */\nexport interface CalculateMarginRiskInputs {\n /** Account's allocated collateral, from `balanceInfoOfPartyA`. */\n allocatedBalance: bigint;\n /** Account's locked CVA, from `balanceInfoOfPartyA`. */\n lockedCVA: bigint;\n /** Account's locked LF, from `balanceInfoOfPartyA`. */\n lockedLF: bigint;\n /** Account's locked PartyA maintenance margin, from `balanceInfoOfPartyA`. */\n lockedPartyAMM: bigint;\n /**\n * **Signed** unrealized PnL of this **whole account** at the current mark\n * price (positive = in profit). Pass the uPnL of the same liquidation domain\n * the balance fields describe — a subset (say one group of a multi-group\n * account) understates `equity` and every figure derived from it. Pass `0n`\n * for a flat book.\n */\n upnl: bigint;\n}\n\n/**\n * Margin and liquidation-risk state of one account, as {@link calculateMarginRisk}\n * computes it. All amounts are 18-decimal wei `bigint` and may be negative where\n * the arithmetic allows it.\n */\nexport interface MarginRiskMetrics {\n /** Collateral allocated to the account — `allocatedBalance`. */\n totalMargin: bigint;\n /** `lockedCVA + lockedLF` — the level `equity` liquidates at. */\n maintenanceMargin: bigint;\n /**\n * `lockedPartyAMM + maintenanceMargin` — every leg partyA has locked. Matches\n * the contract's `LockedValuesOps.totalForPartyA()` (`cva + lf + partyAmm`).\n * These are live locked values, so the figure shrinks on a partial close.\n */\n initialMargin: bigint;\n /** `totalMargin + upnl` — the account's mark-to-market value. */\n equity: bigint;\n /**\n * `equity − maintenanceMargin` — the cushion left before liquidation.\n * **Negative means already liquidatable** (see {@link isLiquidatable}).\n */\n remainingToLiquidation: bigint;\n /**\n * `remainingToLiquidation / (totalMargin − maintenanceMargin) × 100` as an\n * 18-decimal fixed-point percent: how much of the account's zero-uPnL cushion\n * is still intact.\n *\n * Exceeds `100%` on a profitable book and goes negative once liquidatable —\n * **not clamped**; clamp at the render layer if you draw a bar. `undefined`\n * when the zero-uPnL cushion is not positive, because the ratio is genuinely\n * undefined there — read {@link remainingToLiquidation} and\n * {@link isLiquidatable} instead of treating it as `0`.\n */\n liquidationBufferPercent?: bigint;\n /**\n * `remainingToLiquidation < 0n` — bit-for-bit the on-chain predicate\n * `allocatedBalance − (cva + lf) + upnl < 0` from\n * `LibAccount.partyAAvailableBalanceForLiquidation` (perps-core v0.8.6).\n *\n * Prefer this over a threshold on {@link liquidationBufferPercent}: that\n * percent is a styling signal and can be `undefined`, while this is the\n * protocol's own test.\n */\n isLiquidatable: boolean;\n}\n\n/**\n * Margin and liquidation-risk state for one account (sub-account or Virtual\n * Account), from its `balanceInfoOfPartyA` fields and its unrealized PnL:\n *\n * ```\n * totalMargin = allocatedBalance\n * maintenanceMargin = lockedCVA + lockedLF\n * initialMargin = lockedPartyAMM + maintenanceMargin\n * equity = totalMargin + upnl\n * remainingToLiquidation = equity − maintenanceMargin\n * zeroUpnlBuffer = totalMargin − maintenanceMargin\n * liquidationBufferPercent = remainingToLiquidation / zeroUpnlBuffer × 100\n * isLiquidatable = remainingToLiquidation < 0\n * ```\n *\n * The liquidation condition is `equity < maintenanceMargin`, which expands to\n * the contract's own `allocatedBalance − (cva + lf) + upnl < 0`. The **price**\n * at which that happens is `calculateLiquidationPrice`.\n *\n * **Single account only.** Every figure describes one liquidation domain: each\n * Virtual Account is liquidated independently. Do not pass sums across accounts —\n * the totals would be additive but the buffer would not, and a blend hides an\n * account that is about to be liquidated behind a comfortable-looking average.\n *\n * Pure `bigint`, no IO, no rounding drift.\n *\n * @param inputs - One account's balance fields plus its signed uPnL.\n * @returns The account's margin & risk figures.\n *\n * @example\n * ```ts\n * const balance = await getAccountBalanceInfo(config, { account: virtualAccount });\n * const metrics = calculateMarginRisk({ ...balance, upnl: groupUpnl });\n * if (metrics.isLiquidatable) warn();\n * ```\n */\nexport function calculateMarginRisk(inputs: CalculateMarginRiskInputs): MarginRiskMetrics {\n const totalMargin = inputs.allocatedBalance;\n const maintenanceMargin = inputs.lockedCVA + inputs.lockedLF;\n const initialMargin = inputs.lockedPartyAMM + maintenanceMargin;\n const equity = totalMargin + inputs.upnl;\n const remainingToLiquidation = equity - maintenanceMargin;\n\n /** The same cushion measured at zero uPnL — the denominator the buffer is a share of. */\n const zeroUpnlBuffer = totalMargin - maintenanceMargin;\n\n return {\n totalMargin,\n maintenanceMargin,\n initialMargin,\n equity,\n remainingToLiquidation,\n /** `sharePercent` already yields `undefined` for a non-positive denominator. */\n liquidationBufferPercent: sharePercent(remainingToLiquidation, zeroUpnlBuffer),\n isLiquidatable: remainingToLiquidation < 0n,\n };\n}\n"],"mappings":";;AA8GA,SAAgB,EAAoB,GAAsD;CACxF,IAAM,IAAc,EAAO,kBACrB,IAAoB,EAAO,YAAY,EAAO,UAC9C,IAAgB,EAAO,iBAAiB,GACxC,IAAS,IAAc,EAAO,MAC9B,IAAyB,IAAS;CAKxC,OAAO;EACL;EACA;EACA;EACA;EACA;EAEA,0BAA0B,EAAa,GATlB,IAAc,CAS0C;EAC7E,gBAAgB,IAAyB;CAC3C;AACF"}
@@ -49,7 +49,7 @@ export type NotificationSearchFilter = Partial<Record<NotificationSearchField, N
49
49
  */
50
50
  export interface NotificationDocument {
51
51
  id?: string;
52
- /** Publishing app / channel identity, e.g. `"Hyper-EVM_Solver-Low-Cap_Production"`. */
52
+ /** Publishing app / channel identity, e.g. `"Arbitrum_Solver-Low-Cap_Production"`. */
53
53
  app_name?: string;
54
54
  /** SubAccount address the notification belongs to. */
55
55
  address?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/notifications/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAEhF;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GACvC,IAAI,GACJ,UAAU,GACV,SAAS,GACT,oBAAoB,GACpB,sBAAsB,GACtB,MAAM,GACN,aAAa,GACb,aAAa,CAAC;AAElB;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,OAAO,CAAC,MAAM,uBAAuB,EAAE,MAAM,CAAC,EAAE,CAAC;AAE3F;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,+BAA+B,GAAG,mBAAmB,CAAC;AAE5F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,sBAAsB,CAAC,CAAC,GACrG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9C,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/notifications/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAEhF;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GACvC,IAAI,GACJ,UAAU,GACV,SAAS,GACT,oBAAoB,GACpB,sBAAsB,GACtB,MAAM,GACN,aAAa,GACb,aAAa,CAAC;AAElB;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,OAAO,CAAC,MAAM,uBAAuB,EAAE,MAAM,CAAC,EAAE,CAAC;AAE3F;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,+BAA+B,GAAG,mBAAmB,CAAC;AAE5F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,sBAAsB,CAAC,CAAC,GACrG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9C,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
@@ -3,7 +3,7 @@ import { UnifiedQuote } from '../unified-quote.js';
3
3
  * Smallest open quantity a quote may keep after a partial close, wei.
4
4
  *
5
5
  * The contract accepts a partial close only when the remaining position's
6
- * partyA-locked value stays above the symbol's minimum (perps-core v0.8.5
6
+ * partyA-locked value stays above the symbol's minimum (perps-core v0.8.6
7
7
  * `LibQuoteClose.closeQuote`: `lockedValues.totalForPartyA() == 0 ||
8
8
  * lockedValues.totalForPartyA() >= minAcceptableQuoteValue` — "Remaining quote
9
9
  * value is low"). Locked values shrink proportionally with the closed amount,
@@ -1 +1 @@
1
- {"version":3,"file":"min-remaining-quantity.js","names":[],"sources":["../../../src/quotes/close-planning/min-remaining-quantity.ts"],"sourcesContent":["import type { UnifiedQuote } from \"../unified-quote\";\n\n/**\n * Integer division rounding **up** (toward positive infinity). JavaScript has\n * no built-in ceiling for `bigint` — `/` always truncates, and `Math.ceil`\n * neither accepts `bigint` nor survives the 2^53 precision limit of `number`.\n */\nfunction ceilDiv(numerator: bigint, denominator: bigint): bigint {\n return (numerator + denominator - 1n) / denominator;\n}\n\n/**\n * Smallest open quantity a quote may keep after a partial close, wei.\n *\n * The contract accepts a partial close only when the remaining position's\n * partyA-locked value stays above the symbol's minimum (perps-core v0.8.5\n * `LibQuoteClose.closeQuote`: `lockedValues.totalForPartyA() == 0 ||\n * lockedValues.totalForPartyA() >= minAcceptableQuoteValue` — \"Remaining quote\n * value is low\"). Locked values shrink proportionally with the closed amount,\n * so the size bound is:\n *\n * `remaining ≥ openQuantity × minAcceptableQuoteValue / lockedForPartyA`\n *\n * rounded **up** (a remainder one wei short would revert). `lockedForPartyA` is\n * the current `cva + lf + partyAmm`.\n *\n * Returns `openQuantity` (i.e. \"full close only\") when the quote has no\n * partyA-locked value on record — without a margin basis no partial remainder\n * can be proven acceptable.\n *\n * @param quote - The quote being partially closed.\n * @param minAcceptableQuoteValue - The symbol's `minAcceptableQuoteValue`, wei.\n * @returns The minimum acceptable remainder, wei.\n */\nexport function minRemainingQuantityOf(quote: UnifiedQuote, minAcceptableQuoteValue: bigint): bigint {\n const lockedForPartyA = quote.lockedValues.cva + quote.lockedValues.lf + quote.lockedValues.partyAmm;\n if (lockedForPartyA <= 0n) return quote.openQuantity;\n // Round up — rounding down would allow a remainder that reverts on-chain.\n return ceilDiv(quote.openQuantity * minAcceptableQuoteValue, lockedForPartyA);\n}\n"],"mappings":";AAOA,SAAS,EAAQ,GAAmB,GAA6B;CAC/D,QAAQ,IAAY,IAAc,MAAM;AAC1C;AAyBA,SAAgB,EAAuB,GAAqB,GAAyC;CACnG,IAAM,IAAkB,EAAM,aAAa,MAAM,EAAM,aAAa,KAAK,EAAM,aAAa;CAG5F,OAFI,KAAmB,KAAW,EAAM,eAEjC,EAAQ,EAAM,eAAe,GAAyB,CAAe;AAC9E"}
1
+ {"version":3,"file":"min-remaining-quantity.js","names":[],"sources":["../../../src/quotes/close-planning/min-remaining-quantity.ts"],"sourcesContent":["import type { UnifiedQuote } from \"../unified-quote\";\n\n/**\n * Integer division rounding **up** (toward positive infinity). JavaScript has\n * no built-in ceiling for `bigint` — `/` always truncates, and `Math.ceil`\n * neither accepts `bigint` nor survives the 2^53 precision limit of `number`.\n */\nfunction ceilDiv(numerator: bigint, denominator: bigint): bigint {\n return (numerator + denominator - 1n) / denominator;\n}\n\n/**\n * Smallest open quantity a quote may keep after a partial close, wei.\n *\n * The contract accepts a partial close only when the remaining position's\n * partyA-locked value stays above the symbol's minimum (perps-core v0.8.6\n * `LibQuoteClose.closeQuote`: `lockedValues.totalForPartyA() == 0 ||\n * lockedValues.totalForPartyA() >= minAcceptableQuoteValue` — \"Remaining quote\n * value is low\"). Locked values shrink proportionally with the closed amount,\n * so the size bound is:\n *\n * `remaining ≥ openQuantity × minAcceptableQuoteValue / lockedForPartyA`\n *\n * rounded **up** (a remainder one wei short would revert). `lockedForPartyA` is\n * the current `cva + lf + partyAmm`.\n *\n * Returns `openQuantity` (i.e. \"full close only\") when the quote has no\n * partyA-locked value on record — without a margin basis no partial remainder\n * can be proven acceptable.\n *\n * @param quote - The quote being partially closed.\n * @param minAcceptableQuoteValue - The symbol's `minAcceptableQuoteValue`, wei.\n * @returns The minimum acceptable remainder, wei.\n */\nexport function minRemainingQuantityOf(quote: UnifiedQuote, minAcceptableQuoteValue: bigint): bigint {\n const lockedForPartyA = quote.lockedValues.cva + quote.lockedValues.lf + quote.lockedValues.partyAmm;\n if (lockedForPartyA <= 0n) return quote.openQuantity;\n // Round up — rounding down would allow a remainder that reverts on-chain.\n return ceilDiv(quote.openQuantity * minAcceptableQuoteValue, lockedForPartyA);\n}\n"],"mappings":";AAOA,SAAS,EAAQ,GAAmB,GAA6B;CAC/D,QAAQ,IAAY,IAAc,MAAM;AAC1C;AAyBA,SAAgB,EAAuB,GAAqB,GAAyC;CACnG,IAAM,IAAkB,EAAM,aAAa,MAAM,EAAM,aAAa,KAAK,EAAM,aAAa;CAG5F,OAFI,KAAmB,KAAW,EAAM,eAEjC,EAAQ,EAAM,eAAe,GAAyB,CAAe;AAC9E"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * History query over the immutable `quoteEvents` collection (SYMMIO subgraphs
3
- * v0.8.5+). Each row is one close/liquidation event with a frozen `metadata`
3
+ * v0.8.6+). Each row is one close/liquidation event with a frozen `metadata`
4
4
  * snapshot plus the (mutable) `quote` it belongs to — the snapshot is what makes
5
5
  * multiple partial-close rows of the same quote distinct.
6
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"query-document.js","names":[],"sources":["../../../src/quotes/get-quote-history/query-document.ts"],"sourcesContent":["import { graphql } from \"../../symmio-subgraph/types/generated/analytics\";\n\n/**\n * History query over the immutable `quoteEvents` collection (SYMMIO subgraphs\n * v0.8.5+). Each row is one close/liquidation event with a frozen `metadata`\n * snapshot plus the (mutable) `quote` it belongs to — the snapshot is what makes\n * multiple partial-close rows of the same quote distinct.\n *\n * Filtered server-side by event `type_in` (close-type), `timestamp` range, and\n * the quote's `subAccount_in`. Sorted by event `timestamp` (the row's close\n * time). The document compiles to a typed query string via graphql-codegen.\n */\nexport const QuoteEventsForHistoryDocument = graphql(`\n query QuoteEventsForHistory(\n $typeIn: [String!]!\n $subAccounts: [String!]!\n $first: Int!\n $skip: Int!\n $orderDirection: OrderDirection!\n $startDate: BigInt!\n $endDate: BigInt!\n ) {\n quoteEvents(\n first: $first\n skip: $skip\n orderBy: timestamp\n orderDirection: $orderDirection\n where: {\n type_in: $typeIn\n timestamp_gte: $startDate\n timestamp_lte: $endDate\n quote_: { subAccount_in: $subAccounts }\n }\n ) {\n id\n type\n metadata\n timestamp\n quoteId\n blockNumber\n transaction\n quote {\n quoteId\n quoteStatus\n positionType\n orderTypeOpen\n symbol\n symbolId\n partyA\n partyB\n subAccount {\n id\n }\n quantity\n openedPrice\n requestedOpenPrice\n averageClosedPrice\n closePrice\n closedAmount\n quantityToClose\n liquidateAmount\n liquidatePrice\n }\n }\n }\n`);\n"],"mappings":";;AAYA,IAAa,IAAgC,EAAQ,8iCAqDpD"}
1
+ {"version":3,"file":"query-document.js","names":[],"sources":["../../../src/quotes/get-quote-history/query-document.ts"],"sourcesContent":["import { graphql } from \"../../symmio-subgraph/types/generated/analytics\";\n\n/**\n * History query over the immutable `quoteEvents` collection (SYMMIO subgraphs\n * v0.8.6+). Each row is one close/liquidation event with a frozen `metadata`\n * snapshot plus the (mutable) `quote` it belongs to — the snapshot is what makes\n * multiple partial-close rows of the same quote distinct.\n *\n * Filtered server-side by event `type_in` (close-type), `timestamp` range, and\n * the quote's `subAccount_in`. Sorted by event `timestamp` (the row's close\n * time). The document compiles to a typed query string via graphql-codegen.\n */\nexport const QuoteEventsForHistoryDocument = graphql(`\n query QuoteEventsForHistory(\n $typeIn: [String!]!\n $subAccounts: [String!]!\n $first: Int!\n $skip: Int!\n $orderDirection: OrderDirection!\n $startDate: BigInt!\n $endDate: BigInt!\n ) {\n quoteEvents(\n first: $first\n skip: $skip\n orderBy: timestamp\n orderDirection: $orderDirection\n where: {\n type_in: $typeIn\n timestamp_gte: $startDate\n timestamp_lte: $endDate\n quote_: { subAccount_in: $subAccounts }\n }\n ) {\n id\n type\n metadata\n timestamp\n quoteId\n blockNumber\n transaction\n quote {\n quoteId\n quoteStatus\n positionType\n orderTypeOpen\n symbol\n symbolId\n partyA\n partyB\n subAccount {\n id\n }\n quantity\n openedPrice\n requestedOpenPrice\n averageClosedPrice\n closePrice\n closedAmount\n quantityToClose\n liquidateAmount\n liquidatePrice\n }\n }\n }\n`);\n"],"mappings":";;AAYA,IAAa,IAAgC,EAAQ,8iCAqDpD"}
@@ -25,8 +25,8 @@ export declare enum QuoteCloseType {
25
25
  * therefore appear in history. Each carries an immutable `metadata` snapshot.
26
26
  *
27
27
  * @remarks
28
- * Mirrors the event-type strings emitted by the SYMMIO subgraphs (v0.8.5+);
29
- * see the subgraphs `0.8.5_migration` doc — QuoteEvent metadata.
28
+ * Mirrors the event-type strings emitted by the SYMMIO subgraphs (v0.8.6+);
29
+ * see the subgraphs `0.8.6_migration` doc — QuoteEvent metadata.
30
30
  */
31
31
  export declare enum QuoteCloseEventType {
32
32
  /** A normal (partial or full) close. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/quotes/get-quote-history/types.ts"],"sourcesContent":["import type { Address, Hex } from \"viem\";\nimport type { OrderType, PositionType, QuoteStatus } from \"../../symmio-contracts/symmio/types\";\n\n/**\n * Close-type filter for quote history.\n *\n * Selects which terminal events a history read returns. Maps to the subgraph's\n * `QuoteEvent.type` values via {@link \"closeTypeToEventTypes\"}.\n */\nexport enum QuoteCloseType {\n /** Every close and liquidation event. */\n All = \"All\",\n /** Normal close (`FILL_CLOSE`). */\n Closed = \"Closed\",\n /** Force close (`FORCE_CLOSE`). */\n ForceClosed = \"ForceClosed\",\n /** Emergency close (`EMERGENCY_CLOSE`). */\n EmergencyClosed = \"EmergencyClosed\",\n /** Auto-deleveraging close (`ADL_CLOSE`). */\n AdlClosed = \"AdlClosed\",\n /** Liquidation (`LIQUIDATE_PARTY_A` / `_PARTY_B` / `_CLEARING_HOUSE`). */\n Liquidated = \"Liquidated\",\n}\n\n/**\n * Subgraph `QuoteEvent.type` values that terminate a (partial) position and\n * therefore appear in history. Each carries an immutable `metadata` snapshot.\n *\n * @remarks\n * Mirrors the event-type strings emitted by the SYMMIO subgraphs (v0.8.5+);\n * see the subgraphs `0.8.5_migration` doc — QuoteEvent metadata.\n */\nexport enum QuoteCloseEventType {\n /** A normal (partial or full) close. */\n FillClose = \"FILL_CLOSE\",\n /** A force close. */\n ForceClose = \"FORCE_CLOSE\",\n /** An emergency close. */\n EmergencyClose = \"EMERGENCY_CLOSE\",\n /** An auto-deleveraging close. */\n AdlClose = \"ADL_CLOSE\",\n /** Liquidation initiated against partyA. */\n LiquidatePartyA = \"LIQUIDATE_PARTY_A\",\n /** Liquidation initiated against partyB. */\n LiquidatePartyB = \"LIQUIDATE_PARTY_B\",\n /** Liquidation initiated by the clearing house. */\n LiquidateClearingHouse = \"LIQUIDATE_CLEARING_HOUSE\",\n}\n\n/**\n * One row of quote history — a single immutable `QuoteEvent` with its per-event\n * `metadata` snapshot overlaid onto the (otherwise mutable) quote it belongs to.\n *\n * Because the underlying `Quote` entity is mutable, a quote closed across several\n * partial closes produces several history rows that would otherwise show the same\n * final state. The snapshot overlay restores each event's own amount/price, so\n * every partial-close row is distinct.\n *\n * @remarks\n * Amounts and prices are raw `bigint` (18-decimal fixed point, no scaling),\n * matching the SDK's on-chain {@link \"Quote\"} reads. Enum fields are decoded.\n */\nexport interface QuoteHistoryRow {\n /** Stable id of the underlying immutable `QuoteEvent` (use as a row key). */\n eventId: string;\n /** The close / liquidation event that produced this row. */\n closeEventType: QuoteCloseEventType;\n /** Event block timestamp in seconds (the row's \"close time\"). */\n closedAt: number;\n /** Protocol quote id. */\n quoteId: bigint;\n /** Market identifier (`symbolId`). */\n marketId: number;\n /** Market ticker resolved by the subgraph, when known. */\n symbol: string | null;\n /** Long or short. */\n positionType: PositionType;\n /** Limit or market order (open side). */\n orderType: OrderType;\n /** Lifecycle status, forced to `CLOSED` / `LIQUIDATED` from the event type. */\n quoteStatus: QuoteStatus;\n /** Total quote quantity. */\n quantity: bigint;\n /** Open price (snapshot-overlaid when the event carried one). */\n openedPrice: bigint;\n /** Price partyA originally requested to open at. */\n requestedOpenPrice: bigint;\n /** Average close price (snapshot-overlaid with this event's close price). */\n avgClosedPrice: bigint;\n /** Amount closed by this event (snapshot `amount`). */\n closedAmount: bigint;\n /** Quantity of the close request this event settled. */\n quantityToClose: bigint;\n /** Liquidated amount (set only for liquidation rows). */\n liquidateAmount: bigint;\n /** Liquidation price (set only for liquidation rows). */\n liquidatePrice: bigint;\n /** PartyA (the SubAccount or Virtual Account that owns the quote). */\n partyA: Address;\n /** PartyB (the hedger/solver), or `null` when absent. */\n partyB: Address | null;\n /** The account-layer SubAccount address, or `null` when absent. */\n subAccount: Address | null;\n /** Block number of the event, when available. */\n blockNumber?: bigint;\n /** Transaction hash of the event, when available. */\n transaction?: Hex;\n /** Raw event `metadata` JSON string, preserved for power users. */\n rawMetadata: string | null;\n}\n"],"mappings":";AASA,IAAY,IAAL,yBAAA,GAAA;QAEL,EAAA,MAAA,OAEA,EAAA,SAAA,UAEA,EAAA,cAAA,eAEA,EAAA,kBAAA,mBAEA,EAAA,YAAA,aAEA,EAAA,aAAA;AACF,EAAA,CAAA,CAAA,GAUY,IAAL,yBAAA,GAAA;QAEL,EAAA,YAAA,cAEA,EAAA,aAAA,eAEA,EAAA,iBAAA,mBAEA,EAAA,WAAA,aAEA,EAAA,kBAAA,qBAEA,EAAA,kBAAA,qBAEA,EAAA,yBAAA;AACF,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/quotes/get-quote-history/types.ts"],"sourcesContent":["import type { Address, Hex } from \"viem\";\nimport type { OrderType, PositionType, QuoteStatus } from \"../../symmio-contracts/symmio/types\";\n\n/**\n * Close-type filter for quote history.\n *\n * Selects which terminal events a history read returns. Maps to the subgraph's\n * `QuoteEvent.type` values via {@link \"closeTypeToEventTypes\"}.\n */\nexport enum QuoteCloseType {\n /** Every close and liquidation event. */\n All = \"All\",\n /** Normal close (`FILL_CLOSE`). */\n Closed = \"Closed\",\n /** Force close (`FORCE_CLOSE`). */\n ForceClosed = \"ForceClosed\",\n /** Emergency close (`EMERGENCY_CLOSE`). */\n EmergencyClosed = \"EmergencyClosed\",\n /** Auto-deleveraging close (`ADL_CLOSE`). */\n AdlClosed = \"AdlClosed\",\n /** Liquidation (`LIQUIDATE_PARTY_A` / `_PARTY_B` / `_CLEARING_HOUSE`). */\n Liquidated = \"Liquidated\",\n}\n\n/**\n * Subgraph `QuoteEvent.type` values that terminate a (partial) position and\n * therefore appear in history. Each carries an immutable `metadata` snapshot.\n *\n * @remarks\n * Mirrors the event-type strings emitted by the SYMMIO subgraphs (v0.8.6+);\n * see the subgraphs `0.8.6_migration` doc — QuoteEvent metadata.\n */\nexport enum QuoteCloseEventType {\n /** A normal (partial or full) close. */\n FillClose = \"FILL_CLOSE\",\n /** A force close. */\n ForceClose = \"FORCE_CLOSE\",\n /** An emergency close. */\n EmergencyClose = \"EMERGENCY_CLOSE\",\n /** An auto-deleveraging close. */\n AdlClose = \"ADL_CLOSE\",\n /** Liquidation initiated against partyA. */\n LiquidatePartyA = \"LIQUIDATE_PARTY_A\",\n /** Liquidation initiated against partyB. */\n LiquidatePartyB = \"LIQUIDATE_PARTY_B\",\n /** Liquidation initiated by the clearing house. */\n LiquidateClearingHouse = \"LIQUIDATE_CLEARING_HOUSE\",\n}\n\n/**\n * One row of quote history — a single immutable `QuoteEvent` with its per-event\n * `metadata` snapshot overlaid onto the (otherwise mutable) quote it belongs to.\n *\n * Because the underlying `Quote` entity is mutable, a quote closed across several\n * partial closes produces several history rows that would otherwise show the same\n * final state. The snapshot overlay restores each event's own amount/price, so\n * every partial-close row is distinct.\n *\n * @remarks\n * Amounts and prices are raw `bigint` (18-decimal fixed point, no scaling),\n * matching the SDK's on-chain {@link \"Quote\"} reads. Enum fields are decoded.\n */\nexport interface QuoteHistoryRow {\n /** Stable id of the underlying immutable `QuoteEvent` (use as a row key). */\n eventId: string;\n /** The close / liquidation event that produced this row. */\n closeEventType: QuoteCloseEventType;\n /** Event block timestamp in seconds (the row's \"close time\"). */\n closedAt: number;\n /** Protocol quote id. */\n quoteId: bigint;\n /** Market identifier (`symbolId`). */\n marketId: number;\n /** Market ticker resolved by the subgraph, when known. */\n symbol: string | null;\n /** Long or short. */\n positionType: PositionType;\n /** Limit or market order (open side). */\n orderType: OrderType;\n /** Lifecycle status, forced to `CLOSED` / `LIQUIDATED` from the event type. */\n quoteStatus: QuoteStatus;\n /** Total quote quantity. */\n quantity: bigint;\n /** Open price (snapshot-overlaid when the event carried one). */\n openedPrice: bigint;\n /** Price partyA originally requested to open at. */\n requestedOpenPrice: bigint;\n /** Average close price (snapshot-overlaid with this event's close price). */\n avgClosedPrice: bigint;\n /** Amount closed by this event (snapshot `amount`). */\n closedAmount: bigint;\n /** Quantity of the close request this event settled. */\n quantityToClose: bigint;\n /** Liquidated amount (set only for liquidation rows). */\n liquidateAmount: bigint;\n /** Liquidation price (set only for liquidation rows). */\n liquidatePrice: bigint;\n /** PartyA (the SubAccount or Virtual Account that owns the quote). */\n partyA: Address;\n /** PartyB (the hedger/solver), or `null` when absent. */\n partyB: Address | null;\n /** The account-layer SubAccount address, or `null` when absent. */\n subAccount: Address | null;\n /** Block number of the event, when available. */\n blockNumber?: bigint;\n /** Transaction hash of the event, when available. */\n transaction?: Hex;\n /** Raw event `metadata` JSON string, preserved for power users. */\n rawMetadata: string | null;\n}\n"],"mappings":";AASA,IAAY,IAAL,yBAAA,GAAA;QAEL,EAAA,MAAA,OAEA,EAAA,SAAA,UAEA,EAAA,cAAA,eAEA,EAAA,kBAAA,mBAEA,EAAA,YAAA,aAEA,EAAA,aAAA;AACF,EAAA,CAAA,CAAA,GAUY,IAAL,yBAAA,GAAA;QAEL,EAAA,YAAA,cAEA,EAAA,aAAA,eAEA,EAAA,iBAAA,mBAEA,EAAA,WAAA,aAEA,EAAA,kBAAA,qBAEA,EAAA,kBAAA,qBAEA,EAAA,yBAAA;AACF,EAAA,CAAA,CAAA"}
@@ -10,7 +10,7 @@ import { QuoteGroupMetrics } from './quote-group.js';
10
10
  * - `weightedOpenPrice = Σ(openQuantity × openPrice) / Σ openQuantity`, suppressed
11
11
  * (`undefined`) when there is no open size or any child has an unsettled open price.
12
12
  * - `lockedValues` sums each margin leg.
13
- * - `leverage = Σ(quantity × (requestedOpenPrice ?? openedPrice)) / Σ(cva + lf +
13
+ * - `leverage = Σ(quantity × (initialOpenedPrice ?? openedPrice ?? requestedOpenPrice)) / Σ(cva + lf +
14
14
  * partyAmm + partyBmm)`, each child using its frozen `initialLockedValues` (else
15
15
  * `lockedValues`), as an 18-decimal fixed-point `bigint`; `undefined` when that
16
16
  * margin is `0`.
@@ -1 +1 @@
1
- {"version":3,"file":"aggregate-metrics.js","names":[],"sources":["../../../src/quotes/grouping/aggregate-metrics.ts"],"sourcesContent":["import { WEI } from \"../../shared/utils/wei\";\nimport type { LockedValues } from \"../../symmio-contracts/symmio/types\";\nimport { hasUnsettledOpenPrice, leveragePriceOf, openPriceOf } from \"../open-price\";\nimport type { UnifiedQuote } from \"../unified-quote\";\nimport { isActivePosition, isPendingOrder } from \"./partition-quotes\";\nimport type { QuoteGroupMetrics } from \"./quote-group\";\n\n/** A quote's price for the frozen at-open notional: `initialOpenedPrice`, else the requested one. */\nfunction initialNotionalPriceOf(quote: UnifiedQuote): bigint {\n return quote.initialOpenedPrice ?? quote.requestedOpenPrice;\n}\n\n/**\n * A quote's locked-margin basis for leverage: every leg (`cva + lf + partyAmm +\n * partyBmm`) of the frozen `initialLockedValues` when known, else of the current\n * `lockedValues`.\n */\nfunction leverageMarginOf(quote: UnifiedQuote): bigint {\n const margin = quote.initialLockedValues ?? quote.lockedValues;\n return margin.cva + margin.lf + margin.partyAmm + margin.partyBmm;\n}\n\n/**\n * Compute the pure, price-independent {@link QuoteGroupMetrics} for a set of\n * child quotes.\n *\n * - `openQuantity` / `quantity` are plain sums (wei).\n * - `initialNotional = Σ(quantity × (initialOpenedPrice ?? requestedOpenPrice))`,\n * rescaled to wei — the frozen at-open notional; partial closes do not shrink it.\n * - `weightedOpenPrice = Σ(openQuantity × openPrice) / Σ openQuantity`, suppressed\n * (`undefined`) when there is no open size or any child has an unsettled open price.\n * - `lockedValues` sums each margin leg.\n * - `leverage = Σ(quantity × (requestedOpenPrice ?? openedPrice)) / Σ(cva + lf +\n * partyAmm + partyBmm)`, each child using its frozen `initialLockedValues` (else\n * `lockedValues`), as an 18-decimal fixed-point `bigint`; `undefined` when that\n * margin is `0`.\n *\n * Pure and order-independent. Empty input yields all-zero amounts with the\n * optional fields `undefined`.\n *\n * @param quotes - The group's child quotes.\n * @returns The aggregated metrics.\n */\nexport function aggregateGroupMetrics(quotes: readonly UnifiedQuote[]): QuoteGroupMetrics {\n let quantity = 0n;\n let openQuantity = 0n;\n /**\n * Σ(openQuantity × openPrice), scaled by `WEI²`; feeds `weightedOpenPrice` only.\n *\n * **Deliberately not `mulWei`.** Every other `quantity × price` fold in the SDK\n * rescales to wei per item, but this one must stay at `WEI²`: the divide at the\n * bottom is by `openQuantity` (wei), not by `WEI`, and it is that surviving\n * factor which lands `weightedOpenPrice` back on wei scale. Truncating here\n * would return a price 1e18 too small.\n */\n let notionalNumerator = 0n;\n /** Σ(quantity × (initialOpenedPrice ?? requestedOpenPrice)), scaled by `WEI²` until the final rescale. */\n let initialNotionalNumerator = 0n;\n /** Σ(quantity × (requestedOpenPrice ?? openedPrice)), scaled by `WEI²` until the final divide. */\n let leverageNumerator = 0n;\n /** Σ of each child's frozen (initial-preferred) locked-margin legs, wei. */\n let leverageMargin = 0n;\n let cva = 0n;\n let lf = 0n;\n let partyAmm = 0n;\n let partyBmm = 0n;\n let openCount = 0;\n let pendingCount = 0;\n let anyUnsettledOpenPrice = false;\n\n for (const quote of quotes) {\n quantity += quote.quantity;\n openQuantity += quote.openQuantity;\n notionalNumerator += quote.openQuantity * openPriceOf(quote);\n initialNotionalNumerator += quote.quantity * initialNotionalPriceOf(quote);\n leverageNumerator += quote.quantity * leveragePriceOf(quote);\n leverageMargin += leverageMarginOf(quote);\n cva += quote.lockedValues.cva;\n lf += quote.lockedValues.lf;\n partyAmm += quote.lockedValues.partyAmm;\n partyBmm += quote.lockedValues.partyBmm;\n if (hasUnsettledOpenPrice(quote)) anyUnsettledOpenPrice = true;\n if (isPendingOrder(quote)) pendingCount += 1;\n else if (isActivePosition(quote)) openCount += 1;\n }\n\n const lockedValues: LockedValues = { cva, lf, partyAmm, partyBmm };\n const initialNotional = initialNotionalNumerator / WEI;\n\n const weightedOpenPrice = openQuantity > 0n && !anyUnsettledOpenPrice ? notionalNumerator / openQuantity : undefined;\n /** `leverageNumerator` is scaled by WEI²; dividing by the WEI-scaled margin yields an 18-decimal ratio. */\n const leverage = leverageMargin > 0n ? leverageNumerator / leverageMargin : undefined;\n\n return {\n quoteCount: quotes.length,\n openCount,\n pendingCount,\n quantity,\n openQuantity,\n weightedOpenPrice,\n initialNotional,\n lockedValues,\n leverage,\n };\n}\n"],"mappings":";;;;AAQA,SAAS,EAAuB,GAA6B;CAC3D,OAAO,EAAM,sBAAsB,EAAM;AAC3C;AAOA,SAAS,EAAiB,GAA6B;CACrD,IAAM,IAAS,EAAM,uBAAuB,EAAM;CAClD,OAAO,EAAO,MAAM,EAAO,KAAK,EAAO,WAAW,EAAO;AAC3D;AAuBA,SAAgB,EAAsB,GAAoD;CACxF,IAAI,IAAW,IACX,IAAe,IAUf,IAAoB,IAEpB,IAA2B,IAE3B,IAAoB,IAEpB,IAAiB,IACjB,IAAM,IACN,IAAK,IACL,IAAW,IACX,IAAW,IACX,IAAY,GACZ,IAAe,GACf,IAAwB;CAE5B,KAAK,IAAM,KAAS,GAYlB,AAXA,KAAY,EAAM,UAClB,KAAgB,EAAM,cACtB,KAAqB,EAAM,eAAe,EAAY,CAAK,GAC3D,KAA4B,EAAM,WAAW,EAAuB,CAAK,GACzE,KAAqB,EAAM,WAAW,EAAgB,CAAK,GAC3D,KAAkB,EAAiB,CAAK,GACxC,KAAO,EAAM,aAAa,KAC1B,KAAM,EAAM,aAAa,IACzB,KAAY,EAAM,aAAa,UAC/B,KAAY,EAAM,aAAa,UAC3B,EAAsB,CAAK,MAAG,IAAwB,KACtD,EAAe,CAAK,IAAG,KAAgB,IAClC,EAAiB,CAAK,MAAG,KAAa;CAGjD,IAAM,IAA6B;EAAE;EAAK;EAAI;EAAU;CAAS,GAC3D,IAAkB,IAA2B,GAE7C,IAAoB,IAAe,MAAM,CAAC,IAAwB,IAAoB,IAAe,KAAA,GAErG,IAAW,IAAiB,KAAK,IAAoB,IAAiB,KAAA;CAE5E,OAAO;EACL,YAAY,EAAO;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"aggregate-metrics.js","names":[],"sources":["../../../src/quotes/grouping/aggregate-metrics.ts"],"sourcesContent":["import { WEI } from \"../../shared/utils/wei\";\nimport type { LockedValues } from \"../../symmio-contracts/symmio/types\";\nimport { hasUnsettledOpenPrice, leveragePriceOf, openPriceOf } from \"../open-price\";\nimport type { UnifiedQuote } from \"../unified-quote\";\nimport { isActivePosition, isPendingOrder } from \"./partition-quotes\";\nimport type { QuoteGroupMetrics } from \"./quote-group\";\n\n/** A quote's price for the frozen at-open notional: `initialOpenedPrice`, else the requested one. */\nfunction initialNotionalPriceOf(quote: UnifiedQuote): bigint {\n return quote.initialOpenedPrice ?? quote.requestedOpenPrice;\n}\n\n/**\n * A quote's locked-margin basis for leverage: every leg (`cva + lf + partyAmm +\n * partyBmm`) of the frozen `initialLockedValues` when known, else of the current\n * `lockedValues`.\n */\nfunction leverageMarginOf(quote: UnifiedQuote): bigint {\n const margin = quote.initialLockedValues ?? quote.lockedValues;\n return margin.cva + margin.lf + margin.partyAmm + margin.partyBmm;\n}\n\n/**\n * Compute the pure, price-independent {@link QuoteGroupMetrics} for a set of\n * child quotes.\n *\n * - `openQuantity` / `quantity` are plain sums (wei).\n * - `initialNotional = Σ(quantity × (initialOpenedPrice ?? requestedOpenPrice))`,\n * rescaled to wei — the frozen at-open notional; partial closes do not shrink it.\n * - `weightedOpenPrice = Σ(openQuantity × openPrice) / Σ openQuantity`, suppressed\n * (`undefined`) when there is no open size or any child has an unsettled open price.\n * - `lockedValues` sums each margin leg.\n * - `leverage = Σ(quantity × (initialOpenedPrice ?? openedPrice ?? requestedOpenPrice)) / Σ(cva + lf +\n * partyAmm + partyBmm)`, each child using its frozen `initialLockedValues` (else\n * `lockedValues`), as an 18-decimal fixed-point `bigint`; `undefined` when that\n * margin is `0`.\n *\n * Pure and order-independent. Empty input yields all-zero amounts with the\n * optional fields `undefined`.\n *\n * @param quotes - The group's child quotes.\n * @returns The aggregated metrics.\n */\nexport function aggregateGroupMetrics(quotes: readonly UnifiedQuote[]): QuoteGroupMetrics {\n let quantity = 0n;\n let openQuantity = 0n;\n /**\n * Σ(openQuantity × openPrice), scaled by `WEI²`; feeds `weightedOpenPrice` only.\n *\n * **Deliberately not `mulWei`.** Every other `quantity × price` fold in the SDK\n * rescales to wei per item, but this one must stay at `WEI²`: the divide at the\n * bottom is by `openQuantity` (wei), not by `WEI`, and it is that surviving\n * factor which lands `weightedOpenPrice` back on wei scale. Truncating here\n * would return a price 1e18 too small.\n */\n let notionalNumerator = 0n;\n /** Σ(quantity × (initialOpenedPrice ?? requestedOpenPrice)), scaled by `WEI²` until the final rescale. */\n let initialNotionalNumerator = 0n;\n /** Σ(quantity × (requestedOpenPrice ?? openedPrice)), scaled by `WEI²` until the final divide. */\n let leverageNumerator = 0n;\n /** Σ of each child's frozen (initial-preferred) locked-margin legs, wei. */\n let leverageMargin = 0n;\n let cva = 0n;\n let lf = 0n;\n let partyAmm = 0n;\n let partyBmm = 0n;\n let openCount = 0;\n let pendingCount = 0;\n let anyUnsettledOpenPrice = false;\n\n for (const quote of quotes) {\n quantity += quote.quantity;\n openQuantity += quote.openQuantity;\n notionalNumerator += quote.openQuantity * openPriceOf(quote);\n initialNotionalNumerator += quote.quantity * initialNotionalPriceOf(quote);\n leverageNumerator += quote.quantity * leveragePriceOf(quote);\n leverageMargin += leverageMarginOf(quote);\n cva += quote.lockedValues.cva;\n lf += quote.lockedValues.lf;\n partyAmm += quote.lockedValues.partyAmm;\n partyBmm += quote.lockedValues.partyBmm;\n if (hasUnsettledOpenPrice(quote)) anyUnsettledOpenPrice = true;\n if (isPendingOrder(quote)) pendingCount += 1;\n else if (isActivePosition(quote)) openCount += 1;\n }\n\n const lockedValues: LockedValues = { cva, lf, partyAmm, partyBmm };\n const initialNotional = initialNotionalNumerator / WEI;\n\n const weightedOpenPrice = openQuantity > 0n && !anyUnsettledOpenPrice ? notionalNumerator / openQuantity : undefined;\n /** `leverageNumerator` is scaled by WEI²; dividing by the WEI-scaled margin yields an 18-decimal ratio. */\n const leverage = leverageMargin > 0n ? leverageNumerator / leverageMargin : undefined;\n\n return {\n quoteCount: quotes.length,\n openCount,\n pendingCount,\n quantity,\n openQuantity,\n weightedOpenPrice,\n initialNotional,\n lockedValues,\n leverage,\n };\n}\n"],"mappings":";;;;AAQA,SAAS,EAAuB,GAA6B;CAC3D,OAAO,EAAM,sBAAsB,EAAM;AAC3C;AAOA,SAAS,EAAiB,GAA6B;CACrD,IAAM,IAAS,EAAM,uBAAuB,EAAM;CAClD,OAAO,EAAO,MAAM,EAAO,KAAK,EAAO,WAAW,EAAO;AAC3D;AAuBA,SAAgB,EAAsB,GAAoD;CACxF,IAAI,IAAW,IACX,IAAe,IAUf,IAAoB,IAEpB,IAA2B,IAE3B,IAAoB,IAEpB,IAAiB,IACjB,IAAM,IACN,IAAK,IACL,IAAW,IACX,IAAW,IACX,IAAY,GACZ,IAAe,GACf,IAAwB;CAE5B,KAAK,IAAM,KAAS,GAYlB,AAXA,KAAY,EAAM,UAClB,KAAgB,EAAM,cACtB,KAAqB,EAAM,eAAe,EAAY,CAAK,GAC3D,KAA4B,EAAM,WAAW,EAAuB,CAAK,GACzE,KAAqB,EAAM,WAAW,EAAgB,CAAK,GAC3D,KAAkB,EAAiB,CAAK,GACxC,KAAO,EAAM,aAAa,KAC1B,KAAM,EAAM,aAAa,IACzB,KAAY,EAAM,aAAa,UAC/B,KAAY,EAAM,aAAa,UAC3B,EAAsB,CAAK,MAAG,IAAwB,KACtD,EAAe,CAAK,IAAG,KAAgB,IAClC,EAAiB,CAAK,MAAG,KAAa;CAGjD,IAAM,IAA6B;EAAE;EAAK;EAAI;EAAU;CAAS,GAC3D,IAAkB,IAA2B,GAE7C,IAAoB,IAAe,MAAM,CAAC,IAAwB,IAAoB,IAAe,KAAA,GAErG,IAAW,IAAiB,KAAK,IAAoB,IAAiB,KAAA;CAE5E,OAAO;EACL,YAAY,EAAO;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -34,18 +34,18 @@ export declare function hasUnsettledOpenPrice(quote: Pick<UnifiedQuote, "openedP
34
34
  */
35
35
  export declare function openPriceOf(quote: Pick<UnifiedQuote, "openedPrice" | "requestedOpenPrice">): bigint;
36
36
  /**
37
- * A quote's reference price for leverage: the `requestedOpenPrice`, else the
38
- * settled `openedPrice`.
37
+ * A quote's reference price for leverage, in descending precedence: the
38
+ * `initialOpenedPrice` it first opened at, else the settled `openedPrice`, else
39
+ * the current `requestedOpenPrice`.
39
40
  *
40
- * **The precedence is the inverse of {@link openPriceOf}** and that is
41
- * deliberate: leverage describes the position as it was *opened*, so the price
42
- * the trader committed to wins, and the settled fill steps in only when there is
43
- * no requested price on record. Shared by `aggregateGroupMetrics` and
44
- * `calculateQuoteLeverage`, which agree on this rule while deliberately
45
- * differing in numeric strategy (exact bigint vs. float).
41
+ * Leverage describes the position *as it was opened*, so the original open price
42
+ * wins — `requestedOpenPrice` can drift after edits and is only the last resort.
43
+ * A `0n` (or absent) price at any tier falls through to the next. Shared by
44
+ * `aggregateGroupMetrics` and `calculateQuoteLeverage`, which agree on this rule
45
+ * while deliberately differing in numeric strategy (exact bigint vs. float).
46
46
  *
47
47
  * @param quote - Any object carrying the quote's open prices.
48
- * @returns The leverage reference price in wei, or `0n` when neither is set.
48
+ * @returns The leverage reference price in wei, or `0n` when none is set.
49
49
  */
50
- export declare function leveragePriceOf(quote: Pick<UnifiedQuote, "openedPrice" | "requestedOpenPrice">): bigint;
50
+ export declare function leveragePriceOf(quote: Pick<UnifiedQuote, "initialOpenedPrice" | "openedPrice" | "requestedOpenPrice">): bigint;
51
51
  //# sourceMappingURL=open-price.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"open-price.d.ts","sourceRoot":"","sources":["../../src/quotes/open-price.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,MAAM,GAAG,SAAS,CAE/F;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,OAAO,CAEvF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,oBAAoB,CAAC,GAAG,MAAM,CAEnG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,oBAAoB,CAAC,GAAG,MAAM,CAEvG"}
1
+ {"version":3,"file":"open-price.d.ts","sourceRoot":"","sources":["../../src/quotes/open-price.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,MAAM,GAAG,SAAS,CAE/F;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,OAAO,CAEvF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,oBAAoB,CAAC,GAAG,MAAM,CAEnG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,oBAAoB,GAAG,aAAa,GAAG,oBAAoB,CAAC,GACrF,MAAM,CAIR"}
@@ -9,7 +9,7 @@ function n(t) {
9
9
  return e(t) ?? t.requestedOpenPrice;
10
10
  }
11
11
  function r(e) {
12
- return e.requestedOpenPrice === 0n ? e.openedPrice ?? 0n : e.requestedOpenPrice;
12
+ return e.initialOpenedPrice !== void 0 && e.initialOpenedPrice !== 0n ? e.initialOpenedPrice : e.openedPrice !== void 0 && e.openedPrice !== 0n ? e.openedPrice : e.requestedOpenPrice;
13
13
  }
14
14
  //#endregion
15
15
  export { t as hasUnsettledOpenPrice, r as leveragePriceOf, n as openPriceOf, e as settledOpenPriceOf };
@@ -1 +1 @@
1
- {"version":3,"file":"open-price.js","names":[],"sources":["../../src/quotes/open-price.ts"],"sourcesContent":["import type { UnifiedQuote } from \"./unified-quote\";\n\n/**\n * A quote's settled open price, or `undefined` while it has none — a pending or\n * optimistic open.\n *\n * A quote carries `openedPrice: 0n` in the same situations it carries\n * `undefined`, so both collapse to `undefined` here; callers never have to\n * repeat that pair of checks. Substituting `requestedOpenPrice` would value the\n * position at a fill that never happened — use {@link openPriceOf} only where\n * that fallback is intended.\n *\n * @param quote - Any object carrying the quote's settled open price.\n * @returns The settled price in wei, or `undefined` when it is not settled yet.\n */\nexport function settledOpenPriceOf(quote: Pick<UnifiedQuote, \"openedPrice\">): bigint | undefined {\n return quote.openedPrice !== undefined && quote.openedPrice !== 0n ? quote.openedPrice : undefined;\n}\n\n/**\n * Whether a quote still lacks a settled open price (a pending or optimistic\n * open). The exact complement of {@link settledOpenPriceOf}.\n *\n * @param quote - Any object carrying the quote's settled open price.\n * @returns `true` while the open price is unsettled.\n */\nexport function hasUnsettledOpenPrice(quote: Pick<UnifiedQuote, \"openedPrice\">): boolean {\n return settledOpenPriceOf(quote) === undefined;\n}\n\n/**\n * A quote's open price for valuation: the settled `openedPrice`, else the\n * `requestedOpenPrice` it was submitted at.\n *\n * This is the fallback rule shared by `aggregateGroupMetrics` and\n * `toGroupTpSlChildren`, so a group's weighted open price and its TP/SL\n * children are always valued against the same number.\n *\n * @param quote - Any object carrying the quote's open prices.\n * @returns The valuation price in wei.\n */\nexport function openPriceOf(quote: Pick<UnifiedQuote, \"openedPrice\" | \"requestedOpenPrice\">): bigint {\n return settledOpenPriceOf(quote) ?? quote.requestedOpenPrice;\n}\n\n/**\n * A quote's reference price for leverage: the `requestedOpenPrice`, else the\n * settled `openedPrice`.\n *\n * **The precedence is the inverse of {@link openPriceOf}** and that is\n * deliberate: leverage describes the position as it was *opened*, so the price\n * the trader committed to wins, and the settled fill steps in only when there is\n * no requested price on record. Shared by `aggregateGroupMetrics` and\n * `calculateQuoteLeverage`, which agree on this rule while deliberately\n * differing in numeric strategy (exact bigint vs. float).\n *\n * @param quote - Any object carrying the quote's open prices.\n * @returns The leverage reference price in wei, or `0n` when neither is set.\n */\nexport function leveragePriceOf(quote: Pick<UnifiedQuote, \"openedPrice\" | \"requestedOpenPrice\">): bigint {\n return quote.requestedOpenPrice !== 0n ? quote.requestedOpenPrice : (quote.openedPrice ?? 0n);\n}\n"],"mappings":";AAeA,SAAgB,EAAmB,GAA8D;CAC/F,OAAO,EAAM,gBAAgB,KAAA,KAAa,EAAM,gBAAgB,KAAK,EAAM,cAAc,KAAA;AAC3F;AASA,SAAgB,EAAsB,GAAmD;CACvF,OAAO,EAAmB,CAAK,MAAM,KAAA;AACvC;AAaA,SAAgB,EAAY,GAAyE;CACnG,OAAO,EAAmB,CAAK,KAAK,EAAM;AAC5C;AAgBA,SAAgB,EAAgB,GAAyE;CACvG,OAAO,EAAM,uBAAuB,KAAiC,EAAM,eAAe,KAAjD,EAAM;AACjD"}
1
+ {"version":3,"file":"open-price.js","names":[],"sources":["../../src/quotes/open-price.ts"],"sourcesContent":["import type { UnifiedQuote } from \"./unified-quote\";\n\n/**\n * A quote's settled open price, or `undefined` while it has none — a pending or\n * optimistic open.\n *\n * A quote carries `openedPrice: 0n` in the same situations it carries\n * `undefined`, so both collapse to `undefined` here; callers never have to\n * repeat that pair of checks. Substituting `requestedOpenPrice` would value the\n * position at a fill that never happened — use {@link openPriceOf} only where\n * that fallback is intended.\n *\n * @param quote - Any object carrying the quote's settled open price.\n * @returns The settled price in wei, or `undefined` when it is not settled yet.\n */\nexport function settledOpenPriceOf(quote: Pick<UnifiedQuote, \"openedPrice\">): bigint | undefined {\n return quote.openedPrice !== undefined && quote.openedPrice !== 0n ? quote.openedPrice : undefined;\n}\n\n/**\n * Whether a quote still lacks a settled open price (a pending or optimistic\n * open). The exact complement of {@link settledOpenPriceOf}.\n *\n * @param quote - Any object carrying the quote's settled open price.\n * @returns `true` while the open price is unsettled.\n */\nexport function hasUnsettledOpenPrice(quote: Pick<UnifiedQuote, \"openedPrice\">): boolean {\n return settledOpenPriceOf(quote) === undefined;\n}\n\n/**\n * A quote's open price for valuation: the settled `openedPrice`, else the\n * `requestedOpenPrice` it was submitted at.\n *\n * This is the fallback rule shared by `aggregateGroupMetrics` and\n * `toGroupTpSlChildren`, so a group's weighted open price and its TP/SL\n * children are always valued against the same number.\n *\n * @param quote - Any object carrying the quote's open prices.\n * @returns The valuation price in wei.\n */\nexport function openPriceOf(quote: Pick<UnifiedQuote, \"openedPrice\" | \"requestedOpenPrice\">): bigint {\n return settledOpenPriceOf(quote) ?? quote.requestedOpenPrice;\n}\n\n/**\n * A quote's reference price for leverage, in descending precedence: the\n * `initialOpenedPrice` it first opened at, else the settled `openedPrice`, else\n * the current `requestedOpenPrice`.\n *\n * Leverage describes the position *as it was opened*, so the original open price\n * wins — `requestedOpenPrice` can drift after edits and is only the last resort.\n * A `0n` (or absent) price at any tier falls through to the next. Shared by\n * `aggregateGroupMetrics` and `calculateQuoteLeverage`, which agree on this rule\n * while deliberately differing in numeric strategy (exact bigint vs. float).\n *\n * @param quote - Any object carrying the quote's open prices.\n * @returns The leverage reference price in wei, or `0n` when none is set.\n */\nexport function leveragePriceOf(\n quote: Pick<UnifiedQuote, \"initialOpenedPrice\" | \"openedPrice\" | \"requestedOpenPrice\">,\n): bigint {\n if (quote.initialOpenedPrice !== undefined && quote.initialOpenedPrice !== 0n) return quote.initialOpenedPrice;\n if (quote.openedPrice !== undefined && quote.openedPrice !== 0n) return quote.openedPrice;\n return quote.requestedOpenPrice;\n}\n"],"mappings":";AAeA,SAAgB,EAAmB,GAA8D;CAC/F,OAAO,EAAM,gBAAgB,KAAA,KAAa,EAAM,gBAAgB,KAAK,EAAM,cAAc,KAAA;AAC3F;AASA,SAAgB,EAAsB,GAAmD;CACvF,OAAO,EAAmB,CAAK,MAAM,KAAA;AACvC;AAaA,SAAgB,EAAY,GAAyE;CACnG,OAAO,EAAmB,CAAK,KAAK,EAAM;AAC5C;AAgBA,SAAgB,EACd,GACQ;CAGR,OAFI,EAAM,uBAAuB,KAAA,KAAa,EAAM,uBAAuB,KAAW,EAAM,qBACxF,EAAM,gBAAgB,KAAA,KAAa,EAAM,gBAAgB,KAAW,EAAM,cACvE,EAAM;AACf"}
@@ -4,10 +4,12 @@
4
4
  export interface CalculateQuoteLeverageParameters {
5
5
  /** Quote quantity. */
6
6
  quantity: bigint;
7
- /** Quote's requested open price (used as the notional reference price). */
8
- requestedOpenPrice: bigint;
9
- /** Settled open price (wei) — fallback reference used only when `requestedOpenPrice` is `0`. */
7
+ /** Original open price the position first opened at — the preferred reference. */
8
+ initialOpenedPrice?: bigint;
9
+ /** Settled open price (wei) — reference used when `initialOpenedPrice` is absent. */
10
10
  openedPrice?: bigint;
11
+ /** Current requested open price (wei) — last-resort reference; may drift after edits. */
12
+ requestedOpenPrice: bigint;
11
13
  /** Locked-margin legs (partyA + partyB) committed when the quote opened. */
12
14
  lockedValues: {
13
15
  cva: bigint;
@@ -19,9 +21,9 @@ export interface CalculateQuoteLeverageParameters {
19
21
  /**
20
22
  * Quote leverage as a decimal string.
21
23
  *
22
- * `leverage = quantity × (requestedOpenPrice ?? openedPrice) / (CVA + LF + partyAMM + partyBMM)`
23
- * — the requested open price is the reference; the settled `openedPrice` steps in
24
- * only when the requested price is `0`.
24
+ * `leverage = quantity × (initialOpenedPrice ?? openedPrice ?? requestedOpenPrice) / (CVA + LF + partyAMM + partyBMM)`
25
+ * — the original open price is the reference; the settled `openedPrice` then the
26
+ * current `requestedOpenPrice` step in as it is absent (see {@link leveragePriceOf}).
25
27
  *
26
28
  * Returns `"0"` when the locked-margin sum is zero (i.e. the quote has no
27
29
  * partyA-locked collateral on record yet) or when any input is non-finite.
@@ -1 +1 @@
1
- {"version":3,"file":"calculate-quote-leverage.d.ts","sourceRoot":"","sources":["../../../src/quotes/upnl/calculate-quote-leverage.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gGAAgG;IAChG,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,YAAY,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,gCAAgC,GAAG,MAAM,CAkB3F"}
1
+ {"version":3,"file":"calculate-quote-leverage.d.ts","sourceRoot":"","sources":["../../../src/quotes/upnl/calculate-quote-leverage.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yFAAyF;IACzF,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,YAAY,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,gCAAgC,GAAG,MAAM,CAkB3F"}
@@ -1 +1 @@
1
- {"version":3,"file":"calculate-quote-leverage.js","names":[],"sources":["../../../src/quotes/upnl/calculate-quote-leverage.ts"],"sourcesContent":["import { formatUnits } from \"viem\";\nimport { leveragePriceOf } from \"../open-price\";\n\n/** Decimal places of an 18-decimal-wei fixed-point value. */\nconst WEI_DECIMALS = 18;\n\n/**\n * Inputs for {@link calculateQuoteLeverage}. All bigint fields are 18-decimal wei.\n */\nexport interface CalculateQuoteLeverageParameters {\n /** Quote quantity. */\n quantity: bigint;\n /** Quote's requested open price (used as the notional reference price). */\n requestedOpenPrice: bigint;\n /** Settled open price (wei) — fallback reference used only when `requestedOpenPrice` is `0`. */\n openedPrice?: bigint;\n /** Locked-margin legs (partyA + partyB) committed when the quote opened. */\n lockedValues: { cva: bigint; lf: bigint; partyAmm: bigint; partyBmm: bigint };\n}\n\n/**\n * Quote leverage as a decimal string.\n *\n * `leverage = quantity × (requestedOpenPrice ?? openedPrice) / (CVA + LF + partyAMM + partyBMM)`\n * — the requested open price is the reference; the settled `openedPrice` steps in\n * only when the requested price is `0`.\n *\n * Returns `\"0\"` when the locked-margin sum is zero (i.e. the quote has no\n * partyA-locked collateral on record yet) or when any input is non-finite.\n *\n * @example\n * ```ts\n * const lev = calculateQuoteLeverage({\n * quantity: 1_000_000_000_000_000_000n,\n * requestedOpenPrice: 50_000_000_000_000_000_000n,\n * lockedValues: { cva: 1_000_000_000_000_000_000n, lf: 500_000_000_000_000_000n, partyAmm: 1_500_000_000_000_000_000n },\n * });\n * ```\n */\nexport function calculateQuoteLeverage(parameters: CalculateQuoteLeverageParameters): string {\n const referencePriceWei = leveragePriceOf(parameters);\n const quantity = Number(formatUnits(parameters.quantity, WEI_DECIMALS));\n const referencePrice = Number(formatUnits(referencePriceWei, WEI_DECIMALS));\n const lockedSum = Number(\n formatUnits(\n parameters.lockedValues.cva +\n parameters.lockedValues.lf +\n parameters.lockedValues.partyAmm +\n parameters.lockedValues.partyBmm,\n WEI_DECIMALS,\n ),\n );\n if (!Number.isFinite(quantity) || !Number.isFinite(referencePrice) || !Number.isFinite(lockedSum)) return \"0\";\n if (lockedSum === 0) return \"0\";\n const leverage = (quantity * referencePrice) / lockedSum;\n if (!Number.isFinite(leverage)) return \"0\";\n return String(leverage);\n}\n"],"mappings":";;;AAIA,IAAM,IAAe;AAmCrB,SAAgB,EAAuB,GAAsD;CAC3F,IAAM,IAAoB,EAAgB,CAAU,GAC9C,IAAW,OAAO,EAAY,EAAW,UAAU,CAAY,CAAC,GAChE,IAAiB,OAAO,EAAY,GAAmB,CAAY,CAAC,GACpE,IAAY,OAChB,EACE,EAAW,aAAa,MACtB,EAAW,aAAa,KACxB,EAAW,aAAa,WACxB,EAAW,aAAa,UAC1B,CACF,CACF;CAEA,IADI,CAAC,OAAO,SAAS,CAAQ,KAAK,CAAC,OAAO,SAAS,CAAc,KAAK,CAAC,OAAO,SAAS,CAAS,KAC5F,MAAc,GAAG,OAAO;CAC5B,IAAM,IAAY,IAAW,IAAkB;CAE/C,OADK,OAAO,SAAS,CAAQ,IACtB,OAAO,CAAQ,IADiB;AAEzC"}
1
+ {"version":3,"file":"calculate-quote-leverage.js","names":[],"sources":["../../../src/quotes/upnl/calculate-quote-leverage.ts"],"sourcesContent":["import { formatUnits } from \"viem\";\nimport { leveragePriceOf } from \"../open-price\";\n\n/** Decimal places of an 18-decimal-wei fixed-point value. */\nconst WEI_DECIMALS = 18;\n\n/**\n * Inputs for {@link calculateQuoteLeverage}. All bigint fields are 18-decimal wei.\n */\nexport interface CalculateQuoteLeverageParameters {\n /** Quote quantity. */\n quantity: bigint;\n /** Original open price the position first opened at — the preferred reference. */\n initialOpenedPrice?: bigint;\n /** Settled open price (wei) — reference used when `initialOpenedPrice` is absent. */\n openedPrice?: bigint;\n /** Current requested open price (wei) — last-resort reference; may drift after edits. */\n requestedOpenPrice: bigint;\n /** Locked-margin legs (partyA + partyB) committed when the quote opened. */\n lockedValues: { cva: bigint; lf: bigint; partyAmm: bigint; partyBmm: bigint };\n}\n\n/**\n * Quote leverage as a decimal string.\n *\n * `leverage = quantity × (initialOpenedPrice ?? openedPrice ?? requestedOpenPrice) / (CVA + LF + partyAMM + partyBMM)`\n * — the original open price is the reference; the settled `openedPrice` then the\n * current `requestedOpenPrice` step in as it is absent (see {@link leveragePriceOf}).\n *\n * Returns `\"0\"` when the locked-margin sum is zero (i.e. the quote has no\n * partyA-locked collateral on record yet) or when any input is non-finite.\n *\n * @example\n * ```ts\n * const lev = calculateQuoteLeverage({\n * quantity: 1_000_000_000_000_000_000n,\n * requestedOpenPrice: 50_000_000_000_000_000_000n,\n * lockedValues: { cva: 1_000_000_000_000_000_000n, lf: 500_000_000_000_000_000n, partyAmm: 1_500_000_000_000_000_000n },\n * });\n * ```\n */\nexport function calculateQuoteLeverage(parameters: CalculateQuoteLeverageParameters): string {\n const referencePriceWei = leveragePriceOf(parameters);\n const quantity = Number(formatUnits(parameters.quantity, WEI_DECIMALS));\n const referencePrice = Number(formatUnits(referencePriceWei, WEI_DECIMALS));\n const lockedSum = Number(\n formatUnits(\n parameters.lockedValues.cva +\n parameters.lockedValues.lf +\n parameters.lockedValues.partyAmm +\n parameters.lockedValues.partyBmm,\n WEI_DECIMALS,\n ),\n );\n if (!Number.isFinite(quantity) || !Number.isFinite(referencePrice) || !Number.isFinite(lockedSum)) return \"0\";\n if (lockedSum === 0) return \"0\";\n const leverage = (quantity * referencePrice) / lockedSum;\n if (!Number.isFinite(leverage)) return \"0\";\n return String(leverage);\n}\n"],"mappings":";;;AAIA,IAAM,IAAe;AAqCrB,SAAgB,EAAuB,GAAsD;CAC3F,IAAM,IAAoB,EAAgB,CAAU,GAC9C,IAAW,OAAO,EAAY,EAAW,UAAU,CAAY,CAAC,GAChE,IAAiB,OAAO,EAAY,GAAmB,CAAY,CAAC,GACpE,IAAY,OAChB,EACE,EAAW,aAAa,MACtB,EAAW,aAAa,KACxB,EAAW,aAAa,WACxB,EAAW,aAAa,UAC1B,CACF,CACF;CAEA,IADI,CAAC,OAAO,SAAS,CAAQ,KAAK,CAAC,OAAO,SAAS,CAAc,KAAK,CAAC,OAAO,SAAS,CAAS,KAC5F,MAAc,GAAG,OAAO;CAC5B,IAAM,IAAY,IAAW,IAAkB;CAE/C,OADK,OAAO,SAAS,CAAQ,IACtB,OAAO,CAAQ,IADiB;AAEzC"}
@@ -9,8 +9,8 @@
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
- * filterQueryOptions({ chainId: 999, user: "0x…", offset: 0n, query: { staleTime: 1 } });
13
- * // → { chainId: 999, user: "0x…", offset: "0" }
12
+ * filterQueryOptions({ chainId: 42161, user: "0x…", offset: 0n, query: { staleTime: 1 } });
13
+ * // → { chainId: 42161, user: "0x…", offset: "0" }
14
14
  * ```
15
15
  */
16
16
  export declare function filterQueryOptions<type extends Record<string, unknown>>(options: type): Record<string, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","names":[],"sources":["../../../src/shared/utils/query.ts"],"sourcesContent":["/**\n * Keys that configure TanStack Query behavior rather than identify the data.\n * They are stripped before an options object is turned into a query key so two\n * calls that differ only in, say, `staleTime` still share a cache entry.\n *\n * `accessToken` is stripped too: a bearer credential is never a cache dimension\n * (two calls that differ only by a refreshed token still hit the same entry) and\n * must never leak into a devtools-visible key.\n */\nconst NON_KEY_FIELDS = new Set([\"query\", \"enabled\", \"config\", \"accessToken\"]);\n\n/**\n * Turn an options object into the plain, hashable payload that trails a query\n * key. Strips TanStack control fields and functions, drops `undefined`, and\n * recursively serializes `bigint` to its decimal string (TanStack's default key\n * hash throws on `bigint`).\n *\n * @param options - The query-options object passed to a factory.\n * @returns A plain object safe to embed in a query key.\n *\n * @example\n * ```ts\n * filterQueryOptions({ chainId: 999, user: \"0x…\", offset: 0n, query: { staleTime: 1 } });\n * // → { chainId: 999, user: \"0x…\", offset: \"0\" }\n * ```\n */\nexport function filterQueryOptions<type extends Record<string, unknown>>(options: type): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(options)) {\n if (NON_KEY_FIELDS.has(key)) continue;\n if (value === undefined) continue;\n if (typeof value === \"function\") continue;\n result[key] = serializeBigInts(value);\n }\n return result;\n}\n\n/**\n * Recursively replace every `bigint` in a value with its decimal string form so\n * the result survives `JSON.stringify`-based query-key hashing.\n */\nfunction serializeBigInts(value: unknown): unknown {\n if (typeof value === \"bigint\") return value.toString();\n if (Array.isArray(value)) return value.map(serializeBigInts);\n if (value !== null && typeof value === \"object\") {\n const result: Record<string, unknown> = {};\n for (const [key, nested] of Object.entries(value)) {\n result[key] = serializeBigInts(nested);\n }\n return result;\n }\n return value;\n}\n"],"mappings":";AASA,IAAM,IAAiB,IAAI,IAAI;CAAC;CAAS;CAAW;CAAU;AAAa,CAAC;AAiB5E,SAAgB,EAAyD,GAAwC;CAC/G,IAAM,IAAkC,CAAC;CACzC,KAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,CAAO,GAC3C,EAAe,IAAI,CAAG,KACtB,MAAU,KAAA,KACV,OAAO,KAAU,eACrB,EAAO,KAAO,EAAiB,CAAK;CAEtC,OAAO;AACT;AAMA,SAAS,EAAiB,GAAyB;CACjD,IAAI,OAAO,KAAU,UAAU,OAAO,EAAM,SAAS;CACrD,IAAI,MAAM,QAAQ,CAAK,GAAG,OAAO,EAAM,IAAI,CAAgB;CAC3D,IAAsB,OAAO,KAAU,YAAnC,GAA6C;EAC/C,IAAM,IAAkC,CAAC;EACzC,KAAK,IAAM,CAAC,GAAK,MAAW,OAAO,QAAQ,CAAK,GAC9C,EAAO,KAAO,EAAiB,CAAM;EAEvC,OAAO;CACT;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"query.js","names":[],"sources":["../../../src/shared/utils/query.ts"],"sourcesContent":["/**\n * Keys that configure TanStack Query behavior rather than identify the data.\n * They are stripped before an options object is turned into a query key so two\n * calls that differ only in, say, `staleTime` still share a cache entry.\n *\n * `accessToken` is stripped too: a bearer credential is never a cache dimension\n * (two calls that differ only by a refreshed token still hit the same entry) and\n * must never leak into a devtools-visible key.\n */\nconst NON_KEY_FIELDS = new Set([\"query\", \"enabled\", \"config\", \"accessToken\"]);\n\n/**\n * Turn an options object into the plain, hashable payload that trails a query\n * key. Strips TanStack control fields and functions, drops `undefined`, and\n * recursively serializes `bigint` to its decimal string (TanStack's default key\n * hash throws on `bigint`).\n *\n * @param options - The query-options object passed to a factory.\n * @returns A plain object safe to embed in a query key.\n *\n * @example\n * ```ts\n * filterQueryOptions({ chainId: 42161, user: \"0x…\", offset: 0n, query: { staleTime: 1 } });\n * // → { chainId: 42161, user: \"0x…\", offset: \"0\" }\n * ```\n */\nexport function filterQueryOptions<type extends Record<string, unknown>>(options: type): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(options)) {\n if (NON_KEY_FIELDS.has(key)) continue;\n if (value === undefined) continue;\n if (typeof value === \"function\") continue;\n result[key] = serializeBigInts(value);\n }\n return result;\n}\n\n/**\n * Recursively replace every `bigint` in a value with its decimal string form so\n * the result survives `JSON.stringify`-based query-key hashing.\n */\nfunction serializeBigInts(value: unknown): unknown {\n if (typeof value === \"bigint\") return value.toString();\n if (Array.isArray(value)) return value.map(serializeBigInts);\n if (value !== null && typeof value === \"object\") {\n const result: Record<string, unknown> = {};\n for (const [key, nested] of Object.entries(value)) {\n result[key] = serializeBigInts(nested);\n }\n return result;\n }\n return value;\n}\n"],"mappings":";AASA,IAAM,IAAiB,IAAI,IAAI;CAAC;CAAS;CAAW;CAAU;AAAa,CAAC;AAiB5E,SAAgB,EAAyD,GAAwC;CAC/G,IAAM,IAAkC,CAAC;CACzC,KAAK,IAAM,CAAC,GAAK,MAAU,OAAO,QAAQ,CAAO,GAC3C,EAAe,IAAI,CAAG,KACtB,MAAU,KAAA,KACV,OAAO,KAAU,eACrB,EAAO,KAAO,EAAiB,CAAK;CAEtC,OAAO;AACT;AAMA,SAAS,EAAiB,GAAyB;CACjD,IAAI,OAAO,KAAU,UAAU,OAAO,EAAM,SAAS;CACrD,IAAI,MAAM,QAAQ,CAAK,GAAG,OAAO,EAAM,IAAI,CAAgB;CAC3D,IAAsB,OAAO,KAAU,YAAnC,GAA6C;EAC/C,IAAM,IAAkC,CAAC;EACzC,KAAK,IAAM,CAAC,GAAK,MAAW,OAAO,QAAQ,CAAK,GAC9C,EAAO,KAAO,EAAiB,CAAM;EAEvC,OAAO;CACT;CACA,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { symmioAbi as e } from "../../symmio-contracts/abi/v0.8.5/symmio.js";
1
+ import { symmioAbi as e } from "../../symmio-contracts/abi/v0.8.6/symmio.js";
2
2
  import { callAsSubAccount as t } from "../../symmio-contracts/symmio/internal/call-as-sub-account.js";
3
3
  import { encodeFunctionData as n } from "viem";
4
4
  //#region src/solvers/force-close/force-close-position.ts
@@ -1 +1 @@
1
- {"version":3,"file":"force-close-position.js","names":[],"sources":["../../../src/solvers/force-close/force-close-position.ts"],"sourcesContent":["import { encodeFunctionData, type Address, type Hash } from \"viem\";\nimport type { Config } from \"../../core/config\";\nimport type { Compute, WriteContractParameter } from \"../../shared/types/properties\";\nimport { symmioAbi } from \"../../symmio-contracts/abi/v0.8.5/symmio\";\nimport { callAsSubAccount } from \"../../symmio-contracts/symmio/internal/call-as-sub-account\";\nimport type { HighLowPriceSig } from \"../../symmio-contracts/symmio/types\";\n\n/**\n * Parameters for {@link forceClosePosition}.\n */\nexport type ForceClosePositionParameters = Compute<\n WriteContractParameter & {\n /**\n * The subaccount (partyA) that owns the position. The call is routed through\n * the AccountLayer `_call` proxy so the core sees this subaccount as the\n * caller; the connected wallet must be its on-chain `owner`.\n */\n account: Address;\n /** The `CLOSE_PENDING` limit quote id to force-close. */\n quoteId: bigint;\n /** The Muon `priceRange` attestation — see `getForceClosePriceSig`. */\n sig: HighLowPriceSig;\n }\n>;\n\n/** Return type of {@link forceClosePosition}: the submitted transaction hash. */\nexport type ForceClosePositionReturnType = Hash;\n\n/**\n * Send the single-call force close (`forceClosePosition(quoteId, sig)`) — the\n * low-level write. The eligibility gate and Muon signature must already be\n * resolved (use {@link forceCloseAuto} for the end-to-end flow). Routed through\n * `AccountLayer._call(account, …)`, so the connected wallet must be the\n * subaccount's `owner`.\n *\n * @remarks\n * Reverts `ForceActionsFacet: Cross partyB mode enabled` when the position's\n * partyB runs cross-margin settlement — that solver needs the (not-yet-supported)\n * 3-step `initializeForceClose` / `finalizeForceClose` flow.\n *\n * @param config - The SDK config (must have a `getWalletClient` resolver).\n * @param parameters - The owning subaccount, the quote id, the Muon sig, optional `from` / pre-flight / chain id.\n * @returns The submitted transaction hash.\n * @throws {SymmError} when the chain is unsupported or no wallet client is available.\n *\n * @example\n * ```ts\n * const hash = await forceClosePosition(config, { account: \"0xsub…\", quoteId: 42n, sig });\n * ```\n */\nexport async function forceClosePosition(\n config: Config,\n parameters: ForceClosePositionParameters,\n): Promise<ForceClosePositionReturnType> {\n const { chainId, account, quoteId, sig } = parameters;\n\n const data = encodeFunctionData({\n abi: symmioAbi,\n functionName: \"forceClosePosition\",\n args: [quoteId, sig],\n });\n\n return callAsSubAccount(config, {\n account,\n data,\n chainId,\n from: parameters.from,\n simulateBeforeWrite: parameters.simulateBeforeWrite,\n });\n}\n"],"mappings":";;;;AAkDA,eAAsB,EACpB,GACA,GACuC;CACvC,IAAM,EAAE,YAAS,YAAS,YAAS,WAAQ;CAQ3C,OAAO,EAAiB,GAAQ;EAC9B;EACA,MARW,EAAmB;GAC9B,KAAK;GACL,cAAc;GACd,MAAM,CAAC,GAAS,CAAG;EACrB,CAIE;EACA;EACA,MAAM,EAAW;EACjB,qBAAqB,EAAW;CAClC,CAAC;AACH"}
1
+ {"version":3,"file":"force-close-position.js","names":[],"sources":["../../../src/solvers/force-close/force-close-position.ts"],"sourcesContent":["import { encodeFunctionData, type Address, type Hash } from \"viem\";\nimport type { Config } from \"../../core/config\";\nimport type { Compute, WriteContractParameter } from \"../../shared/types/properties\";\nimport { symmioAbi } from \"../../symmio-contracts/abi/v0.8.6/symmio\";\nimport { callAsSubAccount } from \"../../symmio-contracts/symmio/internal/call-as-sub-account\";\nimport type { HighLowPriceSig } from \"../../symmio-contracts/symmio/types\";\n\n/**\n * Parameters for {@link forceClosePosition}.\n */\nexport type ForceClosePositionParameters = Compute<\n WriteContractParameter & {\n /**\n * The subaccount (partyA) that owns the position. The call is routed through\n * the AccountLayer `_call` proxy so the core sees this subaccount as the\n * caller; the connected wallet must be its on-chain `owner`.\n */\n account: Address;\n /** The `CLOSE_PENDING` limit quote id to force-close. */\n quoteId: bigint;\n /** The Muon `priceRange` attestation — see `getForceClosePriceSig`. */\n sig: HighLowPriceSig;\n }\n>;\n\n/** Return type of {@link forceClosePosition}: the submitted transaction hash. */\nexport type ForceClosePositionReturnType = Hash;\n\n/**\n * Send the single-call force close (`forceClosePosition(quoteId, sig)`) — the\n * low-level write. The eligibility gate and Muon signature must already be\n * resolved (use {@link forceCloseAuto} for the end-to-end flow). Routed through\n * `AccountLayer._call(account, …)`, so the connected wallet must be the\n * subaccount's `owner`.\n *\n * @remarks\n * Reverts `ForceActionsFacet: Cross partyB mode enabled` when the position's\n * partyB runs cross-margin settlement — that solver needs the (not-yet-supported)\n * 3-step `initializeForceClose` / `finalizeForceClose` flow.\n *\n * @param config - The SDK config (must have a `getWalletClient` resolver).\n * @param parameters - The owning subaccount, the quote id, the Muon sig, optional `from` / pre-flight / chain id.\n * @returns The submitted transaction hash.\n * @throws {SymmError} when the chain is unsupported or no wallet client is available.\n *\n * @example\n * ```ts\n * const hash = await forceClosePosition(config, { account: \"0xsub…\", quoteId: 42n, sig });\n * ```\n */\nexport async function forceClosePosition(\n config: Config,\n parameters: ForceClosePositionParameters,\n): Promise<ForceClosePositionReturnType> {\n const { chainId, account, quoteId, sig } = parameters;\n\n const data = encodeFunctionData({\n abi: symmioAbi,\n functionName: \"forceClosePosition\",\n args: [quoteId, sig],\n });\n\n return callAsSubAccount(config, {\n account,\n data,\n chainId,\n from: parameters.from,\n simulateBeforeWrite: parameters.simulateBeforeWrite,\n });\n}\n"],"mappings":";;;;AAkDA,eAAsB,EACpB,GACA,GACuC;CACvC,IAAM,EAAE,YAAS,YAAS,YAAS,WAAQ;CAQ3C,OAAO,EAAiB,GAAQ;EAC9B;EACA,MARW,EAAmB;GAC9B,KAAK;GACL,cAAc;GACd,MAAM,CAAC,GAAS,CAAG;EACrB,CAIE;EACA;EACA,MAAM,EAAW;EACjB,qBAAqB,EAAW;CAClC,CAAC;AACH"}
@@ -1,4 +1,4 @@
1
- import { symmioAbi as e } from "../../symmio-contracts/abi/v0.8.5/symmio.js";
1
+ import { symmioAbi as e } from "../../symmio-contracts/abi/v0.8.6/symmio.js";
2
2
  //#region src/solvers/force-close/get-force-close-params.ts
3
3
  async function t(t, n) {
4
4
  let { chainId: r, symbolId: i } = n, { addresses: a } = t.getChainConfig(r), [o, s, c, l] = await t.getClient({ chainId: r }).multicall({
@@ -1 +1 @@
1
- {"version":3,"file":"get-force-close-params.js","names":[],"sources":["../../../src/solvers/force-close/get-force-close-params.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { symmioAbi } from \"../../symmio-contracts/abi/v0.8.5/symmio\";\nimport type { ForceCloseParams } from \"./types\";\n\n/**\n * Parameters for {@link getForceCloseParams}.\n */\nexport type GetForceCloseParametersParameters = Compute<\n ChainIdParameter & {\n /** Market symbol id — `forceCloseGapRatio` is per-symbol. */\n symbolId: bigint;\n }\n>;\n\n/** Return type of {@link getForceCloseParams}. */\nexport type GetForceCloseParametersReturnType = ForceCloseParams;\n\n/**\n * Read the protocol force-close parameters — the cooldowns, price penalty,\n * minimum signature period, and the symbol's gap ratio — in **one multicall**.\n * These drive the eligibility gate ({@link checkForceCloseEligibility}) and the\n * price checks, so they are always read together.\n *\n * @param config - The SDK config.\n * @param parameters - The market `symbolId` (for `forceCloseGapRatio`) and optional chain id.\n * @returns The resolved {@link ForceCloseParams}.\n * @throws {SymmError} when the chain is not supported.\n *\n * @example\n * ```ts\n * const { firstCooldown, secondCooldown, pricePenalty, gapRatio } = await getForceCloseParams(config, {\n * symbolId: 1n,\n * });\n * ```\n */\nexport async function getForceCloseParams(\n config: Config,\n parameters: GetForceCloseParametersParameters,\n): Promise<GetForceCloseParametersReturnType> {\n const { chainId, symbolId } = parameters;\n const { addresses } = config.getChainConfig(chainId);\n const client = config.getClient({ chainId });\n\n const [cooldowns, pricePenalty, minSigPeriod, gapRatio] = await client.multicall({\n allowFailure: false,\n contracts: [\n { address: addresses.symmioAddress, abi: symmioAbi, functionName: \"forceCloseCooldowns\" },\n { address: addresses.symmioAddress, abi: symmioAbi, functionName: \"forceClosePricePenalty\" },\n { address: addresses.symmioAddress, abi: symmioAbi, functionName: \"forceCloseMinSigPeriod\" },\n { address: addresses.symmioAddress, abi: symmioAbi, functionName: \"forceCloseGapRatio\", args: [symbolId] },\n ] as const,\n });\n\n const [firstCooldown, secondCooldown] = cooldowns;\n return { firstCooldown, secondCooldown, pricePenalty, minSigPeriod, gapRatio };\n}\n"],"mappings":";;AAoCA,eAAsB,EACpB,GACA,GAC4C;CAC5C,IAAM,EAAE,YAAS,gBAAa,GACxB,EAAE,iBAAc,EAAO,eAAe,CAAO,GAG7C,CAAC,GAAW,GAAc,GAAc,KAAY,MAF3C,EAAO,UAAU,EAAE,WAAQ,CAEsB,EAAO,UAAU;EAC/E,cAAc;EACd,WAAW;GACT;IAAE,SAAS,EAAU;IAAe,KAAK;IAAW,cAAc;GAAsB;GACxF;IAAE,SAAS,EAAU;IAAe,KAAK;IAAW,cAAc;GAAyB;GAC3F;IAAE,SAAS,EAAU;IAAe,KAAK;IAAW,cAAc;GAAyB;GAC3F;IAAE,SAAS,EAAU;IAAe,KAAK;IAAW,cAAc;IAAsB,MAAM,CAAC,CAAQ;GAAE;EAC3G;CACF,CAAC,GAEK,CAAC,GAAe,KAAkB;CACxC,OAAO;EAAE;EAAe;EAAgB;EAAc;EAAc;CAAS;AAC/E"}
1
+ {"version":3,"file":"get-force-close-params.js","names":[],"sources":["../../../src/solvers/force-close/get-force-close-params.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { symmioAbi } from \"../../symmio-contracts/abi/v0.8.6/symmio\";\nimport type { ForceCloseParams } from \"./types\";\n\n/**\n * Parameters for {@link getForceCloseParams}.\n */\nexport type GetForceCloseParametersParameters = Compute<\n ChainIdParameter & {\n /** Market symbol id — `forceCloseGapRatio` is per-symbol. */\n symbolId: bigint;\n }\n>;\n\n/** Return type of {@link getForceCloseParams}. */\nexport type GetForceCloseParametersReturnType = ForceCloseParams;\n\n/**\n * Read the protocol force-close parameters — the cooldowns, price penalty,\n * minimum signature period, and the symbol's gap ratio — in **one multicall**.\n * These drive the eligibility gate ({@link checkForceCloseEligibility}) and the\n * price checks, so they are always read together.\n *\n * @param config - The SDK config.\n * @param parameters - The market `symbolId` (for `forceCloseGapRatio`) and optional chain id.\n * @returns The resolved {@link ForceCloseParams}.\n * @throws {SymmError} when the chain is not supported.\n *\n * @example\n * ```ts\n * const { firstCooldown, secondCooldown, pricePenalty, gapRatio } = await getForceCloseParams(config, {\n * symbolId: 1n,\n * });\n * ```\n */\nexport async function getForceCloseParams(\n config: Config,\n parameters: GetForceCloseParametersParameters,\n): Promise<GetForceCloseParametersReturnType> {\n const { chainId, symbolId } = parameters;\n const { addresses } = config.getChainConfig(chainId);\n const client = config.getClient({ chainId });\n\n const [cooldowns, pricePenalty, minSigPeriod, gapRatio] = await client.multicall({\n allowFailure: false,\n contracts: [\n { address: addresses.symmioAddress, abi: symmioAbi, functionName: \"forceCloseCooldowns\" },\n { address: addresses.symmioAddress, abi: symmioAbi, functionName: \"forceClosePricePenalty\" },\n { address: addresses.symmioAddress, abi: symmioAbi, functionName: \"forceCloseMinSigPeriod\" },\n { address: addresses.symmioAddress, abi: symmioAbi, functionName: \"forceCloseGapRatio\", args: [symbolId] },\n ] as const,\n });\n\n const [firstCooldown, secondCooldown] = cooldowns;\n return { firstCooldown, secondCooldown, pricePenalty, minSigPeriod, gapRatio };\n}\n"],"mappings":";;AAoCA,eAAsB,EACpB,GACA,GAC4C;CAC5C,IAAM,EAAE,YAAS,gBAAa,GACxB,EAAE,iBAAc,EAAO,eAAe,CAAO,GAG7C,CAAC,GAAW,GAAc,GAAc,KAAY,MAF3C,EAAO,UAAU,EAAE,WAAQ,CAEsB,EAAO,UAAU;EAC/E,cAAc;EACd,WAAW;GACT;IAAE,SAAS,EAAU;IAAe,KAAK;IAAW,cAAc;GAAsB;GACxF;IAAE,SAAS,EAAU;IAAe,KAAK;IAAW,cAAc;GAAyB;GAC3F;IAAE,SAAS,EAAU;IAAe,KAAK;IAAW,cAAc;GAAyB;GAC3F;IAAE,SAAS,EAAU;IAAe,KAAK;IAAW,cAAc;IAAsB,MAAM,CAAC,CAAQ;GAAE;EAC3G;CACF,CAAC,GAEK,CAAC,GAAe,KAAkB;CACxC,OAAO;EAAE;EAAe;EAAgB;EAAc;EAAc;CAAS;AAC/E"}
@@ -1,4 +1,4 @@
1
- import { symmioAbi as e } from "../../../symmio-contracts/abi/v0.8.5/symmio.js";
1
+ import { symmioAbi as e } from "../../../symmio-contracts/abi/v0.8.6/symmio.js";
2
2
  import { encodeFunctionData as t } from "viem";
3
3
  //#region src/solvers/instant-close/shared/calldata.ts
4
4
  function n(n) {
@@ -1 +1 @@
1
- {"version":3,"file":"calldata.js","names":[],"sources":["../../../../src/solvers/instant-close/shared/calldata.ts"],"sourcesContent":["import { encodeFunctionData, type Hex } from \"viem\";\nimport { symmioAbi } from \"../../../symmio-contracts/abi/v0.8.5/symmio\";\n\n/**\n * Parameters for {@link encodeRequestToClosePosition}.\n */\nexport interface EncodeRequestToClosePositionParameters {\n /** Quote id of the open position. */\n quoteId: bigint;\n /** Slippage-adjusted close price (wei, 1e18 fixed-point). */\n closePrice: bigint;\n /** Quantity to close (wei, 1e18 fixed-point). */\n quantityToClose: bigint;\n /** Order type contract value (1 = MARKET). */\n orderType: number;\n /** Unix-seconds deadline. */\n deadline: bigint;\n}\n\n/**\n * Encode calldata for `Symmio.requestToClosePosition(quoteId, closePrice,\n * quantityToClose, orderType, deadline)`.\n */\nexport function encodeRequestToClosePosition(parameters: EncodeRequestToClosePositionParameters): Hex {\n return encodeFunctionData({\n abi: symmioAbi,\n functionName: \"requestToClosePosition\",\n args: [\n parameters.quoteId,\n parameters.closePrice,\n parameters.quantityToClose,\n parameters.orderType,\n parameters.deadline,\n ],\n });\n}\n"],"mappings":";;;AAuBA,SAAgB,EAA6B,GAAyD;CACpG,OAAO,EAAmB;EACxB,KAAK;EACL,cAAc;EACd,MAAM;GACJ,EAAW;GACX,EAAW;GACX,EAAW;GACX,EAAW;GACX,EAAW;EACb;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"calldata.js","names":[],"sources":["../../../../src/solvers/instant-close/shared/calldata.ts"],"sourcesContent":["import { encodeFunctionData, type Hex } from \"viem\";\nimport { symmioAbi } from \"../../../symmio-contracts/abi/v0.8.6/symmio\";\n\n/**\n * Parameters for {@link encodeRequestToClosePosition}.\n */\nexport interface EncodeRequestToClosePositionParameters {\n /** Quote id of the open position. */\n quoteId: bigint;\n /** Slippage-adjusted close price (wei, 1e18 fixed-point). */\n closePrice: bigint;\n /** Quantity to close (wei, 1e18 fixed-point). */\n quantityToClose: bigint;\n /** Order type contract value (1 = MARKET). */\n orderType: number;\n /** Unix-seconds deadline. */\n deadline: bigint;\n}\n\n/**\n * Encode calldata for `Symmio.requestToClosePosition(quoteId, closePrice,\n * quantityToClose, orderType, deadline)`.\n */\nexport function encodeRequestToClosePosition(parameters: EncodeRequestToClosePositionParameters): Hex {\n return encodeFunctionData({\n abi: symmioAbi,\n functionName: \"requestToClosePosition\",\n args: [\n parameters.quoteId,\n parameters.closePrice,\n parameters.quantityToClose,\n parameters.orderType,\n parameters.deadline,\n ],\n });\n}\n"],"mappings":";;;AAuBA,SAAgB,EAA6B,GAAyD;CACpG,OAAO,EAAmB;EACxB,KAAK;EACL,cAAc;EACd,MAAM;GACJ,EAAW;GACX,EAAW;GACX,EAAW;GACX,EAAW;GACX,EAAW;EACb;CACF,CAAC;AACH"}
@@ -0,0 +1,129 @@
1
+ import { Address } from 'viem';
2
+ import { Config } from '../../../core/config/index.js';
3
+ import { Compute, ReadSolverParameter } from '../../../shared/types/properties.js';
4
+ import { FeeForUser } from '../../../symmio-contracts/symmio/actions/get-fee-for-user.js';
5
+ import { InstantOpenMarketData, PositionType } from '../shared/types.js';
6
+ /**
7
+ * Parameters for {@link getInstantOpenFees}. A subset of
8
+ * `PrepareInstantOpenParameters` — the trade intent plus optional pre-fetched
9
+ * data; every pre-filled optional field skips its network fetch.
10
+ */
11
+ export type GetInstantOpenFeesParameters = Compute<ReadSolverParameter & {
12
+ /** Sub-account / partyA address the platform fee rates are read for. */
13
+ subAccountAddress: Address;
14
+ /** Market identification + optional pre-fetched precision metadata. */
15
+ market: InstantOpenMarketData;
16
+ /** Trade side. */
17
+ positionType: PositionType;
18
+ /** Collateral (USD) the user enters as initial margin. Decimal string. */
19
+ initialMargin: string;
20
+ /** Position leverage (integer ≥ 1). */
21
+ leverage: number;
22
+ /**
23
+ * Slippage tolerance percent (e.g. `5` for 5%). **Required on majors
24
+ * (non-lowcap) solvers.** On a lowcap solver it may be omitted to
25
+ * auto-derive from the dry-run estimate plus 4% headroom — the same rule
26
+ * as `prepareInstantOpenParams`, so the preview prices what the open will
27
+ * actually charge.
28
+ */
29
+ slippage?: number;
30
+ /** Pre-fetched mark price as decimal string. When omitted, fetched via the price service. */
31
+ markPrice?: string;
32
+ /** Pre-fetched on-chain fee rates (matches `getFeeForUser` return). When omitted, fetched. */
33
+ feeRates?: FeeForUser;
34
+ /**
35
+ * Pre-fetched solver estimated open (fill) price as decimal string —
36
+ * **lowcap/Enigma only**; ignored on any other solver kind. When omitted
37
+ * on a lowcap solver, fetched via `GET /estimated-price`.
38
+ */
39
+ estimatedOpenPrice?: string;
40
+ }>;
41
+ /**
42
+ * Fee legs every solver kind charges on an instant open.
43
+ */
44
+ export interface BaseInstantOpenFees {
45
+ /** Platform open fee: `getFeeForUser.openFee × notional / 1e18` (decimal string). */
46
+ platformOpenFee: string;
47
+ /** Platform close fee, provisioned at open: `getFeeForUser.closeFee × notional / 1e18` (decimal string). */
48
+ platformCloseFee: string;
49
+ /** Leveraged notional the fee rates were applied to (decimal string). */
50
+ notional: string;
51
+ /** Sum of every fee leg on this quote (decimal string). */
52
+ totalFee: string;
53
+ }
54
+ /**
55
+ * Fee breakdown for a **lowcap (Enigma)** instant open. Extends the platform
56
+ * legs with the solver fees and the settlement provision the solver charges
57
+ * from the VA balance.
58
+ */
59
+ export interface EnigmaInstantOpenFees extends BaseInstantOpenFees {
60
+ /** Discriminant: these fees were priced for an Enigma (lowcap) solver. */
61
+ kind: "enigma";
62
+ /** Solver open fee: `hedgerFeeOpen × notional` (decimal string). */
63
+ openSolverFee: string;
64
+ /**
65
+ * Solver close fee provisioned at open (decimal string). Because the holding
66
+ * time is unknown at open and an early close costs more, this is the
67
+ * worst-case `earlyRate × notional` from the market's close-fee schedule
68
+ * (falling back to the flat `hedgerFeeClose × notional` when no schedule is
69
+ * available).
70
+ */
71
+ closeSolverFee: string;
72
+ /**
73
+ * Expected settlement loss vs the dry-run estimate: side-aware
74
+ * `max(0, adverse fill deviation × quantity)` (decimal string). `"0"` when
75
+ * no usable estimate exists.
76
+ */
77
+ expectedSettlementLoss: string;
78
+ }
79
+ /**
80
+ * Fee breakdown for a **majors (Rasa)** instant open — platform legs only.
81
+ */
82
+ export interface RasaInstantOpenFees extends BaseInstantOpenFees {
83
+ /** Discriminant: these fees were priced for a Rasa (majors) solver. */
84
+ kind: "rasa";
85
+ }
86
+ /**
87
+ * Return type of {@link getInstantOpenFees}. Narrow on `kind` to reach the
88
+ * lowcap-only legs.
89
+ */
90
+ export type GetInstantOpenFeesReturnType = EnigmaInstantOpenFees | RasaInstantOpenFees;
91
+ /**
92
+ * Preview every fee a new instant-open quote pays, separated by leg plus the
93
+ * total — without signing or submitting anything.
94
+ *
95
+ * Mirrors the exact resolution and math `prepareInstantOpenParams` uses, so
96
+ * the preview equals what the open charges for the same inputs:
97
+ *
98
+ * - **Both kinds**: `platformOpenFee` + `platformCloseFee`
99
+ * (on-chain `getFeeForUser` rates × leveraged notional).
100
+ * - **Lowcap (Enigma) only**: `openSolverFee` (`hedgerFeeOpen × notional`) +
101
+ * `closeSolverFee` (the worst-case close rate × notional — see
102
+ * {@link EnigmaInstantOpenFees.closeSolverFee}) and
103
+ * `expectedSettlementLoss` (dry-run estimate vs mark) — the legs the solver
104
+ * charges from the VA balance.
105
+ *
106
+ * `totalFee` sums every leg, including the settlement provision — it is the
107
+ * amount the user must fund even though the settlement leg is a provision
108
+ * rather than a fee the solver keeps.
109
+ *
110
+ * @throws {SymmError} `SLIPPAGE_REQUIRED` on majors without `slippage`;
111
+ * `INVALID_SLIPPAGE` / `INVALID_TRADE_PARAMETERS` /
112
+ * `RESOLVE_MARKET_NOT_FOUND` / `RESOLVE_MARK_PRICE_NOT_FOUND` for invalid or
113
+ * unresolvable inputs.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const fees = await getInstantOpenFees(config, {
118
+ * subAccountAddress,
119
+ * market: { id: 1 },
120
+ * positionType: PositionType.LONG,
121
+ * initialMargin: "100",
122
+ * leverage: 5,
123
+ * });
124
+ * if (fees.kind === "enigma") console.log(fees.openSolverFee, fees.expectedSettlementLoss);
125
+ * console.log(fees.totalFee);
126
+ * ```
127
+ */
128
+ export declare function getInstantOpenFees(config: Config, parameters: GetInstantOpenFeesParameters): Promise<GetInstantOpenFeesReturnType>;
129
+ //# sourceMappingURL=get-instant-open-fees.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-instant-open-fees.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/get-instant-open-fees/get-instant-open-fees.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2DAA2D,CAAC;AAS5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE3E;;;;GAIG;AACH,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAChD,mBAAmB,GAAG;IACpB,wEAAwE;IACxE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,uEAAuE;IACvE,MAAM,EAAE,qBAAqB,CAAC;IAC9B,kBAAkB;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,0EAA0E;IAC1E,aAAa,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CACF,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qFAAqF;IACrF,eAAe,EAAE,MAAM,CAAC;IACxB,4GAA4G;IAC5G,gBAAgB,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,0EAA0E;IAC1E,IAAI,EAAE,QAAQ,CAAC;IACf,oEAAoE;IACpE,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG,qBAAqB,GAAG,mBAAmB,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,4BAA4B,GACvC,OAAO,CAAC,4BAA4B,CAAC,CA8IvC"}