Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

proxy.gno

8.74 Kb · 223 lines
  1package protocol_fee
  2
  3// DistributeProtocolFee distributes accumulated protocol fees to DevOps and
  4// GovStaker, subject to the implementation's caller authorization and halt checks.
  5//
  6// Parameters:
  7//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
  8//
  9// Halt check: returns without distributing while the Withdraw halt scope is active.
 10func DistributeProtocolFee(cur realm) {
 11	getImplementation().DistributeProtocolFee(0, cur)
 12}
 13
 14// DistributeProtocolFeeByTokenPath distributes accumulated protocol fees reserved
 15// for one token path; an unreserved path has nothing to distribute.
 16//
 17// Parameters:
 18//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
 19//   - tokenPath: token contract path whose reserved fee balance should be distributed
 20//
 21// Halt check: returns without distributing while the Withdraw halt scope is active.
 22func DistributeProtocolFeeByTokenPath(cur realm, tokenPath string) {
 23	getImplementation().DistributeProtocolFeeByTokenPath(0, cur, tokenPath)
 24}
 25
 26// SetDevOpsPct sets the share of protocol fees allocated to DevOps.
 27//
 28// Parameters:
 29//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
 30//   - pct: DevOps allocation in basis-point units, from 0 through 10000 inclusive (10000 = 100%)
 31//
 32// Halt check: reverts while the ProtocolFee halt scope is active.
 33func SetDevOpsPct(cur realm, pct int64) {
 34	getImplementation().SetDevOpsPct(0, cur, pct)
 35}
 36
 37// SetGovStakerPct sets the share of protocol fees allocated to GovStaker.
 38//
 39// Parameters:
 40//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
 41//   - pct: GovStaker allocation in basis-point units, from 0 through 10000 inclusive (10000 = 100%)
 42//
 43// Halt check: reverts while the ProtocolFee halt scope is active.
 44func SetGovStakerPct(cur realm, pct int64) {
 45	getImplementation().SetGovStakerPct(0, cur, pct)
 46}
 47
 48// AddToProtocolFee pulls an approved fee amount from an authorized protocol caller
 49// into protocol-fee accounting. Authorized callers are pool, position, router,
 50// and staker realms; direct transfers to this address do not register a fee.
 51//
 52// Parameters:
 53//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
 54//   - tokenPath: token contract path whose fee is being collected
 55//   - amount: non-negative fee amount in the token's base units; zero performs no transfer
 56//
 57// Returns:
 58//   - err: nil on success; errSpoofedRealm for a spoofed-realm call; errProtocolFeeHalted when protocol-fee collection is halted
 59//
 60// Halt check: returns errProtocolFeeHalted without transferring while the ProtocolFee halt scope is active.
 61func AddToProtocolFee(cur realm, tokenPath string, amount int64) error {
 62	return getImplementation().AddToProtocolFee(0, cur, tokenPath, amount)
 63}
 64
 65// AdvanceAccrualEpoch closes the current accrual epoch and returns the new one. Fees
 66// arriving from now on are bucketed under the returned epoch. Only gov/staker may call
 67// it, on every stake change.
 68//
 69// Parameters:
 70//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
 71//
 72// Returns:
 73//   - epoch: newly active non-negative accrual epoch used for subsequently collected GovStaker fees
 74func AdvanceAccrualEpoch(cur realm) int64 {
 75	return getImplementation().AdvanceAccrualEpoch(0, cur)
 76}
 77
 78// ConsumeAccrualBuckets returns and clears up to limit of the oldest pending buckets
 79// of tokenPath as parallel epoch and amount slices. A limit of zero or less consumes
 80// every pending bucket. Only gov/staker may call it.
 81//
 82// Parameters:
 83//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
 84//   - tokenPath: token contract path whose pending GovStaker accrual buckets are consumed
 85//   - limit: maximum number of oldest buckets to consume; zero or negative consumes all pending buckets
 86//
 87// Returns:
 88//   - epochs: consumed accrual epoch numbers in ascending epoch order
 89//   - amounts: GovStaker fee amounts corresponding positionally to epochs, in token base units
 90func ConsumeAccrualBuckets(cur realm, tokenPath string, limit int) ([]int64, []int64) {
 91	return getImplementation().ConsumeAccrualBuckets(0, cur, tokenPath, limit)
 92}
 93
 94// GetDevOpsPct returns the DevOps fee allocation in basis-point units.
 95//
 96// Returns:
 97//   - pct: configured DevOps allocation from 0 through 10000 (10000 = 100%)
 98func GetDevOpsPct() int64 {
 99	return getImplementation().GetDevOpsPct()
100}
101
102// GetGovStakerPct returns the GovStaker fee allocation in basis-point units.
103//
104// Returns:
105//   - pct: configured GovStaker allocation from 0 through 10000 (10000 = 100%)
106func GetGovStakerPct() int64 {
107	return getImplementation().GetGovStakerPct()
108}
109
110// GetAccrualEpoch returns the accrual epoch fees are currently bucketed under.
111//
112// Returns:
113//   - epoch: current non-negative accrual epoch assigned to newly collected GovStaker fees
114func GetAccrualEpoch() int64 {
115	return getImplementation().GetAccrualEpoch()
116}
117
118// GetAccrualPendingTokens returns the token paths that still own pending accrual buckets.
119//
120// Returns:
121//   - tokenPaths: token contract paths with at least one pending GovStaker accrual bucket
122func GetAccrualPendingTokens() []string {
123	return cloneStringSlice(getImplementation().GetAccrualPendingTokens())
124}
125
126// GetAccrualBuckets returns up to limit of the oldest pending buckets of tokenPath
127// without clearing them. A limit of zero or less returns every pending bucket.
128//
129// Parameters:
130//   - tokenPath: token contract path whose pending GovStaker accrual buckets are queried
131//   - limit: maximum number of oldest buckets to return; zero or negative returns all pending buckets
132//
133// Returns:
134//   - epochs: selected accrual epoch numbers in ascending epoch order
135//   - amounts: GovStaker fee amounts corresponding positionally to epochs, in token base units
136func GetAccrualBuckets(tokenPath string, limit int) ([]int64, []int64) {
137	epochs, amounts := getImplementation().GetAccrualBuckets(tokenPath, limit)
138	return cloneInt64Slice(epochs), cloneInt64Slice(amounts)
139}
140
141// GetReservedTokens returns token paths reserved for distribution.
142//
143// Returns:
144//   - tokenPaths: token paths reserved for distribution
145func GetReservedTokens() []string {
146	return cloneStringSlice(getImplementation().GetReservedTokens())
147}
148
149// GetAccuTransfersToGovStaker returns accumulated transfers to GovStaker.
150//
151// Returns:
152//   - transfers: map of token paths to accumulated amounts
153func GetAccuTransfersToGovStaker() map[string]int64 {
154	return cloneStringInt64Map(getImplementation().GetAccuTransfersToGovStaker())
155}
156
157// GetAccuTransfersToDevOps returns accumulated transfers to DevOps.
158//
159// Returns:
160//   - transfers: map of token paths to accumulated amounts
161func GetAccuTransfersToDevOps() map[string]int64 {
162	return cloneStringInt64Map(getImplementation().GetAccuTransfersToDevOps())
163}
164
165// GetAccuTransferToGovStakerByTokenPath returns accumulated GovStaker transfer for a token.
166//
167// Parameters:
168//   - tokenPath: path of the token
169//
170// Returns:
171//   - amount: accumulated transfer amount
172func GetAccuTransferToGovStakerByTokenPath(tokenPath string) int64 {
173	return getImplementation().GetAccuTransferToGovStakerByTokenPath(tokenPath)
174}
175
176// GetAccuTransferToDevOpsByTokenPath returns accumulated DevOps transfer for a token.
177//
178// Parameters:
179//   - tokenPath: path of the token
180//
181// Returns:
182//   - amount: accumulated transfer amount
183func GetAccuTransferToDevOpsByTokenPath(tokenPath string) int64 {
184	return getImplementation().GetAccuTransferToDevOpsByTokenPath(tokenPath)
185}
186
187// GetActualDistributedToGovStaker returns actual transfers completed to GovStaker.
188//
189// Returns:
190//   - transfers: map of token paths to actual distributed amounts
191func GetActualDistributedToGovStaker() map[string]int64 {
192	return cloneStringInt64Map(getImplementation().GetActualDistributedToGovStaker())
193}
194
195// GetActualDistributedToDevOps returns actual transfers completed to DevOps.
196//
197// Returns:
198//   - transfers: map of token paths to actual distributed amounts
199func GetActualDistributedToDevOps() map[string]int64 {
200	return cloneStringInt64Map(getImplementation().GetActualDistributedToDevOps())
201}
202
203// GetActualDistributedToGovStakerByTokenPath returns actual GovStaker transfer for a token.
204//
205// Parameters:
206//   - tokenPath: path of the token
207//
208// Returns:
209//   - amount: actual distributed amount for the token
210func GetActualDistributedToGovStakerByTokenPath(tokenPath string) int64 {
211	return getImplementation().GetActualDistributedToGovStakerByTokenPath(tokenPath)
212}
213
214// GetActualDistributedToDevOpsByTokenPath returns actual DevOps transfer for a token.
215//
216// Parameters:
217//   - tokenPath: path of the token
218//
219// Returns:
220//   - amount: actual distributed amount for the token
221func GetActualDistributedToDevOpsByTokenPath(tokenPath string) int64 {
222	return getImplementation().GetActualDistributedToDevOpsByTokenPath(tokenPath)
223}