@metamask-previews/perps-controller 1.3.0-preview-a0caca0c0 → 1.3.0-preview-afe010990

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 (158) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/PerpsController-method-action-types.cjs +3 -0
  3. package/dist/PerpsController-method-action-types.cjs.map +1 -0
  4. package/dist/PerpsController-method-action-types.d.cts +147 -0
  5. package/dist/PerpsController-method-action-types.d.cts.map +1 -0
  6. package/dist/PerpsController-method-action-types.d.mts +147 -0
  7. package/dist/PerpsController-method-action-types.d.mts.map +1 -0
  8. package/dist/PerpsController-method-action-types.mjs +2 -0
  9. package/dist/PerpsController-method-action-types.mjs.map +1 -0
  10. package/dist/PerpsController.cjs +488 -183
  11. package/dist/PerpsController.cjs.map +1 -1
  12. package/dist/PerpsController.d.cts +91 -131
  13. package/dist/PerpsController.d.cts.map +1 -1
  14. package/dist/PerpsController.d.mts +91 -131
  15. package/dist/PerpsController.d.mts.map +1 -1
  16. package/dist/PerpsController.mjs +485 -182
  17. package/dist/PerpsController.mjs.map +1 -1
  18. package/dist/constants/eventNames.cjs +26 -0
  19. package/dist/constants/eventNames.cjs.map +1 -1
  20. package/dist/constants/eventNames.d.cts +19 -0
  21. package/dist/constants/eventNames.d.cts.map +1 -1
  22. package/dist/constants/eventNames.d.mts +19 -0
  23. package/dist/constants/eventNames.d.mts.map +1 -1
  24. package/dist/constants/eventNames.mjs +26 -0
  25. package/dist/constants/eventNames.mjs.map +1 -1
  26. package/dist/constants/hyperLiquidConfig.cjs +24 -4
  27. package/dist/constants/hyperLiquidConfig.cjs.map +1 -1
  28. package/dist/constants/hyperLiquidConfig.d.cts +8 -3
  29. package/dist/constants/hyperLiquidConfig.d.cts.map +1 -1
  30. package/dist/constants/hyperLiquidConfig.d.mts +8 -3
  31. package/dist/constants/hyperLiquidConfig.d.mts.map +1 -1
  32. package/dist/constants/hyperLiquidConfig.mjs +23 -3
  33. package/dist/constants/hyperLiquidConfig.mjs.map +1 -1
  34. package/dist/constants/myxConfig.cjs +75 -51
  35. package/dist/constants/myxConfig.cjs.map +1 -1
  36. package/dist/constants/myxConfig.d.cts +58 -19
  37. package/dist/constants/myxConfig.d.cts.map +1 -1
  38. package/dist/constants/myxConfig.d.mts +58 -19
  39. package/dist/constants/myxConfig.d.mts.map +1 -1
  40. package/dist/constants/myxConfig.mjs +74 -50
  41. package/dist/constants/myxConfig.mjs.map +1 -1
  42. package/dist/constants/perpsConfig.cjs +6 -2
  43. package/dist/constants/perpsConfig.cjs.map +1 -1
  44. package/dist/constants/perpsConfig.d.cts +5 -1
  45. package/dist/constants/perpsConfig.d.cts.map +1 -1
  46. package/dist/constants/perpsConfig.d.mts +5 -1
  47. package/dist/constants/perpsConfig.d.mts.map +1 -1
  48. package/dist/constants/perpsConfig.mjs +5 -1
  49. package/dist/constants/perpsConfig.mjs.map +1 -1
  50. package/dist/index.cjs +243 -25
  51. package/dist/index.cjs.map +1 -1
  52. package/dist/index.d.cts +48 -5
  53. package/dist/index.d.cts.map +1 -1
  54. package/dist/index.d.mts +48 -5
  55. package/dist/index.d.mts.map +1 -1
  56. package/dist/index.mjs +36 -10
  57. package/dist/index.mjs.map +1 -1
  58. package/dist/providers/AggregatedPerpsProvider.cjs +24 -0
  59. package/dist/providers/AggregatedPerpsProvider.cjs.map +1 -1
  60. package/dist/providers/AggregatedPerpsProvider.d.cts +4 -0
  61. package/dist/providers/AggregatedPerpsProvider.d.cts.map +1 -1
  62. package/dist/providers/AggregatedPerpsProvider.d.mts +4 -0
  63. package/dist/providers/AggregatedPerpsProvider.d.mts.map +1 -1
  64. package/dist/providers/AggregatedPerpsProvider.mjs +24 -0
  65. package/dist/providers/AggregatedPerpsProvider.mjs.map +1 -1
  66. package/dist/providers/HyperLiquidProvider.cjs +470 -154
  67. package/dist/providers/HyperLiquidProvider.cjs.map +1 -1
  68. package/dist/providers/HyperLiquidProvider.d.cts +11 -2
  69. package/dist/providers/HyperLiquidProvider.d.cts.map +1 -1
  70. package/dist/providers/HyperLiquidProvider.d.mts +11 -2
  71. package/dist/providers/HyperLiquidProvider.d.mts.map +1 -1
  72. package/dist/providers/HyperLiquidProvider.mjs +471 -155
  73. package/dist/providers/HyperLiquidProvider.mjs.map +1 -1
  74. package/dist/selectors.cjs +1 -1
  75. package/dist/selectors.cjs.map +1 -1
  76. package/dist/selectors.mjs +1 -1
  77. package/dist/selectors.mjs.map +1 -1
  78. package/dist/services/AccountService.cjs +1 -1
  79. package/dist/services/AccountService.cjs.map +1 -1
  80. package/dist/services/AccountService.d.cts.map +1 -1
  81. package/dist/services/AccountService.d.mts.map +1 -1
  82. package/dist/services/AccountService.mjs +2 -2
  83. package/dist/services/AccountService.mjs.map +1 -1
  84. package/dist/services/DepositService.cjs +2 -1
  85. package/dist/services/DepositService.cjs.map +1 -1
  86. package/dist/services/DepositService.d.cts.map +1 -1
  87. package/dist/services/DepositService.d.mts.map +1 -1
  88. package/dist/services/DepositService.mjs +2 -1
  89. package/dist/services/DepositService.mjs.map +1 -1
  90. package/dist/services/EligibilityService.cjs +8 -103
  91. package/dist/services/EligibilityService.cjs.map +1 -1
  92. package/dist/services/EligibilityService.d.cts +4 -15
  93. package/dist/services/EligibilityService.d.cts.map +1 -1
  94. package/dist/services/EligibilityService.d.mts +4 -15
  95. package/dist/services/EligibilityService.d.mts.map +1 -1
  96. package/dist/services/EligibilityService.mjs +8 -103
  97. package/dist/services/EligibilityService.mjs.map +1 -1
  98. package/dist/services/HyperLiquidSubscriptionService.cjs +252 -46
  99. package/dist/services/HyperLiquidSubscriptionService.cjs.map +1 -1
  100. package/dist/services/HyperLiquidSubscriptionService.d.cts +1 -0
  101. package/dist/services/HyperLiquidSubscriptionService.d.cts.map +1 -1
  102. package/dist/services/HyperLiquidSubscriptionService.d.mts +1 -0
  103. package/dist/services/HyperLiquidSubscriptionService.d.mts.map +1 -1
  104. package/dist/services/HyperLiquidSubscriptionService.mjs +252 -46
  105. package/dist/services/HyperLiquidSubscriptionService.mjs.map +1 -1
  106. package/dist/services/MarketDataService.cjs +2 -4
  107. package/dist/services/MarketDataService.cjs.map +1 -1
  108. package/dist/services/MarketDataService.d.cts.map +1 -1
  109. package/dist/services/MarketDataService.d.mts.map +1 -1
  110. package/dist/services/MarketDataService.mjs +2 -4
  111. package/dist/services/MarketDataService.mjs.map +1 -1
  112. package/dist/services/TradingService.cjs +72 -6
  113. package/dist/services/TradingService.cjs.map +1 -1
  114. package/dist/services/TradingService.d.cts.map +1 -1
  115. package/dist/services/TradingService.d.mts.map +1 -1
  116. package/dist/services/TradingService.mjs +72 -6
  117. package/dist/services/TradingService.mjs.map +1 -1
  118. package/dist/types/index.cjs.map +1 -1
  119. package/dist/types/index.d.cts +51 -3
  120. package/dist/types/index.d.cts.map +1 -1
  121. package/dist/types/index.d.mts +51 -3
  122. package/dist/types/index.d.mts.map +1 -1
  123. package/dist/types/index.mjs.map +1 -1
  124. package/dist/types/messenger.cjs.map +1 -1
  125. package/dist/types/messenger.d.cts +2 -1
  126. package/dist/types/messenger.d.cts.map +1 -1
  127. package/dist/types/messenger.d.mts +2 -1
  128. package/dist/types/messenger.d.mts.map +1 -1
  129. package/dist/types/messenger.mjs.map +1 -1
  130. package/dist/types/myx-types.cjs +19 -3
  131. package/dist/types/myx-types.cjs.map +1 -1
  132. package/dist/types/myx-types.d.cts +33 -2
  133. package/dist/types/myx-types.d.cts.map +1 -1
  134. package/dist/types/myx-types.d.mts +33 -2
  135. package/dist/types/myx-types.d.mts.map +1 -1
  136. package/dist/types/myx-types.mjs +6 -2
  137. package/dist/types/myx-types.mjs.map +1 -1
  138. package/dist/types/perps-types.cjs +3 -0
  139. package/dist/types/perps-types.cjs.map +1 -1
  140. package/dist/types/perps-types.d.cts +3 -3
  141. package/dist/types/perps-types.d.cts.map +1 -1
  142. package/dist/types/perps-types.d.mts +3 -3
  143. package/dist/types/perps-types.d.mts.map +1 -1
  144. package/dist/types/perps-types.mjs +3 -0
  145. package/dist/types/perps-types.mjs.map +1 -1
  146. package/dist/utils/accountUtils.cjs.map +1 -1
  147. package/dist/utils/accountUtils.d.cts.map +1 -1
  148. package/dist/utils/accountUtils.d.mts.map +1 -1
  149. package/dist/utils/accountUtils.mjs.map +1 -1
  150. package/dist/utils/myxAdapter.cjs +360 -15
  151. package/dist/utils/myxAdapter.cjs.map +1 -1
  152. package/dist/utils/myxAdapter.d.cts +94 -7
  153. package/dist/utils/myxAdapter.d.cts.map +1 -1
  154. package/dist/utils/myxAdapter.d.mts +94 -7
  155. package/dist/utils/myxAdapter.d.mts.map +1 -1
  156. package/dist/utils/myxAdapter.mjs +351 -16
  157. package/dist/utils/myxAdapter.mjs.map +1 -1
  158. package/package.json +4 -2
@@ -1,4 +1,5 @@
1
1
  import type { AccountTreeControllerGetAccountsFromSelectedAccountGroupAction, AccountTreeControllerSelectedAccountGroupChangeEvent } from "@metamask/account-tree-controller";
