@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
@@ -1 +1 @@
1
- {"version":3,"file":"trade-math.js","names":[],"sources":["../../../../src/solvers/instant-open/shared/trade-math.ts"],"sourcesContent":["import { parseEther, RoundingMode, toDecimal } from \"@symmio/utils/decimal\";\nimport { PositionType } from \"./types\";\n\n/**\n * Unix-seconds remaining for a MARKET-order deadline (5 minutes).\n */\nexport const MARKET_ORDER_DEADLINE_SECONDS = 300n;\n\n/**\n * Compute a unix-seconds `deadline` for a MARKET order.\n *\n * @param now - Optional override for `Math.floor(Date.now() / 1000)`. Useful for tests.\n */\nexport function getMarketOrderDeadline(now?: bigint): bigint {\n const base = now ?? BigInt(Math.floor(Date.now() / 1000));\n return base + MARKET_ORDER_DEADLINE_SECONDS;\n}\n\n/**\n * Unix-seconds remaining for a LIMIT-order deadline (15 minutes). A resting\n * limit order lives longer than a market fill, so it gets a wider window.\n */\nexport const LIMIT_ORDER_DEADLINE_SECONDS = 900n;\n\n/**\n * Compute a unix-seconds `deadline` for a LIMIT order (default 15 minutes).\n *\n * @param now - Optional override for `Math.floor(Date.now() / 1000)`. Useful for tests.\n */\nexport function getLimitOrderDeadline(now?: bigint): bigint {\n const base = now ?? BigInt(Math.floor(Date.now() / 1000));\n return base + LIMIT_ORDER_DEADLINE_SECONDS;\n}\n\n/**\n * Parameters for {@link calculateTradeParams}.\n */\nexport interface CalculateTradeParamsParameters {\n /** Mark price as decimal string (e.g. `\"50123.45\"`). */\n markPrice: string;\n /** Slippage percent (e.g. `5` for 5%). */\n slippage: number;\n /** Position side: `\"LONG\"` or `\"SHORT\"`. */\n positionType: PositionType;\n /** User input as decimal string. Interpreted as collateral when `inputField === \"PRICE\"`. */\n userInput: string;\n /** Input mode. `\"PRICE\"` = userInput is USD collateral; `\"TOKEN\"` = userInput is base token amount. */\n inputField: \"PRICE\" | \"TOKEN\";\n /** Position leverage (integer ≥ 1). */\n leverage: number;\n /** Price precision (decimals). */\n pricePrecision: number;\n /** Quantity precision (decimals). */\n quantityPrecision: number;\n /** Solver locked-param percentages (e.g. `\"0.02\"` for 2%). */\n cvaPercent?: string;\n /** Solver locked-param percentages (e.g. `\"0.01\"` for 1%). */\n lfPercent?: string;\n /** Solver locked-param percentages. */\n partyAmmPercent?: string;\n /** Solver locked-param percentages. */\n partyBmmPercent?: string;\n}\n\n/**\n * Return type of {@link calculateTradeParams}.\n *\n * All values are decimal strings. Convert to 18-decimal `bigint` with\n * `parseEther(...).toFixed(0)` (or {@link toWeiBigInt}) before passing to a\n * contract call.\n */\nexport interface CalculateTradeParamsReturnType {\n /** Open price with slippage applied, trimmed to `pricePrecision`. */\n requestedOpenPrice: string;\n /** Base quantity (no leverage), trimmed to `quantityPrecision`. */\n quantityBasic: string;\n /** Leveraged quantity (`quantityBasic × leverage`), trimmed to `quantityPrecision`. */\n quantity: string;\n /** Base notional (`quantityBasic × requestedOpenPrice`). */\n notionalBasic: string;\n /** Leveraged notional (`notionalBasic × leverage`). */\n notional: string;\n /** CVA locked margin (`notionalBasic × cvaPercent / 100`). */\n cva: string;\n /** LF locked margin (`notionalBasic × lfPercent / 100`). */\n lf: string;\n /** PartyA maintenance margin. */\n partyAmm: string;\n /** PartyB maintenance margin. */\n partyBmm: string;\n}\n\n/**\n * Pure trade-parameters calculator for lowcap MARKET orders.\n *\n * Steps:\n * 1. `requestedOpenPrice = markPrice × (1 ± slippage/100)` trimmed to `pricePrecision`.\n * 2. `quantityBasic = userInput / requestedOpenPrice` (when `inputField === \"PRICE\"`) or\n * `userInput` (when `inputField === \"TOKEN\"`) trimmed to `quantityPrecision`.\n * 3. `notionalBasic = quantityBasic × requestedOpenPrice`.\n * 4. `cva / lf / partyAmm / partyBmm = notionalBasic × percent / 100`.\n * 5. `quantity = quantityBasic × leverage` trimmed to `quantityPrecision`.\n * 6. `notional = notionalBasic × leverage`.\n *\n * @returns `null` when `markPrice` is zero/NaN or `userInput` is invalid.\n */\nexport function calculateTradeParams(\n parameters: CalculateTradeParamsParameters,\n): CalculateTradeParamsReturnType | null {\n const {\n markPrice,\n slippage,\n positionType,\n userInput,\n inputField,\n leverage,\n pricePrecision,\n quantityPrecision,\n cvaPercent,\n lfPercent,\n partyAmmPercent,\n partyBmmPercent,\n } = parameters;\n\n const markPriceDec = toDecimal(markPrice);\n if (markPriceDec.isZero() || markPriceDec.isNaN()) return null;\n const userInputDec = toDecimal(userInput);\n if (userInputDec.isZero() || userInputDec.isNaN()) return null;\n\n const signedSlippage = positionType === PositionType.SHORT ? slippage : -slippage;\n const slippageFactor = toDecimal(100 - signedSlippage).div(100);\n const requestedOpenPrice = markPriceDec.times(slippageFactor).toFixed(pricePrecision, RoundingMode.ROUND_DOWN);\n\n const quantityBasic =\n inputField === \"PRICE\"\n ? userInputDec.div(requestedOpenPrice).toFixed(quantityPrecision, RoundingMode.ROUND_DOWN)\n : userInputDec.toFixed(quantityPrecision, RoundingMode.ROUND_DOWN);\n\n const notionalBasic = toDecimal(quantityBasic).times(requestedOpenPrice).toString();\n const cva = toDecimal(notionalBasic).times(toDecimal(cvaPercent)).div(100).toString();\n const lf = toDecimal(notionalBasic).times(toDecimal(lfPercent)).div(100).toString();\n const partyAmm = toDecimal(notionalBasic).times(toDecimal(partyAmmPercent)).div(100).toString();\n const partyBmm = toDecimal(notionalBasic).times(toDecimal(partyBmmPercent)).div(100).toString();\n\n const quantity = toDecimal(quantityBasic).times(leverage).toFixed(quantityPrecision, RoundingMode.ROUND_DOWN);\n const notional = toDecimal(notionalBasic).times(leverage).toString();\n\n return {\n requestedOpenPrice,\n quantityBasic,\n quantity,\n notionalBasic,\n notional,\n cva,\n lf,\n partyAmm,\n partyBmm,\n };\n}\n\n/**\n * Parameters for {@link calculateMargin}.\n */\nexport interface CalculateMarginParameters {\n /** Position side. */\n positionType: PositionType;\n /** Mark price (decimal string). */\n markPrice: string;\n /** Base quantity from {@link calculateTradeParams}. */\n quantityBasic: string;\n /** CVA from {@link calculateTradeParams}. */\n cva: string;\n /** LF from {@link calculateTradeParams}. */\n lf: string;\n /** PartyA maintenance margin from {@link calculateTradeParams}. */\n partyAmm: string;\n /** Solver locked-param percents (passed when recomputing for SHORT). */\n cvaPercent?: string;\n /** Solver locked-param percents. */\n lfPercent?: string;\n /** Solver locked-param percents. */\n partyAmmPercent?: string;\n /** On-chain platform fee as decimal string (from {@link computePlatformFee}). */\n platformFee: string;\n}\n\n/**\n * Compute the `addMargin` amount for lowcap isolation.\n *\n * - **LONG**: `margin = cva + lf + partyAmm + platformFee`.\n * - **SHORT**: recompute the locked values at `markPrice`,\n * then sum + `platformFee`.\n *\n * @returns Margin as decimal string.\n */\nexport function calculateMargin(parameters: CalculateMarginParameters): string {\n const {\n positionType,\n markPrice,\n quantityBasic,\n cva,\n lf,\n partyAmm,\n cvaPercent,\n lfPercent,\n partyAmmPercent,\n platformFee,\n } = parameters;\n\n if (positionType === PositionType.LONG) {\n return toDecimal(cva).plus(lf).plus(partyAmm).plus(platformFee).toString();\n }\n\n const marginPrice = toDecimal(markPrice);\n const notionalBasicMargin = toDecimal(quantityBasic).times(marginPrice).toString();\n const cvaMargin = toDecimal(notionalBasicMargin).times(toDecimal(cvaPercent)).div(100).toString();\n const lfMargin = toDecimal(notionalBasicMargin).times(toDecimal(lfPercent)).div(100).toString();\n const partyAmmMargin = toDecimal(notionalBasicMargin).times(toDecimal(partyAmmPercent)).div(100).toString();\n\n return toDecimal(cvaMargin).plus(lfMargin).plus(partyAmmMargin).plus(platformFee).toString();\n}\n\n/**\n * On-chain `getFeeForUser` result, in 18-decimal fixed-point.\n */\nexport interface ComputePlatformFeeRates {\n /** Open fee rate as 18-decimal `bigint`. */\n openFee: bigint;\n /** Close fee rate as 18-decimal `bigint`. */\n closeFee: bigint;\n}\n\n/**\n * Compute the total platform fee for an open + close round trip.\n *\n * `(openFee × initialNotional + closeFee × closeNotional) / 1e18`.\n *\n * @param rates - Fee rates from `getFeeForUser`.\n * @param initialNotional - Notional at open, decimal string.\n * @param closeNotional - Notional at close, decimal string.\n * @returns Total fee as decimal string.\n */\nexport function computePlatformFee(\n rates: ComputePlatformFeeRates,\n initialNotional: string,\n closeNotional: string,\n): string {\n const open = toDecimal(rates.openFee.toString()).times(initialNotional);\n const close = toDecimal(rates.closeFee.toString()).times(closeNotional);\n return open.plus(close).div(toDecimal(\"1e18\")).toString();\n}\n\n/**\n * Convert a decimal string to an 18-decimal-fixed-point `bigint`.\n *\n * Wrapper over `parseEther` from `@symmio/utils/decimal` that returns\n * the wei value as `bigint` (truncated, no rounding) suitable for contract calls.\n */\nexport function toWeiBigInt(value: string): bigint {\n return BigInt(parseEther(value).toFixed(0, RoundingMode.ROUND_DOWN));\n}\n\n/**\n * Inputs for {@link calculateAvailableInstantOpenMargin}. All amounts are\n * 18-decimal wei / fixed-point.\n */\nexport interface CalculateAvailableInstantOpenMarginParameters {\n /** SubAccount available (deallocated) balance from `getAccountBalanceOf`; 1e18-scaled. */\n balance: bigint;\n /** Open fee rate (18-decimal fixed-point) from `getFeeForUser`. */\n openFee: bigint;\n /** Close fee rate (18-decimal fixed-point) from `getFeeForUser`. */\n closeFee: bigint;\n /** Slippage as an 18-decimal fraction (5% → `5n * 10n ** 16n`). */\n slippageFractionWei: bigint;\n /** Requested leverage (integer ≥ 1). */\n leverage: number;\n /** LONG skips the slippage cap; SHORT applies it. */\n positionType: PositionType;\n}\n\n/**\n * Maximum initial margin an instant open can spend. Shaves the raw available\n * balance for fees (both sides, charged on the leveraged notional) and — for\n * SHORT only — a worst-case slippage-fill buffer. Pure `bigint`; clamps to `0n`.\n *\n * ```text\n * available = balance\n * × max(0, 1 − slippageFactor) // SHORT: slippage, LONG: 0\n * × max(0, 1 − leverage × (openFee + closeFee))\n * ```\n *\n * A SHORT sizes quantity off `requestOpenPrice = markPrice × (1 − s)` (below\n * mark), so a worse fill inflates notional by up to `1 / (1 − s)`; capping usable\n * balance at `balance × (1 − s)` covers it. A LONG sets the request above mark,\n * so fills deflate notional and need no cap.\n *\n * @returns spendable margin in 18-decimal wei.\n * @example\n * ```ts\n * const max = calculateAvailableInstantOpenMargin({\n * balance,\n * openFee,\n * closeFee,\n * slippageFractionWei: 5n * 10n ** 16n, // 5%\n * leverage: 10,\n * positionType: PositionType.SHORT,\n * });\n * ```\n */\nexport function calculateAvailableInstantOpenMargin(parameters: CalculateAvailableInstantOpenMarginParameters): bigint {\n const { balance, openFee, closeFee, slippageFractionWei, leverage, positionType } = parameters;\n const ONE_E18 = 10n ** 18n;\n\n const slippageMultiplier =\n positionType === PositionType.SHORT\n ? slippageFractionWei >= ONE_E18\n ? 0n\n : ONE_E18 - slippageFractionWei\n : ONE_E18;\n\n const leverageScaled = BigInt(leverage) * (openFee + closeFee);\n const feeMultiplier = leverageScaled >= ONE_E18 ? 0n : ONE_E18 - leverageScaled;\n\n const afterSlippage = (balance * slippageMultiplier) / ONE_E18;\n return (afterSlippage * feeMultiplier) / ONE_E18;\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"trade-math.js","names":[],"sources":["../../../../src/solvers/instant-open/shared/trade-math.ts"],"sourcesContent":["import { parseEther, RoundingMode, toDecimal } from \"@symmio/utils/decimal\";\nimport { calculateSolverCloseFee } from \"../../shared/solver-close-fee\";\nimport { PositionType } from \"./types\";\n\n/**\n * Unix-seconds remaining for a MARKET-order deadline (5 minutes).\n */\nexport const MARKET_ORDER_DEADLINE_SECONDS = 300n;\n\n/**\n * Compute a unix-seconds `deadline` for a MARKET order.\n *\n * @param now - Optional override for `Math.floor(Date.now() / 1000)`. Useful for tests.\n */\nexport function getMarketOrderDeadline(now?: bigint): bigint {\n const base = now ?? BigInt(Math.floor(Date.now() / 1000));\n return base + MARKET_ORDER_DEADLINE_SECONDS;\n}\n\n/**\n * Unix-seconds remaining for a LIMIT-order deadline (15 minutes). A resting\n * limit order lives longer than a market fill, so it gets a wider window.\n */\nexport const LIMIT_ORDER_DEADLINE_SECONDS = 900n;\n\n/**\n * Compute a unix-seconds `deadline` for a LIMIT order (default 15 minutes).\n *\n * @param now - Optional override for `Math.floor(Date.now() / 1000)`. Useful for tests.\n */\nexport function getLimitOrderDeadline(now?: bigint): bigint {\n const base = now ?? BigInt(Math.floor(Date.now() / 1000));\n return base + LIMIT_ORDER_DEADLINE_SECONDS;\n}\n\n/**\n * Parameters for {@link calculateTradeParams}.\n */\nexport interface CalculateTradeParamsParameters {\n /** Mark price as decimal string (e.g. `\"50123.45\"`). */\n markPrice: string;\n /** Slippage percent (e.g. `5` for 5%). */\n slippage: number;\n /** Position side: `\"LONG\"` or `\"SHORT\"`. */\n positionType: PositionType;\n /** User input as decimal string. Interpreted as collateral when `inputField === \"PRICE\"`. */\n userInput: string;\n /** Input mode. `\"PRICE\"` = userInput is USD collateral; `\"TOKEN\"` = userInput is base token amount. */\n inputField: \"PRICE\" | \"TOKEN\";\n /** Position leverage (integer ≥ 1). */\n leverage: number;\n /** Price precision (decimals). */\n pricePrecision: number;\n /** Quantity precision (decimals). */\n quantityPrecision: number;\n /** Solver locked-param percentages (e.g. `\"0.02\"` for 2%). */\n cvaPercent?: string;\n /** Solver locked-param percentages (e.g. `\"0.01\"` for 1%). */\n lfPercent?: string;\n /** Solver locked-param percentages. */\n partyAmmPercent?: string;\n /** Solver locked-param percentages. */\n partyBmmPercent?: string;\n}\n\n/**\n * Return type of {@link calculateTradeParams}.\n *\n * All values are decimal strings. Convert to 18-decimal `bigint` with\n * `parseEther(...).toFixed(0)` (or {@link toWeiBigInt}) before passing to a\n * contract call.\n */\nexport interface CalculateTradeParamsReturnType {\n /** Open price with slippage applied, trimmed to `pricePrecision`. */\n requestedOpenPrice: string;\n /** Base quantity (no leverage), trimmed to `quantityPrecision`. */\n quantityBasic: string;\n /** Leveraged quantity (`quantityBasic × leverage`), trimmed to `quantityPrecision`. */\n quantity: string;\n /** Base notional (`quantityBasic × requestedOpenPrice`). */\n notionalBasic: string;\n /** Leveraged notional (`notionalBasic × leverage`). */\n notional: string;\n /** CVA locked margin (`notionalBasic × cvaPercent / 100`). */\n cva: string;\n /** LF locked margin (`notionalBasic × lfPercent / 100`). */\n lf: string;\n /** PartyA maintenance margin. */\n partyAmm: string;\n /** PartyB maintenance margin. */\n partyBmm: string;\n}\n\n/**\n * Pure trade-parameters calculator for lowcap MARKET orders.\n *\n * Steps:\n * 1. `requestedOpenPrice = markPrice × (1 ± slippage/100)` trimmed to `pricePrecision`.\n * 2. `quantityBasic = userInput / markPrice` (when `inputField === \"PRICE\"`) or\n * `userInput` (when `inputField === \"TOKEN\"`) trimmed to `quantityPrecision`.\n * Sized at the raw mark price, never the slippage-adjusted bound: `V × L` of\n * notional at mark `M` is `V × L / M` units on every fill, so changing the\n * slippage setting moves only the price bound and never resizes the position.\n * 3. `notionalBasic = quantityBasic × requestedOpenPrice`.\n * 4. `cva / lf / partyAmm / partyBmm = notionalBasic × percent / 100`.\n * 5. `quantity = quantityBasic × leverage` trimmed to `quantityPrecision`.\n * 6. `notional = notionalBasic × leverage`.\n *\n * @returns `null` when `markPrice` is zero/NaN or `userInput` is invalid.\n */\nexport function calculateTradeParams(\n parameters: CalculateTradeParamsParameters,\n): CalculateTradeParamsReturnType | null {\n const {\n markPrice,\n slippage,\n positionType,\n userInput,\n inputField,\n leverage,\n pricePrecision,\n quantityPrecision,\n cvaPercent,\n lfPercent,\n partyAmmPercent,\n partyBmmPercent,\n } = parameters;\n\n const markPriceDec = toDecimal(markPrice);\n if (markPriceDec.isZero() || markPriceDec.isNaN()) return null;\n const userInputDec = toDecimal(userInput);\n if (userInputDec.isZero() || userInputDec.isNaN()) return null;\n\n const signedSlippage = positionType === PositionType.SHORT ? slippage : -slippage;\n const slippageFactor = toDecimal(100 - signedSlippage).div(100);\n const requestedOpenPrice = markPriceDec.times(slippageFactor).toFixed(pricePrecision, RoundingMode.ROUND_DOWN);\n\n const quantityBasic =\n inputField === \"PRICE\"\n ? userInputDec.div(markPriceDec).toFixed(quantityPrecision, RoundingMode.ROUND_DOWN)\n : userInputDec.toFixed(quantityPrecision, RoundingMode.ROUND_DOWN);\n\n const notionalBasic = toDecimal(quantityBasic).times(requestedOpenPrice).toString();\n const cva = toDecimal(notionalBasic).times(toDecimal(cvaPercent)).div(100).toString();\n const lf = toDecimal(notionalBasic).times(toDecimal(lfPercent)).div(100).toString();\n const partyAmm = toDecimal(notionalBasic).times(toDecimal(partyAmmPercent)).div(100).toString();\n const partyBmm = toDecimal(notionalBasic).times(toDecimal(partyBmmPercent)).div(100).toString();\n\n const quantity = toDecimal(quantityBasic).times(leverage).toFixed(quantityPrecision, RoundingMode.ROUND_DOWN);\n const notional = toDecimal(notionalBasic).times(leverage).toString();\n\n return {\n requestedOpenPrice,\n quantityBasic,\n quantity,\n notionalBasic,\n notional,\n cva,\n lf,\n partyAmm,\n partyBmm,\n };\n}\n\n/**\n * Solver fees charged on the position, funded from the VA at open.\n */\nexport interface SolverFees {\n /** `hedgerFeeOpen × notional`, decimal string. */\n openSolverFee: string;\n /**\n * Close fee provisioned at open, decimal string. The solver charges more to\n * close a freshly opened position, so — since the holding time is unknown at\n * open — this provisions the **worst case**: `hedgerFeeCloseEarlyRate ×\n * notional` when the early-rate field is supplied, else the flat\n * `hedgerFeeClose × notional`.\n */\n closeSolverFee: string;\n}\n\n/**\n * Compute the solver's open and close fees on the leveraged notional.\n *\n * The solver charges its fees from the **VA balance**, so both legs must ride\n * the `addMargin` transfer from the SubAccount into the VA. The open leg is\n * `hedgerFeeOpen × notional`. The close leg is provisioned for the **worst\n * case**, because the holding time is unknown at open and an early close costs\n * more: when `hedgerFeeCloseEarlyRate` is supplied it uses the peak rate (the\n * rate at holding time 0); without it it falls back to the flat\n * `hedgerFeeClose`. An absent, NaN, or negative rate contributes `\"0\"`.\n */\nexport function calculateSolverFees({\n notional,\n hedgerFeeOpen,\n hedgerFeeClose,\n hedgerFeeCloseEarlyRate,\n hedgerFeeCloseEarlyThreshold,\n hedgerFeeCloseStandardThreshold,\n}: {\n /** Leveraged notional (decimal string). */\n notional: string;\n /** Solver open-fee rate as a decimal fraction string (e.g. `\"0.0004\"`). */\n hedgerFeeOpen: string | undefined;\n /** Solver standard close-fee rate as a decimal fraction string. Used when no early rate is given. */\n hedgerFeeClose: string | undefined;\n /** Early (peak) close-fee rate; when given, the close leg provisions this worst-case rate. */\n hedgerFeeCloseEarlyRate?: string;\n /** Early-window length in seconds (paired with `hedgerFeeCloseEarlyRate`). */\n hedgerFeeCloseEarlyThreshold?: number;\n /** Standard-rate threshold in seconds (paired with `hedgerFeeCloseEarlyRate`). */\n hedgerFeeCloseStandardThreshold?: number;\n}): SolverFees {\n const notionalDec = toDecimal(notional);\n const toFee = (rate: string | undefined) => {\n const rateDec = toDecimal(rate);\n if (rateDec.isNaN() || rateDec.isNegative() || notionalDec.isNaN()) return \"0\";\n return notionalDec.times(rateDec).toString();\n };\n const closeSolverFee =\n hedgerFeeCloseEarlyRate !== undefined\n ? calculateSolverCloseFee(\n {\n hedgerFeeClose: hedgerFeeClose ?? \"0\",\n hedgerFeeCloseEarlyRate,\n hedgerFeeCloseEarlyThreshold: hedgerFeeCloseEarlyThreshold ?? 0,\n hedgerFeeCloseStandardThreshold: hedgerFeeCloseStandardThreshold ?? 0,\n },\n { notional, holdingSeconds: 0 },\n )\n : toFee(hedgerFeeClose);\n return { openSolverFee: toFee(hedgerFeeOpen), closeSolverFee };\n}\n\n/**\n * Expected settlement loss charged from the VA when the fill lands away from\n * the mark price the order was sized at.\n *\n * Side-aware: a LONG loses when the expected fill is **above** mark\n * (`(expectedFillPrice − markPrice) × quantity`), a SHORT when it is **below**\n * (`(markPrice − expectedFillPrice) × quantity`). Clamped at zero — a\n * favorable expected fill never shrinks the transfer. Returns `\"0\"` when no\n * usable estimate exists.\n */\nexport function calculateExpectedSettlementLoss({\n positionType,\n markPrice,\n expectedFillPrice,\n quantity,\n}: {\n positionType: PositionType;\n /** Mark price the order was sized at (decimal string). */\n markPrice: string;\n /** Solver's estimated fill price (decimal string), when available. */\n expectedFillPrice: string | undefined;\n /** Leveraged order quantity (decimal string). */\n quantity: string;\n}): string {\n if (expectedFillPrice === undefined) return \"0\";\n const mark = toDecimal(markPrice);\n const fill = toDecimal(expectedFillPrice);\n const quantityDec = toDecimal(quantity);\n if (mark.isNaN() || fill.isNaN() || fill.isZero() || quantityDec.isNaN()) return \"0\";\n\n const loss =\n positionType === PositionType.SHORT ? mark.minus(fill).times(quantityDec) : fill.minus(mark).times(quantityDec);\n return loss.isNegative() || loss.isNaN() ? \"0\" : loss.toString();\n}\n\n/**\n * Parameters for {@link calculateMargin}.\n */\nexport interface CalculateMarginParameters {\n /** Position side. */\n positionType: PositionType;\n /** Mark price (decimal string). */\n markPrice: string;\n /** Base quantity from {@link calculateTradeParams}. */\n quantityBasic: string;\n /** CVA from {@link calculateTradeParams}. */\n cva: string;\n /** LF from {@link calculateTradeParams}. */\n lf: string;\n /** PartyA maintenance margin from {@link calculateTradeParams}. */\n partyAmm: string;\n /** Solver locked-param percents (passed when recomputing for SHORT). */\n cvaPercent?: string;\n /** Solver locked-param percents. */\n lfPercent?: string;\n /** Solver locked-param percents. */\n partyAmmPercent?: string;\n /** On-chain platform fee as decimal string (from {@link computePlatformFee}). */\n platformFee: string;\n /** Solver open fee funded from the VA (from {@link calculateSolverFees}). Defaults to `\"0\"`. */\n openSolverFee?: string;\n /** Solver close fee provisioned at open (from {@link calculateSolverFees}). Defaults to `\"0\"`. */\n closeSolverFee?: string;\n /** Expected settlement loss vs the estimated fill (from {@link calculateExpectedSettlementLoss}). Defaults to `\"0\"`. */\n expectedSettlementLoss?: string;\n /**\n * Extra funding headroom percent applied to a SHORT's margin basis\n * (`markPrice × (1 + percent/100)`). A SHORT's `requestedOpenPrice` is a\n * contract FLOOR — a fill above it rescales the signed locks up, so the\n * prefund needs headroom the signed values do not carry. Defaults to `0`;\n * the lowcap open flow passes {@link SHORT_FUNDING_BUFFER_PERCENT}.\n */\n shortFundingBufferPercent?: number;\n}\n\n/**\n * Funding headroom percent the lowcap open flow applies to a SHORT's margin\n * basis (see {@link CalculateMarginParameters.shortFundingBufferPercent}).\n */\nexport const SHORT_FUNDING_BUFFER_PERCENT = 1;\n\n/**\n * Compute the `addMargin` amount for lowcap isolation.\n *\n * - **LONG**: `margin = cva + lf + partyAmm + fees`.\n * - **SHORT**: recompute the locked values at\n * `markPrice × (1 + shortFundingBufferPercent/100)`, then sum + fees — the\n * buffer covers lock growth when the fill lands above the SHORT's floor.\n *\n * `fees = platformFee + openSolverFee + closeSolverFee +\n * expectedSettlementLoss` — the solver charges its fees and the open-price\n * settlement from the **VA balance**, so every leg must ride this SubAccount →\n * VA transfer or the position opens underfunded.\n *\n * @returns Margin as decimal string.\n */\nexport function calculateMargin(parameters: CalculateMarginParameters): string {\n const {\n positionType,\n markPrice,\n quantityBasic,\n cva,\n lf,\n partyAmm,\n cvaPercent,\n lfPercent,\n partyAmmPercent,\n platformFee,\n openSolverFee = \"0\",\n closeSolverFee = \"0\",\n expectedSettlementLoss = \"0\",\n shortFundingBufferPercent = 0,\n } = parameters;\n\n const fees = toDecimal(platformFee).plus(openSolverFee).plus(closeSolverFee).plus(expectedSettlementLoss);\n\n if (positionType === PositionType.LONG) {\n return toDecimal(cva).plus(lf).plus(partyAmm).plus(fees).toString();\n }\n\n const marginPrice = toDecimal(markPrice).times(toDecimal(100 + shortFundingBufferPercent).div(100));\n const notionalBasicMargin = toDecimal(quantityBasic).times(marginPrice).toString();\n const cvaMargin = toDecimal(notionalBasicMargin).times(toDecimal(cvaPercent)).div(100).toString();\n const lfMargin = toDecimal(notionalBasicMargin).times(toDecimal(lfPercent)).div(100).toString();\n const partyAmmMargin = toDecimal(notionalBasicMargin).times(toDecimal(partyAmmPercent)).div(100).toString();\n\n return toDecimal(cvaMargin).plus(lfMargin).plus(partyAmmMargin).plus(fees).toString();\n}\n\n/**\n * On-chain `getFeeForUser` result, in 18-decimal fixed-point.\n */\nexport interface ComputePlatformFeeRates {\n /** Open fee rate as 18-decimal `bigint`. */\n openFee: bigint;\n /** Close fee rate as 18-decimal `bigint`. */\n closeFee: bigint;\n}\n\n/**\n * Compute the total platform fee for an open + close round trip.\n *\n * `(openFee × initialNotional + closeFee × closeNotional) / 1e18`.\n *\n * @param rates - Fee rates from `getFeeForUser`.\n * @param initialNotional - Notional at open, decimal string.\n * @param closeNotional - Notional at close, decimal string.\n * @returns Total fee as decimal string.\n */\nexport function computePlatformFee(\n rates: ComputePlatformFeeRates,\n initialNotional: string,\n closeNotional: string,\n): string {\n const open = toDecimal(rates.openFee.toString()).times(initialNotional);\n const close = toDecimal(rates.closeFee.toString()).times(closeNotional);\n return open.plus(close).div(toDecimal(\"1e18\")).toString();\n}\n\n/**\n * The two platform-fee legs, separated. Their sum equals\n * {@link computePlatformFee} for the same inputs.\n */\nexport interface PlatformFeeLegs {\n /** `openFee × openNotional / 1e18`, decimal string. */\n platformOpenFee: string;\n /** `closeFee × closeNotional / 1e18`, decimal string — provisioned at open. */\n platformCloseFee: string;\n}\n\n/**\n * Compute the platform open and close fee legs separately.\n *\n * Same math as {@link computePlatformFee}, split per leg for fee-breakdown\n * displays. Rates come from on-chain `getFeeForUser` (18-decimal fixed-point).\n */\nexport function computePlatformFeeLegs(\n rates: ComputePlatformFeeRates,\n openNotional: string,\n closeNotional: string,\n): PlatformFeeLegs {\n const scale = toDecimal(\"1e18\");\n return {\n platformOpenFee: toDecimal(rates.openFee.toString()).times(openNotional).div(scale).toString(),\n platformCloseFee: toDecimal(rates.closeFee.toString()).times(closeNotional).div(scale).toString(),\n };\n}\n\n/**\n * Convert a decimal string to an 18-decimal-fixed-point `bigint`.\n *\n * Wrapper over `parseEther` from `@symmio/utils/decimal` that returns\n * the wei value as `bigint` (truncated, no rounding) suitable for contract calls.\n */\nexport function toWeiBigInt(value: string): bigint {\n return BigInt(parseEther(value).toFixed(0, RoundingMode.ROUND_DOWN));\n}\n\n/**\n * Inputs for {@link calculateAvailableInstantOpenMargin}. All amounts are\n * 18-decimal wei / fixed-point.\n */\nexport interface CalculateAvailableInstantOpenMarginParameters {\n /** SubAccount available (deallocated) balance from `getAccountBalanceOf`; 1e18-scaled. */\n balance: bigint;\n /** Open fee rate (18-decimal fixed-point) from `getFeeForUser`. */\n openFee: bigint;\n /** Close fee rate (18-decimal fixed-point) from `getFeeForUser`. */\n closeFee: bigint;\n /** Slippage as an 18-decimal fraction (5% → `5n * 10n ** 16n`). */\n slippageFractionWei: bigint;\n /** Requested leverage (integer ≥ 1). */\n leverage: number;\n /** LONG skips the slippage cap; SHORT applies it. */\n positionType: PositionType;\n}\n\n/**\n * Maximum initial margin an instant open can spend. Shaves the raw available\n * balance for fees (both sides, charged on the leveraged notional) and — for\n * SHORT only — a worst-case slippage-fill buffer. Pure `bigint`; clamps to `0n`.\n *\n * ```text\n * available = balance\n * × max(0, 1 − slippageFactor) // SHORT: slippage, LONG: 0\n * × max(0, 1 − leverage × (openFee + closeFee))\n * ```\n *\n * A SHORT's `requestOpenPrice = markPrice × (1 − s)` is a contract FLOOR: a fill\n * above it rescales the signed locks by up to `1 / (1 − s)`, so capping usable\n * balance at `balance × (1 − s)` covers that growth. A LONG's request price is a\n * ceiling, so fills can only shrink the locks and need no cap.\n *\n * @returns spendable margin in 18-decimal wei.\n * @example\n * ```ts\n * const max = calculateAvailableInstantOpenMargin({\n * balance,\n * openFee,\n * closeFee,\n * slippageFractionWei: 5n * 10n ** 16n, // 5%\n * leverage: 10,\n * positionType: PositionType.SHORT,\n * });\n * ```\n */\nexport function calculateAvailableInstantOpenMargin(parameters: CalculateAvailableInstantOpenMarginParameters): bigint {\n const { balance, openFee, closeFee, slippageFractionWei, leverage, positionType } = parameters;\n const ONE_E18 = 10n ** 18n;\n\n const slippageMultiplier =\n positionType === PositionType.SHORT\n ? slippageFractionWei >= ONE_E18\n ? 0n\n : ONE_E18 - slippageFractionWei\n : ONE_E18;\n\n const leverageScaled = BigInt(leverage) * (openFee + closeFee);\n const feeMultiplier = leverageScaled >= ONE_E18 ? 0n : ONE_E18 - leverageScaled;\n\n const afterSlippage = (balance * slippageMultiplier) / ONE_E18;\n return (afterSlippage * feeMultiplier) / ONE_E18;\n}\n"],"mappings":"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"}
@@ -160,6 +160,38 @@ export interface InstantOpenMarketData {
160
160
  pricePrecision?: number;
161
161
  /** Pre-fetched market quantity precision. When omitted, resolved from solver markets. */
162
162
  quantityPrecision?: number;
163
+ /** Pre-fetched `minOpenSolverFeeCap` (decimal ratio string). When omitted, resolved from solver markets. */
164
+ minOpenSolverFeeCap?: string;
165
+ /** Pre-fetched `minCloseSolverFeeCap` (decimal ratio string). When omitted, resolved from solver markets. */
166
+ minCloseSolverFeeCap?: string;
167
+ /** Pre-fetched solver open-fee rate (decimal fraction string). When omitted, resolved from solver markets. */
168
+ hedgerFeeOpen?: string;
169
+ /** Pre-fetched solver close-fee rate (decimal fraction string). When omitted, resolved from solver markets. */
170
+ hedgerFeeClose?: string;
171
+ /**
172
+ * Pre-fetched early (peak) close-fee rate. When omitted on a lowcap (Enigma)
173
+ * solver, resolved from `/symbols`; the open provisions this worst-case rate.
174
+ * Ignored on non-lowcap solvers.
175
+ */
176
+ hedgerFeeCloseEarlyRate?: string;
177
+ /** Pre-fetched early-window length in seconds (paired with `hedgerFeeCloseEarlyRate`). */
178
+ hedgerFeeCloseEarlyThreshold?: number;
179
+ /** Pre-fetched standard-rate threshold in seconds (paired with `hedgerFeeCloseEarlyRate`). */
180
+ hedgerFeeCloseStandardThreshold?: number;
181
+ }
182
+ /**
183
+ * Solver-fee rate caps authorized on a quote, as 18-decimal fixed-point ratios
184
+ * of quote notional (perps-core v0.8.6 solver fees).
185
+ *
186
+ * Both caps are set immutably at `sendQuote` time — the close-side cap cannot
187
+ * be changed later in `requestToClosePosition`. On-chain the solver may charge
188
+ * up to `notional * rateCap / 1e18` on each side.
189
+ */
190
+ export interface SolverFeeCaps {
191
+ /** Maximum open-side solver fee, as an 18-decimal ratio of open notional. */
192
+ openRateCap: bigint;
193
+ /** Maximum close-side solver fee, as an 18-decimal ratio of close notional. Immutable after `sendQuote`. */
194
+ closeRateCap: bigint;
163
195
  }
