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

13.67 Kb · 312 lines
  1package staker
  2
  3// StakeToken stakes a position NFT to earn rewards.
  4//
  5// Parameters:
  6//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
  7//   - positionId: LP position NFT token ID to stake.
  8//   - referrer: Optional referral address string used for referral tracking.
  9//
 10// Returns:
 11//   - string: Pool path where the position was staked.
 12//
 13// Halt check: reverts while the Staker halt scope is active.
 14func StakeToken(cur realm, positionId uint64, referrer string) string {
 15	return getImplementation().StakeToken(0, cur, positionId, referrer)
 16}
 17
 18// UnStakeToken unstakes a position NFT and creates an exit checkpoint for its rewards.
 19//
 20// The NFT is returned to its owner without calculating or paying rewards. Use a Collect* entry
 21// point afterward; collection of an exit checkpoint is permissionless and pays its pinned owner.
 22//
 23// Parameters:
 24//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
 25//   - positionId: LP position NFT token ID to unstake.
 26//
 27// Returns:
 28//   - string: Pool path where the position was staked.
 29//
 30// Halt check: reverts while the Withdraw halt scope is active.
 31func UnStakeToken(cur realm, positionId uint64) string {
 32	return getImplementation().UnStakeToken(0, cur, positionId)
 33}
 34
 35// CollectReward collects both the GNS emission and external incentive rewards for a live staked
 36// deposit or an exit checkpoint left by UnStakeToken.
 37//
 38// A live-deposit collect requires the depositor/owner. An exit-checkpoint collect is permissionless
 39// and pays the owner pinned in the checkpoint.
 40//
 41// Parameters:
 42//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
 43//   - positionId: Staked position NFT token ID or position with an exit checkpoint.
 44//
 45// Returns:
 46//   - string: GNS emission amount sent to the user.
 47//   - string: GNS emission penalty amount sent to the community pool.
 48//   - map[string]int64: Gross external reward amount per reward token, before the staking-reward fee.
 49//   - map[string]int64: External penalty amount per reward token.
 50//
 51// Halt check: reverts while the Withdraw halt scope is active.
 52func CollectReward(cur realm, positionId uint64) (string, string, map[string]int64, map[string]int64) {
 53	emissionToUser, emissionPenalty, externalRewards, externalPenalties := getImplementation().CollectReward(0, cur, positionId)
 54	return emissionToUser, emissionPenalty, cloneStringInt64Map(externalRewards), cloneStringInt64Map(externalPenalties)
 55}
 56
 57// CollectEmissionReward collects only the GNS emission reward for a live staked deposit or an exit
 58// checkpoint left by UnStakeToken.
 59//
 60// A live-deposit collect requires the depositor/owner. An exit-checkpoint collect is permissionless
 61// and pays the owner pinned in the checkpoint.
 62//
 63// External incentive rewards keep accruing; collect them with CollectExternalIncentiveReward.
 64//
 65// Parameters:
 66//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
 67//   - positionId: Staked position NFT token ID or position with an exit checkpoint.
 68//
 69// Returns:
 70//   - int64: GNS emission amount sent to the user.
 71//   - int64: GNS emission penalty amount sent to the community pool.
 72//
 73// Halt check: reverts while the Withdraw halt scope is active.
 74func CollectEmissionReward(cur realm, positionId uint64) (int64, int64) {
 75	return getImplementation().CollectEmissionReward(0, cur, positionId)
 76}
 77
 78// CollectExternalIncentiveReward collects one external incentive reward for a live staked deposit
 79// or an exit checkpoint left by UnStakeToken.
 80//
 81// A live-deposit collect requires the depositor/owner. An exit-checkpoint collect is permissionless
 82// and pays the owner pinned in the checkpoint.
 83//
 84// The GNS emission reward and every other incentive keep accruing; collect the emission reward with
 85// CollectEmissionReward and the other incentives by calling this with their own incentive id.
 86//
 87// Parameters:
 88//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
 89//   - positionId: Staked position NFT token ID or position with an exit checkpoint.
 90//   - incentiveId: External incentive identifier to collect.
 91//
 92// Returns:
 93//   - int64: Gross reward amount before the staking-reward fee.
 94//   - int64: Penalty amount retained by the incentive.
 95//
 96// Halt check: reverts while the Withdraw halt scope is active.
 97func CollectExternalIncentiveReward(cur realm, positionId uint64, incentiveId string) (int64, int64) {
 98	return getImplementation().CollectExternalIncentiveReward(0, cur, positionId, incentiveId)
 99}