2
+ import type { GeolocationControllerGetGeolocationAction } from "@metamask/geolocation-controller";
2
3
  import type { KeyringControllerGetStateAction, KeyringControllerSignTypedMessageAction } from "@metamask/keyring-controller";
3
4
  import type { Messenger } from "@metamask/messenger";
4
5
  import type { NetworkControllerGetStateAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerFindNetworkClientIdByChainIdAction } from "@metamask/network-controller";
@@ -8,7 +9,7 @@ import type { TransactionControllerAddTransactionAction } from "@metamask/transa
8
9
  /**
9
10
  * Actions from other controllers that PerpsController is allowed to call.
10
11
  */
11
- export type PerpsControllerAllowedActions = NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction | KeyringControllerGetStateAction | KeyringControllerSignTypedMessageAction | TransactionControllerAddTransactionAction | RemoteFeatureFlagControllerGetStateAction | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction | AuthenticationController.AuthenticationControllerGetBearerTokenAction;
12
+ export type PerpsControllerAllowedActions = GeolocationControllerGetGeolocationAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction | KeyringControllerGetStateAction | KeyringControllerSignTypedMessageAction | TransactionControllerAddTransactionAction | RemoteFeatureFlagControllerGetStateAction | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction | AuthenticationController.AuthenticationControllerGetBearerTokenAction;
12
13
  /**
13
14
  * Events from other controllers that PerpsController is allowed to subscribe to.
14
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"messenger.d.cts","sourceRoot":"","sources":["../../src/types/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8DAA8D,EAC9D,oDAAoD,EACrD,0CAA0C;AAC3C,OAAO,KAAK,EACV,+BAA+B,EAC/B,uCAAuC,EACxC,qCAAqC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,+BAA+B,EAC/B,2CAA2C,EAC3C,mDAAmD,EACpD,qCAAqC;AACtC,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C;AAClF,OAAO,KAAK,EACV,yCAAyC,EACzC,2CAA2C,EAC5C,iDAAiD;AAClD,OAAO,KAAK,EAAE,yCAAyC,EAAE,yCAAyC;AAElG;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,+BAA+B,GAC/B,2CAA2C,GAC3C,mDAAmD,GACnD,+BAA+B,GAC/B,uCAAuC,GACvC,yCAAyC,GACzC,yCAAyC,GACzC,8DAA8D,GAC9D,wBAAwB,CAAC,4CAA4C,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,2CAA2C,GAC3C,oDAAoD,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAM,MAAM,4BAA4B,GAAG,SAAS,CAClD,iBAAiB,EACjB,6BAA6B,EAC7B,4BAA4B,CAC7B,CAAC"}
1
+ {"version":3,"file":"messenger.d.cts","sourceRoot":"","sources":["../../src/types/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8DAA8D,EAC9D,oDAAoD,EACrD,0CAA0C;AAC3C,OAAO,KAAK,EAAE,yCAAyC,EAAE,yCAAyC;AAClG,OAAO,KAAK,EACV,+BAA+B,EAC/B,uCAAuC,EACxC,qCAAqC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,+BAA+B,EAC/B,2CAA2C,EAC3C,mDAAmD,EACpD,qCAAqC;AACtC,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C;AAClF,OAAO,KAAK,EACV,yCAAyC,EACzC,2CAA2C,EAC5C,iDAAiD;AAClD,OAAO,KAAK,EAAE,yCAAyC,EAAE,yCAAyC;AAElG;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,yCAAyC,GACzC,+BAA+B,GAC/B,2CAA2C,GAC3C,mDAAmD,GACnD,+BAA+B,GAC/B,uCAAuC,GACvC,yCAAyC,GACzC,yCAAyC,GACzC,8DAA8D,GAC9D,wBAAwB,CAAC,4CAA4C,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,2CAA2C,GAC3C,oDAAoD,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAM,MAAM,4BAA4B,GAAG,SAAS,CAClD,iBAAiB,EACjB,6BAA6B,EAC7B,4BAA4B,CAC7B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { AccountTreeControllerGetAccountsFromSelectedAccountGroupAction, AccountTreeControllerSelectedAccountGroupChangeEvent } from "@metamask/account-tree-controller";
2
+ import type { GeolocationControllerGetGeolocationAction } from "@metamask/geolocation-controller";
2
3
  import type { KeyringControllerGetStateAction, KeyringControllerSignTypedMessageAction } from "@metamask/keyring-controller";
3
4
  import type { Messenger } from "@metamask/messenger";
4
5
  import type { NetworkControllerGetStateAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerFindNetworkClientIdByChainIdAction } from "@metamask/network-controller";
@@ -8,7 +9,7 @@ import type { TransactionControllerAddTransactionAction } from "@metamask/transa
8
9
  /**
9
10
  * Actions from other controllers that PerpsController is allowed to call.
10
11
  */
