tx · ENKWA3RNDcDLpEK28C5qzF375AxfNGdY1j7RmbTG5U3r

3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE:  -0.01700000 Waves

2023.05.19 15:30 [2584845] smart account 3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE > SELF 0.00000000 Waves

{ "type": 13, "id": "ENKWA3RNDcDLpEK28C5qzF375AxfNGdY1j7RmbTG5U3r", "fee": 1700000, "feeAssetId": null, "timestamp": 1684499424266, "version": 2, "chainId": 84, "sender": "3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE", "senderPublicKey": "G349Uq3FTox7dRNLeAfAQeoACvwZ9iEnVSaHcEYn6j8J", "proofs": [ "5R9eYro63rsH2pekhJcWw4uqc8r81nDRfFvSh23CcSiynLf4TjeUBP4BxNYQpcT9zCCj5VePtvYVgMBZhSkPeh5z" ], "script": "base64:BgLHGAgCEgQKAggBEgASAwoBARIAEgASABIDCgEIEgMKAQgSAwoBCBIFCgMBAQESBQoDAQEBEgASAwoBCBIHCgUICAgICCIDU0VQIgVTQ0FMRSIFTVVMVDgiCnplcm9CaWdJbnQiFHByb2Nlc3NpbmdTdGFnZVRvdGFsIhVwcm9jZXNzaW5nU3RhZ2VTaGFyZXMiDmdldE51bWJlckJ5S2V5IgNrZXkiD2dldE51bWJlck9yRmFpbCIOZ2V0U3RyaW5nQnlLZXkiD2dldFN0cmluZ09yRmFpbCIDYWJzIgN2YWwiCWFic0JpZ0ludCILa2V5TWF4RGVwdGgiD21heERlcHRoRGVmYXVsdCIIbWF4RGVwdGgiEWtleUZhY3RvcnlBZGRyZXNzIhFmYWN0b3J5QWRkcmVzc1N0ciIPZmFjdG9yeUNvbnRyYWN0IhJrZXlFbWlzc2lvbkFkZHJlc3MiE2tleU51bVRvVXNlck1hcHBpbmciA251bSIWa2V5UmVmZXJyYWxQcm9ncmFtTmFtZSIacmVmZXJyYWxQcm9ncmFtTmFtZURlZmF1bHQiE3JlZmVycmFsUHJvZ3JhbU5hbWUiF2tle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MgNwkBAmNVAgkBAmNSAgkBAmNSAgkBAmNSAgkBAmNSAgkBAmNSAgkBAmNSAgkBAmNSAgUCY1EAAAABAAIAAwAEAAUABgAHBAJjTAgFAmNOAl8xBAJjSQgFAmNOAl8yBAJjSggFAmNOAl8zAwkBAiE9AgUCY0oFBHVuaXQJAJQKAgUDbmlsCQCmAwEFAmNMBAJjTQkBAW4BCQC4AgIFAmNMCQEFdmFsdWUBBQJjSQkAAgEJAKwCAgIdRCBjYWxjdWxhdGlvbiBlcnJvciwgZERpZmYgPSAJAKYDAQUCY00BAmNWAQJjVwAEAmNYBAJhTwkBAmFRAAMJAAECBQJhTwIKQnl0ZVZlY3RvcgQCYVUFAmFPBQJhVQMJAAECBQJhTwIEVW5pdAgFAmNWD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJjVglib2R5Qnl0ZXMJAJEDAggFAmNWBnByb29mcwAABQJjWJ/Ybmg=", "height": 2584845, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: NiNbdY9WuBDMMPg76CeFVimKAJMj73kmkz2e7J1sDT9 Next: BsDXcBgDX5iaXNxsDZgzf5b15fGCZPguPPbCy9rAzcwU Diff:
OldNewDifferences
1313
1414 let processingStageShares = 1
1515
16-let wavesString = "WAVES"
17-
1816 func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0)
1917
2018
2523
2624
2725 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-
34-
35-func wrapErr (msg) = makeString(["gwx_reward.ride:", msg], " ")
36-
37-
38-func throwErr (msg) = throw(wrapErr(msg))
3926
4027
4128 func abs (val) = if ((0 > val))
6350
6451 func keyEmissionAddress () = "%s%s__config__emissionAddress"
6552
66-
67-func keyVotingEmissionContract () = makeString(["%s", "votingEmissionContract"], SEP)
68-
69-
70-let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract()))
7153
7254 func keyNumToUserMapping (num) = makeString(["%s%s%s", "mapping", "num2user", toString(num)], SEP)
7355
11799 func keyConfig () = "%s__config"
118100
119101
120-func getEmissionAddress () = addressFromStringValue(valueOrErrorMessage(getString(this, keyEmissionAddress()), (("mandatory this." + keyEmissionAddress()) + " is not defined")))
121-
122-
123-let emissionAddress = getEmissionAddress()
124-
125-let wxAssetIdStr = split(value(getString(emissionAddress, keyConfig())), SEP)[1]
126-
127-let wxAssetId = fromBase58String(wxAssetIdStr)
128-
129102 func readConfigArrayOrFail () = split(getStringOrFail(keyConfig()), SEP)
130103
131104
145118
146119
147120 func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current"
148-
149-
150-func keyGwxHoldersRewardCurrent () = "%s%s__gwxHoldersReward__current"
151-
152-
153-func keyGwxHoldersRewardNext () = "%s%s__gwxHoldersReward__next"
154121
155122
156123 func keyPoolWeightVirtual () = "%s%s__poolWeight__GWXvirtualPOOL"
214181
215182
216183 let referralsContractAddressOrFail = addressFromStringValue(getStringOrFail(keyReferralsContractAddress()))
217-
218-func keyTradingRewardHistory (user,i) = makeString(["%s%s%s%s", "tradingReward", "history", user, toBase58String(i.transactionId)], SEP)
219-
220-
221-func keyTradingReward (userAddress) = makeString(["%s%s", "tradingReward", userAddress], SEP)
222-
223-
224-func keyMaxRecipients () = makeString(["%s", "maxRecipients"], SEP)
225-
226184
227185 func HistoryEntry (type,user,amount,i) = {
228186 let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP)
346304 }
347305
348306
349-func getTradingReward (userAddress) = valueOrElse(getInteger(this, keyTradingReward(userAddress)), 0)
350-
351-
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- }
374-
375-
376-
377307 @Callable(i)
378308 func updateReferralActivity (userAddress,gWxAmountStart) = {
379309 let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress))
401331 then $Tuple2(nil, false)
402332 else if ((processingStage == processingStageTotal))
403333 then {
404- let $t01451014626 = calcUserWeight(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser)
405- let userWeight = $t01451014626._1
406- let userActions = $t01451014626._2
334+ let $t01216712283 = calcUserWeight(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser)
335+ let userWeight = $t01216712283._1
336+ let userActions = $t01216712283._2
407337 let totalWeightNew = (totalWeight + userWeight)
408338 let processingActions = if (((usersCount - 1) > currentUser))
409339 then [IntegerEntry(keyNextProcessedUser(), (currentUser + 1))]
478408
479409 @Callable(i)
480410 func deposit () = {
481- let checkCaller = if ((i.caller == votingEmissionContract))
482- then true
483- else mustManager(i)
484- if ((checkCaller == checkCaller))
485- 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))
491- 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
411+ let cfgArray = readConfigArrayOrFail()
412+ if ((i.caller != Address(fromBase58String(cfgArray[IdxCfgPacemakerAddress]))))
413+ then throw("Wrong caller address")
414+ else {
415+ let assetId = value(value(i.payments[0]).assetId)
416+ if ((assetId != fromBase58String(cfgArray[IdxCfgAssetId])))
417+ then throw("Wrong payment asset")
418+ else {
419+ let period = nextPeriod()
420+ let deltaH = (height - getNumberOrFail(keyGwxRewardEmissionStartHeight()))
421+ let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), (("mandatory emission_contract." + keyRatePerBlockCurrent()) + " is not defined"))
422+ let weight = valueOrErrorMessage(getInteger(factoryContract, keyPoolWeightVirtual()), (("mandatory factory_contract." + keyPoolWeightVirtual()) + " is not defined"))
423+ let auxAmount = fraction((deltaH * weight), emissionRate, MULT8)
424+ let em = invoke(emissionContract, "emit", [auxAmount], nil)
496425 if ((em == em))
497426 then {
498- let matcherPart = 0
427+ let matcherPart = value(i.payments[0]).amount
499428 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))
507- 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)
515- }
516- else throw("Strict value is not equal to itself.")
429+[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)]
517430 }
518431 else throw("Strict value is not equal to itself.")
519432 }
520- else throw("Strict value is not equal to itself.")
521433 }
522- else throw("Strict value is not equal to itself.")
523434 }
524435
525436
528439 func claimReward () = {
529440 let cfgArray = readConfigArrayOrFail()
530441 let address = toString(i.caller)
531- let $t01981519865 = commonClaimReward(address)
532- let amount = $t01981519865._1
533- let actions = $t01981519865._2
442+ let $t01762517675 = commonClaimReward(address)
443+ let amount = $t01762517675._1
444+ let actions = $t01762517675._2
534445 let checkAmount = if ((amount > 0))
535446 then true
536447 else throw("Nothing to claim")
553464
554465 @Callable(i)
555466 func claimRewardREADONLY (address) = {
556- let $t02043820488 = commonClaimReward(address)
557- let amount = $t02043820488._1
558- let actions = $t02043820488._2
467+ let $t01824818298 = commonClaimReward(address)
468+ let amount = $t01824818298._1
469+ let actions = $t01824818298._2
559470 let referralUnclaimed = valueOrElse(getInteger(referralsContractAddressOrFail, keyUnclaimedReferral(referralProgramName, address)), 0)
560471 let totalAmount = (amount + referralUnclaimed)
561472 $Tuple2(nil, totalAmount)
622533 let ann = (amp * nCoins)
623534 let arr = [0, 1, 2, 3, 4, 5, 6]
624535 func calc (acc,cur) = {
625- let $t02312123148 = acc
626- let d = $t02312123148._1
627- let dPrev = $t02312123148._2
628- let found = $t02312123148._3
536+ let $t02093120958 = acc
537+ let d = $t02093120958._1
538+ let dPrev = $t02093120958._2
539+ let found = $t02093120958._3
629540 if ((found != unit))
630541 then acc
631542 else {
638549 }
639550 }
640551
641- let $t02374623809 = {
552+ let $t02155621619 = {
642553 let $l = arr
643554 let $s = size($l)
644555 let $acc0 = $Tuple3(s, unit, unit)
652563
653564 $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)
654565 }
655- let dNext = $t02374623809._1
656- let dPrev = $t02374623809._2
657- let found = $t02374623809._3
566+ let dNext = $t02155621619._1
567+ let dPrev = $t02155621619._2
568+ let found = $t02155621619._3
658569 if ((found != unit))
659570 then $Tuple2(nil, toString(dNext))
660571 else {
663574 }
664575 }
665576 }
666-
667-
668-
669-@Callable(i)
670-func tradeReward (userAddresses,rewards) = {
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))
684- then {
685- let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil)
686- if ((tradeRewardInternal == tradeRewardInternal))
687- then $Tuple2(nil, tradeRewardInternal)
688- else throw("Strict value is not equal to itself.")
689- }
690- else throw("Strict value is not equal to itself.")
691- }
692-
693-
694-
695-@Callable(i)
696-func claimTradingReward () = {
697- let userAddress = i.caller
698- let reward = getTradingReward(toString(userAddress))
699- if ((reward > 0))
700- then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId)], reward)
701- else throwErr("nothing to claim")
702- }
703-
704-
705-
706-@Callable(i)
707-func claimTradingRewardREADONLY (userAddress) = $Tuple2(nil, getTradingReward(userAddress))
708577
709578
710579 @Verifier(tx)
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
1010 let zeroBigInt = toBigInt(0)
1111
1212 let processingStageTotal = 0
1313
1414 let processingStageShares = 1
1515
16-let wavesString = "WAVES"
17-
1816 func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0)
1917
2018
2119 func getNumberOrFail (key) = valueOrErrorMessage(getInteger(this, key), (("mandatory this." + key) + " is not defined"))
2220
2321
2422 func getStringByKey (key) = valueOrElse(getString(this, key), "")
2523
2624
2725 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-
34-
35-func wrapErr (msg) = makeString(["gwx_reward.ride:", msg], " ")
36-
37-
38-func throwErr (msg) = throw(wrapErr(msg))
3926
4027
4128 func abs (val) = if ((0 > val))
4229 then -(val)
4330 else val
4431
4532
4633 func absBigInt (val) = if ((zeroBigInt > val))
4734 then -(val)
4835 else val
4936
5037
5138 let keyMaxDepth = "%s__maxDepth"
5239
5340 let maxDepthDefault = 30
5441
5542 let maxDepth = valueOrElse(getInteger(this, keyMaxDepth), maxDepthDefault)
5643
5744 func keyFactoryAddress () = "%s%s__config__factoryAddress"
5845
5946
6047 let factoryAddressStr = getStringOrFail(keyFactoryAddress())
6148
6249 let factoryContract = addressFromStringValue(factoryAddressStr)
6350
6451 func keyEmissionAddress () = "%s%s__config__emissionAddress"
6552
66-
67-func keyVotingEmissionContract () = makeString(["%s", "votingEmissionContract"], SEP)
68-
69-
70-let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract()))
7153
7254 func keyNumToUserMapping (num) = makeString(["%s%s%s", "mapping", "num2user", toString(num)], SEP)
7355
7456
7557 let keyReferralProgramName = makeString(["%s%s", "referral", "programName"], SEP)
7658
7759 let referralProgramNameDefault = "wxlock"
7860
7961 let referralProgramName = valueOrElse(getString(this, keyReferralProgramName), referralProgramNameDefault)
8062
8163 let keyReferralMinGWxAmount = makeString(["%s%s", "referral", "minGWxAmount"], SEP)
8264
8365 let referralMinGWxAmountDefault = (500 * MULT8)
8466
8567 let referralMinGWxAmount = valueOrElse(getInteger(this, keyReferralMinGWxAmount), referralMinGWxAmountDefault)
8668
8769 let keyReferrerRewardPermille = makeString(["%s%s", "referral", "referrerRewardPermille"], SEP)
8870
8971 let referrerRewardPermilleDefault = 50
9072
9173 let referrerRewardPermille = valueOrElse(getInteger(this, keyReferrerRewardPermille), referrerRewardPermilleDefault)
9274
9375 let keyReferralRewardPermille = makeString(["%s%s", "referral", "referralRewardPermille"], SEP)
9476
9577 let referralRewardPermilleDefault = 50
9678
9779 let referralRewardPermille = valueOrElse(getInteger(this, keyReferralRewardPermille), referralRewardPermilleDefault)
9880
9981 func keyReferrer (referralAddress) = makeString(["%s%s%s", "referrer", referralProgramName, referralAddress], SEP)
10082
10183
10284 func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferral", programName, claimerAddress], SEP)
10385
10486
10587 let emissionAddressStr = getStringOrFail(keyEmissionAddress())
10688
10789 let emissionContract = addressFromStringValue(emissionAddressStr)
10890
10991 let IdxCfgAssetId = 1
11092
11193 let IdxCfgPacemakerAddress = 2
11294
11395 let IdxCfgBoostingContract = 3
11496
11597 let IdxCfgMaxDepth = 4
11698
11799 func keyConfig () = "%s__config"
118100
119101
120-func getEmissionAddress () = addressFromStringValue(valueOrErrorMessage(getString(this, keyEmissionAddress()), (("mandatory this." + keyEmissionAddress()) + " is not defined")))
121-
122-
123-let emissionAddress = getEmissionAddress()
124-
125-let wxAssetIdStr = split(value(getString(emissionAddress, keyConfig())), SEP)[1]
126-
127-let wxAssetId = fromBase58String(wxAssetIdStr)
128-
129102 func readConfigArrayOrFail () = split(getStringOrFail(keyConfig()), SEP)
130103
131104
132105 func formatConfig (wxAssetIdStr,matcherPacemakerAddressStr,boostingContractAddressStr,maxDepth) = makeString(["%s%s%s%d", wxAssetIdStr, matcherPacemakerAddressStr, boostingContractAddressStr, toString(maxDepth)], SEP)
133106
134107
135108 func boostingContractOrFail () = {
136109 let cfgArray = readConfigArrayOrFail()
137110 valueOrErrorMessage(addressFromString(cfgArray[IdxCfgBoostingContract]), "boosting contract address is not defined")
138111 }
139112
140113
141114 func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight"
142115
143116
144117 func keyUsersCount () = "%s__nextUserNum"
145118
146119
147120 func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current"
148-
149-
150-func keyGwxHoldersRewardCurrent () = "%s%s__gwxHoldersReward__current"
151-
152-
153-func keyGwxHoldersRewardNext () = "%s%s__gwxHoldersReward__next"
154121
155122
156123 func keyPoolWeightVirtual () = "%s%s__poolWeight__GWXvirtualPOOL"
157124
158125
159126 func keyNextProcessedUser () = "%s__nextProcessedUser"
160127
161128
162129 func keyLatestPeriod () = "%s__latestPeriod"
163130
164131
165132 func keyNextPeriod () = "%s__nextPeriod"
166133
167134
168135 func keyProcessingStage () = "%s__processingStage"
169136
170137
171138 func keyNextProcessedPeriod () = "%s__nextProcessedPeriod"
172139
173140
174141 func keyUserUnclaimed (userIndex) = makeString(["%s%d", "userUnclaimed", toString(userIndex)], SEP)
175142
176143
177144 func keyNextUnlaimedPeriodOfUser (userIndex) = makeString(["%s%d__nextClaimedPeriod", toString(userIndex)], SEP)
178145
179146
180147 func keyLastProcessedPeriodOfUser (userIndex) = makeString(["%s%d__lastProcessedPeriod", toString(userIndex)], SEP)
181148
182149
183150 func keyHeightForPeriod (period) = makeString(["%s%d__startHeightForPeriod", toString(period)], SEP)
184151
185152
186153 func keyAuxEmissionRewardForPeriod (period) = makeString(["%s%d__auxEmissionReward", toString(period)], SEP)
187154
188155
189156 func keyTotalAmountForPeriod (period) = makeString(["%s%d__totalAmountForPeriod", toString(period)], SEP)
190157
191158
192159 func keyLastPayoutInfo () = "%s__lastPayoutInfo"
193160
194161
195162 func PeriodPayoutInfo (period,matcherReward,emissionReward) = makeString(["%d%d%d", toString(period), toString(matcherReward), toString(emissionReward)], SEP)
196163
197164
198165 func keyPayoutHistoryInfo (period) = makeString(["%s%s%d__payouts__history", toString(period)], SEP)
199166
200167
201168 func keyTotalWeightForPeriod (period) = makeString(["%s%d__totalWeightForPeriod", toString(period)], SEP)
202169
203170
204171 func keyUserKValueForPeriod (period,userIndex) = makeString(["%s%d%s%d__paramByPeriod", toString(userIndex), "k", toString(period)], SEP)
205172
206173
207174 func keyUserBValueForPeriod (period,userIndex) = makeString(["%s%d%s%d__paramByPeriod", toString(userIndex), "b", toString(period)], SEP)
208175
209176
210177 func keyUserWeightForPeriod (period,userIndex) = makeString(["%s%d%s%d__paramByPeriod", toString(userIndex), "weight", toString(period)], SEP)
211178
212179
213180 func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP)
214181
215182
216183 let referralsContractAddressOrFail = addressFromStringValue(getStringOrFail(keyReferralsContractAddress()))
217-
218-func keyTradingRewardHistory (user,i) = makeString(["%s%s%s%s", "tradingReward", "history", user, toBase58String(i.transactionId)], SEP)
219-
220-
221-func keyTradingReward (userAddress) = makeString(["%s%s", "tradingReward", userAddress], SEP)
222-
223-
224-func keyMaxRecipients () = makeString(["%s", "maxRecipients"], SEP)
225-
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
278236 func calcUserWeight (boostingContractAddress,heightForPeriod,period,userIndex) = {
279237 let kLast = keyLastProcessedPeriodOfUser(userIndex)
280238 let kKey = keyUserKValueForPeriod(period, userIndex)
281239 let kRaw = getInteger(boostingContractAddress, kKey)
282240 let kUserWeight = keyUserWeightForPeriod(period, userIndex)
283241 if (isDefined(kRaw))
284242 then {
285243 let k = value(kRaw)
286244 let b = value(getInteger(boostingContractAddress, keyUserBValueForPeriod(period, userIndex)))
287245 let w = ((k * heightForPeriod) + b)
288246 if ((w > 0))
289247 then $Tuple2((w / SCALE), [IntegerEntry(kLast, period), IntegerEntry(kUserWeight, w)])
290248 else $Tuple2(0, nil)
291249 }
292250 else {
293251 let p = getInteger(this, kLast)
294252 if (if (isDefined(p))
295253 then (period >= value(p))
296254 else false)
297255 then {
298256 let pv = value(p)
299257 let k = value(getInteger(boostingContractAddress, keyUserKValueForPeriod(pv, userIndex)))
300258 let b = value(getInteger(boostingContractAddress, keyUserBValueForPeriod(pv, userIndex)))
301259 let w = ((k * heightForPeriod) + b)
302260 if ((w > 0))
303261 then $Tuple2((w / SCALE), [IntegerEntry(kUserWeight, w)])
304262 else $Tuple2(0, nil)
305263 }
306264 else $Tuple2(0, nil)
307265 }
308266 }
309267
310268
311269 func calcUserWeightForClaim (boostingContractAddress,heightForPeriod,period,userIndex) = {
312270 let kUserWeight = keyUserWeightForPeriod(period, userIndex)
313271 let userWeightOrUnit = getInteger(kUserWeight)
314272 match userWeightOrUnit {
315273 case _: Unit =>
316274 0
317275 case w: Int =>
318276 (w / SCALE)
319277 case _ =>
320278 throw("Match error")
321279 }
322280 }
323281
324282
325283 func getUserIndexByAddress (boostingContractAddressStr,userAddress) = {
326284 let key = makeString(["%s%s%s", "mapping", "user2num", userAddress], SEP)
327285 parseIntValue(valueOrErrorMessage(getString(Address(fromBase58String(boostingContractAddressStr)), key), ((("User address " + userAddress) + " is not found in boosting contract data, key=") + key)))
328286 }
329287
330288
331289 func nextPeriod () = getNumberByKey(keyNextPeriod())
332290
333291
334292 func commonClaimReward (userAddress) = {
335293 let cfgArray = readConfigArrayOrFail()
336294 let userIdx = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddress)
337295 let userUnclaimedOption = getInteger(keyUserUnclaimed(userIdx))
338296 match userUnclaimedOption {
339297 case _: Unit =>
340298 $Tuple2(0, nil)
341299 case u: Int =>
342300 $Tuple2(u, [IntegerEntry(keyUserUnclaimed(userIdx), 0)])
343301 case _ =>
344302 throw("Match error")
345303 }
346304 }
347305
348306
349-func getTradingReward (userAddress) = valueOrElse(getInteger(this, keyTradingReward(userAddress)), 0)
350-
351-
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- }
374-
375-
376-
377307 @Callable(i)
378308 func updateReferralActivity (userAddress,gWxAmountStart) = {
379309 let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress))
380310 let activeReferralInv = if ((referrer == unit))
381311 then unit
382312 else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil)
383313 if ((activeReferralInv == activeReferralInv))
384314 then $Tuple2(nil, unit)
385315 else throw("Strict value is not equal to itself.")
386316 }
387317
388318
389319
390320 @Callable(i)
391321 func finalizeHelper () = {
392322 let processingStage = valueOrElse(getInteger(keyProcessingStage()), processingStageTotal)
393323 let currentPeriod = getNumberByKey(keyNextProcessedPeriod())
394324 let currentUser = getNumberByKey(keyNextProcessedUser())
395325 let latestPeriod = getNumberByKey(keyLatestPeriod())
396326 let usersCount = valueOrElse(getInteger(boostingContractOrFail(), keyUsersCount()), 0)
397327 let totalWeightKey = keyTotalWeightForPeriod(currentPeriod)
398328 let totalWeight = getNumberByKey(keyTotalWeightForPeriod(currentPeriod))
399329 let heightForPeriod = getNumberByKey(keyHeightForPeriod(currentPeriod))
400330 if ((currentPeriod > latestPeriod))
401331 then $Tuple2(nil, false)
402332 else if ((processingStage == processingStageTotal))
403333 then {
404- let $t01451014626 = calcUserWeight(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser)
405- let userWeight = $t01451014626._1
406- let userActions = $t01451014626._2
334+ let $t01216712283 = calcUserWeight(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser)
335+ let userWeight = $t01216712283._1
336+ let userActions = $t01216712283._2
407337 let totalWeightNew = (totalWeight + userWeight)
408338 let processingActions = if (((usersCount - 1) > currentUser))
409339 then [IntegerEntry(keyNextProcessedUser(), (currentUser + 1))]
410340 else [IntegerEntry(keyProcessingStage(), processingStageShares), IntegerEntry(keyNextProcessedUser(), 0)]
411341 $Tuple2((([IntegerEntry(totalWeightKey, totalWeightNew)] ++ processingActions) ++ userActions), true)
412342 }
413343 else if ((processingStage == processingStageShares))
414344 then {
415345 let userWeight = calcUserWeightForClaim(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser)
416346 let userAmountMatcherForPeriod = fraction(getNumberByKey(keyTotalAmountForPeriod(currentPeriod)), userWeight, totalWeight)
417347 let userAmountEmissionForPeriod = fraction(getNumberByKey(keyAuxEmissionRewardForPeriod(currentPeriod)), userWeight, totalWeight)
418348 let userTotalAmount = (userAmountEmissionForPeriod + userAmountMatcherForPeriod)
419349 let userUnclaimedOption = getInteger(keyUserUnclaimed(currentUser))
420350 let userAddress = getStringValue(boostingContractOrFail(), keyNumToUserMapping(currentUser))
421351 let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress))
422352 let activeReferralInv = if ((referrer == unit))
423353 then unit
424354 else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userWeight >= referralMinGWxAmount)], nil)
425355 if ((activeReferralInv == activeReferralInv))
426356 then {
427357 let referralInv = if (if ((referrer == unit))
428358 then true
429359 else (referralMinGWxAmount > userWeight))
430360 then unit
431361 else {
432362 let referrerReward = fraction(userTotalAmount, referrerRewardPermille, SCALE)
433363 let referralReward = fraction(userTotalAmount, referralRewardPermille, SCALE)
434364 invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil)
435365 }
436366 if ((referralInv == referralInv))
437367 then {
438368 let unclaimedActions = [IntegerEntry(keyUserUnclaimed(currentUser), (valueOrElse(userUnclaimedOption, 0) + userTotalAmount))]
439369 let processingActions = if (((usersCount - 1) > currentUser))
440370 then [IntegerEntry(keyNextProcessedUser(), (currentUser + 1))]
441371 else [IntegerEntry(keyNextProcessedPeriod(), (currentPeriod + 1)), IntegerEntry(keyNextProcessedUser(), 0), DeleteEntry(keyProcessingStage())]
442372 $Tuple2((unclaimedActions ++ processingActions), true)
443373 }
444374 else throw("Strict value is not equal to itself.")
445375 }
446376 else throw("Strict value is not equal to itself.")
447377 }
448378 else throw("invalid processing stage")
449379 }
450380
451381
452382
453383 @Callable(i)
454384 func finalizeWrapper (counter) = {
455385 let result = {
456386 let @ = invoke(this, "finalizeHelper", nil, nil)
457387 if ($isInstanceOf(@, "Boolean"))
458388 then @
459389 else throw(($getType(@) + " couldn't be cast to Boolean"))
460390 }
461391 if ((result == result))
462392 then if (!(result))
463393 then if ((counter == maxDepth))
464394 then throw("Nothing to process")
465395 else $Tuple2(nil, unit)
466396 else if ((counter > 0))
467397 then $Tuple2(nil, invoke(this, "finalizeWrapper", [(counter - 1)], nil))
468398 else $Tuple2(nil, unit)
469399 else throw("Strict value is not equal to itself.")
470400 }
471401
472402
473403
474404 @Callable(i)
475405 func processPendingPeriodsAndUsers () = $Tuple2(nil, invoke(this, "finalizeWrapper", [maxDepth], nil))
476406
477407
478408
479409 @Callable(i)
480410 func deposit () = {
481- let checkCaller = if ((i.caller == votingEmissionContract))
482- then true
483- else mustManager(i)
484- if ((checkCaller == checkCaller))
485- 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))
491- 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
411+ let cfgArray = readConfigArrayOrFail()
412+ if ((i.caller != Address(fromBase58String(cfgArray[IdxCfgPacemakerAddress]))))
413+ then throw("Wrong caller address")
414+ else {
415+ let assetId = value(value(i.payments[0]).assetId)
416+ if ((assetId != fromBase58String(cfgArray[IdxCfgAssetId])))
417+ then throw("Wrong payment asset")
418+ else {
419+ let period = nextPeriod()
420+ let deltaH = (height - getNumberOrFail(keyGwxRewardEmissionStartHeight()))
421+ let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), (("mandatory emission_contract." + keyRatePerBlockCurrent()) + " is not defined"))
422+ let weight = valueOrErrorMessage(getInteger(factoryContract, keyPoolWeightVirtual()), (("mandatory factory_contract." + keyPoolWeightVirtual()) + " is not defined"))
423+ let auxAmount = fraction((deltaH * weight), emissionRate, MULT8)
424+ let em = invoke(emissionContract, "emit", [auxAmount], nil)
496425 if ((em == em))
497426 then {
498- let matcherPart = 0
427+ let matcherPart = value(i.payments[0]).amount
499428 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))
507- 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)
515- }
516- else throw("Strict value is not equal to itself.")
429+[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)]
517430 }
518431 else throw("Strict value is not equal to itself.")
519432 }
520- else throw("Strict value is not equal to itself.")
521433 }
522- else throw("Strict value is not equal to itself.")
523434 }
524435
525436
526437
527438 @Callable(i)
528439 func claimReward () = {
529440 let cfgArray = readConfigArrayOrFail()
530441 let address = toString(i.caller)
531- let $t01981519865 = commonClaimReward(address)
532- let amount = $t01981519865._1
533- let actions = $t01981519865._2
442+ let $t01762517675 = commonClaimReward(address)
443+ let amount = $t01762517675._1
444+ let actions = $t01762517675._2
534445 let checkAmount = if ((amount > 0))
535446 then true
536447 else throw("Nothing to claim")
537448 if ((checkAmount == checkAmount))
538449 then {
539450 let amountFromEmission = 0
540451 let claimedReferral = {
541452 let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil)
542453 if ($isInstanceOf(@, "Int"))
543454 then @
544455 else throw(($getType(@) + " couldn't be cast to Int"))
545456 }
546457 let totalAmount = (amount + claimedReferral)
547458 $Tuple2(([ScriptTransfer(i.caller, totalAmount, fromBase58String(cfgArray[IdxCfgAssetId])), HistoryEntry("claim", address, amount, i)] ++ actions), [totalAmount, amountFromEmission])
548459 }
549460 else throw("Strict value is not equal to itself.")
550461 }
551462
552463
553464
554465 @Callable(i)
555466 func claimRewardREADONLY (address) = {
556- let $t02043820488 = commonClaimReward(address)
557- let amount = $t02043820488._1
558- let actions = $t02043820488._2
467+ let $t01824818298 = commonClaimReward(address)
468+ let amount = $t01824818298._1
469+ let actions = $t01824818298._2
559470 let referralUnclaimed = valueOrElse(getInteger(referralsContractAddressOrFail, keyUnclaimedReferral(referralProgramName, address)), 0)
560471 let totalAmount = (amount + referralUnclaimed)
561472 $Tuple2(nil, totalAmount)
562473 }
563474
564475
565476
566477 @Callable(i)
567478 func latestFinalizedPeriodREADONLY (address) = $Tuple2(nil, valueOrElse(getInteger(this, keyLatestPeriod()), -1))
568479
569480
570481
571482 @Callable(i)
572483 func latestFinalizedPeriodInfoREADONLY (address) = $Tuple2(nil, getStringByKey(keyLastPayoutInfo()))
573484
574485
575486
576487 @Callable(i)
577488 func calcGwxParamsREADONLY (gwxAmountStart,lockStartHeight,lockDurationBlocks) = {
578489 let lockEndHeight = (lockStartHeight + lockDurationBlocks)
579490 let scale8ParamK = -(fraction(gwxAmountStart, SCALE, lockDurationBlocks))
580491 let scale8ParamB = (fraction(gwxAmountStart, SCALE, lockDurationBlocks) * lockEndHeight)
581492 $Tuple2(nil, [scale8ParamK, scale8ParamB, nextPeriod()])
582493 }
583494
584495
585496
586497 @Callable(i)
587498 func calcGwxAmountStartREADONLY (wxLockAmount,lockDuration,maxLockDuration) = {
588499 let coeffX8 = fraction(lockDuration, MULT8, maxLockDuration)
589500 let gWxAmountStart = fraction(wxLockAmount, coeffX8, MULT8)
590501 $Tuple2(nil, [gWxAmountStart])
591502 }
592503
593504
594505
595506 @Callable(i)
596507 func onEmissionForGwxStart () = if ((i.caller != factoryContract))
597508 then throw("permissions denied")
598509 else [IntegerEntry(keyGwxRewardEmissionStartHeight(), height)]
599510
600511
601512
602513 @Callable(i)
603514 func latestPeriodEmissionRewardsREADONLY (address) = {
604515 let period = nextPeriod()
605516 $Tuple2(nil, [getNumberByKey(keyAuxEmissionRewardForPeriod(period))])
606517 }
607518
608519
609520
610521 @Callable(i)
611522 func calcD (x1BigIntStr,x2BigIntStr,ampBigIntStr,aPrecisionBigIntStr,targetPrecisionBigIntStr) = {
612523 let nCoins = toBigInt(2)
613524 let aPrecision = parseBigIntValue(aPrecisionBigIntStr)
614525 let targetPrecision = parseBigIntValue(targetPrecisionBigIntStr)
615526 let x1 = parseBigIntValue(x1BigIntStr)
616527 let x2 = parseBigIntValue(x2BigIntStr)
617528 let amp = (parseBigIntValue(ampBigIntStr) * aPrecision)
618529 let s = (x1 + x2)
619530 if ((s == zeroBigInt))
620531 then $Tuple2(nil, toString(zeroBigInt))
621532 else {
622533 let ann = (amp * nCoins)
623534 let arr = [0, 1, 2, 3, 4, 5, 6]
624535 func calc (acc,cur) = {
625- let $t02312123148 = acc
626- let d = $t02312123148._1
627- let dPrev = $t02312123148._2
628- let found = $t02312123148._3
536+ let $t02093120958 = acc
537+ let d = $t02093120958._1
538+ let dPrev = $t02093120958._2
539+ let found = $t02093120958._3
629540 if ((found != unit))
630541 then acc
631542 else {
632543 let dp = (((d * d) * d) / (((x1 * x2) * nCoins) * nCoins))
633544 let dNext = (((((ann * s) / aPrecision) + (dp * nCoins)) * d) / ((((ann - aPrecision) * d) / aPrecision) + ((nCoins + toBigInt(1)) * dp)))
634545 let dDiff = absBigInt((dNext - value(d)))
635546 if ((targetPrecision >= dDiff))
636547 then $Tuple3(dNext, d, cur)
637548 else $Tuple3(dNext, d, unit)
638549 }
639550 }
640551
641- let $t02374623809 = {
552+ let $t02155621619 = {
642553 let $l = arr
643554 let $s = size($l)
644555 let $acc0 = $Tuple3(s, unit, unit)
645556 func $f0_1 ($a,$i) = if (($i >= $s))
646557 then $a
647558 else calc($a, $l[$i])
648559
649560 func $f0_2 ($a,$i) = if (($i >= $s))
650561 then $a
651562 else throw("List size exceeds 7")
652563
653564 $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)
654565 }
655- let dNext = $t02374623809._1
656- let dPrev = $t02374623809._2
657- let found = $t02374623809._3
566+ let dNext = $t02155621619._1
567+ let dPrev = $t02155621619._2
568+ let found = $t02155621619._3
658569 if ((found != unit))
659570 then $Tuple2(nil, toString(dNext))
660571 else {
661572 let dDiff = absBigInt((dNext - value(dPrev)))
662573 throw(("D calculation error, dDiff = " + toString(dDiff)))
663574 }
664575 }
665576 }
666-
667-
668-
669-@Callable(i)
670-func tradeReward (userAddresses,rewards) = {
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))
684- then {
685- let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil)
686- if ((tradeRewardInternal == tradeRewardInternal))
687- then $Tuple2(nil, tradeRewardInternal)
688- else throw("Strict value is not equal to itself.")
689- }
690- else throw("Strict value is not equal to itself.")
691- }
692-
693-
694-
695-@Callable(i)
696-func claimTradingReward () = {
697- let userAddress = i.caller
698- let reward = getTradingReward(toString(userAddress))
699- if ((reward > 0))
700- then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId)], reward)
701- else throwErr("nothing to claim")
702- }
703-
704-
705-
706-@Callable(i)
707-func claimTradingRewardREADONLY (userAddress) = $Tuple2(nil, getTradingReward(userAddress))
708577
709578
710579 @Verifier(tx)
711580 func verify () = {
712581 let targetPublicKey = match managerPublicKeyOrUnit() {
713582 case pk: ByteVector =>
714583 pk
715584 case _: Unit =>
716585 tx.senderPublicKey
717586 case _ =>
718587 throw("Match error")
719588 }
720589 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
721590 }
722591

github/deemru/w8io/026f985 
189.07 ms