tx · ECZ5ks2Fr6gQpWBaUuJRgsVuctmivBG5Fo9GK2Uc75kg

3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE:  -0.01500000 Waves

2023.08.17 16:29 [2714656] smart account 3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE > SELF 0.00000000 Waves

{ "type": 13, "id": "ECZ5ks2Fr6gQpWBaUuJRgsVuctmivBG5Fo9GK2Uc75kg", "fee": 1500000, "feeAssetId": null, "timestamp": 1692279033196, "version": 2, "chainId": 84, "sender": "3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE", "senderPublicKey": "G349Uq3FTox7dRNLeAfAQeoACvwZ9iEnVSaHcEYn6j8J", "proofs": [ "4qhYeHm8QWkdWzGeBEqFxBxqhjchupmdpK6JaxKvbALN3ELCgCxaTiU6ZDEgF8phhq5ZbcL3sj5VG5E6Gz6eZLmm" ], "script": "base64:BgKMFggCEgQKAgIBEgYKBAEYEQESBAoCCAESABIAEgMKAQgSABIECgIYERIAEgMKAQgiA1NFUCIFU0NBTEUiBU1VTFQ4IgdNVUxUOEJJIgp6ZXJvQmlnSW50IhRwcm9jZXNzaW5nU3RhZ2VUb3RhbCIVcHJvY2Vzc2luZ1N0YWdlU2hhcmVzIgZNVUxUMTgiCE1VTFQxOEJJIgt3YXZlc1N0cmluZyIHd3JhcEVyciIDbXNnIgh0aHJvd0VyciIOZ2V0TnVtYmVyQnlLZXkiA2tleSIPZ2V0TnVtYmVyT3JGYWlsIg5nZXRTdHJpbmdCeUtleSIPZ2V0U3RyaW5nT3JGYWlsIgxwYXJzZUFzc2V0SWQiBWlucHV0IgNhYnMiA3ZhbCIJYWJzQmlnSW50IgtrZXlNYXhEZXB0aCIPbWF4RGVwdGhEZWZhdWx0IghtYXhEZXB0aCIRa2V5RmFjdG9yeUFkZHJlc3MiEWZhY3RvcnlBZGRyZXNzU3RyIg9mYWN0b3J5Q29udHJhY3QiEmtleUVtaXNzaW9uQWRkcmVzcyIZa2V5Vm90aW5nRW1p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gADCQABAgUCYVACCkJ5dGVWZWN0b3IEAmFWBQJhUAUCYVYDCQABAgUCYVACBFVuaXQIBQJjZg9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgkA9AMDCAUCY2YJYm9keUJ5dGVzCQCRAwIIBQJjZgZwcm9vZnMAAAUCY2iJw1hP", "height": 2714656, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: F1jk2vaguPNe2csU8QgwMub7ZcvwW6GhDN8ZRT4PLLgA Next: G6fZHDhXeatGFoj34kPv9VhdwkiimeX6CM7cG5843yyL Diff:
OldNewDifferences
77
88 let MULT8 = 100000000
99
10+let MULT8BI = toBigInt(MULT8)
11+
1012 let zeroBigInt = toBigInt(0)
1113
1214 let processingStageTotal = 0
1315
1416 let processingStageShares = 1
1517
18+let MULT18 = 1000000000000000000
19+
20+let MULT18BI = toBigInt(MULT18)
21+
1622 let wavesString = "WAVES"
23+
24+func wrapErr (msg) = makeString(["gwx_reward.ride:", msg], " ")
25+
26+
27+func throwErr (msg) = throw(wrapErr(msg))
28+
1729
1830 func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0)
1931
2032
21-func getNumberOrFail (key) = valueOrErrorMessage(getInteger(this, key), (("mandatory this." + key) + " is not defined"))
33+func getNumberOrFail (key) = valueOrErrorMessage(getInteger(this, key), wrapErr((("mandatory this." + key) + " is not defined")))
2234
2335
2436 func getStringByKey (key) = valueOrElse(getString(this, key), "")
2537
2638
27-func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (("mandatory this." + key) + " is not defined"))
39+func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), wrapErr((("mandatory this." + key) + " is not defined")))
2840
2941
3042 func parseAssetId (input) = if ((input == wavesString))
3143 then unit
3244 else fromBase58String(input)
33-
34-
35-func wrapErr (msg) = makeString(["gwx_reward.ride:", msg], " ")
36-
37-
38-func throwErr (msg) = throw(wrapErr(msg))
3945
4046
4147 func abs (val) = if ((0 > val))
144150 func keyUsersCount () = "%s__nextUserNum"
145151
146152
153+func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", toString(userAddress)], SEP)
154+
155+
147156 func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current"
148157
149158
156165 func keyPoolWeightVirtual () = "%s%s__poolWeight__GWXvirtualPOOL"
157166
158167
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-
174168 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)
211169
212170
213171 func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP)
275233 }
276234
277235
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-
325236 func getUserIndexByAddress (boostingContractAddressStr,userAddress) = {
326237 let key = makeString(["%s%s%s", "mapping", "user2num", userAddress], SEP)
327238 parseIntValue(valueOrErrorMessage(getString(Address(fromBase58String(boostingContractAddressStr)), key), ((("User address " + userAddress) + " is not found in boosting contract data, key=") + key)))
328239 }
329240
330241
331-func nextPeriod () = getNumberByKey(keyNextPeriod())
242+func getTradingReward (userAddress) = valueOrElse(getInteger(this, keyTradingReward(userAddress)), 0)
332243
333244
334-func commonClaimReward (userAddress) = {
335- let cfgArray = readConfigArrayOrFail()
336- let userIdx = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddress)
337- let userUnclaimedOption = getInteger(keyUserUnclaimed(userIdx))
338- match userUnclaimedOption {
245+func keyRewardPerGwxIntegral () = makeString(["%s", "rewardPerGwxIntegral"], SEP)
246+
247+
248+func getGwxAmountTotalOption () = {
249+ let keyGwxTotal = "%s%s__gwx__total"
250+ getInteger(boostingContractOrFail(), keyGwxTotal)
251+ }
252+
253+
254+func getUserGwxAmountTotalOption (userAddress) = {
255+ func keyUserGwxAmountTotal (userAddress) = makeString(["%s%s__gwxAmountTotal", toString(userAddress)], SEP)
256+
257+ getInteger(boostingContractOrFail(), keyUserGwxAmountTotal(userAddress))
258+ }
259+
260+
261+func _refreshRewardPerGwxIntegral () = {
262+ let rewardPerGwxIntegralPrevious = valueOrElse( match getString(this, keyRewardPerGwxIntegral()) {
263+ case s: String =>
264+ parseBigInt(s)
339265 case _: Unit =>
340- $Tuple2(0, nil)
341- case u: Int =>
342- $Tuple2(u, [IntegerEntry(keyUserUnclaimed(userIdx), 0)])
266+ unit
267+ case _ =>
268+ throw("Match error")
269+ }, zeroBigInt)
270+ let rewardPerGwxIntegralLastHeight = valueOrErrorMessage(getInteger(this, keyGwxRewardEmissionStartHeight()), wrapErr(("invalid " + keyGwxRewardEmissionStartHeight())))
271+ let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), wrapErr(("invalid " + keyRatePerBlockCurrent())))
272+ let gwxHoldersRewardCurrent = valueOrElse(getInteger(emissionContract, keyGwxHoldersRewardCurrent()), 0)
273+ let gwxAmountTotal = valueOrElse(getGwxAmountTotalOption(), 0)
274+ let dh = toBigInt((height - rewardPerGwxIntegralLastHeight))
275+ let gwxAmountTotalBI = toBigInt(gwxAmountTotal)
276+ let rewardPerGwxIntegral = (rewardPerGwxIntegralPrevious + (if ((gwxAmountTotalBI == zeroBigInt))
277+ then zeroBigInt
278+ else fraction(dh, ((toBigInt(emissionRate) * toBigInt(gwxHoldersRewardCurrent)) * MULT18BI), (gwxAmountTotalBI * MULT8BI))))
279+ $Tuple2([IntegerEntry(keyGwxRewardEmissionStartHeight(), height), StringEntry(keyRewardPerGwxIntegral(), toString(rewardPerGwxIntegral))], rewardPerGwxIntegral)
280+ }
281+
282+
283+func keyRewardPerGwxIntegralUserLast (userAddress) = makeString(["%s%s", "rewardPerGwxIntegralUserLast", toString(userAddress)], SEP)
284+
285+
286+func _refreshUserReward (userAddress,userNum) = {
287+ let $t01012210210 = _refreshRewardPerGwxIntegral()
288+ let rewardPerGwxIntegralActions = $t01012210210._1
289+ let rewardPerGwxIntegral = $t01012210210._2
290+ let rewardPerGwxIntegralUserLast = match getString(this, keyRewardPerGwxIntegralUserLast(userAddress)) {
291+ case s: String =>
292+ valueOrErrorMessage(parseBigInt(s), wrapErr("invalid user last integral"))
293+ case _: Unit =>
294+ rewardPerGwxIntegral
343295 case _ =>
344296 throw("Match error")
345297 }
298+ let userIdxOption = getString(boostingContractOrFail(), keyUser2NumMapping(userAddress))
299+ let userUnclaimed = valueOrElse(getInteger(keyUserUnclaimed(userNum)), 0)
300+ let userGwxAmount = valueOrElse(getUserGwxAmountTotalOption(userAddress), 0)
301+ let userReward = (toInt(fraction(toBigInt(userGwxAmount), (rewardPerGwxIntegral - rewardPerGwxIntegralUserLast), MULT18BI)) + userUnclaimed)
302+ $Tuple2(([StringEntry(keyRewardPerGwxIntegralUserLast(userAddress), toString(rewardPerGwxIntegral))] ++ rewardPerGwxIntegralActions), userReward)
346303 }
347304
348305
349-func getTradingReward (userAddress) = valueOrElse(getInteger(this, keyTradingReward(userAddress)), 0)
306+func commonClaimReward (userAddressStr) = {
307+ let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address"))
308+ let cfgArray = readConfigArrayOrFail()
309+ let userNum = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddressStr)
310+ let $t01150111565 = _refreshUserReward(userAddress, userNum)
311+ let actions = $t01150111565._1
312+ let reward = $t01150111565._2
313+ $Tuple2(reward, ([IntegerEntry(keyUserUnclaimed(userNum), 0)] ++ actions))
314+ }
315+
316+
317+@Callable(i)
318+func refreshUserReward (userAddressBytes,userNum) = {
319+ let checkCaller = if ((i.caller == boostingContractOrFail()))
320+ then true
321+ else throwErr("permission denied")
322+ if ((checkCaller == checkCaller))
323+ then {
324+ let $t01184511923 = _refreshUserReward(Address(userAddressBytes), userNum)
325+ let actions = $t01184511923._1
326+ let reward = $t01184511923._2
327+ $Tuple2(([IntegerEntry(keyUserUnclaimed(userNum), reward)] ++ actions), reward)
328+ }
329+ else throw("Strict value is not equal to itself.")
330+ }
331+
350332
351333
352334 @Callable(i)
388370
389371
390372 @Callable(i)
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)
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- }
373+func processPendingPeriodsAndUsers () = $Tuple2(nil, throwErr("deprecated"))
450374
451375
452376
453377 @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)
469- else throw("Strict value is not equal to itself.")
470- }
471-
472-
473-
474-@Callable(i)
475-func processPendingPeriodsAndUsers () = $Tuple2(nil, invoke(this, "finalizeWrapper", [maxDepth], nil))
476-
477-
478-
479-@Callable(i)
480-func deposit () = {
481- let checkCaller = if ((i.caller == votingEmissionContract))
378+func claimReward () = {
379+ let cfgArray = readConfigArrayOrFail()
380+ let userAddress = i.caller
381+ let userAddressStr = toString(userAddress)
382+ let $t01365513712 = commonClaimReward(userAddressStr)
383+ let amount = $t01365513712._1
384+ let actions = $t01365513712._2
385+ let checkAmount = if ((amount > 0))
482386 then true
483- else mustManager(i)
484- if ((checkCaller == checkCaller))
387+ else throw("nothing to claim")
388+ if ((checkAmount == checkAmount))
485389 then {
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))
390+ let userGwxAmount = {
391+ let @ = invoke(boostingContractOrFail(), "getUserGwxAmount", [userAddressStr], nil)
392+ if ($isInstanceOf(@, "Int"))
393+ then @
394+ else throw(($getType(@) + " couldn't be cast to Int"))
395+ }
396+ let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddressStr))
397+ let activeReferralInv = if ((referrer == unit))
398+ then unit
399+ else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userGwxAmount >= referralMinGWxAmount)], nil)
400+ if ((activeReferralInv == activeReferralInv))
491401 then {
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))
402+ let referralInv = if (if ((referrer == unit))
403+ then true
404+ else (referralMinGWxAmount > userGwxAmount))
405+ then unit
406+ else {
407+ let referrerReward = fraction(amount, referrerRewardPermille, SCALE)
408+ let referralReward = fraction(amount, referralRewardPermille, SCALE)
409+ invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil)
410+ }
411+ if ((referralInv == referralInv))
497412 then {
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"))
413+ let claimedReferral = {
414+ let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil)
415+ if ($isInstanceOf(@, "Int"))
503416 then @
504- else throw(($getType(@) + " couldn't be cast to Boolean"))
417+ else throw(($getType(@) + " couldn't be cast to Int"))
505418 }
506- if ((gwxHoldersRewardUpdated == gwxHoldersRewardUpdated))
419+ if ((claimedReferral == claimedReferral))
507420 then {
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)
421+ let totalAmount = (amount + claimedReferral)
422+ $Tuple2(([ScriptTransfer(i.caller, amount, fromBase58String(cfgArray[IdxCfgAssetId])), HistoryEntry("claim", userAddressStr, totalAmount, i)] ++ actions), totalAmount)
515423 }
516424 else throw("Strict value is not equal to itself.")
517425 }
525433
526434
527435 @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)
555436 func claimRewardREADONLY (address) = {
556- let $t02043820488 = commonClaimReward(address)
557- let amount = $t02043820488._1
558- let actions = $t02043820488._2
437+ let $t01503915089 = commonClaimReward(address)
438+ let amount = $t01503915089._1
439+ let actions = $t01503915089._2
559440 let referralUnclaimed = valueOrElse(getInteger(referralsContractAddressOrFail, keyUnclaimedReferral(referralProgramName, address)), 0)
560441 let totalAmount = (amount + referralUnclaimed)
561442 $Tuple2(nil, totalAmount)
564445
565446
566447 @Callable(i)
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)
596448 func onEmissionForGwxStart () = if ((i.caller != factoryContract))
597449 then throw("permissions denied")
598450 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- }
665- }
666451
667452
668453
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let SCALE = 1000
77
88 let MULT8 = 100000000
99
10+let MULT8BI = toBigInt(MULT8)
11+
1012 let zeroBigInt = toBigInt(0)
1113
1214 let processingStageTotal = 0
1315
1416 let processingStageShares = 1
1517
18+let MULT18 = 1000000000000000000
19+
20+let MULT18BI = toBigInt(MULT18)
21+
1622 let wavesString = "WAVES"
23+
24+func wrapErr (msg) = makeString(["gwx_reward.ride:", msg], " ")
25+
26+
27+func throwErr (msg) = throw(wrapErr(msg))
28+
1729
1830 func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0)
1931
2032
21-func getNumberOrFail (key) = valueOrErrorMessage(getInteger(this, key), (("mandatory this." + key) + " is not defined"))
33+func getNumberOrFail (key) = valueOrErrorMessage(getInteger(this, key), wrapErr((("mandatory this." + key) + " is not defined")))
2234
2335
2436 func getStringByKey (key) = valueOrElse(getString(this, key), "")
2537
2638
27-func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), (("mandatory this." + key) + " is not defined"))
39+func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), wrapErr((("mandatory this." + key) + " is not defined")))
2840
2941
3042 func parseAssetId (input) = if ((input == wavesString))
3143 then unit
3244 else fromBase58String(input)
33-
34-
35-func wrapErr (msg) = makeString(["gwx_reward.ride:", msg], " ")
36-
37-
38-func throwErr (msg) = throw(wrapErr(msg))
3945
4046
4147 func abs (val) = if ((0 > val))
4248 then -(val)
4349 else val
4450
4551
4652 func absBigInt (val) = if ((zeroBigInt > val))
4753 then -(val)
4854 else val
4955
5056
5157 let keyMaxDepth = "%s__maxDepth"
5258
5359 let maxDepthDefault = 30
5460
5561 let maxDepth = valueOrElse(getInteger(this, keyMaxDepth), maxDepthDefault)
5662
5763 func keyFactoryAddress () = "%s%s__config__factoryAddress"
5864
5965
6066 let factoryAddressStr = getStringOrFail(keyFactoryAddress())
6167
6268 let factoryContract = addressFromStringValue(factoryAddressStr)
6369
6470 func keyEmissionAddress () = "%s%s__config__emissionAddress"
6571
6672
6773 func keyVotingEmissionContract () = makeString(["%s", "votingEmissionContract"], SEP)
6874
6975
7076 let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract()))
7177
7278 func keyNumToUserMapping (num) = makeString(["%s%s%s", "mapping", "num2user", toString(num)], SEP)
7379
7480
7581 let keyReferralProgramName = makeString(["%s%s", "referral", "programName"], SEP)
7682
7783 let referralProgramNameDefault = "wxlock"
7884
7985 let referralProgramName = valueOrElse(getString(this, keyReferralProgramName), referralProgramNameDefault)
8086
8187 let keyReferralMinGWxAmount = makeString(["%s%s", "referral", "minGWxAmount"], SEP)
8288
8389 let referralMinGWxAmountDefault = (500 * MULT8)
8490
8591 let referralMinGWxAmount = valueOrElse(getInteger(this, keyReferralMinGWxAmount), referralMinGWxAmountDefault)
8692
8793 let keyReferrerRewardPermille = makeString(["%s%s", "referral", "referrerRewardPermille"], SEP)
8894
8995 let referrerRewardPermilleDefault = 50
9096
9197 let referrerRewardPermille = valueOrElse(getInteger(this, keyReferrerRewardPermille), referrerRewardPermilleDefault)
9298
9399 let keyReferralRewardPermille = makeString(["%s%s", "referral", "referralRewardPermille"], SEP)
94100
95101 let referralRewardPermilleDefault = 50
96102
97103 let referralRewardPermille = valueOrElse(getInteger(this, keyReferralRewardPermille), referralRewardPermilleDefault)
98104
99105 func keyReferrer (referralAddress) = makeString(["%s%s%s", "referrer", referralProgramName, referralAddress], SEP)
100106
101107
102108 func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferral", programName, claimerAddress], SEP)
103109
104110
105111 let emissionAddressStr = getStringOrFail(keyEmissionAddress())
106112
107113 let emissionContract = addressFromStringValue(emissionAddressStr)
108114
109115 let IdxCfgAssetId = 1
110116
111117 let IdxCfgPacemakerAddress = 2
112118
113119 let IdxCfgBoostingContract = 3
114120
115121 let IdxCfgMaxDepth = 4
116122
117123 func keyConfig () = "%s__config"
118124
119125
120126 func getEmissionAddress () = addressFromStringValue(valueOrErrorMessage(getString(this, keyEmissionAddress()), (("mandatory this." + keyEmissionAddress()) + " is not defined")))
121127
122128
123129 let emissionAddress = getEmissionAddress()
124130
125131 let wxAssetIdStr = split(value(getString(emissionAddress, keyConfig())), SEP)[1]
126132
127133 let wxAssetId = fromBase58String(wxAssetIdStr)
128134
129135 func readConfigArrayOrFail () = split(getStringOrFail(keyConfig()), SEP)
130136
131137
132138 func formatConfig (wxAssetIdStr,matcherPacemakerAddressStr,boostingContractAddressStr,maxDepth) = makeString(["%s%s%s%d", wxAssetIdStr, matcherPacemakerAddressStr, boostingContractAddressStr, toString(maxDepth)], SEP)
133139
134140
135141 func boostingContractOrFail () = {
136142 let cfgArray = readConfigArrayOrFail()
137143 valueOrErrorMessage(addressFromString(cfgArray[IdxCfgBoostingContract]), "boosting contract address is not defined")
138144 }
139145
140146
141147 func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight"
142148
143149
144150 func keyUsersCount () = "%s__nextUserNum"
145151
146152
153+func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", toString(userAddress)], SEP)
154+
155+
147156 func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current"
148157
149158
150159 func keyGwxHoldersRewardCurrent () = "%s%s__gwxHoldersReward__current"
151160
152161
153162 func keyGwxHoldersRewardNext () = "%s%s__gwxHoldersReward__next"
154163
155164
156165 func keyPoolWeightVirtual () = "%s%s__poolWeight__GWXvirtualPOOL"
157166
158167
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-
174168 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)
211169
212170
213171 func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP)
214172
215173
216174 let referralsContractAddressOrFail = addressFromStringValue(getStringOrFail(keyReferralsContractAddress()))
217175
218176 func keyTradingRewardHistory (user,i) = makeString(["%s%s%s%s", "tradingReward", "history", user, toBase58String(i.transactionId)], SEP)
219177
220178
221179 func keyTradingReward (userAddress) = makeString(["%s%s", "tradingReward", userAddress], SEP)
222180
223181
224182 func keyMaxRecipients () = makeString(["%s", "maxRecipients"], SEP)
225183
226184
227185 func HistoryEntry (type,user,amount,i) = {
228186 let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP)
229187 let historyDATA = makeString(["%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount)], SEP)
230188 StringEntry(historyKEY, historyDATA)
231189 }
232190
233191
234192 func keyManagerPublicKey () = "%s__managerPublicKey"
235193
236194
237195 func keyManagerVaultAddress () = "%s__managerVaultAddress"
238196
239197
240198 func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) {
241199 case s: String =>
242200 addressFromStringValue(s)
243201 case _ =>
244202 this
245203 }
246204
247205
248206 func managerPublicKeyOrUnit () = {
249207 let managerVaultAddress = getManagerVaultAddressOrThis()
250208 match getString(managerVaultAddress, keyManagerPublicKey()) {
251209 case s: String =>
252210 fromBase58String(s)
253211 case _: Unit =>
254212 unit
255213 case _ =>
256214 throw("Match error")
257215 }
258216 }
259217
260218
261219 func mustManager (i) = {
262220 let pd = throw("Permission denied")
263221 match managerPublicKeyOrUnit() {
264222 case pk: ByteVector =>
265223 if ((i.callerPublicKey == pk))
266224 then true
267225 else pd
268226 case _: Unit =>
269227 if ((i.caller == this))
270228 then true
271229 else pd
272230 case _ =>
273231 throw("Match error")
274232 }
275233 }
276234
277235
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-
325236 func getUserIndexByAddress (boostingContractAddressStr,userAddress) = {
326237 let key = makeString(["%s%s%s", "mapping", "user2num", userAddress], SEP)
327238 parseIntValue(valueOrErrorMessage(getString(Address(fromBase58String(boostingContractAddressStr)), key), ((("User address " + userAddress) + " is not found in boosting contract data, key=") + key)))
328239 }
329240
330241
331-func nextPeriod () = getNumberByKey(keyNextPeriod())
242+func getTradingReward (userAddress) = valueOrElse(getInteger(this, keyTradingReward(userAddress)), 0)
332243
333244
334-func commonClaimReward (userAddress) = {
335- let cfgArray = readConfigArrayOrFail()
336- let userIdx = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddress)
337- let userUnclaimedOption = getInteger(keyUserUnclaimed(userIdx))
338- match userUnclaimedOption {
245+func keyRewardPerGwxIntegral () = makeString(["%s", "rewardPerGwxIntegral"], SEP)
246+
247+
248+func getGwxAmountTotalOption () = {
249+ let keyGwxTotal = "%s%s__gwx__total"
250+ getInteger(boostingContractOrFail(), keyGwxTotal)
251+ }
252+
253+
254+func getUserGwxAmountTotalOption (userAddress) = {
255+ func keyUserGwxAmountTotal (userAddress) = makeString(["%s%s__gwxAmountTotal", toString(userAddress)], SEP)
256+
257+ getInteger(boostingContractOrFail(), keyUserGwxAmountTotal(userAddress))
258+ }
259+
260+
261+func _refreshRewardPerGwxIntegral () = {
262+ let rewardPerGwxIntegralPrevious = valueOrElse( match getString(this, keyRewardPerGwxIntegral()) {
263+ case s: String =>
264+ parseBigInt(s)
339265 case _: Unit =>
340- $Tuple2(0, nil)
341- case u: Int =>
342- $Tuple2(u, [IntegerEntry(keyUserUnclaimed(userIdx), 0)])
266+ unit
267+ case _ =>
268+ throw("Match error")
269+ }, zeroBigInt)
270+ let rewardPerGwxIntegralLastHeight = valueOrErrorMessage(getInteger(this, keyGwxRewardEmissionStartHeight()), wrapErr(("invalid " + keyGwxRewardEmissionStartHeight())))
271+ let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), wrapErr(("invalid " + keyRatePerBlockCurrent())))
272+ let gwxHoldersRewardCurrent = valueOrElse(getInteger(emissionContract, keyGwxHoldersRewardCurrent()), 0)
273+ let gwxAmountTotal = valueOrElse(getGwxAmountTotalOption(), 0)
274+ let dh = toBigInt((height - rewardPerGwxIntegralLastHeight))
275+ let gwxAmountTotalBI = toBigInt(gwxAmountTotal)
276+ let rewardPerGwxIntegral = (rewardPerGwxIntegralPrevious + (if ((gwxAmountTotalBI == zeroBigInt))
277+ then zeroBigInt
278+ else fraction(dh, ((toBigInt(emissionRate) * toBigInt(gwxHoldersRewardCurrent)) * MULT18BI), (gwxAmountTotalBI * MULT8BI))))
279+ $Tuple2([IntegerEntry(keyGwxRewardEmissionStartHeight(), height), StringEntry(keyRewardPerGwxIntegral(), toString(rewardPerGwxIntegral))], rewardPerGwxIntegral)
280+ }
281+
282+
283+func keyRewardPerGwxIntegralUserLast (userAddress) = makeString(["%s%s", "rewardPerGwxIntegralUserLast", toString(userAddress)], SEP)
284+
285+
286+func _refreshUserReward (userAddress,userNum) = {
287+ let $t01012210210 = _refreshRewardPerGwxIntegral()
288+ let rewardPerGwxIntegralActions = $t01012210210._1
289+ let rewardPerGwxIntegral = $t01012210210._2
290+ let rewardPerGwxIntegralUserLast = match getString(this, keyRewardPerGwxIntegralUserLast(userAddress)) {
291+ case s: String =>
292+ valueOrErrorMessage(parseBigInt(s), wrapErr("invalid user last integral"))
293+ case _: Unit =>
294+ rewardPerGwxIntegral
343295 case _ =>
344296 throw("Match error")
345297 }
298+ let userIdxOption = getString(boostingContractOrFail(), keyUser2NumMapping(userAddress))
299+ let userUnclaimed = valueOrElse(getInteger(keyUserUnclaimed(userNum)), 0)
300+ let userGwxAmount = valueOrElse(getUserGwxAmountTotalOption(userAddress), 0)
301+ let userReward = (toInt(fraction(toBigInt(userGwxAmount), (rewardPerGwxIntegral - rewardPerGwxIntegralUserLast), MULT18BI)) + userUnclaimed)
302+ $Tuple2(([StringEntry(keyRewardPerGwxIntegralUserLast(userAddress), toString(rewardPerGwxIntegral))] ++ rewardPerGwxIntegralActions), userReward)
346303 }
347304
348305
349-func getTradingReward (userAddress) = valueOrElse(getInteger(this, keyTradingReward(userAddress)), 0)
306+func commonClaimReward (userAddressStr) = {
307+ let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address"))
308+ let cfgArray = readConfigArrayOrFail()
309+ let userNum = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddressStr)
310+ let $t01150111565 = _refreshUserReward(userAddress, userNum)
311+ let actions = $t01150111565._1
312+ let reward = $t01150111565._2
313+ $Tuple2(reward, ([IntegerEntry(keyUserUnclaimed(userNum), 0)] ++ actions))
314+ }
315+
316+
317+@Callable(i)
318+func refreshUserReward (userAddressBytes,userNum) = {
319+ let checkCaller = if ((i.caller == boostingContractOrFail()))
320+ then true
321+ else throwErr("permission denied")
322+ if ((checkCaller == checkCaller))
323+ then {
324+ let $t01184511923 = _refreshUserReward(Address(userAddressBytes), userNum)
325+ let actions = $t01184511923._1
326+ let reward = $t01184511923._2
327+ $Tuple2(([IntegerEntry(keyUserUnclaimed(userNum), reward)] ++ actions), reward)
328+ }
329+ else throw("Strict value is not equal to itself.")
330+ }
331+
350332
351333
352334 @Callable(i)
353335 func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = if ((currentIter == size(userAddresses)))
354336 then nil
355337 else {
356338 let checks = [if ((i.caller == this))
357339 then true
358340 else throwErr("Permission denied"), if ((paymentAmountLeftOver >= rewards[currentIter]))
359341 then true
360342 else throwErr("insufficient payment assetId")]
361343 if ((checks == checks))
362344 then {
363345 let tradeRewardInternal = invoke(this, "tradeRewardInternal", [(paymentAmountLeftOver - rewards[currentIter]), userAddresses, rewards, (currentIter + 1)], nil)
364346 if ((tradeRewardInternal == tradeRewardInternal))
365347 then {
366348 let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i)
367349 let userAddress = addressFromStringValue(userAddresses[currentIter])
368350 $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), IntegerEntry(keyTradingReward(userAddresses[currentIter]), rewards[currentIter])], tradeRewardInternal)
369351 }
370352 else throw("Strict value is not equal to itself.")
371353 }
372354 else throw("Strict value is not equal to itself.")
373355 }
374356
375357
376358
377359 @Callable(i)
378360 func updateReferralActivity (userAddress,gWxAmountStart) = {
379361 let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress))
380362 let activeReferralInv = if ((referrer == unit))
381363 then unit
382364 else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil)
383365 if ((activeReferralInv == activeReferralInv))
384366 then $Tuple2(nil, unit)
385367 else throw("Strict value is not equal to itself.")
386368 }
387369
388370
389371
390372 @Callable(i)
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)
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- }
373+func processPendingPeriodsAndUsers () = $Tuple2(nil, throwErr("deprecated"))
450374
451375
452376
453377 @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)
469- else throw("Strict value is not equal to itself.")
470- }
471-
472-
473-
474-@Callable(i)
475-func processPendingPeriodsAndUsers () = $Tuple2(nil, invoke(this, "finalizeWrapper", [maxDepth], nil))
476-
477-
478-
479-@Callable(i)
480-func deposit () = {
481- let checkCaller = if ((i.caller == votingEmissionContract))
378+func claimReward () = {
379+ let cfgArray = readConfigArrayOrFail()
380+ let userAddress = i.caller
381+ let userAddressStr = toString(userAddress)
382+ let $t01365513712 = commonClaimReward(userAddressStr)
383+ let amount = $t01365513712._1
384+ let actions = $t01365513712._2
385+ let checkAmount = if ((amount > 0))
482386 then true
483- else mustManager(i)
484- if ((checkCaller == checkCaller))
387+ else throw("nothing to claim")
388+ if ((checkAmount == checkAmount))
485389 then {
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))
390+ let userGwxAmount = {
391+ let @ = invoke(boostingContractOrFail(), "getUserGwxAmount", [userAddressStr], nil)
392+ if ($isInstanceOf(@, "Int"))
393+ then @
394+ else throw(($getType(@) + " couldn't be cast to Int"))
395+ }
396+ let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddressStr))
397+ let activeReferralInv = if ((referrer == unit))
398+ then unit
399+ else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userGwxAmount >= referralMinGWxAmount)], nil)
400+ if ((activeReferralInv == activeReferralInv))
491401 then {
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))
402+ let referralInv = if (if ((referrer == unit))
403+ then true
404+ else (referralMinGWxAmount > userGwxAmount))
405+ then unit
406+ else {
407+ let referrerReward = fraction(amount, referrerRewardPermille, SCALE)
408+ let referralReward = fraction(amount, referralRewardPermille, SCALE)
409+ invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil)
410+ }
411+ if ((referralInv == referralInv))
497412 then {
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"))
413+ let claimedReferral = {
414+ let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil)
415+ if ($isInstanceOf(@, "Int"))
503416 then @
504- else throw(($getType(@) + " couldn't be cast to Boolean"))
417+ else throw(($getType(@) + " couldn't be cast to Int"))
505418 }
506- if ((gwxHoldersRewardUpdated == gwxHoldersRewardUpdated))
419+ if ((claimedReferral == claimedReferral))
507420 then {
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)
421+ let totalAmount = (amount + claimedReferral)
422+ $Tuple2(([ScriptTransfer(i.caller, amount, fromBase58String(cfgArray[IdxCfgAssetId])), HistoryEntry("claim", userAddressStr, totalAmount, i)] ++ actions), totalAmount)
515423 }
516424 else throw("Strict value is not equal to itself.")
517425 }
518426 else throw("Strict value is not equal to itself.")
519427 }
520428 else throw("Strict value is not equal to itself.")
521429 }
522430 else throw("Strict value is not equal to itself.")
523431 }
524432
525433
526434
527435 @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)
555436 func claimRewardREADONLY (address) = {
556- let $t02043820488 = commonClaimReward(address)
557- let amount = $t02043820488._1
558- let actions = $t02043820488._2
437+ let $t01503915089 = commonClaimReward(address)
438+ let amount = $t01503915089._1
439+ let actions = $t01503915089._2
559440 let referralUnclaimed = valueOrElse(getInteger(referralsContractAddressOrFail, keyUnclaimedReferral(referralProgramName, address)), 0)
560441 let totalAmount = (amount + referralUnclaimed)
561442 $Tuple2(nil, totalAmount)
562443 }
563444
564445
565446
566447 @Callable(i)
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)
596448 func onEmissionForGwxStart () = if ((i.caller != factoryContract))
597449 then throw("permissions denied")
598450 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- }
665- }
666451
667452
668453
669454 @Callable(i)
670455 func tradeReward (userAddresses,rewards) = {
671456 let argsComparison = (size(userAddresses) == size(rewards))
672457 let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0)
673458 let payment = i.payments[0]
674459 let paymentAssetId = payment.assetId
675460 let paymentAmount = payment.amount
676461 let checks = [if ((maxRecipients >= size(userAddresses)))
677462 then true
678463 else throwErr("Too many recipients"), if (argsComparison)
679464 then true
680465 else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId))
681466 then true
682467 else throwErr("Wrong asset payment")]
683468 if ((checks == checks))
684469 then {
685470 let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil)
686471 if ((tradeRewardInternal == tradeRewardInternal))
687472 then $Tuple2(nil, tradeRewardInternal)
688473 else throw("Strict value is not equal to itself.")
689474 }
690475 else throw("Strict value is not equal to itself.")
691476 }
692477
693478
694479
695480 @Callable(i)
696481 func claimTradingReward () = {
697482 let userAddress = i.caller
698483 let userAddressString = toString(userAddress)
699484 let reward = getTradingReward(userAddressString)
700485 if ((reward > 0))
701486 then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId), IntegerEntry(keyTradingReward(userAddressString), 0)], reward)
702487 else throwErr("nothing to claim")
703488 }
704489
705490
706491
707492 @Callable(i)
708493 func claimTradingRewardREADONLY (userAddress) = $Tuple2(nil, getTradingReward(userAddress))
709494
710495
711496 @Verifier(tx)
712497 func verify () = {
713498 let targetPublicKey = match managerPublicKeyOrUnit() {
714499 case pk: ByteVector =>
715500 pk
716501 case _: Unit =>
717502 tx.senderPublicKey
718503 case _ =>
719504 throw("Match error")
720505 }
721506 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
722507 }
723508

github/deemru/w8io/169f3d6 
91.07 ms