forked from sonirico/go-hyperliquid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactions.go
More file actions
206 lines (178 loc) · 8.03 KB
/
actions.go
File metadata and controls
206 lines (178 loc) · 8.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package hyperliquid
// Action structs with deterministic field ordering for consistent MessagePack serialization
// The order of fields in these structs is critical for signature generation
// CancelOrderWire represents cancel order item wire format
type CancelOrderWire struct {
Asset int `json:"a" msgpack:"a"`
OrderID string `json:"o" msgpack:"o"`
}
// CancelAction represents the cancel action
type CancelAction struct {
Type string `json:"type" msgpack:"type"`
Cancels []CancelOrderWire `json:"cancels" msgpack:"cancels"`
}
// CancelByCloidWire represents cancel by cloid item wire format
type CancelByCloidWire struct {
Asset int `json:"a" msgpack:"a"`
OrderID string `json:"cloid" msgpack:"cloid"`
}
// CancelByCloidAction represents the cancel by cloid action
type CancelByCloidAction struct {
Type string `json:"type" msgpack:"type"`
Cancels []CancelByCloidWire `json:"cancels" msgpack:"cancels"`
}
// UsdClassTransferAction represents USD class transfer
type UsdClassTransferAction struct {
Type string `json:"type" msgpack:"type"`
Amount string `json:"amount" msgpack:"amount"`
ToPerp bool `json:"toPerp" msgpack:"toPerp"`
Nonce int64 `json:"nonce" msgpack:"nonce"`
}
// SpotTransferAction represents spot transfer
type SpotTransferAction struct {
Type string `json:"type" msgpack:"type"`
Destination string `json:"destination" msgpack:"destination"`
Amount string `json:"amount" msgpack:"amount"`
Token string `json:"token" msgpack:"token"`
Time int64 `json:"time" msgpack:"time"`
}
// UsdTransferAction represents USD transfer
type UsdTransferAction struct {
Type string `json:"type" msgpack:"type"`
Destination string `json:"destination" msgpack:"destination"`
Amount string `json:"amount" msgpack:"amount"`
Time int64 `json:"time" msgpack:"time"`
}
// SubAccountTransferAction represents sub-account transfer
type SubAccountTransferAction struct {
Type string `json:"type" msgpack:"type"`
SubAccountUser string `json:"subAccountUser" msgpack:"subAccountUser"`
IsDeposit bool `json:"isDeposit" msgpack:"isDeposit"`
Usd int `json:"usd" msgpack:"usd"`
}
// VaultUsdTransferAction represents vault USD transfer
type VaultUsdTransferAction struct {
Type string `json:"type" msgpack:"type"`
VaultAddress string `json:"vaultAddress" msgpack:"vaultAddress"`
IsDeposit bool `json:"isDeposit" msgpack:"isDeposit"`
Usd int `json:"usd" msgpack:"usd"`
}
// UpdateLeverageAction represents leverage update
type UpdateLeverageAction struct {
Type string `json:"type" msgpack:"type"`
Asset int `json:"asset" msgpack:"asset"`
Leverage map[string]any `json:"leverage" msgpack:"leverage"`
}
// UpdateIsolatedMarginAction represents isolated margin update
type UpdateIsolatedMarginAction struct {
Type string `json:"type" msgpack:"type"`
Asset int `json:"asset" msgpack:"asset"`
IsBuy bool `json:"isBuy" msgpack:"isBuy"`
Ntli float64 `json:"ntli" msgpack:"ntli"`
}
// OrderWire represents the wire format for orders with deterministic field ordering
type OrderWire struct {
Asset int `json:"a" msgpack:"a"`
IsBuy bool `json:"b" msgpack:"b"`
LimitPx string `json:"p" msgpack:"p"`
Size string `json:"s" msgpack:"s"`
ReduceOnly bool `json:"r" msgpack:"r"`
OrderType map[string]any `json:"t" msgpack:"t"`
Cloid *string `json:"c,omitempty" msgpack:"c,omitempty"`
}
// OrderAction represents the order action with deterministic field ordering
type OrderAction struct {
Type string `json:"type" msgpack:"type"`
Orders []OrderWire `json:"orders" msgpack:"orders"`
Grouping string `json:"grouping" msgpack:"grouping"`
Builder *BuilderInfo `json:"builder,omitempty" msgpack:"builder,omitempty"`
}
// ModifyAction represents a single order modification
type ModifyAction struct {
Type string `json:"type" msgpack:"type"`
Oid any `json:"oid" msgpack:"oid"`
Order OrderWire `json:"order" msgpack:"order"`
}
// BatchModifyAction represents multiple order modifications
type BatchModifyAction struct {
Type string `json:"type" msgpack:"type"`
Modifies []ModifyAction `json:"modifies" msgpack:"modifies"`
}
// PerpDexClassTransferAction represents perp dex class transfer
type PerpDexClassTransferAction struct {
Type string `json:"type" msgpack:"type"`
Dex string `json:"dex" msgpack:"dex"`
Token string `json:"token" msgpack:"token"`
Amount float64 `json:"amount" msgpack:"amount"`
ToPerp bool `json:"toPerp" msgpack:"toPerp"`
}
// SubAccountSpotTransferAction represents sub-account spot transfer
type SubAccountSpotTransferAction struct {
Type string `json:"type" msgpack:"type"`
SubAccountUser string `json:"subAccountUser" msgpack:"subAccountUser"`
IsDeposit bool `json:"isDeposit" msgpack:"isDeposit"`
Token string `json:"token" msgpack:"token"`
Amount float64 `json:"amount" msgpack:"amount"`
}
// ScheduleCancelAction represents schedule cancel action
type ScheduleCancelAction struct {
Type string `json:"type" msgpack:"type"`
Time *int64 `json:"time,omitempty" msgpack:"time,omitempty"`
}
// SetReferrerAction represents set referrer action
type SetReferrerAction struct {
Type string `json:"type" msgpack:"type"`
Code string `json:"code" msgpack:"code"`
}
// CreateSubAccountAction represents create sub-account action
type CreateSubAccountAction struct {
Type string `json:"type" msgpack:"type"`
Name string `json:"name" msgpack:"name"`
}
// UseBigBlocksAction represents use big blocks action
type UseBigBlocksAction struct {
Type string `json:"type" msgpack:"type"`
UsingBigBlocks bool `json:"usingBigBlocks" msgpack:"usingBigBlocks"`
}
// TokenDelegateAction represents token delegate action
type TokenDelegateAction struct {
Type string `json:"type" msgpack:"type"`
Validator string `json:"validator" msgpack:"validator"`
Wei int `json:"wei" msgpack:"wei"`
IsUndelegate bool `json:"isUndelegate" msgpack:"isUndelegate"`
Nonce int64 `json:"nonce" msgpack:"nonce"`
}
// WithdrawFromBridgeAction represents withdraw from bridge action
type WithdrawFromBridgeAction struct {
Type string `json:"type" msgpack:"type"`
Destination string `json:"destination" msgpack:"destination"`
Amount string `json:"amount" msgpack:"amount"`
Time int64 `json:"time" msgpack:"time"`
}
// ApproveAgentAction represents approve agent action
type ApproveAgentAction struct {
Type string `json:"type" msgpack:"type"`
AgentAddress string `json:"agentAddress" msgpack:"agentAddress"`
AgentName *string `json:"agentName,omitempty" msgpack:"agentName,omitempty"`
Nonce int64 `json:"nonce" msgpack:"nonce"`
}
// ApproveBuilderFeeAction represents approve builder fee action
type ApproveBuilderFeeAction struct {
Type string `json:"type" msgpack:"type"`
Builder string `json:"builder" msgpack:"builder"`
MaxFeeRate string `json:"maxFeeRate" msgpack:"maxFeeRate"`
Nonce int64 `json:"nonce" msgpack:"nonce"`
}
// ConvertToMultiSigUserAction represents convert to multi-sig user action
type ConvertToMultiSigUserAction struct {
Type string `json:"type" msgpack:"type"`
Signers string `json:"signers" msgpack:"signers"`
Nonce int64 `json:"nonce" msgpack:"nonce"`
}
// MultiSigAction represents multi-signature action
type MultiSigAction struct {
Type string `json:"type" msgpack:"type"`
Action map[string]any `json:"action" msgpack:"action"`
Signers []string `json:"signers" msgpack:"signers"`
Signatures []string `json:"signatures" msgpack:"signatures"`
}