@3rd-eye-labs/openmm 0.1.1 → 0.1.3

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 (268) hide show
  1. package/dist/cli/cli.js +4 -0
  2. package/dist/cli/cli.js.map +1 -1
  3. package/dist/cli/commands/ohlcv.d.ts +3 -0
  4. package/dist/cli/commands/ohlcv.d.ts.map +1 -0
  5. package/dist/cli/commands/ohlcv.js +115 -0
  6. package/dist/cli/commands/ohlcv.js.map +1 -0
  7. package/dist/cli/commands/wallet.d.ts +7 -0
  8. package/dist/cli/commands/wallet.d.ts.map +1 -0
  9. package/dist/cli/commands/wallet.js +271 -0
  10. package/dist/cli/commands/wallet.js.map +1 -0
  11. package/dist/core/exchange/base-exchange-connector.d.ts +2 -1
  12. package/dist/core/exchange/base-exchange-connector.d.ts.map +1 -1
  13. package/dist/core/exchange/base-exchange-connector.js.map +1 -1
  14. package/dist/exchanges/bitget/bitget-connector.d.ts +11 -1
  15. package/dist/exchanges/bitget/bitget-connector.d.ts.map +1 -1
  16. package/dist/exchanges/bitget/bitget-connector.js +52 -0
  17. package/dist/exchanges/bitget/bitget-connector.js.map +1 -1
  18. package/dist/exchanges/gateio/gateio-connector.d.ts +11 -1
  19. package/dist/exchanges/gateio/gateio-connector.d.ts.map +1 -1
  20. package/dist/exchanges/gateio/gateio-connector.js +54 -0
  21. package/dist/exchanges/gateio/gateio-connector.js.map +1 -1
  22. package/dist/exchanges/kraken/kraken-connector.d.ts +6 -1
  23. package/dist/exchanges/kraken/kraken-connector.d.ts.map +1 -1
  24. package/dist/exchanges/kraken/kraken-connector.js +44 -0
  25. package/dist/exchanges/kraken/kraken-connector.js.map +1 -1
  26. package/dist/exchanges/mexc/mexc-auth.d.ts +1 -0
  27. package/dist/exchanges/mexc/mexc-auth.d.ts.map +1 -1
  28. package/dist/exchanges/mexc/mexc-auth.js +4 -1
  29. package/dist/exchanges/mexc/mexc-auth.js.map +1 -1
  30. package/dist/exchanges/mexc/mexc-connector.d.ts +6 -1
  31. package/dist/exchanges/mexc/mexc-connector.d.ts.map +1 -1
  32. package/dist/exchanges/mexc/mexc-connector.js +37 -0
  33. package/dist/exchanges/mexc/mexc-connector.js.map +1 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +25 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/types/market.d.ts +15 -0
  39. package/dist/types/market.d.ts.map +1 -1
  40. package/dist/x402/crypto.d.ts +79 -0
  41. package/dist/x402/crypto.d.ts.map +1 -0
  42. package/dist/x402/crypto.js +300 -0
  43. package/dist/x402/crypto.js.map +1 -0
  44. package/dist/x402/evm.d.ts +41 -0
  45. package/dist/x402/evm.d.ts.map +1 -0
  46. package/dist/x402/evm.js +229 -0
  47. package/dist/x402/evm.js.map +1 -0
  48. package/dist/x402/handler.d.ts +53 -0
  49. package/dist/x402/handler.d.ts.map +1 -0
  50. package/dist/x402/handler.js +233 -0
  51. package/dist/x402/handler.js.map +1 -0
  52. package/dist/x402/index.d.ts +29 -0
  53. package/dist/x402/index.d.ts.map +1 -0
  54. package/dist/x402/index.js +67 -0
  55. package/dist/x402/index.js.map +1 -0
  56. package/dist/x402/types.d.ts +185 -0
  57. package/dist/x402/types.d.ts.map +1 -0
  58. package/dist/x402/types.js +7 -0
  59. package/dist/x402/types.js.map +1 -0
  60. package/dist/x402/wallet.d.ts +65 -0
  61. package/dist/x402/wallet.d.ts.map +1 -0
  62. package/dist/x402/wallet.js +282 -0
  63. package/dist/x402/wallet.js.map +1 -0
  64. package/package.json +1 -1
  65. package/dist/cli/commands/grid.d.ts +0 -3
  66. package/dist/cli/commands/grid.d.ts.map +0 -1
  67. package/dist/cli/commands/grid.js +0 -103
  68. package/dist/cli/commands/grid.js.map +0 -1
  69. package/dist/cli/commands/multi-trade.d.ts +0 -3
  70. package/dist/cli/commands/multi-trade.d.ts.map +0 -1
  71. package/dist/cli/commands/multi-trade.js +0 -175
  72. package/dist/cli/commands/multi-trade.js.map +0 -1
  73. package/dist/cli/pool-discovery.d.ts +0 -56
  74. package/dist/cli/pool-discovery.d.ts.map +0 -1
  75. package/dist/cli/pool-discovery.js +0 -283
  76. package/dist/cli/pool-discovery.js.map +0 -1
  77. package/dist/core/price-aggregation/price-cache.d.ts +0 -55
  78. package/dist/core/price-aggregation/price-cache.d.ts.map +0 -1
  79. package/dist/core/price-aggregation/price-cache.js +0 -152
  80. package/dist/core/price-aggregation/price-cache.js.map +0 -1
  81. package/dist/examples/mexc-connector-comprehensive-test.d.ts +0 -15
  82. package/dist/examples/mexc-connector-comprehensive-test.d.ts.map +0 -1
  83. package/dist/examples/mexc-connector-comprehensive-test.js +0 -514
  84. package/dist/examples/mexc-connector-comprehensive-test.js.map +0 -1
  85. package/dist/examples/mexc-order-update-test.d.ts +0 -4
  86. package/dist/examples/mexc-order-update-test.d.ts.map +0 -1
  87. package/dist/examples/mexc-order-update-test.js +0 -186
  88. package/dist/examples/mexc-order-update-test.js.map +0 -1
  89. package/dist/examples/mexc-test.d.ts +0 -9
  90. package/dist/examples/mexc-test.d.ts.map +0 -1
  91. package/dist/examples/mexc-test.js +0 -218
  92. package/dist/examples/mexc-test.js.map +0 -1
  93. package/dist/examples/mexc-trades-debug.d.ts +0 -2
  94. package/dist/examples/mexc-trades-debug.d.ts.map +0 -1
  95. package/dist/examples/mexc-trades-debug.js +0 -101
  96. package/dist/examples/mexc-trades-debug.js.map +0 -1
  97. package/dist/examples/mexc-trades-subscription-debug.d.ts +0 -2
  98. package/dist/examples/mexc-trades-subscription-debug.d.ts.map +0 -1
  99. package/dist/examples/mexc-trades-subscription-debug.js +0 -150
  100. package/dist/examples/mexc-trades-subscription-debug.js.map +0 -1
  101. package/dist/examples/mexc-websocket-test.d.ts +0 -8
  102. package/dist/examples/mexc-websocket-test.d.ts.map +0 -1
  103. package/dist/examples/mexc-websocket-test.js +0 -115
  104. package/dist/examples/mexc-websocket-test.js.map +0 -1
  105. package/dist/examples/test-protobuf-status-detection.d.ts +0 -9
  106. package/dist/examples/test-protobuf-status-detection.d.ts.map +0 -1
  107. package/dist/examples/test-protobuf-status-detection.js +0 -83
  108. package/dist/examples/test-protobuf-status-detection.js.map +0 -1
  109. package/dist/exchanges/base-exchange-connector.d.ts +0 -33
  110. package/dist/exchanges/base-exchange-connector.d.ts.map +0 -1
  111. package/dist/exchanges/base-exchange-connector.js +0 -55
  112. package/dist/exchanges/base-exchange-connector.js.map +0 -1
  113. package/dist/exchanges/kraken/test-kraken-websocket.d.ts +0 -19
  114. package/dist/exchanges/kraken/test-kraken-websocket.d.ts.map +0 -1
  115. package/dist/exchanges/kraken/test-kraken-websocket.js +0 -413
  116. package/dist/exchanges/kraken/test-kraken-websocket.js.map +0 -1
  117. package/dist/mcp/resources/index.d.ts +0 -3
  118. package/dist/mcp/resources/index.d.ts.map +0 -1
  119. package/dist/mcp/resources/index.js +0 -11
  120. package/dist/mcp/resources/index.js.map +0 -1
  121. package/dist/mcp/server.d.ts +0 -4
  122. package/dist/mcp/server.d.ts.map +0 -1
  123. package/dist/mcp/server.js +0 -29
  124. package/dist/mcp/server.js.map +0 -1
  125. package/dist/mcp/tools/index.d.ts +0 -3
  126. package/dist/mcp/tools/index.d.ts.map +0 -1
  127. package/dist/mcp/tools/index.js +0 -12
  128. package/dist/mcp/tools/index.js.map +0 -1
  129. package/dist/tests/fixtures/test-helpers.d.ts +0 -5
  130. package/dist/tests/fixtures/test-helpers.d.ts.map +0 -1
  131. package/dist/tests/fixtures/test-helpers.js +0 -8
  132. package/dist/tests/fixtures/test-helpers.js.map +0 -1
  133. package/dist/tests/integration/exchanges/mexc/mexc-integration.test.d.ts +0 -2
  134. package/dist/tests/integration/exchanges/mexc/mexc-integration.test.d.ts.map +0 -1
  135. package/dist/tests/integration/exchanges/mexc/mexc-integration.test.js +0 -237
  136. package/dist/tests/integration/exchanges/mexc/mexc-integration.test.js.map +0 -1
  137. package/dist/tests/integration/price-aggregation/cardano-price-service.test.d.ts +0 -2
  138. package/dist/tests/integration/price-aggregation/cardano-price-service.test.d.ts.map +0 -1
  139. package/dist/tests/integration/price-aggregation/cardano-price-service.test.js +0 -57
  140. package/dist/tests/integration/price-aggregation/cardano-price-service.test.js.map +0 -1
  141. package/dist/tests/integration/price-aggregation/price-aggregation-integration.test.d.ts +0 -2
  142. package/dist/tests/integration/price-aggregation/price-aggregation-integration.test.d.ts.map +0 -1
  143. package/dist/tests/integration/price-aggregation/price-aggregation-integration.test.js +0 -141
  144. package/dist/tests/integration/price-aggregation/price-aggregation-integration.test.js.map +0 -1
  145. package/dist/tests/integration/strategies/grid/grid-strategy-e2e.test.d.ts +0 -2
  146. package/dist/tests/integration/strategies/grid/grid-strategy-e2e.test.d.ts.map +0 -1
  147. package/dist/tests/integration/strategies/grid/grid-strategy-e2e.test.js +0 -375
  148. package/dist/tests/integration/strategies/grid/grid-strategy-e2e.test.js.map +0 -1
  149. package/dist/tests/unit/cli/exchange-factory.test.d.ts +0 -2
  150. package/dist/tests/unit/cli/exchange-factory.test.d.ts.map +0 -1
  151. package/dist/tests/unit/cli/exchange-factory.test.js +0 -148
  152. package/dist/tests/unit/cli/exchange-factory.test.js.map +0 -1
  153. package/dist/tests/unit/config/environment.test.d.ts +0 -2
  154. package/dist/tests/unit/config/environment.test.d.ts.map +0 -1
  155. package/dist/tests/unit/config/environment.test.js +0 -158
  156. package/dist/tests/unit/config/environment.test.js.map +0 -1
  157. package/dist/tests/unit/config/launcher-config.test.d.ts +0 -2
  158. package/dist/tests/unit/config/launcher-config.test.d.ts.map +0 -1
  159. package/dist/tests/unit/config/launcher-config.test.js +0 -117
  160. package/dist/tests/unit/config/launcher-config.test.js.map +0 -1
  161. package/dist/tests/unit/config/price-aggregation.test.d.ts +0 -2
  162. package/dist/tests/unit/config/price-aggregation.test.d.ts.map +0 -1
  163. package/dist/tests/unit/config/price-aggregation.test.js +0 -144
  164. package/dist/tests/unit/config/price-aggregation.test.js.map +0 -1
  165. package/dist/tests/unit/core/exchange/base-exchange-connector.test.d.ts +0 -2
  166. package/dist/tests/unit/core/exchange/base-exchange-connector.test.d.ts.map +0 -1
  167. package/dist/tests/unit/core/exchange/base-exchange-connector.test.js +0 -191
  168. package/dist/tests/unit/core/exchange/base-exchange-connector.test.js.map +0 -1
  169. package/dist/tests/unit/core/exchange/base-exchange-data-mapper.test.d.ts +0 -2
  170. package/dist/tests/unit/core/exchange/base-exchange-data-mapper.test.d.ts.map +0 -1
  171. package/dist/tests/unit/core/exchange/base-exchange-data-mapper.test.js +0 -324
  172. package/dist/tests/unit/core/exchange/base-exchange-data-mapper.test.js.map +0 -1
  173. package/dist/tests/unit/core/price-aggregation/cardano-price-service.test.d.ts +0 -2
  174. package/dist/tests/unit/core/price-aggregation/cardano-price-service.test.d.ts.map +0 -1
  175. package/dist/tests/unit/core/price-aggregation/cardano-price-service.test.js +0 -177
  176. package/dist/tests/unit/core/price-aggregation/cardano-price-service.test.js.map +0 -1
  177. package/dist/tests/unit/core/price-aggregation/iris-api-client.test.d.ts +0 -2
  178. package/dist/tests/unit/core/price-aggregation/iris-api-client.test.d.ts.map +0 -1
  179. package/dist/tests/unit/core/price-aggregation/iris-api-client.test.js +0 -168
  180. package/dist/tests/unit/core/price-aggregation/iris-api-client.test.js.map +0 -1
  181. package/dist/tests/unit/core/price-aggregation/iris-pool-discovery.test.d.ts +0 -2
  182. package/dist/tests/unit/core/price-aggregation/iris-pool-discovery.test.d.ts.map +0 -1
  183. package/dist/tests/unit/core/price-aggregation/iris-pool-discovery.test.js +0 -217
  184. package/dist/tests/unit/core/price-aggregation/iris-pool-discovery.test.js.map +0 -1
  185. package/dist/tests/unit/core/price-aggregation/price-calculator.test.d.ts +0 -2
  186. package/dist/tests/unit/core/price-aggregation/price-calculator.test.d.ts.map +0 -1
  187. package/dist/tests/unit/core/price-aggregation/price-calculator.test.js +0 -229
  188. package/dist/tests/unit/core/price-aggregation/price-calculator.test.js.map +0 -1
  189. package/dist/tests/unit/core/risk-management/risk-manager.test.d.ts +0 -2
  190. package/dist/tests/unit/core/risk-management/risk-manager.test.d.ts.map +0 -1
  191. package/dist/tests/unit/core/risk-management/risk-manager.test.js +0 -194
  192. package/dist/tests/unit/core/risk-management/risk-manager.test.js.map +0 -1
  193. package/dist/tests/unit/core/strategy/base-strategy.test.d.ts +0 -2
  194. package/dist/tests/unit/core/strategy/base-strategy.test.d.ts.map +0 -1
  195. package/dist/tests/unit/core/strategy/base-strategy.test.js +0 -254
  196. package/dist/tests/unit/core/strategy/base-strategy.test.js.map +0 -1
  197. package/dist/tests/unit/core/strategy/strategy-factory.test.d.ts +0 -2
  198. package/dist/tests/unit/core/strategy/strategy-factory.test.d.ts.map +0 -1
  199. package/dist/tests/unit/core/strategy/strategy-factory.test.js +0 -213
  200. package/dist/tests/unit/core/strategy/strategy-factory.test.js.map +0 -1
  201. package/dist/tests/unit/exchanges/mexc/mexc-auth.test.d.ts +0 -2
  202. package/dist/tests/unit/exchanges/mexc/mexc-auth.test.d.ts.map +0 -1
  203. package/dist/tests/unit/exchanges/mexc/mexc-auth.test.js +0 -452
  204. package/dist/tests/unit/exchanges/mexc/mexc-auth.test.js.map +0 -1
  205. package/dist/tests/unit/exchanges/mexc/mexc-connector.test.d.ts +0 -2
  206. package/dist/tests/unit/exchanges/mexc/mexc-connector.test.d.ts.map +0 -1
  207. package/dist/tests/unit/exchanges/mexc/mexc-connector.test.js +0 -1419
  208. package/dist/tests/unit/exchanges/mexc/mexc-connector.test.js.map +0 -1
  209. package/dist/tests/unit/exchanges/mexc/mexc-data-mapper.test.d.ts +0 -2
  210. package/dist/tests/unit/exchanges/mexc/mexc-data-mapper.test.d.ts.map +0 -1
  211. package/dist/tests/unit/exchanges/mexc/mexc-data-mapper.test.js +0 -435
  212. package/dist/tests/unit/exchanges/mexc/mexc-data-mapper.test.js.map +0 -1
  213. package/dist/tests/unit/exchanges/mexc/mexc-protobuf-decoder.test.d.ts +0 -2
  214. package/dist/tests/unit/exchanges/mexc/mexc-protobuf-decoder.test.d.ts.map +0 -1
  215. package/dist/tests/unit/exchanges/mexc/mexc-protobuf-decoder.test.js +0 -314
  216. package/dist/tests/unit/exchanges/mexc/mexc-protobuf-decoder.test.js.map +0 -1
  217. package/dist/tests/unit/exchanges/mexc/mexc-protobuf-status-detection.test.d.ts +0 -2
  218. package/dist/tests/unit/exchanges/mexc/mexc-protobuf-status-detection.test.d.ts.map +0 -1
  219. package/dist/tests/unit/exchanges/mexc/mexc-protobuf-status-detection.test.js +0 -178
  220. package/dist/tests/unit/exchanges/mexc/mexc-protobuf-status-detection.test.js.map +0 -1
  221. package/dist/tests/unit/exchanges/mexc/mexc-user-stream.test.d.ts +0 -2
  222. package/dist/tests/unit/exchanges/mexc/mexc-user-stream.test.d.ts.map +0 -1
  223. package/dist/tests/unit/exchanges/mexc/mexc-user-stream.test.js +0 -502
  224. package/dist/tests/unit/exchanges/mexc/mexc-user-stream.test.js.map +0 -1
  225. package/dist/tests/unit/exchanges/mexc/mexc-utils.test.d.ts +0 -2
  226. package/dist/tests/unit/exchanges/mexc/mexc-utils.test.d.ts.map +0 -1
  227. package/dist/tests/unit/exchanges/mexc/mexc-utils.test.js +0 -317
  228. package/dist/tests/unit/exchanges/mexc/mexc-utils.test.js.map +0 -1
  229. package/dist/tests/unit/exchanges/mexc/mexc-websocket.test.d.ts +0 -2
  230. package/dist/tests/unit/exchanges/mexc/mexc-websocket.test.d.ts.map +0 -1
  231. package/dist/tests/unit/exchanges/mexc/mexc-websocket.test.js +0 -843
  232. package/dist/tests/unit/exchanges/mexc/mexc-websocket.test.js.map +0 -1
  233. package/dist/tests/unit/strategies/grid/grid-calculator.test.d.ts +0 -2
  234. package/dist/tests/unit/strategies/grid/grid-calculator.test.d.ts.map +0 -1
  235. package/dist/tests/unit/strategies/grid/grid-calculator.test.js +0 -67
  236. package/dist/tests/unit/strategies/grid/grid-calculator.test.js.map +0 -1
  237. package/dist/tests/unit/strategies/grid/grid-order-manager.test.d.ts +0 -2
  238. package/dist/tests/unit/strategies/grid/grid-order-manager.test.d.ts.map +0 -1
  239. package/dist/tests/unit/strategies/grid/grid-order-manager.test.js +0 -211
  240. package/dist/tests/unit/strategies/grid/grid-order-manager.test.js.map +0 -1
  241. package/dist/tests/unit/strategies/grid/grid-strategy-simple.test.d.ts +0 -2
  242. package/dist/tests/unit/strategies/grid/grid-strategy-simple.test.d.ts.map +0 -1
  243. package/dist/tests/unit/strategies/grid/grid-strategy-simple.test.js +0 -197
  244. package/dist/tests/unit/strategies/grid/grid-strategy-simple.test.js.map +0 -1
  245. package/dist/tests/unit/strategies/grid/grid-strategy.test.d.ts +0 -2
  246. package/dist/tests/unit/strategies/grid/grid-strategy.test.d.ts.map +0 -1
  247. package/dist/tests/unit/strategies/grid/grid-strategy.test.js +0 -429
  248. package/dist/tests/unit/strategies/grid/grid-strategy.test.js.map +0 -1
  249. package/dist/tests/unit/utils/logger.test.d.ts +0 -2
  250. package/dist/tests/unit/utils/logger.test.d.ts.map +0 -1
  251. package/dist/tests/unit/utils/logger.test.js +0 -260
  252. package/dist/tests/unit/utils/logger.test.js.map +0 -1
  253. package/dist/tests/unit/utils/symbol-utils.test.d.ts +0 -2
  254. package/dist/tests/unit/utils/symbol-utils.test.d.ts.map +0 -1
  255. package/dist/tests/unit/utils/symbol-utils.test.js +0 -178
  256. package/dist/tests/unit/utils/symbol-utils.test.js.map +0 -1
  257. package/dist/types/price-aggregation.d.ts +0 -31
  258. package/dist/types/price-aggregation.d.ts.map +0 -1
  259. package/dist/types/price-aggregation.js +0 -6
  260. package/dist/types/price-aggregation.js.map +0 -1
  261. package/dist/utils/crypto.d.ts +0 -15
  262. package/dist/utils/crypto.d.ts.map +0 -1
  263. package/dist/utils/crypto.js +0 -50
  264. package/dist/utils/crypto.js.map +0 -1
  265. package/dist/utils/validation.d.ts +0 -36
  266. package/dist/utils/validation.d.ts.map +0 -1
  267. package/dist/utils/validation.js +0 -174
  268. package/dist/utils/validation.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export { GateioConnector } from './exchanges/gateio/gateio-connector';
