Kind Realm (renderable)
Name launchpad
Namespace gnoswap
Exported functions 71
Module gno.land/r/gnoswap/launchpad
gno 0.9 reward_manager.gno gno
⧉
1 package launchpad 2 3 import ( 4 bptree "gno.land/p/nt/bptree/v0" 5 6 u256 "gno.land/p/gnoswap/uint256/v1" 7 ) 8 CollectDepositGns (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, depositID string) (int64, interface {Error func() string})
CollectEmissionReward (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string})
CollectProtocolFee (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string})
CollectProtocolFeeReward (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, tokenPath string)
CollectRewardByDepositId (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, depositID string) int64
CreateProject (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, name string, tokenPath string, recipient string, depositAmount int64, conditionTokens string, conditionAmounts string, tier30Ratio int64, tier90Ratio int64, tier180Ratio int64, startTime int64) string
DefaultDeposit () struct{depositor .uverse.address; id string; projectID string; tier int64; depositAmount int64; withdrawnHeight int64; withdrawnTime int64; createdHeight int64; createdAt int64; endTime int64}
DepositGns (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, targetProjectTierID string, depositAmount int64, referrer string) string
GetCurrentDepositId () int64
GetDeposit (depositId string) (struct{depositor .uverse.address; id string; projectID string; tier int64; depositAmount int64; withdrawnHeight int64; withdrawnTime int64; createdHeight int64; createdAt int64; endTime int64}, interface {Error func() string})
GetDepositAmount (depositId string) (int64, interface {Error func() string})
GetDepositCount () int
GetDepositCreatedAt (depositId string) (int64, interface {Error func() string})
GetDepositCreatedHeight (depositId string) (int64, interface {Error func() string})
GetDepositEndTime (depositId string) (int64, interface {Error func() string})
GetDepositProjectID (depositId string) (string, interface {Error func() string})
GetDepositProjectTierID (depositId string) (string, interface {Error func() string})
GetDepositTier (depositId string) (int64, interface {Error func() string})
GetDepositWithdrawnHeight (depositId string) (int64, interface {Error func() string})
GetDepositWithdrawnTime (depositId string) (int64, interface {Error func() string})
GetImplementationPackagePath () string
GetProjectActiveStatus (projectId string) (bool, interface {Error func() string})
GetProjectCondition (projectId string, tokenPath string) (*gno.land/r/gnoswap/launchpad.ProjectCondition, interface {Error func() string})
GetProjectCreatedAt (projectId string) (int64, interface {Error func() string})
GetProjectCreatedHeight (projectId string) (int64, interface {Error func() string})
GetProjectDepositAmount (projectId string) (int64, interface {Error func() string})
GetProjectName (projectId string) (string, interface {Error func() string})
GetProjectRecipient (projectId string) (string, interface {Error func() string})
GetProjects () *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree
GetProjectTier (projectId string, tier int64) (*gno.land/r/gnoswap/launchpad.ProjectTier, interface {Error func() string})
GetProjectTierDistributeAmountPerSecondX128 (projectId string, tier int64) (*gno.land/p/gnoswap/uint256/v1.Uint, interface {Error func() string})
GetProjectTierEndTime (projectId string, tier int64) (int64, interface {Error func() string})
GetProjectTierRewardAccumulatedDistributeAmount (projectTierId string) (int64, interface {Error func() string})
GetProjectTierRewardAccumulatedRewardPerDepositX128 (projectTierId string) (*gno.land/p/gnoswap/uint256/v1.Uint, interface {Error func() string})
GetProjectTierRewardAccumulatedTime (projectTierId string) (int64, interface {Error func() string})
GetProjectTierRewardClaimableDuration (projectTierId string) (int64, interface {Error func() string})
GetProjectTierRewardDistributeAmountPerSecondX128 (projectTierId string) (*gno.land/p/gnoswap/uint256/v1.Uint, interface {Error func() string})
GetProjectTierRewardDistributeEndTime (projectTierId string) (int64, interface {Error func() string})
GetProjectTierRewardDistributeStartTime (projectTierId string) (int64, interface {Error func() string})
GetProjectTierRewardManager (projectTierId string) (*gno.land/r/gnoswap/launchpad.RewardManager, interface {Error func() string})
GetProjectTierRewardManagerCount () int
GetProjectTierRewards (projectId string, tier int64) *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree
GetProjectTierRewardTotalClaimedAmount (projectTierId string) (int64, interface {Error func() string})
GetProjectTierRewardTotalDistributeAmount (projectTierId string) (int64, interface {Error func() string})
GetProjectTiersRatios (projectId string) (map[int64]int64, interface {Error func() string})
GetProjectTierStartTime (projectId string, tier int64) (int64, interface {Error func() string})
GetProjectTierTotalCollectedAmount (projectId string, tier int64) (int64, interface {Error func() string})
GetProjectTierTotalDepositAmount (projectId string, tier int64) (int64, interface {Error func() string})
GetProjectTierTotalDepositCount (projectId string, tier int64) (int64, interface {Error func() string})
GetProjectTierTotalDistributeAmount (projectId string, tier int64) (int64, interface {Error func() string})
GetProjectTierTotalWithdrawAmount (projectId string, tier int64) (int64, interface {Error func() string})
GetProjectTierTotalWithdrawCount (projectId string, tier int64) (int64, interface {Error func() string})
GetProjectTokenPath (projectId string) (string, interface {Error func() string})
GetRewardState (projectTierId string, depositId string) (*gno.land/r/gnoswap/launchpad.RewardState, interface {Error func() string})
GetTotalGNSStakedAmount () int64
MakeDeposit (depositID string, projectID string, tier int64, depositor string, depositAmount int64, createdHeight int64, createdTime int64, endTime int64) struct{depositor .uverse.address; id string; projectID string; tier int64; depositAmount int64; withdrawnHeight int64; withdrawnTime int64; createdHeight int64; createdAt int64; endTime int64}
MakeProjectID (tokenPath string, createdHeight int64) string
MakeProjectTierID (projectID string, duration int64) string
NewBPTreeN (fanout int) *gno.land/p/nt/bptree/v0.BPTree
NewCounter () *gno.land/r/gnoswap/launchpad.Counter
NewLaunchpadStore (kvStore interface {AddAuthorizedCaller func(int, .uverse.realm, .uverse.address, gno.land/p/gnoswap/store/v1.Permission) .uverse.error; Delete func(int, .uverse.realm, string) .uverse.error; Get func(string) (interface {}, .uverse.error); GetAddress func(string) (.uverse.address, .uverse.error); GetAllKeys func() ([]string, .uverse.error); GetAuthorizedCallers func() (map[.uverse.address]gno.land/p/gnoswap/store/v1.Permission, .uverse.error); GetBPTree func(string) (*gno.land/p/nt/bptree/v0.BPTree, .uverse.error); GetBool func(string) (bool, .uverse.error); GetDomainAddress func() .uverse.address; GetInt64 func(string) (int64, .uverse.error); GetString func(string) (string, .uverse.error); GetUint64 func(string) (uint64, .uverse.error); Has func(string) bool; IsWriteAuthorized func(.uverse.address) bool; RemoveAuthorizedCaller func(int, .uverse.realm, .uverse.address) .uverse.error; Set func(int, .uverse.realm, string, interface {}) .uverse.error; UpdateAuthorizedCaller func(int, .uverse.realm, .uverse.address, gno.land/p/gnoswap/store/v1.Permission) .uverse.error}) interface {GetDepositCounter func() *gno.land/r/gnoswap/launchpad.Counter; GetDeposits func() *gno.land/p/nt/bptree/v0.BPTree; GetProjectRecipients func() *gno.land/p/nt/bptree/v0.BPTree; GetProjectTierRewardManagers func() *gno.land/p/nt/bptree/v0.BPTree; GetProjects func() *gno.land/p/nt/bptree/v0.BPTree; GetTotalGNSStakedAmount func() int64; HasDepositCounterStoreKey func() bool; HasDepositsKey func() bool; HasProjectRecipientsKey func() bool; HasProjectTierRewardManagersKey func() bool; HasProjectsKey func() bool; HasTotalGNSStakedAmountKey func() bool; NextDepositID func() string; SetDepositCounter func(int, .uverse.realm, *gno.land/r/gnoswap/launchpad.Counter) .uverse.error; SetDeposits func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetProjectRecipients func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetProjectTierRewardManagers func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetProjects func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetTotalGNSStakedAmount func(int, .uverse.realm, int64) .uverse.error}
NewProject (name string, tokenPath string, depositAmount int64, recipient string, createdHeight int64, createdAt int64) *gno.land/r/gnoswap/launchpad.Project
NewProjectCondition (tokenPath string, minimumAmount int64) *gno.land/r/gnoswap/launchpad.ProjectCondition
NewProjectConditionsWithError (conditionTokens string, conditionAmounts string) ([]*gno.land/r/gnoswap/launchpad.ProjectCondition, interface {Error func() string})
NewProjectTier (projectID string, tierDuration int64, totalDistributeAmount int64, startTime int64, endTime int64) *gno.land/r/gnoswap/launchpad.ProjectTier
NewRewardManager (totalDistributeAmount int64, distributeStartTime int64, distributeEndTime int64, rewardCollectableDuration int64) *gno.land/r/gnoswap/launchpad.RewardManager
NewRewardState (accumulatedRewardPerDepositX128 *gno.land/p/gnoswap/uint256/v1.Uint, depositAmount int64, distributeStartTime int64, distributeEndTime int64, claimableTime int64) *gno.land/r/gnoswap/launchpad.RewardState
RegisterInitializer (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, initializer func(int, .uverse.realm, gno.land/r/gnoswap/launchpad.ILaunchpadStore) gno.land/r/gnoswap/launchpad.ILaunchpad)
Render (path string) string
TransferLeftFromProjectByAdmin (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, projectID string, recipient string) int64
UpgradeImpl (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, packagePath string)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
9 // RewardManager manages the distribution of rewards for a project tier.
10 //
11 // This struct contains the necessary data and methods to calculate and track
12 // rewards for deposits associated with a project tier.
13 //
14 // Fields:
15 // - rewards (bptree.BPTree): A map of deposit IDs to their associated reward states.
16 // - distributeAmountPerSecondX128 (u256.Uint): The amount of tokens to be distributed per second, represented as a Q128 fixed-point number.
17 // - accumulatedRewardPerDepositX128 (u256.Uint): The accumulated reward per GNS stake, represented as a Q128 fixed-point number.
18 // - totalDistributeAmount (int64): The total token allocation for this tier.
19 // - totalClaimedAmount (int64): The total amount of tokens claimed.
20 // - distributeStartTime (int64): The start time of the reward calculation.
21 // - distributeEndTime (int64): The end time of the reward calculation.
22 // - accumulatedDistributeAmount (int64): A legacy field not maintained by v1 reward accounting; normally zero unless explicitly set.
23 // - rewardClaimableDuration (int64): The duration of reward claimable.
24 type RewardManager struct {
25 rewards *bptree.BPTree // depositId -> RewardState
26
27 distributeAmountPerSecondX128 *u256.Uint // distribute amount per second, Q128
28 accumulatedRewardPerDepositX128 *u256.Uint // accumulated reward per GNS stake, Q128
29
30 totalDistributeAmount int64 // total token allocation for this tier
31 totalClaimedAmount int64 // total claimed amount
32 activeDepositAmount int64 // principal represented by active reward states
33 activeClaimedAmount int64 // claims paid to active reward states
34 distributeStartTime int64 // start time of reward calculation
35 distributeEndTime int64 // end time of reward calculation
36 accumulatedDistributeAmount int64 // legacy field; v1 reward paths do not update it
37 accumulatedTime int64 // last time when reward was calculated
38 rewardClaimableDuration int64 // duration of reward claimable
39
40 activePriceDebtX128 *u256.Uint // sum of active deposit amount × initial reward index
41 }
42
43 // Rewards returns the rewards tree of the reward manager.
44 //
45 // Returns:
46 // - rewards: reward-state tree keyed by deposit ID.
47 func (rm *RewardManager) Rewards() *bptree.BPTree {
48 return rm.rewards
49 }
50
51 // SetRewards sets the rewards tree of the reward manager.
52 //
53 // Parameters:
54 // - rewards: reward-state tree to use for this manager.
55 func (rm *RewardManager) SetRewards(rewards *bptree.BPTree) {
56 rm.rewards = rewards
57 }
58
59 // SetReward associates a reward state with a deposit ID in the manager's reward tree.
60 //
61 // Parameters:
62 // - depositID: deposit identifier used as the reward-tree key.
63 // - rewardState: reward state to store for that deposit.
64 func (rm *RewardManager) SetReward(depositID string , rewardState *RewardState) {
65 rm.rewards.Set(depositID, rewardState)
66 }
67
68 // RemoveReward removes the reward state associated with a deposit ID.
69 //
70 // Parameters:
71 // - depositID: deposit identifier whose reward state is removed.
72 func (rm *RewardManager) RemoveReward(depositID string ) {
73 rm.rewards.Remove(depositID)
74 }
75
76 // DistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of the reward manager.
77 //
78 // Returns:
79 // - amountPerSecondX128: reward distribution rate in Q128 fixed-point token units per second.
80 func (rm *RewardManager) DistributeAmountPerSecondX128() *u256.Uint {
81 return rm.distributeAmountPerSecondX128
82 }
83
84 // SetDistributeAmountPerSecondX128 sets the distribute amount per second (Q128) of the reward manager.
85 //
86 // Parameters:
87 // - amount: replacement reward distribution rate in Q128 fixed-point token units per second; the value is copied.
88 func (rm *RewardManager) SetDistributeAmountPerSecondX128(amount *u256.Uint) {
89 rm.distributeAmountPerSecondX128 = u256.Zero().Set(amount)
90 }
91
92 // AccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of the reward manager.
93 //
94 // Returns:
95 // - accumulatedRewardPerDepositX128: accumulated reward index per deposited GNS unit in Q128 fixed-point units.
96 func (rm *RewardManager) AccumulatedRewardPerDepositX128() *u256.Uint {
97 return rm.accumulatedRewardPerDepositX128
98 }
99
100 // SetAccumulatedRewardPerDepositX128 sets the accumulated reward per deposit (Q128) of the reward manager.
101 //
102 // Parameters:
103 // - amount: replacement accumulated reward-per-deposit index in Q128 fixed-point units; the value is copied.
104 func (rm *RewardManager) SetAccumulatedRewardPerDepositX128(amount *u256.Uint) {
105 rm.accumulatedRewardPerDepositX128 = u256.Zero().Set(amount)
106 }
107
108 // TotalDistributeAmount returns the total distribute amount of the reward manager.
109 //
110 // Returns:
111 // - amount: total reward allocation for the tier in token base units.
112 func (rm *RewardManager) TotalDistributeAmount() int64 {
113 return rm.totalDistributeAmount
114 }
115
116 // SetTotalDistributeAmount sets the total distribute amount of the reward manager.
117 //
118 // Parameters:
119 // - amount: total reward allocation for the tier in token base units.
120 func (rm *RewardManager) SetTotalDistributeAmount(amount int64 ) {
121 rm.totalDistributeAmount = amount
122 }
123
124 // TotalClaimedAmount returns the total claimed amount of the reward manager.
125 //
126 // Returns:
127 // - amount: total reward amount claimed from the tier in token base units.
128 func (rm *RewardManager) TotalClaimedAmount() int64 {
129 return rm.totalClaimedAmount
130 }
131
132 // SetTotalClaimedAmount sets the total claimed amount of the reward manager.
133 //
134 // Parameters:
135 // - amount: total claimed reward amount in token base units.
136 func (rm *RewardManager) SetTotalClaimedAmount(amount int64 ) {
137 rm.totalClaimedAmount = amount
138 }
139
140 // ActiveDepositAmount returns the principal represented by currently active reward states.
141 //
142 // Returns:
143 // - amount: active deposited GNS principal in base units.
144 func (rm *RewardManager) ActiveDepositAmount() int64 {
145 return rm.activeDepositAmount
146 }
147
148 // SetActiveDepositAmount replaces the principal represented by currently active reward states.
149 //
150 // Parameters:
151 // - amount: active deposited GNS principal in base units.
152 func (rm *RewardManager) SetActiveDepositAmount(amount int64 ) {
153 rm.activeDepositAmount = amount
154 }
155
156 // ActiveClaimedAmount returns the reward amount claimed by currently active reward states.
157 //
158 // Returns:
159 // - amount: active claimed reward amount in token base units.
160 func (rm *RewardManager) ActiveClaimedAmount() int64 {
161 return rm.activeClaimedAmount
162 }
163
164 // SetActiveClaimedAmount replaces the reward amount claimed by currently active reward states.
165 //
166 // Parameters:
167 // - amount: active claimed reward amount in token base units.
168 func (rm *RewardManager) SetActiveClaimedAmount(amount int64 ) {
169 rm.activeClaimedAmount = amount
170 }
171
172 // ActivePriceDebtX128 returns the sum of active deposits' initial reward-index debts.
173 //
174 // Returns:
175 // - debt: aggregate active price debt in Q128 fixed-point units.
176 func (rm *RewardManager) ActivePriceDebtX128() *u256.Uint {
177 return rm.activePriceDebtX128
178 }
179
180 // SetActivePriceDebtX128 replaces the aggregate active price-index debt.
181 //
182 // Parameters:
183 // - debt: aggregate active price debt in Q128 fixed-point units; the value is copied.
184 func (rm *RewardManager) SetActivePriceDebtX128(debt *u256.Uint) {
185 rm.activePriceDebtX128 = u256.Zero().Set(debt)
186 }
187
188 // DistributeStartTime returns the distribute start time of the reward manager.
189 //
190 // Returns:
191 // - startTime: reward distribution start timestamp in Unix seconds.
192 func (rm *RewardManager) DistributeStartTime() int64 {
193 return rm.distributeStartTime
194 }
195
196 // SetDistributeStartTime sets the distribute start time of the reward manager.
197 //
198 // Parameters:
199 // - time: reward distribution start timestamp in Unix seconds.
200 func (rm *RewardManager) SetDistributeStartTime(time int64 ) {
201 rm.distributeStartTime = time
202 }
203
204 // DistributeEndTime returns the distribute end time of the reward manager.
205 //
206 // Returns:
207 // - endTime: reward distribution end timestamp in Unix seconds.
208 func (rm *RewardManager) DistributeEndTime() int64 {
209 return rm.distributeEndTime
210 }
211
212 // SetDistributeEndTime sets the distribute end time of the reward manager.
213 //
214 // Parameters:
215 // - time: reward distribution end timestamp in Unix seconds.
216 func (rm *RewardManager) SetDistributeEndTime(time int64 ) {
217 rm.distributeEndTime = time
218 }
219
220 // AccumulatedDistributeAmount returns the legacy reward-manager field.
221 // v1 reward paths do not maintain it, so normal reads return zero unless it was
222 // explicitly set.
223 //
224 // Returns:
225 // - amount: legacy accumulated distribution amount in token base units; v1 accounting normally leaves it at zero unless explicitly set.
226 func (rm *RewardManager) AccumulatedDistributeAmount() int64 {
227 return rm.accumulatedDistributeAmount
228 }
229
230 // SetAccumulatedDistributeAmount sets the legacy reward-manager field. It is not
231 // used by v1 reward accounting.
232 //
233 // Parameters:
234 // - amount: legacy accumulated distribution amount in token base units; v1 accounting does not update this field.
235 func (rm *RewardManager) SetAccumulatedDistributeAmount(amount int64 ) {
236 rm.accumulatedDistributeAmount = amount
237 }
238
239 // AccumulatedTime returns the accumulated time of the reward manager.
240 //
241 // Returns:
242 // - time: last reward-accumulation timestamp in Unix seconds, or zero before accumulation.
243 func (rm *RewardManager) AccumulatedTime() int64 {
244 return rm.accumulatedTime
245 }
246
247 // SetAccumulatedTime sets the accumulated time of the reward manager.
248 //
249 // Parameters:
250 // - time: last reward-accumulation timestamp in Unix seconds.
251 func (rm *RewardManager) SetAccumulatedTime(time int64 ) {
252 rm.accumulatedTime = time
253 }
254
255 // RewardClaimableDuration returns the reward claimable duration of the reward manager.
256 //
257 // Returns:
258 // - duration: time after a reward becomes claimable during which it remains collectible, in seconds.
259 func (rm *RewardManager) RewardClaimableDuration() int64 {
260 return rm.rewardClaimableDuration
261 }
262
263 // SetRewardClaimableDuration sets the reward claimable duration of the reward manager.
264 //
265 // Parameters:
266 // - duration: claimable reward window in seconds.
267 func (rm *RewardManager) SetRewardClaimableDuration(duration int64 ) {
268 rm.rewardClaimableDuration = duration
269 }
270
271 // Clone returns an independent copy of the reward manager, including its reward states and Q128 values.
272 //
273 // Returns:
274 // - rewardManager: deep copy with a separate reward tree and mutable numeric values.
275 func (rm RewardManager) Clone() *RewardManager {
276 rewardsTree := bptree.NewBPTreeN( 16 )
277 rm.rewards.Iterate( "" , "" , func (key string , value interface {}) bool {
278 rewardState, ok := value.(*RewardState)
279 if !ok {
280 return true
281 }
282 rewardsTree.Set(key, rewardState.Clone())
283 return false
284 })
285
286 return &RewardManager{
287 rewards: rewardsTree,
288 distributeAmountPerSecondX128: rm.distributeAmountPerSecondX128.Clone(),
289 accumulatedRewardPerDepositX128: rm.accumulatedRewardPerDepositX128.Clone(),
290 totalDistributeAmount: rm.totalDistributeAmount,
291 totalClaimedAmount: rm.totalClaimedAmount,
292 activeDepositAmount: rm.activeDepositAmount,
293 activeClaimedAmount: rm.activeClaimedAmount,
294 distributeStartTime: rm.distributeStartTime,
295 distributeEndTime: rm.distributeEndTime,
296 accumulatedDistributeAmount: rm.accumulatedDistributeAmount,
297 accumulatedTime: rm.accumulatedTime,
298 rewardClaimableDuration: rm.rewardClaimableDuration,
299 activePriceDebtX128: rm.activePriceDebtX128.Clone(),
300 }
301 }
302
303 // NewRewardManager returns a pointer to a new RewardManager with the given values.
304 //
305 // Parameters:
306 // - totalDistributeAmount: total reward allocation for the tier in token base units.
307 // - distributeStartTime: reward distribution start timestamp in Unix seconds.
308 // - distributeEndTime: reward distribution end timestamp in Unix seconds.
309 // - rewardCollectableDuration: duration in seconds for which each accrued reward remains claimable.
310 //
311 // Returns:
312 // - rewardManager: initialized manager with zeroed accounting counters and an empty reward tree.
313 func NewRewardManager(
314 totalDistributeAmount int64 ,
315 distributeStartTime int64 ,
316 distributeEndTime int64 ,
317 rewardCollectableDuration int64 ,
318 ) *RewardManager {
319 return &RewardManager{
320 totalDistributeAmount: totalDistributeAmount,
321 distributeStartTime: distributeStartTime,
322 distributeEndTime: distributeEndTime,
323 totalClaimedAmount: 0 ,
324 activeDepositAmount: 0 ,
325 activeClaimedAmount: 0 ,
326 accumulatedDistributeAmount: 0 ,
327 accumulatedTime: 0 ,
328 accumulatedRewardPerDepositX128: u256.Zero(),
329 distributeAmountPerSecondX128: u256.Zero(),
330 rewardClaimableDuration: rewardCollectableDuration,
331 activePriceDebtX128: u256.Zero(),
332 rewards: bptree.NewBPTreeN( 16 ),
333 }
334 }
335
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.