@metaflux-dex/client 0.0.3 → 0.0.6

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 (137) hide show
  1. package/README.md +196 -16
  2. package/dist/client.d.ts +173 -3
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +264 -11
  5. package/dist/client.js.map +1 -1
  6. package/dist/faucet.js +1 -1
  7. package/dist/faucet.js.map +1 -1
  8. package/dist/index.d.ts +8 -7
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +14 -9
  11. package/dist/index.js.map +1 -1
  12. package/dist/native/actions.d.ts +46 -0
  13. package/dist/native/actions.d.ts.map +1 -0
  14. package/dist/native/actions.js +593 -0
  15. package/dist/native/actions.js.map +1 -0
  16. package/dist/native/digest.d.ts +28 -0
  17. package/dist/native/digest.d.ts.map +1 -0
  18. package/dist/{native.js → native/digest.js} +71 -86
  19. package/dist/native/digest.js.map +1 -0
  20. package/dist/native/index.d.ts +3 -0
  21. package/dist/native/index.d.ts.map +1 -0
  22. package/dist/native/index.js +5 -0
  23. package/dist/native/index.js.map +1 -0
  24. package/dist/rest/http.d.ts.map +1 -0
  25. package/dist/rest/http.js.map +1 -0
  26. package/dist/{info.d.ts → rest/info.d.ts} +1 -1
  27. package/dist/rest/info.d.ts.map +1 -0
  28. package/dist/{info.js → rest/info.js} +8 -5
  29. package/dist/rest/info.js.map +1 -0
  30. package/dist/types/account.d.ts +52 -0
  31. package/dist/types/account.d.ts.map +1 -0
  32. package/dist/types/account.js +8 -0
  33. package/dist/types/account.js.map +1 -0
  34. package/dist/types/encrypted.d.ts +8 -0
  35. package/dist/types/encrypted.d.ts.map +1 -0
  36. package/dist/types/encrypted.js +7 -0
  37. package/dist/types/encrypted.js.map +1 -0
  38. package/dist/types/governance.d.ts +11 -0
  39. package/dist/types/governance.d.ts.map +1 -0
  40. package/dist/types/governance.js +7 -0
  41. package/dist/types/governance.js.map +1 -0
  42. package/dist/types/index.d.ts +10 -0
  43. package/dist/types/index.d.ts.map +1 -0
  44. package/dist/types/index.js +6 -0
  45. package/dist/types/index.js.map +1 -0
  46. package/dist/types/info/core.d.ts +97 -0
  47. package/dist/types/info/core.d.ts.map +1 -0
  48. package/dist/types/info/core.js +15 -0
  49. package/dist/types/info/core.js.map +1 -0
  50. package/dist/{info-types.d.ts → types/info/hl-parity.d.ts} +8 -177
  51. package/dist/types/info/hl-parity.d.ts.map +1 -0
  52. package/dist/types/info/hl-parity.js +8 -0
  53. package/dist/types/info/hl-parity.js.map +1 -0
  54. package/dist/types/info/index.d.ts +4 -0
  55. package/dist/types/info/index.d.ts.map +1 -0
  56. package/dist/types/info/index.js +6 -0
  57. package/dist/types/info/index.js.map +1 -0
  58. package/dist/types/info/reads.d.ts +81 -0
  59. package/dist/types/info/reads.d.ts.map +1 -0
  60. package/dist/types/info/reads.js +7 -0
  61. package/dist/types/info/reads.js.map +1 -0
  62. package/dist/types/meta-bridge.d.ts +8 -0
  63. package/dist/types/meta-bridge.d.ts.map +1 -0
  64. package/dist/types/meta-bridge.js +7 -0
  65. package/dist/types/meta-bridge.js.map +1 -0
  66. package/dist/types/spot.d.ts +41 -0
  67. package/dist/types/spot.d.ts.map +1 -0
  68. package/dist/types/spot.js +7 -0
  69. package/dist/types/spot.js.map +1 -0
  70. package/dist/types/staking.d.ts +12 -0
  71. package/dist/types/staking.d.ts.map +1 -0
  72. package/dist/types/staking.js +6 -0
  73. package/dist/types/staking.js.map +1 -0
  74. package/dist/{types.d.ts → types/trading.d.ts} +33 -1
  75. package/dist/types/trading.d.ts.map +1 -0
  76. package/dist/{types.js → types/trading.js} +3 -3
  77. package/dist/types/trading.js.map +1 -0
  78. package/dist/types/twap.d.ts +13 -0
  79. package/dist/types/twap.d.ts.map +1 -0
  80. package/dist/types/twap.js +7 -0
  81. package/dist/types/twap.js.map +1 -0
  82. package/dist/types/vault.d.ts +24 -0
  83. package/dist/types/vault.d.ts.map +1 -0
  84. package/dist/types/vault.js +6 -0
  85. package/dist/types/vault.js.map +1 -0
  86. package/dist/{wasm.d.ts → wallet/wasm.d.ts} +1 -1
  87. package/dist/wallet/wasm.d.ts.map +1 -0
  88. package/dist/{wasm.js → wallet/wasm.js} +9 -8
  89. package/dist/wallet/wasm.js.map +1 -0
  90. package/dist/{ws.d.ts → ws/ws.d.ts} +14 -1
  91. package/dist/ws/ws.d.ts.map +1 -0
  92. package/dist/{ws.js → ws/ws.js} +27 -15
  93. package/dist/ws/ws.js.map +1 -0
  94. package/package.json +3 -1
  95. package/src/client.ts +610 -12
  96. package/src/faucet.ts +1 -1
  97. package/src/index.ts +117 -15
  98. package/src/native/actions.ts +820 -0
  99. package/src/{native.ts → native/digest.ts} +78 -95
  100. package/src/native/index.ts +5 -0
  101. package/src/{http.ts → rest/http.ts} +1 -1
  102. package/src/{info.ts → rest/info.ts} +9 -6
  103. package/src/types/account.ts +111 -0
  104. package/src/types/encrypted.ts +21 -0
  105. package/src/types/governance.ts +27 -0
  106. package/src/types/index.ts +79 -0
  107. package/src/types/info/core.ts +214 -0
  108. package/src/types/info/hl-parity.ts +428 -0
  109. package/src/types/info/index.ts +78 -0
  110. package/src/types/info/reads.ts +165 -0
  111. package/src/types/meta-bridge.ts +22 -0
  112. package/src/types/spot.ts +114 -0
  113. package/src/types/staking.ts +27 -0
  114. package/src/{types.ts → types/trading.ts} +92 -8
  115. package/src/types/twap.ts +29 -0
  116. package/src/types/vault.ts +55 -0
  117. package/src/{wasm.ts → wallet/wasm.ts} +10 -9
  118. package/src/{ws.ts → ws/ws.ts} +75 -22
  119. package/dist/http.d.ts.map +0 -1
  120. package/dist/http.js.map +0 -1
  121. package/dist/info-types.d.ts.map +0 -1
  122. package/dist/info-types.js +0 -16
  123. package/dist/info-types.js.map +0 -1
  124. package/dist/info.d.ts.map +0 -1
  125. package/dist/info.js.map +0 -1
  126. package/dist/native.d.ts +0 -12
  127. package/dist/native.d.ts.map +0 -1
  128. package/dist/native.js.map +0 -1
  129. package/dist/types.d.ts.map +0 -1
  130. package/dist/types.js.map +0 -1
  131. package/dist/wasm.d.ts.map +0 -1
  132. package/dist/wasm.js.map +0 -1
  133. package/dist/ws.d.ts.map +0 -1
  134. package/dist/ws.js.map +0 -1
  135. package/src/info-types.ts +0 -783
  136. /package/dist/{http.d.ts → rest/http.d.ts} +0 -0
  137. /package/dist/{http.js → rest/http.js} +0 -0