6
6
  export { BitgetConnector } from './exchanges/bitget/bitget-connector';
7
7
  export { KrakenConnector } from './exchanges/kraken/kraken-connector';
8
8
  export { ExchangeFactory, SupportedExchange } from './cli/exchange-factory';
9
+ export * as x402 from './x402';
9
10
  export declare class OpenMM {
10
11
  private logger;
11
12
  constructor();
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAQ,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAGvE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG5E,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAA+C;;IAMtD,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI;CAGpB;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAQ,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAGvE,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG5E,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAG/B,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAA+C;;IAMtD,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI;CAGpB;AAED,eAAe,MAAM,CAAC"}
package/dist/index.js CHANGED
@@ -10,11 +10,33 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
13
18
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
20
  };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
16
38
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.OpenMM = exports.ExchangeFactory = exports.KrakenConnector = exports.BitgetConnector = exports.GateioConnector = exports.MexcConnector = exports.BaseStrategy = exports.BaseExchangeConnector = void 0;
39
+ exports.OpenMM = exports.x402 = exports.ExchangeFactory = exports.KrakenConnector = exports.BitgetConnector = exports.GateioConnector = exports.MexcConnector = exports.BaseStrategy = exports.BaseExchangeConnector = void 0;
18
40
  __exportStar(require("./types"), exports);
