1type IProtocolFeeStore interface {
2 // HasDevOpsPctStoreKey reports whether the persisted DevOps percentage key exists.
3 //
4 // Returns:
5 // - exists: true when the DevOps percentage key is present in the KV store
6 HasDevOpsPctStoreKey() bool
7
8 // InitializeDevOpsPct creates the DevOps percentage key with its default value.
9 //
10 // Parameters:
11 // - _: cross-call discriminator; callers pass 0
12 // - rlm: propagated protocol_fee realm context required for the authorized store write
13 //
14 // Returns:
15 // - err: nil when initialization succeeds; an error for invalid realm context or KV-store failure
16 InitializeDevOpsPct(_ int, rlm realm) error
17
18 // GetDevOpsPct reads the persisted DevOps percentage.
19 //
20 // Returns:
21 // - pct: stored DevOps allocation in basis-point units
22 GetDevOpsPct() int64
23
24 // SetDevOpsPct persists a new DevOps percentage.
25 //
26 // Parameters:
27 // - _: cross-call discriminator; callers pass 0
28 // - rlm: propagated protocol_fee realm context required for the authorized store write
29 // - pct: DevOps allocation in basis-point units
30 //
31 // Returns:
32 // - err: nil when the value is stored; an error for invalid realm context or KV-store failure
33 SetDevOpsPct(_ int, rlm realm, pct int64) error
34
35 // HasAccuToGovStakerStoreKey reports whether the GovStaker allocation tree key exists.
36 //
37 // Returns:
38 // - exists: true when the cumulative GovStaker allocation tree is present in the KV store
39 HasAccuToGovStakerStoreKey() bool
40
41 // InitializeAccuToGovStaker creates the cumulative GovStaker allocation tree.
42 //
43 // Parameters:
44 // - _: cross-call discriminator; callers pass 0
45 // - rlm: propagated protocol_fee realm context required for the authorized store write
46 //
47 // Returns:
48 // - err: nil when initialization succeeds; an error for invalid realm context or KV-store failure
49 InitializeAccuToGovStaker(_ int, rlm realm) error
50
51 // GetAccuToGovStaker returns the tree of cumulative GovStaker allocations by token.
52 //
53 // Returns:
54 // - tree: persistent BPTree keyed by token path with int64 allocation values
55 GetAccuToGovStaker() *bptree.BPTree
56
57 // GetAccuToGovStakerItem reads one token's cumulative GovStaker allocation.
58 //
59 // Parameters:
60 // - tokenPath: token contract path used as the allocation-tree key
61 //
62 // Returns:
63 // - amount: stored allocation in token base units, or zero when tokenPath is absent
64 // - exists: true when tokenPath has a stored allocation; false when absent
65 GetAccuToGovStakerItem(tokenPath string) (int64, bool)
66
67 // SetAccuToGovStakerItem stores one token's cumulative GovStaker allocation.
68 //
69 // Parameters:
70 // - _: cross-call discriminator; callers pass 0
71 // - rlm: propagated protocol_fee realm context required for the authorized store write
72 // - tokenPath: token contract path used as the allocation-tree key
73 // - amount: cumulative GovStaker allocation in token base units to store
74 //
75 // Returns:
76 // - err: nil when the value is stored; an error for invalid realm context, missing tree, or KV-store failure
77 SetAccuToGovStakerItem(_ int, rlm realm, tokenPath string, amount int64) error
78
79 // HasAccuToDevOpsStoreKey reports whether the DevOps allocation tree key exists.
80 //
81 // Returns:
82 // - exists: true when the cumulative DevOps allocation tree is present in the KV store
83 HasAccuToDevOpsStoreKey() bool
84
85 // InitializeAccuToDevOps creates the cumulative DevOps allocation tree.
86 //
87 // Parameters:
88 // - _: cross-call discriminator; callers pass 0
89 // - rlm: propagated protocol_fee realm context required for the authorized store write
90 //
91 // Returns:
92 // - err: nil when initialization succeeds; an error for invalid realm context or KV-store failure
93 InitializeAccuToDevOps(_ int, rlm realm) error
94
95 // GetAccuToDevOps returns the tree of cumulative DevOps allocations by token.
96 //
97 // Returns:
98 // - tree: persistent BPTree keyed by token path with int64 allocation values
99 GetAccuToDevOps() *bptree.BPTree
100
101 // GetAccuToDevOpsItem reads one token's cumulative DevOps allocation.
102 //
103 // Parameters:
104 // - tokenPath: token contract path used as the allocation-tree key
105 //
106 // Returns:
107 // - amount: stored allocation in token base units, or zero when tokenPath is absent
108 // - exists: true when tokenPath has a stored allocation; false when absent
109 GetAccuToDevOpsItem(tokenPath string) (int64, bool)
110
111 // SetAccuToDevOpsItem stores one token's cumulative DevOps allocation.
112 //
113 // Parameters:
114 // - _: cross-call discriminator; callers pass 0
115 // - rlm: propagated protocol_fee realm context required for the authorized store write
116 // - tokenPath: token contract path used as the allocation-tree key
117 // - amount: cumulative DevOps allocation in token base units to store
118 //
119 // Returns:
120 // - err: nil when the value is stored; an error for invalid realm context, missing tree, or KV-store failure
121 SetAccuToDevOpsItem(_ int, rlm realm, tokenPath string, amount int64) error
122
123 // HasDistributedToGovStakerHistoryStoreKey reports whether the GovStaker history tree key exists.
124 //
125 // Returns:
126 // - exists: true when the cumulative GovStaker distribution-history tree is present
127 HasDistributedToGovStakerHistoryStoreKey() bool
128
129 // InitializeDistributedToGovStakerHistory creates the GovStaker distribution-history tree.
130 //
131 // Parameters:
132 // - _: cross-call discriminator; callers pass 0
133 // - rlm: propagated protocol_fee realm context required for the authorized store write
134 //
135 // Returns:
136 // - err: nil when initialization succeeds; an error for invalid realm context or KV-store failure
137 InitializeDistributedToGovStakerHistory(_ int, rlm realm) error
138
139 // GetDistributedToGovStakerHistory returns cumulative actual GovStaker transfers by token.
140 //
141 // Returns:
142 // - tree: persistent BPTree keyed by token path with int64 transferred amounts
143 GetDistributedToGovStakerHistory() *bptree.BPTree
144
145 // GetDistributedToGovStakerHistoryItem reads one token's actual GovStaker transfer.
146 //
147 // Parameters:
148 // - tokenPath: token contract path used as the history-tree key
149 //
150 // Returns:
151 // - amount: stored transferred amount in token base units, or zero when tokenPath is absent
152 // - exists: true when tokenPath has a stored history amount; false when absent
153 GetDistributedToGovStakerHistoryItem(tokenPath string) (int64, bool)
154
155 // SetDistributedToGovStakerHistoryItem stores one token's actual GovStaker transfer.
156 //
157 // Parameters:
158 // - _: cross-call discriminator; callers pass 0
159 // - rlm: propagated protocol_fee realm context required for the authorized store write
160 // - tokenPath: token contract path used as the history-tree key
161 // - amount: cumulative amount actually transferred to GovStaker in token base units
162 //
163 // Returns:
164 // - err: nil when the value is stored; an error for invalid realm context, missing tree, or KV-store failure
165 SetDistributedToGovStakerHistoryItem(_ int, rlm realm, tokenPath string, amount int64) error
166
167 // HasDistributedToDevOpsHistoryStoreKey reports whether the DevOps history tree key exists.
168 //
169 // Returns:
170 // - exists: true when the cumulative DevOps distribution-history tree is present
171 HasDistributedToDevOpsHistoryStoreKey() bool
172
173 // InitializeDistributedToDevOpsHistory creates the DevOps distribution-history tree.
174 //
175 // Parameters:
176 // - _: cross-call discriminator; callers pass 0
177 // - rlm: propagated protocol_fee realm context required for the authorized store write
178 //
179 // Returns:
180 // - err: nil when initialization succeeds; an error for invalid realm context or KV-store failure
181 InitializeDistributedToDevOpsHistory(_ int, rlm realm) error
182
183 // GetDistributedToDevOpsHistory returns cumulative actual DevOps transfers by token.
184 //
185 // Returns:
186 // - tree: persistent BPTree keyed by token path with int64 transferred amounts
187 GetDistributedToDevOpsHistory() *bptree.BPTree
188
189 // GetDistributedToDevOpsHistoryItem reads one token's actual DevOps transfer.
190 //
191 // Parameters:
192 // - tokenPath: token contract path used as the history-tree key
193 //
194 // Returns:
195 // - amount: stored transferred amount in token base units, or zero when tokenPath is absent
196 // - exists: true when tokenPath has a stored history amount; false when absent
197 GetDistributedToDevOpsHistoryItem(tokenPath string) (int64, bool)
198
199 // SetDistributedToDevOpsHistoryItem stores one token's actual DevOps transfer.
200 //
201 // Parameters:
202 // - _: cross-call discriminator; callers pass 0
203 // - rlm: propagated protocol_fee realm context required for the authorized store write
204 // - tokenPath: token contract path used as the history-tree key
205 // - amount: cumulative amount actually transferred to DevOps in token base units
206 //
207 // Returns:
208 // - err: nil when the value is stored; an error for invalid realm context, missing tree, or KV-store failure
209 SetDistributedToDevOpsHistoryItem(_ int, rlm realm, tokenPath string, amount int64) error
210
211 // HasReservedTokensStoreKey reports whether the reserved-token index key exists.
212 //
213 // Returns:
214 // - exists: true when the reserved-token index is present in the KV store
215 HasReservedTokensStoreKey() bool
216
217 // InitializeReservedTokens creates the empty reserved-token index.
218 //
219 // Parameters:
220 // - _: cross-call discriminator; callers pass 0
221 // - rlm: propagated protocol_fee realm context required for the authorized store write
222 //
223 // Returns:
224 // - err: nil when initialization succeeds; an error for invalid realm context or KV-store failure
225 InitializeReservedTokens(_ int, rlm realm) error
226
227 // GetReservedTokens returns token paths currently marked as awaiting distribution.
228 //
229 // Returns:
230 // - tokenPaths: keys in the reserved-token index
231 GetReservedTokens() []string
232
233 // HasReservedToken reports whether tokenPath is in the reserved-token index.
234 //
235 // Parameters:
236 // - tokenPath: token contract path to look up in the reserved-token index
237 //
238 // Returns:
239 // - exists: true when tokenPath is reserved for distribution
240 HasReservedToken(tokenPath string) bool
241
242 // AddReservedToken marks tokenPath as awaiting fee distribution.
243 //
244 // Parameters:
245 // - _: cross-call discriminator; callers pass 0
246 // - rlm: propagated protocol_fee realm context required for the authorized store write
247 // - tokenPath: token contract path to add to the reserved-token index
248 //
249 // Returns:
250 // - err: nil when added or already present; an error for invalid realm context or KV-store failure
251 AddReservedToken(_ int, rlm realm, tokenPath string) error
252
253 // RemoveReservedToken removes tokenPath from the reserved-token index when present.
254 //
255 // Parameters:
256 // - _: cross-call discriminator; callers pass 0
257 // - rlm: propagated protocol_fee realm context required for the authorized store write
258 // - tokenPath: token contract path to remove from the reserved-token index
259 //
260 // Returns:
261 // - err: nil when removed or already absent; an error for invalid realm context or KV-store failure
262 RemoveReservedToken(_ int, rlm realm, tokenPath string) error
263
264 // HasAccrualEpochStoreKey reports whether the accrual-epoch key exists.
265 //
266 // Returns:
267 // - exists: true when the current accrual epoch is present in the KV store
268 HasAccrualEpochStoreKey() bool
269
270 // InitializeAccrualEpoch creates the accrual-epoch key with epoch zero.
271 //
272 // Parameters:
273 // - _: cross-call discriminator; callers pass 0
274 // - rlm: propagated protocol_fee realm context required for the authorized store write
275 //
276 // Returns:
277 // - err: nil when initialization succeeds; an error for invalid realm context or KV-store failure
278 InitializeAccrualEpoch(_ int, rlm realm) error
279
280 // GetAccrualEpoch reads the epoch currently assigned to newly collected fees.
281 //
282 // Returns:
283 // - epoch: current non-negative accrual epoch
284 GetAccrualEpoch() int64
285
286 // SetAccrualEpoch persists a new current accrual epoch.
287 //
288 // Parameters:
289 // - _: cross-call discriminator; callers pass 0
290 // - rlm: propagated protocol_fee realm context required for the authorized store write
291 // - accrualEpoch: epoch number to store for subsequently collected fees
292 //
293 // Returns:
294 // - err: nil when the epoch is stored; an error for invalid realm context or KV-store failure
295 SetAccrualEpoch(_ int, rlm realm, accrualEpoch int64) error
296
297 // HasAccrualBucketsStoreKey reports whether the accrual-buckets tree key exists.
298 //
299 // Returns:
300 // - exists: true when the per-token accrual-bucket tree is present
301 HasAccrualBucketsStoreKey() bool
302
303 // InitializeAccrualBuckets creates the empty per-token accrual-bucket tree.
304 //
305 // Parameters:
306 // - _: cross-call discriminator; callers pass 0
307 // - rlm: propagated protocol_fee realm context required for the authorized store write
308 //
309 // Returns:
310 // - err: nil when initialization succeeds; an error for invalid realm context or KV-store failure
311 InitializeAccrualBuckets(_ int, rlm realm) error
312
313 // GetAccrualBuckets reads the oldest pending buckets for one token without removing them.
314 //
315 // Parameters:
316 // - tokenPath: token contract path whose accrual buckets are queried
317 // - limit: maximum number of oldest buckets; zero or negative returns all pending buckets
318 //
319 // Returns:
320 // - epochs: selected accrual epoch numbers in ascending order
321 // - amounts: bucket amounts corresponding positionally to epochs, in token base units
322 GetAccrualBuckets(tokenPath string, limit int) ([]int64, []int64)
323
324 // AddAccrualBucket adds amount to one token's bucket for an accrual epoch.
325 //
326 // Parameters:
327 // - _: cross-call discriminator; callers pass 0
328 // - rlm: propagated protocol_fee realm context required for the authorized store write
329 // - tokenPath: token contract path whose accrual bucket is updated
330 // - epoch: accrual epoch receiving the fee amount
331 // - amount: fee amount in token base units to add to that epoch bucket
332 //
333 // Returns:
334 // - err: nil when the bucket is stored; an error for invalid realm context or KV-store failure
335 AddAccrualBucket(_ int, rlm realm, tokenPath string, epoch int64, amount int64) error
336
337 // RemoveAccrualBuckets removes specified epoch buckets for one token.
338 //
339 // Parameters:
340 // - _: cross-call discriminator; callers pass 0
341 // - rlm: propagated protocol_fee realm context required for the authorized store write
342 // - tokenPath: token contract path whose buckets are removed
343 // - epochs: accrual epoch numbers to remove; an empty result removes no buckets
344 //
345 // Returns:
346 // - err: nil when removal succeeds; an error for invalid realm context or KV-store failure
347 RemoveAccrualBuckets(_ int, rlm realm, tokenPath string, epochs []int64) error
348
349 // HasAccrualPendingTokensStoreKey reports whether the pending-token index key exists.
350 //
351 // Returns:
352 // - exists: true when the index of tokens with pending buckets is present
353 HasAccrualPendingTokensStoreKey() bool
354
355 // InitializeAccrualPendingTokens creates the empty pending-token index.
356 //
357 // Parameters:
358 // - _: cross-call discriminator; callers pass 0
359 // - rlm: propagated protocol_fee realm context required for the authorized store write
360 //
361 // Returns:
362 // - err: nil when initialization succeeds; an error for invalid realm context or KV-store failure
363 InitializeAccrualPendingTokens(_ int, rlm realm) error
364
365 // GetAccrualPendingTokens returns token paths indexed as owning pending buckets.
366 //
367 // Returns:
368 // - tokenPaths: token contract paths present in the pending-token index
369 GetAccrualPendingTokens() []string
370
371 // AddAccrualPendingToken marks a token path as owning at least one pending bucket.
372 //
373 // Parameters:
374 // - _: cross-call discriminator; callers pass 0
375 // - rlm: propagated protocol_fee realm context required for the authorized store write
376 // - tokenPath: token contract path to add to the pending-token index
377 //
378 // Returns:
379 // - err: nil when added or already present; an error for invalid realm context or KV-store failure
380 AddAccrualPendingToken(_ int, rlm realm, tokenPath string) error
381
382 // RemoveAccrualPendingToken removes a token path from the pending-token index when present.
383 //
384 // Parameters:
385 // - _: cross-call discriminator; callers pass 0
386 // - rlm: propagated protocol_fee realm context required for the authorized store write
387 // - tokenPath: token contract path to remove after its pending buckets are consumed
388 //
389 // Returns:
390 // - err: nil when removed or already absent; an error for invalid realm context or KV-store failure
391 RemoveAccrualPendingToken(_ int, rlm realm, tokenPath string) error
392}