164
196
  /**
165
197
  * Margin context passed to `InstantOpenParameters`.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/shared/types.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/solvers/instant-open/shared/types.ts"],"names":[],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/solvers/instant-open/shared/types.ts"],"sourcesContent":["import type { Address, Hex } from \"viem\";\nimport type { InstantLayerAccount } from \"../../../symmio-contracts/instant-layer/types\";\nimport { PositionType, type SingleUpnlAndPriceSig } from \"../../../symmio-contracts/symmio/types\";\n\n/**\n * Re-export the canonical trade-side enum (defined in\n * `symmio-contracts/symmio/types.ts`) so the instant-open slice has one place\n * to import it from. Numeric values match the on-chain enum: `LONG = 0`,\n * `SHORT = 1`.\n */\nexport { PositionType };\n\n/** Contract enum value for MARKET orders. */\nexport const ORDER_TYPE_MARKET = 1 as const;\n/** Contract enum value for LIMIT orders (majors / rasa only). */\nexport const ORDER_TYPE_LIMIT = 0 as const;\n/** Order type sent to the hedger: `ORDER_TYPE_MARKET` (instant) or `ORDER_TYPE_LIMIT`. */\nexport type SolverOrderType = typeof ORDER_TYPE_MARKET | typeof ORDER_TYPE_LIMIT;\n\n/**\n * Virtual-account isolation type values used by `addMarginToNextVA`.\n *\n * Matches the on-chain `VirtualAccountIsolationType` enum.\n */\nexport const VIRTUAL_ACCOUNT_ISOLATION_TYPE = {\n POSITION: 0,\n MARKET: 1,\n MARKET_LONG: 2,\n MARKET_SHORT: 3,\n} as const;\n\nexport type VirtualAccountIsolationType =\n (typeof VIRTUAL_ACCOUNT_ISOLATION_TYPE)[keyof typeof VIRTUAL_ACCOUNT_ISOLATION_TYPE];\n\n/**\n * Map a trade side to the market-isolation type its Virtual Account is created\n * with. A `SHORT` lands in a `MARKET_SHORT` VA; everything else (i.e. `LONG`)\n * lands in a `MARKET_LONG` VA.\n *\n * This is the side ↔ isolation rule used both when opening (`addMarginToNextVA`)\n * and when predicting a not-yet-created VA's address\n * (`predictNextVirtualAccountAddress`). It lives next to\n * {@link VIRTUAL_ACCOUNT_ISOLATION_TYPE} so callers that only need the side\n * mapping (e.g. the quotes slice) can import it without pulling in the rest of\n * the instant-open flow.\n *\n * @param positionType - The trade side (`LONG` or `SHORT`).\n * @returns The matching {@link VirtualAccountIsolationType}\n * (`MARKET_SHORT` for `SHORT`, otherwise `MARKET_LONG`).\n *\n * @example\n * ```ts\n * isolationTypeForSide(PositionType.SHORT); // VIRTUAL_ACCOUNT_ISOLATION_TYPE.MARKET_SHORT\n * isolationTypeForSide(PositionType.LONG); // VIRTUAL_ACCOUNT_ISOLATION_TYPE.MARKET_LONG\n * ```\n *\n * TODO: what happend if someone have different isolation type than the one we expect? like POSITION or MARKET?\n */\nexport function isolationTypeForSide(positionType: PositionType): VirtualAccountIsolationType {\n return positionType === PositionType.SHORT\n ? VIRTUAL_ACCOUNT_ISOLATION_TYPE.MARKET_SHORT\n : VIRTUAL_ACCOUNT_ISOLATION_TYPE.MARKET_LONG;\n}\n\n/**\n * Muon oracle signature accepted by `sendQuoteWithAffiliateAndData`.\n *\n * For lowcap flows, pass `ZERO_UPNL_SIG` or build a placeholder with\n * `getFakeSendQuoteMuonSignature`. Solvers that enforce Muon verification\n * (Rasa / majors) need a live attestation from `getSendQuoteUpnlSig`.\n *\n * @deprecated Renamed to {@link SingleUpnlAndPriceSig} to match the on-chain\n * struct name. This alias is kept for one release and will be removed in the\n * next major.\n */\nexport type UpnlSig = SingleUpnlAndPriceSig;\n\n/**\n * InstantLayer EIP-712 `ReplayAttackHeader` struct.\n */\nexport interface ReplayAttackHeader {\n /** Operation nonce (`0n` for single-use ops). */\n nonce: bigint;\n /** Unix-seconds deadline. */\n deadline: bigint;\n /** Random 32-byte salt. */\n salt: Hex;\n}\n\n/**\n * InstantLayer EIP-712 `FlexField` struct.\n */\nexport interface FlexField {\n /** Byte offset into `callData`. */\n offset: bigint;\n /** Byte length. */\n length: bigint;\n /** Address authorized to fill this slot. */\n authorizedFlexFiller: Address;\n}\n\n/**\n * InstantLayer EIP-712 `SignedOperation` struct.\n */\nexport interface SignedOperation {\n /** Session-key signer that produces the EIP-712 signature. */\n signer: Address;\n /** Target contract the operation calls. */\n target: Address;\n /** ABI-encoded calldata for the `target` call. */\n callData: Hex;\n /** Account whose authority the operation runs under. */\n signerAccount: InstantLayerAccount;\n /** Flex fields (empty for lowcap flows). */\n flexFields: FlexField[];\n /** Max number of times the operation may be executed. */\n maxUses: bigint;\n /** Replay-attack protection header. */\n replayAttackHeader: ReplayAttackHeader;\n}\n\n/**\n * Wire-format `SignedOperation` accepted by the hedger's `/instant_trade/*` REST API.\n *\n * Re-exports the orval-generated `Eip712SignedOperationJSON` shape; `bigint`s\n * are serialized as decimal strings to survive JSON.\n */\nexport type { Eip712SignedOperationJSON as SignedOperationPayload } from \"../../types/generated/enigma-solver\";\n\n/**\n * Wire-format signed-and-signed-operation pair accepted by the hedger API.\n *\n * Re-exports the orval-generated `Eip712OperationWithSigJSON`.\n */\nexport type { Eip712OperationWithSigJSON as InstantOperationPayload } from \"../../types/generated/enigma-solver\";\n\n/**\n * Locked-margin breakdown passed to `InstantOpenParameters`.\n *\n * All values are 18-decimal-wei `bigint` matching the contract argument order\n * of `sendQuoteWithAffiliateAndData`.\n */\nexport interface InstantOpenLockedParams {\n /** CVA locked margin (wei). */\n cva: bigint;\n /** LF locked margin (wei). */\n lf: bigint;\n /** PartyA maintenance margin (wei). */\n partyAmm: bigint;\n /** PartyB maintenance margin (wei). */\n partyBmm: bigint;\n}\n\n/**\n * Order-side trade values passed to `InstantOpenParameters`.\n *\n * All wei `bigint`s, final values (already through trade math + leverage).\n */\nexport interface InstantOpenOrder {\n /** Requested open price (wei). */\n price: bigint;\n /** Leveraged quantity (wei). */\n quantity: bigint;\n}\n\n/**\n * Market identification + precision metadata used by the wizard.\n *\n * Only `id` is required. `name`, `pricePrecision`, and `quantityPrecision` are\n * pre-fetched overrides; when omitted, the wizard resolves them from solver\n * `/contract-symbols` via `id`.\n */\nexport interface InstantOpenMarketData {\n /** Market `symbol_id` from solver markets. */\n id: number;\n /** Pre-fetched market name. When omitted, resolved from solver markets. */\n name?: string;\n /** Pre-fetched market price precision. When omitted, resolved from solver markets. */\n pricePrecision?: number;\n /** Pre-fetched market quantity precision. When omitted, resolved from solver markets. */\n quantityPrecision?: number;\n}\n\n/**\n * Margin context passed to `InstantOpenParameters`.\n *\n * The single mark price for the trade lives in `order.price` (wei); it's\n * forwarded into the fake-Muon `upnlSig.price` field by the primitive.\n */\nexport interface InstantOpenMargin {\n /** Total margin amount for `addMarginToNextVA` (wei). */\n amount: bigint;\n}\n"],"mappings":";;AAaA,IAAa,IAAoB,GAWpB,IAAiC;CAC5C,UAAU;CACV,QAAQ;CACR,aAAa;CACb,cAAc;AAChB;AA6BA,SAAgB,EAAqB,GAAyD;CAC5F,OAAO,MAAiB,EAAa,QACjC,EAA+B,eAC/B,EAA+B;AACrC"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/solvers/instant-open/shared/types.ts"],"sourcesContent":["import type { Address, Hex } from \"viem\";\nimport type { InstantLayerAccount } from \"../../../symmio-contracts/instant-layer/types\";\nimport { PositionType, type SingleUpnlAndPriceSig } from \"../../../symmio-contracts/symmio/types\";\n\n/**\n * Re-export the canonical trade-side enum (defined in\n * `symmio-contracts/symmio/types.ts`) so the instant-open slice has one place\n * to import it from. Numeric values match the on-chain enum: `LONG = 0`,\n * `SHORT = 1`.\n */\nexport { PositionType };\n\n/** Contract enum value for MARKET orders. */\nexport const ORDER_TYPE_MARKET = 1 as const;\n/** Contract enum value for LIMIT orders (majors / rasa only). */\nexport const ORDER_TYPE_LIMIT = 0 as const;\n/** Order type sent to the hedger: `ORDER_TYPE_MARKET` (instant) or `ORDER_TYPE_LIMIT`. */\nexport type SolverOrderType = typeof ORDER_TYPE_MARKET | typeof ORDER_TYPE_LIMIT;\n\n/**\n * Virtual-account isolation type values used by `addMarginToNextVA`.\n *\n * Matches the on-chain `VirtualAccountIsolationType` enum.\n */\nexport const VIRTUAL_ACCOUNT_ISOLATION_TYPE = {\n POSITION: 0,\n MARKET: 1,\n MARKET_LONG: 2,\n MARKET_SHORT: 3,\n} as const;\n\nexport type VirtualAccountIsolationType =\n (typeof VIRTUAL_ACCOUNT_ISOLATION_TYPE)[keyof typeof VIRTUAL_ACCOUNT_ISOLATION_TYPE];\n\n/**\n * Map a trade side to the market-isolation type its Virtual Account is created\n * with. A `SHORT` lands in a `MARKET_SHORT` VA; everything else (i.e. `LONG`)\n * lands in a `MARKET_LONG` VA.\n *\n * This is the side ↔ isolation rule used both when opening (`addMarginToNextVA`)\n * and when predicting a not-yet-created VA's address\n * (`predictNextVirtualAccountAddress`). It lives next to\n * {@link VIRTUAL_ACCOUNT_ISOLATION_TYPE} so callers that only need the side\n * mapping (e.g. the quotes slice) can import it without pulling in the rest of\n * the instant-open flow.\n *\n * @param positionType - The trade side (`LONG` or `SHORT`).\n * @returns The matching {@link VirtualAccountIsolationType}\n * (`MARKET_SHORT` for `SHORT`, otherwise `MARKET_LONG`).\n *\n * @example\n * ```ts\n * isolationTypeForSide(PositionType.SHORT); // VIRTUAL_ACCOUNT_ISOLATION_TYPE.MARKET_SHORT\n * isolationTypeForSide(PositionType.LONG); // VIRTUAL_ACCOUNT_ISOLATION_TYPE.MARKET_LONG\n * ```\n *\n * TODO: what happend if someone have different isolation type than the one we expect? like POSITION or MARKET?\n */\nexport function isolationTypeForSide(positionType: PositionType): VirtualAccountIsolationType {\n return positionType === PositionType.SHORT\n ? VIRTUAL_ACCOUNT_ISOLATION_TYPE.MARKET_SHORT\n : VIRTUAL_ACCOUNT_ISOLATION_TYPE.MARKET_LONG;\n}\n\n/**\n * Muon oracle signature accepted by `sendQuoteWithAffiliateAndData`.\n *\n * For lowcap flows, pass `ZERO_UPNL_SIG` or build a placeholder with\n * `getFakeSendQuoteMuonSignature`. Solvers that enforce Muon verification\n * (Rasa / majors) need a live attestation from `getSendQuoteUpnlSig`.\n *\n * @deprecated Renamed to {@link SingleUpnlAndPriceSig} to match the on-chain\n * struct name. This alias is kept for one release and will be removed in the\n * next major.\n */\nexport type UpnlSig = SingleUpnlAndPriceSig;\n\n/**\n * InstantLayer EIP-712 `ReplayAttackHeader` struct.\n */\nexport interface ReplayAttackHeader {\n /** Operation nonce (`0n` for single-use ops). */\n nonce: bigint;\n /** Unix-seconds deadline. */\n deadline: bigint;\n /** Random 32-byte salt. */\n salt: Hex;\n}\n\n/**\n * InstantLayer EIP-712 `FlexField` struct.\n */\nexport interface FlexField {\n /** Byte offset into `callData`. */\n offset: bigint;\n /** Byte length. */\n length: bigint;\n /** Address authorized to fill this slot. */\n authorizedFlexFiller: Address;\n}\n\n/**\n * InstantLayer EIP-712 `SignedOperation` struct.\n */\nexport interface SignedOperation {\n /** Session-key signer that produces the EIP-712 signature. */\n signer: Address;\n /** Target contract the operation calls. */\n target: Address;\n /** ABI-encoded calldata for the `target` call. */\n callData: Hex;\n /** Account whose authority the operation runs under. */\n signerAccount: InstantLayerAccount;\n /** Flex fields (empty for lowcap flows). */\n flexFields: FlexField[];\n /** Max number of times the operation may be executed. */\n maxUses: bigint;\n /** Replay-attack protection header. */\n replayAttackHeader: ReplayAttackHeader;\n}\n\n/**\n * Wire-format `SignedOperation` accepted by the hedger's `/instant_trade/*` REST API.\n *\n * Re-exports the orval-generated `Eip712SignedOperationJSON` shape; `bigint`s\n * are serialized as decimal strings to survive JSON.\n */\nexport type { Eip712SignedOperationJSON as SignedOperationPayload } from \"../../types/generated/enigma-solver\";\n\n/**\n * Wire-format signed-and-signed-operation pair accepted by the hedger API.\n *\n * Re-exports the orval-generated `Eip712OperationWithSigJSON`.\n */\nexport type { Eip712OperationWithSigJSON as InstantOperationPayload } from \"../../types/generated/enigma-solver\";\n\n/**\n * Locked-margin breakdown passed to `InstantOpenParameters`.\n *\n * All values are 18-decimal-wei `bigint` matching the contract argument order\n * of `sendQuoteWithAffiliateAndData`.\n */\nexport interface InstantOpenLockedParams {\n /** CVA locked margin (wei). */\n cva: bigint;\n /** LF locked margin (wei). */\n lf: bigint;\n /** PartyA maintenance margin (wei). */\n partyAmm: bigint;\n /** PartyB maintenance margin (wei). */\n partyBmm: bigint;\n}\n\n/**\n * Order-side trade values passed to `InstantOpenParameters`.\n *\n * All wei `bigint`s, final values (already through trade math + leverage).\n */\nexport interface InstantOpenOrder {\n /** Requested open price (wei). */\n price: bigint;\n /** Leveraged quantity (wei). */\n quantity: bigint;\n}\n\n/**\n * Market identification + precision metadata used by the wizard.\n *\n * Only `id` is required. `name`, `pricePrecision`, and `quantityPrecision` are\n * pre-fetched overrides; when omitted, the wizard resolves them from solver\n * `/contract-symbols` via `id`.\n */\nexport interface InstantOpenMarketData {\n /** Market `symbol_id` from solver markets. */\n id: number;\n /** Pre-fetched market name. When omitted, resolved from solver markets. */\n name?: string;\n /** Pre-fetched market price precision. When omitted, resolved from solver markets. */\n pricePrecision?: number;\n /** Pre-fetched market quantity precision. When omitted, resolved from solver markets. */\n quantityPrecision?: number;\n /** Pre-fetched `minOpenSolverFeeCap` (decimal ratio string). When omitted, resolved from solver markets. */\n minOpenSolverFeeCap?: string;\n /** Pre-fetched `minCloseSolverFeeCap` (decimal ratio string). When omitted, resolved from solver markets. */\n minCloseSolverFeeCap?: string;\n /** Pre-fetched solver open-fee rate (decimal fraction string). When omitted, resolved from solver markets. */\n hedgerFeeOpen?: string;\n /** Pre-fetched solver close-fee rate (decimal fraction string). When omitted, resolved from solver markets. */\n hedgerFeeClose?: string;\n /**\n * Pre-fetched early (peak) close-fee rate. When omitted on a lowcap (Enigma)\n * solver, resolved from `/symbols`; the open provisions this worst-case rate.\n * Ignored on non-lowcap solvers.\n */\n hedgerFeeCloseEarlyRate?: string;\n /** Pre-fetched early-window length in seconds (paired with `hedgerFeeCloseEarlyRate`). */\n hedgerFeeCloseEarlyThreshold?: number;\n /** Pre-fetched standard-rate threshold in seconds (paired with `hedgerFeeCloseEarlyRate`). */\n hedgerFeeCloseStandardThreshold?: number;\n}\n\n/**\n * Solver-fee rate caps authorized on a quote, as 18-decimal fixed-point ratios\n * of quote notional (perps-core v0.8.6 solver fees).\n *\n * Both caps are set immutably at `sendQuote` time — the close-side cap cannot\n * be changed later in `requestToClosePosition`. On-chain the solver may charge\n * up to `notional * rateCap / 1e18` on each side.\n */\nexport interface SolverFeeCaps {\n /** Maximum open-side solver fee, as an 18-decimal ratio of open notional. */\n openRateCap: bigint;\n /** Maximum close-side solver fee, as an 18-decimal ratio of close notional. Immutable after `sendQuote`. */\n closeRateCap: bigint;\n}\n\n/**\n * Margin context passed to `InstantOpenParameters`.\n *\n * The single mark price for the trade lives in `order.price` (wei); it's\n * forwarded into the fake-Muon `upnlSig.price` field by the primitive.\n */\nexport interface InstantOpenMargin {\n /** Total margin amount for `addMarginToNextVA` (wei). */\n amount: bigint;\n}\n"],"mappings":";;AAaA,IAAa,IAAoB,GAWpB,IAAiC;CAC5C,UAAU;CACV,QAAQ;CACR,aAAa;CACb,cAAc;AAChB;AA6BA,SAAgB,EAAqB,GAAyD;CAC5F,OAAO,MAAiB,EAAa,QACjC,EAA+B,eAC/B,EAA+B;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"enigma-markets.d.ts","sourceRoot":"","sources":["../../../../src/solvers/markets/adapters/enigma-markets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAsB7C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,GAAG,YAAY,EAAE,CAErF;AAgCD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAGjF"}
