tx · F4PAPxf4h7YMvKLURBZ1CyHMnE6S2NX29goD5Cu16nES 3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE: -0.02000000 Waves 2023.09.07 12:07 [2744761] smart account 3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE > SELF 0.00000000 Waves
{ "type": 13, "id": "F4PAPxf4h7YMvKLURBZ1CyHMnE6S2NX29goD5Cu16nES", "fee": 2000000, "feeAssetId": null, "timestamp": 1694077670503, "version": 2, "chainId": 84, "sender": "3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE", "senderPublicKey": "G349Uq3FTox7dRNLeAfAQeoACvwZ9iEnVSaHcEYn6j8J", "proofs": [ "5GJ4H5Zw52WxNdAYZbdhTnDdcdDpQLSAJoQ3gQLk3DLSEDr5JtnuF1fBeToJH1hLPe6wSQMj9y5DsQ9dJ2hNbvrX" ], "script": "base64:BgKMHQgCEgYKBAEYEQESBAoCCAESABIDCgEBEgASABIAEgMKAQgSAwoBCBIDCgEIEgUKAwEBARIFCgMBAQESABIDCgEIEgcKBQgICAgIEgQKAhgREgASAwoBCCIDU0VQIgVTQ0FMRSIFTVVMVDgiCnplcm9CaWdJbnQiFHByb2Nlc3NpbmdTdGFnZVRvdGFsIhVwcm9jZXNzaW5nU3RhZ2VTaGFyZXMiC3dhdmVzU3RyaW5nIg5nZXROdW1iZXJCeUtleSIDa2V5Ig9nZXROdW1iZXJPckZhaWwiDmdldFN0cmluZ0J5S2V5Ig9nZXRTdHJpbmdPckZhaWwiDHBhcnNlQXNzZXRJZCIFaW5wdXQiB3dyYXBFcnIiA21zZyIIdGhyb3dFcnIiA2FicyIDdmFsIglhYnNCaWdJbnQiC2tleU1heERlcHRoIg9tYXhEZXB0aERlZmF1bHQiCG1heERlcHRoIhFrZXlGYWN0b3J5QWRkcmVzcyIRZmFjdG9yeUFkZHJlc3NTdHIiD2ZhY3RvcnlDb250cmFjdCISa2V5RW1pc3Npb25BZGRyZXNzIhlrZXlWb3RpbmdFbWlzc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gXfmWAtfJK5AKbzAuT7KLDLwqDPbpnJRrpQZ4WdX6k4 Next: D2pxJxcYEhJxxbt4AsasHmgTGpcAJvxVodqyJx2TZXBD Diff:
Old | New | Differences | |
---|---|---|---|
7 | 7 | ||
8 | 8 | let MULT8 = 100000000 | |
9 | 9 | ||
10 | - | let MULT8BI = toBigInt(MULT8) | |
11 | - | ||
12 | 10 | let zeroBigInt = toBigInt(0) | |
13 | 11 | ||
14 | 12 | let processingStageTotal = 0 | |
15 | 13 | ||
16 | 14 | let processingStageShares = 1 | |
17 | 15 | ||
18 | - | let | |
16 | + | let wavesString = "WAVES" | |
19 | 17 | ||
20 | - | ||
18 | + | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
21 | 19 | ||
22 | - | let wavesString = "WAVES" | |
20 | + | ||
21 | + | func getNumberOrFail (key) = valueOrErrorMessage(getInteger(this, key), (("mandatory this." + key) + " is not defined")) | |
22 | + | ||
23 | + | ||
24 | + | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
25 | + | ||
26 | + | ||
27 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (("mandatory this." + key) + " is not defined")) | |
28 | + | ||
29 | + | ||
30 | + | func parseAssetId (input) = if ((input == wavesString)) | |
31 | + | then unit | |
32 | + | else fromBase58String(input) | |
33 | + | ||
23 | 34 | ||
24 | 35 | func wrapErr (msg) = makeString(["gwx_reward.ride:", msg], " ") | |
25 | 36 | ||
26 | 37 | ||
27 | 38 | func throwErr (msg) = throw(wrapErr(msg)) | |
28 | - | ||
29 | - | ||
30 | - | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
31 | - | ||
32 | - | ||
33 | - | func getNumberOrFail (key) = valueOrErrorMessage(getInteger(this, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
34 | - | ||
35 | - | ||
36 | - | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
37 | - | ||
38 | - | ||
39 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
40 | - | ||
41 | - | ||
42 | - | func parseAssetId (input) = if ((input == wavesString)) | |
43 | - | then unit | |
44 | - | else fromBase58String(input) | |
45 | 39 | ||
46 | 40 | ||
47 | 41 | func abs (val) = if ((0 > val)) | |
144 | 138 | } | |
145 | 139 | ||
146 | 140 | ||
147 | - | let keySuspension = "%s__suspension" | |
148 | - | ||
149 | - | let isSuspended = valueOrElse(getBoolean(this, keySuspension), false) | |
150 | - | ||
151 | - | func throwIfSuspended () = if (!(isSuspended)) | |
152 | - | then true | |
153 | - | else throwErr("suspended") | |
154 | - | ||
155 | - | ||
156 | 141 | func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight" | |
157 | 142 | ||
158 | 143 | ||
159 | 144 | func keyUsersCount () = "%s__nextUserNum" | |
160 | - | ||
161 | - | ||
162 | - | func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", toString(userAddress)], SEP) | |
163 | 145 | ||
164 | 146 | ||
165 | 147 | func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
174 | 156 | func keyPoolWeightVirtual () = "%s%s__poolWeight__GWXvirtualPOOL" | |
175 | 157 | ||
176 | 158 | ||
159 | + | func keyNextProcessedUser () = "%s__nextProcessedUser" | |
160 | + | ||
161 | + | ||
162 | + | func keyLatestPeriod () = "%s__latestPeriod" | |
163 | + | ||
164 | + | ||
165 | + | func keyNextPeriod () = "%s__nextPeriod" | |
166 | + | ||
167 | + | ||
168 | + | func keyProcessingStage () = "%s__processingStage" | |
169 | + | ||
170 | + | ||
171 | + | func keyNextProcessedPeriod () = "%s__nextProcessedPeriod" | |
172 | + | ||
173 | + | ||
177 | 174 | func keyUserUnclaimed (userIndex) = makeString(["%s%d", "userUnclaimed", toString(userIndex)], SEP) | |
175 | + | ||
176 | + | ||
177 | + | func keyNextUnlaimedPeriodOfUser (userIndex) = makeString(["%s%d__nextClaimedPeriod", toString(userIndex)], SEP) | |
178 | + | ||
179 | + | ||
180 | + | func keyLastProcessedPeriodOfUser (userIndex) = makeString(["%s%d__lastProcessedPeriod", toString(userIndex)], SEP) | |
181 | + | ||
182 | + | ||
183 | + | func keyHeightForPeriod (period) = makeString(["%s%d__startHeightForPeriod", toString(period)], SEP) | |
184 | + | ||
185 | + | ||
186 | + | func keyAuxEmissionRewardForPeriod (period) = makeString(["%s%d__auxEmissionReward", toString(period)], SEP) | |
187 | + | ||
188 | + | ||
189 | + | func keyTotalAmountForPeriod (period) = makeString(["%s%d__totalAmountForPeriod", toString(period)], SEP) | |
190 | + | ||
191 | + | ||
192 | + | func keyLastPayoutInfo () = "%s__lastPayoutInfo" | |
193 | + | ||
194 | + | ||
195 | + | func PeriodPayoutInfo (period,matcherReward,emissionReward) = makeString(["%d%d%d", toString(period), toString(matcherReward), toString(emissionReward)], SEP) | |
196 | + | ||
197 | + | ||
198 | + | func keyPayoutHistoryInfo (period) = makeString(["%s%s%d__payouts__history", toString(period)], SEP) | |
199 | + | ||
200 | + | ||
201 | + | func keyTotalWeightForPeriod (period) = makeString(["%s%d__totalWeightForPeriod", toString(period)], SEP) | |
202 | + | ||
203 | + | ||
204 | + | func keyUserKValueForPeriod (period,userIndex) = makeString(["%s%d%s%d__paramByPeriod", toString(userIndex), "k", toString(period)], SEP) | |
205 | + | ||
206 | + | ||
207 | + | func keyUserBValueForPeriod (period,userIndex) = makeString(["%s%d%s%d__paramByPeriod", toString(userIndex), "b", toString(period)], SEP) | |
208 | + | ||
209 | + | ||
210 | + | func keyUserWeightForPeriod (period,userIndex) = makeString(["%s%d%s%d__paramByPeriod", toString(userIndex), "weight", toString(period)], SEP) | |
178 | 211 | ||
179 | 212 | ||
180 | 213 | func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP) | |
242 | 275 | } | |
243 | 276 | ||
244 | 277 | ||
278 | + | func calcUserWeight (boostingContractAddress,heightForPeriod,period,userIndex) = { | |
279 | + | let kLast = keyLastProcessedPeriodOfUser(userIndex) | |
280 | + | let kKey = keyUserKValueForPeriod(period, userIndex) | |
281 | + | let kRaw = getInteger(boostingContractAddress, kKey) | |
282 | + | let kUserWeight = keyUserWeightForPeriod(period, userIndex) | |
283 | + | if (isDefined(kRaw)) | |
284 | + | then { | |
285 | + | let k = value(kRaw) | |
286 | + | let b = value(getInteger(boostingContractAddress, keyUserBValueForPeriod(period, userIndex))) | |
287 | + | let w = ((k * heightForPeriod) + b) | |
288 | + | if ((w > 0)) | |
289 | + | then $Tuple2((w / SCALE), [IntegerEntry(kLast, period), IntegerEntry(kUserWeight, w)]) | |
290 | + | else $Tuple2(0, nil) | |
291 | + | } | |
292 | + | else { | |
293 | + | let p = getInteger(this, kLast) | |
294 | + | if (if (isDefined(p)) | |
295 | + | then (period >= value(p)) | |
296 | + | else false) | |
297 | + | then { | |
298 | + | let pv = value(p) | |
299 | + | let k = value(getInteger(boostingContractAddress, keyUserKValueForPeriod(pv, userIndex))) | |
300 | + | let b = value(getInteger(boostingContractAddress, keyUserBValueForPeriod(pv, userIndex))) | |
301 | + | let w = ((k * heightForPeriod) + b) | |
302 | + | if ((w > 0)) | |
303 | + | then $Tuple2((w / SCALE), [IntegerEntry(kUserWeight, w)]) | |
304 | + | else $Tuple2(0, nil) | |
305 | + | } | |
306 | + | else $Tuple2(0, nil) | |
307 | + | } | |
308 | + | } | |
309 | + | ||
310 | + | ||
311 | + | func calcUserWeightForClaim (boostingContractAddress,heightForPeriod,period,userIndex) = { | |
312 | + | let kUserWeight = keyUserWeightForPeriod(period, userIndex) | |
313 | + | let userWeightOrUnit = getInteger(kUserWeight) | |
314 | + | match userWeightOrUnit { | |
315 | + | case _: Unit => | |
316 | + | 0 | |
317 | + | case w: Int => | |
318 | + | (w / SCALE) | |
319 | + | case _ => | |
320 | + | throw("Match error") | |
321 | + | } | |
322 | + | } | |
323 | + | ||
324 | + | ||
245 | 325 | func getUserIndexByAddress (boostingContractAddressStr,userAddress) = { | |
246 | 326 | let key = makeString(["%s%s%s", "mapping", "user2num", userAddress], SEP) | |
247 | 327 | parseIntValue(valueOrErrorMessage(getString(Address(fromBase58String(boostingContractAddressStr)), key), ((("User address " + userAddress) + " is not found in boosting contract data, key=") + key))) | |
248 | 328 | } | |
249 | 329 | ||
250 | 330 | ||
331 | + | func nextPeriod () = getNumberByKey(keyNextPeriod()) | |
332 | + | ||
333 | + | ||
334 | + | func commonClaimReward (userAddress) = { | |
335 | + | let cfgArray = readConfigArrayOrFail() | |
336 | + | let userIdx = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddress) | |
337 | + | let userUnclaimedOption = getInteger(keyUserUnclaimed(userIdx)) | |
338 | + | match userUnclaimedOption { | |
339 | + | case _: Unit => | |
340 | + | $Tuple2(0, nil) | |
341 | + | case u: Int => | |
342 | + | $Tuple2(u, [IntegerEntry(keyUserUnclaimed(userIdx), 0)]) | |
343 | + | case _ => | |
344 | + | throw("Match error") | |
345 | + | } | |
346 | + | } | |
347 | + | ||
348 | + | ||
251 | 349 | func getTradingReward (userAddress) = valueOrElse(getInteger(this, keyTradingReward(userAddress)), 0) | |
252 | 350 | ||
253 | 351 | ||
254 | - | func keyRewardPerGwxIntegral () = makeString(["%s", "rewardPerGwxIntegral"], SEP) | |
352 | + | @Callable(i) | |
353 | + | func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = if ((currentIter == size(userAddresses))) | |
354 | + | then nil | |
355 | + | else { | |
356 | + | let checks = [if ((i.caller == this)) | |
357 | + | then true | |
358 | + | else throwErr("Permission denied"), if ((paymentAmountLeftOver >= rewards[currentIter])) | |
359 | + | then true | |
360 | + | else throwErr("insufficient payment assetId")] | |
361 | + | if ((checks == checks)) | |
362 | + | then { | |
363 | + | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [(paymentAmountLeftOver - rewards[currentIter]), userAddresses, rewards, (currentIter + 1)], nil) | |
364 | + | if ((tradeRewardInternal == tradeRewardInternal)) | |
365 | + | then { | |
366 | + | let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i) | |
367 | + | let userAddress = addressFromStringValue(userAddresses[currentIter]) | |
368 | + | $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), IntegerEntry(keyTradingReward(userAddresses[currentIter]), rewards[currentIter])], tradeRewardInternal) | |
369 | + | } | |
370 | + | else throw("Strict value is not equal to itself.") | |
371 | + | } | |
372 | + | else throw("Strict value is not equal to itself.") | |
373 | + | } | |
255 | 374 | ||
256 | - | ||
257 | - | func getGwxAmountTotalOption () = { | |
258 | - | let keyGwxTotal = "%s%s__gwx__total" | |
259 | - | getInteger(boostingContractOrFail(), keyGwxTotal) | |
260 | - | } | |
261 | - | ||
262 | - | ||
263 | - | func getUserGwxAmountTotalOption (userAddress) = { | |
264 | - | func keyUserGwxAmountTotal (userAddress) = makeString(["%s%s__gwxAmountTotal", toString(userAddress)], SEP) | |
265 | - | ||
266 | - | getInteger(boostingContractOrFail(), keyUserGwxAmountTotal(userAddress)) | |
267 | - | } | |
268 | - | ||
269 | - | ||
270 | - | func _refreshRewardPerGwxIntegral () = { | |
271 | - | let rewardPerGwxIntegralPrevious = valueOrElse( match getString(this, keyRewardPerGwxIntegral()) { | |
272 | - | case s: String => | |
273 | - | parseBigInt(s) | |
274 | - | case _: Unit => | |
275 | - | unit | |
276 | - | case _ => | |
277 | - | throw("Match error") | |
278 | - | }, zeroBigInt) | |
279 | - | let rewardPerGwxIntegralLastHeight = valueOrErrorMessage(getInteger(this, keyGwxRewardEmissionStartHeight()), wrapErr(("invalid " + keyGwxRewardEmissionStartHeight()))) | |
280 | - | let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), wrapErr(("invalid " + keyRatePerBlockCurrent()))) | |
281 | - | let gwxHoldersRewardCurrent = valueOrElse(getInteger(emissionContract, keyGwxHoldersRewardCurrent()), 0) | |
282 | - | let gwxAmountTotal = valueOrElse(getGwxAmountTotalOption(), 0) | |
283 | - | let dh = toBigInt((height - rewardPerGwxIntegralLastHeight)) | |
284 | - | let gwxAmountTotalBI = toBigInt(gwxAmountTotal) | |
285 | - | let rewardPerGwxIntegral = (rewardPerGwxIntegralPrevious + (if ((gwxAmountTotalBI == zeroBigInt)) | |
286 | - | then zeroBigInt | |
287 | - | else fraction(dh, ((toBigInt(emissionRate) * toBigInt(gwxHoldersRewardCurrent)) * MULT18BI), (gwxAmountTotalBI * MULT8BI)))) | |
288 | - | $Tuple2([IntegerEntry(keyGwxRewardEmissionStartHeight(), height), StringEntry(keyRewardPerGwxIntegral(), toString(rewardPerGwxIntegral))], rewardPerGwxIntegral) | |
289 | - | } | |
290 | - | ||
291 | - | ||
292 | - | func keyRewardPerGwxIntegralUserLast (userAddress) = makeString(["%s%s", "rewardPerGwxIntegralUserLast", toString(userAddress)], SEP) | |
293 | - | ||
294 | - | ||
295 | - | func _refreshUserReward (userAddress,userNum) = { | |
296 | - | let $t01029210380 = _refreshRewardPerGwxIntegral() | |
297 | - | let rewardPerGwxIntegralActions = $t01029210380._1 | |
298 | - | let rewardPerGwxIntegral = $t01029210380._2 | |
299 | - | let rewardPerGwxIntegralUserLast = match getString(this, keyRewardPerGwxIntegralUserLast(userAddress)) { | |
300 | - | case s: String => | |
301 | - | valueOrErrorMessage(parseBigInt(s), wrapErr("invalid user last integral")) | |
302 | - | case _: Unit => | |
303 | - | rewardPerGwxIntegral | |
304 | - | case _ => | |
305 | - | throw("Match error") | |
306 | - | } | |
307 | - | let userIdxOption = getString(boostingContractOrFail(), keyUser2NumMapping(userAddress)) | |
308 | - | let userUnclaimed = valueOrElse(getInteger(keyUserUnclaimed(userNum)), 0) | |
309 | - | let userGwxAmount = valueOrElse(getUserGwxAmountTotalOption(userAddress), 0) | |
310 | - | let userReward = (toInt(fraction(toBigInt(userGwxAmount), (rewardPerGwxIntegral - rewardPerGwxIntegralUserLast), MULT18BI)) + userUnclaimed) | |
311 | - | $Tuple2(([StringEntry(keyRewardPerGwxIntegralUserLast(userAddress), toString(rewardPerGwxIntegral))] ++ rewardPerGwxIntegralActions), userReward) | |
312 | - | } | |
313 | - | ||
314 | - | ||
315 | - | func commonClaimReward (userAddressStr) = { | |
316 | - | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
317 | - | let cfgArray = readConfigArrayOrFail() | |
318 | - | let userNum = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddressStr) | |
319 | - | let $t01167111735 = _refreshUserReward(userAddress, userNum) | |
320 | - | let actions = $t01167111735._1 | |
321 | - | let reward = $t01167111735._2 | |
322 | - | $Tuple2(reward, ([IntegerEntry(keyUserUnclaimed(userNum), 0)] ++ actions)) | |
323 | - | } | |
324 | 375 | ||
325 | 376 | ||
326 | 377 | @Callable(i) | |
327 | - | func refreshUserReward (userAddressBytes,userNum) = { | |
328 | - | let suspensionCheck = throwIfSuspended() | |
329 | - | if ((suspensionCheck == suspensionCheck)) | |
330 | - | then { | |
331 | - | let checkCaller = if ((i.caller == boostingContractOrFail())) | |
332 | - | then true | |
333 | - | else throwErr("permission denied") | |
334 | - | if ((checkCaller == checkCaller)) | |
335 | - | then { | |
336 | - | let $t01206112139 = _refreshUserReward(Address(userAddressBytes), userNum) | |
337 | - | let actions = $t01206112139._1 | |
338 | - | let reward = $t01206112139._2 | |
339 | - | $Tuple2(([IntegerEntry(keyUserUnclaimed(userNum), reward)] ++ actions), reward) | |
340 | - | } | |
341 | - | else throw("Strict value is not equal to itself.") | |
342 | - | } | |
378 | + | func updateReferralActivity (userAddress,gWxAmountStart) = { | |
379 | + | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
380 | + | let activeReferralInv = if ((referrer == unit)) | |
381 | + | then unit | |
382 | + | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil) | |
383 | + | if ((activeReferralInv == activeReferralInv)) | |
384 | + | then $Tuple2(nil, unit) | |
343 | 385 | else throw("Strict value is not equal to itself.") | |
344 | 386 | } | |
345 | 387 | ||
346 | 388 | ||
347 | 389 | ||
348 | 390 | @Callable(i) | |
349 | - | func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = { | |
350 | - | let suspensionCheck = throwIfSuspended() | |
351 | - | if ((suspensionCheck == suspensionCheck)) | |
352 | - | then if ((currentIter == size(userAddresses))) | |
353 | - | then nil | |
354 | - | else { | |
355 | - | let checks = [if ((i.caller == this)) | |
356 | - | then true | |
357 | - | else throwErr("Permission denied"), if ((paymentAmountLeftOver >= rewards[currentIter])) | |
358 | - | then true | |
359 | - | else throwErr("insufficient payment assetId")] | |
360 | - | if ((checks == checks)) | |
361 | - | then { | |
362 | - | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [(paymentAmountLeftOver - rewards[currentIter]), userAddresses, rewards, (currentIter + 1)], nil) | |
363 | - | if ((tradeRewardInternal == tradeRewardInternal)) | |
364 | - | then { | |
365 | - | let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i) | |
366 | - | let userAddress = addressFromStringValue(userAddresses[currentIter]) | |
367 | - | $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), IntegerEntry(keyTradingReward(userAddresses[currentIter]), rewards[currentIter])], tradeRewardInternal) | |
368 | - | } | |
369 | - | else throw("Strict value is not equal to itself.") | |
370 | - | } | |
371 | - | else throw("Strict value is not equal to itself.") | |
391 | + | func finalizeHelper () = { | |
392 | + | let processingStage = valueOrElse(getInteger(keyProcessingStage()), processingStageTotal) | |
393 | + | let currentPeriod = getNumberByKey(keyNextProcessedPeriod()) | |
394 | + | let currentUser = getNumberByKey(keyNextProcessedUser()) | |
395 | + | let latestPeriod = getNumberByKey(keyLatestPeriod()) | |
396 | + | let usersCount = valueOrElse(getInteger(boostingContractOrFail(), keyUsersCount()), 0) | |
397 | + | let totalWeightKey = keyTotalWeightForPeriod(currentPeriod) | |
398 | + | let totalWeight = getNumberByKey(keyTotalWeightForPeriod(currentPeriod)) | |
399 | + | let heightForPeriod = getNumberByKey(keyHeightForPeriod(currentPeriod)) | |
400 | + | if ((currentPeriod > latestPeriod)) | |
401 | + | then $Tuple2(nil, false) | |
402 | + | else if ((processingStage == processingStageTotal)) | |
403 | + | then { | |
404 | + | let $t01451014626 = calcUserWeight(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser) | |
405 | + | let userWeight = $t01451014626._1 | |
406 | + | let userActions = $t01451014626._2 | |
407 | + | let totalWeightNew = (totalWeight + userWeight) | |
408 | + | let processingActions = if (((usersCount - 1) > currentUser)) | |
409 | + | then [IntegerEntry(keyNextProcessedUser(), (currentUser + 1))] | |
410 | + | else [IntegerEntry(keyProcessingStage(), processingStageShares), IntegerEntry(keyNextProcessedUser(), 0)] | |
411 | + | $Tuple2((([IntegerEntry(totalWeightKey, totalWeightNew)] ++ processingActions) ++ userActions), true) | |
372 | 412 | } | |
413 | + | else if ((processingStage == processingStageShares)) | |
414 | + | then { | |
415 | + | let userWeight = calcUserWeightForClaim(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser) | |
416 | + | let userAmountMatcherForPeriod = fraction(getNumberByKey(keyTotalAmountForPeriod(currentPeriod)), userWeight, totalWeight) | |
417 | + | let userAmountEmissionForPeriod = fraction(getNumberByKey(keyAuxEmissionRewardForPeriod(currentPeriod)), userWeight, totalWeight) | |
418 | + | let userTotalAmount = (userAmountEmissionForPeriod + userAmountMatcherForPeriod) | |
419 | + | let userUnclaimedOption = getInteger(keyUserUnclaimed(currentUser)) | |
420 | + | let userAddress = getStringValue(boostingContractOrFail(), keyNumToUserMapping(currentUser)) | |
421 | + | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
422 | + | let activeReferralInv = if ((referrer == unit)) | |
423 | + | then unit | |
424 | + | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userWeight >= referralMinGWxAmount)], nil) | |
425 | + | if ((activeReferralInv == activeReferralInv)) | |
426 | + | then { | |
427 | + | let referralInv = if (if ((referrer == unit)) | |
428 | + | then true | |
429 | + | else (referralMinGWxAmount > userWeight)) | |
430 | + | then unit | |
431 | + | else { | |
432 | + | let referrerReward = fraction(userTotalAmount, referrerRewardPermille, SCALE) | |
433 | + | let referralReward = fraction(userTotalAmount, referralRewardPermille, SCALE) | |
434 | + | invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil) | |
435 | + | } | |
436 | + | if ((referralInv == referralInv)) | |
437 | + | then { | |
438 | + | let unclaimedActions = [IntegerEntry(keyUserUnclaimed(currentUser), (valueOrElse(userUnclaimedOption, 0) + userTotalAmount))] | |
439 | + | let processingActions = if (((usersCount - 1) > currentUser)) | |
440 | + | then [IntegerEntry(keyNextProcessedUser(), (currentUser + 1))] | |
441 | + | else [IntegerEntry(keyNextProcessedPeriod(), (currentPeriod + 1)), IntegerEntry(keyNextProcessedUser(), 0), DeleteEntry(keyProcessingStage())] | |
442 | + | $Tuple2((unclaimedActions ++ processingActions), true) | |
443 | + | } | |
444 | + | else throw("Strict value is not equal to itself.") | |
445 | + | } | |
446 | + | else throw("Strict value is not equal to itself.") | |
447 | + | } | |
448 | + | else throw("invalid processing stage") | |
449 | + | } | |
450 | + | ||
451 | + | ||
452 | + | ||
453 | + | @Callable(i) | |
454 | + | func finalizeWrapper (counter) = { | |
455 | + | let result = { | |
456 | + | let @ = invoke(this, "finalizeHelper", nil, nil) | |
457 | + | if ($isInstanceOf(@, "Boolean")) | |
458 | + | then @ | |
459 | + | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
460 | + | } | |
461 | + | if ((result == result)) | |
462 | + | then if (!(result)) | |
463 | + | then if ((counter == maxDepth)) | |
464 | + | then throw("Nothing to process") | |
465 | + | else $Tuple2(nil, unit) | |
466 | + | else if ((counter > 0)) | |
467 | + | then $Tuple2(nil, invoke(this, "finalizeWrapper", [(counter - 1)], nil)) | |
468 | + | else $Tuple2(nil, unit) | |
373 | 469 | else throw("Strict value is not equal to itself.") | |
374 | 470 | } | |
375 | 471 | ||
376 | 472 | ||
377 | 473 | ||
378 | 474 | @Callable(i) | |
379 | - | func updateReferralActivity (userAddress,gWxAmountStart) = { | |
380 | - | let suspensionCheck = throwIfSuspended() | |
381 | - | if ((suspensionCheck == suspensionCheck)) | |
382 | - | then { | |
383 | - | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
384 | - | let activeReferralInv = if ((referrer == unit)) | |
385 | - | then unit | |
386 | - | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil) | |
387 | - | if ((activeReferralInv == activeReferralInv)) | |
388 | - | then $Tuple2(nil, unit) | |
389 | - | else throw("Strict value is not equal to itself.") | |
390 | - | } | |
391 | - | else throw("Strict value is not equal to itself.") | |
392 | - | } | |
475 | + | func processPendingPeriodsAndUsers () = $Tuple2(nil, invoke(this, "finalizeWrapper", [maxDepth], nil)) | |
393 | 476 | ||
394 | 477 | ||
395 | 478 | ||
396 | 479 | @Callable(i) | |
397 | - | func processPendingPeriodsAndUsers () = $Tuple2(nil, throwErr("deprecated")) | |
398 | - | ||
399 | - | ||
400 | - | ||
401 | - | @Callable(i) | |
402 | - | func claimReward () = { | |
403 | - | let suspensionCheck = throwIfSuspended() | |
404 | - | if ((suspensionCheck == suspensionCheck)) | |
480 | + | func deposit () = { | |
481 | + | let checkCaller = if ((i.caller == votingEmissionContract)) | |
482 | + | then true | |
483 | + | else mustManager(i) | |
484 | + | if ((checkCaller == checkCaller)) | |
405 | 485 | then { | |
406 | - | let cfgArray = readConfigArrayOrFail() | |
407 | - | let userAddress = i.caller | |
408 | - | let userAddressStr = toString(userAddress) | |
409 | - | let $t01400914066 = commonClaimReward(userAddressStr) | |
410 | - | let amount = $t01400914066._1 | |
411 | - | let actions = $t01400914066._2 | |
412 | - | let checkAmount = if ((amount > 0)) | |
413 | - | then true | |
414 | - | else throw("nothing to claim") | |
415 | - | if ((checkAmount == checkAmount)) | |
486 | + | let period = nextPeriod() | |
487 | + | let deltaH = (height - getNumberOrFail(keyGwxRewardEmissionStartHeight())) | |
488 | + | let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), (("mandatory emission_contract." + keyRatePerBlockCurrent()) + " is not defined")) | |
489 | + | let gwxHoldersRewardCurrent = valueOrElse(getInteger(emissionContract, keyGwxHoldersRewardCurrent()), 0) | |
490 | + | if ((gwxHoldersRewardCurrent == gwxHoldersRewardCurrent)) | |
416 | 491 | then { | |
417 | - | let userGwxAmount = { | |
418 | - | let @ = invoke(boostingContractOrFail(), "getUserGwxAmount", [userAddressStr], nil) | |
419 | - | if ($isInstanceOf(@, "Int")) | |
420 | - | then @ | |
421 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
422 | - | } | |
423 | - | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddressStr)) | |
424 | - | let activeReferralInv = if ((referrer == unit)) | |
425 | - | then unit | |
426 | - | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userGwxAmount >= referralMinGWxAmount)], nil) | |
427 | - | if ((activeReferralInv == activeReferralInv)) | |
492 | + | let auxAmount = fraction((deltaH * gwxHoldersRewardCurrent), emissionRate, MULT8) | |
493 | + | let em = if ((auxAmount > 0)) | |
494 | + | then invoke(emissionContract, "emit", [auxAmount], nil) | |
495 | + | else unit | |
496 | + | if ((em == em)) | |
428 | 497 | then { | |
429 | - | let referralInv = if (if ((referrer == unit)) | |
430 | - | then true | |
431 | - | else (referralMinGWxAmount > userGwxAmount)) | |
432 | - | then unit | |
433 | - | else { | |
434 | - | let referrerReward = fraction(amount, referrerRewardPermille, SCALE) | |
435 | - | let referralReward = fraction(amount, referralRewardPermille, SCALE) | |
436 | - | invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil) | |
437 | - | } | |
438 | - | if ((referralInv == referralInv)) | |
498 | + | let matcherPart = 0 | |
499 | + | let payoutInfo = PeriodPayoutInfo(period, matcherPart, auxAmount) | |
500 | + | let gwxHoldersRewardUpdated = { | |
501 | + | let @ = invoke(emissionContract, "gwxHoldersRewardUpdate", nil, nil) | |
502 | + | if ($isInstanceOf(@, "Boolean")) | |
503 | + | then @ | |
504 | + | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
505 | + | } | |
506 | + | if ((gwxHoldersRewardUpdated == gwxHoldersRewardUpdated)) | |
439 | 507 | then { | |
440 | - | let emit = invoke(emissionContract, "emit", [amount], nil) | |
441 | - | if ((emit == emit)) | |
442 | - | then { | |
443 | - | let claimedReferral = { | |
444 | - | let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil) | |
445 | - | if ($isInstanceOf(@, "Int")) | |
446 | - | then @ | |
447 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
448 | - | } | |
449 | - | if ((claimedReferral == claimedReferral)) | |
450 | - | then { | |
451 | - | let totalAmount = (amount + claimedReferral) | |
452 | - | $Tuple2(([ScriptTransfer(i.caller, amount, wxAssetId), HistoryEntry("claim", userAddressStr, totalAmount, i)] ++ actions), totalAmount) | |
453 | - | } | |
454 | - | else throw("Strict value is not equal to itself.") | |
455 | - | } | |
456 | - | else throw("Strict value is not equal to itself.") | |
508 | + | let totalReward = (matcherPart + auxAmount) | |
509 | + | let actions = if (if ((totalReward == 0)) | |
510 | + | then !(gwxHoldersRewardUpdated) | |
511 | + | else false) | |
512 | + | then nil | |
513 | + | else [IntegerEntry(keyLatestPeriod(), period), IntegerEntry(keyHeightForPeriod(period), height), IntegerEntry(keyAuxEmissionRewardForPeriod(period), auxAmount), IntegerEntry(keyGwxRewardEmissionStartHeight(), height), IntegerEntry(keyTotalAmountForPeriod(period), matcherPart), IntegerEntry(keyNextPeriod(), (period + 1)), StringEntry(keyLastPayoutInfo(), payoutInfo), StringEntry(keyPayoutHistoryInfo(period), payoutInfo)] | |
514 | + | $Tuple2(actions, unit) | |
457 | 515 | } | |
458 | 516 | else throw("Strict value is not equal to itself.") | |
459 | 517 | } | |
467 | 525 | ||
468 | 526 | ||
469 | 527 | @Callable(i) | |
528 | + | func claimReward () = { | |
529 | + | let cfgArray = readConfigArrayOrFail() | |
530 | + | let address = toString(i.caller) | |
531 | + | let $t01981519865 = commonClaimReward(address) | |
532 | + | let amount = $t01981519865._1 | |
533 | + | let actions = $t01981519865._2 | |
534 | + | let checkAmount = if ((amount > 0)) | |
535 | + | then true | |
536 | + | else throw("Nothing to claim") | |
537 | + | if ((checkAmount == checkAmount)) | |
538 | + | then { | |
539 | + | let amountFromEmission = 0 | |
540 | + | let claimedReferral = { | |
541 | + | let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil) | |
542 | + | if ($isInstanceOf(@, "Int")) | |
543 | + | then @ | |
544 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
545 | + | } | |
546 | + | let totalAmount = (amount + claimedReferral) | |
547 | + | $Tuple2(([ScriptTransfer(i.caller, totalAmount, fromBase58String(cfgArray[IdxCfgAssetId])), HistoryEntry("claim", address, amount, i)] ++ actions), [totalAmount, amountFromEmission]) | |
548 | + | } | |
549 | + | else throw("Strict value is not equal to itself.") | |
550 | + | } | |
551 | + | ||
552 | + | ||
553 | + | ||
554 | + | @Callable(i) | |
470 | 555 | func claimRewardREADONLY (address) = { | |
471 | - | let $ | |
472 | - | let amount = $ | |
473 | - | let actions = $ | |
556 | + | let $t02043820488 = commonClaimReward(address) | |
557 | + | let amount = $t02043820488._1 | |
558 | + | let actions = $t02043820488._2 | |
474 | 559 | let referralUnclaimed = valueOrElse(getInteger(referralsContractAddressOrFail, keyUnclaimedReferral(referralProgramName, address)), 0) | |
475 | 560 | let totalAmount = (amount + referralUnclaimed) | |
476 | 561 | $Tuple2(nil, totalAmount) | |
479 | 564 | ||
480 | 565 | ||
481 | 566 | @Callable(i) | |
482 | - | func onEmissionForGwxStart () = { | |
483 | - | let suspensionCheck = throwIfSuspended() | |
484 | - | if ((suspensionCheck == suspensionCheck)) | |
485 | - | then if ((i.caller != factoryContract)) | |
486 | - | then throw("permissions denied") | |
487 | - | else [IntegerEntry(keyGwxRewardEmissionStartHeight(), height)] | |
488 | - | else throw("Strict value is not equal to itself.") | |
567 | + | func latestFinalizedPeriodREADONLY (address) = $Tuple2(nil, valueOrElse(getInteger(this, keyLatestPeriod()), -1)) | |
568 | + | ||
569 | + | ||
570 | + | ||
571 | + | @Callable(i) | |
572 | + | func latestFinalizedPeriodInfoREADONLY (address) = $Tuple2(nil, getStringByKey(keyLastPayoutInfo())) | |
573 | + | ||
574 | + | ||
575 | + | ||
576 | + | @Callable(i) | |
577 | + | func calcGwxParamsREADONLY (gwxAmountStart,lockStartHeight,lockDurationBlocks) = { | |
578 | + | let lockEndHeight = (lockStartHeight + lockDurationBlocks) | |
579 | + | let scale8ParamK = -(fraction(gwxAmountStart, SCALE, lockDurationBlocks)) | |
580 | + | let scale8ParamB = (fraction(gwxAmountStart, SCALE, lockDurationBlocks) * lockEndHeight) | |
581 | + | $Tuple2(nil, [scale8ParamK, scale8ParamB, nextPeriod()]) | |
582 | + | } | |
583 | + | ||
584 | + | ||
585 | + | ||
586 | + | @Callable(i) | |
587 | + | func calcGwxAmountStartREADONLY (wxLockAmount,lockDuration,maxLockDuration) = { | |
588 | + | let coeffX8 = fraction(lockDuration, MULT8, maxLockDuration) | |
589 | + | let gWxAmountStart = fraction(wxLockAmount, coeffX8, MULT8) | |
590 | + | $Tuple2(nil, [gWxAmountStart]) | |
591 | + | } | |
592 | + | ||
593 | + | ||
594 | + | ||
595 | + | @Callable(i) | |
596 | + | func onEmissionForGwxStart () = if ((i.caller != factoryContract)) | |
597 | + | then throw("permissions denied") | |
598 | + | else [IntegerEntry(keyGwxRewardEmissionStartHeight(), height)] | |
599 | + | ||
600 | + | ||
601 | + | ||
602 | + | @Callable(i) | |
603 | + | func latestPeriodEmissionRewardsREADONLY (address) = { | |
604 | + | let period = nextPeriod() | |
605 | + | $Tuple2(nil, [getNumberByKey(keyAuxEmissionRewardForPeriod(period))]) | |
606 | + | } | |
607 | + | ||
608 | + | ||
609 | + | ||
610 | + | @Callable(i) | |
611 | + | func calcD (x1BigIntStr,x2BigIntStr,ampBigIntStr,aPrecisionBigIntStr,targetPrecisionBigIntStr) = { | |
612 | + | let nCoins = toBigInt(2) | |
613 | + | let aPrecision = parseBigIntValue(aPrecisionBigIntStr) | |
614 | + | let targetPrecision = parseBigIntValue(targetPrecisionBigIntStr) | |
615 | + | let x1 = parseBigIntValue(x1BigIntStr) | |
616 | + | let x2 = parseBigIntValue(x2BigIntStr) | |
617 | + | let amp = (parseBigIntValue(ampBigIntStr) * aPrecision) | |
618 | + | let s = (x1 + x2) | |
619 | + | if ((s == zeroBigInt)) | |
620 | + | then $Tuple2(nil, toString(zeroBigInt)) | |
621 | + | else { | |
622 | + | let ann = (amp * nCoins) | |
623 | + | let arr = [0, 1, 2, 3, 4, 5, 6] | |
624 | + | func calc (acc,cur) = { | |
625 | + | let $t02312123148 = acc | |
626 | + | let d = $t02312123148._1 | |
627 | + | let dPrev = $t02312123148._2 | |
628 | + | let found = $t02312123148._3 | |
629 | + | if ((found != unit)) | |
630 | + | then acc | |
631 | + | else { | |
632 | + | let dp = (((d * d) * d) / (((x1 * x2) * nCoins) * nCoins)) | |
633 | + | let dNext = (((((ann * s) / aPrecision) + (dp * nCoins)) * d) / ((((ann - aPrecision) * d) / aPrecision) + ((nCoins + toBigInt(1)) * dp))) | |
634 | + | let dDiff = absBigInt((dNext - value(d))) | |
635 | + | if ((targetPrecision >= dDiff)) | |
636 | + | then $Tuple3(dNext, d, cur) | |
637 | + | else $Tuple3(dNext, d, unit) | |
638 | + | } | |
639 | + | } | |
640 | + | ||
641 | + | let $t02374623809 = { | |
642 | + | let $l = arr | |
643 | + | let $s = size($l) | |
644 | + | let $acc0 = $Tuple3(s, unit, unit) | |
645 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
646 | + | then $a | |
647 | + | else calc($a, $l[$i]) | |
648 | + | ||
649 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
650 | + | then $a | |
651 | + | else throw("List size exceeds 7") | |
652 | + | ||
653 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7) | |
654 | + | } | |
655 | + | let dNext = $t02374623809._1 | |
656 | + | let dPrev = $t02374623809._2 | |
657 | + | let found = $t02374623809._3 | |
658 | + | if ((found != unit)) | |
659 | + | then $Tuple2(nil, toString(dNext)) | |
660 | + | else { | |
661 | + | let dDiff = absBigInt((dNext - value(dPrev))) | |
662 | + | throw(("D calculation error, dDiff = " + toString(dDiff))) | |
663 | + | } | |
664 | + | } | |
489 | 665 | } | |
490 | 666 | ||
491 | 667 | ||
492 | 668 | ||
493 | 669 | @Callable(i) | |
494 | 670 | func tradeReward (userAddresses,rewards) = { | |
495 | - | let suspensionCheck = throwIfSuspended() | |
496 | - | if ((suspensionCheck == suspensionCheck)) | |
671 | + | let argsComparison = (size(userAddresses) == size(rewards)) | |
672 | + | let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0) | |
673 | + | let payment = i.payments[0] | |
674 | + | let paymentAssetId = payment.assetId | |
675 | + | let paymentAmount = payment.amount | |
676 | + | let checks = [if ((maxRecipients >= size(userAddresses))) | |
677 | + | then true | |
678 | + | else throwErr("Too many recipients"), if (argsComparison) | |
679 | + | then true | |
680 | + | else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId)) | |
681 | + | then true | |
682 | + | else throwErr("Wrong asset payment")] | |
683 | + | if ((checks == checks)) | |
497 | 684 | then { | |
498 | - | let argsComparison = (size(userAddresses) == size(rewards)) | |
499 | - | let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0) | |
500 | - | let payment = i.payments[0] | |
501 | - | let paymentAssetId = payment.assetId | |
502 | - | let paymentAmount = payment.amount | |
503 | - | let checks = [if ((maxRecipients >= size(userAddresses))) | |
504 | - | then true | |
505 | - | else throwErr("Too many recipients"), if (argsComparison) | |
506 | - | then true | |
507 | - | else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId)) | |
508 | - | then true | |
509 | - | else throwErr("Wrong asset payment")] | |
510 | - | if ((checks == checks)) | |
511 | - | then { | |
512 | - | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil) | |
513 | - | if ((tradeRewardInternal == tradeRewardInternal)) | |
514 | - | then $Tuple2(nil, tradeRewardInternal) | |
515 | - | else throw("Strict value is not equal to itself.") | |
516 | - | } | |
685 | + | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil) | |
686 | + | if ((tradeRewardInternal == tradeRewardInternal)) | |
687 | + | then $Tuple2(nil, tradeRewardInternal) | |
517 | 688 | else throw("Strict value is not equal to itself.") | |
518 | 689 | } | |
519 | 690 | else throw("Strict value is not equal to itself.") | |
523 | 694 | ||
524 | 695 | @Callable(i) | |
525 | 696 | func claimTradingReward () = { | |
526 | - | let suspensionCheck = throwIfSuspended() | |
527 | - | if ((suspensionCheck == suspensionCheck)) | |
528 | - | then { | |
529 | - | let userAddress = i.caller | |
530 | - | let userAddressString = toString(userAddress) | |
531 | - | let reward = getTradingReward(userAddressString) | |
532 | - | if ((reward > 0)) | |
533 | - | then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId), IntegerEntry(keyTradingReward(userAddressString), 0)], reward) | |
534 | - | else throwErr("nothing to claim") | |
535 | - | } | |
536 | - | else throw("Strict value is not equal to itself.") | |
697 | + | let userAddress = i.caller | |
698 | + | let userAddressString = toString(userAddress) | |
699 | + | let reward = getTradingReward(userAddressString) | |
700 | + | if ((reward > 0)) | |
701 | + | then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId), IntegerEntry(keyTradingReward(userAddressString), 0)], reward) | |
702 | + | else throwErr("nothing to claim") | |
537 | 703 | } | |
538 | 704 | ||
539 | 705 | ||
540 | 706 | ||
541 | 707 | @Callable(i) | |
542 | 708 | func claimTradingRewardREADONLY (userAddress) = $Tuple2(nil, getTradingReward(userAddress)) | |
543 | - | ||
544 | - | ||
545 | - | ||
546 | - | @Callable(i) | |
547 | - | func suspend (v) = { | |
548 | - | let checkCaller = mustManager(i) | |
549 | - | if ((checkCaller == checkCaller)) | |
550 | - | then $Tuple2([BooleanEntry(keySuspension, v)], v) | |
551 | - | else throw("Strict value is not equal to itself.") | |
552 | - | } | |
553 | 709 | ||
554 | 710 | ||
555 | 711 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let SCALE = 1000 | |
7 | 7 | ||
8 | 8 | let MULT8 = 100000000 | |
9 | 9 | ||
10 | - | let MULT8BI = toBigInt(MULT8) | |
11 | - | ||
12 | 10 | let zeroBigInt = toBigInt(0) | |
13 | 11 | ||
14 | 12 | let processingStageTotal = 0 | |
15 | 13 | ||
16 | 14 | let processingStageShares = 1 | |
17 | 15 | ||
18 | - | let | |
16 | + | let wavesString = "WAVES" | |
19 | 17 | ||
20 | - | ||
18 | + | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
21 | 19 | ||
22 | - | let wavesString = "WAVES" | |
20 | + | ||
21 | + | func getNumberOrFail (key) = valueOrErrorMessage(getInteger(this, key), (("mandatory this." + key) + " is not defined")) | |
22 | + | ||
23 | + | ||
24 | + | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
25 | + | ||
26 | + | ||
27 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (("mandatory this." + key) + " is not defined")) | |
28 | + | ||
29 | + | ||
30 | + | func parseAssetId (input) = if ((input == wavesString)) | |
31 | + | then unit | |
32 | + | else fromBase58String(input) | |
33 | + | ||
23 | 34 | ||
24 | 35 | func wrapErr (msg) = makeString(["gwx_reward.ride:", msg], " ") | |
25 | 36 | ||
26 | 37 | ||
27 | 38 | func throwErr (msg) = throw(wrapErr(msg)) | |
28 | - | ||
29 | - | ||
30 | - | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
31 | - | ||
32 | - | ||
33 | - | func getNumberOrFail (key) = valueOrErrorMessage(getInteger(this, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
34 | - | ||
35 | - | ||
36 | - | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
37 | - | ||
38 | - | ||
39 | - | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
40 | - | ||
41 | - | ||
42 | - | func parseAssetId (input) = if ((input == wavesString)) | |
43 | - | then unit | |
44 | - | else fromBase58String(input) | |
45 | 39 | ||
46 | 40 | ||
47 | 41 | func abs (val) = if ((0 > val)) | |
48 | 42 | then -(val) | |
49 | 43 | else val | |
50 | 44 | ||
51 | 45 | ||
52 | 46 | func absBigInt (val) = if ((zeroBigInt > val)) | |
53 | 47 | then -(val) | |
54 | 48 | else val | |
55 | 49 | ||
56 | 50 | ||
57 | 51 | let keyMaxDepth = "%s__maxDepth" | |
58 | 52 | ||
59 | 53 | let maxDepthDefault = 30 | |
60 | 54 | ||
61 | 55 | let maxDepth = valueOrElse(getInteger(this, keyMaxDepth), maxDepthDefault) | |
62 | 56 | ||
63 | 57 | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
64 | 58 | ||
65 | 59 | ||
66 | 60 | let factoryAddressStr = getStringOrFail(keyFactoryAddress()) | |
67 | 61 | ||
68 | 62 | let factoryContract = addressFromStringValue(factoryAddressStr) | |
69 | 63 | ||
70 | 64 | func keyEmissionAddress () = "%s%s__config__emissionAddress" | |
71 | 65 | ||
72 | 66 | ||
73 | 67 | func keyVotingEmissionContract () = makeString(["%s", "votingEmissionContract"], SEP) | |
74 | 68 | ||
75 | 69 | ||
76 | 70 | let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract())) | |
77 | 71 | ||
78 | 72 | func keyNumToUserMapping (num) = makeString(["%s%s%s", "mapping", "num2user", toString(num)], SEP) | |
79 | 73 | ||
80 | 74 | ||
81 | 75 | let keyReferralProgramName = makeString(["%s%s", "referral", "programName"], SEP) | |
82 | 76 | ||
83 | 77 | let referralProgramNameDefault = "wxlock" | |
84 | 78 | ||
85 | 79 | let referralProgramName = valueOrElse(getString(this, keyReferralProgramName), referralProgramNameDefault) | |
86 | 80 | ||
87 | 81 | let keyReferralMinGWxAmount = makeString(["%s%s", "referral", "minGWxAmount"], SEP) | |
88 | 82 | ||
89 | 83 | let referralMinGWxAmountDefault = (500 * MULT8) | |
90 | 84 | ||
91 | 85 | let referralMinGWxAmount = valueOrElse(getInteger(this, keyReferralMinGWxAmount), referralMinGWxAmountDefault) | |
92 | 86 | ||
93 | 87 | let keyReferrerRewardPermille = makeString(["%s%s", "referral", "referrerRewardPermille"], SEP) | |
94 | 88 | ||
95 | 89 | let referrerRewardPermilleDefault = 50 | |
96 | 90 | ||
97 | 91 | let referrerRewardPermille = valueOrElse(getInteger(this, keyReferrerRewardPermille), referrerRewardPermilleDefault) | |
98 | 92 | ||
99 | 93 | let keyReferralRewardPermille = makeString(["%s%s", "referral", "referralRewardPermille"], SEP) | |
100 | 94 | ||
101 | 95 | let referralRewardPermilleDefault = 50 | |
102 | 96 | ||
103 | 97 | let referralRewardPermille = valueOrElse(getInteger(this, keyReferralRewardPermille), referralRewardPermilleDefault) | |
104 | 98 | ||
105 | 99 | func keyReferrer (referralAddress) = makeString(["%s%s%s", "referrer", referralProgramName, referralAddress], SEP) | |
106 | 100 | ||
107 | 101 | ||
108 | 102 | func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferral", programName, claimerAddress], SEP) | |
109 | 103 | ||
110 | 104 | ||
111 | 105 | let emissionAddressStr = getStringOrFail(keyEmissionAddress()) | |
112 | 106 | ||
113 | 107 | let emissionContract = addressFromStringValue(emissionAddressStr) | |
114 | 108 | ||
115 | 109 | let IdxCfgAssetId = 1 | |
116 | 110 | ||
117 | 111 | let IdxCfgPacemakerAddress = 2 | |
118 | 112 | ||
119 | 113 | let IdxCfgBoostingContract = 3 | |
120 | 114 | ||
121 | 115 | let IdxCfgMaxDepth = 4 | |
122 | 116 | ||
123 | 117 | func keyConfig () = "%s__config" | |
124 | 118 | ||
125 | 119 | ||
126 | 120 | func getEmissionAddress () = addressFromStringValue(valueOrErrorMessage(getString(this, keyEmissionAddress()), (("mandatory this." + keyEmissionAddress()) + " is not defined"))) | |
127 | 121 | ||
128 | 122 | ||
129 | 123 | let emissionAddress = getEmissionAddress() | |
130 | 124 | ||
131 | 125 | let wxAssetIdStr = split(value(getString(emissionAddress, keyConfig())), SEP)[1] | |
132 | 126 | ||
133 | 127 | let wxAssetId = fromBase58String(wxAssetIdStr) | |
134 | 128 | ||
135 | 129 | func readConfigArrayOrFail () = split(getStringOrFail(keyConfig()), SEP) | |
136 | 130 | ||
137 | 131 | ||
138 | 132 | func formatConfig (wxAssetIdStr,matcherPacemakerAddressStr,boostingContractAddressStr,maxDepth) = makeString(["%s%s%s%d", wxAssetIdStr, matcherPacemakerAddressStr, boostingContractAddressStr, toString(maxDepth)], SEP) | |
139 | 133 | ||
140 | 134 | ||
141 | 135 | func boostingContractOrFail () = { | |
142 | 136 | let cfgArray = readConfigArrayOrFail() | |
143 | 137 | valueOrErrorMessage(addressFromString(cfgArray[IdxCfgBoostingContract]), "boosting contract address is not defined") | |
144 | 138 | } | |
145 | 139 | ||
146 | 140 | ||
147 | - | let keySuspension = "%s__suspension" | |
148 | - | ||
149 | - | let isSuspended = valueOrElse(getBoolean(this, keySuspension), false) | |
150 | - | ||
151 | - | func throwIfSuspended () = if (!(isSuspended)) | |
152 | - | then true | |
153 | - | else throwErr("suspended") | |
154 | - | ||
155 | - | ||
156 | 141 | func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight" | |
157 | 142 | ||
158 | 143 | ||
159 | 144 | func keyUsersCount () = "%s__nextUserNum" | |
160 | - | ||
161 | - | ||
162 | - | func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", toString(userAddress)], SEP) | |
163 | 145 | ||
164 | 146 | ||
165 | 147 | func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
166 | 148 | ||
167 | 149 | ||
168 | 150 | func keyGwxHoldersRewardCurrent () = "%s%s__gwxHoldersReward__current" | |
169 | 151 | ||
170 | 152 | ||
171 | 153 | func keyGwxHoldersRewardNext () = "%s%s__gwxHoldersReward__next" | |
172 | 154 | ||
173 | 155 | ||
174 | 156 | func keyPoolWeightVirtual () = "%s%s__poolWeight__GWXvirtualPOOL" | |
175 | 157 | ||
176 | 158 | ||
159 | + | func keyNextProcessedUser () = "%s__nextProcessedUser" | |
160 | + | ||
161 | + | ||
162 | + | func keyLatestPeriod () = "%s__latestPeriod" | |
163 | + | ||
164 | + | ||
165 | + | func keyNextPeriod () = "%s__nextPeriod" | |
166 | + | ||
167 | + | ||
168 | + | func keyProcessingStage () = "%s__processingStage" | |
169 | + | ||
170 | + | ||
171 | + | func keyNextProcessedPeriod () = "%s__nextProcessedPeriod" | |
172 | + | ||
173 | + | ||
177 | 174 | func keyUserUnclaimed (userIndex) = makeString(["%s%d", "userUnclaimed", toString(userIndex)], SEP) | |
175 | + | ||
176 | + | ||
177 | + | func keyNextUnlaimedPeriodOfUser (userIndex) = makeString(["%s%d__nextClaimedPeriod", toString(userIndex)], SEP) | |
178 | + | ||
179 | + | ||
180 | + | func keyLastProcessedPeriodOfUser (userIndex) = makeString(["%s%d__lastProcessedPeriod", toString(userIndex)], SEP) | |
181 | + | ||
182 | + | ||
183 | + | func keyHeightForPeriod (period) = makeString(["%s%d__startHeightForPeriod", toString(period)], SEP) | |
184 | + | ||
185 | + | ||
186 | + | func keyAuxEmissionRewardForPeriod (period) = makeString(["%s%d__auxEmissionReward", toString(period)], SEP) | |
187 | + | ||
188 | + | ||
189 | + | func keyTotalAmountForPeriod (period) = makeString(["%s%d__totalAmountForPeriod", toString(period)], SEP) | |
190 | + | ||
191 | + | ||
192 | + | func keyLastPayoutInfo () = "%s__lastPayoutInfo" | |
193 | + | ||
194 | + | ||
195 | + | func PeriodPayoutInfo (period,matcherReward,emissionReward) = makeString(["%d%d%d", toString(period), toString(matcherReward), toString(emissionReward)], SEP) | |
196 | + | ||
197 | + | ||
198 | + | func keyPayoutHistoryInfo (period) = makeString(["%s%s%d__payouts__history", toString(period)], SEP) | |
199 | + | ||
200 | + | ||
201 | + | func keyTotalWeightForPeriod (period) = makeString(["%s%d__totalWeightForPeriod", toString(period)], SEP) | |
202 | + | ||
203 | + | ||
204 | + | func keyUserKValueForPeriod (period,userIndex) = makeString(["%s%d%s%d__paramByPeriod", toString(userIndex), "k", toString(period)], SEP) | |
205 | + | ||
206 | + | ||
207 | + | func keyUserBValueForPeriod (period,userIndex) = makeString(["%s%d%s%d__paramByPeriod", toString(userIndex), "b", toString(period)], SEP) | |
208 | + | ||
209 | + | ||
210 | + | func keyUserWeightForPeriod (period,userIndex) = makeString(["%s%d%s%d__paramByPeriod", toString(userIndex), "weight", toString(period)], SEP) | |
178 | 211 | ||
179 | 212 | ||
180 | 213 | func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP) | |
181 | 214 | ||
182 | 215 | ||
183 | 216 | let referralsContractAddressOrFail = addressFromStringValue(getStringOrFail(keyReferralsContractAddress())) | |
184 | 217 | ||
185 | 218 | func keyTradingRewardHistory (user,i) = makeString(["%s%s%s%s", "tradingReward", "history", user, toBase58String(i.transactionId)], SEP) | |
186 | 219 | ||
187 | 220 | ||
188 | 221 | func keyTradingReward (userAddress) = makeString(["%s%s", "tradingReward", userAddress], SEP) | |
189 | 222 | ||
190 | 223 | ||
191 | 224 | func keyMaxRecipients () = makeString(["%s", "maxRecipients"], SEP) | |
192 | 225 | ||
193 | 226 | ||
194 | 227 | func HistoryEntry (type,user,amount,i) = { | |
195 | 228 | let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP) | |
196 | 229 | let historyDATA = makeString(["%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount)], SEP) | |
197 | 230 | StringEntry(historyKEY, historyDATA) | |
198 | 231 | } | |
199 | 232 | ||
200 | 233 | ||
201 | 234 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
202 | 235 | ||
203 | 236 | ||
204 | 237 | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
205 | 238 | ||
206 | 239 | ||
207 | 240 | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
208 | 241 | case s: String => | |
209 | 242 | addressFromStringValue(s) | |
210 | 243 | case _ => | |
211 | 244 | this | |
212 | 245 | } | |
213 | 246 | ||
214 | 247 | ||
215 | 248 | func managerPublicKeyOrUnit () = { | |
216 | 249 | let managerVaultAddress = getManagerVaultAddressOrThis() | |
217 | 250 | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
218 | 251 | case s: String => | |
219 | 252 | fromBase58String(s) | |
220 | 253 | case _: Unit => | |
221 | 254 | unit | |
222 | 255 | case _ => | |
223 | 256 | throw("Match error") | |
224 | 257 | } | |
225 | 258 | } | |
226 | 259 | ||
227 | 260 | ||
228 | 261 | func mustManager (i) = { | |
229 | 262 | let pd = throw("Permission denied") | |
230 | 263 | match managerPublicKeyOrUnit() { | |
231 | 264 | case pk: ByteVector => | |
232 | 265 | if ((i.callerPublicKey == pk)) | |
233 | 266 | then true | |
234 | 267 | else pd | |
235 | 268 | case _: Unit => | |
236 | 269 | if ((i.caller == this)) | |
237 | 270 | then true | |
238 | 271 | else pd | |
239 | 272 | case _ => | |
240 | 273 | throw("Match error") | |
241 | 274 | } | |
242 | 275 | } | |
243 | 276 | ||
244 | 277 | ||
278 | + | func calcUserWeight (boostingContractAddress,heightForPeriod,period,userIndex) = { | |
279 | + | let kLast = keyLastProcessedPeriodOfUser(userIndex) | |
280 | + | let kKey = keyUserKValueForPeriod(period, userIndex) | |
281 | + | let kRaw = getInteger(boostingContractAddress, kKey) | |
282 | + | let kUserWeight = keyUserWeightForPeriod(period, userIndex) | |
283 | + | if (isDefined(kRaw)) | |
284 | + | then { | |
285 | + | let k = value(kRaw) | |
286 | + | let b = value(getInteger(boostingContractAddress, keyUserBValueForPeriod(period, userIndex))) | |
287 | + | let w = ((k * heightForPeriod) + b) | |
288 | + | if ((w > 0)) | |
289 | + | then $Tuple2((w / SCALE), [IntegerEntry(kLast, period), IntegerEntry(kUserWeight, w)]) | |
290 | + | else $Tuple2(0, nil) | |
291 | + | } | |
292 | + | else { | |
293 | + | let p = getInteger(this, kLast) | |
294 | + | if (if (isDefined(p)) | |
295 | + | then (period >= value(p)) | |
296 | + | else false) | |
297 | + | then { | |
298 | + | let pv = value(p) | |
299 | + | let k = value(getInteger(boostingContractAddress, keyUserKValueForPeriod(pv, userIndex))) | |
300 | + | let b = value(getInteger(boostingContractAddress, keyUserBValueForPeriod(pv, userIndex))) | |
301 | + | let w = ((k * heightForPeriod) + b) | |
302 | + | if ((w > 0)) | |
303 | + | then $Tuple2((w / SCALE), [IntegerEntry(kUserWeight, w)]) | |
304 | + | else $Tuple2(0, nil) | |
305 | + | } | |
306 | + | else $Tuple2(0, nil) | |
307 | + | } | |
308 | + | } | |
309 | + | ||
310 | + | ||
311 | + | func calcUserWeightForClaim (boostingContractAddress,heightForPeriod,period,userIndex) = { | |
312 | + | let kUserWeight = keyUserWeightForPeriod(period, userIndex) | |
313 | + | let userWeightOrUnit = getInteger(kUserWeight) | |
314 | + | match userWeightOrUnit { | |
315 | + | case _: Unit => | |
316 | + | 0 | |
317 | + | case w: Int => | |
318 | + | (w / SCALE) | |
319 | + | case _ => | |
320 | + | throw("Match error") | |
321 | + | } | |
322 | + | } | |
323 | + | ||
324 | + | ||
245 | 325 | func getUserIndexByAddress (boostingContractAddressStr,userAddress) = { | |
246 | 326 | let key = makeString(["%s%s%s", "mapping", "user2num", userAddress], SEP) | |
247 | 327 | parseIntValue(valueOrErrorMessage(getString(Address(fromBase58String(boostingContractAddressStr)), key), ((("User address " + userAddress) + " is not found in boosting contract data, key=") + key))) | |
248 | 328 | } | |
249 | 329 | ||
250 | 330 | ||
331 | + | func nextPeriod () = getNumberByKey(keyNextPeriod()) | |
332 | + | ||
333 | + | ||
334 | + | func commonClaimReward (userAddress) = { | |
335 | + | let cfgArray = readConfigArrayOrFail() | |
336 | + | let userIdx = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddress) | |
337 | + | let userUnclaimedOption = getInteger(keyUserUnclaimed(userIdx)) | |
338 | + | match userUnclaimedOption { | |
339 | + | case _: Unit => | |
340 | + | $Tuple2(0, nil) | |
341 | + | case u: Int => | |
342 | + | $Tuple2(u, [IntegerEntry(keyUserUnclaimed(userIdx), 0)]) | |
343 | + | case _ => | |
344 | + | throw("Match error") | |
345 | + | } | |
346 | + | } | |
347 | + | ||
348 | + | ||
251 | 349 | func getTradingReward (userAddress) = valueOrElse(getInteger(this, keyTradingReward(userAddress)), 0) | |
252 | 350 | ||
253 | 351 | ||
254 | - | func keyRewardPerGwxIntegral () = makeString(["%s", "rewardPerGwxIntegral"], SEP) | |
352 | + | @Callable(i) | |
353 | + | func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = if ((currentIter == size(userAddresses))) | |
354 | + | then nil | |
355 | + | else { | |
356 | + | let checks = [if ((i.caller == this)) | |
357 | + | then true | |
358 | + | else throwErr("Permission denied"), if ((paymentAmountLeftOver >= rewards[currentIter])) | |
359 | + | then true | |
360 | + | else throwErr("insufficient payment assetId")] | |
361 | + | if ((checks == checks)) | |
362 | + | then { | |
363 | + | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [(paymentAmountLeftOver - rewards[currentIter]), userAddresses, rewards, (currentIter + 1)], nil) | |
364 | + | if ((tradeRewardInternal == tradeRewardInternal)) | |
365 | + | then { | |
366 | + | let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i) | |
367 | + | let userAddress = addressFromStringValue(userAddresses[currentIter]) | |
368 | + | $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), IntegerEntry(keyTradingReward(userAddresses[currentIter]), rewards[currentIter])], tradeRewardInternal) | |
369 | + | } | |
370 | + | else throw("Strict value is not equal to itself.") | |
371 | + | } | |
372 | + | else throw("Strict value is not equal to itself.") | |
373 | + | } | |
255 | 374 | ||
256 | - | ||
257 | - | func getGwxAmountTotalOption () = { | |
258 | - | let keyGwxTotal = "%s%s__gwx__total" | |
259 | - | getInteger(boostingContractOrFail(), keyGwxTotal) | |
260 | - | } | |
261 | - | ||
262 | - | ||
263 | - | func getUserGwxAmountTotalOption (userAddress) = { | |
264 | - | func keyUserGwxAmountTotal (userAddress) = makeString(["%s%s__gwxAmountTotal", toString(userAddress)], SEP) | |
265 | - | ||
266 | - | getInteger(boostingContractOrFail(), keyUserGwxAmountTotal(userAddress)) | |
267 | - | } | |
268 | - | ||
269 | - | ||
270 | - | func _refreshRewardPerGwxIntegral () = { | |
271 | - | let rewardPerGwxIntegralPrevious = valueOrElse( match getString(this, keyRewardPerGwxIntegral()) { | |
272 | - | case s: String => | |
273 | - | parseBigInt(s) | |
274 | - | case _: Unit => | |
275 | - | unit | |
276 | - | case _ => | |
277 | - | throw("Match error") | |
278 | - | }, zeroBigInt) | |
279 | - | let rewardPerGwxIntegralLastHeight = valueOrErrorMessage(getInteger(this, keyGwxRewardEmissionStartHeight()), wrapErr(("invalid " + keyGwxRewardEmissionStartHeight()))) | |
280 | - | let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), wrapErr(("invalid " + keyRatePerBlockCurrent()))) | |
281 | - | let gwxHoldersRewardCurrent = valueOrElse(getInteger(emissionContract, keyGwxHoldersRewardCurrent()), 0) | |
282 | - | let gwxAmountTotal = valueOrElse(getGwxAmountTotalOption(), 0) | |
283 | - | let dh = toBigInt((height - rewardPerGwxIntegralLastHeight)) | |
284 | - | let gwxAmountTotalBI = toBigInt(gwxAmountTotal) | |
285 | - | let rewardPerGwxIntegral = (rewardPerGwxIntegralPrevious + (if ((gwxAmountTotalBI == zeroBigInt)) | |
286 | - | then zeroBigInt | |
287 | - | else fraction(dh, ((toBigInt(emissionRate) * toBigInt(gwxHoldersRewardCurrent)) * MULT18BI), (gwxAmountTotalBI * MULT8BI)))) | |
288 | - | $Tuple2([IntegerEntry(keyGwxRewardEmissionStartHeight(), height), StringEntry(keyRewardPerGwxIntegral(), toString(rewardPerGwxIntegral))], rewardPerGwxIntegral) | |
289 | - | } | |
290 | - | ||
291 | - | ||
292 | - | func keyRewardPerGwxIntegralUserLast (userAddress) = makeString(["%s%s", "rewardPerGwxIntegralUserLast", toString(userAddress)], SEP) | |
293 | - | ||
294 | - | ||
295 | - | func _refreshUserReward (userAddress,userNum) = { | |
296 | - | let $t01029210380 = _refreshRewardPerGwxIntegral() | |
297 | - | let rewardPerGwxIntegralActions = $t01029210380._1 | |
298 | - | let rewardPerGwxIntegral = $t01029210380._2 | |
299 | - | let rewardPerGwxIntegralUserLast = match getString(this, keyRewardPerGwxIntegralUserLast(userAddress)) { | |
300 | - | case s: String => | |
301 | - | valueOrErrorMessage(parseBigInt(s), wrapErr("invalid user last integral")) | |
302 | - | case _: Unit => | |
303 | - | rewardPerGwxIntegral | |
304 | - | case _ => | |
305 | - | throw("Match error") | |
306 | - | } | |
307 | - | let userIdxOption = getString(boostingContractOrFail(), keyUser2NumMapping(userAddress)) | |
308 | - | let userUnclaimed = valueOrElse(getInteger(keyUserUnclaimed(userNum)), 0) | |
309 | - | let userGwxAmount = valueOrElse(getUserGwxAmountTotalOption(userAddress), 0) | |
310 | - | let userReward = (toInt(fraction(toBigInt(userGwxAmount), (rewardPerGwxIntegral - rewardPerGwxIntegralUserLast), MULT18BI)) + userUnclaimed) | |
311 | - | $Tuple2(([StringEntry(keyRewardPerGwxIntegralUserLast(userAddress), toString(rewardPerGwxIntegral))] ++ rewardPerGwxIntegralActions), userReward) | |
312 | - | } | |
313 | - | ||
314 | - | ||
315 | - | func commonClaimReward (userAddressStr) = { | |
316 | - | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
317 | - | let cfgArray = readConfigArrayOrFail() | |
318 | - | let userNum = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddressStr) | |
319 | - | let $t01167111735 = _refreshUserReward(userAddress, userNum) | |
320 | - | let actions = $t01167111735._1 | |
321 | - | let reward = $t01167111735._2 | |
322 | - | $Tuple2(reward, ([IntegerEntry(keyUserUnclaimed(userNum), 0)] ++ actions)) | |
323 | - | } | |
324 | 375 | ||
325 | 376 | ||
326 | 377 | @Callable(i) | |
327 | - | func refreshUserReward (userAddressBytes,userNum) = { | |
328 | - | let suspensionCheck = throwIfSuspended() | |
329 | - | if ((suspensionCheck == suspensionCheck)) | |
330 | - | then { | |
331 | - | let checkCaller = if ((i.caller == boostingContractOrFail())) | |
332 | - | then true | |
333 | - | else throwErr("permission denied") | |
334 | - | if ((checkCaller == checkCaller)) | |
335 | - | then { | |
336 | - | let $t01206112139 = _refreshUserReward(Address(userAddressBytes), userNum) | |
337 | - | let actions = $t01206112139._1 | |
338 | - | let reward = $t01206112139._2 | |
339 | - | $Tuple2(([IntegerEntry(keyUserUnclaimed(userNum), reward)] ++ actions), reward) | |
340 | - | } | |
341 | - | else throw("Strict value is not equal to itself.") | |
342 | - | } | |
378 | + | func updateReferralActivity (userAddress,gWxAmountStart) = { | |
379 | + | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
380 | + | let activeReferralInv = if ((referrer == unit)) | |
381 | + | then unit | |
382 | + | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil) | |
383 | + | if ((activeReferralInv == activeReferralInv)) | |
384 | + | then $Tuple2(nil, unit) | |
343 | 385 | else throw("Strict value is not equal to itself.") | |
344 | 386 | } | |
345 | 387 | ||
346 | 388 | ||
347 | 389 | ||
348 | 390 | @Callable(i) | |
349 | - | func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = { | |
350 | - | let suspensionCheck = throwIfSuspended() | |
351 | - | if ((suspensionCheck == suspensionCheck)) | |
352 | - | then if ((currentIter == size(userAddresses))) | |
353 | - | then nil | |
354 | - | else { | |
355 | - | let checks = [if ((i.caller == this)) | |
356 | - | then true | |
357 | - | else throwErr("Permission denied"), if ((paymentAmountLeftOver >= rewards[currentIter])) | |
358 | - | then true | |
359 | - | else throwErr("insufficient payment assetId")] | |
360 | - | if ((checks == checks)) | |
361 | - | then { | |
362 | - | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [(paymentAmountLeftOver - rewards[currentIter]), userAddresses, rewards, (currentIter + 1)], nil) | |
363 | - | if ((tradeRewardInternal == tradeRewardInternal)) | |
364 | - | then { | |
365 | - | let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i) | |
366 | - | let userAddress = addressFromStringValue(userAddresses[currentIter]) | |
367 | - | $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), IntegerEntry(keyTradingReward(userAddresses[currentIter]), rewards[currentIter])], tradeRewardInternal) | |
368 | - | } | |
369 | - | else throw("Strict value is not equal to itself.") | |
370 | - | } | |
371 | - | else throw("Strict value is not equal to itself.") | |
391 | + | func finalizeHelper () = { | |
392 | + | let processingStage = valueOrElse(getInteger(keyProcessingStage()), processingStageTotal) | |
393 | + | let currentPeriod = getNumberByKey(keyNextProcessedPeriod()) | |
394 | + | let currentUser = getNumberByKey(keyNextProcessedUser()) | |
395 | + | let latestPeriod = getNumberByKey(keyLatestPeriod()) | |
396 | + | let usersCount = valueOrElse(getInteger(boostingContractOrFail(), keyUsersCount()), 0) | |
397 | + | let totalWeightKey = keyTotalWeightForPeriod(currentPeriod) | |
398 | + | let totalWeight = getNumberByKey(keyTotalWeightForPeriod(currentPeriod)) | |
399 | + | let heightForPeriod = getNumberByKey(keyHeightForPeriod(currentPeriod)) | |
400 | + | if ((currentPeriod > latestPeriod)) | |
401 | + | then $Tuple2(nil, false) | |
402 | + | else if ((processingStage == processingStageTotal)) | |
403 | + | then { | |
404 | + | let $t01451014626 = calcUserWeight(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser) | |
405 | + | let userWeight = $t01451014626._1 | |
406 | + | let userActions = $t01451014626._2 | |
407 | + | let totalWeightNew = (totalWeight + userWeight) | |
408 | + | let processingActions = if (((usersCount - 1) > currentUser)) | |
409 | + | then [IntegerEntry(keyNextProcessedUser(), (currentUser + 1))] | |
410 | + | else [IntegerEntry(keyProcessingStage(), processingStageShares), IntegerEntry(keyNextProcessedUser(), 0)] | |
411 | + | $Tuple2((([IntegerEntry(totalWeightKey, totalWeightNew)] ++ processingActions) ++ userActions), true) | |
372 | 412 | } | |
413 | + | else if ((processingStage == processingStageShares)) | |
414 | + | then { | |
415 | + | let userWeight = calcUserWeightForClaim(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser) | |
416 | + | let userAmountMatcherForPeriod = fraction(getNumberByKey(keyTotalAmountForPeriod(currentPeriod)), userWeight, totalWeight) | |
417 | + | let userAmountEmissionForPeriod = fraction(getNumberByKey(keyAuxEmissionRewardForPeriod(currentPeriod)), userWeight, totalWeight) | |
418 | + | let userTotalAmount = (userAmountEmissionForPeriod + userAmountMatcherForPeriod) | |
419 | + | let userUnclaimedOption = getInteger(keyUserUnclaimed(currentUser)) | |
420 | + | let userAddress = getStringValue(boostingContractOrFail(), keyNumToUserMapping(currentUser)) | |
421 | + | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
422 | + | let activeReferralInv = if ((referrer == unit)) | |
423 | + | then unit | |
424 | + | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userWeight >= referralMinGWxAmount)], nil) | |
425 | + | if ((activeReferralInv == activeReferralInv)) | |
426 | + | then { | |
427 | + | let referralInv = if (if ((referrer == unit)) | |
428 | + | then true | |
429 | + | else (referralMinGWxAmount > userWeight)) | |
430 | + | then unit | |
431 | + | else { | |
432 | + | let referrerReward = fraction(userTotalAmount, referrerRewardPermille, SCALE) | |
433 | + | let referralReward = fraction(userTotalAmount, referralRewardPermille, SCALE) | |
434 | + | invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil) | |
435 | + | } | |
436 | + | if ((referralInv == referralInv)) | |
437 | + | then { | |
438 | + | let unclaimedActions = [IntegerEntry(keyUserUnclaimed(currentUser), (valueOrElse(userUnclaimedOption, 0) + userTotalAmount))] | |
439 | + | let processingActions = if (((usersCount - 1) > currentUser)) | |
440 | + | then [IntegerEntry(keyNextProcessedUser(), (currentUser + 1))] | |
441 | + | else [IntegerEntry(keyNextProcessedPeriod(), (currentPeriod + 1)), IntegerEntry(keyNextProcessedUser(), 0), DeleteEntry(keyProcessingStage())] | |
442 | + | $Tuple2((unclaimedActions ++ processingActions), true) | |
443 | + | } | |
444 | + | else throw("Strict value is not equal to itself.") | |
445 | + | } | |
446 | + | else throw("Strict value is not equal to itself.") | |
447 | + | } | |
448 | + | else throw("invalid processing stage") | |
449 | + | } | |
450 | + | ||
451 | + | ||
452 | + | ||
453 | + | @Callable(i) | |
454 | + | func finalizeWrapper (counter) = { | |
455 | + | let result = { | |
456 | + | let @ = invoke(this, "finalizeHelper", nil, nil) | |
457 | + | if ($isInstanceOf(@, "Boolean")) | |
458 | + | then @ | |
459 | + | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
460 | + | } | |
461 | + | if ((result == result)) | |
462 | + | then if (!(result)) | |
463 | + | then if ((counter == maxDepth)) | |
464 | + | then throw("Nothing to process") | |
465 | + | else $Tuple2(nil, unit) | |
466 | + | else if ((counter > 0)) | |
467 | + | then $Tuple2(nil, invoke(this, "finalizeWrapper", [(counter - 1)], nil)) | |
468 | + | else $Tuple2(nil, unit) | |
373 | 469 | else throw("Strict value is not equal to itself.") | |
374 | 470 | } | |
375 | 471 | ||
376 | 472 | ||
377 | 473 | ||
378 | 474 | @Callable(i) | |
379 | - | func updateReferralActivity (userAddress,gWxAmountStart) = { | |
380 | - | let suspensionCheck = throwIfSuspended() | |
381 | - | if ((suspensionCheck == suspensionCheck)) | |
382 | - | then { | |
383 | - | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
384 | - | let activeReferralInv = if ((referrer == unit)) | |
385 | - | then unit | |
386 | - | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil) | |
387 | - | if ((activeReferralInv == activeReferralInv)) | |
388 | - | then $Tuple2(nil, unit) | |
389 | - | else throw("Strict value is not equal to itself.") | |
390 | - | } | |
391 | - | else throw("Strict value is not equal to itself.") | |
392 | - | } | |
475 | + | func processPendingPeriodsAndUsers () = $Tuple2(nil, invoke(this, "finalizeWrapper", [maxDepth], nil)) | |
393 | 476 | ||
394 | 477 | ||
395 | 478 | ||
396 | 479 | @Callable(i) | |
397 | - | func processPendingPeriodsAndUsers () = $Tuple2(nil, throwErr("deprecated")) | |
398 | - | ||
399 | - | ||
400 | - | ||
401 | - | @Callable(i) | |
402 | - | func claimReward () = { | |
403 | - | let suspensionCheck = throwIfSuspended() | |
404 | - | if ((suspensionCheck == suspensionCheck)) | |
480 | + | func deposit () = { | |
481 | + | let checkCaller = if ((i.caller == votingEmissionContract)) | |
482 | + | then true | |
483 | + | else mustManager(i) | |
484 | + | if ((checkCaller == checkCaller)) | |
405 | 485 | then { | |
406 | - | let cfgArray = readConfigArrayOrFail() | |
407 | - | let userAddress = i.caller | |
408 | - | let userAddressStr = toString(userAddress) | |
409 | - | let $t01400914066 = commonClaimReward(userAddressStr) | |
410 | - | let amount = $t01400914066._1 | |
411 | - | let actions = $t01400914066._2 | |
412 | - | let checkAmount = if ((amount > 0)) | |
413 | - | then true | |
414 | - | else throw("nothing to claim") | |
415 | - | if ((checkAmount == checkAmount)) | |
486 | + | let period = nextPeriod() | |
487 | + | let deltaH = (height - getNumberOrFail(keyGwxRewardEmissionStartHeight())) | |
488 | + | let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), (("mandatory emission_contract." + keyRatePerBlockCurrent()) + " is not defined")) | |
489 | + | let gwxHoldersRewardCurrent = valueOrElse(getInteger(emissionContract, keyGwxHoldersRewardCurrent()), 0) | |
490 | + | if ((gwxHoldersRewardCurrent == gwxHoldersRewardCurrent)) | |
416 | 491 | then { | |
417 | - | let userGwxAmount = { | |
418 | - | let @ = invoke(boostingContractOrFail(), "getUserGwxAmount", [userAddressStr], nil) | |
419 | - | if ($isInstanceOf(@, "Int")) | |
420 | - | then @ | |
421 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
422 | - | } | |
423 | - | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddressStr)) | |
424 | - | let activeReferralInv = if ((referrer == unit)) | |
425 | - | then unit | |
426 | - | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userGwxAmount >= referralMinGWxAmount)], nil) | |
427 | - | if ((activeReferralInv == activeReferralInv)) | |
492 | + | let auxAmount = fraction((deltaH * gwxHoldersRewardCurrent), emissionRate, MULT8) | |
493 | + | let em = if ((auxAmount > 0)) | |
494 | + | then invoke(emissionContract, "emit", [auxAmount], nil) | |
495 | + | else unit | |
496 | + | if ((em == em)) | |
428 | 497 | then { | |
429 | - | let referralInv = if (if ((referrer == unit)) | |
430 | - | then true | |
431 | - | else (referralMinGWxAmount > userGwxAmount)) | |
432 | - | then unit | |
433 | - | else { | |
434 | - | let referrerReward = fraction(amount, referrerRewardPermille, SCALE) | |
435 | - | let referralReward = fraction(amount, referralRewardPermille, SCALE) | |
436 | - | invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil) | |
437 | - | } | |
438 | - | if ((referralInv == referralInv)) | |
498 | + | let matcherPart = 0 | |
499 | + | let payoutInfo = PeriodPayoutInfo(period, matcherPart, auxAmount) | |
500 | + | let gwxHoldersRewardUpdated = { | |
501 | + | let @ = invoke(emissionContract, "gwxHoldersRewardUpdate", nil, nil) | |
502 | + | if ($isInstanceOf(@, "Boolean")) | |
503 | + | then @ | |
504 | + | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
505 | + | } | |
506 | + | if ((gwxHoldersRewardUpdated == gwxHoldersRewardUpdated)) | |
439 | 507 | then { | |
440 | - | let emit = invoke(emissionContract, "emit", [amount], nil) | |
441 | - | if ((emit == emit)) | |
442 | - | then { | |
443 | - | let claimedReferral = { | |
444 | - | let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil) | |
445 | - | if ($isInstanceOf(@, "Int")) | |
446 | - | then @ | |
447 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
448 | - | } | |
449 | - | if ((claimedReferral == claimedReferral)) | |
450 | - | then { | |
451 | - | let totalAmount = (amount + claimedReferral) | |
452 | - | $Tuple2(([ScriptTransfer(i.caller, amount, wxAssetId), HistoryEntry("claim", userAddressStr, totalAmount, i)] ++ actions), totalAmount) | |
453 | - | } | |
454 | - | else throw("Strict value is not equal to itself.") | |
455 | - | } | |
456 | - | else throw("Strict value is not equal to itself.") | |
508 | + | let totalReward = (matcherPart + auxAmount) | |
509 | + | let actions = if (if ((totalReward == 0)) | |
510 | + | then !(gwxHoldersRewardUpdated) | |
511 | + | else false) | |
512 | + | then nil | |
513 | + | else [IntegerEntry(keyLatestPeriod(), period), IntegerEntry(keyHeightForPeriod(period), height), IntegerEntry(keyAuxEmissionRewardForPeriod(period), auxAmount), IntegerEntry(keyGwxRewardEmissionStartHeight(), height), IntegerEntry(keyTotalAmountForPeriod(period), matcherPart), IntegerEntry(keyNextPeriod(), (period + 1)), StringEntry(keyLastPayoutInfo(), payoutInfo), StringEntry(keyPayoutHistoryInfo(period), payoutInfo)] | |
514 | + | $Tuple2(actions, unit) | |
457 | 515 | } | |
458 | 516 | else throw("Strict value is not equal to itself.") | |
459 | 517 | } | |
460 | 518 | else throw("Strict value is not equal to itself.") | |
461 | 519 | } | |
462 | 520 | else throw("Strict value is not equal to itself.") | |
463 | 521 | } | |
464 | 522 | else throw("Strict value is not equal to itself.") | |
465 | 523 | } | |
466 | 524 | ||
467 | 525 | ||
468 | 526 | ||
469 | 527 | @Callable(i) | |
528 | + | func claimReward () = { | |
529 | + | let cfgArray = readConfigArrayOrFail() | |
530 | + | let address = toString(i.caller) | |
531 | + | let $t01981519865 = commonClaimReward(address) | |
532 | + | let amount = $t01981519865._1 | |
533 | + | let actions = $t01981519865._2 | |
534 | + | let checkAmount = if ((amount > 0)) | |
535 | + | then true | |
536 | + | else throw("Nothing to claim") | |
537 | + | if ((checkAmount == checkAmount)) | |
538 | + | then { | |
539 | + | let amountFromEmission = 0 | |
540 | + | let claimedReferral = { | |
541 | + | let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil) | |
542 | + | if ($isInstanceOf(@, "Int")) | |
543 | + | then @ | |
544 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
545 | + | } | |
546 | + | let totalAmount = (amount + claimedReferral) | |
547 | + | $Tuple2(([ScriptTransfer(i.caller, totalAmount, fromBase58String(cfgArray[IdxCfgAssetId])), HistoryEntry("claim", address, amount, i)] ++ actions), [totalAmount, amountFromEmission]) | |
548 | + | } | |
549 | + | else throw("Strict value is not equal to itself.") | |
550 | + | } | |
551 | + | ||
552 | + | ||
553 | + | ||
554 | + | @Callable(i) | |
470 | 555 | func claimRewardREADONLY (address) = { | |
471 | - | let $ | |
472 | - | let amount = $ | |
473 | - | let actions = $ | |
556 | + | let $t02043820488 = commonClaimReward(address) | |
557 | + | let amount = $t02043820488._1 | |
558 | + | let actions = $t02043820488._2 | |
474 | 559 | let referralUnclaimed = valueOrElse(getInteger(referralsContractAddressOrFail, keyUnclaimedReferral(referralProgramName, address)), 0) | |
475 | 560 | let totalAmount = (amount + referralUnclaimed) | |
476 | 561 | $Tuple2(nil, totalAmount) | |
477 | 562 | } | |
478 | 563 | ||
479 | 564 | ||
480 | 565 | ||
481 | 566 | @Callable(i) | |
482 | - | func onEmissionForGwxStart () = { | |
483 | - | let suspensionCheck = throwIfSuspended() | |
484 | - | if ((suspensionCheck == suspensionCheck)) | |
485 | - | then if ((i.caller != factoryContract)) | |
486 | - | then throw("permissions denied") | |
487 | - | else [IntegerEntry(keyGwxRewardEmissionStartHeight(), height)] | |
488 | - | else throw("Strict value is not equal to itself.") | |
567 | + | func latestFinalizedPeriodREADONLY (address) = $Tuple2(nil, valueOrElse(getInteger(this, keyLatestPeriod()), -1)) | |
568 | + | ||
569 | + | ||
570 | + | ||
571 | + | @Callable(i) | |
572 | + | func latestFinalizedPeriodInfoREADONLY (address) = $Tuple2(nil, getStringByKey(keyLastPayoutInfo())) | |
573 | + | ||
574 | + | ||
575 | + | ||
576 | + | @Callable(i) | |
577 | + | func calcGwxParamsREADONLY (gwxAmountStart,lockStartHeight,lockDurationBlocks) = { | |
578 | + | let lockEndHeight = (lockStartHeight + lockDurationBlocks) | |
579 | + | let scale8ParamK = -(fraction(gwxAmountStart, SCALE, lockDurationBlocks)) | |
580 | + | let scale8ParamB = (fraction(gwxAmountStart, SCALE, lockDurationBlocks) * lockEndHeight) | |
581 | + | $Tuple2(nil, [scale8ParamK, scale8ParamB, nextPeriod()]) | |
582 | + | } | |
583 | + | ||
584 | + | ||
585 | + | ||
586 | + | @Callable(i) | |
587 | + | func calcGwxAmountStartREADONLY (wxLockAmount,lockDuration,maxLockDuration) = { | |
588 | + | let coeffX8 = fraction(lockDuration, MULT8, maxLockDuration) | |
589 | + | let gWxAmountStart = fraction(wxLockAmount, coeffX8, MULT8) | |
590 | + | $Tuple2(nil, [gWxAmountStart]) | |
591 | + | } | |
592 | + | ||
593 | + | ||
594 | + | ||
595 | + | @Callable(i) | |
596 | + | func onEmissionForGwxStart () = if ((i.caller != factoryContract)) | |
597 | + | then throw("permissions denied") | |
598 | + | else [IntegerEntry(keyGwxRewardEmissionStartHeight(), height)] | |
599 | + | ||
600 | + | ||
601 | + | ||
602 | + | @Callable(i) | |
603 | + | func latestPeriodEmissionRewardsREADONLY (address) = { | |
604 | + | let period = nextPeriod() | |
605 | + | $Tuple2(nil, [getNumberByKey(keyAuxEmissionRewardForPeriod(period))]) | |
606 | + | } | |
607 | + | ||
608 | + | ||
609 | + | ||
610 | + | @Callable(i) | |
611 | + | func calcD (x1BigIntStr,x2BigIntStr,ampBigIntStr,aPrecisionBigIntStr,targetPrecisionBigIntStr) = { | |
612 | + | let nCoins = toBigInt(2) | |
613 | + | let aPrecision = parseBigIntValue(aPrecisionBigIntStr) | |
614 | + | let targetPrecision = parseBigIntValue(targetPrecisionBigIntStr) | |
615 | + | let x1 = parseBigIntValue(x1BigIntStr) | |
616 | + | let x2 = parseBigIntValue(x2BigIntStr) | |
617 | + | let amp = (parseBigIntValue(ampBigIntStr) * aPrecision) | |
618 | + | let s = (x1 + x2) | |
619 | + | if ((s == zeroBigInt)) | |
620 | + | then $Tuple2(nil, toString(zeroBigInt)) | |
621 | + | else { | |
622 | + | let ann = (amp * nCoins) | |
623 | + | let arr = [0, 1, 2, 3, 4, 5, 6] | |
624 | + | func calc (acc,cur) = { | |
625 | + | let $t02312123148 = acc | |
626 | + | let d = $t02312123148._1 | |
627 | + | let dPrev = $t02312123148._2 | |
628 | + | let found = $t02312123148._3 | |
629 | + | if ((found != unit)) | |
630 | + | then acc | |
631 | + | else { | |
632 | + | let dp = (((d * d) * d) / (((x1 * x2) * nCoins) * nCoins)) | |
633 | + | let dNext = (((((ann * s) / aPrecision) + (dp * nCoins)) * d) / ((((ann - aPrecision) * d) / aPrecision) + ((nCoins + toBigInt(1)) * dp))) | |
634 | + | let dDiff = absBigInt((dNext - value(d))) | |
635 | + | if ((targetPrecision >= dDiff)) | |
636 | + | then $Tuple3(dNext, d, cur) | |
637 | + | else $Tuple3(dNext, d, unit) | |
638 | + | } | |
639 | + | } | |
640 | + | ||
641 | + | let $t02374623809 = { | |
642 | + | let $l = arr | |
643 | + | let $s = size($l) | |
644 | + | let $acc0 = $Tuple3(s, unit, unit) | |
645 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
646 | + | then $a | |
647 | + | else calc($a, $l[$i]) | |
648 | + | ||
649 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
650 | + | then $a | |
651 | + | else throw("List size exceeds 7") | |
652 | + | ||
653 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7) | |
654 | + | } | |
655 | + | let dNext = $t02374623809._1 | |
656 | + | let dPrev = $t02374623809._2 | |
657 | + | let found = $t02374623809._3 | |
658 | + | if ((found != unit)) | |
659 | + | then $Tuple2(nil, toString(dNext)) | |
660 | + | else { | |
661 | + | let dDiff = absBigInt((dNext - value(dPrev))) | |
662 | + | throw(("D calculation error, dDiff = " + toString(dDiff))) | |
663 | + | } | |
664 | + | } | |
489 | 665 | } | |
490 | 666 | ||
491 | 667 | ||
492 | 668 | ||
493 | 669 | @Callable(i) | |
494 | 670 | func tradeReward (userAddresses,rewards) = { | |
495 | - | let suspensionCheck = throwIfSuspended() | |
496 | - | if ((suspensionCheck == suspensionCheck)) | |
671 | + | let argsComparison = (size(userAddresses) == size(rewards)) | |
672 | + | let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0) | |
673 | + | let payment = i.payments[0] | |
674 | + | let paymentAssetId = payment.assetId | |
675 | + | let paymentAmount = payment.amount | |
676 | + | let checks = [if ((maxRecipients >= size(userAddresses))) | |
677 | + | then true | |
678 | + | else throwErr("Too many recipients"), if (argsComparison) | |
679 | + | then true | |
680 | + | else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId)) | |
681 | + | then true | |
682 | + | else throwErr("Wrong asset payment")] | |
683 | + | if ((checks == checks)) | |
497 | 684 | then { | |
498 | - | let argsComparison = (size(userAddresses) == size(rewards)) | |
499 | - | let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0) | |
500 | - | let payment = i.payments[0] | |
501 | - | let paymentAssetId = payment.assetId | |
502 | - | let paymentAmount = payment.amount | |
503 | - | let checks = [if ((maxRecipients >= size(userAddresses))) | |
504 | - | then true | |
505 | - | else throwErr("Too many recipients"), if (argsComparison) | |
506 | - | then true | |
507 | - | else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId)) | |
508 | - | then true | |
509 | - | else throwErr("Wrong asset payment")] | |
510 | - | if ((checks == checks)) | |
511 | - | then { | |
512 | - | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil) | |
513 | - | if ((tradeRewardInternal == tradeRewardInternal)) | |
514 | - | then $Tuple2(nil, tradeRewardInternal) | |
515 | - | else throw("Strict value is not equal to itself.") | |
516 | - | } | |
685 | + | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil) | |
686 | + | if ((tradeRewardInternal == tradeRewardInternal)) | |
687 | + | then $Tuple2(nil, tradeRewardInternal) | |
517 | 688 | else throw("Strict value is not equal to itself.") | |
518 | 689 | } | |
519 | 690 | else throw("Strict value is not equal to itself.") | |
520 | 691 | } | |
521 | 692 | ||
522 | 693 | ||
523 | 694 | ||
524 | 695 | @Callable(i) | |
525 | 696 | func claimTradingReward () = { | |
526 | - | let suspensionCheck = throwIfSuspended() | |
527 | - | if ((suspensionCheck == suspensionCheck)) | |
528 | - | then { | |
529 | - | let userAddress = i.caller | |
530 | - | let userAddressString = toString(userAddress) | |
531 | - | let reward = getTradingReward(userAddressString) | |
532 | - | if ((reward > 0)) | |
533 | - | then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId), IntegerEntry(keyTradingReward(userAddressString), 0)], reward) | |
534 | - | else throwErr("nothing to claim") | |
535 | - | } | |
536 | - | else throw("Strict value is not equal to itself.") | |
697 | + | let userAddress = i.caller | |
698 | + | let userAddressString = toString(userAddress) | |
699 | + | let reward = getTradingReward(userAddressString) | |
700 | + | if ((reward > 0)) | |
701 | + | then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId), IntegerEntry(keyTradingReward(userAddressString), 0)], reward) | |
702 | + | else throwErr("nothing to claim") | |
537 | 703 | } | |
538 | 704 | ||
539 | 705 | ||
540 | 706 | ||
541 | 707 | @Callable(i) | |
542 | 708 | func claimTradingRewardREADONLY (userAddress) = $Tuple2(nil, getTradingReward(userAddress)) | |
543 | - | ||
544 | - | ||
545 | - | ||
546 | - | @Callable(i) | |
547 | - | func suspend (v) = { | |
548 | - | let checkCaller = mustManager(i) | |
549 | - | if ((checkCaller == checkCaller)) | |
550 | - | then $Tuple2([BooleanEntry(keySuspension, v)], v) | |
551 | - | else throw("Strict value is not equal to itself.") | |
552 | - | } | |
553 | 709 | ||
554 | 710 | ||
555 | 711 | @Verifier(tx) | |
556 | 712 | func verify () = { | |
557 | 713 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
558 | 714 | case pk: ByteVector => | |
559 | 715 | pk | |
560 | 716 | case _: Unit => | |
561 | 717 | tx.senderPublicKey | |
562 | 718 | case _ => | |
563 | 719 | throw("Match error") | |
564 | 720 | } | |
565 | 721 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
566 | 722 | } | |
567 | 723 |
github/deemru/w8io/026f985 79.75 ms ◑