getter.gno
6.32 Kb · 179 lines
1package protocol_fee
2
3// GetDevOpsPct returns the percentage allocated to devOps.
4//
5// Returns:
6// - pct: DevOps' protocol-fee allocation percentage in basis points (0 through 10000).
7func (pf *protocolFeeV1) GetDevOpsPct() int64 {
8 return pf.getProtocolFeeState().DevOpsPct()
9}
10
11// GetGovStakerPct returns the percentage allocated to gov/staker.
12//
13// Returns:
14// - pct: Gov/Staker's protocol-fee allocation percentage in basis points, computed as 10000 minus the stored DevOps percentage.
15func (pf *protocolFeeV1) GetGovStakerPct() int64 {
16 return pf.getProtocolFeeState().GovStakerPct()
17}
18
19// GetReservedTokens returns token paths reserved for distribution.
20//
21// Returns:
22// - tokenPaths: Token paths currently reserved for protocol-fee distribution.
23func (pf *protocolFeeV1) GetReservedTokens() []string {
24 return pf.getProtocolFeeState().ReservedTokens()
25}
26
27// GetAccrualEpoch returns the accrual epoch fees are currently bucketed under.
28//
29// Returns:
30// - epoch: Current accrual epoch under which newly collected Gov/Staker amounts are bucketed.
31func (pf *protocolFeeV1) GetAccrualEpoch() int64 {
32 return pf.getProtocolFeeState().store.GetAccrualEpoch()
33}
34
35// GetAccrualPendingTokens returns the token paths that still own pending accrual buckets.
36//
37// Returns:
38// - tokenPaths: Token paths that still have one or more pending Gov/Staker accrual buckets.
39func (pf *protocolFeeV1) GetAccrualPendingTokens() []string {
40 return pf.getProtocolFeeState().store.GetAccrualPendingTokens()
41}
42
43// GetAccrualBuckets returns up to limit of the oldest pending buckets of tokenPath
44// without clearing them. A limit of zero or less returns every pending bucket.
45//
46// Parameters:
47// - tokenPath: Token path whose pending Gov/Staker accrual buckets should be read.
48// - limit: Maximum number of buckets to return; zero or a negative value returns all pending buckets.
49//
50// Returns:
51// - epochs: Epoch numbers for the returned buckets in ascending epoch order.
52// - amounts: Gov/Staker amounts for the returned epochs; amounts[i] corresponds to epochs[i].
53func (pf *protocolFeeV1) GetAccrualBuckets(tokenPath string, limit int) ([]int64, []int64) {
54 return pf.getProtocolFeeState().store.GetAccrualBuckets(tokenPath, limit)
55}
56
57// GetAccuTransfersToGovStaker returns all accumulated transfers to gov/staker.
58//
59// Returns:
60// - transfers: Snapshot map from token path to cumulative amount allocated to Gov/Staker, including amounts still pending distribution.
61func (pf *protocolFeeV1) GetAccuTransfersToGovStaker() map[string]int64 {
62 accuTransfers := make(map[string]int64)
63
64 pf.getProtocolFeeState().AccuToGovStaker().Iterate("", "", func(key string, value any) bool {
65 amount, ok := value.(int64)
66 if !ok {
67 return false
68 }
69
70 accuTransfers[key] = amount
71 return false
72 })
73
74 return accuTransfers
75}
76
77// GetAccuTransfersToDevOps returns all accumulated transfers to devOps.
78//
79// Returns:
80// - transfers: Snapshot map from token path to cumulative amount allocated to DevOps, including amounts still pending distribution.
81func (pf *protocolFeeV1) GetAccuTransfersToDevOps() map[string]int64 {
82 accuTransfers := make(map[string]int64)
83
84 pf.getProtocolFeeState().AccuToDevOps().Iterate("", "", func(key string, value any) bool {
85 amount, ok := value.(int64)
86 if !ok {
87 return false
88 }
89
90 accuTransfers[key] = amount
91 return false
92 })
93
94 return accuTransfers
95}
96
97// GetAccuTransferToGovStakerByTokenPath returns the accumulated transfer to gov/staker by token path.
98//
99// Parameters:
100// - path: Token path whose cumulative Gov/Staker allocation should be read.
101//
102// Returns:
103// - amount: Cumulative Gov/Staker amount allocated for path, or zero when no allocation is recorded.
104func (pf *protocolFeeV1) GetAccuTransferToGovStakerByTokenPath(path string) int64 {
105 return pf.getProtocolFeeState().GetAccuTransferToGovStakerByTokenPath(path)
106}
107
108// GetAccuTransferToDevOpsByTokenPath returns the accumulated transfer to devOps by token path.
109//
110// Parameters:
111// - path: Token path whose cumulative DevOps allocation should be read.
112//
113// Returns:
114// - amount: Cumulative DevOps amount allocated for path, or zero when no allocation is recorded.
115func (pf *protocolFeeV1) GetAccuTransferToDevOpsByTokenPath(path string) int64 {
116 return pf.getProtocolFeeState().GetAccuTransferToDevOpsByTokenPath(path)
117}
118
119// GetActualDistributedToGovStaker returns all actual transfers to gov/staker.
120//
121// Returns:
122// - transfers: Snapshot map from token path to cumulative amount actually distributed to Gov/Staker.
123func (pf *protocolFeeV1) GetActualDistributedToGovStaker() map[string]int64 {
124 actualDistributed := make(map[string]int64)
125
126 pf.getProtocolFeeState().ActualDistributedToGovStaker().Iterate("", "", func(key string, value any) bool {
127 amount, ok := value.(int64)
128 if !ok {
129 return false
130 }
131
132 actualDistributed[key] = amount
133 return false
134 })
135
136 return actualDistributed
137}
138
139// GetActualDistributedToDevOps returns all actual transfers to devOps.
140//
141// Returns:
142// - transfers: Snapshot map from token path to cumulative amount actually distributed to DevOps.
143func (pf *protocolFeeV1) GetActualDistributedToDevOps() map[string]int64 {
144 actualDistributed := make(map[string]int64)
145
146 pf.getProtocolFeeState().ActualDistributedToDevOps().Iterate("", "", func(key string, value any) bool {
147 amount, ok := value.(int64)
148 if !ok {
149 return false
150 }
151
152 actualDistributed[key] = amount
153 return false
154 })
155
156 return actualDistributed
157}
158
159// GetActualDistributedToGovStakerByTokenPath returns the actual transfer to gov/staker by token path.
160//
161// Parameters:
162// - path: Token path whose cumulative actual Gov/Staker distribution should be read.
163//
164// Returns:
165// - amount: Cumulative amount actually distributed to Gov/Staker for path, or zero when no history is recorded.
166func (pf *protocolFeeV1) GetActualDistributedToGovStakerByTokenPath(path string) int64 {
167 return pf.getProtocolFeeState().GetActualDistributedToGovStakerByTokenPath(path)
168}
169
170// GetActualDistributedToDevOpsByTokenPath returns the actual transfer to devOps by token path.
171//
172// Parameters:
173// - path: Token path whose cumulative actual DevOps distribution should be read.
174//
175// Returns:
176// - amount: Cumulative amount actually distributed to DevOps for path, or zero when no history is recorded.
177func (pf *protocolFeeV1) GetActualDistributedToDevOpsByTokenPath(path string) int64 {
178 return pf.getProtocolFeeState().GetActualDistributedToDevOpsByTokenPath(path)
179}