1
+ {"version":3,"file":"enigma-markets.d.ts","sourceRoot":"","sources":["../../../../src/solvers/markets/adapters/enigma-markets.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAsB7C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,GAAG,YAAY,EAAE,CAErF;AAsCD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAGjF"}
@@ -1,44 +1,50 @@
1
- import { getContractSymbols as e } from "../../types/generated/enigma-solver.js";
1
+ import { toThresholdSeconds as e } from "../../shared/solver-close-fee.js";
2
+ import { getContractSymbols as t } from "../../types/generated/enigma-solver.js";
2
3
  //#region src/solvers/markets/adapters/enigma-markets.ts
3
- function t(e) {
4
- return e.symbol_id !== void 0 && e.name !== void 0 && e.symbol !== void 0;
5
- }
6
4
  function n(e) {
7
- return e.filter(t).map(r);
5
+ return e.symbol_id !== void 0 && e.name !== void 0 && e.symbol !== void 0;
8
6
  }
9
7
  function r(e) {
8
+ return e.filter(n).map(i);
9
+ }
10
+ function i(t) {
10
11
  return {
11
12
  kind: "enigma",
12
- symbolId: e.symbol_id,
13
- name: e.name,
14
- symbol: e.symbol,
15
- asset: e.asset ?? "",
16
- isValid: e.is_valid ?? !1,
17
- pricePrecision: e.price_precision ?? 0,
18
- quantityPrecision: e.quantity_precision ?? 0,
19
- maxLeverage: e.max_leverage == null ? 0 : Number(e.max_leverage),
20
- maxNotionalValue: e.max_notional_value ?? 0,
21
- rfqAllowed: e.rfq_allowed ?? !1,
22
- tradingFee: e.trading_fee ?? "0",
23
- hedgerFeeOpen: e.hedger_fee_open ?? "0",
24
- hedgerFeeClose: e.hedger_fee_close ?? "0",
25
- maxFundingRate: e.max_funding_rate ?? "0",
26
- minNotionalValue: e.min_notional_value ?? "0",
27
- maxQuantity: e.max_quantity ?? "0",
28
- lotSize: e.lot_size ?? "0",
29
- minAcceptableQuoteValue: e.min_acceptable_quote_value ?? "0",
30
- minAcceptablePortionLf: e.min_acceptable_portion_lf ?? "0",
31
- side: e.side ?? "",
32
- state: e.state ?? 0,
33
- tokenAddress: e.token_address ?? "",
34
- fundingRateEpochDuration: e.funding_rate_epoch_duration ?? "0",
35
- fundingRateWindowTime: e.funding_rate_window_time ?? "0"
13
+ symbolId: t.symbol_id,
14
+ name: t.name,
15
+ symbol: t.symbol,
16
+ asset: t.asset ?? "",
17
+ isValid: t.is_valid ?? !1,
18
+ pricePrecision: t.price_precision ?? 0,
19
+ quantityPrecision: t.quantity_precision ?? 0,
20
+ maxLeverage: t.max_leverage == null ? 0 : Number(t.max_leverage),
21
+ maxNotionalValue: t.max_notional_value ?? 0,
22
+ rfqAllowed: t.rfq_allowed ?? !1,
23
+ tradingFee: t.trading_fee ?? "0",
24
+ hedgerFeeOpen: t.hedger_fee_open ?? "0",
25
+ hedgerFeeClose: t.hedger_fee_close ?? "0",
26
+ hedgerFeeCloseEarlyRate: t.hedger_fee_close_early_rate ?? t.hedger_fee_close ?? "0",
27
+ hedgerFeeCloseEarlyThreshold: e(t.hedger_fee_close_early_threshold),
28
+ hedgerFeeCloseStandardThreshold: e(t.hedger_fee_close_standard_threshold),
29
+ maxFundingRate: t.max_funding_rate ?? "0",
30
+ minNotionalValue: t.min_notional_value ?? "0",
31
+ maxQuantity: t.max_quantity ?? "0",
32
+ lotSize: t.lot_size ?? "0",
33
+ minAcceptableQuoteValue: t.min_acceptable_quote_value ?? "0",
34
+ minAcceptablePortionLf: t.min_acceptable_portion_lf ?? "0",
35
+ side: t.side ?? "",
36
+ state: t.state ?? 0,
37
+ tokenAddress: t.token_address ?? "",
38
+ fundingRateEpochDuration: t.funding_rate_epoch_duration ?? "0",
39
+ fundingRateWindowTime: t.funding_rate_window_time ?? "0",
40
+ minOpenSolverFeeCap: t.min_open_solver_fee_cap ?? "0",
41
+ minCloseSolverFeeCap: t.min_close_solver_fee_cap ?? "0"
36
42
  };
37
43
  }
38
- async function i(t) {
39
- return n((await e({ baseURL: t })).data.symbols ?? []);
44
+ async function a(e) {
45
+ return r((await t({ baseURL: e })).data.symbols ?? []);
40
46
  }
41
47
  //#endregion
42
- export { i as fetchEnigmaMarkets };
48
+ export { a as fetchEnigmaMarkets };
43
49
 
44
50
  //# sourceMappingURL=enigma-markets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"enigma-markets.js","names":[],"sources":["../../../../src/solvers/markets/adapters/enigma-markets.ts"],"sourcesContent":["import { getContractSymbols, type ApiContractSymbol } from \"../../types/generated/enigma-solver\";\nimport type { EnigmaMarket } from \"../types\";\n\n/**\n * An Enigma contract symbol with its identity fields present. Enigma marks every\n * field optional in its OpenAPI spec, so we narrow to the rows that carry a\n * usable identity (`symbol_id` / `name` / `symbol`) before mapping — a market\n * without identity cannot be traded or displayed.\n */\ntype IdentifiedEnigmaSymbol = ApiContractSymbol & {\n symbol_id: number;\n name: string;\n symbol: string;\n};\n\n/**\n * Type guard: does an Enigma contract symbol carry the identity fields the SDK\n * requires? Rows failing this are dropped by {@link toEnigmaMarkets}.\n */\nfunction hasIdentity(symbol: ApiContractSymbol): symbol is IdentifiedEnigmaSymbol {\n return symbol.symbol_id !== undefined && symbol.name !== undefined && symbol.symbol !== undefined;\n}\n\n/**\n * Normalize raw Enigma `/contract-symbols` rows to {@link EnigmaMarket}. Rows\n * missing an identity field are skipped; every other Enigma-optional field is\n * filled with a neutral default so the normalized shape has no optional noise.\n */\nexport function toEnigmaMarkets(symbols: readonly ApiContractSymbol[]): EnigmaMarket[] {\n return symbols.filter(hasIdentity).map(toEnigmaMarket);\n}\n\nfunction toEnigmaMarket(symbol: IdentifiedEnigmaSymbol): EnigmaMarket {\n return {\n kind: \"enigma\",\n symbolId: symbol.symbol_id,\n name: symbol.name,\n symbol: symbol.symbol,\n asset: symbol.asset ?? \"\",\n isValid: symbol.is_valid ?? false,\n pricePrecision: symbol.price_precision ?? 0,\n quantityPrecision: symbol.quantity_precision ?? 0,\n maxLeverage: symbol.max_leverage != null ? Number(symbol.max_leverage) : 0,\n maxNotionalValue: symbol.max_notional_value ?? 0,\n rfqAllowed: symbol.rfq_allowed ?? false,\n tradingFee: symbol.trading_fee ?? \"0\",\n hedgerFeeOpen: symbol.hedger_fee_open ?? \"0\",\n hedgerFeeClose: symbol.hedger_fee_close ?? \"0\",\n maxFundingRate: symbol.max_funding_rate ?? \"0\",\n minNotionalValue: symbol.min_notional_value ?? \"0\",\n maxQuantity: symbol.max_quantity ?? \"0\",\n lotSize: symbol.lot_size ?? \"0\",\n minAcceptableQuoteValue: symbol.min_acceptable_quote_value ?? \"0\",\n minAcceptablePortionLf: symbol.min_acceptable_portion_lf ?? \"0\",\n side: symbol.side ?? \"\",\n state: symbol.state ?? 0,\n tokenAddress: symbol.token_address ?? \"\",\n fundingRateEpochDuration: symbol.funding_rate_epoch_duration ?? \"0\",\n fundingRateWindowTime: symbol.funding_rate_window_time ?? \"0\",\n };\n}\n\n/**\n * Fetch and normalize markets from an **Enigma**-kind solver. Owns Enigma's full\n * fetch story for `/contract-symbols`: the generated Enigma client call plus the\n * mapping to {@link EnigmaMarket}.\n *\n * @param baseURL - The solver's API base URL.\n * @internal\n */\nexport async function fetchEnigmaMarkets(baseURL: string): Promise<EnigmaMarket[]> {\n const response = await getContractSymbols({ baseURL });\n return toEnigmaMarkets(response.data.symbols ?? []);\n}\n"],"mappings":";;AAmBA,SAAS,EAAY,GAA6D;CAChF,OAAO,EAAO,cAAc,KAAA,KAAa,EAAO,SAAS,KAAA,KAAa,EAAO,WAAW,KAAA;AAC1F;AAOA,SAAgB,EAAgB,GAAuD;CACrF,OAAO,EAAQ,OAAO,CAAW,EAAE,IAAI,CAAc;AACvD;AAEA,SAAS,EAAe,GAA8C;CACpE,OAAO;EACL,MAAM;EACN,UAAU,EAAO;EACjB,MAAM,EAAO;EACb,QAAQ,EAAO;EACf,OAAO,EAAO,SAAS;EACvB,SAAS,EAAO,YAAY;EAC5B,gBAAgB,EAAO,mBAAmB;EAC1C,mBAAmB,EAAO,sBAAsB;EAChD,aAAa,EAAO,gBAAgB,OAAqC,IAA9B,OAAO,EAAO,YAAY;EACrE,kBAAkB,EAAO,sBAAsB;EAC/C,YAAY,EAAO,eAAe;EAClC,YAAY,EAAO,eAAe;EAClC,eAAe,EAAO,mBAAmB;EACzC,gBAAgB,EAAO,oBAAoB;EAC3C,gBAAgB,EAAO,oBAAoB;EAC3C,kBAAkB,EAAO,sBAAsB;EAC/C,aAAa,EAAO,gBAAgB;EACpC,SAAS,EAAO,YAAY;EAC5B,yBAAyB,EAAO,8BAA8B;EAC9D,wBAAwB,EAAO,6BAA6B;EAC5D,MAAM,EAAO,QAAQ;EACrB,OAAO,EAAO,SAAS;EACvB,cAAc,EAAO,iBAAiB;EACtC,0BAA0B,EAAO,+BAA+B;EAChE,uBAAuB,EAAO,4BAA4B;CAC5D;AACF;AAUA,eAAsB,EAAmB,GAA0C;CAEjF,OAAO,GAAgB,MADA,EAAmB,EAAE,WAAQ,CAAC,GACrB,KAAK,WAAW,CAAC,CAAC;AACpD"}
1
+ {"version":3,"file":"enigma-markets.js","names":[],"sources":["../../../../src/solvers/markets/adapters/enigma-markets.ts"],"sourcesContent":["import { toThresholdSeconds } from \"../../shared/solver-close-fee\";\nimport { getContractSymbols, type ApiContractSymbol } from \"../../types/generated/enigma-solver\";\nimport type { EnigmaMarket } from \"../types\";\n\n/**\n * An Enigma contract symbol with its identity fields present. Enigma marks every\n * field optional in its OpenAPI spec, so we narrow to the rows that carry a\n * usable identity (`symbol_id` / `name` / `symbol`) before mapping — a market\n * without identity cannot be traded or displayed.\n */\ntype IdentifiedEnigmaSymbol = ApiContractSymbol & {\n symbol_id: number;\n name: string;\n symbol: string;\n};\n\n/**\n * Type guard: does an Enigma contract symbol carry the identity fields the SDK\n * requires? Rows failing this are dropped by {@link toEnigmaMarkets}.\n */\nfunction hasIdentity(symbol: ApiContractSymbol): symbol is IdentifiedEnigmaSymbol {\n return symbol.symbol_id !== undefined && symbol.name !== undefined && symbol.symbol !== undefined;\n}\n\n/**\n * Normalize raw Enigma `/contract-symbols` rows to {@link EnigmaMarket}. Rows\n * missing an identity field are skipped; every other Enigma-optional field is\n * filled with a neutral default so the normalized shape has no optional noise.\n */\nexport function toEnigmaMarkets(symbols: readonly ApiContractSymbol[]): EnigmaMarket[] {\n return symbols.filter(hasIdentity).map(toEnigmaMarket);\n}\n\nfunction toEnigmaMarket(symbol: IdentifiedEnigmaSymbol): EnigmaMarket {\n return {\n kind: \"enigma\",\n symbolId: symbol.symbol_id,\n name: symbol.name,\n symbol: symbol.symbol,\n asset: symbol.asset ?? \"\",\n isValid: symbol.is_valid ?? false,\n pricePrecision: symbol.price_precision ?? 0,\n quantityPrecision: symbol.quantity_precision ?? 0,\n maxLeverage: symbol.max_leverage != null ? Number(symbol.max_leverage) : 0,\n maxNotionalValue: symbol.max_notional_value ?? 0,\n rfqAllowed: symbol.rfq_allowed ?? false,\n tradingFee: symbol.trading_fee ?? \"0\",\n hedgerFeeOpen: symbol.hedger_fee_open ?? \"0\",\n hedgerFeeClose: symbol.hedger_fee_close ?? \"0\",\n // No early rate published → no decay: the early rate collapses to the standard rate.\n hedgerFeeCloseEarlyRate: symbol.hedger_fee_close_early_rate ?? symbol.hedger_fee_close ?? \"0\",\n hedgerFeeCloseEarlyThreshold: toThresholdSeconds(symbol.hedger_fee_close_early_threshold),\n hedgerFeeCloseStandardThreshold: toThresholdSeconds(symbol.hedger_fee_close_standard_threshold),\n maxFundingRate: symbol.max_funding_rate ?? \"0\",\n minNotionalValue: symbol.min_notional_value ?? \"0\",\n maxQuantity: symbol.max_quantity ?? \"0\",\n lotSize: symbol.lot_size ?? \"0\",\n minAcceptableQuoteValue: symbol.min_acceptable_quote_value ?? \"0\",\n minAcceptablePortionLf: symbol.min_acceptable_portion_lf ?? \"0\",\n side: symbol.side ?? \"\",\n state: symbol.state ?? 0,\n tokenAddress: symbol.token_address ?? \"\",\n fundingRateEpochDuration: symbol.funding_rate_epoch_duration ?? \"0\",\n fundingRateWindowTime: symbol.funding_rate_window_time ?? \"0\",\n minOpenSolverFeeCap: symbol.min_open_solver_fee_cap ?? \"0\",\n minCloseSolverFeeCap: symbol.min_close_solver_fee_cap ?? \"0\",\n };\n}\n\n/**\n * Fetch and normalize markets from an **Enigma**-kind solver. Owns Enigma's full\n * fetch story for `/contract-symbols`: the generated Enigma client call plus the\n * mapping to {@link EnigmaMarket}.\n *\n * @param baseURL - The solver's API base URL.\n * @internal\n */\nexport async function fetchEnigmaMarkets(baseURL: string): Promise<EnigmaMarket[]> {\n const response = await getContractSymbols({ baseURL });\n return toEnigmaMarkets(response.data.symbols ?? []);\n}\n"],"mappings":";;;AAoBA,SAAS,EAAY,GAA6D;CAChF,OAAO,EAAO,cAAc,KAAA,KAAa,EAAO,SAAS,KAAA,KAAa,EAAO,WAAW,KAAA;AAC1F;AAOA,SAAgB,EAAgB,GAAuD;CACrF,OAAO,EAAQ,OAAO,CAAW,EAAE,IAAI,CAAc;AACvD;AAEA,SAAS,EAAe,GAA8C;CACpE,OAAO;EACL,MAAM;EACN,UAAU,EAAO;EACjB,MAAM,EAAO;EACb,QAAQ,EAAO;EACf,OAAO,EAAO,SAAS;EACvB,SAAS,EAAO,YAAY;EAC5B,gBAAgB,EAAO,mBAAmB;EAC1C,mBAAmB,EAAO,sBAAsB;EAChD,aAAa,EAAO,gBAAgB,OAAqC,IAA9B,OAAO,EAAO,YAAY;EACrE,kBAAkB,EAAO,sBAAsB;EAC/C,YAAY,EAAO,eAAe;EAClC,YAAY,EAAO,eAAe;EAClC,eAAe,EAAO,mBAAmB;EACzC,gBAAgB,EAAO,oBAAoB;EAE3C,yBAAyB,EAAO,+BAA+B,EAAO,oBAAoB;EAC1F,8BAA8B,EAAmB,EAAO,gCAAgC;EACxF,iCAAiC,EAAmB,EAAO,mCAAmC;EAC9F,gBAAgB,EAAO,oBAAoB;EAC3C,kBAAkB,EAAO,sBAAsB;EAC/C,aAAa,EAAO,gBAAgB;EACpC,SAAS,EAAO,YAAY;EAC5B,yBAAyB,EAAO,8BAA8B;EAC9D,wBAAwB,EAAO,6BAA6B;EAC5D,MAAM,EAAO,QAAQ;EACrB,OAAO,EAAO,SAAS;EACvB,cAAc,EAAO,iBAAiB;EACtC,0BAA0B,EAAO,+BAA+B;EAChE,uBAAuB,EAAO,4BAA4B;EAC1D,qBAAqB,EAAO,2BAA2B;EACvD,sBAAsB,EAAO,4BAA4B;CAC3D;AACF;AAUA,eAAsB,EAAmB,GAA0C;CAEjF,OAAO,GAAgB,MADA,EAAmB,EAAE,WAAQ,CAAC,GACrB,KAAK,WAAW,CAAC,CAAC;AACpD"}
@@ -66,6 +66,21 @@ export interface EnigmaMarket extends BaseMarket {
66
66
  fundingRateEpochDuration: string;
67
67
  /** Funding-rate window time. Enigma-only. */
68
68
  fundingRateWindowTime: string;
69
+ /** Minimum solver-fee cap a quote must allow on open, as a decimal string (perps-core v0.8.6 solver fees). Enigma-only. */
70
+ minOpenSolverFeeCap: string;
71
+ /** Minimum solver-fee cap a quote must allow on close, as a decimal string (perps-core v0.8.6 solver fees). Enigma-only. */
72
+ minCloseSolverFeeCap: string;
73
+ /**
74
+ * Early (peak) close-fee rate charged flat until {@link EnigmaMarket.hedgerFeeCloseEarlyThreshold}
75
+ * seconds, then decaying to {@link BaseMarket.hedgerFeeClose}. Decimal string; equals `hedgerFeeClose`
76
+ * when the solver publishes no decay. Enigma-only. Pass the market to `getSolverCloseFeeRate` /
77
+ * `calculateSolverCloseFee` to price a close by holding time.
78
+ */
79
+ hedgerFeeCloseEarlyRate: string;
80
+ /** Seconds from open during which `hedgerFeeCloseEarlyRate` applies flat. `0` when no decay. Enigma-only. */
81
+ hedgerFeeCloseEarlyThreshold: number;
82
+ /** Seconds from open at/after which `hedgerFeeClose` applies; linear decay between the thresholds. Enigma-only. */
83
+ hedgerFeeCloseStandardThreshold: number;
69
84
  }
70
85
  /**
71
86
  * A market from a **Rasa**-kind solver. Carries only the shared
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/solvers/markets/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,UAAU,UAAU;IAClB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,gBAAgB,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,UAAU,EAAE,OAAO,CAAC;IACpB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,aAAa,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,cAAc,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,gBAAgB,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,uBAAuB,EAAE,MAAM,CAAC;IAChC,8EAA8E;IAC9E,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,4DAA4D;IAC5D,IAAI,EAAE,QAAQ,CAAC;IACf,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,kGAAkG;IAClG,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,wBAAwB,EAAE,MAAM,CAAC;IACjC,6CAA6C;IAC7C,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC;AAE/C;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;CAClB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/solvers/markets/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,UAAU,UAAU;IAClB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,cAAc,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,gBAAgB,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,UAAU,EAAE,OAAO,CAAC;IACpB,4EAA4E;IAC5E,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,aAAa,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,cAAc,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,gBAAgB,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,uBAAuB,EAAE,MAAM,CAAC;IAChC,8EAA8E;IAC9E,sBAAsB,EAAE,MAAM,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,4DAA4D;IAC5D,IAAI,EAAE,QAAQ,CAAC;IACf,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,kGAAkG;IAClG,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,YAAY,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,wBAAwB,EAAE,MAAM,CAAC;IACjC,6CAA6C;IAC7C,qBAAqB,EAAE,MAAM,CAAC;IAC9B,2HAA2H;IAC3H,mBAAmB,EAAE,MAAM,CAAC;IAC5B,4HAA4H;IAC5H,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC,6GAA6G;IAC7G,4BAA4B,EAAE,MAAM,CAAC;IACrC,mHAAmH;IACnH,+BAA+B,EAAE,MAAM,CAAC;CACzC;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC;AAE/C;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;CAClB"}
@@ -6,11 +6,12 @@ import { SolverRevenue, SolverRevenueTimeRange } from './types.js';
6
6
  */
7
7
  export type GetSolverRevenueParameters = Compute<ReadSolverParameter & {
8
8
  /**
9
- * Restrict the totals to one market. **Omit for the protocol-wide total** —
10
- * that is the whole point of this read, and passing a `symbolId` narrows it
11
- * to a single market's share.
9
+ * The market whose revenue to read. Required: the current solver generation
10
+ * serves revenue **per market only** — the protocol-wide `/revenue`
11
+ * aggregate no longer exists. For a multi-market figure, call once per
12
+ * market and label the result with the markets it covers.
12
13
  */
13
- symbolId?: number;
14
+ symbolId: number;
14
15
  /**
15
16
  * Trailing window. Defaults to `"lifetime"` when omitted, matching the
16
17
  * solver's own default.
@@ -20,8 +21,7 @@ export type GetSolverRevenueParameters = Compute<ReadSolverParameter & {
20
21
  /** Return type of {@link getSolverRevenue}: revenue totals for the window. */
21
22
  export type GetSolverRevenueReturnType = SolverRevenue;
22
23
  /**
23
- * Read revenue totals from the chain's solver — protocol-wide by default, or for
24
- * a single market when `symbolId` is given.
24
+ * Read one market's revenue totals from the chain's solver.
25
25
  *
26
26
  * Figures come back as plain dollar `number`s and split into a hedger-fee share
27
27
  * and a funding share, whose sum is `totalRevenue`.
@@ -30,19 +30,19 @@ export type GetSolverRevenueReturnType = SolverRevenue;
30
30
  * with `UNSUPPORTED_BY_SOLVER` rather than a confusing 404.
31
31
  *
32
32
  * @param config - The SDK config.
33
- * @param parameters - Optional chain, solver, market and window.
33
+ * @param parameters - The market, plus optional chain, solver and window.
34
34
  * @returns The normalized {@link SolverRevenue} totals.
35
35
  * @throws {SymmApiError} when the API request fails.
36
36
  * @throws {SymmError} `UNSUPPORTED_BY_SOLVER` when the solver is not enigma-kind.
37
37
  *
38
38
  * @example
39
39
  * ```ts
40
- * // Protocol-wide, since listing.
41
- * const lifetime = await getSolverRevenue(config);
40
+ * // One market, since listing.
41
+ * const lifetime = await getSolverRevenue(config, { symbolId: 1 });
42
42
  *
43
- * // Trailing 24 hours, one market.
43
+ * // The same market over the trailing 24 hours.
44
44
  * const day = await getSolverRevenue(config, { symbolId: 1, timeRange: "24h" });
45
45
  * ```
46
46
  */
47
- export declare function getSolverRevenue(config: Config, parameters?: GetSolverRevenueParameters): Promise<GetSolverRevenueReturnType>;
47
+ export declare function getSolverRevenue(config: Config, parameters: GetSolverRevenueParameters): Promise<GetSolverRevenueReturnType>;
48
48
  //# sourceMappingURL=get-solver-revenue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-solver-revenue.d.ts","sourceRoot":"","sources":["../../../src/solvers/revenue/get-solver-revenue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIlF,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAC9C,mBAAmB,GAAG;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACpC,CACF,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,0BAA0B,GAAG,aAAa,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,0BAA+B,GAC1C,OAAO,CAAC,0BAA0B,CAAC,CAIrC"}
1
+ {"version":3,"file":"get-solver-revenue.d.ts","sourceRoot":"","sources":["../../../src/solvers/revenue/get-solver-revenue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIlF,OAAO,KAAK,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAC9C,mBAAmB,GAAG;IACpB;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACpC,CACF,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,0BAA0B,GAAG,aAAa,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,0BAA0B,GACrC,OAAO,CAAC,0BAA0B,CAAC,CAIrC"}
@@ -1,28 +1,28 @@
1
1
  import { SymmApiError as e, SymmError as t } from "../../shared/errors/symm-error.js";
2
- import { getRevenue as n, getRevenueSymbolId as r } from "../types/generated/enigma-solver.js";
3
- import { assertSolverKind as i } from "../assert-solver-kind.js";
4
- import { toSolverRevenue as a } from "./to-solver-revenue.js";
5
- import { isAxiosError as o } from "axios";
2
+ import { getRevenueSymbolId as n } from "../types/generated/enigma-solver.js";
3
+ import { assertSolverKind as r } from "../assert-solver-kind.js";
4
+ import { toSolverRevenue as i } from "./to-solver-revenue.js";
5
+ import { isAxiosError as a } from "axios";
6
6
  //#region src/solvers/revenue/get-solver-revenue.ts
7
- async function s(e, t = {}) {
7
+ async function o(e, t) {
8
8
  let n = e.getSolver({
9
9
  chainId: t.chainId,
10
10
  solverId: t.solverId
11
11
  });
12
- return i(n, "enigma", "getSolverRevenue"), c(n.url, t);
12
+ return r(n, "enigma", "getSolverRevenue"), s(n.url, t);
13
13
  }
14
- async function c(i, s) {
15
- let c = s.timeRange === void 0 ? void 0 : { time_range: s.timeRange };
14
+ async function s(r, o) {
15
+ let s = o.timeRange === void 0 ? void 0 : { time_range: o.timeRange };
16
16
  try {
17
- return a((s.symbolId === void 0 ? await n(c, { baseURL: i }) : await r(s.symbolId, c, { baseURL: i })).data);
17
+ return i((await n(o.symbolId, s, { baseURL: r })).data);
18
18
  } catch (n) {
19
- throw n instanceof t ? n : o(n) ? e.fromAxios(n, {
19
+ throw n instanceof t ? n : a(n) ? e.fromAxios(n, {
20
20
  code: "FETCH_SOLVER_REVENUE_FAILED",
21
- baseURL: i
21
+ baseURL: r
22
22
  }) : new t("api", "FETCH_SOLVER_REVENUE_FAILED", `Failed to fetch solver revenue: ${n instanceof Error ? n.message : String(n)}`, { cause: n instanceof Error ? n : void 0 });
23
23
  }
24
24
  }
25
25
  //#endregion
26
- export { s as getSolverRevenue };
26
+ export { o as getSolverRevenue };
27
27
 
28
28
  //# sourceMappingURL=get-solver-revenue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-solver-revenue.js","names":[],"sources":["../../../src/solvers/revenue/get-solver-revenue.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { Compute, ReadSolverParameter } from \"../../shared/types/properties\";\nimport { assertSolverKind } from \"../assert-solver-kind\";\nimport { getRevenue, getRevenueSymbolId } from \"../types/generated/enigma-solver\";\nimport { toSolverRevenue } from \"./to-solver-revenue\";\nimport type { SolverRevenue, SolverRevenueTimeRange } from \"./types\";\n\n/**\n * Parameters for {@link getSolverRevenue}.\n */\nexport type GetSolverRevenueParameters = Compute<\n ReadSolverParameter & {\n /**\n * Restrict the totals to one market. **Omit for the protocol-wide total** —\n * that is the whole point of this read, and passing a `symbolId` narrows it\n * to a single market's share.\n */\n symbolId?: number;\n /**\n * Trailing window. Defaults to `\"lifetime\"` when omitted, matching the\n * solver's own default.\n */\n timeRange?: SolverRevenueTimeRange;\n }\n>;\n\n/** Return type of {@link getSolverRevenue}: revenue totals for the window. */\nexport type GetSolverRevenueReturnType = SolverRevenue;\n\n/**\n * Read revenue totals from the chain's solver — protocol-wide by default, or for\n * a single market when `symbolId` is given.\n *\n * Figures come back as plain dollar `number`s and split into a hedger-fee share\n * and a funding share, whose sum is `totalRevenue`.\n *\n * Enigma-only: the endpoint does not exist on a rasa-kind solver, which fails\n * with `UNSUPPORTED_BY_SOLVER` rather than a confusing 404.\n *\n * @param config - The SDK config.\n * @param parameters - Optional chain, solver, market and window.\n * @returns The normalized {@link SolverRevenue} totals.\n * @throws {SymmApiError} when the API request fails.\n * @throws {SymmError} `UNSUPPORTED_BY_SOLVER` when the solver is not enigma-kind.\n *\n * @example\n * ```ts\n * // Protocol-wide, since listing.\n * const lifetime = await getSolverRevenue(config);\n *\n * // Trailing 24 hours, one market.\n * const day = await getSolverRevenue(config, { symbolId: 1, timeRange: \"24h\" });\n * ```\n */\nexport async function getSolverRevenue(\n config: Config,\n parameters: GetSolverRevenueParameters = {},\n): Promise<GetSolverRevenueReturnType> {\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n assertSolverKind(solver, \"enigma\", \"getSolverRevenue\");\n return fetchSolverRevenue(solver.url, parameters);\n}\n\nasync function fetchSolverRevenue(baseURL: string, parameters: GetSolverRevenueParameters): Promise<SolverRevenue> {\n /** Omitted rather than defaulted: the solver's own default is already `lifetime`. */\n const params = parameters.timeRange === undefined ? undefined : { time_range: parameters.timeRange };\n\n try {\n const response =\n parameters.symbolId === undefined\n ? await getRevenue(params, { baseURL })\n : await getRevenueSymbolId(parameters.symbolId, params, { baseURL });\n\n return toSolverRevenue(response.data);\n } catch (err) {\n if (err instanceof SymmError) throw err;\n\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"FETCH_SOLVER_REVENUE_FAILED\", baseURL });\n }\n\n throw new SymmError(\n \"api\",\n \"FETCH_SOLVER_REVENUE_FAILED\",\n `Failed to fetch solver revenue: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;AAwDA,eAAsB,EACpB,GACA,IAAyC,CAAC,GACL;CACrC,IAAM,IAAS,EAAO,UAAU;EAAE,SAAS,EAAW;EAAS,UAAU,EAAW;CAAS,CAAC;CAE9F,OADA,EAAiB,GAAQ,UAAU,kBAAkB,GAC9C,EAAmB,EAAO,KAAK,CAAU;AAClD;AAEA,eAAe,EAAmB,GAAiB,GAAgE;CAEjH,IAAM,IAAS,EAAW,cAAc,KAAA,IAAY,KAAA,IAAY,EAAE,YAAY,EAAW,UAAU;CAEnG,IAAI;EAMF,OAAO,GAJL,EAAW,aAAa,KAAA,IACpB,MAAM,EAAW,GAAQ,EAAE,WAAQ,CAAC,IACpC,MAAM,EAAmB,EAAW,UAAU,GAAQ,EAAE,WAAQ,CAAC,GAEvC,IAAI;CACtC,SAAS,GAAK;EAOZ,MANI,aAAe,IAAiB,IAEhC,EAAa,CAAG,IACZ,EAAa,UAAU,GAAK;GAAE,MAAM;GAA+B;EAAQ,CAAC,IAG9E,IAAI,EACR,OACA,+BACA,mCAAmC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KAClF,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
1
+ {"version":3,"file":"get-solver-revenue.js","names":[],"sources":["../../../src/solvers/revenue/get-solver-revenue.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { Compute, ReadSolverParameter } from \"../../shared/types/properties\";\nimport { assertSolverKind } from \"../assert-solver-kind\";\nimport { getRevenueSymbolId } from \"../types/generated/enigma-solver\";\nimport { toSolverRevenue } from \"./to-solver-revenue\";\nimport type { SolverRevenue, SolverRevenueTimeRange } from \"./types\";\n\n/**\n * Parameters for {@link getSolverRevenue}.\n */\nexport type GetSolverRevenueParameters = Compute<\n ReadSolverParameter & {\n /**\n * The market whose revenue to read. Required: the current solver generation\n * serves revenue **per market only** — the protocol-wide `/revenue`\n * aggregate no longer exists. For a multi-market figure, call once per\n * market and label the result with the markets it covers.\n */\n symbolId: number;\n /**\n * Trailing window. Defaults to `\"lifetime\"` when omitted, matching the\n * solver's own default.\n */\n timeRange?: SolverRevenueTimeRange;\n }\n>;\n\n/** Return type of {@link getSolverRevenue}: revenue totals for the window. */\nexport type GetSolverRevenueReturnType = SolverRevenue;\n\n/**\n * Read one market's revenue totals from the chain's solver.\n *\n * Figures come back as plain dollar `number`s and split into a hedger-fee share\n * and a funding share, whose sum is `totalRevenue`.\n *\n * Enigma-only: the endpoint does not exist on a rasa-kind solver, which fails\n * with `UNSUPPORTED_BY_SOLVER` rather than a confusing 404.\n *\n * @param config - The SDK config.\n * @param parameters - The market, plus optional chain, solver and window.\n * @returns The normalized {@link SolverRevenue} totals.\n * @throws {SymmApiError} when the API request fails.\n * @throws {SymmError} `UNSUPPORTED_BY_SOLVER` when the solver is not enigma-kind.\n *\n * @example\n * ```ts\n * // One market, since listing.\n * const lifetime = await getSolverRevenue(config, { symbolId: 1 });\n *\n * // The same market over the trailing 24 hours.\n * const day = await getSolverRevenue(config, { symbolId: 1, timeRange: \"24h\" });\n * ```\n */\nexport async function getSolverRevenue(\n config: Config,\n parameters: GetSolverRevenueParameters,\n): Promise<GetSolverRevenueReturnType> {\n const solver = config.getSolver({ chainId: parameters.chainId, solverId: parameters.solverId });\n assertSolverKind(solver, \"enigma\", \"getSolverRevenue\");\n return fetchSolverRevenue(solver.url, parameters);\n}\n\nasync function fetchSolverRevenue(baseURL: string, parameters: GetSolverRevenueParameters): Promise<SolverRevenue> {\n /** Omitted rather than defaulted: the solver's own default is already `lifetime`. */\n const params = parameters.timeRange === undefined ? undefined : { time_range: parameters.timeRange };\n\n try {\n const response = await getRevenueSymbolId(parameters.symbolId, params, { baseURL });\n\n return toSolverRevenue(response.data);\n } catch (err) {\n if (err instanceof SymmError) throw err;\n\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"FETCH_SOLVER_REVENUE_FAILED\", baseURL });\n }\n\n throw new SymmError(\n \"api\",\n \"FETCH_SOLVER_REVENUE_FAILED\",\n `Failed to fetch solver revenue: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;AAwDA,eAAsB,EACpB,GACA,GACqC;CACrC,IAAM,IAAS,EAAO,UAAU;EAAE,SAAS,EAAW;EAAS,UAAU,EAAW;CAAS,CAAC;CAE9F,OADA,EAAiB,GAAQ,UAAU,kBAAkB,GAC9C,EAAmB,EAAO,KAAK,CAAU;AAClD;AAEA,eAAe,EAAmB,GAAiB,GAAgE;CAEjH,IAAM,IAAS,EAAW,cAAc,KAAA,IAAY,KAAA,IAAY,EAAE,YAAY,EAAW,UAAU;CAEnG,IAAI;EAGF,OAAO,GAAgB,MAFA,EAAmB,EAAW,UAAU,GAAQ,EAAE,WAAQ,CAAC,GAElD,IAAI;CACtC,SAAS,GAAK;EAOZ,MANI,aAAe,IAAiB,IAEhC,EAAa,CAAG,IACZ,EAAa,UAAU,GAAK;GAAE,MAAM;GAA+B;EAAQ,CAAC,IAG9E,IAAI,EACR,OACA,+BACA,mCAAmC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KAClF,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
@@ -29,8 +29,8 @@ export type GetSolverRevenueQueryOptions = SymmioQueryOptions<GetSolverRevenueDa
29
29
  *
30
30
  * @example
31
31
  * ```ts
32
- * useQuery(getSolverRevenueQueryOptions(config, { timeRange: "24h" }));
32
+ * useQuery(getSolverRevenueQueryOptions(config, { symbolId: 1, timeRange: "24h" }));
33
33
  * ```
34
34
  */
35
- export declare function getSolverRevenueQueryOptions(config: Config, options?: GetSolverRevenueOptions): GetSolverRevenueQueryOptions;
35
+ export declare function getSolverRevenueQueryOptions(config: Config, options: GetSolverRevenueOptions): GetSolverRevenueQueryOptions;
36
36
  //# sourceMappingURL=query.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/solvers/revenue/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAE9B,uEAAuE;AACvE,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAE9D;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,0BAA0B,GAAG,kBAAkB,CAAC,0DAEzG;AAED,mEAAmE;AACnE,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEnF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAC3C,0BAA0B,GACxB,cAAc,CAAC,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,CAAC,CAC9F,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,4BAA4B,GAAG,kBAAkB,CAC3D,oBAAoB,EACpB,KAAK,EACL,oBAAoB,EACpB,wBAAwB,CACzB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,uBAA4B,GACpC,4BAA4B,CAgB9B"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/solvers/revenue/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAE9B,uEAAuE;AACvE,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAE9D;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,0BAA0B,GAAG,kBAAkB,CAAC,0DAEzG;AAED,mEAAmE;AACnE,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEnF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAC3C,0BAA0B,GACxB,cAAc,CAAC,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,CAAC,CAC9F,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,4BAA4B,GAAG,kBAAkB,CAC3D,oBAAoB,EACpB,KAAK,EACL,oBAAoB,EACpB,wBAAwB,CACzB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,GAC/B,4BAA4B,CAgB9B"}
@@ -4,7 +4,7 @@ import { getSolverRevenue as t } from "./get-solver-revenue.js";
4
4
  function n(t) {
5
5
  return ["getSolverRevenue", e(t)];
6
6
  }
7
- function r(e, r = {}) {
7
+ function r(e, r) {
8
8
  return {
9
9
  ...r.query,
10
10
  queryKey: n({
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","names":[],"sources":["../../../src/solvers/revenue/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { Compute, ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport {\n getSolverRevenue,\n type GetSolverRevenueParameters,\n type GetSolverRevenueReturnType,\n} from \"./get-solver-revenue\";\n\n/** Data resolved by the {@link getSolverRevenueQueryOptions} query. */\nexport type GetSolverRevenueData = GetSolverRevenueReturnType;\n\n/**\n * Build the TanStack Query key for {@link getSolverRevenueQueryOptions}.\n *\n * @param options - Query parameters plus the resolved config key.\n * @returns A stable, hashable query key.\n */\nexport function getSolverRevenueQueryKey(options: Compute<GetSolverRevenueParameters & ConfigKeyParameter>) {\n return [\"getSolverRevenue\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getSolverRevenueQueryKey}. */\nexport type GetSolverRevenueQueryKey = ReturnType<typeof getSolverRevenueQueryKey>;\n\n/**\n * Options accepted by {@link getSolverRevenueQueryOptions}: the action's\n * parameters, an optional cache scope, and TanStack overrides.\n */\nexport type GetSolverRevenueOptions = Compute<\n GetSolverRevenueParameters &\n QueryParameter<GetSolverRevenueData, Error, GetSolverRevenueData, GetSolverRevenueQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getSolverRevenueQueryOptions}. */\nexport type GetSolverRevenueQueryOptions = SymmioQueryOptions<\n GetSolverRevenueData,\n Error,\n GetSolverRevenueData,\n GetSolverRevenueQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getSolverRevenue}.\n *\n * @param config - The SDK config.\n * @param options - Query parameters and TanStack overrides.\n * @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.\n *\n * @example\n * ```ts\n * useQuery(getSolverRevenueQueryOptions(config, { timeRange: \"24h\" }));\n * ```\n */\nexport function getSolverRevenueQueryOptions(\n config: Config,\n options: GetSolverRevenueOptions = {},\n): GetSolverRevenueQueryOptions {\n return {\n ...options.query,\n queryKey: getSolverRevenueQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: options.query?.enabled ?? true,\n queryFn: () =>\n getSolverRevenue(config, {\n chainId: options.chainId,\n solverId: options.solverId,\n symbolId: options.symbolId,\n timeRange: options.timeRange,\n }),\n };\n}\n"],"mappings":";;;AAmBA,SAAgB,EAAyB,GAAmE;CAC1G,OAAO,CAAC,oBAAoB,EAAmB,CAAO,CAAC;AACzD;AAkCA,SAAgB,EACd,GACA,IAAmC,CAAC,GACN;CAC9B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAyB;GACjC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,SAAS,EAAQ,OAAO,WAAW;EACnC,eACE,EAAiB,GAAQ;GACvB,SAAS,EAAQ;GACjB,UAAU,EAAQ;GAClB,UAAU,EAAQ;GAClB,WAAW,EAAQ;EACrB,CAAC;CACL;AACF"}
1
+ {"version":3,"file":"query.js","names":[],"sources":["../../../src/solvers/revenue/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { Compute, ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport {\n getSolverRevenue,\n type GetSolverRevenueParameters,\n type GetSolverRevenueReturnType,\n} from \"./get-solver-revenue\";\n\n/** Data resolved by the {@link getSolverRevenueQueryOptions} query. */\nexport type GetSolverRevenueData = GetSolverRevenueReturnType;\n\n/**\n * Build the TanStack Query key for {@link getSolverRevenueQueryOptions}.\n *\n * @param options - Query parameters plus the resolved config key.\n * @returns A stable, hashable query key.\n */\nexport function getSolverRevenueQueryKey(options: Compute<GetSolverRevenueParameters & ConfigKeyParameter>) {\n return [\"getSolverRevenue\", filterQueryOptions(options)] as const;\n}\n\n/** Query-key type produced by {@link getSolverRevenueQueryKey}. */\nexport type GetSolverRevenueQueryKey = ReturnType<typeof getSolverRevenueQueryKey>;\n\n/**\n * Options accepted by {@link getSolverRevenueQueryOptions}: the action's\n * parameters, an optional cache scope, and TanStack overrides.\n */\nexport type GetSolverRevenueOptions = Compute<\n GetSolverRevenueParameters &\n QueryParameter<GetSolverRevenueData, Error, GetSolverRevenueData, GetSolverRevenueQueryKey>\n>;\n\n/** TanStack Query options returned by {@link getSolverRevenueQueryOptions}. */\nexport type GetSolverRevenueQueryOptions = SymmioQueryOptions<\n GetSolverRevenueData,\n Error,\n GetSolverRevenueData,\n GetSolverRevenueQueryKey\n>;\n\n/**\n * Build TanStack Query options for {@link getSolverRevenue}.\n *\n * @param config - The SDK config.\n * @param options - Query parameters and TanStack overrides.\n * @returns Options to pass to `useQuery` / `queryClient.fetchQuery`.\n *\n * @example\n * ```ts\n * useQuery(getSolverRevenueQueryOptions(config, { symbolId: 1, timeRange: \"24h\" }));\n * ```\n */\nexport function getSolverRevenueQueryOptions(\n config: Config,\n options: GetSolverRevenueOptions,\n): GetSolverRevenueQueryOptions {\n return {\n ...options.query,\n queryKey: getSolverRevenueQueryKey({\n ...options,\n configKey: config.getChainConfigKey(options.chainId),\n }),\n enabled: options.query?.enabled ?? true,\n queryFn: () =>\n getSolverRevenue(config, {\n chainId: options.chainId,\n solverId: options.solverId,\n symbolId: options.symbolId,\n timeRange: options.timeRange,\n }),\n };\n}\n"],"mappings":";;;AAmBA,SAAgB,EAAyB,GAAmE;CAC1G,OAAO,CAAC,oBAAoB,EAAmB,CAAO,CAAC;AACzD;AAkCA,SAAgB,EACd,GACA,GAC8B;CAC9B,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAyB;GACjC,GAAG;GACH,WAAW,EAAO,kBAAkB,EAAQ,OAAO;EACrD,CAAC;EACD,SAAS,EAAQ,OAAO,WAAW;EACnC,eACE,EAAiB,GAAQ;GACvB,SAAS,EAAQ;GACjB,UAAU,EAAQ;GAClB,UAAU,EAAQ;GAClB,WAAW,EAAQ;EACrB,CAAC;CACL;AACF"}
@@ -1,12 +1,13 @@
1
1
  import { ApiRevenueResponse } from '../types/generated/enigma-solver.js';
2
2
  import { SolverRevenue } from './types.js';
3
3
  /**
4
- * Map the solver's `/revenue` response into the SDK's {@link SolverRevenue}.
4
+ * Map the solver's `/revenue/{symbolId}` response into the SDK's
5
+ * {@link SolverRevenue}.
5
6
  *
6
7
  * Every field is optional in the generated schema, so each defaults to `0` — the
7
8
  * solver omits a dimension rather than sending a zero when it has nothing for it.
8
9
  *
9
- * @param raw - The raw `/revenue` (or `/revenue/{symbolId}`) response body.
10
+ * @param raw - The raw `/revenue/{symbolId}` response body.
10
11
  * @returns The normalized revenue totals.
11
12
  */
12
13
  export declare function toSolverRevenue(raw: ApiRevenueResponse): SolverRevenue;
@@ -1 +1 @@
1
- {"version":3,"file":"to-solver-revenue.d.ts","sourceRoot":"","sources":["../../../src/solvers/revenue/to-solver-revenue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,kBAAkB,GAAG,aAAa,CAOtE"}
1
+ {"version":3,"file":"to-solver-revenue.d.ts","sourceRoot":"","sources":["../../../src/solvers/revenue/to-solver-revenue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,kBAAkB,GAAG,aAAa,CAOtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"to-solver-revenue.js","names":[],"sources":["../../../src/solvers/revenue/to-solver-revenue.ts"],"sourcesContent":["import { toFiniteNumber } from \"@symmio/utils/number\";\nimport type { ApiRevenueResponse } from \"../types/generated/enigma-solver\";\nimport type { SolverRevenue } from \"./types\";\n\n/**\n * Map the solver's `/revenue` response into the SDK's {@link SolverRevenue}.\n *\n * Every field is optional in the generated schema, so each defaults to `0` — the\n * solver omits a dimension rather than sending a zero when it has nothing for it.\n *\n * @param raw - The raw `/revenue` (or `/revenue/{symbolId}`) response body.\n * @returns The normalized revenue totals.\n */\nexport function toSolverRevenue(raw: ApiRevenueResponse): SolverRevenue {\n return {\n totalRevenue: toFiniteNumber(raw.total_revenue),\n hedgerFeeRevenue: toFiniteNumber(raw.hedger_fee_revenue),\n fundingRevenue: toFiniteNumber(raw.funding_revenue),\n recordCount: toFiniteNumber(raw.record_count),\n };\n}\n"],"mappings":";;AAaA,SAAgB,EAAgB,GAAwC;CACtE,OAAO;EACL,cAAc,EAAe,EAAI,aAAa;EAC9C,kBAAkB,EAAe,EAAI,kBAAkB;EACvD,gBAAgB,EAAe,EAAI,eAAe;EAClD,aAAa,EAAe,EAAI,YAAY;CAC9C;AACF"}
1
+ {"version":3,"file":"to-solver-revenue.js","names":[],"sources":["../../../src/solvers/revenue/to-solver-revenue.ts"],"sourcesContent":["import { toFiniteNumber } from \"@symmio/utils/number\";\nimport type { ApiRevenueResponse } from \"../types/generated/enigma-solver\";\nimport type { SolverRevenue } from \"./types\";\n\n/**\n * Map the solver's `/revenue/{symbolId}` response into the SDK's\n * {@link SolverRevenue}.\n *\n * Every field is optional in the generated schema, so each defaults to `0` — the\n * solver omits a dimension rather than sending a zero when it has nothing for it.\n *\n * @param raw - The raw `/revenue/{symbolId}` response body.\n * @returns The normalized revenue totals.\n */\nexport function toSolverRevenue(raw: ApiRevenueResponse): SolverRevenue {\n return {\n totalRevenue: toFiniteNumber(raw.total_revenue),\n hedgerFeeRevenue: toFiniteNumber(raw.hedger_fee_revenue),\n fundingRevenue: toFiniteNumber(raw.funding_revenue),\n recordCount: toFiniteNumber(raw.record_count),\n };\n}\n"],"mappings":";;AAcA,SAAgB,EAAgB,GAAwC;CACtE,OAAO;EACL,cAAc,EAAe,EAAI,aAAa;EAC9C,kBAAkB,EAAe,EAAI,kBAAkB;EACvD,gBAAgB,EAAe,EAAI,eAAe;EAClD,aAAa,EAAe,EAAI,YAAY;CAC9C;AACF"}
@@ -6,4 +6,5 @@
6
6
  * own `shared/` folder.
7
7
  */
8
8
  export * from './resolvers/index.js';
9
+ export * from './solver-close-fee.js';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/solvers/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/solvers/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}