/
liquidity.go
590 lines (477 loc) · 15.3 KB
/
liquidity.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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
//nolint:revive,golint,stylecheck
package swap
import (
"github.com/ethereum/go-ethereum/common"
ethTypes "github.com/ethereum/go-ethereum/core/types"
"github.com/synapsecns/sanguine/core"
"github.com/synapsecns/sanguine/services/explorer/types/swap"
"math/big"
)
// GetRaw gets the raw event logs from the redeem and remove event.
func (s SwapFlashLoanAddLiquidity) GetRaw() ethTypes.Log {
return s.Raw
}
// GetTxHash gets the unique identifier (txhash) for the withdraw.
func (s SwapFlashLoanAddLiquidity) GetTxHash() common.Hash {
return s.Raw.TxHash
}
// GetBlockNumber gets the block number for the event.
func (s SwapFlashLoanAddLiquidity) GetBlockNumber() uint64 {
return s.Raw.BlockNumber
}
// GetContractAddress gets the contract address the event occurred on.
func (s SwapFlashLoanAddLiquidity) GetContractAddress() common.Address {
return s.Raw.Address
}
// GetEventType gets the type of the redeem event.
func (s SwapFlashLoanAddLiquidity) GetEventType() swap.EventType {
return swap.AddLiquidityEvent
}
// GetInvariant gets the invariant of the swap.
func (s SwapFlashLoanAddLiquidity) GetInvariant() *big.Int {
return core.CopyBigInt(s.Invariant)
}
// GetProvider gets the provider.
func (s SwapFlashLoanAddLiquidity) GetProvider() *common.Address {
return &s.Provider
}
// GetAmount gets the token amounts.
func (s SwapFlashLoanAddLiquidity) GetAmount() map[uint8]string {
tokenAmounts := make(map[uint8]string)
zero := big.NewInt(0)
for i, tokenAmount := range s.TokenAmounts {
if tokenAmount.Cmp(zero) == 1 {
tokenAmounts[uint8(i)] = core.CopyBigInt(tokenAmount).String()
}
}
return tokenAmounts
}
// GetAmountFee gets the fees.
func (s SwapFlashLoanAddLiquidity) GetAmountFee() map[uint8]string {
feeAmounts := make(map[uint8]string)
zero := big.NewInt(0)
for i, feeAmount := range s.Fees {
if feeAmount.Cmp(zero) == 1 {
feeAmounts[uint8(i)] = core.CopyBigInt(feeAmount).String()
}
}
return feeAmounts
}
// GetLPTokenSupply gets the LP token supply.
func (s SwapFlashLoanAddLiquidity) GetLPTokenSupply() *big.Int {
return core.CopyBigInt(s.LpTokenSupply)
}
// GetBoughtID gets the bought id.
func (s SwapFlashLoanAddLiquidity) GetBoughtID() *big.Int {
return nil
}
// GetSoldID gets the solid id.
func (s SwapFlashLoanAddLiquidity) GetSoldID() *big.Int {
return nil
}
// GetLPTokenAmount gets the LP token supply.
func (s SwapFlashLoanAddLiquidity) GetLPTokenAmount() *big.Int {
return nil
}
// GetTokensBought gets the amount of tokens bought.
func (s SwapFlashLoanAddLiquidity) GetTokensBought() *big.Int {
return nil
}
// GetProtocolFee gets the protocol fee of the tx.
func (s SwapFlashLoanAddLiquidity) GetProtocolFee() *big.Int {
return nil
}
// GetBuyer gets the buyer.
func (s SwapFlashLoanAddLiquidity) GetBuyer() *common.Address {
return nil
}
// GetNewAdminFee gets the new admin fee.
func (s SwapFlashLoanAddLiquidity) GetNewAdminFee() *big.Int {
return nil
}
// GetNewSwapFee gets the new swap fee.
func (s SwapFlashLoanAddLiquidity) GetNewSwapFee() *big.Int {
return nil
}
// GetTokensSold gets the tokens sold.
func (s SwapFlashLoanAddLiquidity) GetTokensSold() *big.Int {
return nil
}
// GetInitialTime gets the initial time.
func (s SwapFlashLoanAddLiquidity) GetInitialTime() *big.Int {
return nil
}
// GetFutureTime gets the future time.
func (s SwapFlashLoanAddLiquidity) GetFutureTime() *big.Int {
return nil
}
// GetOldA gets the old A.
func (s SwapFlashLoanAddLiquidity) GetOldA() *big.Int {
return nil
}
// GetNewA gets the new A.
func (s SwapFlashLoanAddLiquidity) GetNewA() *big.Int {
return nil
}
// GetCurrentA gets the current A.
func (s SwapFlashLoanAddLiquidity) GetCurrentA() *big.Int {
return nil
}
// GetTime gets the current time.
func (s SwapFlashLoanAddLiquidity) GetTime() *big.Int {
return nil
}
// GetReceiver gets the receiver.
func (s SwapFlashLoanAddLiquidity) GetReceiver() *common.Address {
return nil
}
func (s SwapFlashLoanAddLiquidity) GetEventIndex() uint64 {
return uint64(s.Raw.Index)
}
var _ swap.EventLog = &SwapFlashLoanAddLiquidity{}
// GetRaw gets the raw event logs from the redeem and remove event.
func (s SwapFlashLoanRemoveLiquidity) GetRaw() ethTypes.Log {
return s.Raw
}
// GetTxHash gets the unique identifier (txhash) for the withdraw.
func (s SwapFlashLoanRemoveLiquidity) GetTxHash() common.Hash {
return s.Raw.TxHash
}
// GetBlockNumber gets the block number for the event.
func (s SwapFlashLoanRemoveLiquidity) GetBlockNumber() uint64 {
return s.Raw.BlockNumber
}
// GetContractAddress gets the contract address the event occurred on.
func (s SwapFlashLoanRemoveLiquidity) GetContractAddress() common.Address {
return s.Raw.Address
}
// GetEventType gets the type of the redeem event.
func (s SwapFlashLoanRemoveLiquidity) GetEventType() swap.EventType {
return swap.RemoveLiquidityEvent
}
// GetProvider gets the Provider of the swap.
func (s SwapFlashLoanRemoveLiquidity) GetProvider() *common.Address {
return &s.Provider
}
// GetAmount gets the token amounts.
func (s SwapFlashLoanRemoveLiquidity) GetAmount() map[uint8]string {
tokenAmounts := make(map[uint8]string)
zero := big.NewInt(0)
for i, tokenAmount := range s.TokenAmounts {
if tokenAmount.Cmp(zero) == 1 {
tokenAmounts[uint8(i)] = core.CopyBigInt(tokenAmount).String()
}
}
return tokenAmounts
}
// GetAmountFee gets the fees.
func (s SwapFlashLoanRemoveLiquidity) GetAmountFee() map[uint8]string {
return map[uint8]string{}
}
// GetLPTokenSupply gets the LP token supply.
func (s SwapFlashLoanRemoveLiquidity) GetLPTokenSupply() *big.Int {
return s.LpTokenSupply
}
// GetBoughtID gets the bought id.
func (s SwapFlashLoanRemoveLiquidity) GetBoughtID() *big.Int {
return nil
}
// GetSoldID gets the solid id.
func (s SwapFlashLoanRemoveLiquidity) GetSoldID() *big.Int {
return nil
}
// GetLPTokenAmount gets the LP token supply.
func (s SwapFlashLoanRemoveLiquidity) GetLPTokenAmount() *big.Int {
return nil
}
// GetTokensBought gets the amount of tokens bought.
func (s SwapFlashLoanRemoveLiquidity) GetTokensBought() *big.Int {
return nil
}
// GetInvariant gets the invariant.
func (s SwapFlashLoanRemoveLiquidity) GetInvariant() *big.Int {
return nil
}
// GetProtocolFee gets the protocol fee of the tx.
func (s SwapFlashLoanRemoveLiquidity) GetProtocolFee() *big.Int {
return nil
}
// GetBuyer gets the buyer.
func (s SwapFlashLoanRemoveLiquidity) GetBuyer() *common.Address {
return nil
}
// GetNewAdminFee gets the new admin fee.
func (s SwapFlashLoanRemoveLiquidity) GetNewAdminFee() *big.Int {
return nil
}
// GetNewSwapFee gets the new swap fee.
func (s SwapFlashLoanRemoveLiquidity) GetNewSwapFee() *big.Int {
return nil
}
// GetTokensSold gets the tokens sold.
func (s SwapFlashLoanRemoveLiquidity) GetTokensSold() *big.Int {
return nil
}
// GetInitialTime gets the initial time.
func (s SwapFlashLoanRemoveLiquidity) GetInitialTime() *big.Int {
return nil
}
// GetFutureTime gets the future time.
func (s SwapFlashLoanRemoveLiquidity) GetFutureTime() *big.Int {
return nil
}
// GetOldA gets the old A.
func (s SwapFlashLoanRemoveLiquidity) GetOldA() *big.Int {
return nil
}
// GetNewA gets the new A.
func (s SwapFlashLoanRemoveLiquidity) GetNewA() *big.Int {
return nil
}
// GetCurrentA gets the current A.
func (s SwapFlashLoanRemoveLiquidity) GetCurrentA() *big.Int {
return nil
}
// GetTime gets the current time.
func (s SwapFlashLoanRemoveLiquidity) GetTime() *big.Int {
return nil
}
// GetReceiver gets the receiver.
func (s SwapFlashLoanRemoveLiquidity) GetReceiver() *common.Address {
return nil
}
func (s SwapFlashLoanRemoveLiquidity) GetEventIndex() uint64 {
return uint64(s.Raw.Index)
}
var _ swap.EventLog = &SwapFlashLoanRemoveLiquidity{}
// GetRaw gets the raw event logs from the redeem and remove event.
func (s SwapFlashLoanRemoveLiquidityOne) GetRaw() ethTypes.Log {
return s.Raw
}
// GetTxHash gets the unique identifier (txhash) for the withdraw.
func (s SwapFlashLoanRemoveLiquidityOne) GetTxHash() common.Hash {
return s.Raw.TxHash
}
// GetBlockNumber gets the block number for the event.
func (s SwapFlashLoanRemoveLiquidityOne) GetBlockNumber() uint64 {
return s.Raw.BlockNumber
}
// GetContractAddress gets the contract address the event occurred on.
func (s SwapFlashLoanRemoveLiquidityOne) GetContractAddress() common.Address {
return s.Raw.Address
}
// GetEventType gets the type of the redeem event.
func (s SwapFlashLoanRemoveLiquidityOne) GetEventType() swap.EventType {
return swap.RemoveLiquidityOneEvent
}
// GetProvider gets the Provider of the swap.
func (s SwapFlashLoanRemoveLiquidityOne) GetProvider() *common.Address {
return &s.Provider
}
// GetLPTokenAmount gets the LP Token Amount.
func (s SwapFlashLoanRemoveLiquidityOne) GetLPTokenAmount() *big.Int {
return core.CopyBigInt(s.LpTokenAmount)
}
// GetLPTokenSupply gets the LP Token Supply.
func (s SwapFlashLoanRemoveLiquidityOne) GetLPTokenSupply() *big.Int {
return core.CopyBigInt(s.LpTokenSupply)
}
// GetBoughtID gets the bought id.
func (s SwapFlashLoanRemoveLiquidityOne) GetBoughtID() *big.Int {
return core.CopyBigInt(s.BoughtId)
}
// GetTokensBought gets the tokens bought.
func (s SwapFlashLoanRemoveLiquidityOne) GetTokensBought() *big.Int {
return core.CopyBigInt(s.TokensBought)
}
// GetAmount puts the amount in a map with its associated token index.
func (s SwapFlashLoanRemoveLiquidityOne) GetAmount() map[uint8]string {
output := map[uint8]string{uint8(s.BoughtId.Int64()): core.CopyBigInt(s.TokensBought).String()}
return output
}
// GetSoldID gets the solid id.
func (s SwapFlashLoanRemoveLiquidityOne) GetSoldID() *big.Int {
return nil
}
// GetAmountFee gets the amount.
func (s SwapFlashLoanRemoveLiquidityOne) GetAmountFee() map[uint8]string {
return map[uint8]string{}
}
// GetProtocolFee gets the protocol fee of the tx.
func (s SwapFlashLoanRemoveLiquidityOne) GetProtocolFee() *big.Int {
return nil
}
// GetBuyer gets the buyer.
func (s SwapFlashLoanRemoveLiquidityOne) GetBuyer() *common.Address {
return nil
}
// GetInvariant gets the invariant.
func (s SwapFlashLoanRemoveLiquidityOne) GetInvariant() *big.Int {
return nil
}
// GetNewAdminFee gets the new admin fee.
func (s SwapFlashLoanRemoveLiquidityOne) GetNewAdminFee() *big.Int {
return nil
}
// GetNewSwapFee gets the new swap fee.
func (s SwapFlashLoanRemoveLiquidityOne) GetNewSwapFee() *big.Int {
return nil
}
// GetTokensSold gets the tokens sold.
func (s SwapFlashLoanRemoveLiquidityOne) GetTokensSold() *big.Int {
return nil
}
// GetInitialTime gets the initial time.
func (s SwapFlashLoanRemoveLiquidityOne) GetInitialTime() *big.Int {
return nil
}
// GetFutureTime gets the future time.
func (s SwapFlashLoanRemoveLiquidityOne) GetFutureTime() *big.Int {
return nil
}
// GetOldA gets the old A.
func (s SwapFlashLoanRemoveLiquidityOne) GetOldA() *big.Int {
return nil
}
// GetNewA gets the new A.
func (s SwapFlashLoanRemoveLiquidityOne) GetNewA() *big.Int {
return nil
}
// GetCurrentA gets the current A.
func (s SwapFlashLoanRemoveLiquidityOne) GetCurrentA() *big.Int {
return nil
}
// GetTime gets the current time.
func (s SwapFlashLoanRemoveLiquidityOne) GetTime() *big.Int {
return nil
}
// GetReceiver gets the receiver.
func (s SwapFlashLoanRemoveLiquidityOne) GetReceiver() *common.Address {
return nil
}
func (s SwapFlashLoanRemoveLiquidityOne) GetEventIndex() uint64 {
return uint64(s.Raw.Index)
}
var _ swap.EventLog = &SwapFlashLoanRemoveLiquidityOne{}
// GetRaw gets the raw event logs from the redeem and remove event.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetRaw() ethTypes.Log {
return s.Raw
}
// GetTxHash gets the unique identifier (txhash) for the withdraw.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetTxHash() common.Hash {
return s.Raw.TxHash
}
// GetBlockNumber gets the block number for the event.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetBlockNumber() uint64 {
return s.Raw.BlockNumber
}
// GetContractAddress gets the contract address the event occurred on.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetContractAddress() common.Address {
return s.Raw.Address
}
// GetEventType gets the type of the redeem event.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetEventType() swap.EventType {
return swap.RemoveLiquidityImbalanceEvent
}
// GetProvider gets the Provider of the swap.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetProvider() *common.Address {
return &s.Provider
}
// GetAmount gets the token amounts.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetAmount() map[uint8]string {
tokenAmounts := make(map[uint8]string)
zero := big.NewInt(0)
for i, tokenAmount := range s.TokenAmounts {
if tokenAmount.Cmp(zero) == 1 {
tokenAmounts[uint8(i)] = core.CopyBigInt(tokenAmount).String()
}
}
return tokenAmounts
}
// GetAmountFee gets the fees.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetAmountFee() map[uint8]string {
feeAmounts := make(map[uint8]string)
zero := big.NewInt(0)
for i, feeAmount := range s.Fees {
if feeAmount.Cmp(zero) == 1 {
feeAmounts[uint8(i)] = core.CopyBigInt(feeAmount).String()
}
}
return feeAmounts
}
// GetInvariant gets the invariant.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetInvariant() *big.Int {
return core.CopyBigInt(s.Invariant)
}
// GetLPTokenSupply gets the lp token supply.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetLPTokenSupply() *big.Int {
return core.CopyBigInt(s.LpTokenSupply)
}
// GetSoldID gets the solid id.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetSoldID() *big.Int {
return nil
}
// GetProtocolFee gets the protocol fee of the tx.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetProtocolFee() *big.Int {
return nil
}
// GetBuyer gets the buyer.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetBuyer() *common.Address {
return nil
}
// GetNewAdminFee gets the new admin fee.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetNewAdminFee() *big.Int {
return nil
}
// GetNewSwapFee gets the new swap fee.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetNewSwapFee() *big.Int {
return nil
}
// GetTokensSold gets the tokens sold.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetTokensSold() *big.Int {
return nil
}
// GetInitialTime gets the initial time.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetInitialTime() *big.Int {
return nil
}
// GetFutureTime gets the future time.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetFutureTime() *big.Int {
return nil
}
// GetOldA gets the old A.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetOldA() *big.Int {
return nil
}
// GetLPTokenAmount gets the LP token supply.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetLPTokenAmount() *big.Int {
return nil
}
// GetNewA gets the new A.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetNewA() *big.Int {
return nil
}
// GetCurrentA gets the current A.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetCurrentA() *big.Int {
return nil
}
// GetTime gets the current time.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetTime() *big.Int {
return nil
}
// GetBoughtID gets the bought id.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetBoughtID() *big.Int {
return nil
}
// GetTokensBought gets the amount of tokens bought.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetTokensBought() *big.Int {
return nil
}
// GetReceiver gets the receiver.
func (s SwapFlashLoanRemoveLiquidityImbalance) GetReceiver() *common.Address {
return nil
}
func (s SwapFlashLoanRemoveLiquidityImbalance) GetEventIndex() uint64 {
return uint64(s.Raw.Index)
}
var _ swap.EventLog = &SwapFlashLoanRemoveLiquidityImbalance{}