getter.gno
2.31 Kb ยท 72 lines
1package emission
2
3// GetLeftGNSAmount returns the amount of undistributed GNS tokens from previous distributions.
4func GetLeftGNSAmount() int64 {
5 return leftGNSAmount
6}
7
8// GetDistributionStartTimestamp returns the timestamp when emission distribution started.
9// Returns 0 if distribution has not been started yet.
10func GetDistributionStartTimestamp() int64 {
11 return distributionStartTimestamp
12}
13
14// GetLastExecutedTimestamp returns the timestamp of the last emission distribution execution.
15func GetLastExecutedTimestamp() int64 {
16 return lastExecutedTimestamp
17}
18
19// GetAllDistributionBpsPct returns all distribution percentages in basis points.
20func GetAllDistributionBpsPct() map[int]int64 {
21 result := make(map[int]int64, len(distributionBpsPct))
22 if distributionBpsPct == nil {
23 return result
24 }
25
26 for target, pct := range distributionBpsPct {
27 result[target] = pct
28 }
29
30 return result
31}
32
33// GetTotalAccuDistributed returns the total accumulated distributed GNS amount.
34func GetTotalAccuDistributed() int64 {
35 return safeAddInt64(
36 safeAddInt64(accuDistributedToStaker, accuDistributedToDevOps),
37 safeAddInt64(accuDistributedToCommunityPool, accuDistributedToGovStaker),
38 )
39}
40
41// GetTotalDistributed returns the total pending distributed GNS amount.
42func GetTotalDistributed() int64 {
43 return safeAddInt64(
44 safeAddInt64(distributedToStaker, distributedToDevOps),
45 safeAddInt64(distributedToCommunityPool, distributedToGovStaker),
46 )
47}
48
49// GetDistributionEndTimestamp returns the timestamp when emission distribution ends.
50// Returns 0 if distribution has not been started yet.
51func GetDistributionEndTimestamp() int64 {
52 if distributionStartTimestamp == 0 {
53 return 0
54 }
55
56 return safeAddInt64(distributionStartTimestamp, totalDistributionDuration-1)
57}
58
59// GetDistributableAmount returns distribution amounts by target and the remainder.
60// If timestamp is outside the distribution window, it returns an empty map and the full amount as left.
61func GetDistributableAmount(amount, timestamp int64) (map[int]int64, int64) {
62 if distributionStartTimestamp == 0 || timestamp < distributionStartTimestamp {
63 return make(map[int]int64), amount
64 }
65
66 endTimestamp := GetDistributionEndTimestamp()
67 if endTimestamp != 0 && timestamp > endTimestamp {
68 return make(map[int]int64), amount
69 }
70
71 return calculateDistributableAmounts(amount, distributionBpsPct)
72}