19
41
  // Core components
20
42
  var base_exchange_connector_1 = require("./core/exchange/base-exchange-connector");
@@ -33,6 +55,8 @@ Object.defineProperty(exports, "KrakenConnector", { enumerable: true, get: funct
33
55
  // Exchange factory
34
56
  var exchange_factory_1 = require("./cli/exchange-factory");
35
57
  Object.defineProperty(exports, "ExchangeFactory", { enumerable: true, get: function () { return exchange_factory_1.ExchangeFactory; } });
58
+ // x402 Payment Support
59
+ exports.x402 = __importStar(require("./x402"));
36
60
  const utils_1 = require("./utils");
37
61
  class OpenMM {
38
62
  constructor() {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AAExB,kBAAkB;AAClB,mFAAgF;AAAvE,gIAAA,qBAAqB,OAAA;AAC9B,+DAA6D;AAApD,6GAAA,YAAY,OAAA;AAErB,sBAAsB;AACtB,kEAAgE;AAAvD,+GAAA,aAAa,OAAA;AACtB,wEAAsE;AAA7D,mHAAA,eAAe,OAAA;AACxB,wEAAsE;AAA7D,mHAAA,eAAe,OAAA;AACxB,wEAAuE;AAA7D,mHAAA,eAAe,OAAA;AAEzB,mBAAmB;AACnB,2DAA4E;AAAnE,mHAAA,eAAe,OAAA;AACxB,mCAAuC;AAEvC,MAAa,MAAM;IAGjB;QAFQ,WAAM,GAAG,IAAA,oBAAY,EAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;QAG3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;IACzE,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IAC5D,CAAC;IAEM,IAAI;QACT,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IAC5D,CAAC;CACF;AAdD,wBAcC;AAED,kBAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAwB;AAExB,kBAAkB;AAClB,mFAAgF;AAAvE,gIAAA,qBAAqB,OAAA;AAC9B,+DAA6D;AAApD,6GAAA,YAAY,OAAA;AAErB,sBAAsB;AACtB,kEAAgE;AAAvD,+GAAA,aAAa,OAAA;AACtB,wEAAsE;AAA7D,mHAAA,eAAe,OAAA;AACxB,wEAAsE;AAA7D,mHAAA,eAAe,OAAA;AACxB,wEAAuE;AAA7D,mHAAA,eAAe,OAAA;AAEzB,mBAAmB;AACnB,2DAA4E;AAAnE,mHAAA,eAAe,OAAA;AAExB,uBAAuB;AACvB,+CAA+B;AAC/B,mCAAuC;AAEvC,MAAa,MAAM;IAGjB;QAFQ,WAAM,GAAG,IAAA,oBAAY,EAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;QAG3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;IACzE,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IAC5D,CAAC;IAEM,IAAI;QACT,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IAC5D,CAAC;CACF;AAdD,wBAcC;AAED,kBAAe,MAAM,CAAC"}
@@ -13,4 +13,19 @@ export interface MarketData {
13
13
  price: number;
14
14
  timestamp: number;
15
15
  }
16
+ /**
17
+ * OHLCV candlestick data
18
+ */
19
+ export interface OHLCV {
20
+ timestamp: number;
21
+ open: number;
22
+ high: number;
23
+ low: number;
24
+ close: number;
25
+ volume: number;
26
+ }
27
+ /**
28
+ * Supported OHLCV timeframes
29
+ */
30
+ export type OHLCVTimeframe = '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '1d' | '1w';
16
31
  //# sourceMappingURL=market.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"market.d.ts","sourceRoot":"","sources":["../../src/types/market.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB"}
1
+ {"version":3,"file":"market.d.ts","sourceRoot":"","sources":["../../src/types/market.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,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;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * OpenMM x402 Cryptographic Utilities
3
+ * Pure Node.js crypto implementations for EVM signing.
4
+ * No external dependencies required.
5
+ */
6
+ import type { ECDSASignature } from './types';
7
+ /**
8
+ * Compute keccak256 hash (Ethereum's version of SHA3-256).
9
+ * Uses Node.js crypto which supports keccak256 natively.
10
+ */
11
+ export declare function keccak256(data: Buffer): Buffer;
12
+ /**
13
+ * Sign a message hash with secp256k1 private key.
14
+ * Returns { r, s, v } where v is recovery id (0 or 1).
15
+ */
16
+ export declare function signSecp256k1(msgHash: Buffer, privateKey: Buffer): ECDSASignature;
17
+ /**
18
+ * Encrypt a private key with a password.
19
+ */
20
+ export declare function encryptKey(privateKeyHex: string, password: string | null): {
21
+ data?: string;
22
+ encrypted?: boolean;
23
+ cipher?: string;
24
+ kdf?: string;
25
+ kdfParams?: {
26
+ N: number;
27
+ r: number;
28
+ p: number;
29
+ };
30
+ salt?: string;
31
+ iv?: string;
32
+ authTag?: string;
33
+ ciphertext?: string;
34
+ };
35
+ /**
36
+ * Decrypt a private key with a password.
37
+ */
38
+ export declare function decryptKey(encryptedData: {
39
+ data?: string;
40
+ encrypted?: boolean;
41
+ salt?: string;
42
+ iv?: string;
43
+ authTag?: string;
44
+ ciphertext?: string;
45
+ }, password: string | null): string;
46
+ /**
47
+ * Hash a password for verification (not encryption).
48
+ */
49
+ export declare function hashPassword(password: string): {
50
+ salt: string;
51
+ hash: string;
52
+ };
53
+ /**
54
+ * Verify a password against stored hash.
55
+ */
56
+ export declare function verifyPassword(password: string, storedHash: {
57
+ salt: string;
58
+ hash: string;
59
+ }): boolean;
60
+ /**
61
+ * Generate a random 32-byte private key.
62
+ */
63
+ export declare function generatePrivateKey(): Buffer;
64
+ /**
65
+ * Derive EVM address from private key.
66
+ */
67
+ export declare function privateKeyToEvmAddress(privateKey: Buffer): string;
68
+ /**
69
+ * Generate Ed25519 keypair for Solana.
70
+ */
71
+ export declare function generateSolanaKeypair(): {
72
+ privateKey: Buffer;
73
+ publicKey: Buffer;
74
+ };
75
+ /**
76
+ * Encode buffer to Base58 string (for Solana addresses).
77
+ */
78
+ export declare function base58Encode(buffer: Buffer): string;
79
+ //# sourceMappingURL=crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.d.ts","sourceRoot":"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,IAAI,EAAE,MAAM,CAAA;CAAE,CAS7E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzC,OAAO,CAQT;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAmBjE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAcjF;AAMD;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAyBnD"}
@@ -0,0 +1,300 @@
1
+ "use strict";
2
+ /**
3
+ * OpenMM x402 Cryptographic Utilities
4
+ * Pure Node.js crypto implementations for EVM signing.
5
+ * No external dependencies required.
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.keccak256 = keccak256;
12
+ exports.signSecp256k1 = signSecp256k1;
13
+ exports.encryptKey = encryptKey;
14
+ exports.decryptKey = decryptKey;
15
+ exports.hashPassword = hashPassword;
16
+ exports.verifyPassword = verifyPassword;
17
+ exports.generatePrivateKey = generatePrivateKey;
18
+ exports.privateKeyToEvmAddress = privateKeyToEvmAddress;
19
+ exports.generateSolanaKeypair = generateSolanaKeypair;
20
+ exports.base58Encode = base58Encode;
21
+ const crypto_1 = __importDefault(require("crypto"));
22
+ /**
23
+ * Compute keccak256 hash (Ethereum's version of SHA3-256).
24
+ * Uses Node.js crypto which supports keccak256 natively.
25
+ */
26
+ function keccak256(data) {
27
+ return crypto_1.default.createHash('sha3-256').update(data).digest();
28
+ }
29
+ /**
30
+ * Sign a message hash with secp256k1 private key.
31
+ * Returns { r, s, v } where v is recovery id (0 or 1).
32
+ */
33
+ function signSecp256k1(msgHash, privateKey) {
34
+ // Use Node.js ECDH to get the public key for recovery
35
+ const ecdh = crypto_1.default.createECDH('secp256k1');
36
+ ecdh.setPrivateKey(privateKey);
37
+ const publicKey = ecdh.getPublicKey(null, 'uncompressed');
38
+ // Sign the message
39
+ const sign = crypto_1.default.createSign('sha256');
40
+ sign.update(msgHash);
41
+ sign.end();
42
+ // Node.js sign() with ECDSA returns DER-encoded signature
43
+ // We need to extract r and s from it
44
+ const derSig = sign.sign({ key: privateKeyToPem(privateKey), dsaEncoding: 'der' });
45
+ // Parse DER signature to get r and s
46
+ const { r, s } = parseDerSignature(derSig);
47
+ // Normalize s to low-S form (required by Ethereum)
48
+ const secp256k1N = BigInt('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141');
49
+ const halfN = secp256k1N / 2n;
50
+ let sBigInt = BigInt('0x' + s.toString('hex'));
51
+ let sNormalized = s;
52
+ if (sBigInt > halfN) {
53
+ sBigInt = secp256k1N - sBigInt;
54
+ sNormalized = Buffer.from(sBigInt.toString(16).padStart(64, '0'), 'hex');
55
+ }
56
+ // Determine recovery id by trying both values
57
+ const v = recoverV(msgHash, r, sNormalized, publicKey);
58
+ return { r, s: sNormalized, v };
59
+ }
60
+ /**
61
+ * Convert raw private key to PEM format for Node.js crypto.
62
+ */
63
+ function privateKeyToPem(privateKey) {
64
+ // Create SEC1 EC private key DER structure
65
+ const ecdh = crypto_1.default.createECDH('secp256k1');
66
+ ecdh.setPrivateKey(privateKey);
67
+ // Use Node.js KeyObject API
68
+ const keyObject = crypto_1.default.createPrivateKey({
69
+ key: {
70
+ kty: 'EC',
71
+ crv: 'secp256k1',
72
+ d: privateKey.toString('base64url'),
73
+ x: ecdh.getPublicKey().subarray(1, 33).toString('base64url'),
74
+ y: ecdh.getPublicKey().subarray(33, 65).toString('base64url'),
75
+ },
76
+ format: 'jwk',
77
+ });
78
+ return keyObject.export({ type: 'pkcs8', format: 'pem' });
79
+ }
80
+ /**
81
+ * Parse DER-encoded ECDSA signature to extract r and s values.
82
+ */
83
+ function parseDerSignature(der) {
84
+ // DER: 30 <len> 02 <r-len> <r> 02 <s-len> <s>
85
+ let offset = 2; // Skip SEQUENCE header
86
+ // Read r
87
+ if (der[offset] !== 0x02)
88
+ throw new Error('Invalid DER signature');
89
+ offset++;
90
+ const rLen = der[offset];
91
+ offset++;
92
+ let r = der.subarray(offset, offset + rLen);
93
+ offset += rLen;
94
+ // Read s
95
+ if (der[offset] !== 0x02)
96
+ throw new Error('Invalid DER signature');
97
+ offset++;
98
+ const sLen = der[offset];
99
+ offset++;
100
+ let s = der.subarray(offset, offset + sLen);
101
+ // Remove leading zeros if present (DER may add 0x00 prefix for positive numbers)
102
+ if (r.length === 33 && r[0] === 0x00)
103
+ r = r.subarray(1);
104
+ if (s.length === 33 && s[0] === 0x00)
105
+ s = s.subarray(1);
106
+ // Pad to 32 bytes if needed
107
+ if (r.length < 32)
108
+ r = Buffer.concat([Buffer.alloc(32 - r.length), r]);
109
+ if (s.length < 32)
110
+ s = Buffer.concat([Buffer.alloc(32 - s.length), s]);
111
+ return { r, s };
112
+ }
113
+ /**
114
+ * Determine the recovery id (v) by verifying which value recovers the correct public key.
115
+ */
116
+ function recoverV(msgHash, r, s, expectedPubKey) {
117
+ // Try v=0 and v=1, see which recovers the correct public key
118
+ // For simplicity, we'll use a mathematical approach based on Y parity
119
+ // The recovery id is based on the Y coordinate of the signature point
120
+ // For Ethereum, v is typically 0 or 1 (added to 27 for legacy reasons)
121
+ // Extract Y coordinate from the expected public key
122
+ const yCoord = expectedPubKey.subarray(33, 65);
123
+ const yBigInt = BigInt('0x' + yCoord.toString('hex'));
124
+ // If Y is even, v = 0; if odd, v = 1
125
+ return yBigInt % 2n === 0n ? 0 : 1;
126
+ }
127
+ // ============= Encryption for Wallet Storage =============
128
+ const SCRYPT_N = 131072;
129
+ const SCRYPT_R = 8;
130
+ const SCRYPT_P = 1;
131
+ const SCRYPT_KEYLEN = 32;
132
+ const SALT_LEN = 16;
133
+ const IV_LEN = 12;
134
+ /**
135
+ * Derive encryption key from password using scrypt.
136
+ */
137
+ function deriveKey(password, salt) {
138
+ return crypto_1.default.scryptSync(password, salt, SCRYPT_KEYLEN, {
139
+ N: SCRYPT_N,
140
+ r: SCRYPT_R,
141
+ p: SCRYPT_P,
142
+ maxmem: 256 * 1024 * 1024,
143
+ });
144
+ }
145
+ /**
146
+ * Encrypt a private key with a password.
147
+ */
148
+ function encryptKey(privateKeyHex, password) {
149
+ if (password === null) {
150
+ return { data: privateKeyHex, encrypted: false };
151
+ }
152
+ const salt = crypto_1.default.randomBytes(SALT_LEN);
153
+ const iv = crypto_1.default.randomBytes(IV_LEN);
154
+ const key = deriveKey(password, salt);
155
+ const cipher = crypto_1.default.createCipheriv('aes-256-gcm', key, iv);
156
+ const encrypted = Buffer.concat([cipher.update(privateKeyHex, 'utf8'), cipher.final()]);
157
+ const authTag = cipher.getAuthTag();
158
+ return {
159
+ cipher: 'aes-256-gcm',
160
+ kdf: 'scrypt',
161
+ kdfParams: { N: SCRYPT_N, r: SCRYPT_R, p: SCRYPT_P },
162
+ salt: salt.toString('hex'),
163
+ iv: iv.toString('hex'),
164
+ authTag: authTag.toString('hex'),
165
+ ciphertext: encrypted.toString('hex'),
166
+ };
167
+ }
168
+ /**
169
+ * Decrypt a private key with a password.
170
+ */
171
+ function decryptKey(encryptedData, password) {
172
+ const ENCRYPTED_FIELDS = ['salt', 'iv', 'authTag', 'ciphertext'];
173
+ const hasEncryptionFields = ENCRYPTED_FIELDS.some(f => f in encryptedData);
174
+ // Unencrypted blob
175
+ if (encryptedData.encrypted === false) {
176
+ if (hasEncryptionFields) {
177
+ throw new Error('Wallet data corrupted or tampered');
178
+ }
179
+ return encryptedData.data;
180
+ }
181
+ // Encrypted blob with missing fields
182
+ if (!ENCRYPTED_FIELDS.every(f => f in encryptedData)) {
183
+ throw new Error('Wallet data corrupted or tampered');
184
+ }
185
+ // Encrypted blob but no password provided
186
+ if (password === null || password === undefined) {
187
+ throw new Error('Wallet is encrypted. Set OPENMM_WALLET_PASSWORD.');
188
+ }
189
+ const salt = Buffer.from(encryptedData.salt, 'hex');
190
+ const iv = Buffer.from(encryptedData.iv, 'hex');
191
+ const authTag = Buffer.from(encryptedData.authTag, 'hex');
192
+ const ciphertext = Buffer.from(encryptedData.ciphertext, 'hex');
193
+ const key = deriveKey(password, salt);
194
+ const decipher = crypto_1.default.createDecipheriv('aes-256-gcm', key, iv);
195
+ decipher.setAuthTag(authTag);
196
+ try {
197
+ const decrypted = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
198
+ return decrypted.toString('utf8');
199
+ }
200
+ catch {
201
+ throw new Error('Incorrect password');
202
+ }
203
+ }
204
+ /**
205
+ * Hash a password for verification (not encryption).
206
+ */
207
+ function hashPassword(password) {
208
+ const salt = crypto_1.default.randomBytes(16);
209
+ const hash = crypto_1.default.scryptSync(password, salt, 32, {
210
+ N: SCRYPT_N,
211
+ r: SCRYPT_R,
212
+ p: SCRYPT_P,
213
+ maxmem: 256 * 1024 * 1024,
214
+ });
215
+ return { salt: salt.toString('hex'), hash: hash.toString('hex') };
216
+ }
217
+ /**
218
+ * Verify a password against stored hash.
219
+ */
220
+ function verifyPassword(password, storedHash) {
221
+ const derived = crypto_1.default.scryptSync(password, Buffer.from(storedHash.salt, 'hex'), 32, {
222
+ N: SCRYPT_N,
223
+ r: SCRYPT_R,
224
+ p: SCRYPT_P,
225
+ maxmem: 256 * 1024 * 1024,
226
+ });
227
+ return crypto_1.default.timingSafeEqual(derived, Buffer.from(storedHash.hash, 'hex'));
228
+ }
229
+ /**
230
+ * Generate a random 32-byte private key.
231
+ */
232
+ function generatePrivateKey() {
233
+ return crypto_1.default.randomBytes(32);
234
+ }
235
+ /**
236
+ * Derive EVM address from private key.
237
+ */
238
+ function privateKeyToEvmAddress(privateKey) {
239
+ // Derive public key (uncompressed, 65 bytes: 0x04 + x + y)
240
+ const ecdh = crypto_1.default.createECDH('secp256k1');
241
+ ecdh.setPrivateKey(privateKey);
242
+ const publicKey = ecdh.getPublicKey(null, 'uncompressed');
243
+ // Address = last 20 bytes of keccak256(publicKey without 0x04 prefix)
244
+ const hash = keccak256(publicKey.subarray(1));
245
+ const addressBytes = hash.subarray(12);
246
+ const addressHex = addressBytes.toString('hex');
247
+ // EIP-55 checksum
248
+ const addressHash = keccak256(Buffer.from(addressHex, 'utf8')).toString('hex');
249
+ let checksummed = '0x';
250
+ for (let i = 0; i < 40; i++) {
251
+ checksummed += parseInt(addressHash[i], 16) >= 8 ? addressHex[i].toUpperCase() : addressHex[i];
252
+ }
253
+ return checksummed;
254
+ }
255
+ /**
256
+ * Generate Ed25519 keypair for Solana.
257
+ */
258
+ function generateSolanaKeypair() {
259
+ const { publicKey, privateKey } = crypto_1.default.generateKeyPairSync('ed25519', {
260
+ publicKeyEncoding: { type: 'spki', format: 'der' },
261
+ privateKeyEncoding: { type: 'pkcs8', format: 'der' },
262
+ });
263
+ // Extract raw 32-byte keys from DER encoding
264
+ const rawPrivate = privateKey.subarray(privateKey.length - 32);
265
+ const rawPublic = publicKey.subarray(publicKey.length - 32);
266
+ // Solana keypair format: 64 bytes = private seed (32) + public key (32)
267
+ const keypair = Buffer.concat([rawPrivate, rawPublic]);
268
+ return { privateKey: keypair, publicKey: rawPublic };
269
+ }
270
+ // ============= Base58 for Solana addresses =============
271
+ const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
272
+ /**
273
+ * Encode buffer to Base58 string (for Solana addresses).
274
+ */
275
+ function base58Encode(buffer) {
276
+ const bytes = [...buffer];
277
+ const digits = [0];
278
+ for (const byte of bytes) {
279
+ let carry = byte;
280
+ for (let j = 0; j < digits.length; j++) {
281
+ carry += digits[j] << 8;
282
+ digits[j] = carry % 58;
283
+ carry = Math.floor(carry / 58);
284
+ }
285
+ while (carry > 0) {
286
+ digits.push(carry % 58);
287
+ carry = Math.floor(carry / 58);
288
+ }
289
+ }
290
+ // Handle leading zeros
291
+ let leadingZeros = '';
292
+ for (const byte of bytes) {
293
+ if (byte === 0)
294
+ leadingZeros += '1';
295
+ else
296
+ break;
297
+ }
298
+ return leadingZeros + digits.reverse().map(d => BASE58_ALPHABET[d]).join('');
299
+ }
300
+ //# sourceMappingURL=crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/x402/crypto.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;AASH,8BAEC;AAMD,sCAiCC;AAoGD,gCAmCC;AAKD,gCA+CC;AAKD,oCASC;AAKD,wCAWC;AAKD,gDAEC;AAKD,wDAmBC;AAKD,sDAcC;AASD,oCAyBC;AA7VD,oDAA4B;AAG5B;;;GAGG;AACH,SAAgB,SAAS,CAAC,IAAY;IACpC,OAAO,gBAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;AAC7D,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,OAAe,EAAE,UAAkB;IAC/D,sDAAsD;IACtD,MAAM,IAAI,GAAG,gBAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC5C,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAE1D,mBAAmB;IACnB,MAAM,IAAI,GAAG,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACrB,IAAI,CAAC,GAAG,EAAE,CAAC;IAEX,0DAA0D;IAC1D,qCAAqC;IACrC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE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AAC;QACzB,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACxB,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACvB,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,KAAK,GAAG,CAAC,EAAE,CAAC;YACjB,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;YACxB,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,uBAAuB;IACvB,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,KAAK,CAAC;YAAE,YAAY,IAAI,GAAG,CAAC;;YAC/B,MAAM;IACb,CAAC;IAED,OAAO,YAAY,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * OpenMM x402 EVM Auto-Payment
3
+ * Implements EIP-3009 TransferWithAuthorization via EIP-712 typed data signing.
4
+ * Pure Node.js implementation — no external dependencies.
5
+ */
6
+ import type { PaymentRequirement, EIP712Domain } from './types';
7
+ interface TypeField {
8
+ name: string;
9
+ type: string;
10
+ }
11
+ /**
12
+ * Compute EIP-712 final hash: keccak256("\x19\x01" || domainSeparator || structHash)
13
+ */
14
+ export declare function hashTypedData(domain: EIP712Domain, primaryType: string, fields: TypeField[], message: Record<string, unknown>): Buffer;
15
+ /**
16
+ * Check if a network string is an EVM network.
17
+ */
18
+ export declare function isEvmNetwork(network: string): boolean;
19
+ /**
20
+ * Create an x402 payment payload for EVM (EIP-3009 TransferWithAuthorization).
21
+ *
22
+ * @param requirements - Parsed PaymentRequirements from 402 response
23
+ * @param privateKeyHex - 32-byte EVM private key as hex
24
+ * @param walletAddress - Signer's EVM address
25
+ * @param resource - Original request URL
26
+ * @returns Base64-encoded PaymentPayload for Payment-Signature header
27
+ */
28
+ export declare function createEvmPaymentPayload(requirements: PaymentRequirement, privateKeyHex: string, walletAddress: string, resource: string): string;
29
+ /**
30
+ * Check USDC balance on Base network.
31
+ *
32
+ * @param address - EVM address to check
33
+ * @returns Balance in USD (number) or null if check fails
34
+ */
35
+ export declare function checkEvmBalance(address: string): Promise<number | null>;
36
+ /**
37
+ * Get Base network RPC URL.
38
+ */
39
+ export declare function getBaseRpcUrl(): string;
40
+ export {};
41
+ //# sourceMappingURL=evm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/x402/evm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EAGb,MAAM,SAAS,CAAC;AAIjB,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AA0GD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,SAAS,EAAE,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAKR;AAcD;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,kBAAkB,EAChC,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf,MAAM,CAwER;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwB7E;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}