tx · 958jHzAm97nACCBdSrVUWCfUuN6RBimQU8Rf2Q2Wjz3k 3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE: -0.01800000 Waves 2023.04.24 11:38 [2548400] smart account 3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE > SELF 0.00000000 Waves
{ "type": 13, "id": "958jHzAm97nACCBdSrVUWCfUuN6RBimQU8Rf2Q2Wjz3k", "fee": 1800000, "feeAssetId": null, "timestamp": 1682325588365, "version": 2, "chainId": 84, "sender": "3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE", "senderPublicKey": "G349Uq3FTox7dRNLeAfAQeoACvwZ9iEnVSaHcEYn6j8J", "proofs": [ "4WyRW2hyPzf3Bk8r9UnPNeQVMsvQaXLuHEAeenSMuQ3fiNHhjH3ivMfiCCBKYGrv5zsqKo1Xqss26uRRctVqGQtf" ], "script": "base64:BgKPGQgCEgQKAggBEgASAwoBARIAEgASABIDCgEIEgMKAQgSAwoBCBIFCgMBAQESBQoDAQEBEgASAwoBCBIHCgUICAgICBIDCgEIEgAiA1NFUCIFU0NBTEUiBU1VTFQ4Igp6ZXJvQmlnSW50IhRwcm9jZXNzaW5nU3RhZ2VUb3RhbCIVcHJvY2Vzc2luZ1N0YWdlU2hhcmVzIg5nZXROdW1iZXJCeUtleSIDa2V5Ig9nZXROdW1iZXJPckZhaWwiDmdldFN0cmluZ0J5S2V5Ig9nZXRTdHJpbmdPckZhaWwiA2FicyIDdmFsIglhYnNCaWdJbnQiC2tleU1heERlcHRoIg9tYXhEZXB0aERlZmF1bHQiCG1heERlcHRoIhFrZXlGYWN0b3J5QWRkcmVzcyIRZmFjdG9yeUFkZHJlc3NTdHIiD2ZhY3RvcnlDb250cmFjdCISa2V5RW1pc3Npb25BZGRyZXNzIhNrZXlOdW1Ub1VzZXJNYXBwaW5nIgNudW0iFmtleVJlZmVycmFsUHJvZ3JhbU5hbWUiGnJlZmVycmFsUHJvZ3JhbU5hbWVEZWZhdWx0IhNyZWZlcn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ECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECZGEBAmRiAAQCZGMEAmFPCQECYU4AAwkAAQIFAmFPAgpCeXRlVmVjdG9yBAJhVAUCYU8FAmFUAwkAAQIFAmFPAgRVbml0CAUCZGEPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAmRhCWJvZHlCeXRlcwkAkQMCCAUCZGEGcHJvb2ZzAAAFAmRj6gXGCA==", "height": 2548400, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 29mtBhKRAQh5dMH7TYqryWqcsiUQQSZiwH2q7VG5JL8L Next: 121KLAoDzyHyfc45Y69acyfxP1nJKnQE1VHsU4juyXwD 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 keyMaxRecipients () = makeString(["%s", "maxRecipients"], SEP) | |
222 | - | ||
223 | 184 | ||
224 | 185 | func HistoryEntry (type,user,amount,i) = { | |
225 | 186 | let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP) | |
343 | 304 | ||
344 | 305 | ||
345 | 306 | @Callable(i) | |
346 | - | func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = if ((currentIter == size(userAddresses))) | |
347 | - | then nil | |
348 | - | else { | |
349 | - | let checks = [if ((i.caller == this)) | |
350 | - | then true | |
351 | - | else throwErr("Permission denied"), if ((paymentAmountLeftOver >= rewards[currentIter])) | |
352 | - | then true | |
353 | - | else throwErr("insufficient payment assetId")] | |
354 | - | if ((checks == checks)) | |
355 | - | then { | |
356 | - | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [(paymentAmountLeftOver - rewards[currentIter]), userAddresses, rewards, (currentIter + 1)], nil) | |
357 | - | if ((tradeRewardInternal == tradeRewardInternal)) | |
358 | - | then { | |
359 | - | let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i) | |
360 | - | let userAddress = addressFromStringValue(userAddresses[currentIter]) | |
361 | - | $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), ScriptTransfer(userAddress, rewards[currentIter], wxAssetId)], tradeRewardInternal) | |
362 | - | } | |
363 | - | else throw("Strict value is not equal to itself.") | |
364 | - | } | |
365 | - | else throw("Strict value is not equal to itself.") | |
366 | - | } | |
367 | - | ||
368 | - | ||
369 | - | ||
370 | - | @Callable(i) | |
371 | 307 | func updateReferralActivity (userAddress,gWxAmountStart) = { | |
372 | 308 | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
373 | 309 | let activeReferralInv = if ((referrer == unit)) | |
394 | 330 | then $Tuple2(nil, false) | |
395 | 331 | else if ((processingStage == processingStageTotal)) | |
396 | 332 | then { | |
397 | - | let $ | |
398 | - | let userWeight = $ | |
399 | - | let userActions = $ | |
333 | + | let $t01208212198 = calcUserWeight(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser) | |
334 | + | let userWeight = $t01208212198._1 | |
335 | + | let userActions = $t01208212198._2 | |
400 | 336 | let totalWeightNew = (totalWeight + userWeight) | |
401 | 337 | let processingActions = if (((usersCount - 1) > currentUser)) | |
402 | 338 | then [IntegerEntry(keyNextProcessedUser(), (currentUser + 1))] | |
471 | 407 | ||
472 | 408 | @Callable(i) | |
473 | 409 | func deposit () = { | |
474 | - | let checkCaller = if ((i.caller == votingEmissionContract)) | |
475 | - | then true | |
476 | - | else mustManager(i) | |
477 | - | if ((checkCaller == checkCaller)) | |
478 | - | then { | |
479 | - | let period = nextPeriod() | |
480 | - | let deltaH = (height - getNumberOrFail(keyGwxRewardEmissionStartHeight())) | |
481 | - | let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), (("mandatory emission_contract." + keyRatePerBlockCurrent()) + " is not defined")) | |
482 | - | let gwxHoldersRewardCurrent = valueOrElse(getInteger(emissionContract, keyGwxHoldersRewardCurrent()), 0) | |
483 | - | if ((gwxHoldersRewardCurrent == gwxHoldersRewardCurrent)) | |
484 | - | then { | |
485 | - | let auxAmount = fraction((deltaH * gwxHoldersRewardCurrent), emissionRate, MULT8) | |
486 | - | let em = if ((auxAmount > 0)) | |
487 | - | then invoke(emissionContract, "emit", [auxAmount], nil) | |
488 | - | else unit | |
410 | + | let cfgArray = readConfigArrayOrFail() | |
411 | + | if ((i.caller != Address(fromBase58String(cfgArray[IdxCfgPacemakerAddress])))) | |
412 | + | then throw("Wrong caller address") | |
413 | + | else { | |
414 | + | let assetId = value(value(i.payments[0]).assetId) | |
415 | + | if ((assetId != fromBase58String(cfgArray[IdxCfgAssetId]))) | |
416 | + | then throw("Wrong payment asset") | |
417 | + | else { | |
418 | + | let period = nextPeriod() | |
419 | + | let deltaH = (height - getNumberOrFail(keyGwxRewardEmissionStartHeight())) | |
420 | + | let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), (("mandatory emission_contract." + keyRatePerBlockCurrent()) + " is not defined")) | |
421 | + | let weight = valueOrErrorMessage(getInteger(factoryContract, keyPoolWeightVirtual()), (("mandatory factory_contract." + keyPoolWeightVirtual()) + " is not defined")) | |
422 | + | let auxAmount = fraction((deltaH * weight), emissionRate, MULT8) | |
423 | + | let em = invoke(emissionContract, "emit", [auxAmount], nil) | |
489 | 424 | if ((em == em)) | |
490 | 425 | then { | |
491 | - | let matcherPart = 0 | |
426 | + | let matcherPart = value(i.payments[0]).amount | |
492 | 427 | let payoutInfo = PeriodPayoutInfo(period, matcherPart, auxAmount) | |
493 | - | let gwxHoldersRewardUpdated = { | |
494 | - | let @ = invoke(emissionContract, "gwxHoldersRewardUpdate", nil, nil) | |
495 | - | if ($isInstanceOf(@, "Boolean")) | |
496 | - | then @ | |
497 | - | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
498 | - | } | |
499 | - | if ((gwxHoldersRewardUpdated == gwxHoldersRewardUpdated)) | |
500 | - | then { | |
501 | - | let totalReward = (matcherPart + auxAmount) | |
502 | - | let actions = if (if ((totalReward == 0)) | |
503 | - | then !(gwxHoldersRewardUpdated) | |
504 | - | else false) | |
505 | - | then nil | |
506 | - | 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)] | |
507 | - | $Tuple2(actions, unit) | |
508 | - | } | |
509 | - | else throw("Strict value is not equal to itself.") | |
428 | + | [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)] | |
510 | 429 | } | |
511 | 430 | else throw("Strict value is not equal to itself.") | |
512 | 431 | } | |
513 | - | else throw("Strict value is not equal to itself.") | |
514 | 432 | } | |
515 | - | else throw("Strict value is not equal to itself.") | |
516 | 433 | } | |
517 | 434 | ||
518 | 435 | ||
521 | 438 | func claimReward () = { | |
522 | 439 | let cfgArray = readConfigArrayOrFail() | |
523 | 440 | let address = toString(i.caller) | |
524 | - | let $ | |
525 | - | let amount = $ | |
526 | - | let actions = $ | |
441 | + | let $t01754017590 = commonClaimReward(address) | |
442 | + | let amount = $t01754017590._1 | |
443 | + | let actions = $t01754017590._2 | |
527 | 444 | let checkAmount = if ((amount > 0)) | |
528 | 445 | then true | |
529 | 446 | else throw("Nothing to claim") | |
546 | 463 | ||
547 | 464 | @Callable(i) | |
548 | 465 | func claimRewardREADONLY (address) = { | |
549 | - | let $ | |
550 | - | let amount = $ | |
551 | - | let actions = $ | |
466 | + | let $t01816318213 = commonClaimReward(address) | |
467 | + | let amount = $t01816318213._1 | |
468 | + | let actions = $t01816318213._2 | |
552 | 469 | let referralUnclaimed = valueOrElse(getInteger(referralsContractAddressOrFail, keyUnclaimedReferral(referralProgramName, address)), 0) | |
553 | 470 | let totalAmount = (amount + referralUnclaimed) | |
554 | 471 | $Tuple2(nil, totalAmount) | |
615 | 532 | let ann = (amp * nCoins) | |
616 | 533 | let arr = [0, 1, 2, 3, 4, 5, 6] | |
617 | 534 | func calc (acc,cur) = { | |
618 | - | let $ | |
619 | - | let d = $ | |
620 | - | let dPrev = $ | |
621 | - | let found = $ | |
535 | + | let $t02084620873 = acc | |
536 | + | let d = $t02084620873._1 | |
537 | + | let dPrev = $t02084620873._2 | |
538 | + | let found = $t02084620873._3 | |
622 | 539 | if ((found != unit)) | |
623 | 540 | then acc | |
624 | 541 | else { | |
631 | 548 | } | |
632 | 549 | } | |
633 | 550 | ||
634 | - | let $ | |
551 | + | let $t02147121534 = { | |
635 | 552 | let $l = arr | |
636 | 553 | let $s = size($l) | |
637 | 554 | let $acc0 = $Tuple3(s, unit, unit) | |
645 | 562 | ||
646 | 563 | $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) | |
647 | 564 | } | |
648 | - | let dNext = $ | |
649 | - | let dPrev = $ | |
650 | - | let found = $ | |
565 | + | let dNext = $t02147121534._1 | |
566 | + | let dPrev = $t02147121534._2 | |
567 | + | let found = $t02147121534._3 | |
651 | 568 | if ((found != unit)) | |
652 | 569 | then $Tuple2(nil, toString(dNext)) | |
653 | 570 | else { | |
655 | 572 | throw(("D calculation error, dDiff = " + toString(dDiff))) | |
656 | 573 | } | |
657 | 574 | } | |
658 | - | } | |
659 | - | ||
660 | - | ||
661 | - | ||
662 | - | @Callable(i) | |
663 | - | func tradeReward (userAddresses,rewards) = { | |
664 | - | let argsComparison = (size(userAddresses) == size(rewards)) | |
665 | - | let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0) | |
666 | - | let payment = i.payments[0] | |
667 | - | let paymentAssetId = payment.assetId | |
668 | - | let paymentAmount = payment.amount | |
669 | - | let checks = [if ((maxRecipients >= size(userAddresses))) | |
670 | - | then true | |
671 | - | else throwErr("Too many recipients"), if (argsComparison) | |
672 | - | then true | |
673 | - | else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId)) | |
674 | - | then true | |
675 | - | else throwErr("Wrong asset payment")] | |
676 | - | if ((checks == checks)) | |
677 | - | then { | |
678 | - | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil) | |
679 | - | if ((tradeRewardInternal == tradeRewardInternal)) | |
680 | - | then $Tuple2(nil, tradeRewardInternal) | |
681 | - | else throw("Strict value is not equal to itself.") | |
682 | - | } | |
683 | - | else throw("Strict value is not equal to itself.") | |
684 | 575 | } | |
685 | 576 | ||
686 | 577 |
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 keyMaxRecipients () = makeString(["%s", "maxRecipients"], SEP) | |
222 | - | ||
223 | 184 | ||
224 | 185 | func HistoryEntry (type,user,amount,i) = { | |
225 | 186 | let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP) | |
226 | 187 | let historyDATA = makeString(["%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount)], SEP) | |
227 | 188 | StringEntry(historyKEY, historyDATA) | |
228 | 189 | } | |
229 | 190 | ||
230 | 191 | ||
231 | 192 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
232 | 193 | ||
233 | 194 | ||
234 | 195 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
235 | 196 | ||
236 | 197 | ||
237 | 198 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
238 | 199 | case s: String => | |
239 | 200 | fromBase58String(s) | |
240 | 201 | case _: Unit => | |
241 | 202 | unit | |
242 | 203 | case _ => | |
243 | 204 | throw("Match error") | |
244 | 205 | } | |
245 | 206 | ||
246 | 207 | ||
247 | 208 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
248 | 209 | case s: String => | |
249 | 210 | fromBase58String(s) | |
250 | 211 | case _: Unit => | |
251 | 212 | unit | |
252 | 213 | case _ => | |
253 | 214 | throw("Match error") | |
254 | 215 | } | |
255 | 216 | ||
256 | 217 | ||
257 | 218 | func mustManager (i) = { | |
258 | 219 | let pd = throw("Permission denied") | |
259 | 220 | match managerPublicKeyOrUnit() { | |
260 | 221 | case pk: ByteVector => | |
261 | 222 | if ((i.callerPublicKey == pk)) | |
262 | 223 | then true | |
263 | 224 | else pd | |
264 | 225 | case _: Unit => | |
265 | 226 | if ((i.caller == this)) | |
266 | 227 | then true | |
267 | 228 | else pd | |
268 | 229 | case _ => | |
269 | 230 | throw("Match error") | |
270 | 231 | } | |
271 | 232 | } | |
272 | 233 | ||
273 | 234 | ||
274 | 235 | func calcUserWeight (boostingContractAddress,heightForPeriod,period,userIndex) = { | |
275 | 236 | let kLast = keyLastProcessedPeriodOfUser(userIndex) | |
276 | 237 | let kKey = keyUserKValueForPeriod(period, userIndex) | |
277 | 238 | let kRaw = getInteger(boostingContractAddress, kKey) | |
278 | 239 | let kUserWeight = keyUserWeightForPeriod(period, userIndex) | |
279 | 240 | if (isDefined(kRaw)) | |
280 | 241 | then { | |
281 | 242 | let k = value(kRaw) | |
282 | 243 | let b = value(getInteger(boostingContractAddress, keyUserBValueForPeriod(period, userIndex))) | |
283 | 244 | let w = ((k * heightForPeriod) + b) | |
284 | 245 | if ((w > 0)) | |
285 | 246 | then $Tuple2((w / SCALE), [IntegerEntry(kLast, period), IntegerEntry(kUserWeight, w)]) | |
286 | 247 | else $Tuple2(0, nil) | |
287 | 248 | } | |
288 | 249 | else { | |
289 | 250 | let p = getInteger(this, kLast) | |
290 | 251 | if (if (isDefined(p)) | |
291 | 252 | then (period >= value(p)) | |
292 | 253 | else false) | |
293 | 254 | then { | |
294 | 255 | let pv = value(p) | |
295 | 256 | let k = value(getInteger(boostingContractAddress, keyUserKValueForPeriod(pv, userIndex))) | |
296 | 257 | let b = value(getInteger(boostingContractAddress, keyUserBValueForPeriod(pv, userIndex))) | |
297 | 258 | let w = ((k * heightForPeriod) + b) | |
298 | 259 | if ((w > 0)) | |
299 | 260 | then $Tuple2((w / SCALE), [IntegerEntry(kUserWeight, w)]) | |
300 | 261 | else $Tuple2(0, nil) | |
301 | 262 | } | |
302 | 263 | else $Tuple2(0, nil) | |
303 | 264 | } | |
304 | 265 | } | |
305 | 266 | ||
306 | 267 | ||
307 | 268 | func calcUserWeightForClaim (boostingContractAddress,heightForPeriod,period,userIndex) = { | |
308 | 269 | let kUserWeight = keyUserWeightForPeriod(period, userIndex) | |
309 | 270 | let userWeightOrUnit = getInteger(kUserWeight) | |
310 | 271 | match userWeightOrUnit { | |
311 | 272 | case _: Unit => | |
312 | 273 | 0 | |
313 | 274 | case w: Int => | |
314 | 275 | (w / SCALE) | |
315 | 276 | case _ => | |
316 | 277 | throw("Match error") | |
317 | 278 | } | |
318 | 279 | } | |
319 | 280 | ||
320 | 281 | ||
321 | 282 | func getUserIndexByAddress (boostingContractAddressStr,userAddress) = { | |
322 | 283 | let key = makeString(["%s%s%s", "mapping", "user2num", userAddress], SEP) | |
323 | 284 | parseIntValue(valueOrErrorMessage(getString(Address(fromBase58String(boostingContractAddressStr)), key), ((("User address " + userAddress) + " is not found in boosting contract data, key=") + key))) | |
324 | 285 | } | |
325 | 286 | ||
326 | 287 | ||
327 | 288 | func nextPeriod () = getNumberByKey(keyNextPeriod()) | |
328 | 289 | ||
329 | 290 | ||
330 | 291 | func commonClaimReward (userAddress) = { | |
331 | 292 | let cfgArray = readConfigArrayOrFail() | |
332 | 293 | let userIdx = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddress) | |
333 | 294 | let userUnclaimedOption = getInteger(keyUserUnclaimed(userIdx)) | |
334 | 295 | match userUnclaimedOption { | |
335 | 296 | case _: Unit => | |
336 | 297 | $Tuple2(0, nil) | |
337 | 298 | case u: Int => | |
338 | 299 | $Tuple2(u, [IntegerEntry(keyUserUnclaimed(userIdx), 0)]) | |
339 | 300 | case _ => | |
340 | 301 | throw("Match error") | |
341 | 302 | } | |
342 | 303 | } | |
343 | 304 | ||
344 | 305 | ||
345 | 306 | @Callable(i) | |
346 | - | func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = if ((currentIter == size(userAddresses))) | |
347 | - | then nil | |
348 | - | else { | |
349 | - | let checks = [if ((i.caller == this)) | |
350 | - | then true | |
351 | - | else throwErr("Permission denied"), if ((paymentAmountLeftOver >= rewards[currentIter])) | |
352 | - | then true | |
353 | - | else throwErr("insufficient payment assetId")] | |
354 | - | if ((checks == checks)) | |
355 | - | then { | |
356 | - | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [(paymentAmountLeftOver - rewards[currentIter]), userAddresses, rewards, (currentIter + 1)], nil) | |
357 | - | if ((tradeRewardInternal == tradeRewardInternal)) | |
358 | - | then { | |
359 | - | let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i) | |
360 | - | let userAddress = addressFromStringValue(userAddresses[currentIter]) | |
361 | - | $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), ScriptTransfer(userAddress, rewards[currentIter], wxAssetId)], tradeRewardInternal) | |
362 | - | } | |
363 | - | else throw("Strict value is not equal to itself.") | |
364 | - | } | |
365 | - | else throw("Strict value is not equal to itself.") | |
366 | - | } | |
367 | - | ||
368 | - | ||
369 | - | ||
370 | - | @Callable(i) | |
371 | 307 | func updateReferralActivity (userAddress,gWxAmountStart) = { | |
372 | 308 | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
373 | 309 | let activeReferralInv = if ((referrer == unit)) | |
374 | 310 | then unit | |
375 | 311 | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil) | |
376 | 312 | if ((activeReferralInv == activeReferralInv)) | |
377 | 313 | then $Tuple2(nil, unit) | |
378 | 314 | else throw("Strict value is not equal to itself.") | |
379 | 315 | } | |
380 | 316 | ||
381 | 317 | ||
382 | 318 | ||
383 | 319 | @Callable(i) | |
384 | 320 | func finalizeHelper () = { | |
385 | 321 | let processingStage = valueOrElse(getInteger(keyProcessingStage()), processingStageTotal) | |
386 | 322 | let currentPeriod = getNumberByKey(keyNextProcessedPeriod()) | |
387 | 323 | let currentUser = getNumberByKey(keyNextProcessedUser()) | |
388 | 324 | let latestPeriod = getNumberByKey(keyLatestPeriod()) | |
389 | 325 | let usersCount = valueOrElse(getInteger(boostingContractOrFail(), keyUsersCount()), 0) | |
390 | 326 | let totalWeightKey = keyTotalWeightForPeriod(currentPeriod) | |
391 | 327 | let totalWeight = getNumberByKey(keyTotalWeightForPeriod(currentPeriod)) | |
392 | 328 | let heightForPeriod = getNumberByKey(keyHeightForPeriod(currentPeriod)) | |
393 | 329 | if ((currentPeriod > latestPeriod)) | |
394 | 330 | then $Tuple2(nil, false) | |
395 | 331 | else if ((processingStage == processingStageTotal)) | |
396 | 332 | then { | |
397 | - | let $ | |
398 | - | let userWeight = $ | |
399 | - | let userActions = $ | |
333 | + | let $t01208212198 = calcUserWeight(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser) | |
334 | + | let userWeight = $t01208212198._1 | |
335 | + | let userActions = $t01208212198._2 | |
400 | 336 | let totalWeightNew = (totalWeight + userWeight) | |
401 | 337 | let processingActions = if (((usersCount - 1) > currentUser)) | |
402 | 338 | then [IntegerEntry(keyNextProcessedUser(), (currentUser + 1))] | |
403 | 339 | else [IntegerEntry(keyProcessingStage(), processingStageShares), IntegerEntry(keyNextProcessedUser(), 0)] | |
404 | 340 | $Tuple2((([IntegerEntry(totalWeightKey, totalWeightNew)] ++ processingActions) ++ userActions), true) | |
405 | 341 | } | |
406 | 342 | else if ((processingStage == processingStageShares)) | |
407 | 343 | then { | |
408 | 344 | let userWeight = calcUserWeightForClaim(boostingContractOrFail(), heightForPeriod, currentPeriod, currentUser) | |
409 | 345 | let userAmountMatcherForPeriod = fraction(getNumberByKey(keyTotalAmountForPeriod(currentPeriod)), userWeight, totalWeight) | |
410 | 346 | let userAmountEmissionForPeriod = fraction(getNumberByKey(keyAuxEmissionRewardForPeriod(currentPeriod)), userWeight, totalWeight) | |
411 | 347 | let userTotalAmount = (userAmountEmissionForPeriod + userAmountMatcherForPeriod) | |
412 | 348 | let userUnclaimedOption = getInteger(keyUserUnclaimed(currentUser)) | |
413 | 349 | let userAddress = getStringValue(boostingContractOrFail(), keyNumToUserMapping(currentUser)) | |
414 | 350 | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
415 | 351 | let activeReferralInv = if ((referrer == unit)) | |
416 | 352 | then unit | |
417 | 353 | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userWeight >= referralMinGWxAmount)], nil) | |
418 | 354 | if ((activeReferralInv == activeReferralInv)) | |
419 | 355 | then { | |
420 | 356 | let referralInv = if (if ((referrer == unit)) | |
421 | 357 | then true | |
422 | 358 | else (referralMinGWxAmount > userWeight)) | |
423 | 359 | then unit | |
424 | 360 | else { | |
425 | 361 | let referrerReward = fraction(userTotalAmount, referrerRewardPermille, SCALE) | |
426 | 362 | let referralReward = fraction(userTotalAmount, referralRewardPermille, SCALE) | |
427 | 363 | invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil) | |
428 | 364 | } | |
429 | 365 | if ((referralInv == referralInv)) | |
430 | 366 | then { | |
431 | 367 | let unclaimedActions = [IntegerEntry(keyUserUnclaimed(currentUser), (valueOrElse(userUnclaimedOption, 0) + userTotalAmount))] | |
432 | 368 | let processingActions = if (((usersCount - 1) > currentUser)) | |
433 | 369 | then [IntegerEntry(keyNextProcessedUser(), (currentUser + 1))] | |
434 | 370 | else [IntegerEntry(keyNextProcessedPeriod(), (currentPeriod + 1)), IntegerEntry(keyNextProcessedUser(), 0), DeleteEntry(keyProcessingStage())] | |
435 | 371 | $Tuple2((unclaimedActions ++ processingActions), true) | |
436 | 372 | } | |
437 | 373 | else throw("Strict value is not equal to itself.") | |
438 | 374 | } | |
439 | 375 | else throw("Strict value is not equal to itself.") | |
440 | 376 | } | |
441 | 377 | else throw("invalid processing stage") | |
442 | 378 | } | |
443 | 379 | ||
444 | 380 | ||
445 | 381 | ||
446 | 382 | @Callable(i) | |
447 | 383 | func finalizeWrapper (counter) = { | |
448 | 384 | let result = { | |
449 | 385 | let @ = invoke(this, "finalizeHelper", nil, nil) | |
450 | 386 | if ($isInstanceOf(@, "Boolean")) | |
451 | 387 | then @ | |
452 | 388 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
453 | 389 | } | |
454 | 390 | if ((result == result)) | |
455 | 391 | then if (!(result)) | |
456 | 392 | then if ((counter == maxDepth)) | |
457 | 393 | then throw("Nothing to process") | |
458 | 394 | else $Tuple2(nil, unit) | |
459 | 395 | else if ((counter > 0)) | |
460 | 396 | then $Tuple2(nil, invoke(this, "finalizeWrapper", [(counter - 1)], nil)) | |
461 | 397 | else $Tuple2(nil, unit) | |
462 | 398 | else throw("Strict value is not equal to itself.") | |
463 | 399 | } | |
464 | 400 | ||
465 | 401 | ||
466 | 402 | ||
467 | 403 | @Callable(i) | |
468 | 404 | func processPendingPeriodsAndUsers () = $Tuple2(nil, invoke(this, "finalizeWrapper", [maxDepth], nil)) | |
469 | 405 | ||
470 | 406 | ||
471 | 407 | ||
472 | 408 | @Callable(i) | |
473 | 409 | func deposit () = { | |
474 | - | let checkCaller = if ((i.caller == votingEmissionContract)) | |
475 | - | then true | |
476 | - | else mustManager(i) | |
477 | - | if ((checkCaller == checkCaller)) | |
478 | - | then { | |
479 | - | let period = nextPeriod() | |
480 | - | let deltaH = (height - getNumberOrFail(keyGwxRewardEmissionStartHeight())) | |
481 | - | let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), (("mandatory emission_contract." + keyRatePerBlockCurrent()) + " is not defined")) | |
482 | - | let gwxHoldersRewardCurrent = valueOrElse(getInteger(emissionContract, keyGwxHoldersRewardCurrent()), 0) | |
483 | - | if ((gwxHoldersRewardCurrent == gwxHoldersRewardCurrent)) | |
484 | - | then { | |
485 | - | let auxAmount = fraction((deltaH * gwxHoldersRewardCurrent), emissionRate, MULT8) | |
486 | - | let em = if ((auxAmount > 0)) | |
487 | - | then invoke(emissionContract, "emit", [auxAmount], nil) | |
488 | - | else unit | |
410 | + | let cfgArray = readConfigArrayOrFail() | |
411 | + | if ((i.caller != Address(fromBase58String(cfgArray[IdxCfgPacemakerAddress])))) | |
412 | + | then throw("Wrong caller address") | |
413 | + | else { | |
414 | + | let assetId = value(value(i.payments[0]).assetId) | |
415 | + | if ((assetId != fromBase58String(cfgArray[IdxCfgAssetId]))) | |
416 | + | then throw("Wrong payment asset") | |
417 | + | else { | |
418 | + | let period = nextPeriod() | |
419 | + | let deltaH = (height - getNumberOrFail(keyGwxRewardEmissionStartHeight())) | |
420 | + | let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), (("mandatory emission_contract." + keyRatePerBlockCurrent()) + " is not defined")) | |
421 | + | let weight = valueOrErrorMessage(getInteger(factoryContract, keyPoolWeightVirtual()), (("mandatory factory_contract." + keyPoolWeightVirtual()) + " is not defined")) | |
422 | + | let auxAmount = fraction((deltaH * weight), emissionRate, MULT8) | |
423 | + | let em = invoke(emissionContract, "emit", [auxAmount], nil) | |
489 | 424 | if ((em == em)) | |
490 | 425 | then { | |
491 | - | let matcherPart = 0 | |
426 | + | let matcherPart = value(i.payments[0]).amount | |
492 | 427 | let payoutInfo = PeriodPayoutInfo(period, matcherPart, auxAmount) | |
493 | - | let gwxHoldersRewardUpdated = { | |
494 | - | let @ = invoke(emissionContract, "gwxHoldersRewardUpdate", nil, nil) | |
495 | - | if ($isInstanceOf(@, "Boolean")) | |
496 | - | then @ | |
497 | - | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
498 | - | } | |
499 | - | if ((gwxHoldersRewardUpdated == gwxHoldersRewardUpdated)) | |
500 | - | then { | |
501 | - | let totalReward = (matcherPart + auxAmount) | |
502 | - | let actions = if (if ((totalReward == 0)) | |
503 | - | then !(gwxHoldersRewardUpdated) | |
504 | - | else false) | |
505 | - | then nil | |
506 | - | 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)] | |
507 | - | $Tuple2(actions, unit) | |
508 | - | } | |
509 | - | else throw("Strict value is not equal to itself.") | |
428 | + | [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)] | |
510 | 429 | } | |
511 | 430 | else throw("Strict value is not equal to itself.") | |
512 | 431 | } | |
513 | - | else throw("Strict value is not equal to itself.") | |
514 | 432 | } | |
515 | - | else throw("Strict value is not equal to itself.") | |
516 | 433 | } | |
517 | 434 | ||
518 | 435 | ||
519 | 436 | ||
520 | 437 | @Callable(i) | |
521 | 438 | func claimReward () = { | |
522 | 439 | let cfgArray = readConfigArrayOrFail() | |
523 | 440 | let address = toString(i.caller) | |
524 | - | let $ | |
525 | - | let amount = $ | |
526 | - | let actions = $ | |
441 | + | let $t01754017590 = commonClaimReward(address) | |
442 | + | let amount = $t01754017590._1 | |
443 | + | let actions = $t01754017590._2 | |
527 | 444 | let checkAmount = if ((amount > 0)) | |
528 | 445 | then true | |
529 | 446 | else throw("Nothing to claim") | |
530 | 447 | if ((checkAmount == checkAmount)) | |
531 | 448 | then { | |
532 | 449 | let amountFromEmission = 0 | |
533 | 450 | let claimedReferral = { | |
534 | 451 | let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil) | |
535 | 452 | if ($isInstanceOf(@, "Int")) | |
536 | 453 | then @ | |
537 | 454 | else throw(($getType(@) + " couldn't be cast to Int")) | |
538 | 455 | } | |
539 | 456 | let totalAmount = (amount + claimedReferral) | |
540 | 457 | $Tuple2(([ScriptTransfer(i.caller, totalAmount, fromBase58String(cfgArray[IdxCfgAssetId])), HistoryEntry("claim", address, amount, i)] ++ actions), [totalAmount, amountFromEmission]) | |
541 | 458 | } | |
542 | 459 | else throw("Strict value is not equal to itself.") | |
543 | 460 | } | |
544 | 461 | ||
545 | 462 | ||
546 | 463 | ||
547 | 464 | @Callable(i) | |
548 | 465 | func claimRewardREADONLY (address) = { | |
549 | - | let $ | |
550 | - | let amount = $ | |
551 | - | let actions = $ | |
466 | + | let $t01816318213 = commonClaimReward(address) | |
467 | + | let amount = $t01816318213._1 | |
468 | + | let actions = $t01816318213._2 | |
552 | 469 | let referralUnclaimed = valueOrElse(getInteger(referralsContractAddressOrFail, keyUnclaimedReferral(referralProgramName, address)), 0) | |
553 | 470 | let totalAmount = (amount + referralUnclaimed) | |
554 | 471 | $Tuple2(nil, totalAmount) | |
555 | 472 | } | |
556 | 473 | ||
557 | 474 | ||
558 | 475 | ||
559 | 476 | @Callable(i) | |
560 | 477 | func latestFinalizedPeriodREADONLY (address) = $Tuple2(nil, valueOrElse(getInteger(this, keyLatestPeriod()), -1)) | |
561 | 478 | ||
562 | 479 | ||
563 | 480 | ||
564 | 481 | @Callable(i) | |
565 | 482 | func latestFinalizedPeriodInfoREADONLY (address) = $Tuple2(nil, getStringByKey(keyLastPayoutInfo())) | |
566 | 483 | ||
567 | 484 | ||
568 | 485 | ||
569 | 486 | @Callable(i) | |
570 | 487 | func calcGwxParamsREADONLY (gwxAmountStart,lockStartHeight,lockDurationBlocks) = { | |
571 | 488 | let lockEndHeight = (lockStartHeight + lockDurationBlocks) | |
572 | 489 | let scale8ParamK = -(fraction(gwxAmountStart, SCALE, lockDurationBlocks)) | |
573 | 490 | let scale8ParamB = (fraction(gwxAmountStart, SCALE, lockDurationBlocks) * lockEndHeight) | |
574 | 491 | $Tuple2(nil, [scale8ParamK, scale8ParamB, nextPeriod()]) | |
575 | 492 | } | |
576 | 493 | ||
577 | 494 | ||
578 | 495 | ||
579 | 496 | @Callable(i) | |
580 | 497 | func calcGwxAmountStartREADONLY (wxLockAmount,lockDuration,maxLockDuration) = { | |
581 | 498 | let coeffX8 = fraction(lockDuration, MULT8, maxLockDuration) | |
582 | 499 | let gWxAmountStart = fraction(wxLockAmount, coeffX8, MULT8) | |
583 | 500 | $Tuple2(nil, [gWxAmountStart]) | |
584 | 501 | } | |
585 | 502 | ||
586 | 503 | ||
587 | 504 | ||
588 | 505 | @Callable(i) | |
589 | 506 | func onEmissionForGwxStart () = if ((i.caller != factoryContract)) | |
590 | 507 | then throw("permissions denied") | |
591 | 508 | else [IntegerEntry(keyGwxRewardEmissionStartHeight(), height)] | |
592 | 509 | ||
593 | 510 | ||
594 | 511 | ||
595 | 512 | @Callable(i) | |
596 | 513 | func latestPeriodEmissionRewardsREADONLY (address) = { | |
597 | 514 | let period = nextPeriod() | |
598 | 515 | $Tuple2(nil, [getNumberByKey(keyAuxEmissionRewardForPeriod(period))]) | |
599 | 516 | } | |
600 | 517 | ||
601 | 518 | ||
602 | 519 | ||
603 | 520 | @Callable(i) | |
604 | 521 | func calcD (x1BigIntStr,x2BigIntStr,ampBigIntStr,aPrecisionBigIntStr,targetPrecisionBigIntStr) = { | |
605 | 522 | let nCoins = toBigInt(2) | |
606 | 523 | let aPrecision = parseBigIntValue(aPrecisionBigIntStr) | |
607 | 524 | let targetPrecision = parseBigIntValue(targetPrecisionBigIntStr) | |
608 | 525 | let x1 = parseBigIntValue(x1BigIntStr) | |
609 | 526 | let x2 = parseBigIntValue(x2BigIntStr) | |
610 | 527 | let amp = (parseBigIntValue(ampBigIntStr) * aPrecision) | |
611 | 528 | let s = (x1 + x2) | |
612 | 529 | if ((s == zeroBigInt)) | |
613 | 530 | then $Tuple2(nil, toString(zeroBigInt)) | |
614 | 531 | else { | |
615 | 532 | let ann = (amp * nCoins) | |
616 | 533 | let arr = [0, 1, 2, 3, 4, 5, 6] | |
617 | 534 | func calc (acc,cur) = { | |
618 | - | let $ | |
619 | - | let d = $ | |
620 | - | let dPrev = $ | |
621 | - | let found = $ | |
535 | + | let $t02084620873 = acc | |
536 | + | let d = $t02084620873._1 | |
537 | + | let dPrev = $t02084620873._2 | |
538 | + | let found = $t02084620873._3 | |
622 | 539 | if ((found != unit)) | |
623 | 540 | then acc | |
624 | 541 | else { | |
625 | 542 | let dp = (((d * d) * d) / (((x1 * x2) * nCoins) * nCoins)) | |
626 | 543 | let dNext = (((((ann * s) / aPrecision) + (dp * nCoins)) * d) / ((((ann - aPrecision) * d) / aPrecision) + ((nCoins + toBigInt(1)) * dp))) | |
627 | 544 | let dDiff = absBigInt((dNext - value(d))) | |
628 | 545 | if ((targetPrecision >= dDiff)) | |
629 | 546 | then $Tuple3(dNext, d, cur) | |
630 | 547 | else $Tuple3(dNext, d, unit) | |
631 | 548 | } | |
632 | 549 | } | |
633 | 550 | ||
634 | - | let $ | |
551 | + | let $t02147121534 = { | |
635 | 552 | let $l = arr | |
636 | 553 | let $s = size($l) | |
637 | 554 | let $acc0 = $Tuple3(s, unit, unit) | |
638 | 555 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
639 | 556 | then $a | |
640 | 557 | else calc($a, $l[$i]) | |
641 | 558 | ||
642 | 559 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
643 | 560 | then $a | |
644 | 561 | else throw("List size exceeds 7") | |
645 | 562 | ||
646 | 563 | $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) | |
647 | 564 | } | |
648 | - | let dNext = $ | |
649 | - | let dPrev = $ | |
650 | - | let found = $ | |
565 | + | let dNext = $t02147121534._1 | |
566 | + | let dPrev = $t02147121534._2 | |
567 | + | let found = $t02147121534._3 | |
651 | 568 | if ((found != unit)) | |
652 | 569 | then $Tuple2(nil, toString(dNext)) | |
653 | 570 | else { | |
654 | 571 | let dDiff = absBigInt((dNext - value(dPrev))) | |
655 | 572 | throw(("D calculation error, dDiff = " + toString(dDiff))) | |
656 | 573 | } | |
657 | 574 | } | |
658 | - | } | |
659 | - | ||
660 | - | ||
661 | - | ||
662 | - | @Callable(i) | |
663 | - | func tradeReward (userAddresses,rewards) = { | |
664 | - | let argsComparison = (size(userAddresses) == size(rewards)) | |
665 | - | let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0) | |
666 | - | let payment = i.payments[0] | |
667 | - | let paymentAssetId = payment.assetId | |
668 | - | let paymentAmount = payment.amount | |
669 | - | let checks = [if ((maxRecipients >= size(userAddresses))) | |
670 | - | then true | |
671 | - | else throwErr("Too many recipients"), if (argsComparison) | |
672 | - | then true | |
673 | - | else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId)) | |
674 | - | then true | |
675 | - | else throwErr("Wrong asset payment")] | |
676 | - | if ((checks == checks)) | |
677 | - | then { | |
678 | - | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil) | |
679 | - | if ((tradeRewardInternal == tradeRewardInternal)) | |
680 | - | then $Tuple2(nil, tradeRewardInternal) | |
681 | - | else throw("Strict value is not equal to itself.") | |
682 | - | } | |
683 | - | else throw("Strict value is not equal to itself.") | |
684 | 575 | } | |
685 | 576 | ||
686 | 577 | ||
687 | 578 | ||
688 | 579 | @Callable(i) | |
689 | 580 | func setManager (pendingManagerPublicKey) = { | |
690 | 581 | let checkCaller = mustManager(i) | |
691 | 582 | if ((checkCaller == checkCaller)) | |
692 | 583 | then { | |
693 | 584 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
694 | 585 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
695 | 586 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
696 | 587 | else throw("Strict value is not equal to itself.") | |
697 | 588 | } | |
698 | 589 | else throw("Strict value is not equal to itself.") | |
699 | 590 | } | |
700 | 591 | ||
701 | 592 | ||
702 | 593 | ||
703 | 594 | @Callable(i) | |
704 | 595 | func confirmManager () = { | |
705 | 596 | let pm = pendingManagerPublicKeyOrUnit() | |
706 | 597 | let hasPM = if (isDefined(pm)) | |
707 | 598 | then true | |
708 | 599 | else throw("No pending manager") | |
709 | 600 | if ((hasPM == hasPM)) | |
710 | 601 | then { | |
711 | 602 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
712 | 603 | then true | |
713 | 604 | else throw("You are not pending manager") | |
714 | 605 | if ((checkPM == checkPM)) | |
715 | 606 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
716 | 607 | else throw("Strict value is not equal to itself.") | |
717 | 608 | } | |
718 | 609 | else throw("Strict value is not equal to itself.") | |
719 | 610 | } | |
720 | 611 | ||
721 | 612 | ||
722 | 613 | @Verifier(tx) | |
723 | 614 | func verify () = { | |
724 | 615 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
725 | 616 | case pk: ByteVector => | |
726 | 617 | pk | |
727 | 618 | case _: Unit => | |
728 | 619 | tx.senderPublicKey | |
729 | 620 | case _ => | |
730 | 621 | throw("Match error") | |
731 | 622 | } | |
732 | 623 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
733 | 624 | } | |
734 | 625 |
github/deemru/w8io/026f985 89.57 ms ◑