@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.
- 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} +14 -1
- package/dist/ws/ws.d.ts.map +1 -0
- package/dist/{ws.js → ws/ws.js} +27 -15
- 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 +117 -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} +75 -22
- 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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Re-export barrel for the `/info` response type modules, split by domain:
|
|
2
|
+
// core.ts — node / account / market / vault / staking / fee shapes
|
|
3
|
+
// reads.ts — book / trade / account-history reads
|
|
4
|
+
// hl-parity.ts — the HL-node parity query shapes
|
|
5
|
+
|
|
6
|
+
export type {
|
|
7
|
+
NodeInfo,
|
|
8
|
+
AccountState,
|
|
9
|
+
AccountPosition,
|
|
10
|
+
Balances,
|
|
11
|
+
Tier,
|
|
12
|
+
MarginMode,
|
|
13
|
+
MarketInfo,
|
|
14
|
+
Funding,
|
|
15
|
+
VaultState,
|
|
16
|
+
StakingState,
|
|
17
|
+
Delegation,
|
|
18
|
+
PendingUnstake,
|
|
19
|
+
FeeSchedule,
|
|
20
|
+
FeeTier,
|
|
21
|
+
} from './core.js';
|
|
22
|
+
export type {
|
|
23
|
+
OpenOrders,
|
|
24
|
+
OpenOrder,
|
|
25
|
+
L2Book,
|
|
26
|
+
L2Level,
|
|
27
|
+
RecentTrades,
|
|
28
|
+
UserFills,
|
|
29
|
+
FundingHistory,
|
|
30
|
+
FundingSample,
|
|
31
|
+
BlockInfo,
|
|
32
|
+
Agents,
|
|
33
|
+
AgentEntry,
|
|
34
|
+
SubAccounts,
|
|
35
|
+
SubAccountEntry,
|
|
36
|
+
Mip3ActiveBids,
|
|
37
|
+
Mip3Bid,
|
|
38
|
+
} from './reads.js';
|
|
39
|
+
export type {
|
|
40
|
+
SpotMeta,
|
|
41
|
+
SpotPair,
|
|
42
|
+
SpotToken,
|
|
43
|
+
SpotClearinghouseState,
|
|
44
|
+
SpotBalance,
|
|
45
|
+
ExchangeStatus,
|
|
46
|
+
FrontendOpenOrders,
|
|
47
|
+
FrontendOpenOrder,
|
|
48
|
+
OrderTrigger,
|
|
49
|
+
Liquidatable,
|
|
50
|
+
LiquidatableAccount,
|
|
51
|
+
ActiveAssetData,
|
|
52
|
+
MaxMarketOrderNtls,
|
|
53
|
+
MaxMarketOrderNtl,
|
|
54
|
+
VaultSummaries,
|
|
55
|
+
VaultSummary,
|
|
56
|
+
UserVaultEquities,
|
|
57
|
+
VaultEquity,
|
|
58
|
+
LeadingVaults,
|
|
59
|
+
UserRateLimit,
|
|
60
|
+
SpotDeployState,
|
|
61
|
+
DelegatorSummary,
|
|
62
|
+
MaxBuilderFee,
|
|
63
|
+
UserToMultiSigSigners,
|
|
64
|
+
UserRole,
|
|
65
|
+
PerpsAtOpenInterestCap,
|
|
66
|
+
ValidatorL1Votes,
|
|
67
|
+
ValidatorL1Vote,
|
|
68
|
+
MarginTable,
|
|
69
|
+
MarginTier,
|
|
70
|
+
PerpDexs,
|
|
71
|
+
PerpDex,
|
|
72
|
+
ValidatorSummaries,
|
|
73
|
+
ValidatorSummary,
|
|
74
|
+
GossipRootIps,
|
|
75
|
+
WebData2,
|
|
76
|
+
WebData2Clearinghouse,
|
|
77
|
+
WebData2Position,
|
|
78
|
+
} from './hl-parity.js';
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// Book / trade / account-history response interfaces for `POST /info`.
|
|
2
|
+
//
|
|
3
|
+
// Source of truth: the KB spec metaflux-knowledges/api/rest/info.md. Field
|
|
4
|
+
// names are the exact snake_case keys the node emits inside `{type, data}.data`.
|
|
5
|
+
// Money magnitudes that can exceed 2^53 are typed `string`.
|
|
6
|
+
|
|
7
|
+
/// One resting order inside an `OpenOrders` response.
|
|
8
|
+
export interface OpenOrder {
|
|
9
|
+
/// Server order id.
|
|
10
|
+
oid: number;
|
|
11
|
+
/// Asset / market id the order rests on.
|
|
12
|
+
market_id: number;
|
|
13
|
+
/// Order side.
|
|
14
|
+
side: 'bid' | 'ask';
|
|
15
|
+
/// Resting price, fixed-point decimal string.
|
|
16
|
+
px: string;
|
|
17
|
+
/// Remaining size, fixed-point decimal string.
|
|
18
|
+
size: string;
|
|
19
|
+
/// Insertion timestamp (consensus ms).
|
|
20
|
+
inserted_at_ms: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/// `open_orders` — account-scoped resting orders across every perp book.
|
|
24
|
+
export interface OpenOrders {
|
|
25
|
+
/// Resolved account address (0x).
|
|
26
|
+
address: string;
|
|
27
|
+
/// Echoed only when the request used `account_id`.
|
|
28
|
+
account_id?: number;
|
|
29
|
+
/// Resting orders.
|
|
30
|
+
orders: OpenOrder[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// One aggregated L2 book level.
|
|
34
|
+
export interface L2Level {
|
|
35
|
+
/// Level price, fixed-point decimal string.
|
|
36
|
+
px: string;
|
|
37
|
+
/// Summed size at the level, fixed-point decimal string.
|
|
38
|
+
size: string;
|
|
39
|
+
/// Resting orders at the level.
|
|
40
|
+
n_orders: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// `l2_book` — market-scoped aggregated bid/ask levels.
|
|
44
|
+
export interface L2Book {
|
|
45
|
+
/// Echoed market id.
|
|
46
|
+
market_id: number;
|
|
47
|
+
/// Bid side (best-first, descending price).
|
|
48
|
+
bids: L2Level[];
|
|
49
|
+
/// Ask side (ascending price).
|
|
50
|
+
asks: L2Level[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/// `recent_trades` — market-scoped trade tape (honest-empty today).
|
|
54
|
+
export interface RecentTrades {
|
|
55
|
+
/// Echoed market id.
|
|
56
|
+
market_id: number;
|
|
57
|
+
/// Timestamp of the last trade (`0` if none).
|
|
58
|
+
last_trade_ms: number;
|
|
59
|
+
/// Empty until the trade indexer lands.
|
|
60
|
+
trades: unknown[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// `user_fills` — account-scoped fill history (honest-empty today).
|
|
64
|
+
export interface UserFills {
|
|
65
|
+
/// Resolved account address (0x).
|
|
66
|
+
address: string;
|
|
67
|
+
/// Echoed only when the request used `account_id`.
|
|
68
|
+
account_id?: number;
|
|
69
|
+
/// Empty until the fill indexer lands.
|
|
70
|
+
fills: unknown[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// One funding premium sample.
|
|
74
|
+
export interface FundingSample {
|
|
75
|
+
/// Sample timestamp (consensus ms).
|
|
76
|
+
ts_ms: number;
|
|
77
|
+
/// Funding premium sample (signed), decimal string.
|
|
78
|
+
premium: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/// `funding_history` — market-scoped funding premium samples.
|
|
82
|
+
export interface FundingHistory {
|
|
83
|
+
/// Echoed market id.
|
|
84
|
+
market_id: number;
|
|
85
|
+
/// Ordered ring of `(ts_ms, premium)` samples.
|
|
86
|
+
samples: FundingSample[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/// `block_info` — committed block metadata.
|
|
90
|
+
export interface BlockInfo {
|
|
91
|
+
/// Latest committed block height.
|
|
92
|
+
height: number;
|
|
93
|
+
/// Consensus round of that block.
|
|
94
|
+
round: number;
|
|
95
|
+
/// Current epoch.
|
|
96
|
+
epoch: number;
|
|
97
|
+
/// Block timestamp (consensus ms).
|
|
98
|
+
timestamp_ms: number;
|
|
99
|
+
/// Block hash (0x + 32 bytes); all-zero until plumbed into read state.
|
|
100
|
+
block_hash: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/// One approved agent inside an `Agents` response.
|
|
104
|
+
export interface AgentEntry {
|
|
105
|
+
/// Approved agent wallet address (0x).
|
|
106
|
+
agent: string;
|
|
107
|
+
/// Agent approval expiry (consensus ms).
|
|
108
|
+
expires_at_ms: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// `agents` — approved agent / API wallets for an account.
|
|
112
|
+
export interface Agents {
|
|
113
|
+
/// Resolved master address (0x).
|
|
114
|
+
address: string;
|
|
115
|
+
/// Echoed only when the request used `account_id`.
|
|
116
|
+
account_id?: number;
|
|
117
|
+
/// Approved agents.
|
|
118
|
+
agents: AgentEntry[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/// One sub-account inside a `SubAccounts` response.
|
|
122
|
+
export interface SubAccountEntry {
|
|
123
|
+
/// Sub-account index under the parent.
|
|
124
|
+
index: number;
|
|
125
|
+
/// Sub-account address (0x).
|
|
126
|
+
address: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// `sub_accounts` — sub-accounts of an account.
|
|
130
|
+
export interface SubAccounts {
|
|
131
|
+
/// Resolved parent address (0x).
|
|
132
|
+
address: string;
|
|
133
|
+
/// Echoed only when the request used `account_id`.
|
|
134
|
+
account_id?: number;
|
|
135
|
+
/// Sub-accounts.
|
|
136
|
+
sub_accounts: SubAccountEntry[];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// One MIP-3 auction bid.
|
|
140
|
+
export interface Mip3Bid {
|
|
141
|
+
/// Bidder address (0x).
|
|
142
|
+
bidder: string;
|
|
143
|
+
/// Bid amount, decimal string.
|
|
144
|
+
amount: string;
|
|
145
|
+
/// Bid submission timestamp (consensus ms).
|
|
146
|
+
submitted_at_ms: number;
|
|
147
|
+
/// Bid tag (e.g. the proposed market name).
|
|
148
|
+
tag: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/// `mip3_active_bids` — MIP-3 permissionless perp-deploy auction snapshot.
|
|
152
|
+
export interface Mip3ActiveBids {
|
|
153
|
+
/// Current auction round.
|
|
154
|
+
auction_round: number;
|
|
155
|
+
/// Leading bid amount, decimal string.
|
|
156
|
+
current_bid: string;
|
|
157
|
+
/// Current winning bidder (0x), or `null` if none.
|
|
158
|
+
current_winner: string | null;
|
|
159
|
+
/// Auction close timestamp (consensus ms).
|
|
160
|
+
auction_end_ms: number;
|
|
161
|
+
/// Auction start timestamp (consensus ms).
|
|
162
|
+
started_at_ms: number;
|
|
163
|
+
/// Bids.
|
|
164
|
+
bids: Mip3Bid[];
|
|
165
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// MTF-native MetaBridge withdrawal action payload types.
|
|
2
|
+
//
|
|
3
|
+
// Sender-authorized: the signer is the account whose cross-collateral is
|
|
4
|
+
// debited. The withdrawal queues an outbound message for validator co-signing,
|
|
5
|
+
// which releases funds on the destination chain.
|
|
6
|
+
|
|
7
|
+
/// Destination chain for a MetaBridge withdrawal. PascalCase to match the
|
|
8
|
+
/// node's chain enum.
|
|
9
|
+
export type MbChain = 'Base' | 'Arbitrum' | 'Solana';
|
|
10
|
+
|
|
11
|
+
/// `mb_withdraw` — withdraw cross-collateral to a destination chain.
|
|
12
|
+
export interface MbWithdraw {
|
|
13
|
+
/// Destination chain.
|
|
14
|
+
chain: MbChain;
|
|
15
|
+
/// MetaFlux asset id (`u32`; currently only `0` = USDC cross-collateral).
|
|
16
|
+
asset: number;
|
|
17
|
+
/// Amount in base units (`u64`).
|
|
18
|
+
amount: number;
|
|
19
|
+
/// Destination address as `0x`-hex: a 20-byte EVM address (Base / Arbitrum)
|
|
20
|
+
/// or a 32-byte recipient (Solana).
|
|
21
|
+
dst_addr: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// MTF-native spot CLOB (SE-0) action types.
|
|
2
|
+
//
|
|
3
|
+
// Byte-for-byte mirrors of the server spot action structs. Field ORDER is
|
|
4
|
+
// load-bearing for the signed bytes (see `buildNativeSpotOrderAction` /
|
|
5
|
+
// `buildNativeSpotCancelAction`).
|
|
6
|
+
|
|
7
|
+
import type { NativeSide, NativeStpMode, NativeTif } from './trading.js';
|
|
8
|
+
|
|
9
|
+
/// MTF-native `spot_order` action shape (SE-0 spot CLOB) — byte-for-byte mirror
|
|
10
|
+
/// of the server `NativeSpotOrder`. Sender-authorized (the signer is the trader,
|
|
11
|
+
/// no `owner`); spot has no positions, so there is no `reduce_only` /
|
|
12
|
+
/// `position_side`. v0 accepts ONLY `tif:"ioc"` with `limit_px > 0` — Gtc / Alo
|
|
13
|
+
/// and a zero (market) price are rejected by the node.
|
|
14
|
+
///
|
|
15
|
+
/// Field ORDER is load-bearing for the signed bytes (see `buildNativeSpotOrderAction`).
|
|
16
|
+
export interface NativeSpotOrder {
|
|
17
|
+
/// Spot pair id (`u32`); maps identity → asset id.
|
|
18
|
+
pair: number;
|
|
19
|
+
/// Side: `"bid"` (buy) or `"ask"` (sell).
|
|
20
|
+
side: NativeSide;
|
|
21
|
+
/// Base-asset size in raw lots (`u64` on the wire).
|
|
22
|
+
size: number;
|
|
23
|
+
/// Limit price in the 1e8 plane (`u64` on the wire); must be `> 0` in v0.
|
|
24
|
+
limit_px: number;
|
|
25
|
+
/// Time-in-force. v0 requires `"ioc"` (defaulted by the builder).
|
|
26
|
+
tif: NativeTif;
|
|
27
|
+
/// Self-trade-prevention mode.
|
|
28
|
+
stp_mode: NativeStpMode;
|
|
29
|
+
/// Optional `0x`-hex 32-char (16-byte) client order id. Omitted from the
|
|
30
|
+
/// signed bytes entirely when absent.
|
|
31
|
+
cloid?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// MTF-native `spot_cancel` action shape — byte-for-byte mirror of the server
|
|
35
|
+
/// `NativeSpotCancel`. Cancels a resting spot order by `oid` (the node cancels
|
|
36
|
+
/// by `oid`; there is no cancel-by-cloid on this path).
|
|
37
|
+
export interface NativeSpotCancel {
|
|
38
|
+
/// Spot pair id (`u32`).
|
|
39
|
+
pair: number;
|
|
40
|
+
/// Server order id (`u64`) to cancel. REQUIRED.
|
|
41
|
+
oid: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ---- Spot margin (leveraged spot) + Earn (lending pool) ----
|
|
45
|
+
//
|
|
46
|
+
// Available on devnet (preview). Leveraged spot is isolated per `(account,
|
|
47
|
+
// pair)`: posted quote collateral is a loss buffer, the borrow funds the buy
|
|
48
|
+
// 100%, and the bought base is held segregated on the margin account. Earn is
|
|
49
|
+
// the supply side that funds the borrows. All six actions are sender-authorized
|
|
50
|
+
// (the recovered signer is the actor — no `owner`). Decimal magnitudes
|
|
51
|
+
// (`amount` / `borrow` / `shares`) ride the wire as JSON **strings** to preserve
|
|
52
|
+
// fractional precision; `size` / `limit_px` are plain integers on the raw-lot /
|
|
53
|
+
// 1e8 planes, like a `NativeSpotOrder`. Field ORDER is load-bearing for the
|
|
54
|
+
// signed bytes (see the `buildNativeSpotMargin*` / `buildNativeEarn*` builders).
|
|
55
|
+
|
|
56
|
+
/// MTF-native `spot_margin_deposit` action params — post quote collateral into
|
|
57
|
+
/// the `(account, pair)` margin account. Margin must be enabled for the pair.
|
|
58
|
+
export interface NativeSpotMarginDeposit {
|
|
59
|
+
/// Spot pair id (`u32`).
|
|
60
|
+
pair: number;
|
|
61
|
+
/// Quote collateral to post (whole units), as a decimal string (`> 0`).
|
|
62
|
+
amount: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// MTF-native `spot_margin_withdraw` action params — withdraw free collateral
|
|
66
|
+
/// back to the spendable quote balance (initial-margin-gated while open).
|
|
67
|
+
export interface NativeSpotMarginWithdraw {
|
|
68
|
+
/// Spot pair id (`u32`).
|
|
69
|
+
pair: number;
|
|
70
|
+
/// Collateral to withdraw (whole quote units), as a decimal string (`> 0`).
|
|
71
|
+
amount: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// MTF-native `spot_margin_open` action params — borrow quote from the pair's
|
|
75
|
+
/// Earn pool and IOC-buy `size` base at up to `limit_px` on leverage. The
|
|
76
|
+
/// borrow funds the buy 100%; unspent borrow is repaid instantly.
|
|
77
|
+
export interface NativeSpotMarginOpen {
|
|
78
|
+
/// Spot pair id (`u32`).
|
|
79
|
+
pair: number;
|
|
80
|
+
/// Buy size in base raw lots (`u64`).
|
|
81
|
+
size: number;
|
|
82
|
+
/// Limit price in the 1e8 plane (`u64`, `> 0`).
|
|
83
|
+
limit_px: number;
|
|
84
|
+
/// Quote principal to draw from the Earn pool (whole units), as a decimal
|
|
85
|
+
/// string (`> 0`).
|
|
86
|
+
borrow: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/// MTF-native `spot_margin_close` action params — IOC-sell the held base at no
|
|
90
|
+
/// less than `limit_px`, repay principal + interest, return the remainder.
|
|
91
|
+
export interface NativeSpotMarginClose {
|
|
92
|
+
/// Spot pair id (`u32`).
|
|
93
|
+
pair: number;
|
|
94
|
+
/// Floor price for the close sell, in the 1e8 plane (`u64`, `> 0`).
|
|
95
|
+
limit_px: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/// MTF-native `earn_deposit` action params — supply quote into a lending pool
|
|
99
|
+
/// for pool shares (1:1 on a fresh pool, else priced off NAV; auto-creates).
|
|
100
|
+
export interface NativeEarnDeposit {
|
|
101
|
+
/// Lendable asset id (a spot pair's quote) — the pool key (`u32`).
|
|
102
|
+
asset: number;
|
|
103
|
+
/// Quote to supply (whole units), as a decimal string (`> 0`).
|
|
104
|
+
amount: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/// MTF-native `earn_withdraw` action params — redeem pool shares back to quote,
|
|
108
|
+
/// clamped to the pool's idle liquidity (`supplied − borrowed`).
|
|
109
|
+
export interface NativeEarnWithdraw {
|
|
110
|
+
/// Lendable asset id (the pool key) (`u32`).
|
|
111
|
+
asset: number;
|
|
112
|
+
/// Pool shares to redeem, as a decimal string (`> 0`, owned by the sender).
|
|
113
|
+
shares: string;
|
|
114
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// MTF-native staking action payload types.
|
|
2
|
+
//
|
|
3
|
+
// All sender-authorized (the recovered signer is the staking account). `amount`
|
|
4
|
+
// rides the wire as a decimal string.
|
|
5
|
+
|
|
6
|
+
/// `token_delegate` — delegate stake to a validator, or queue an undelegation.
|
|
7
|
+
export interface TokenDelegate {
|
|
8
|
+
/// `0x`-hex 20-byte validator address.
|
|
9
|
+
validator: string;
|
|
10
|
+
/// Stake amount as a decimal string.
|
|
11
|
+
amount: string;
|
|
12
|
+
/// `true` = unstake / queue undelegation; `false` = delegate.
|
|
13
|
+
is_undelegate: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/// `claim_rewards` — claim accrued staking rewards.
|
|
17
|
+
export interface ClaimRewards {
|
|
18
|
+
/// `0x`-hex 20-byte validator to claim from. Omit to claim across all
|
|
19
|
+
/// delegations.
|
|
20
|
+
validator?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/// `link_staking_user` — alias another account as this account's staking target.
|
|
24
|
+
export interface LinkStakingUser {
|
|
25
|
+
/// `0x`-hex 20-byte staking target address.
|
|
26
|
+
target: string;
|
|
27
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Trading type definitions for the @metaflux-dex/client surface.
|
|
2
2
|
//
|
|
3
3
|
// Shapes mirror the CCXT-compat REST responses emitted by the MetaFlux
|
|
4
|
-
// api-gateway
|
|
4
|
+
// api-gateway and the MTF-native signed-action wire. The
|
|
5
5
|
// monetary-fields-as-decimal-strings convention is load-bearing — CCXT
|
|
6
6
|
// clients pass these straight into `Decimal(value)` and any drift to
|
|
7
7
|
// number-typed fields silently loses precision.
|
|
@@ -96,7 +96,7 @@ export interface SignedOrder {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/// MTF-native order action shape (snake_case), byte-for-byte mirror of the
|
|
99
|
-
/// server `NativeOrder` (
|
|
99
|
+
/// server `NativeOrder` (per the KB spec metaflux-knowledges/api/rest/exchange.md).
|
|
100
100
|
/// These string/number forms are EXACTLY what rides inside the signed
|
|
101
101
|
/// `action` JSON posted to `POST /exchange` — the digest covers the
|
|
102
102
|
/// full object, so every field here is part of the signed bytes.
|
|
@@ -130,10 +130,26 @@ export interface NativeOrder {
|
|
|
130
130
|
cloid?: string;
|
|
131
131
|
/// Optional builder-code carve. Rides INSIDE the signed action object.
|
|
132
132
|
builder?: NativeBuilder;
|
|
133
|
+
/// HEDGE MODE: target leg (`"long"` / `"short"`). OMITTED on a one-way
|
|
134
|
+
/// account (the default), REQUIRED on a hedge account — the node validates
|
|
135
|
+
/// the mode↔side pairing. Left off the signed bytes entirely when absent, so
|
|
136
|
+
/// a one-way payload stays byte-identical to a pre-hedge SDK.
|
|
137
|
+
position_side?: NativePositionSide;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/// MTF-native `set_position_mode` action payload — byte-for-byte mirror of the
|
|
141
|
+
/// server `SetPositionModeParams`. Toggles the account between one-way (net,
|
|
142
|
+
/// `hedge:false`) and hedge / two-way (`hedge:true`) position modes. Only legal
|
|
143
|
+
/// while flat on every market (the node rejects a switch with open positions).
|
|
144
|
+
/// Sender-authorized: the recovered signer IS the account, so there is no
|
|
145
|
+
/// `owner` field.
|
|
146
|
+
export interface NativeSetPositionMode {
|
|
147
|
+
/// `true` = hedge / two-way; `false` = one-way / net.
|
|
148
|
+
hedge: boolean;
|
|
133
149
|
}
|
|
134
150
|
|
|
135
151
|
/// MTF-native `cancel_order` action shape (snake_case), byte-for-byte mirror of
|
|
136
|
-
/// the server `NativeCancel` (
|
|
152
|
+
/// the server `NativeCancel` (per the KB spec metaflux-knowledges/api/rest/exchange.md).
|
|
137
153
|
/// Field ORDER is load-bearing for the same reason as `NativeOrder`: the server
|
|
138
154
|
/// verifies the signature over the raw `action` bytes (see
|
|
139
155
|
/// `buildNativeCancelAction`).
|
|
@@ -154,6 +170,10 @@ export interface NativeCancel {
|
|
|
154
170
|
/// MTF-native side string — mirrors the server `NativeSide`.
|
|
155
171
|
export type NativeSide = 'bid' | 'ask';
|
|
156
172
|
|
|
173
|
+
/// MTF-native position-side string (HEDGE MODE) — mirrors the server
|
|
174
|
+
/// `NativePositionSide`. Selects which leg a hedge-account order targets.
|
|
175
|
+
export type NativePositionSide = 'long' | 'short';
|
|
176
|
+
|
|
157
177
|
/// MTF-native order kind — mirrors the server `NativeOrderKind`. Only
|
|
158
178
|
/// `limit` / `market` are mapped server-side; `stop_loss` / `take_profit`
|
|
159
179
|
/// are rejected (triggers not wired).
|
|
@@ -180,6 +200,70 @@ export interface NativeBuilder {
|
|
|
180
200
|
user: string;
|
|
181
201
|
}
|
|
182
202
|
|
|
203
|
+
// ---- order-management actions ----
|
|
204
|
+
|
|
205
|
+
/// Order grouping for a [`BatchOrder`] — mirrors the server `OrderGrouping`.
|
|
206
|
+
/// `"na"` = independent orders; the TP/SL variants attach children.
|
|
207
|
+
export type OrderGrouping = 'na' | 'normalTpsl' | 'positionTpsl';
|
|
208
|
+
|
|
209
|
+
/// `modify` action payload — amend a resting order's price and/or size in
|
|
210
|
+
/// place. An omitted field is left unchanged.
|
|
211
|
+
export interface Modify {
|
|
212
|
+
/// Target market id (`u32`).
|
|
213
|
+
market: number;
|
|
214
|
+
/// Order id to amend (`u64`).
|
|
215
|
+
oid: number;
|
|
216
|
+
/// New limit price in tick units (`u64`); omit to leave unchanged.
|
|
217
|
+
new_px?: number;
|
|
218
|
+
/// New size in tick units (`u64`); omit to leave unchanged.
|
|
219
|
+
new_size?: number;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/// `batch_modify` action payload — N [`Modify`]s under one signature.
|
|
223
|
+
export interface BatchModify {
|
|
224
|
+
/// Modifications, applied in order.
|
|
225
|
+
modifications: Modify[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/// `batch_order` action payload — N orders under one signature. Each order's
|
|
229
|
+
/// `owner` must equal the signing wallet.
|
|
230
|
+
export interface BatchOrder {
|
|
231
|
+
/// Orders to place, in priority order.
|
|
232
|
+
orders: NativeOrder[];
|
|
233
|
+
/// Grouping semantics. Defaults to `"na"` when omitted.
|
|
234
|
+
grouping?: OrderGrouping;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/// `batch_cancel` action payload — N cancels under one signature. Each cancel's
|
|
238
|
+
/// `owner` must equal the signing wallet and must carry an `oid`.
|
|
239
|
+
export interface BatchCancel {
|
|
240
|
+
/// Cancels to apply, in order.
|
|
241
|
+
cancels: NativeCancel[];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/// `cancel_by_cloid` action payload — cancel a resting order by client id.
|
|
245
|
+
export interface CancelByCloid {
|
|
246
|
+
/// Target asset / market id (`u32`).
|
|
247
|
+
asset: number;
|
|
248
|
+
/// `0x`-hex 32-char (16-byte) client order id.
|
|
249
|
+
cloid: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/// `schedule_cancel` action payload — cancel-all of the sender's open orders at
|
|
253
|
+
/// a future block.
|
|
254
|
+
export interface ScheduleCancel {
|
|
255
|
+
/// Block height at which all of the sender's open orders are cancelled
|
|
256
|
+
/// (`u64`).
|
|
257
|
+
cancel_at_block: number;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/// `cancel_all_orders` action payload — cancel all of the sender's open orders,
|
|
261
|
+
/// optionally filtered to one asset.
|
|
262
|
+
export interface CancelAllOrders {
|
|
263
|
+
/// Asset filter (`u32`). Omit to cancel across all assets.
|
|
264
|
+
asset?: number;
|
|
265
|
+
}
|
|
266
|
+
|
|
183
267
|
/// Signed native action envelope posted to `POST /exchange`.
|
|
184
268
|
///
|
|
185
269
|
/// `action` is the raw JSON STRING (not a parsed object) so the bytes sent
|
|
@@ -198,7 +282,7 @@ export interface NativeSignedAction {
|
|
|
198
282
|
/// Per-order status entry returned by `/exchange` for an order-type action.
|
|
199
283
|
///
|
|
200
284
|
/// Byte-for-byte the node `OrderStatusEntry`
|
|
201
|
-
/// (
|
|
285
|
+
/// (per the KB spec metaflux-knowledges/api/rest/exchange.md): a tagged union selected by
|
|
202
286
|
/// the single present key, one entry per submitted order, in submission order.
|
|
203
287
|
/// `total_sz` / `avg_px` are 8-decimal fixed-point u128 STRINGS (native JSON
|
|
204
288
|
/// numbers lose precision past 2^53); `oid` / `nonce` are JSON numbers.
|
|
@@ -215,7 +299,7 @@ export type OrderStatus =
|
|
|
215
299
|
| { pending: { action_hash: string; nonce: number } };
|
|
216
300
|
|
|
217
301
|
/// Server response to `POST /exchange`. Mirrors the node `ExchangeResponse`
|
|
218
|
-
/// (
|
|
302
|
+
/// (per the KB spec metaflux-knowledges/api/rest/exchange.md).
|
|
219
303
|
///
|
|
220
304
|
/// Two shapes share this struct (the node omits the absent keys):
|
|
221
305
|
/// - **Order-type actions** (`submit_order` / `batch_order` / `cancel_order` /
|
|
@@ -241,8 +325,8 @@ export interface NativeExchangeAck {
|
|
|
241
325
|
action_hash?: string;
|
|
242
326
|
}
|
|
243
327
|
|
|
244
|
-
/// Acknowledgement from `submitOrder`. Mirrors `Order` from the
|
|
245
|
-
/// response shape
|
|
328
|
+
/// Acknowledgement from `submitOrder`. Mirrors `Order` from the gateway's
|
|
329
|
+
/// CCXT-compat REST response shape; monetary
|
|
246
330
|
/// fields are decimal strings to match what the gateway emits.
|
|
247
331
|
export interface OrderAck {
|
|
248
332
|
id: string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// MTF-native TWAP (time-weighted average price) action payload types.
|
|
2
|
+
//
|
|
3
|
+
// A TWAP parent slices `total_size` into `slice_count` child orders spaced
|
|
4
|
+
// `delay_ms` apart. Sender-authorized (no `owner` field); `total_size` is in
|
|
5
|
+
// fixed-point tick units like a perp order's `size`.
|
|
6
|
+
|
|
7
|
+
import type { NativeSide } from './trading.js';
|
|
8
|
+
|
|
9
|
+
/// `twap_order` — submit a sliced (TWAP) order.
|
|
10
|
+
export interface TwapOrder {
|
|
11
|
+
/// Target market id (`u32`).
|
|
12
|
+
market: number;
|
|
13
|
+
/// Side: `"bid"` (buy) or `"ask"` (sell).
|
|
14
|
+
side: NativeSide;
|
|
15
|
+
/// Total size in fixed-point tick units (`u64`), split across all slices.
|
|
16
|
+
total_size: number;
|
|
17
|
+
/// Number of child slices (`u32`).
|
|
18
|
+
slice_count: number;
|
|
19
|
+
/// Inter-slice delay in milliseconds (`u64`).
|
|
20
|
+
delay_ms: number;
|
|
21
|
+
/// Reduce-only flag (each slice may only reduce an existing position).
|
|
22
|
+
reduce_only: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/// `twap_cancel` — cancel a running TWAP parent by id.
|
|
26
|
+
export interface TwapCancel {
|
|
27
|
+
/// TWAP parent id (`u64`), assigned when the parent was submitted.
|
|
28
|
+
twap_id: number;
|
|
29
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// MTF-native vault action payload types.
|
|
2
|
+
//
|
|
3
|
+
// Sender-authorized: the recovered signer is the leader / follower. Decimal
|
|
4
|
+
// magnitudes (`amount` / `shares`) ride the wire as JSON strings.
|
|
5
|
+
|
|
6
|
+
/// Kind of vault created by [`CreateVault`]. PascalCase to match the node's
|
|
7
|
+
/// vault-kind enum.
|
|
8
|
+
export type VaultKind = 'User' | 'Metaliquidity';
|
|
9
|
+
|
|
10
|
+
/// `create_vault` — create a new vault. The signing wallet becomes the leader.
|
|
11
|
+
export interface CreateVault {
|
|
12
|
+
/// Display name.
|
|
13
|
+
name: string;
|
|
14
|
+
/// Follower withdrawal lock period in seconds (`u64`).
|
|
15
|
+
lock_period_secs: number;
|
|
16
|
+
/// Optional parent vault id (`u64`).
|
|
17
|
+
parent?: number;
|
|
18
|
+
/// Vault kind. Defaults to `"User"` when omitted.
|
|
19
|
+
kind?: VaultKind;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// `vault_transfer` — leader moves capital into (`deposit: true`) or out of
|
|
23
|
+
/// (`deposit: false`) a vault.
|
|
24
|
+
export interface VaultTransfer {
|
|
25
|
+
/// Target vault id (`u64`).
|
|
26
|
+
vault_id: number;
|
|
27
|
+
/// `true` = deposit (leader → vault), `false` = withdraw (vault → leader).
|
|
28
|
+
deposit: boolean;
|
|
29
|
+
/// Amount in USD as a decimal string.
|
|
30
|
+
amount: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/// `vault_modify` — leader updates vault configuration. An omitted field is
|
|
34
|
+
/// left unchanged.
|
|
35
|
+
export interface VaultModify {
|
|
36
|
+
/// Target vault id (`u64`).
|
|
37
|
+
vault_id: number;
|
|
38
|
+
/// New display name.
|
|
39
|
+
new_name?: string;
|
|
40
|
+
/// New lock period in seconds (`u64`).
|
|
41
|
+
new_lock_period_secs?: number;
|
|
42
|
+
/// New management fee in bps (`u16`).
|
|
43
|
+
new_management_fee_bps?: number;
|
|
44
|
+
/// New paused flag.
|
|
45
|
+
new_paused?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// `vault_withdraw` — follower redeems shares from a vault (subject to the
|
|
49
|
+
/// per-vault lock).
|
|
50
|
+
export interface VaultWithdraw {
|
|
51
|
+
/// Target vault id (`u64`).
|
|
52
|
+
vault_id: number;
|
|
53
|
+
/// Shares to redeem, as a decimal string.
|
|
54
|
+
shares: string;
|
|
55
|
+
}
|