@metaflux-dex/client 0.0.3 → 0.0.5
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.
- package/README.md +196 -16
- package/dist/client.d.ts +173 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +264 -11
- package/dist/client.js.map +1 -1
- package/dist/faucet.js +1 -1
- package/dist/faucet.js.map +1 -1
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -9
- package/dist/index.js.map +1 -1
- package/dist/native/actions.d.ts +46 -0
- package/dist/native/actions.d.ts.map +1 -0
- package/dist/native/actions.js +593 -0
- package/dist/native/actions.js.map +1 -0
- package/dist/native/digest.d.ts +28 -0
- package/dist/native/digest.d.ts.map +1 -0
- package/dist/{native.js → native/digest.js} +71 -86
- package/dist/native/digest.js.map +1 -0
- package/dist/native/index.d.ts +3 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native/index.js +5 -0
- package/dist/native/index.js.map +1 -0
- package/dist/rest/http.d.ts.map +1 -0
- package/dist/rest/http.js.map +1 -0
- package/dist/{info.d.ts → rest/info.d.ts} +1 -1
- package/dist/rest/info.d.ts.map +1 -0
- package/dist/{info.js → rest/info.js} +8 -5
- package/dist/rest/info.js.map +1 -0
- package/dist/types/account.d.ts +52 -0
- package/dist/types/account.d.ts.map +1 -0
- package/dist/types/account.js +8 -0
- package/dist/types/account.js.map +1 -0
- package/dist/types/encrypted.d.ts +8 -0
- package/dist/types/encrypted.d.ts.map +1 -0
- package/dist/types/encrypted.js +7 -0
- package/dist/types/encrypted.js.map +1 -0
- package/dist/types/governance.d.ts +11 -0
- package/dist/types/governance.d.ts.map +1 -0
- package/dist/types/governance.js +7 -0
- package/dist/types/governance.js.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/info/core.d.ts +97 -0
- package/dist/types/info/core.d.ts.map +1 -0
- package/dist/types/info/core.js +15 -0
- package/dist/types/info/core.js.map +1 -0
- package/dist/{info-types.d.ts → types/info/hl-parity.d.ts} +8 -177
- package/dist/types/info/hl-parity.d.ts.map +1 -0
- package/dist/types/info/hl-parity.js +8 -0
- package/dist/types/info/hl-parity.js.map +1 -0
- package/dist/types/info/index.d.ts +4 -0
- package/dist/types/info/index.d.ts.map +1 -0
- package/dist/types/info/index.js +6 -0
- package/dist/types/info/index.js.map +1 -0
- package/dist/types/info/reads.d.ts +81 -0
- package/dist/types/info/reads.d.ts.map +1 -0
- package/dist/types/info/reads.js +7 -0
- package/dist/types/info/reads.js.map +1 -0
- package/dist/types/meta-bridge.d.ts +8 -0
- package/dist/types/meta-bridge.d.ts.map +1 -0
- package/dist/types/meta-bridge.js +7 -0
- package/dist/types/meta-bridge.js.map +1 -0
- package/dist/types/spot.d.ts +41 -0
- package/dist/types/spot.d.ts.map +1 -0
- package/dist/types/spot.js +7 -0
- package/dist/types/spot.js.map +1 -0
- package/dist/types/staking.d.ts +12 -0
- package/dist/types/staking.d.ts.map +1 -0
- package/dist/types/staking.js +6 -0
- package/dist/types/staking.js.map +1 -0
- package/dist/{types.d.ts → types/trading.d.ts} +33 -1
- package/dist/types/trading.d.ts.map +1 -0
- package/dist/{types.js → types/trading.js} +3 -3
- package/dist/types/trading.js.map +1 -0
- package/dist/types/twap.d.ts +13 -0
- package/dist/types/twap.d.ts.map +1 -0
- package/dist/types/twap.js +7 -0
- package/dist/types/twap.js.map +1 -0
- package/dist/types/vault.d.ts +24 -0
- package/dist/types/vault.d.ts.map +1 -0
- package/dist/types/vault.js +6 -0
- package/dist/types/vault.js.map +1 -0
- package/dist/{wasm.d.ts → wallet/wasm.d.ts} +1 -1
- package/dist/wallet/wasm.d.ts.map +1 -0
- package/dist/{wasm.js → wallet/wasm.js} +9 -8
- package/dist/wallet/wasm.js.map +1 -0
- package/dist/{ws.d.ts → ws/ws.d.ts} +1 -1
- package/dist/ws/ws.d.ts.map +1 -0
- package/dist/{ws.js → ws/ws.js} +11 -10
- package/dist/ws/ws.js.map +1 -0
- package/package.json +3 -1
- package/src/client.ts +610 -12
- package/src/faucet.ts +1 -1
- package/src/index.ts +115 -15
- package/src/native/actions.ts +820 -0
- package/src/{native.ts → native/digest.ts} +78 -95
- package/src/native/index.ts +5 -0
- package/src/{http.ts → rest/http.ts} +1 -1
- package/src/{info.ts → rest/info.ts} +9 -6
- package/src/types/account.ts +111 -0
- package/src/types/encrypted.ts +21 -0
- package/src/types/governance.ts +27 -0
- package/src/types/index.ts +79 -0
- package/src/types/info/core.ts +214 -0
- package/src/types/info/hl-parity.ts +428 -0
- package/src/types/info/index.ts +78 -0
- package/src/types/info/reads.ts +165 -0
- package/src/types/meta-bridge.ts +22 -0
- package/src/types/spot.ts +114 -0
- package/src/types/staking.ts +27 -0
- package/src/{types.ts → types/trading.ts} +92 -8
- package/src/types/twap.ts +29 -0
- package/src/types/vault.ts +55 -0
- package/src/{wasm.ts → wallet/wasm.ts} +10 -9
- package/src/{ws.ts → ws/ws.ts} +16 -14
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js.map +0 -1
- package/dist/info-types.d.ts.map +0 -1
- package/dist/info-types.js +0 -16
- package/dist/info-types.js.map +0 -1
- package/dist/info.d.ts.map +0 -1
- package/dist/info.js.map +0 -1
- package/dist/native.d.ts +0 -12
- package/dist/native.d.ts.map +0 -1
- package/dist/native.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/wasm.d.ts.map +0 -1
- package/dist/wasm.js.map +0 -1
- package/dist/ws.d.ts.map +0 -1
- package/dist/ws.js.map +0 -1
- package/src/info-types.ts +0 -783
- /package/dist/{http.d.ts → rest/http.d.ts} +0 -0
- /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
|
|
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
|
|
15
|
-
//
|
|
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:
|
|
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
|
|
149
|
+
} from './types/info/index.js';
|
|
104
150
|
export {
|
|
105
151
|
// MTF-native WebSocket client + subscription/channel types.
|
|
106
152
|
WsClient,
|
|
@@ -110,7 +156,7 @@ export {
|
|
|
110
156
|
type WsFrame,
|
|
111
157
|
type WsMessageHandler,
|
|
112
158
|
type WsConfig,
|
|
113
|
-
} from './ws.js';
|
|
159
|
+
} from './ws/ws.js';
|
|
114
160
|
export {
|
|
115
161
|
WasmNotBuiltError,
|
|
116
162
|
WasmCallError,
|
|
@@ -123,7 +169,7 @@ export {
|
|
|
123
169
|
eip712TypedDataHash,
|
|
124
170
|
encodeLimitOrder,
|
|
125
171
|
deriveAddressFromPubkey,
|
|
126
|
-
} from './wasm.js';
|
|
172
|
+
} from './wallet/wasm.js';
|
|
127
173
|
export type {
|
|
128
174
|
Order,
|
|
129
175
|
Builder,
|
|
@@ -139,9 +185,63 @@ export type {
|
|
|
139
185
|
NativeCancel,
|
|
140
186
|
NativeBuilder,
|
|
141
187
|
NativeSide,
|
|
188
|
+
NativePositionSide,
|
|
142
189
|
NativeOrderKind,
|
|
143
190
|
NativeTif,
|
|
144
191
|
NativeStpMode,
|
|
192
|
+
NativeSetPositionMode,
|
|
193
|
+
NativeSpotOrder,
|
|
194
|
+
NativeSpotCancel,
|
|
195
|
+
NativeSpotMarginDeposit,
|
|
196
|
+
NativeSpotMarginWithdraw,
|
|
197
|
+
NativeSpotMarginOpen,
|
|
198
|
+
NativeSpotMarginClose,
|
|
199
|
+
NativeEarnDeposit,
|
|
200
|
+
NativeEarnWithdraw,
|
|
145
201
|
NativeSignedAction,
|
|
146
202
|
NativeExchangeAck,
|
|
147
|
-
|
|
203
|
+
// Order-management actions.
|
|
204
|
+
OrderGrouping,
|
|
205
|
+
Modify,
|
|
206
|
+
BatchModify,
|
|
207
|
+
BatchOrder,
|
|
208
|
+
BatchCancel,
|
|
209
|
+
CancelByCloid,
|
|
210
|
+
ScheduleCancel,
|
|
211
|
+
CancelAllOrders,
|
|
212
|
+
// Account / margin / agent actions.
|
|
213
|
+
UpdateLeverage,
|
|
214
|
+
UpdateIsolatedMargin,
|
|
215
|
+
TopUpIsolatedOnlyMargin,
|
|
216
|
+
UserPortfolioMargin,
|
|
217
|
+
SetDisplayName,
|
|
218
|
+
SetReferrer,
|
|
219
|
+
ApproveAgent,
|
|
220
|
+
ApproveBuilderFee,
|
|
221
|
+
ConvertToMultiSigUser,
|
|
222
|
+
UserDexAbstraction,
|
|
223
|
+
UserSetAbstraction,
|
|
224
|
+
AgentSetAbstraction,
|
|
225
|
+
PriorityBid,
|
|
226
|
+
// TWAP.
|
|
227
|
+
TwapOrder,
|
|
228
|
+
TwapCancel,
|
|
229
|
+
// Staking.
|
|
230
|
+
TokenDelegate,
|
|
231
|
+
ClaimRewards,
|
|
232
|
+
LinkStakingUser,
|
|
233
|
+
// Encrypted orders.
|
|
234
|
+
SubmitEncryptedOrder,
|
|
235
|
+
// Vaults.
|
|
236
|
+
VaultKind,
|
|
237
|
+
CreateVault,
|
|
238
|
+
VaultTransfer,
|
|
239
|
+
VaultModify,
|
|
240
|
+
VaultWithdraw,
|
|
241
|
+
// MetaBridge.
|
|
242
|
+
MbChain,
|
|
243
|
+
MbWithdraw,
|
|
244
|
+
// Governance / operator.
|
|
245
|
+
SetMetaliquidityWhitelist,
|
|
246
|
+
RegisterMetaliquidityOperator,
|
|
247
|
+
} from './types/index.js';
|