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