package/src/index.ts CHANGED
@@ -1,36 +1,81 @@
1
1
  // Public barrel — every export consumers see goes through this file.
2
2
  //
3
3
  // Pinning the public surface here means we can refactor the internal
4
- // `client.ts` / `wasm.ts` / `http.ts` split without touching anything
5
- // import-facing. The npm package `exports` map points at the compiled
4
+ // `client.ts` / `wallet/wasm.ts` / `rest/http.ts` split without touching
5
+ // anything import-facing. The npm package `exports` map points at the compiled
6
6
  // `dist/index.js`, so consumers write:
7
7
  //
8
8
  // import { Client, type Order } from '@metaflux-dex/client';
9
9
 
10
10
  export { Client, type ClientOpts } from './client.js';
11
- export { MetaFluxApiError } from './http.js';
11
+ export { MetaFluxApiError } from './rest/http.js';
12
12
  export { requestFaucet, type FaucetResponse } from './faucet.js';
13
13
  export {
14
- // MTF-native signed-action surface (the path the server now accepts).
15
- // Exported so power users can build / sign / inspect actions out-of-band.
14
+ // MTF-native signed-action signing core. Exported so power users can build /
15
+ // sign / inspect actions out-of-band.
16
16
  MTF_CHAIN_ID,
17
17
  MTF_MAINNET_CHAIN_ID,
18
18
  MTF_TESTNET_CHAIN_ID,
19
19
  nativeActionDigest,
20
- buildNativeOrderAction,
21
- buildNativeCancelAction,
22
20
  signNativeAction,
23
21
  recoverNativeSigner,
24
22
  nativeRequestBody,
25
- } from './native.js';
23
+ } from './native/digest.js';
24
+ export {
25
+ // MTF-native action builders — the full real /exchange surface.
26
+ buildNativeOrderAction,
27
+ buildNativeCancelAction,
28
+ buildNativeCancelByCloidAction,
29
+ buildNativeModifyAction,
30
+ buildNativeBatchModifyAction,
31
+ buildNativeBatchOrderAction,
32
+ buildNativeBatchCancelAction,
33
+ buildNativeScheduleCancelAction,
34
+ buildNativeCancelAllOrdersAction,
35
+ buildNativeSetPositionModeAction,
36
+ buildNativeTwapOrderAction,
37
+ buildNativeTwapCancelAction,
38
+ buildNativeUpdateLeverageAction,
39
+ buildNativeUpdateIsolatedMarginAction,
40
+ buildNativeTopUpIsolatedOnlyMarginAction,
41
+ buildNativeUserPortfolioMarginAction,
42
+ buildNativeSetDisplayNameAction,
43
+ buildNativeSetReferrerAction,
44
+ buildNativeApproveAgentAction,
45
+ buildNativeApproveBuilderFeeAction,
46
+ buildNativeConvertToMultiSigUserAction,
47
+ buildNativeUserDexAbstractionAction,
48
+ buildNativeUserSetAbstractionAction,
49
+ buildNativeAgentSetAbstractionAction,
50
+ buildNativePriorityBidAction,
51
+ buildNativeTokenDelegateAction,
52
+ buildNativeClaimRewardsAction,
53
+ buildNativeLinkStakingUserAction,
54
+ buildNativeSubmitEncryptedOrderAction,
55
+ buildNativeCreateVaultAction,
56
+ buildNativeVaultTransferAction,
57
+ buildNativeVaultModifyAction,
58
+ buildNativeVaultWithdrawAction,
59
+ buildNativeMbWithdrawAction,
60
+ buildNativeSetMetaliquidityWhitelistAction,
61
+ buildNativeRegisterMetaliquidityOperatorAction,
62
+ // Spot CLOB + spot margin (leveraged spot) + Earn (lending pool).
63
+ buildNativeSpotOrderAction,
64
+ buildNativeSpotCancelAction,
65
+ buildNativeSpotMarginDepositAction,
66
+ buildNativeSpotMarginWithdrawAction,
67
+ buildNativeSpotMarginOpenAction,
68
+ buildNativeSpotMarginCloseAction,
69
+ buildNativeEarnDepositAction,
70
+ buildNativeEarnWithdrawAction,
71
+ } from './native/actions.js';
26
72
  export {
27
73
  // MTF-native `/info` read API + the account-ref union (address | account_id).
28
74
  InfoApi,
29
75
  type AccountRef,
30
- } from './info.js';
76
+ } from './rest/info.js';
31
77
  export type {
32
- // MTF-native `/info` response shapes. Source of truth: the node handlers in
33
- // `metaflux/crates/api-node/src/rest/info/{reads,markets,hl_parity}.rs` and
78
+ // MTF-native `/info` response shapes. Source of truth:
34
79
  // the KB spec `metaflux-knowledges/api/rest/info.md`. Every field is the exact
35
80
  // snake_case key the node emits inside the `{type, data}` envelope's `data`.
36
81
  NodeInfo,
@@ -65,6 +110,7 @@ export type {
65
110
  // HL-node parity shapes.
66
111
  SpotMeta,
67
112
  SpotPair,
113
+ SpotToken,
68
114
  SpotClearinghouseState,
69
115
  SpotBalance,
70
116
  ExchangeStatus,
@@ -100,7 +146,7 @@ export type {
100
146
  WebData2,
101
147
  WebData2Clearinghouse,
102
148
  WebData2Position,
103
- } from './info-types.js';
149
+ } from './types/info/index.js';
104
150
  export {
105
151
  // MTF-native WebSocket client + subscription/channel types.
106
152
  WsClient,
@@ -110,7 +156,9 @@ export {
110
156
  type WsFrame,
111
157
  type WsMessageHandler,
112
158
  type WsConfig,
113
- } from './ws.js';
159
+ type AllMids,
160
+ type ActiveAssetCtx,
161
+ } from './ws/ws.js';
114
162
  export {
115
163
  WasmNotBuiltError,
116
164
  WasmCallError,
@@ -123,7 +171,7 @@ export {
123
171
  eip712TypedDataHash,
124
172
  encodeLimitOrder,
125
173
  deriveAddressFromPubkey,
126
- } from './wasm.js';
174
+ } from './wallet/wasm.js';
127
175
  export type {
128
176
  Order,
129
177
  Builder,
@@ -139,9 +187,63 @@ export type {
139
187
  NativeCancel,
140
188
  NativeBuilder,
141
189
  NativeSide,
190
+ NativePositionSide,
142
191
  NativeOrderKind,
143
192
  NativeTif,
144
193
  NativeStpMode,
194
+ NativeSetPositionMode,
195
+ NativeSpotOrder,
196
+ NativeSpotCancel,
197
+ NativeSpotMarginDeposit,
198
+ NativeSpotMarginWithdraw,
199
+ NativeSpotMarginOpen,
200
+ NativeSpotMarginClose,
201
+ NativeEarnDeposit,
202
+ NativeEarnWithdraw,
145
203
  NativeSignedAction,
146
204
  NativeExchangeAck,
147
- } from './types.js';
205
+ // Order-management actions.
206
+ OrderGrouping,
207
+ Modify,
208
+ BatchModify,
209
+ BatchOrder,
210
+ BatchCancel,
211
+ CancelByCloid,
212
+ ScheduleCancel,
213
+ CancelAllOrders,
214
+ // Account / margin / agent actions.
215
+ UpdateLeverage,
216
+ UpdateIsolatedMargin,
217
+ TopUpIsolatedOnlyMargin,
218
+ UserPortfolioMargin,
219
+ SetDisplayName,
220
+ SetReferrer,
221
+ ApproveAgent,
222
+ ApproveBuilderFee,
223
+ ConvertToMultiSigUser,
224
+ UserDexAbstraction,
225
+ UserSetAbstraction,
226
+ AgentSetAbstraction,
227
+ PriorityBid,
228
+ // TWAP.
229
+ TwapOrder,
230
+ TwapCancel,
231
+ // Staking.
232
+ TokenDelegate,
233
+ ClaimRewards,
234
+ LinkStakingUser,
235
+ // Encrypted orders.
236
+ SubmitEncryptedOrder,
237
+ // Vaults.
238
+ VaultKind,
239
+ CreateVault,
240
+ VaultTransfer,
241
+ VaultModify,
242
+ VaultWithdraw,
243
+ // MetaBridge.
244
+ MbChain,
245
+ MbWithdraw,
246
+ // Governance / operator.
247
+ SetMetaliquidityWhitelist,
248
+ RegisterMetaliquidityOperator,
249
+ } from './types/index.js';