-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemClobKeeper.go
417 lines (342 loc) · 14.4 KB
/
MemClobKeeper.go
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
// Code generated by mockery v2.26.1. DO NOT EDIT.
package mocks
import (
big "math/big"
indexer_manager "github.com/jinxprotocol/v4-chain/protocol/indexer/indexer_manager"
clobtypes "github.com/jinxprotocol/v4-chain/protocol/x/clob/types"
log "github.com/cometbft/cometbft/libs/log"
mock "github.com/stretchr/testify/mock"
subaccountstypes "github.com/jinxprotocol/v4-chain/protocol/x/subaccounts/types"
time "time"
types "github.com/cosmos/cosmos-sdk/types"
)
// MemClobKeeper is an autogenerated mock type for the MemClobKeeper type
type MemClobKeeper struct {
mock.Mock
}
// AddOrderToOrderbookCollatCheck provides a mock function with given fields: ctx, clobPairId, subaccountOpenOrders
func (_m *MemClobKeeper) AddOrderToOrderbookCollatCheck(ctx types.Context, clobPairId clobtypes.ClobPairId, subaccountOpenOrders map[subaccountstypes.SubaccountId][]clobtypes.PendingOpenOrder) (bool, map[subaccountstypes.SubaccountId]subaccountstypes.UpdateResult) {
ret := _m.Called(ctx, clobPairId, subaccountOpenOrders)
var r0 bool
var r1 map[subaccountstypes.SubaccountId]subaccountstypes.UpdateResult
if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPairId, map[subaccountstypes.SubaccountId][]clobtypes.PendingOpenOrder) (bool, map[subaccountstypes.SubaccountId]subaccountstypes.UpdateResult)); ok {
return rf(ctx, clobPairId, subaccountOpenOrders)
}
if rf, ok := ret.Get(0).(func(types.Context, clobtypes.ClobPairId, map[subaccountstypes.SubaccountId][]clobtypes.PendingOpenOrder) bool); ok {
r0 = rf(ctx, clobPairId, subaccountOpenOrders)
} else {
r0 = ret.Get(0).(bool)
}
if rf, ok := ret.Get(1).(func(types.Context, clobtypes.ClobPairId, map[subaccountstypes.SubaccountId][]clobtypes.PendingOpenOrder) map[subaccountstypes.SubaccountId]subaccountstypes.UpdateResult); ok {
r1 = rf(ctx, clobPairId, subaccountOpenOrders)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(map[subaccountstypes.SubaccountId]subaccountstypes.UpdateResult)
}
}
return r0, r1
}
// AddPreexistingStatefulOrder provides a mock function with given fields: ctx, order, memclob
func (_m *MemClobKeeper) AddPreexistingStatefulOrder(ctx types.Context, order *clobtypes.Order, memclob clobtypes.MemClob) (subaccountstypes.BaseQuantums, clobtypes.OrderStatus, *clobtypes.OffchainUpdates, error) {
ret := _m.Called(ctx, order, memclob)
var r0 subaccountstypes.BaseQuantums
var r1 clobtypes.OrderStatus
var r2 *clobtypes.OffchainUpdates
var r3 error
if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.Order, clobtypes.MemClob) (subaccountstypes.BaseQuantums, clobtypes.OrderStatus, *clobtypes.OffchainUpdates, error)); ok {
return rf(ctx, order, memclob)
}
if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.Order, clobtypes.MemClob) subaccountstypes.BaseQuantums); ok {
r0 = rf(ctx, order, memclob)
} else {
r0 = ret.Get(0).(subaccountstypes.BaseQuantums)
}
if rf, ok := ret.Get(1).(func(types.Context, *clobtypes.Order, clobtypes.MemClob) clobtypes.OrderStatus); ok {
r1 = rf(ctx, order, memclob)
} else {
r1 = ret.Get(1).(clobtypes.OrderStatus)
}
if rf, ok := ret.Get(2).(func(types.Context, *clobtypes.Order, clobtypes.MemClob) *clobtypes.OffchainUpdates); ok {
r2 = rf(ctx, order, memclob)
} else {
if ret.Get(2) != nil {
r2 = ret.Get(2).(*clobtypes.OffchainUpdates)
}
}
if rf, ok := ret.Get(3).(func(types.Context, *clobtypes.Order, clobtypes.MemClob) error); ok {
r3 = rf(ctx, order, memclob)
} else {
r3 = ret.Error(3)
}
return r0, r1, r2, r3
}
// CanDeleverageSubaccount provides a mock function with given fields: ctx, subaccountId, perpetualId
func (_m *MemClobKeeper) CanDeleverageSubaccount(ctx types.Context, subaccountId subaccountstypes.SubaccountId, perpetualId uint32) (bool, bool, error) {
ret := _m.Called(ctx, subaccountId, perpetualId)
var r0 bool
var r1 bool
var r2 error
if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, uint32) (bool, bool, error)); ok {
return rf(ctx, subaccountId, perpetualId)
}
if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, uint32) bool); ok {
r0 = rf(ctx, subaccountId, perpetualId)
} else {
r0 = ret.Get(0).(bool)
}
if rf, ok := ret.Get(1).(func(types.Context, subaccountstypes.SubaccountId, uint32) bool); ok {
r1 = rf(ctx, subaccountId, perpetualId)
} else {
r1 = ret.Get(1).(bool)
}
if rf, ok := ret.Get(2).(func(types.Context, subaccountstypes.SubaccountId, uint32) error); ok {
r2 = rf(ctx, subaccountId, perpetualId)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// CancelShortTermOrder provides a mock function with given fields: ctx, msgCancelOrder
func (_m *MemClobKeeper) CancelShortTermOrder(ctx types.Context, msgCancelOrder *clobtypes.MsgCancelOrder) error {
ret := _m.Called(ctx, msgCancelOrder)
var r0 error
if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MsgCancelOrder) error); ok {
r0 = rf(ctx, msgCancelOrder)
} else {
r0 = ret.Error(0)
}
return r0
}
// GetIndexerEventManager provides a mock function with given fields:
func (_m *MemClobKeeper) GetIndexerEventManager() indexer_manager.IndexerEventManager {
ret := _m.Called()
var r0 indexer_manager.IndexerEventManager
if rf, ok := ret.Get(0).(func() indexer_manager.IndexerEventManager); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(indexer_manager.IndexerEventManager)
}
}
return r0
}
// GetLongTermOrderPlacement provides a mock function with given fields: ctx, orderId
func (_m *MemClobKeeper) GetLongTermOrderPlacement(ctx types.Context, orderId clobtypes.OrderId) (clobtypes.LongTermOrderPlacement, bool) {
ret := _m.Called(ctx, orderId)
var r0 clobtypes.LongTermOrderPlacement
var r1 bool
if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) (clobtypes.LongTermOrderPlacement, bool)); ok {
return rf(ctx, orderId)
}
if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) clobtypes.LongTermOrderPlacement); ok {
r0 = rf(ctx, orderId)
} else {
r0 = ret.Get(0).(clobtypes.LongTermOrderPlacement)
}
if rf, ok := ret.Get(1).(func(types.Context, clobtypes.OrderId) bool); ok {
r1 = rf(ctx, orderId)
} else {
r1 = ret.Get(1).(bool)
}
return r0, r1
}
// GetOrderFillAmount provides a mock function with given fields: ctx, orderId
func (_m *MemClobKeeper) GetOrderFillAmount(ctx types.Context, orderId clobtypes.OrderId) (bool, subaccountstypes.BaseQuantums, uint32) {
ret := _m.Called(ctx, orderId)
var r0 bool
var r1 subaccountstypes.BaseQuantums
var r2 uint32
if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) (bool, subaccountstypes.BaseQuantums, uint32)); ok {
return rf(ctx, orderId)
}
if rf, ok := ret.Get(0).(func(types.Context, clobtypes.OrderId) bool); ok {
r0 = rf(ctx, orderId)
} else {
r0 = ret.Get(0).(bool)
}
if rf, ok := ret.Get(1).(func(types.Context, clobtypes.OrderId) subaccountstypes.BaseQuantums); ok {
r1 = rf(ctx, orderId)
} else {
r1 = ret.Get(1).(subaccountstypes.BaseQuantums)
}
if rf, ok := ret.Get(2).(func(types.Context, clobtypes.OrderId) uint32); ok {
r2 = rf(ctx, orderId)
} else {
r2 = ret.Get(2).(uint32)
}
return r0, r1, r2
}
// GetStatePosition provides a mock function with given fields: ctx, subaccountId, clobPairId
func (_m *MemClobKeeper) GetStatePosition(ctx types.Context, subaccountId subaccountstypes.SubaccountId, clobPairId clobtypes.ClobPairId) *big.Int {
ret := _m.Called(ctx, subaccountId, clobPairId)
var r0 *big.Int
if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, clobtypes.ClobPairId) *big.Int); ok {
r0 = rf(ctx, subaccountId, clobPairId)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*big.Int)
}
}
return r0
}
// IsLiquidatable provides a mock function with given fields: ctx, subaccountId
func (_m *MemClobKeeper) IsLiquidatable(ctx types.Context, subaccountId subaccountstypes.SubaccountId) (bool, error) {
ret := _m.Called(ctx, subaccountId)
var r0 bool
var r1 error
if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId) (bool, error)); ok {
return rf(ctx, subaccountId)
}
if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId) bool); ok {
r0 = rf(ctx, subaccountId)
} else {
r0 = ret.Get(0).(bool)
}
if rf, ok := ret.Get(1).(func(types.Context, subaccountstypes.SubaccountId) error); ok {
r1 = rf(ctx, subaccountId)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Logger provides a mock function with given fields: ctx
func (_m *MemClobKeeper) Logger(ctx types.Context) log.Logger {
ret := _m.Called(ctx)
var r0 log.Logger
if rf, ok := ret.Get(0).(func(types.Context) log.Logger); ok {
r0 = rf(ctx)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(log.Logger)
}
}
return r0
}
// MustAddOrderToStatefulOrdersTimeSlice provides a mock function with given fields: ctx, goodTilBlockTime, orderId
func (_m *MemClobKeeper) MustAddOrderToStatefulOrdersTimeSlice(ctx types.Context, goodTilBlockTime time.Time, orderId clobtypes.OrderId) {
_m.Called(ctx, goodTilBlockTime, orderId)
}
// OffsetSubaccountPerpetualPosition provides a mock function with given fields: ctx, liquidatedSubaccountId, perpetualId, deltaQuantumsTotal, isFinalSettlement
func (_m *MemClobKeeper) OffsetSubaccountPerpetualPosition(ctx types.Context, liquidatedSubaccountId subaccountstypes.SubaccountId, perpetualId uint32, deltaQuantumsTotal *big.Int, isFinalSettlement bool) ([]clobtypes.MatchPerpetualDeleveraging_Fill, *big.Int) {
ret := _m.Called(ctx, liquidatedSubaccountId, perpetualId, deltaQuantumsTotal, isFinalSettlement)
var r0 []clobtypes.MatchPerpetualDeleveraging_Fill
var r1 *big.Int
if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, uint32, *big.Int, bool) ([]clobtypes.MatchPerpetualDeleveraging_Fill, *big.Int)); ok {
return rf(ctx, liquidatedSubaccountId, perpetualId, deltaQuantumsTotal, isFinalSettlement)
}
if rf, ok := ret.Get(0).(func(types.Context, subaccountstypes.SubaccountId, uint32, *big.Int, bool) []clobtypes.MatchPerpetualDeleveraging_Fill); ok {
r0 = rf(ctx, liquidatedSubaccountId, perpetualId, deltaQuantumsTotal, isFinalSettlement)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]clobtypes.MatchPerpetualDeleveraging_Fill)
}
}
if rf, ok := ret.Get(1).(func(types.Context, subaccountstypes.SubaccountId, uint32, *big.Int, bool) *big.Int); ok {
r1 = rf(ctx, liquidatedSubaccountId, perpetualId, deltaQuantumsTotal, isFinalSettlement)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*big.Int)
}
}
return r0, r1
}
// ProcessSingleMatch provides a mock function with given fields: ctx, matchWithOrders
func (_m *MemClobKeeper) ProcessSingleMatch(ctx types.Context, matchWithOrders *clobtypes.MatchWithOrders) (bool, subaccountstypes.UpdateResult, subaccountstypes.UpdateResult, *clobtypes.OffchainUpdates, error) {
ret := _m.Called(ctx, matchWithOrders)
var r0 bool
var r1 subaccountstypes.UpdateResult
var r2 subaccountstypes.UpdateResult
var r3 *clobtypes.OffchainUpdates
var r4 error
if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MatchWithOrders) (bool, subaccountstypes.UpdateResult, subaccountstypes.UpdateResult, *clobtypes.OffchainUpdates, error)); ok {
return rf(ctx, matchWithOrders)
}
if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MatchWithOrders) bool); ok {
r0 = rf(ctx, matchWithOrders)
} else {
r0 = ret.Get(0).(bool)
}
if rf, ok := ret.Get(1).(func(types.Context, *clobtypes.MatchWithOrders) subaccountstypes.UpdateResult); ok {
r1 = rf(ctx, matchWithOrders)
} else {
r1 = ret.Get(1).(subaccountstypes.UpdateResult)
}
if rf, ok := ret.Get(2).(func(types.Context, *clobtypes.MatchWithOrders) subaccountstypes.UpdateResult); ok {
r2 = rf(ctx, matchWithOrders)
} else {
r2 = ret.Get(2).(subaccountstypes.UpdateResult)
}
if rf, ok := ret.Get(3).(func(types.Context, *clobtypes.MatchWithOrders) *clobtypes.OffchainUpdates); ok {
r3 = rf(ctx, matchWithOrders)
} else {
if ret.Get(3) != nil {
r3 = ret.Get(3).(*clobtypes.OffchainUpdates)
}
}
if rf, ok := ret.Get(4).(func(types.Context, *clobtypes.MatchWithOrders) error); ok {
r4 = rf(ctx, matchWithOrders)
} else {
r4 = ret.Error(4)
}
return r0, r1, r2, r3, r4
}
// ReplayPlaceOrder provides a mock function with given fields: ctx, msg
func (_m *MemClobKeeper) ReplayPlaceOrder(ctx types.Context, msg *clobtypes.MsgPlaceOrder) (subaccountstypes.BaseQuantums, clobtypes.OrderStatus, *clobtypes.OffchainUpdates, error) {
ret := _m.Called(ctx, msg)
var r0 subaccountstypes.BaseQuantums
var r1 clobtypes.OrderStatus
var r2 *clobtypes.OffchainUpdates
var r3 error
if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MsgPlaceOrder) (subaccountstypes.BaseQuantums, clobtypes.OrderStatus, *clobtypes.OffchainUpdates, error)); ok {
return rf(ctx, msg)
}
if rf, ok := ret.Get(0).(func(types.Context, *clobtypes.MsgPlaceOrder) subaccountstypes.BaseQuantums); ok {
r0 = rf(ctx, msg)
} else {
r0 = ret.Get(0).(subaccountstypes.BaseQuantums)
}
if rf, ok := ret.Get(1).(func(types.Context, *clobtypes.MsgPlaceOrder) clobtypes.OrderStatus); ok {
r1 = rf(ctx, msg)
} else {
r1 = ret.Get(1).(clobtypes.OrderStatus)
}
if rf, ok := ret.Get(2).(func(types.Context, *clobtypes.MsgPlaceOrder) *clobtypes.OffchainUpdates); ok {
r2 = rf(ctx, msg)
} else {
if ret.Get(2) != nil {
r2 = ret.Get(2).(*clobtypes.OffchainUpdates)
}
}
if rf, ok := ret.Get(3).(func(types.Context, *clobtypes.MsgPlaceOrder) error); ok {
r3 = rf(ctx, msg)
} else {
r3 = ret.Error(3)
}
return r0, r1, r2, r3
}
// SetLongTermOrderPlacement provides a mock function with given fields: ctx, order, blockHeight
func (_m *MemClobKeeper) SetLongTermOrderPlacement(ctx types.Context, order clobtypes.Order, blockHeight uint32) {
_m.Called(ctx, order, blockHeight)
}
// ValidateSubaccountEquityTierLimitForNewOrder provides a mock function with given fields: ctx, order
func (_m *MemClobKeeper) ValidateSubaccountEquityTierLimitForNewOrder(ctx types.Context, order clobtypes.Order) error {
ret := _m.Called(ctx, order)
var r0 error
if rf, ok := ret.Get(0).(func(types.Context, clobtypes.Order) error); ok {
r0 = rf(ctx, order)
} else {
r0 = ret.Error(0)
}
return r0
}
type mockConstructorTestingTNewMemClobKeeper interface {
mock.TestingT
Cleanup(func())
}
// NewMemClobKeeper creates a new instance of MemClobKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewMemClobKeeper(t mockConstructorTestingTNewMemClobKeeper) *MemClobKeeper {
mock := &MemClobKeeper{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}