100
101// SetPoolTier assigns a pool to an internal GNS emission reward tier.
102//
103// Parameters:
104//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
105//   - poolPath: Pool path whose emission tier is assigned.
106//   - tier: Target tier number from 0 through 3; zero removes the pool from emission targeting.
107//
108// Halt check: reverts while the Staker halt scope is active.
109func SetPoolTier(cur realm, poolPath string, tier uint64) {
110	getImplementation().SetPoolTier(0, cur, poolPath, tier)
111}
112
113// ChangePoolTier changes the internal GNS emission tier assigned to a pool.
114//
115// Parameters:
116//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
117//   - poolPath: Pool path whose emission tier is changed.
118//   - tier: New tier number from 0 through 3; zero means no internal-emission target.
119//
120// Halt check: reverts while the Staker halt scope is active.
121func ChangePoolTier(cur realm, poolPath string, tier uint64) {
122	getImplementation().ChangePoolTier(0, cur, poolPath, tier)
123}
124
125// RemovePoolTier removes a pool from the internal GNS emission tier system.
126//
127// Parameters:
128//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
129//   - poolPath: Pool path to remove from emission-tier membership.
130//
131// Halt check: reverts while the Staker halt scope is active.
132func RemovePoolTier(cur realm, poolPath string) {
133	getImplementation().RemovePoolTier(0, cur, poolPath)
134}
135
136// CreateExternalIncentive creates an external reward incentive for a pool.
137//
138// Parameters:
139//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
140//   - targetPoolPath: Pool path whose liquidity providers will receive the incentive.
141//   - rewardToken: Registered token path used to pay the incentive.
142//   - rewardAmount: Total reward amount deposited, in reward-token units.
143//   - startTimestamp: Incentive start time as an inclusive Unix timestamp.
144//   - endTimestamp: Incentive end time as an inclusive Unix timestamp.
145//
146// Any caller may create an incentive after satisfying the token, duration, start-time,
147// reward-minimum, and GNS-deposit checks.
148//
149// Halt check: reverts while the Staker halt scope is active.
150func CreateExternalIncentive(
151	cur realm,
152	targetPoolPath string,
153	rewardToken string,
154	rewardAmount int64,
155	startTimestamp int64,
156	endTimestamp int64,
157) {
158	getImplementation().CreateExternalIncentive(
159		0,
160		cur,
161		targetPoolPath,
162		rewardToken,
163		rewardAmount,
164		startTimestamp,
165		endTimestamp,
166	)
167}
168
169// EndExternalIncentive finalizes an external incentive once its end timestamp has passed,
170// sending the unclaimable/remainder reward portion and GNS deposit to the explicit refundAddress.
171// Only the incentive creator or admin may call it; an outstanding exit checkpoint for this
172// incentive must be collected or forfeited first.
173//
174// Parameters:
175//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
176//   - targetPoolPath: Pool path containing the incentive.
177//   - incentiveId: Unique incentive identifier to finalize.
178//   - refundAddress: Address receiving the refundable reward tokens and GNS deposit.
179//
180// Halt check: reverts while the Withdraw halt scope is active.
181func EndExternalIncentive(cur realm, targetPoolPath, incentiveId string, refundAddress address) {
182	getImplementation().EndExternalIncentive(0, cur, targetPoolPath, incentiveId, refundAddress)
183}
184
185// CancelExternalIncentive cancels an external incentive that has not started yet,
186// removing it and refunding the reward tokens and the GNS deposit to the creator.
187// Callable by admin, governance, or the incentive creator.
188//
189// Parameters:
190//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
191//   - targetPoolPath: Pool path containing the incentive.
192//   - incentiveId: Unique incentive identifier to cancel.
193//
194// Halt check: reverts while the Withdraw halt scope is active.
195func CancelExternalIncentive(cur realm, targetPoolPath, incentiveId string) {
196	getImplementation().CancelExternalIncentive(0, cur, targetPoolPath, incentiveId)
197}
198
199// CollectExternalIncentivePenalty collects accumulated warm-up penalties after
200// EndExternalIncentive has finalized the incentive, sending them to refundAddress.
201// Only the incentive creator or admin may call it.
202//
203// Parameters:
204//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
205//   - targetPoolPath: Pool path containing the incentive.
206//   - incentiveId: Unique incentive identifier whose penalty is collected.
207//   - refundAddress: Address receiving the collected penalty amount.
208//
209// Returns:
210//   - int64: Penalty amount transferred, capped by the staker's available reward-token balance.
211//
212// Halt check: reverts while the Withdraw halt scope is active.
213func CollectExternalIncentivePenalty(cur realm, targetPoolPath, incentiveId string, refundAddress address) int64 {
214	return getImplementation().CollectExternalIncentivePenalty(0, cur, targetPoolPath, incentiveId, refundAddress)
215}
216
217// AddToken adds a token to the reward token whitelist.
218//
219// Parameters:
220//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
221//   - tokenPath: Registered token path to add to the allowed reward-token list.
222//
223// Halt check: reverts while the Staker halt scope is active.
224func AddToken(cur realm, tokenPath string) {
225	getImplementation().AddToken(0, cur, tokenPath)
226}
227
228// RemoveToken removes a token from the reward token whitelist.
229//
230// Parameters:
231//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
232//   - tokenPath: Token path to remove from the allowed reward-token list.
233//
234// Halt check: reverts while the Staker halt scope is active.
235func RemoveToken(cur realm, tokenPath string) {
236	getImplementation().RemoveToken(0, cur, tokenPath)
237}
238
239// SetDeniedRewardToken sets or clears the operational deny flag for an external
240// incentive reward token. Pool-pair tokens qualify as reward tokens without the
241// governance allowlist (by design), so this flag is the only lever to stop NEW
242// incentives in a pair token whose issuer turned hostile. Existing incentives
243// and their collection are deliberately unaffected; the ledger-level delivery
244// guard in the implementation bounds their blast radius instead.
245//
246// Parameters:
247//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
248//   - tokenPath: Reward-token path whose deny status is changed.
249//   - denied: True to block new incentives for tokenPath; false to clear that block.
250//
251// Halt check: reverts while the Staker halt scope is active.
252func SetDeniedRewardToken(cur realm, tokenPath string, denied bool) {
253	getImplementation().SetDeniedRewardToken(0, cur, tokenPath, denied)
254}
255
256// SetWarmUp configures the duration for the warm-up tier selected by its fixed ratio.
257// Finite tiers are capped at 365 days; the final 100% tier must retain math.MaxInt64.
258//
259// Parameters:
260//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
261//   - pct: Warm-up payout percentage selecting one of the 30%, 50%, 70%, or 100% tiers.
262//   - timeDuration: Warm-up duration in Unix seconds for the selected percentage tier; finite tiers are capped at 365 days and the 100% tier uses math.MaxInt64.
263//
264// Halt check: reverts while the Staker halt scope is active.
265func SetWarmUp(cur realm, pct, timeDuration int64) {
266	getImplementation().SetWarmUp(0, cur, pct, timeDuration)
267}
268
269// SetDepositGnsAmount sets the GNS deposit required for each external incentive.
270//
271// Parameters:
272//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
273//   - amount: GNS amount required as the per-incentive deposit.
274//
275// Halt check: reverts while the Staker halt scope is active.
276func SetDepositGnsAmount(cur realm, amount int64) {
277	getImplementation().SetDepositGnsAmount(0, cur, amount)
278}
279
280// SetMinimumRewardAmount sets the default minimum reward amount required to create an external
281// incentive. A token-specific override may apply.
282//
283// Parameters:
284//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
285//   - amount: Default minimum reward amount, measured in the reward token's units.
286//
287// Halt check: reverts while the Staker halt scope is active.
288func SetMinimumRewardAmount(cur realm, amount int64) {
289	getImplementation().SetMinimumRewardAmount(0, cur, amount)
290}
291
292// SetTokenMinimumRewardAmount sets minimum reward amounts per token.
293//
294// Parameters:
295//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
296//   - paramsStr: Colon-delimited token path and minimum amount (`tokenPath:amount`); amount zero removes the override.
297//
298// Halt check: reverts while the Staker halt scope is active.
299func SetTokenMinimumRewardAmount(cur realm, paramsStr string) {
300	getImplementation().SetTokenMinimumRewardAmount(0, cur, paramsStr)
301}
302
303// SetUnStakingFee sets the unstaking fee rate in basis points (0-1,000; 100 = 1%).
304//
305// Parameters:
306//   - cur: Current realm context; callers use cross(cur) when crossing into this realm.
307//   - fee: Unstaking fee rate in basis points, from 0 through 1,000 inclusive.
308//
309// Halt check: reverts while the Staker halt scope is active.
310func SetUnStakingFee(cur realm, fee uint64) {
311	getImplementation().SetUnStakingFee(0, cur, fee)
312}