11
- export type PerpsControllerAllowedActions = NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction | KeyringControllerGetStateAction | KeyringControllerSignTypedMessageAction | TransactionControllerAddTransactionAction | RemoteFeatureFlagControllerGetStateAction | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction | AuthenticationController.AuthenticationControllerGetBearerTokenAction;
12
+ export type PerpsControllerAllowedActions = GeolocationControllerGetGeolocationAction | NetworkControllerGetStateAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerFindNetworkClientIdByChainIdAction | KeyringControllerGetStateAction | KeyringControllerSignTypedMessageAction | TransactionControllerAddTransactionAction | RemoteFeatureFlagControllerGetStateAction | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction | AuthenticationController.AuthenticationControllerGetBearerTokenAction;
12
13
  /**
13
14
  * Events from other controllers that PerpsController is allowed to subscribe to.
14
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"messenger.d.mts","sourceRoot":"","sources":["../../src/types/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8DAA8D,EAC9D,oDAAoD,EACrD,0CAA0C;AAC3C,OAAO,KAAK,EACV,+BAA+B,EAC/B,uCAAuC,EACxC,qCAAqC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,+BAA+B,EAC/B,2CAA2C,EAC3C,mDAAmD,EACpD,qCAAqC;AACtC,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C;AAClF,OAAO,KAAK,EACV,yCAAyC,EACzC,2CAA2C,EAC5C,iDAAiD;AAClD,OAAO,KAAK,EAAE,yCAAyC,EAAE,yCAAyC;AAElG;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,+BAA+B,GAC/B,2CAA2C,GAC3C,mDAAmD,GACnD,+BAA+B,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{"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/types/messenger.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountTreeControllerGetAccountsFromSelectedAccountGroupAction,\n AccountTreeControllerSelectedAccountGroupChangeEvent,\n} from '@metamask/account-tree-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerSignTypedMessageAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerGetStateAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerFindNetworkClientIdByChainIdAction,\n} from '@metamask/network-controller';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport type {\n RemoteFeatureFlagControllerGetStateAction,\n RemoteFeatureFlagControllerStateChangeEvent,\n} from '@metamask/remote-feature-flag-controller';\nimport type { TransactionControllerAddTransactionAction } from '@metamask/transaction-controller';\n\n/**\n * Actions from other controllers that PerpsController is allowed to call.\n */\nexport type PerpsControllerAllowedActions =\n | NetworkControllerGetStateAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | KeyringControllerGetStateAction\n | KeyringControllerSignTypedMessageAction\n | TransactionControllerAddTransactionAction\n | RemoteFeatureFlagControllerGetStateAction\n | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction\n | AuthenticationController.AuthenticationControllerGetBearerTokenAction;\n\n/**\n * Events from other controllers that PerpsController is allowed to subscribe to.\n */\nexport type PerpsControllerAllowedEvents =\n | RemoteFeatureFlagControllerStateChangeEvent\n | AccountTreeControllerSelectedAccountGroupChangeEvent;\n\n/**\n * The messenger type used by PerpsController and its services.\n * Defined here (rather than in PerpsController.ts) to avoid circular imports\n * between the controller and service files.\n *\n * The first two type parameters (Actions, Events) are filled in by\n * PerpsController.ts when it unions in its own actions/events.\n * Services use this base type directly since they only need the allowed\n * external actions/events.\n */\nexport type PerpsControllerMessengerBase = Messenger<\n 'PerpsController',\n PerpsControllerAllowedActions,\n PerpsControllerAllowedEvents\n>;\n"]}
1
+ {"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/types/messenger.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountTreeControllerGetAccountsFromSelectedAccountGroupAction,\n AccountTreeControllerSelectedAccountGroupChangeEvent,\n} from '@metamask/account-tree-controller';\nimport type { GeolocationControllerGetGeolocationAction } from '@metamask/geolocation-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerSignTypedMessageAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n NetworkControllerGetStateAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerFindNetworkClientIdByChainIdAction,\n} from '@metamask/network-controller';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport type {\n RemoteFeatureFlagControllerGetStateAction,\n RemoteFeatureFlagControllerStateChangeEvent,\n} from '@metamask/remote-feature-flag-controller';\nimport type { TransactionControllerAddTransactionAction } from '@metamask/transaction-controller';\n\n/**\n * Actions from other controllers that PerpsController is allowed to call.\n */\nexport type PerpsControllerAllowedActions =\n | GeolocationControllerGetGeolocationAction\n | NetworkControllerGetStateAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerFindNetworkClientIdByChainIdAction\n | KeyringControllerGetStateAction\n | KeyringControllerSignTypedMessageAction\n | TransactionControllerAddTransactionAction\n | RemoteFeatureFlagControllerGetStateAction\n | AccountTreeControllerGetAccountsFromSelectedAccountGroupAction\n | AuthenticationController.AuthenticationControllerGetBearerTokenAction;\n\n/**\n * Events from other controllers that PerpsController is allowed to subscribe to.\n */\nexport type PerpsControllerAllowedEvents =\n | RemoteFeatureFlagControllerStateChangeEvent\n | AccountTreeControllerSelectedAccountGroupChangeEvent;\n\n/**\n * The messenger type used by PerpsController and its services.\n * Defined here (rather than in PerpsController.ts) to avoid circular imports\n * between the controller and service files.\n *\n * The first two type parameters (Actions, Events) are filled in by\n * PerpsController.ts when it unions in its own actions/events.\n * Services use this base type directly since they only need the allowed\n * external actions/events.\n */\nexport type PerpsControllerMessengerBase = Messenger<\n 'PerpsController',\n PerpsControllerAllowedActions,\n PerpsControllerAllowedEvents\n>;\n"]}
@@ -2,11 +2,27 @@
2
2
  /**
3
3
  * MYX Protocol Type Definitions
4
4
  *
5
- * Minimal types needed for Stage 1 (market display and price fetching).
6
- * Only defines what's needed - SDK types are re-exported with MYX prefix.
5
+ * SDK types re-exported with MYX prefix for consistency.
6
+ * Includes types for market display, positions, orders, and trading.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.MYX_HL_OVERLAPPING_MARKETS = void 0;
9
+ exports.MYX_HL_OVERLAPPING_MARKETS = exports.MYXTradeFlowTypeEnum = exports.MYXExecTypeEnum = exports.MYXOrderStatusEnum = exports.MYXOperationEnum = exports.MYXOrderTypeEnum = exports.MYXDirectionEnum = exports.MYXTimeInForce = exports.MYXOrderStatus = exports.MYXTriggerType = exports.MYXOperationType = exports.MYXOrderType = exports.MYXDirection = void 0;
10
+ // SDK enums (re-exported as types since they're const objects in the SDK)
11
+ var sdk_1 = require("@myx-trade/sdk");
12
+ Object.defineProperty(exports, "MYXDirection", { enumerable: true, get: function () { return sdk_1.Direction; } });
13
+ Object.defineProperty(exports, "MYXOrderType", { enumerable: true, get: function () { return sdk_1.OrderType; } });
14
+ Object.defineProperty(exports, "MYXOperationType", { enumerable: true, get: function () { return sdk_1.OperationType; } });
15
+ Object.defineProperty(exports, "MYXTriggerType", { enumerable: true, get: function () { return sdk_1.TriggerType; } });
16
+ Object.defineProperty(exports, "MYXOrderStatus", { enumerable: true, get: function () { return sdk_1.OrderStatus; } });
17
+ Object.defineProperty(exports, "MYXTimeInForce", { enumerable: true, get: function () { return sdk_1.TimeInForce; } });
18
+ // History enums
19
+ var sdk_2 = require("@myx-trade/sdk");
20
+ Object.defineProperty(exports, "MYXDirectionEnum", { enumerable: true, get: function () { return sdk_2.DirectionEnum; } });
21
+ Object.defineProperty(exports, "MYXOrderTypeEnum", { enumerable: true, get: function () { return sdk_2.OrderTypeEnum; } });
22
+ Object.defineProperty(exports, "MYXOperationEnum", { enumerable: true, get: function () { return sdk_2.OperationEnum; } });
23
+ Object.defineProperty(exports, "MYXOrderStatusEnum", { enumerable: true, get: function () { return sdk_2.OrderStatusEnum; } });
24
+ Object.defineProperty(exports, "MYXExecTypeEnum", { enumerable: true, get: function () { return sdk_2.ExecTypeEnum; } });
25
+ Object.defineProperty(exports, "MYXTradeFlowTypeEnum", { enumerable: true, get: function () { return sdk_2.TradeFlowTypeEnum; } });
10
26
  // ============================================================================
11
27
  // Market Overlap Configuration
12
28
  // ============================================================================
@@ -1 +1 @@
1
- {"version":3,"file":"myx-types.cjs","sourceRoot":"","sources":["../../src/types/myx-types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAwDH,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E;;;;GAIG;AACU,QAAA,0BAA0B,GAAG;IACxC,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;CACE,CAAC","sourcesContent":["/**\n * MYX Protocol Type Definitions\n *\n * Minimal types needed for Stage 1 (market display and price fetching).\n * Only defines what's needed - SDK types are re-exported with MYX prefix.\n */\n\nimport type { CaipChainId } from '@metamask/utils';\n\n// ============================================================================\n// Re-export SDK Types with MYX prefix for consistency\n// ============================================================================\n\nexport type { PoolSymbolAllResponse as MYXPoolSymbol } from '@myx-trade/sdk';\nexport type { TickerDataItem as MYXTicker } from '@myx-trade/sdk';\n\n// ============================================================================\n// Network Configuration Types\n// ============================================================================\n\n/**\n * MYX Network type - mainnet or testnet\n */\nexport type MYXNetwork = 'mainnet' | 'testnet';\n\n/**\n * MYX Endpoint configuration for a single network\n */\nexport type MYXEndpointConfig = {\n http: string;\n ws: string;\n};\n\n/**\n * MYX Endpoints for all networks\n */\nexport type MYXEndpoints = {\n mainnet: MYXEndpointConfig;\n testnet: MYXEndpointConfig;\n};\n\n/**\n * MYX Asset network configuration (token addresses per network)\n */\nexport type MYXAssetNetworkConfig = {\n chainId: CaipChainId;\n tokenAddress: string;\n};\n\n/**\n * MYX Asset configurations by network\n */\nexport type MYXAssetConfigs = {\n // USDT is the token symbol used as API key - not a variable name\n // eslint-disable-next-line @typescript-eslint/naming-convention\n USDT: {\n mainnet: MYXAssetNetworkConfig;\n testnet: MYXAssetNetworkConfig;\n };\n};\n\n// ============================================================================\n// Market Overlap Configuration\n// ============================================================================\n\n/**\n * Markets that overlap with HyperLiquid\n * These are excluded from MYX display in v1.0 to avoid confusion\n * In Stage 7, we'll implement market collision handling\n */\nexport const MYX_HL_OVERLAPPING_MARKETS = [\n 'BTC',\n 'ETH',\n 'BNB',\n 'PUMP',\n 'WLFI',\n] as const;\n\nexport type MYXOverlappingMarket = (typeof MYX_HL_OVERLAPPING_MARKETS)[number];\n\n// ============================================================================\n// Client Service Types\n// ============================================================================\n\n/**\n * Price callback for REST polling\n */\nexport type MYXPriceCallback = (\n tickers: { symbol: string; price: string; change24h: number }[],\n) => void;\n\n/**\n * Error callback for client operations\n */\nexport type MYXErrorCallback = (error: Error) => void;\n"]}
1
+ {"version":3,"file":"myx-types.cjs","sourceRoot":"","sources":["../../src/types/myx-types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAiCH,0EAA0E;AAC1E,sCAOwB;AANtB,mGAAA,SAAS,OAAgB;AACzB,mGAAA,SAAS,OAAgB;AACzB,uGAAA,aAAa,OAAoB;AACjC,qGAAA,WAAW,OAAkB;AAC7B,qGAAA,WAAW,OAAkB;AAC7B,qGAAA,WAAW,OAAkB;AAG/B,gBAAgB;AAChB,sCAOwB;AANtB,uGAAA,aAAa,OAAoB;AACjC,uGAAA,aAAa,OAAoB;AACjC,uGAAA,aAAa,OAAoB;AACjC,yGAAA,eAAe,OAAsB;AACrC,sGAAA,YAAY,OAAmB;AAC/B,2GAAA,iBAAiB,OAAwB;AAqD3C,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E;;;;GAIG;AACU,QAAA,0BAA0B,GAAG;IACxC,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;CACE,CAAC","sourcesContent":["/**\n * MYX Protocol Type Definitions\n *\n * SDK types re-exported with MYX prefix for consistency.\n * Includes types for market display, positions, orders, and trading.\n */\n\nimport type { CaipChainId } from '@metamask/utils';\n\n// ============================================================================\n// Re-export SDK Types with MYX prefix for consistency\n// ============================================================================\n\nexport type { PoolSymbolAllResponse as MYXPoolSymbol } from '@myx-trade/sdk';\nexport type { TickerDataItem as MYXTicker } from '@myx-trade/sdk';\n\n// Position & order types from SDK\nexport type { PositionType as MYXPositionType } from '@myx-trade/sdk';\nexport type { HistoryOrderItem as MYXHistoryOrderItem } from '@myx-trade/sdk';\nexport type { PositionHistoryItem as MYXPositionHistoryItem } from '@myx-trade/sdk';\nexport type { TradeFlowItem as MYXTradeFlowItem } from '@myx-trade/sdk';\nexport type { KlineDataItemType as MYXKlineData } from '@myx-trade/sdk';\n// KlineData is declared but not exported by @myx-trade/sdk — define locally.\n// Property names match the SDK's wire format (single-char keys).\nexport type MYXKlineWsData = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n E: number; // Timestamp\n // eslint-disable-next-line @typescript-eslint/naming-convention\n T: string; // Turnover\n c: string; // Close price\n h: string; // High price\n l: string; // Low price\n o: string; // Open price\n t: number; // Timestamp\n v: string; // Volume\n};\nexport type { KlineDataResponse as MYXKlineDataResponse } from '@myx-trade/sdk';\n\n// SDK enums (re-exported as types since they're const objects in the SDK)\nexport {\n Direction as MYXDirection,\n OrderType as MYXOrderType,\n OperationType as MYXOperationType,\n TriggerType as MYXTriggerType,\n OrderStatus as MYXOrderStatus,\n TimeInForce as MYXTimeInForce,\n} from '@myx-trade/sdk';\n\n// History enums\nexport {\n DirectionEnum as MYXDirectionEnum,\n OrderTypeEnum as MYXOrderTypeEnum,\n OperationEnum as MYXOperationEnum,\n OrderStatusEnum as MYXOrderStatusEnum,\n ExecTypeEnum as MYXExecTypeEnum,\n TradeFlowTypeEnum as MYXTradeFlowTypeEnum,\n} from '@myx-trade/sdk';\n\n// Trading params types\nexport type { PlaceOrderParams as MYXPlaceOrderParams } from '@myx-trade/sdk';\nexport type { PositionTpSlOrderParams as MYXPositionTpSlOrderParams } from '@myx-trade/sdk';\nexport type { GetHistoryOrdersParams as MYXGetHistoryOrdersParams } from '@myx-trade/sdk';\n\n// ============================================================================\n// Network Configuration Types\n// ============================================================================\n\n/**\n * MYX Network type - mainnet or testnet\n */\nexport type MYXNetwork = 'mainnet' | 'testnet';\n\n/**\n * MYX Endpoint configuration for a single network\n */\nexport type MYXEndpointConfig = {\n http: string;\n ws: string;\n};\n\n/**\n * MYX Endpoints for all networks\n */\nexport type MYXEndpoints = {\n mainnet: MYXEndpointConfig;\n testnet: MYXEndpointConfig;\n};\n\n/**\n * MYX Asset network configuration (token addresses per network)\n */\nexport type MYXAssetNetworkConfig = {\n chainId: CaipChainId;\n tokenAddress: string;\n};\n\n/**\n * MYX Asset configurations by network\n */\nexport type MYXAssetConfigs = {\n // USDT is the token symbol used as API key - not a variable name\n // eslint-disable-next-line @typescript-eslint/naming-convention\n USDT: {\n mainnet: MYXAssetNetworkConfig;\n testnet: MYXAssetNetworkConfig;\n };\n};\n\n// ============================================================================\n// Market Overlap Configuration\n// ============================================================================\n\n/**\n * Markets that overlap with HyperLiquid\n * These are excluded from MYX display in v1.0 to avoid confusion\n * In Stage 7, we'll implement market collision handling\n */\nexport const MYX_HL_OVERLAPPING_MARKETS = [\n 'BTC',\n 'ETH',\n 'BNB',\n 'PUMP',\n 'WLFI',\n] as const;\n\nexport type MYXOverlappingMarket = (typeof MYX_HL_OVERLAPPING_MARKETS)[number];\n\n// ============================================================================\n// Auth Configuration (passed from init file via babel-transformed env vars)\n// ============================================================================\n\n/**\n * MYX auth credentials passed at construction time.\n * Eliminates runtime `process.env` lookups — values come from the init file\n * where `process.env.X` is babel-transformed at build time.\n */\nexport type MYXAuthConfig = {\n appId: string;\n apiSecret: string;\n brokerAddress: string;\n};\n\n// ============================================================================\n// Client Service Types\n// ============================================================================\n\n/**\n * Price callback for REST polling\n */\nexport type MYXPriceCallback = (\n tickers: { symbol: string; price: string; change24h: number }[],\n) => void;\n\n/**\n * Error callback for client operations\n */\nexport type MYXErrorCallback = (error: Error) => void;\n"]}
@@ -1,12 +1,33 @@
1
1
  /**
2
2
  * MYX Protocol Type Definitions
3
3
  *
4
- * Minimal types needed for Stage 1 (market display and price fetching).
5
- * Only defines what's needed - SDK types are re-exported with MYX prefix.
4
+ * SDK types re-exported with MYX prefix for consistency.
5
+ * Includes types for market display, positions, orders, and trading.
6
6
  */
7
7
  import type { CaipChainId } from "@metamask/utils";
8
8
  export type { PoolSymbolAllResponse as MYXPoolSymbol } from "@myx-trade/sdk";
9
9
  export type { TickerDataItem as MYXTicker } from "@myx-trade/sdk";
10
+ export type { PositionType as MYXPositionType } from "@myx-trade/sdk";
11
+ export type { HistoryOrderItem as MYXHistoryOrderItem } from "@myx-trade/sdk";
12
+ export type { PositionHistoryItem as MYXPositionHistoryItem } from "@myx-trade/sdk";
13
+ export type { TradeFlowItem as MYXTradeFlowItem } from "@myx-trade/sdk";
14
+ export type { KlineDataItemType as MYXKlineData } from "@myx-trade/sdk";
15
+ export type MYXKlineWsData = {
16
+ E: number;
17
+ T: string;
18
+ c: string;
19
+ h: string;
20
+ l: string;
21
+ o: string;
22
+ t: number;
23
+ v: string;
24
+ };
25
+ export type { KlineDataResponse as MYXKlineDataResponse } from "@myx-trade/sdk";
26
+ export { Direction as MYXDirection, OrderType as MYXOrderType, OperationType as MYXOperationType, TriggerType as MYXTriggerType, OrderStatus as MYXOrderStatus, TimeInForce as MYXTimeInForce, } from "@myx-trade/sdk";
27
+ export { DirectionEnum as MYXDirectionEnum, OrderTypeEnum as MYXOrderTypeEnum, OperationEnum as MYXOperationEnum, OrderStatusEnum as MYXOrderStatusEnum, ExecTypeEnum as MYXExecTypeEnum, TradeFlowTypeEnum as MYXTradeFlowTypeEnum, } from "@myx-trade/sdk";
28
+ export type { PlaceOrderParams as MYXPlaceOrderParams } from "@myx-trade/sdk";
29
+ export type { PositionTpSlOrderParams as MYXPositionTpSlOrderParams } from "@myx-trade/sdk";
30
+ export type { GetHistoryOrdersParams as MYXGetHistoryOrdersParams } from "@myx-trade/sdk";
10
31
  /**
11
32
  * MYX Network type - mainnet or testnet
12
33
  */
@@ -48,6 +69,16 @@ export type MYXAssetConfigs = {
48
69
  */
49
70
  export declare const MYX_HL_OVERLAPPING_MARKETS: readonly ["BTC", "ETH", "BNB", "PUMP", "WLFI"];
50
71
  export type MYXOverlappingMarket = (typeof MYX_HL_OVERLAPPING_MARKETS)[number];
72
+ /**
73
+ * MYX auth credentials passed at construction time.
74
+ * Eliminates runtime `process.env` lookups — values come from the init file
75
+ * where `process.env.X` is babel-transformed at build time.
76
+ */
77
+ export type MYXAuthConfig = {
78
+ appId: string;
79
+ apiSecret: string;
80
+ brokerAddress: string;
81
+ };
51
82
  /**
52
83
  * Price callback for REST polling
53
84
  */
@@ -1 +1 @@
1
- {"version":3,"file":"myx-types.d.cts","sourceRoot":"","sources":["../../src/types/myx-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB;AAMnD,YAAY,EAAE,qBAAqB,IAAI,aAAa,EAAE,uBAAuB;AAC7E,YAAY,EAAE,cAAc,IAAI,SAAS,EAAE,uBAAuB;AAMlE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AAEF;;GAEG;A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AC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAG5B,IAAI,EAAE;QACJ,OAAO,EAAE,qBAAqB,CAAC;QAC/B,OAAO,EAAE,qBAAqB,CAAC;KAChC,CAAC;CACH,CAAC;AAMF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,gDAM7B,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAM/E;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAMF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAAE,KAC5D,IAAI,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC"}
@@ -1,12 +1,33 @@
1
1
  /**
2
2
  * MYX Protocol Type Definitions
3
3
  *
4
- * Minimal types needed for Stage 1 (market display and price fetching).
5
- * Only defines what's needed - SDK types are re-exported with MYX prefix.
4
+ * SDK types re-exported with MYX prefix for consistency.
5
+ * Includes types for market display, positions, orders, and trading.
6
6
  */
7
7
  import type { CaipChainId } from "@metamask/utils";
8
8
  export type { PoolSymbolAllResponse as MYXPoolSymbol } from "@myx-trade/sdk";
9
9
  export type { TickerDataItem as MYXTicker } from "@myx-trade/sdk";
10
+ export type { PositionType as MYXPositionType } from "@myx-trade/sdk";
11
+ export type { HistoryOrderItem as MYXHistoryOrderItem } from "@myx-trade/sdk";
12
+ export type { PositionHistoryItem as MYXPositionHistoryItem } from "@myx-trade/sdk";
13
+ export type { TradeFlowItem as MYXTradeFlowItem } from "@myx-trade/sdk";
14
+ export type { KlineDataItemType as MYXKlineData } from "@myx-trade/sdk";
15
+ export type MYXKlineWsData = {
16
+ E: number;
17
+ T: string;
18
+ c: string;
19
+ h: string;
20
+ l: string;
21
+ o: string;
22
+ t: number;
23
+ v: string;
24
+ };
25
+ export type { KlineDataResponse as MYXKlineDataResponse } from "@myx-trade/sdk";
26
+ export { Direction as MYXDirection, OrderType as MYXOrderType, OperationType as MYXOperationType, TriggerType as MYXTriggerType, OrderStatus as MYXOrderStatus, TimeInForce as MYXTimeInForce, } from "@myx-trade/sdk";
27
+ export { DirectionEnum as MYXDirectionEnum, OrderTypeEnum as MYXOrderTypeEnum, OperationEnum as MYXOperationEnum, OrderStatusEnum as MYXOrderStatusEnum, ExecTypeEnum as MYXExecTypeEnum, TradeFlowTypeEnum as MYXTradeFlowTypeEnum, } from "@myx-trade/sdk";
28
+ export type { PlaceOrderParams as MYXPlaceOrderParams } from "@myx-trade/sdk";
29
+ export type { PositionTpSlOrderParams as MYXPositionTpSlOrderParams } from "@myx-trade/sdk";
30
+ export type { GetHistoryOrdersParams as MYXGetHistoryOrdersParams } from "@myx-trade/sdk";
10
31
  /**
11
32
  * MYX Network type - mainnet or testnet
12
33
  */
@@ -48,6 +69,16 @@ export type MYXAssetConfigs = {
48
69
  */
49
70
  export declare const MYX_HL_OVERLAPPING_MARKETS: readonly ["BTC", "ETH", "BNB", "PUMP", "WLFI"];
50
71
  export type MYXOverlappingMarket = (typeof MYX_HL_OVERLAPPING_MARKETS)[number];
72
+ /**
73
+ * MYX auth credentials passed at construction time.
74
+ * Eliminates runtime `process.env` lookups — values come from the init file
75
+ * where `process.env.X` is babel-transformed at build time.
76
+ */
77
+ export type MYXAuthConfig = {
78
+ appId: string;
79
+ apiSecret: string;
80
+ brokerAddress: string;
81
+ };
51
82
  /**
52
83
  * Price callback for REST polling
53
84
  */
@@ -1 +1 @@
1
- {"version":3,"file":"myx-types.d.mts","sourceRoot":"","sources":["../../src/types/myx-types.ts"],"names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
1
1
  /**
2
2
  * MYX Protocol Type Definitions
3
3
  *
4
- * Minimal types needed for Stage 1 (market display and price fetching).
5
- * Only defines what's needed - SDK types are re-exported with MYX prefix.
4
+ * SDK types re-exported with MYX prefix for consistency.
5
+ * Includes types for market display, positions, orders, and trading.
6
6
  */
7
+ // SDK enums (re-exported as types since they're const objects in the SDK)
8
+ export { Direction as MYXDirection, OrderType as MYXOrderType, OperationType as MYXOperationType, TriggerType as MYXTriggerType, OrderStatus as MYXOrderStatus, TimeInForce as MYXTimeInForce } from "@myx-trade/sdk";
9
+ // History enums
10
+ export { DirectionEnum as MYXDirectionEnum, OrderTypeEnum as MYXOrderTypeEnum, OperationEnum as MYXOperationEnum, OrderStatusEnum as MYXOrderStatusEnum, ExecTypeEnum as MYXExecTypeEnum, TradeFlowTypeEnum as MYXTradeFlowTypeEnum } from "@myx-trade/sdk";
7
11
  // ============================================================================
8
12
  // Market Overlap Configuration
9
13
  // ============================================================================
@@ -1 +1 @@
1
- {"version":3,"file":"myx-types.mjs","sourceRoot":"","sources":["../../src/types/myx-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwDH,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;CACE,CAAC","sourcesContent":["/**\n * MYX Protocol Type Definitions\n *\n * Minimal types needed for Stage 1 (market display and price fetching).\n * Only defines what's needed - SDK types are re-exported with MYX prefix.\n */\n\nimport type { CaipChainId } from '@metamask/utils';\n\n// ============================================================================\n// Re-export SDK Types with MYX prefix for consistency\n// ============================================================================\n\nexport type { PoolSymbolAllResponse as MYXPoolSymbol } from '@myx-trade/sdk';\nexport type { TickerDataItem as MYXTicker } from '@myx-trade/sdk';\n\n// ============================================================================\n// Network Configuration Types\n// ============================================================================\n\n/**\n * MYX Network type - mainnet or testnet\n */\nexport type MYXNetwork = 'mainnet' | 'testnet';\n\n/**\n * MYX Endpoint configuration for a single network\n */\nexport type MYXEndpointConfig = {\n http: string;\n ws: string;\n};\n\n/**\n * MYX Endpoints for all networks\n */\nexport type MYXEndpoints = {\n mainnet: MYXEndpointConfig;\n testnet: MYXEndpointConfig;\n};\n\n/**\n * MYX Asset network configuration (token addresses per network)\n */\nexport type MYXAssetNetworkConfig = {\n chainId: CaipChainId;\n tokenAddress: string;\n};\n\n/**\n * MYX Asset configurations by network\n */\nexport type MYXAssetConfigs = {\n // USDT is the token symbol used as API key - not a variable name\n // eslint-disable-next-line @typescript-eslint/naming-convention\n USDT: {\n mainnet: MYXAssetNetworkConfig;\n testnet: MYXAssetNetworkConfig;\n };\n};\n\n// ============================================================================\n// Market Overlap Configuration\n// ============================================================================\n\n/**\n * Markets that overlap with HyperLiquid\n * These are excluded from MYX display in v1.0 to avoid confusion\n * In Stage 7, we'll implement market collision handling\n */\nexport const MYX_HL_OVERLAPPING_MARKETS = [\n 'BTC',\n 'ETH',\n 'BNB',\n 'PUMP',\n 'WLFI',\n] as const;\n\nexport type MYXOverlappingMarket = (typeof MYX_HL_OVERLAPPING_MARKETS)[number];\n\n// ============================================================================\n// Client Service Types\n// ============================================================================\n\n/**\n * Price callback for REST polling\n */\nexport type MYXPriceCallback = (\n tickers: { symbol: string; price: string; change24h: number }[],\n) => void;\n\n/**\n * Error callback for client operations\n */\nexport type MYXErrorCallback = (error: Error) => void;\n"]}
1
+ {"version":3,"file":"myx-types.mjs","sourceRoot":"","sources":["../../src/types/myx-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiCH,0EAA0E;AAC1E,OAAO,EACL,SAAS,IAAI,YAAY,EACzB,SAAS,IAAI,YAAY,EACzB,aAAa,IAAI,gBAAgB,EACjC,WAAW,IAAI,cAAc,EAC7B,WAAW,IAAI,cAAc,EAC7B,WAAW,IAAI,cAAc,EAC9B,uBAAuB;AAExB,gBAAgB;AAChB,OAAO,EACL,aAAa,IAAI,gBAAgB,EACjC,aAAa,IAAI,gBAAgB,EACjC,aAAa,IAAI,gBAAgB,EACjC,eAAe,IAAI,kBAAkB,EACrC,YAAY,IAAI,eAAe,EAC/B,iBAAiB,IAAI,oBAAoB,EAC1C,uBAAuB;AAoDxB,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;CACE,CAAC","sourcesContent":["/**\n * MYX Protocol Type Definitions\n *\n * SDK types re-exported with MYX prefix for consistency.\n * Includes types for market display, positions, orders, and trading.\n */\n\nimport type { CaipChainId } from '@metamask/utils';\n\n// ============================================================================\n// Re-export SDK Types with MYX prefix for consistency\n// ============================================================================\n\nexport type { PoolSymbolAllResponse as MYXPoolSymbol } from '@myx-trade/sdk';\nexport type { TickerDataItem as MYXTicker } from '@myx-trade/sdk';\n\n// Position & order types from SDK\nexport type { PositionType as MYXPositionType } from '@myx-trade/sdk';\nexport type { HistoryOrderItem as MYXHistoryOrderItem } from '@myx-trade/sdk';\nexport type { PositionHistoryItem as MYXPositionHistoryItem } from '@myx-trade/sdk';\nexport type { TradeFlowItem as MYXTradeFlowItem } from '@myx-trade/sdk';\nexport type { KlineDataItemType as MYXKlineData } from '@myx-trade/sdk';\n// KlineData is declared but not exported by @myx-trade/sdk — define locally.\n// Property names match the SDK's wire format (single-char keys).\nexport type MYXKlineWsData = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n E: number; // Timestamp\n // eslint-disable-next-line @typescript-eslint/naming-convention\n T: string; // Turnover\n c: string; // Close price\n h: string; // High price\n l: string; // Low price\n o: string; // Open price\n t: number; // Timestamp\n v: string; // Volume\n};\nexport type { KlineDataResponse as MYXKlineDataResponse } from '@myx-trade/sdk';\n\n// SDK enums (re-exported as types since they're const objects in the SDK)\nexport {\n Direction as MYXDirection,\n OrderType as MYXOrderType,\n OperationType as MYXOperationType,\n TriggerType as MYXTriggerType,\n OrderStatus as MYXOrderStatus,\n TimeInForce as MYXTimeInForce,\n} from '@myx-trade/sdk';\n\n// History enums\nexport {\n DirectionEnum as MYXDirectionEnum,\n OrderTypeEnum as MYXOrderTypeEnum,\n OperationEnum as MYXOperationEnum,\n OrderStatusEnum as MYXOrderStatusEnum,\n ExecTypeEnum as MYXExecTypeEnum,\n TradeFlowTypeEnum as MYXTradeFlowTypeEnum,\n} from '@myx-trade/sdk';\n\n// Trading params types\nexport type { PlaceOrderParams as MYXPlaceOrderParams } from '@myx-trade/sdk';\nexport type { PositionTpSlOrderParams as MYXPositionTpSlOrderParams } from '@myx-trade/sdk';\nexport type { GetHistoryOrdersParams as MYXGetHistoryOrdersParams } from '@myx-trade/sdk';\n\n// ============================================================================\n// Network Configuration Types\n// ============================================================================\n\n/**\n * MYX Network type - mainnet or testnet\n */\nexport type MYXNetwork = 'mainnet' | 'testnet';\n\n/**\n * MYX Endpoint configuration for a single network\n */\nexport type MYXEndpointConfig = {\n http: string;\n ws: string;\n};\n\n/**\n * MYX Endpoints for all networks\n */\nexport type MYXEndpoints = {\n mainnet: MYXEndpointConfig;\n testnet: MYXEndpointConfig;\n};\n\n/**\n * MYX Asset network configuration (token addresses per network)\n */\nexport type MYXAssetNetworkConfig = {\n chainId: CaipChainId;\n tokenAddress: string;\n};\n\n/**\n * MYX Asset configurations by network\n */\nexport type MYXAssetConfigs = {\n // USDT is the token symbol used as API key - not a variable name\n // eslint-disable-next-line @typescript-eslint/naming-convention\n USDT: {\n mainnet: MYXAssetNetworkConfig;\n testnet: MYXAssetNetworkConfig;\n };\n};\n\n// ============================================================================\n// Market Overlap Configuration\n// ============================================================================\n\n/**\n * Markets that overlap with HyperLiquid\n * These are excluded from MYX display in v1.0 to avoid confusion\n * In Stage 7, we'll implement market collision handling\n */\nexport const MYX_HL_OVERLAPPING_MARKETS = [\n 'BTC',\n 'ETH',\n 'BNB',\n 'PUMP',\n 'WLFI',\n] as const;\n\nexport type MYXOverlappingMarket = (typeof MYX_HL_OVERLAPPING_MARKETS)[number];\n\n// ============================================================================\n// Auth Configuration (passed from init file via babel-transformed env vars)\n// ============================================================================\n\n/**\n * MYX auth credentials passed at construction time.\n * Eliminates runtime `process.env` lookups — values come from the init file\n * where `process.env.X` is babel-transformed at build time.\n */\nexport type MYXAuthConfig = {\n appId: string;\n apiSecret: string;\n brokerAddress: string;\n};\n\n// ============================================================================\n// Client Service Types\n// ============================================================================\n\n/**\n * Price callback for REST polling\n */\nexport type MYXPriceCallback = (\n tickers: { symbol: string; price: string; change24h: number }[],\n) => void;\n\n/**\n * Error callback for client operations\n */\nexport type MYXErrorCallback = (error: Error) => void;\n"]}
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Test result states for SDK validation
5
+ */
3
6
  const chartConfig_1 = require("../constants/chartConfig.cjs");
4
7
  //# sourceMappingURL=perps-types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"perps-types.cjs","sourceRoot":"","sources":["../../src/types/perps-types.ts"],"names":[],"mappings":";;AAIA,8DAAwD","sourcesContent":["/**\n * Test result states for SDK validation\n */\nimport { OrderType } from '.';\nimport { CandlePeriod } from '../constants/chartConfig';\n\nexport type TestResultStatus =\n | 'idle'\n | 'loading'\n | 'success'\n | 'warning'\n | 'error';\n\n/**\n * Test result data structure\n */\nexport type TestResult = {\n status: TestResultStatus;\n message: string;\n data?: Record<string, unknown>;\n};\n\n/**\n * SDK test types\n */\nexport type SDKTestType = 'connection' | 'asset-listing' | 'websocket';\n\n/**\n * Hyperliquid asset interface (basic structure)\n */\nexport type HyperliquidAsset = {\n name: string;\n [key: string]: unknown;\n};\n\n/**\n * Represents a single candlestick data point\n */\nexport type CandleStick = {\n time: number;\n open: string;\n high: string;\n low: string;\n close: string;\n volume: string;\n};\n\n/**\n * Represents historical candlestick data for a specific symbol and interval\n */\nexport type CandleData = {\n /** Asset identifier (e.g., 'BTC', 'ETH'). Protocol-agnostic terminology for multi-provider support. */\n symbol: string;\n interval: CandlePeriod;\n candles: CandleStick[];\n};\n\n// Export all configuration types directly\nexport type * from './config';\nexport type * from './token';\n\n/**\n * Order form state for the Perps order view\n */\nexport type OrderFormState = {\n asset: string;\n direction: 'long' | 'short';\n amount: string;\n leverage: number;\n balancePercent: number;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n limitPrice?: string;\n type: OrderType;\n};\n\nexport type OrderDirection = 'long' | 'short';\n\n/**\n * Options for reconnecting the Perps connection\n */\nexport type ReconnectOptions = {\n /**\n * If true, forces immediate disconnect and cancels all pending operations.\n * Use for user-initiated retry actions.\n * If false (default), waits for pending operations to complete.\n * Use for automatic reconnections like account switches.\n */\n force?: boolean;\n};\n\n/**\n * Extended asset metadata including Growth Mode fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedAssetMeta = {\n name: string;\n szDecimals: number;\n maxLeverage: number;\n /** Per-asset Growth Mode status - \"enabled\" means 90% fee reduction */\n growthMode?: 'enabled' | null;\n /** ISO timestamp of last Growth Mode change */\n lastGrowthModeChangeTime?: string;\n};\n\n/**\n * Extended perp DEX info including fee scale fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedPerpDex = {\n name: string;\n fullName?: string;\n deployer?: string;\n /** DEX-level fee scale (e.g., \"1.0\" for xyz DEX) - determines HIP-3 multiplier */\n deployerFeeScale?: string;\n /** ISO timestamp of last fee scale change */\n lastDeployerFeeScaleChangeTime?: string;\n};\n"]}
1
+ {"version":3,"file":"perps-types.cjs","sourceRoot":"","sources":["../../src/types/perps-types.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,8DAAwD","sourcesContent":["/**\n * Test result states for SDK validation\n */\nimport { CandlePeriod } from '../constants/chartConfig';\n\n// Order type enumeration\nexport type OrderType = 'market' | 'limit';\n\nexport type TestResultStatus =\n | 'idle'\n | 'loading'\n | 'success'\n | 'warning'\n | 'error';\n\n/**\n * Test result data structure\n */\nexport type TestResult = {\n status: TestResultStatus;\n message: string;\n data?: Record<string, unknown>;\n};\n\n/**\n * SDK test types\n */\nexport type SDKTestType = 'connection' | 'asset-listing' | 'websocket';\n\n/**\n * Hyperliquid asset interface (basic structure)\n */\nexport type HyperliquidAsset = {\n name: string;\n [key: string]: unknown;\n};\n\n/**\n * Represents a single candlestick data point\n */\nexport type CandleStick = {\n time: number;\n open: string;\n high: string;\n low: string;\n close: string;\n volume: string;\n};\n\n/**\n * Represents historical candlestick data for a specific symbol and interval\n */\nexport type CandleData = {\n /** Asset identifier (e.g., 'BTC', 'ETH'). Protocol-agnostic terminology for multi-provider support. */\n symbol: string;\n interval: CandlePeriod;\n candles: CandleStick[];\n};\n\n// Configuration types\nexport type {\n HyperLiquidEndpoints,\n AssetNetworkConfig,\n HyperLiquidAssetConfigs,\n BridgeContractConfig,\n HyperLiquidBridgeContracts,\n TransportReconnectConfig,\n TransportKeepAliveConfig,\n HyperLiquidTransportConfig,\n TradingAmountConfig,\n TradingDefaultsConfig,\n FeeRatesConfig,\n HyperLiquidNetwork,\n} from './config';\n\n// Token types\nexport type { PerpsToken } from './token';\n\n/**\n * Order form state for the Perps order view\n */\nexport type OrderFormState = {\n asset: string;\n direction: 'long' | 'short';\n amount: string;\n leverage: number;\n balancePercent: number;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n limitPrice?: string;\n type: OrderType;\n};\n\nexport type OrderDirection = 'long' | 'short';\n\n/**\n * Options for reconnecting the Perps connection\n */\nexport type ReconnectOptions = {\n /**\n * If true, forces immediate disconnect and cancels all pending operations.\n * Use for user-initiated retry actions.\n * If false (default), waits for pending operations to complete.\n * Use for automatic reconnections like account switches.\n */\n force?: boolean;\n};\n\n/**\n * Extended asset metadata including Growth Mode fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedAssetMeta = {\n name: string;\n szDecimals: number;\n maxLeverage: number;\n /** Per-asset Growth Mode status - \"enabled\" means 90% fee reduction */\n growthMode?: 'enabled' | null;\n /** ISO timestamp of last Growth Mode change */\n lastGrowthModeChangeTime?: string;\n};\n\n/**\n * Extended perp DEX info including fee scale fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedPerpDex = {\n name: string;\n fullName?: string;\n deployer?: string;\n /** DEX-level fee scale (e.g., \"1.0\" for xyz DEX) - determines HIP-3 multiplier */\n deployerFeeScale?: string;\n /** ISO timestamp of last fee scale change */\n lastDeployerFeeScaleChangeTime?: string;\n};\n"]}
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Test result states for SDK validation
3
3
  */
4
- import { OrderType } from "./index.cjs";
5
4
  import { CandlePeriod } from "../constants/chartConfig.cjs";
5
+ export type OrderType = 'market' | 'limit';
6
6
  export type TestResultStatus = 'idle' | 'loading' | 'success' | 'warning' | 'error';
7
7
  /**
8
8
  * Test result data structure
@@ -43,8 +43,8 @@ export type CandleData = {
43
43
  interval: CandlePeriod;
44
44
  candles: CandleStick[];
45
45
  };
46
- export type * from "./config.cjs";
47
- export type * from "./token.cjs";
46
+ export type { HyperLiquidEndpoints, AssetNetworkConfig, HyperLiquidAssetConfigs, BridgeContractConfig, HyperLiquidBridgeContracts, TransportReconnectConfig, TransportKeepAliveConfig, HyperLiquidTransportConfig, TradingAmountConfig, TradingDefaultsConfig, FeeRatesConfig, HyperLiquidNetwork, } from "./config.cjs";
47
+ export type { PerpsToken } from "./token.cjs";
48
48
  /**
49
49
  * Order form state for the Perps order view
50
50
  */
@@ -1 +1 @@
1
- {"version":3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,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,UAAU,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,+CAA+C;IAC/C,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACzC,CAAC"}
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Test result states for SDK validation
3
3
  */
4
- import { OrderType } from "./index.mjs";
5
4
  import { CandlePeriod } from "../constants/chartConfig.mjs";
5
+ export type OrderType = 'market' | 'limit';
6
6
  export type TestResultStatus = 'idle' | 'loading' | 'success' | 'warning' | 'error';
7
7
  /**
8
8
  * Test result data structure
@@ -43,8 +43,8 @@ export type CandleData = {
43
43
  interval: CandlePeriod;
44
44
  candles: CandleStick[];
45
45
  };
46
- export type * from "./config.mjs";
47
- export type * from "./token.mjs";
46
+ export type { HyperLiquidEndpoints, AssetNetworkConfig, HyperLiquidAssetConfigs, BridgeContractConfig, HyperLiquidBridgeContracts, TransportReconnectConfig, TransportKeepAliveConfig, HyperLiquidTransportConfig, TradingAmountConfig, TradingDefaultsConfig, FeeRatesConfig, HyperLiquidNetwork, } from "./config.mjs";
47
+ export type { PerpsToken } from "./token.mjs";
48
48
  /**
49
49
  * Order form state for the Perps order view
50
50
  */
@@ -1 +1 @@
1
- {"version":3,"file":"perps-types.d.mts","sourceRoot":"","sources":["../../src/types/perps-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,oBAAU;AAC9B,OAAO,EAAE,YAAY,EAAE,qCAAiC;AAExD,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,SAAS,GACT,SAAS,GACT,SAAS,GACT,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,eAAe,GAAG,WAAW,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,uGAAuG;IACvG,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;A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AAC;IACd,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,UAAU,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,+CAA+C;IAC/C,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,8BAA8B,CAAC,EAAE,MAAM,CAAC;CACzC,CAAC"}
@@ -1,2 +1,5 @@
1
+ /**
2
+ * Test result states for SDK validation
3
+ */
1
4
  import { CandlePeriod } from "../constants/chartConfig.mjs";
2
5
  //# sourceMappingURL=perps-types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"perps-types.mjs","sourceRoot":"","sources":["../../src/types/perps-types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,qCAAiC","sourcesContent":["/**\n * Test result states for SDK validation\n */\nimport { OrderType } from '.';\nimport { CandlePeriod } from '../constants/chartConfig';\n\nexport type TestResultStatus =\n | 'idle'\n | 'loading'\n | 'success'\n | 'warning'\n | 'error';\n\n/**\n * Test result data structure\n */\nexport type TestResult = {\n status: TestResultStatus;\n message: string;\n data?: Record<string, unknown>;\n};\n\n/**\n * SDK test types\n */\nexport type SDKTestType = 'connection' | 'asset-listing' | 'websocket';\n\n/**\n * Hyperliquid asset interface (basic structure)\n */\nexport type HyperliquidAsset = {\n name: string;\n [key: string]: unknown;\n};\n\n/**\n * Represents a single candlestick data point\n */\nexport type CandleStick = {\n time: number;\n open: string;\n high: string;\n low: string;\n close: string;\n volume: string;\n};\n\n/**\n * Represents historical candlestick data for a specific symbol and interval\n */\nexport type CandleData = {\n /** Asset identifier (e.g., 'BTC', 'ETH'). Protocol-agnostic terminology for multi-provider support. */\n symbol: string;\n interval: CandlePeriod;\n candles: CandleStick[];\n};\n\n// Export all configuration types directly\nexport type * from './config';\nexport type * from './token';\n\n/**\n * Order form state for the Perps order view\n */\nexport type OrderFormState = {\n asset: string;\n direction: 'long' | 'short';\n amount: string;\n leverage: number;\n balancePercent: number;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n limitPrice?: string;\n type: OrderType;\n};\n\nexport type OrderDirection = 'long' | 'short';\n\n/**\n * Options for reconnecting the Perps connection\n */\nexport type ReconnectOptions = {\n /**\n * If true, forces immediate disconnect and cancels all pending operations.\n * Use for user-initiated retry actions.\n * If false (default), waits for pending operations to complete.\n * Use for automatic reconnections like account switches.\n */\n force?: boolean;\n};\n\n/**\n * Extended asset metadata including Growth Mode fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedAssetMeta = {\n name: string;\n szDecimals: number;\n maxLeverage: number;\n /** Per-asset Growth Mode status - \"enabled\" means 90% fee reduction */\n growthMode?: 'enabled' | null;\n /** ISO timestamp of last Growth Mode change */\n lastGrowthModeChangeTime?: string;\n};\n\n/**\n * Extended perp DEX info including fee scale fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedPerpDex = {\n name: string;\n fullName?: string;\n deployer?: string;\n /** DEX-level fee scale (e.g., \"1.0\" for xyz DEX) - determines HIP-3 multiplier */\n deployerFeeScale?: string;\n /** ISO timestamp of last fee scale change */\n lastDeployerFeeScaleChangeTime?: string;\n};\n"]}
1
+ {"version":3,"file":"perps-types.mjs","sourceRoot":"","sources":["../../src/types/perps-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,qCAAiC","sourcesContent":["/**\n * Test result states for SDK validation\n */\nimport { CandlePeriod } from '../constants/chartConfig';\n\n// Order type enumeration\nexport type OrderType = 'market' | 'limit';\n\nexport type TestResultStatus =\n | 'idle'\n | 'loading'\n | 'success'\n | 'warning'\n | 'error';\n\n/**\n * Test result data structure\n */\nexport type TestResult = {\n status: TestResultStatus;\n message: string;\n data?: Record<string, unknown>;\n};\n\n/**\n * SDK test types\n */\nexport type SDKTestType = 'connection' | 'asset-listing' | 'websocket';\n\n/**\n * Hyperliquid asset interface (basic structure)\n */\nexport type HyperliquidAsset = {\n name: string;\n [key: string]: unknown;\n};\n\n/**\n * Represents a single candlestick data point\n */\nexport type CandleStick = {\n time: number;\n open: string;\n high: string;\n low: string;\n close: string;\n volume: string;\n};\n\n/**\n * Represents historical candlestick data for a specific symbol and interval\n */\nexport type CandleData = {\n /** Asset identifier (e.g., 'BTC', 'ETH'). Protocol-agnostic terminology for multi-provider support. */\n symbol: string;\n interval: CandlePeriod;\n candles: CandleStick[];\n};\n\n// Configuration types\nexport type {\n HyperLiquidEndpoints,\n AssetNetworkConfig,\n HyperLiquidAssetConfigs,\n BridgeContractConfig,\n HyperLiquidBridgeContracts,\n TransportReconnectConfig,\n TransportKeepAliveConfig,\n HyperLiquidTransportConfig,\n TradingAmountConfig,\n TradingDefaultsConfig,\n FeeRatesConfig,\n HyperLiquidNetwork,\n} from './config';\n\n// Token types\nexport type { PerpsToken } from './token';\n\n/**\n * Order form state for the Perps order view\n */\nexport type OrderFormState = {\n asset: string;\n direction: 'long' | 'short';\n amount: string;\n leverage: number;\n balancePercent: number;\n takeProfitPrice?: string;\n stopLossPrice?: string;\n limitPrice?: string;\n type: OrderType;\n};\n\nexport type OrderDirection = 'long' | 'short';\n\n/**\n * Options for reconnecting the Perps connection\n */\nexport type ReconnectOptions = {\n /**\n * If true, forces immediate disconnect and cancels all pending operations.\n * Use for user-initiated retry actions.\n * If false (default), waits for pending operations to complete.\n * Use for automatic reconnections like account switches.\n */\n force?: boolean;\n};\n\n/**\n * Extended asset metadata including Growth Mode fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedAssetMeta = {\n name: string;\n szDecimals: number;\n maxLeverage: number;\n /** Per-asset Growth Mode status - \"enabled\" means 90% fee reduction */\n growthMode?: 'enabled' | null;\n /** ISO timestamp of last Growth Mode change */\n lastGrowthModeChangeTime?: string;\n};\n\n/**\n * Extended perp DEX info including fee scale fields not in SDK types.\n * The HyperLiquid API returns these fields but the SDK doesn't type them.\n *\n * @see https://hyperliquid.gitbook.io/hyperliquid-docs/trading/fees#fee-formula-for-developers\n */\nexport type ExtendedPerpDex = {\n name: string;\n fullName?: string;\n deployer?: string;\n /** DEX-level fee scale (e.g., \"1.0\" for xyz DEX) - determines HIP-3 multiplier */\n deployerFeeScale?: string;\n /** ISO timestamp of last fee scale change */\n lastDeployerFeeScaleChangeTime?: string;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"accountUtils.cjs","sourceRoot":"","sources":["../../src/utils/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AU,CAAC;AACpB,CAAC;AA/CD,wDA+CC","sourcesContent":["/**\n * Account utilities for Perps components\n * Handles account selection and EVM account filtering\n */\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig';\nimport type { AccountState, PerpsInternalAccount } from '../types';\n\nconst EVM_ACCOUNT_TYPES = new Set(['eip155:eoa', 'eip155:erc4337']);\n\nfunction isEvmAccountType(type: string): boolean {\n return EVM_ACCOUNT_TYPES.has(type);\n}\n\nexport function findEvmAccount(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string; type: string } | null {\n const evmAccount = accounts.find(\n (account) => account && isEvmAccountType(account.type),\n );\n return evmAccount ?? null;\n}\n\nexport function getEvmAccountFromAccountGroup(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string } | undefined {\n const evmAccount = findEvmAccount(accounts);\n return evmAccount ? { address: evmAccount.address } : undefined;\n}\n\nexport function getSelectedEvmAccount(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string } | undefined {\n return getEvmAccountFromAccountGroup(accounts);\n}\n\nexport type ReturnOnEquityInput = {\n unrealizedPnl: string | number;\n returnOnEquity: string | number;\n};\n\nexport function calculateWeightedReturnOnEquity(\n accounts: ReturnOnEquityInput[],\n): string {\n if (accounts.length === 0) {\n return '0';\n }\n\n let totalWeightedROE = 0;\n let totalMarginUsed = 0;\n\n for (const account of accounts) {\n const unrealizedPnl =\n typeof account.unrealizedPnl === 'string'\n ? Number.parseFloat(account.unrealizedPnl)\n : account.unrealizedPnl;\n const returnOnEquity =\n typeof account.returnOnEquity === 'string'\n ? Number.parseFloat(account.returnOnEquity)\n : account.returnOnEquity;\n\n if (Number.isNaN(unrealizedPnl) || Number.isNaN(returnOnEquity)) {\n continue;\n }\n\n if (returnOnEquity === 0) {\n continue;\n }\n\n const marginUsed = (unrealizedPnl / returnOnEquity) * 100;\n\n if (Number.isNaN(marginUsed) || marginUsed <= 0) {\n continue;\n }\n\n const roeDecimal = returnOnEquity / 100;\n\n totalWeightedROE += roeDecimal * marginUsed;\n totalMarginUsed += marginUsed;\n }\n\n if (totalMarginUsed <= 0) {\n return '0';\n }\n\n const weightedROE = (totalWeightedROE / totalMarginUsed) * 100;\n return weightedROE.toString();\n}\n\n/**\n * Aggregate multiple per-DEX AccountState objects into one by summing numeric fields.\n * ROE is recalculated as (totalUnrealizedPnl / totalMarginUsed) * 100.\n *\n * @param states - The array of per-DEX account states to aggregate.\n * @returns The combined account state with summed balances and recalculated ROE.\n */\nexport function aggregateAccountStates(states: AccountState[]): AccountState {\n const fallback: AccountState = {\n availableBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n totalBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n marginUsed: PERPS_CONSTANTS.FallbackDataDisplay,\n unrealizedPnl: PERPS_CONSTANTS.FallbackDataDisplay,\n returnOnEquity: PERPS_CONSTANTS.FallbackDataDisplay,\n };\n\n if (states.length === 0) {\n return fallback;\n }\n\n const aggregated = states.reduce<AccountState>((acc, state, index) => {\n if (index === 0) {\n return { ...state };\n }\n return {\n availableBalance: (\n parseFloat(acc.availableBalance) + parseFloat(state.availableBalance)\n ).toString(),\n totalBalance: (\n parseFloat(acc.totalBalance) + parseFloat(state.totalBalance)\n ).toString(),\n marginUsed: (\n parseFloat(acc.marginUsed) + parseFloat(state.marginUsed)\n ).toString(),\n unrealizedPnl: (\n parseFloat(acc.unrealizedPnl) + parseFloat(state.unrealizedPnl)\n ).toString(),\n returnOnEquity: '0',\n };\n }, fallback);\n\n // Recalculate ROE across all DEXs\n const totalMarginUsed = parseFloat(aggregated.marginUsed);\n const totalUnrealizedPnl = parseFloat(aggregated.unrealizedPnl);\n if (totalMarginUsed > 0) {\n aggregated.returnOnEquity = (\n (totalUnrealizedPnl / totalMarginUsed) *\n 100\n ).toString();\n } else {\n aggregated.returnOnEquity = '0';\n }\n\n return aggregated;\n}\n"]}
1
+ {"version":3,"file":"accountUtils.cjs","sourceRo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AC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AA/CD,wDA+CC","sourcesContent":["/**\n * Account utilities for Perps components\n * Handles account selection and EVM account filtering\n */\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig';\nimport type { AccountState, PerpsInternalAccount } from '../types';\n\nconst EVM_ACCOUNT_TYPES = new Set(['eip155:eoa', 'eip155:erc4337']);\n\nfunction isEvmAccountType(type: string): boolean {\n return EVM_ACCOUNT_TYPES.has(type);\n}\n\nexport function findEvmAccount(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string; type: string } | null {\n const evmAccount = accounts.find(\n (account) =>\n account && isEvmAccountType(account.type as InternalAccount['type']),\n );\n return evmAccount ?? null;\n}\n\nexport function getEvmAccountFromAccountGroup(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string } | undefined {\n const evmAccount = findEvmAccount(accounts);\n return evmAccount ? { address: evmAccount.address } : undefined;\n}\n\nexport function getSelectedEvmAccount(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string } | undefined {\n return getEvmAccountFromAccountGroup(accounts);\n}\n\nexport type ReturnOnEquityInput = {\n unrealizedPnl: string | number;\n returnOnEquity: string | number;\n};\n\nexport function calculateWeightedReturnOnEquity(\n accounts: ReturnOnEquityInput[],\n): string {\n if (accounts.length === 0) {\n return '0';\n }\n\n let totalWeightedROE = 0;\n let totalMarginUsed = 0;\n\n for (const account of accounts) {\n const unrealizedPnl =\n typeof account.unrealizedPnl === 'string'\n ? Number.parseFloat(account.unrealizedPnl)\n : account.unrealizedPnl;\n const returnOnEquity =\n typeof account.returnOnEquity === 'string'\n ? Number.parseFloat(account.returnOnEquity)\n : account.returnOnEquity;\n\n if (Number.isNaN(unrealizedPnl) || Number.isNaN(returnOnEquity)) {\n continue;\n }\n\n if (returnOnEquity === 0) {\n continue;\n }\n\n const marginUsed = (unrealizedPnl / returnOnEquity) * 100;\n\n if (Number.isNaN(marginUsed) || marginUsed <= 0) {\n continue;\n }\n\n const roeDecimal = returnOnEquity / 100;\n\n totalWeightedROE += roeDecimal * marginUsed;\n totalMarginUsed += marginUsed;\n }\n\n if (totalMarginUsed <= 0) {\n return '0';\n }\n\n const weightedROE = (totalWeightedROE / totalMarginUsed) * 100;\n return weightedROE.toString();\n}\n\n/**\n * Aggregate multiple per-DEX AccountState objects into one by summing numeric fields.\n * ROE is recalculated as (totalUnrealizedPnl / totalMarginUsed) * 100.\n *\n * @param states - The array of per-DEX account states to aggregate.\n * @returns The combined account state with summed balances and recalculated ROE.\n */\nexport function aggregateAccountStates(states: AccountState[]): AccountState {\n const fallback: AccountState = {\n availableBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n totalBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n marginUsed: PERPS_CONSTANTS.FallbackDataDisplay,\n unrealizedPnl: PERPS_CONSTANTS.FallbackDataDisplay,\n returnOnEquity: PERPS_CONSTANTS.FallbackDataDisplay,\n };\n\n if (states.length === 0) {\n return fallback;\n }\n\n const aggregated = states.reduce<AccountState>((acc, state, index) => {\n if (index === 0) {\n return { ...state };\n }\n return {\n availableBalance: (\n parseFloat(acc.availableBalance) + parseFloat(state.availableBalance)\n ).toString(),\n totalBalance: (\n parseFloat(acc.totalBalance) + parseFloat(state.totalBalance)\n ).toString(),\n marginUsed: (\n parseFloat(acc.marginUsed) + parseFloat(state.marginUsed)\n ).toString(),\n unrealizedPnl: (\n parseFloat(acc.unrealizedPnl) + parseFloat(state.unrealizedPnl)\n ).toString(),\n returnOnEquity: '0',\n };\n }, fallback);\n\n // Recalculate ROE across all DEXs\n const totalMarginUsed = parseFloat(aggregated.marginUsed);\n const totalUnrealizedPnl = parseFloat(aggregated.unrealizedPnl);\n if (totalMarginUsed > 0) {\n aggregated.returnOnEquity = (\n (totalUnrealizedPnl / totalMarginUsed) *\n 100\n ).toString();\n } else {\n aggregated.returnOnEquity = '0';\n }\n\n return aggregated;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"accountUtils.d.cts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAGtE,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,2BAAiB;AAQnE,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,CAAC,eAAe,GAAG,oBAAoB,CAAC,EAAE,GACnD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAK1C;AAED,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,CAAC,eAAe,GAAG,oBAAoB,CAAC,EAAE,GACnD;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAGjC;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,CAAC,eAAe,GAAG,oBAAoB,CAAC,EAAE,GACnD;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAEjC;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC,CAAC;AAEF,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,mBAAmB,EAAE,GAC9B,MAAM,CA4CR;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CA+C3E"}
1
+ {"version":3,"file":"accountUtils.d.cts","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAGtE,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,2BAAiB;AAQnE,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,CAAC,eAAe,GAAG,oBAAoB,CAAC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Ac,GAAG,CAC1B,CAAC,kBAAkB,GAAG,eAAe,CAAC;YACtC,GAAG,CACJ,CAAC,QAAQ,EAAE,CAAC;IACf,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,cAAc,GAAG,GAAG,CAAC;IAClC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["/**\n * Account utilities for Perps components\n * Handles account selection and EVM account filtering\n */\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig';\nimport type { AccountState, PerpsInternalAccount } from '../types';\n\nconst EVM_ACCOUNT_TYPES = new Set(['eip155:eoa', 'eip155:erc4337']);\n\nfunction isEvmAccountType(type: string): boolean {\n return EVM_ACCOUNT_TYPES.has(type);\n}\n\nexport function findEvmAccount(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string; type: string } | null {\n const evmAccount = accounts.find(\n (account) => account && isEvmAccountType(account.type),\n );\n return evmAccount ?? null;\n}\n\nexport function getEvmAccountFromAccountGroup(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string } | undefined {\n const evmAccount = findEvmAccount(accounts);\n return evmAccount ? { address: evmAccount.address } : undefined;\n}\n\nexport function getSelectedEvmAccount(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string } | undefined {\n return getEvmAccountFromAccountGroup(accounts);\n}\n\nexport type ReturnOnEquityInput = {\n unrealizedPnl: string | number;\n returnOnEquity: string | number;\n};\n\nexport function calculateWeightedReturnOnEquity(\n accounts: ReturnOnEquityInput[],\n): string {\n if (accounts.length === 0) {\n return '0';\n }\n\n let totalWeightedROE = 0;\n let totalMarginUsed = 0;\n\n for (const account of accounts) {\n const unrealizedPnl =\n typeof account.unrealizedPnl === 'string'\n ? Number.parseFloat(account.unrealizedPnl)\n : account.unrealizedPnl;\n const returnOnEquity =\n typeof account.returnOnEquity === 'string'\n ? Number.parseFloat(account.returnOnEquity)\n : account.returnOnEquity;\n\n if (Number.isNaN(unrealizedPnl) || Number.isNaN(returnOnEquity)) {\n continue;\n }\n\n if (returnOnEquity === 0) {\n continue;\n }\n\n const marginUsed = (unrealizedPnl / returnOnEquity) * 100;\n\n if (Number.isNaN(marginUsed) || marginUsed <= 0) {\n continue;\n }\n\n const roeDecimal = returnOnEquity / 100;\n\n totalWeightedROE += roeDecimal * marginUsed;\n totalMarginUsed += marginUsed;\n }\n\n if (totalMarginUsed <= 0) {\n return '0';\n }\n\n const weightedROE = (totalWeightedROE / totalMarginUsed) * 100;\n return weightedROE.toString();\n}\n\n/**\n * Aggregate multiple per-DEX AccountState objects into one by summing numeric fields.\n * ROE is recalculated as (totalUnrealizedPnl / totalMarginUsed) * 100.\n *\n * @param states - The array of per-DEX account states to aggregate.\n * @returns The combined account state with summed balances and recalculated ROE.\n */\nexport function aggregateAccountStates(states: AccountState[]): AccountState {\n const fallback: AccountState = {\n availableBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n totalBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n marginUsed: PERPS_CONSTANTS.FallbackDataDisplay,\n unrealizedPnl: PERPS_CONSTANTS.FallbackDataDisplay,\n returnOnEquity: PERPS_CONSTANTS.FallbackDataDisplay,\n };\n\n if (states.length === 0) {\n return fallback;\n }\n\n const aggregated = states.reduce<AccountState>((acc, state, index) => {\n if (index === 0) {\n return { ...state };\n }\n return {\n availableBalance: (\n parseFloat(acc.availableBalance) + parseFloat(state.availableBalance)\n ).toString(),\n totalBalance: (\n parseFloat(acc.totalBalance) + parseFloat(state.totalBalance)\n ).toString(),\n marginUsed: (\n parseFloat(acc.marginUsed) + parseFloat(state.marginUsed)\n ).toString(),\n unrealizedPnl: (\n parseFloat(acc.unrealizedPnl) + parseFloat(state.unrealizedPnl)\n ).toString(),\n returnOnEquity: '0',\n };\n }, fallback);\n\n // Recalculate ROE across all DEXs\n const totalMarginUsed = parseFloat(aggregated.marginUsed);\n const totalUnrealizedPnl = parseFloat(aggregated.unrealizedPnl);\n if (totalMarginUsed > 0) {\n aggregated.returnOnEquity = (\n (totalUnrealizedPnl / totalMarginUsed) *\n 100\n ).toString();\n } else {\n aggregated.returnOnEquity = '0';\n }\n\n return aggregated;\n}\n"]}
1
+ {"version":3,"file":"accountUtils.mjs","sourceRoot":"","sources":["../../src/utils/accountUtils.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,qCAAiC;AAG3D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAEpE,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,QAAoD;IAEpD,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAC9B,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,IAAI,gBAAgB,CAAC,OAAO,CAAC,IAA+B,CAAC,CACvE,CAAC;IACF,OAAO,UAAU,IAAI,IAAI,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,QAAoD;IAEpD,MAAM,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,QAAoD;IAEpD,OAAO,6BAA6B,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC;AAOD,MAAM,UAAU,+BAA+B,CAC7C,QAA+B;IAE/B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,gBAAgB,GAAG,CAAC,CAAC;IACzB,IAAI,eAAe,GAAG,CAAC,CAAC;IAExB,KAAK,MAAM,OAAO,IAAI,QAAQ,EA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C1B,CAAC,kBAAkB,GAAG,eAAe,CAAC;YACtC,GAAG,CACJ,CAAC,QAAQ,EAAE,CAAC;IACf,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,cAAc,GAAG,GAAG,CAAC;IAClC,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["/**\n * Account utilities for Perps components\n * Handles account selection and EVM account filtering\n */\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { PERPS_CONSTANTS } from '../constants/perpsConfig';\nimport type { AccountState, PerpsInternalAccount } from '../types';\n\nconst EVM_ACCOUNT_TYPES = new Set(['eip155:eoa', 'eip155:erc4337']);\n\nfunction isEvmAccountType(type: string): boolean {\n return EVM_ACCOUNT_TYPES.has(type);\n}\n\nexport function findEvmAccount(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string; type: string } | null {\n const evmAccount = accounts.find(\n (account) =>\n account && isEvmAccountType(account.type as InternalAccount['type']),\n );\n return evmAccount ?? null;\n}\n\nexport function getEvmAccountFromAccountGroup(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string } | undefined {\n const evmAccount = findEvmAccount(accounts);\n return evmAccount ? { address: evmAccount.address } : undefined;\n}\n\nexport function getSelectedEvmAccount(\n accounts: (InternalAccount | PerpsInternalAccount)[],\n): { address: string } | undefined {\n return getEvmAccountFromAccountGroup(accounts);\n}\n\nexport type ReturnOnEquityInput = {\n unrealizedPnl: string | number;\n returnOnEquity: string | number;\n};\n\nexport function calculateWeightedReturnOnEquity(\n accounts: ReturnOnEquityInput[],\n): string {\n if (accounts.length === 0) {\n return '0';\n }\n\n let totalWeightedROE = 0;\n let totalMarginUsed = 0;\n\n for (const account of accounts) {\n const unrealizedPnl =\n typeof account.unrealizedPnl === 'string'\n ? Number.parseFloat(account.unrealizedPnl)\n : account.unrealizedPnl;\n const returnOnEquity =\n typeof account.returnOnEquity === 'string'\n ? Number.parseFloat(account.returnOnEquity)\n : account.returnOnEquity;\n\n if (Number.isNaN(unrealizedPnl) || Number.isNaN(returnOnEquity)) {\n continue;\n }\n\n if (returnOnEquity === 0) {\n continue;\n }\n\n const marginUsed = (unrealizedPnl / returnOnEquity) * 100;\n\n if (Number.isNaN(marginUsed) || marginUsed <= 0) {\n continue;\n }\n\n const roeDecimal = returnOnEquity / 100;\n\n totalWeightedROE += roeDecimal * marginUsed;\n totalMarginUsed += marginUsed;\n }\n\n if (totalMarginUsed <= 0) {\n return '0';\n }\n\n const weightedROE = (totalWeightedROE / totalMarginUsed) * 100;\n return weightedROE.toString();\n}\n\n/**\n * Aggregate multiple per-DEX AccountState objects into one by summing numeric fields.\n * ROE is recalculated as (totalUnrealizedPnl / totalMarginUsed) * 100.\n *\n * @param states - The array of per-DEX account states to aggregate.\n * @returns The combined account state with summed balances and recalculated ROE.\n */\nexport function aggregateAccountStates(states: AccountState[]): AccountState {\n const fallback: AccountState = {\n availableBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n totalBalance: PERPS_CONSTANTS.FallbackDataDisplay,\n marginUsed: PERPS_CONSTANTS.FallbackDataDisplay,\n unrealizedPnl: PERPS_CONSTANTS.FallbackDataDisplay,\n returnOnEquity: PERPS_CONSTANTS.FallbackDataDisplay,\n };\n\n if (states.length === 0) {\n return fallback;\n }\n\n const aggregated = states.reduce<AccountState>((acc, state, index) => {\n if (index === 0) {\n return { ...state };\n }\n return {\n availableBalance: (\n parseFloat(acc.availableBalance) + parseFloat(state.availableBalance)\n ).toString(),\n totalBalance: (\n parseFloat(acc.totalBalance) + parseFloat(state.totalBalance)\n ).toString(),\n marginUsed: (\n parseFloat(acc.marginUsed) + parseFloat(state.marginUsed)\n ).toString(),\n unrealizedPnl: (\n parseFloat(acc.unrealizedPnl) + parseFloat(state.unrealizedPnl)\n ).toString(),\n returnOnEquity: '0',\n };\n }, fallback);\n\n // Recalculate ROE across all DEXs\n const totalMarginUsed = parseFloat(aggregated.marginUsed);\n const totalUnrealizedPnl = parseFloat(aggregated.unrealizedPnl);\n if (totalMarginUsed > 0) {\n aggregated.returnOnEquity = (\n (totalUnrealizedPnl / totalMarginUsed) *\n 100\n ).toString();\n } else {\n aggregated.returnOnEquity = '0';\n }\n\n return aggregated;\n}\n"]}