This repository has been archived by the owner on Nov 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
whale.go
74 lines (59 loc) · 1.54 KB
/
whale.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
package services
import (
"fmt"
"time"
"github.com/everstake/teztracker/models"
)
const minAmountForLargeTransfer = 3e11
func (t *TezTracker) GetWhaleTransfers(limits Limiter, period string) (transfers []models.Operation, err error) {
timeSince := time.Time{}
tt := time.Now()
var cycle int64
switch period {
case "C":
block, err := t.repoProvider.GetBlock().Last()
if err != nil {
return transfers, err
}
cycle = block.MetaCycle
case "D":
timeSince = tt.AddDate(0, 0, -1)
case "W":
timeSince = tt.AddDate(0, 0, -7)
case "M":
timeSince = tt.AddDate(0, -1, 0)
default:
return transfers, fmt.Errorf("wrong period")
}
transfers, err = t.repoProvider.GetOperation().LargeTransfers(minAmountForLargeTransfer, cycle, limits.Limit(), limits.Offset(), timeSince)
if err != nil {
return transfers, err
}
return transfers, nil
}
func (t *TezTracker) LargestSources(limits Limiter, period, side string) (source []models.Account, err error) {
timeSince := time.Time{}
tt := time.Now()
var cycle int64
switch period {
case "C":
block, err := t.repoProvider.GetBlock().Last()
if err != nil {
return source, err
}
cycle = block.MetaCycle
case "D":
timeSince = tt.AddDate(0, 0, -1)
case "W":
timeSince = tt.AddDate(0, 0, -7)
case "M":
timeSince = tt.AddDate(0, -1, 0)
default:
return source, fmt.Errorf("wrong period")
}
source, err = t.repoProvider.GetOperation().LargestSources(cycle, limits.Limit(), limits.Offset(), timeSince, side == "sender")
if err != nil {
return source, err
}
return source, nil
}