tx · J4yBN261bq3dkFdNev3X6agcLXU6hredbUo21P4Q1UL1 3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy: -0.02600000 Waves 2023.08.11 18:05 [2706081] smart account 3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy > SELF 0.00000000 Waves
{ "type": 13, "id": "J4yBN261bq3dkFdNev3X6agcLXU6hredbUo21P4Q1UL1", "fee": 2600000, "feeAssetId": null, "timestamp": 1691766319364, "version": 2, "chainId": 84, "sender": "3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy", "senderPublicKey": "9W33iCCNfmFxUbiC6XZcH5x7f6xfwC7Jb3BoExT5q2PV", "proofs": [ "4YxyoBSM6fnZtqt8Atxp1FRfPKZqH5FexfPG6zvP9Ug5d95yvUYhKUwvysTa1iNdCzdcSZV4a4nFRzDP73Lyqp1C" ], "script": "base64:BgKKLggCEggKBggIAQEBCBIFCgMBCAISAwoBARIECgIICBIECgIICBIDCgEIEgMKAQgSAwoBCBIECgIIARIDCgEIEgASABIFCgMICAQSAwoBCBIDCgEIEgQKAggIEgQKAggIIgNTRVAiBlNDQUxFOCIFTVVMVDgiDlBPT0xXRUlHSFRNVUxUIhBjb250cmFjdEZpbGVuYW1lIgdTQ0FMRTE4IgZNVUxUMTgiCE1VTFQxOEJJIhVkdXJhdGlvbk1vbnRoc0FsbG93ZWQiC2Jsb2Nrc0luRGF5Ig1ibG9ja3NJbk1vbnRoIgd3cmFwRXJyIgNtc2ciCHRocm93RXJyIg9nZXRTdHJpbmdPckZhaWwiB2FkZHJlc3MiA2tleSIMZ2V0SW50T3JaZXJvIg9nZXRJbnRPckRlZmF1bHQiCmRlZmF1bHRWYWwiDGdldEludE9yRmFpbCIDYWJzIgN2YWwiDmVuc3VyZVBvc2l0aXZlIgF2IgFtIhtrZXlSZWZlcnJhbHNDb250cmFjdEFkZHJlc3MiHnJlZmVycmFsc0NvbnRyYWN0QWRkcmVzc09yRmFpbCIWa2V5UmVmZXJyYWx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ZGRyZXNzBAJiaQkBAmNGAQUCYVoJAJQKAgUDbmlsBQJiaQJhUAETZ2V0R3d4VG90YWxSRUFET05MWQAJAJQKAgUDbmlsCQECY2IAAmFQARVvbkJvb3N0RW1pc3Npb25VcGRhdGUABAJlSAMJAAACCAUCYVAGY2FsbGVyBQJiUgYJAQJhTwEFAmFQAwkAAAIFAmVIBQJlSAkBAmRHAAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgJhUAESb25TdGFrZWRWb3RlVXBkYXRlAwJiSAJiUAJkcwQCZUgDCQAAAggFAmFQBmNhbGxlcgUCYlMGCQECYU8BBQJhUAMJAAACBQJlSAUCZUgEAmR2CQECZHIDBQJiSAUCYlAFAmRzCQCUCgIFAmR2BQR1bml0CQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAmFQAR1nZXRWb3RpbmdSZXN1bHRTdGFrZWRSRUFET05MWQECYkgJAJQKAgUDbmlsCQECY1cBBQJiSAJhUAElZ2V0Vm90aW5nUmVzdWx0U3Rha2VkSW50ZWdyYWxSRUFET05MWQECYkgJAJQKAgUDbmlsCQECZGEBBQJiSAJhUAEcZ2V0VXNlclZvdGVGaW5hbGl6ZWRSRUFET05MWQICYkgCYlAJAJQKAgUDbmlsCQECY1ACBQJiSAUCYlACYVABIWdldFVzZXJWb3RlU3Rha2VkSW50ZWdyYWxSRUFET05MWQICYkgCYlAJAJQKAgUDbmlsCQECZGsCBQJiSAUCYlABAmVaAQJmYQAEAmZiBAJhSwkBAmFNAAMJAAECBQJhSwIKQnl0ZVZlY3RvcgQCYVIFAmFLBQJhUgMJAAECBQJhSwIEVW5pdAgFAmVaD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJlWglib2R5Qnl0ZXMJAJEDAggFAmVaBnByb29mcwAABQJmYvMpV50=", "height": 2706081, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5mLpGSjrJ9FY9CnVPpc53f3Rku6vtNeMtpswhY5LcNi6 Next: HNuyo542xzNyJZ8fWbNgw4Y9zsDqt61JkAmxSk7M3QJc Diff:
Old | New | Differences | |
---|---|---|---|
16 | 16 | let MULT18 = 1000000000000000000 | |
17 | 17 | ||
18 | 18 | let MULT18BI = toBigInt(MULT18) | |
19 | + | ||
20 | + | let durationMonthsAllowed = [1, 3, 6, 12, 24, 48] | |
19 | 21 | ||
20 | 22 | let blocksInDay = 1440 | |
21 | 23 | ||
434 | 436 | ||
435 | 437 | ||
436 | 438 | func getVotingEmissionEpochInfo () = { | |
437 | - | let $ | |
439 | + | let $t01521415504 = { | |
438 | 440 | let currentEpochUi = value(getInteger(votingEmissionContract, keyCurrentEpochUi())) | |
439 | 441 | let lastFinalizedEpoch = (currentEpochUi - 1) | |
440 | 442 | if ((0 > lastFinalizedEpoch)) | |
441 | 443 | then throwErr("invalid epoch") | |
442 | 444 | else $Tuple2(currentEpochUi, lastFinalizedEpoch) | |
443 | 445 | } | |
444 | - | let currentEpochUi = $ | |
445 | - | let lastFinalizedEpoch = $ | |
446 | + | let currentEpochUi = $t01521415504._1 | |
447 | + | let lastFinalizedEpoch = $t01521415504._2 | |
446 | 448 | let currentEpochStartHeight = value(getInteger(votingEmissionContract, keyStartHeightByEpoch(currentEpochUi))) | |
447 | 449 | $Tuple2(lastFinalizedEpoch, currentEpochStartHeight) | |
448 | 450 | } | |
475 | 477 | ||
476 | 478 | func getUserVoteFinalized (lpAssetIdStr,userAddressStr) = { | |
477 | 479 | let userAddress = addressFromStringValue(userAddressStr) | |
478 | - | let $ | |
479 | - | let lastFinalizedEpoch = $ | |
480 | - | let currentEpochStartHeight = $ | |
481 | - | let $ | |
482 | - | let amountAssetId = $ | |
483 | - | let priceAssetId = $ | |
480 | + | let $t01619516275 = getVotingEmissionEpochInfo() | |
481 | + | let lastFinalizedEpoch = $t01619516275._1 | |
482 | + | let currentEpochStartHeight = $t01619516275._2 | |
483 | + | let $t01627816353 = getPoolAssetsByLpAssetId(lpAssetIdStr) | |
484 | + | let amountAssetId = $t01627816353._1 | |
485 | + | let priceAssetId = $t01627816353._2 | |
484 | 486 | let userVoteKey = keyVote(amountAssetId, priceAssetId, userAddress, lastFinalizedEpoch) | |
485 | 487 | let userVote = valueOrElse(getInteger(votingEmissionContract, userVoteKey), 0) | |
486 | 488 | userVote | |
497 | 499 | ||
498 | 500 | ||
499 | 501 | func getVotingResultStaked (lpAssetIdStr) = { | |
500 | - | let $ | |
501 | - | let lastFinalizedEpoch = $ | |
502 | - | let currentEpochStartHeight = $ | |
502 | + | let $t01689716977 = getVotingEmissionEpochInfo() | |
503 | + | let lastFinalizedEpoch = $t01689716977._1 | |
504 | + | let currentEpochStartHeight = $t01689716977._2 | |
503 | 505 | let votingResultStakedStart = valueOrElse(getInteger(votingEmissionContract, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), 0) | |
504 | 506 | let votingResultStaked = valueOrElse(getInteger(this, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), votingResultStakedStart) | |
505 | 507 | votingResultStaked | |
507 | 509 | ||
508 | 510 | ||
509 | 511 | func getVotingResultStakedIntegral (lpAssetIdStr) = { | |
510 | - | let $ | |
511 | - | let lastFinalizedEpoch = $ | |
512 | - | let currentEpochStartHeight = $ | |
512 | + | let $t01733917419 = getVotingEmissionEpochInfo() | |
513 | + | let lastFinalizedEpoch = $t01733917419._1 | |
514 | + | let currentEpochStartHeight = $t01733917419._2 | |
513 | 515 | let votingResultStaked = getVotingResultStaked(lpAssetIdStr) | |
514 | 516 | let votingResultStakedIntegralPrev = valueOrElse(getInteger(this, keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch)), 0) | |
515 | 517 | let votingResultStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch)), currentEpochStartHeight) | |
520 | 522 | ||
521 | 523 | ||
522 | 524 | func refreshVotingResultStakedIntegral (lpAssetIdStr,stakedVoteDelta) = { | |
523 | - | let $ | |
524 | - | let lastFinalizedEpoch = $ | |
525 | - | let currentEpochStartHeight = $ | |
525 | + | let $t01825618336 = getVotingEmissionEpochInfo() | |
526 | + | let lastFinalizedEpoch = $t01825618336._1 | |
527 | + | let currentEpochStartHeight = $t01825618336._2 | |
526 | 528 | let votingResultStaked = getVotingResultStaked(lpAssetIdStr) | |
527 | 529 | let votingResultStakedNew = (votingResultStaked + stakedVoteDelta) | |
528 | 530 | let votingResultStakedIntegral = getVotingResultStakedIntegral(lpAssetIdStr) | |
531 | 533 | ||
532 | 534 | ||
533 | 535 | func getUserVoteStakedIntegral (lpAssetIdStr,userAddressStr) = { | |
534 | - | let $ | |
535 | - | let lastFinalizedEpoch = $ | |
536 | - | let currentEpochStartHeight = $ | |
536 | + | let $t01894719027 = getVotingEmissionEpochInfo() | |
537 | + | let lastFinalizedEpoch = $t01894719027._1 | |
538 | + | let currentEpochStartHeight = $t01894719027._2 | |
537 | 539 | let userAddress = addressFromStringValue(userAddressStr) | |
538 | 540 | let userVoteStaked = getUserVoteStaked(lpAssetIdStr, userAddressStr) | |
539 | 541 | let userVoteStakedIntegralPrev = valueOrElse(getInteger(this, keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch)), 0) | |
545 | 547 | ||
546 | 548 | ||
547 | 549 | func refreshVoteStakedIntegral (lpAssetIdStr,userAddressStr,edge) = { | |
548 | - | let $ | |
549 | - | let lastFinalizedEpoch = $ | |
550 | - | let currentEpochStartHeight = $ | |
550 | + | let $t01981519895 = getVotingEmissionEpochInfo() | |
551 | + | let lastFinalizedEpoch = $t01981519895._1 | |
552 | + | let currentEpochStartHeight = $t01981519895._2 | |
551 | 553 | let userAddress = addressFromStringValue(userAddressStr) | |
552 | 554 | let userVoteFinalized = getUserVoteFinalized(lpAssetIdStr, userAddressStr) | |
553 | 555 | let actions = if ((userVoteFinalized == 0)) | |
566 | 568 | ||
567 | 569 | ||
568 | 570 | func getStakedVotesIntegralsDiff (lpAssetIdStr,userAddressStr) = { | |
569 | - | let $ | |
570 | - | let lastFinalizedEpoch = $ | |
571 | - | let currentEpochStartHeight = $ | |
571 | + | let $t02074920829 = getVotingEmissionEpochInfo() | |
572 | + | let lastFinalizedEpoch = $t02074920829._1 | |
573 | + | let currentEpochStartHeight = $t02074920829._2 | |
572 | 574 | let userAddress = addressFromStringValue(userAddressStr) | |
573 | 575 | let userVoteStakedIntegralLastKey = keyVoteStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
574 | 576 | let userVoteStakedIntegralLast = valueOrElse(getInteger(this, userVoteStakedIntegralLastKey), 0) | |
627 | 629 | if ((0 > userBoostEmissionIntegral)) | |
628 | 630 | then throwErr("wrong calculations") | |
629 | 631 | else { | |
630 | - | let $ | |
631 | - | let stakedVotesIntegralsActions = $ | |
632 | - | let userVoteIntegralDiff = $ | |
633 | - | let totalVotesIntegralDiff = $ | |
632 | + | let $t02437124510 = getStakedVotesIntegralsDiff(lpAssetIdStr, userAddressStr) | |
633 | + | let stakedVotesIntegralsActions = $t02437124510._1 | |
634 | + | let userVoteIntegralDiff = $t02437124510._2 | |
635 | + | let totalVotesIntegralDiff = $t02437124510._3 | |
634 | 636 | let poolUserBoostEmissionIntegral = fraction(userBoostEmissionIntegral, poolWeight, POOLWEIGHTMULT) | |
635 | 637 | let userBoostAvaliableToClaimTotalNew = if ((totalVotesIntegralDiff == 0)) | |
636 | 638 | then 0 | |
644 | 646 | } | |
645 | 647 | ||
646 | 648 | ||
647 | - | func lockActions (i,durationMonths) = { | |
648 | - | let durationMonthsAllowed = [1, 3, 6, 12, 24, 48] | |
649 | - | if (!(containsElement(durationMonthsAllowed, durationMonths))) | |
650 | - | then throwErr("invalid duration") | |
651 | - | else { | |
652 | - | let duration = (durationMonths * blocksInMonth) | |
653 | - | let assetIdStr = toBase58String(assetId) | |
654 | - | if ((size(i.payments) != 1)) | |
655 | - | then throwErr("invalid payment - exact one payment must be attached") | |
656 | - | else { | |
657 | - | let pmt = i.payments[0] | |
658 | - | let pmtAmount = pmt.amount | |
659 | - | if ((assetId != value(pmt.assetId))) | |
660 | - | then throwErr((("invalid asset is in payment - " + assetIdStr) + " is expected")) | |
661 | - | else { | |
662 | - | let nextUserNumKEY = keyNextUserNum() | |
663 | - | let userAddress = i.caller | |
664 | - | let userAddressStr = toString(userAddress) | |
665 | - | let userIsExisting = isDefined(getString(keyUser2NumMapping(userAddressStr))) | |
666 | - | let userNumStr = if (userIsExisting) | |
667 | - | then value(getString(keyUser2NumMapping(userAddressStr))) | |
668 | - | else toString(getIntOrFail(this, nextUserNumKEY)) | |
669 | - | let userNum = parseIntValue(userNumStr) | |
670 | - | let lockStart = height | |
671 | - | if (if ((minLockAmount > pmtAmount)) | |
672 | - | then (userAddress != lpStakingPoolsContract) | |
673 | - | else false) | |
674 | - | then throwErr(("amount is less then minLockAmount=" + toString(minLockAmount))) | |
675 | - | else if ((minLockDuration > duration)) | |
676 | - | then throwErr(("passed duration is less then minLockDuration=" + toString(minLockDuration))) | |
677 | - | else if ((duration > maxLockDuration)) | |
678 | - | then throwErr(("passed duration is greater then maxLockDuration=" + toString(maxLockDuration))) | |
679 | - | else { | |
680 | - | let coeffX8 = fraction(duration, MULT8, maxLockDuration) | |
681 | - | let gWxAmountStart = fraction(pmtAmount, coeffX8, MULT8) | |
682 | - | let gwxAmountTotal = getGwxAmountTotal() | |
683 | - | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum) | |
684 | - | let boostEmissionIntegral = refreshBoostEmissionIntegral()._2 | |
685 | - | let userGwxAmountTotal = getUserGwxAmountTotal(userAddress) | |
686 | - | let gwxRewardInv = reentrantInvoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes], nil) | |
687 | - | if ((gwxRewardInv == gwxRewardInv)) | |
688 | - | then { | |
689 | - | let arr = if (userIsExisting) | |
690 | - | then nil | |
691 | - | else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)] | |
692 | - | $Tuple2(((((arr ++ LockParamsEntry(userAddress, i.transactionId, pmtAmount, lockStart, duration, gWxAmountStart, 0)) ++ StatsEntry(pmtAmount, duration, 1, if (userIsExisting) | |
693 | - | then 0 | |
694 | - | else 1)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, duration, gWxAmountStart, i)) ++ [IntegerEntry(userBoostEmissionLastIntegralKEY, boostEmissionIntegral), IntegerEntry(keyGwxTotal(), (gwxAmountTotal + gWxAmountStart)), IntegerEntry(keyUserGwxAmountTotal(userAddress), (userGwxAmountTotal + gWxAmountStart))]), gWxAmountStart) | |
695 | - | } | |
696 | - | else throw("Strict value is not equal to itself.") | |
697 | - | } | |
698 | - | } | |
699 | - | } | |
700 | - | } | |
701 | - | } | |
649 | + | func lockActions (i,durationMonths) = if (!(containsElement(durationMonthsAllowed, durationMonths))) | |
650 | + | then throwErr("invalid duration") | |
651 | + | else { | |
652 | + | let duration = (durationMonths * blocksInMonth) | |
653 | + | let assetIdStr = toBase58String(assetId) | |
654 | + | if ((size(i.payments) != 1)) | |
655 | + | then throwErr("invalid payment - exact one payment must be attached") | |
656 | + | else { | |
657 | + | let pmt = i.payments[0] | |
658 | + | let pmtAmount = pmt.amount | |
659 | + | if ((assetId != value(pmt.assetId))) | |
660 | + | then throwErr((("invalid asset is in payment - " + assetIdStr) + " is expected")) | |
661 | + | else { | |
662 | + | let nextUserNumKEY = keyNextUserNum() | |
663 | + | let userAddress = i.caller | |
664 | + | let userAddressStr = toString(userAddress) | |
665 | + | let userIsExisting = isDefined(getString(keyUser2NumMapping(userAddressStr))) | |
666 | + | let userNumStr = if (userIsExisting) | |
667 | + | then value(getString(keyUser2NumMapping(userAddressStr))) | |
668 | + | else toString(getIntOrFail(this, nextUserNumKEY)) | |
669 | + | let userNum = parseIntValue(userNumStr) | |
670 | + | let lockStart = height | |
671 | + | if (if ((minLockAmount > pmtAmount)) | |
672 | + | then (userAddress != lpStakingPoolsContract) | |
673 | + | else false) | |
674 | + | then throwErr(("amount is less then minLockAmount=" + toString(minLockAmount))) | |
675 | + | else if ((minLockDuration > duration)) | |
676 | + | then throwErr(("passed duration is less then minLockDuration=" + toString(minLockDuration))) | |
677 | + | else if ((duration > maxLockDuration)) | |
678 | + | then throwErr(("passed duration is greater then maxLockDuration=" + toString(maxLockDuration))) | |
679 | + | else { | |
680 | + | let gWxAmountStart = fraction(pmtAmount, duration, maxLockDuration) | |
681 | + | let gwxAmountTotal = getGwxAmountTotal() | |
682 | + | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum) | |
683 | + | let boostEmissionIntegral = refreshBoostEmissionIntegral()._2 | |
684 | + | let userGwxAmountTotal = getUserGwxAmountTotal(userAddress) | |
685 | + | let gwxRewardInv = reentrantInvoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes], nil) | |
686 | + | if ((gwxRewardInv == gwxRewardInv)) | |
687 | + | then { | |
688 | + | let arr = if (userIsExisting) | |
689 | + | then nil | |
690 | + | else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)] | |
691 | + | $Tuple2(((((arr ++ LockParamsEntry(userAddress, i.transactionId, pmtAmount, lockStart, duration, gWxAmountStart, 0)) ++ StatsEntry(pmtAmount, duration, 1, if (userIsExisting) | |
692 | + | then 0 | |
693 | + | else 1)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, duration, gWxAmountStart, i)) ++ [IntegerEntry(userBoostEmissionLastIntegralKEY, boostEmissionIntegral), IntegerEntry(keyGwxTotal(), (gwxAmountTotal + gWxAmountStart)), IntegerEntry(keyUserGwxAmountTotal(userAddress), (userGwxAmountTotal + gWxAmountStart))]), gWxAmountStart) | |
694 | + | } | |
695 | + | else throw("Strict value is not equal to itself.") | |
696 | + | } | |
697 | + | } | |
698 | + | } | |
699 | + | } | |
702 | 700 | ||
703 | 701 | ||
704 | 702 | func getWxWithdrawable (userAddress,txIdOption) = { | |
708 | 706 | let lockDuration = parseIntValue(userRecordArray[IdxLockDuration]) | |
709 | 707 | let lockEnd = (lockStart + lockDuration) | |
710 | 708 | let wxClaimed = parseIntValue(userRecordArray[IdxLockWxClaimed]) | |
711 | - | let gwxAmount = parseIntValue(userRecordArray[IdxLockGwxAmount]) | |
712 | 709 | let t = ((height - lockStart) / blocksInPeriod) | |
713 | 710 | let exponent = fraction(toBigInt(t), (toBigInt((8 * blocksInPeriod)) * MULT18BI), toBigInt(lockDuration)) | |
714 | 711 | let wxWithdrawable = if ((height > lockEnd)) | |
730 | 727 | ||
731 | 728 | @Callable(i) | |
732 | 729 | func lockRef (duration,referrerAddress,signature) = { | |
733 | - | let $ | |
734 | - | let lockActionsResult = $ | |
735 | - | let gWxAmountStart = $ | |
730 | + | let $t02930929374 = lockActions(i, duration) | |
731 | + | let lockActionsResult = $t02930929374._1 | |
732 | + | let gWxAmountStart = $t02930929374._2 | |
736 | 733 | let referralAddress = toString(i.caller) | |
737 | 734 | let refInv = if (if ((referrerAddress == "")) | |
738 | 735 | then true | |
753 | 750 | ||
754 | 751 | @Callable(i) | |
755 | 752 | func lock (duration) = { | |
756 | - | let $ | |
757 | - | let lockActionsResult = $ | |
758 | - | let gWxAmountStart = $ | |
753 | + | let $t02983229897 = lockActions(i, duration) | |
754 | + | let lockActionsResult = $t02983229897._1 | |
755 | + | let gWxAmountStart = $t02983229897._2 | |
759 | 756 | let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil) | |
760 | 757 | if ((updateRefActivity == updateRefActivity)) | |
761 | 758 | then $Tuple2(lockActionsResult, unit) | |
768 | 765 | func claimWxBoost (lpAssetIdStr,userAddressStr) = if ((stakingContract != i.caller)) | |
769 | 766 | then throwErr("permissions denied") | |
770 | 767 | else { | |
771 | - | let $ | |
772 | - | let userBoostAvailable = $ | |
773 | - | let dataState = $ | |
774 | - | let debug = $ | |
768 | + | let $t03020730309 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, false) | |
769 | + | let userBoostAvailable = $t03020730309._1 | |
770 | + | let dataState = $t03020730309._2 | |
771 | + | let debug = $t03020730309._3 | |
775 | 772 | $Tuple2(dataState, [userBoostAvailable]) | |
776 | 773 | } | |
777 | 774 | ||
779 | 776 | ||
780 | 777 | @Callable(i) | |
781 | 778 | func claimWxBoostREADONLY (lpAssetIdStr,userAddressStr) = { | |
782 | - | let $ | |
783 | - | let userBoostAvailable = $ | |
784 | - | let dataState = $ | |
785 | - | let debug = $ | |
779 | + | let $t03044130542 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, true) | |
780 | + | let userBoostAvailable = $t03044130542._1 | |
781 | + | let dataState = $t03044130542._2 | |
782 | + | let debug = $t03044130542._3 | |
786 | 783 | $Tuple2(nil, [userBoostAvailable, debug]) | |
787 | 784 | } | |
788 | 785 | ||
799 | 796 | let userAmount = parseIntValue(userRecordArray[IdxLockAmount]) | |
800 | 797 | let lockStart = parseIntValue(userRecordArray[IdxLockStart]) | |
801 | 798 | let lockDuration = parseIntValue(userRecordArray[IdxLockDuration]) | |
802 | - | let lockEnd = (lockStart + lockDuration) | |
803 | 799 | let wxClaimed = parseIntValue(userRecordArray[IdxLockWxClaimed]) | |
804 | 800 | let gwxAmount = parseIntValue(userRecordArray[IdxLockGwxAmount]) | |
805 | 801 | let t = ((height - lockStart) / blocksInPeriod) | |
806 | 802 | let wxWithdrawable = getWxWithdrawable(userAddress, if ((txIdStr == "")) | |
807 | 803 | then unit | |
808 | 804 | else txId) | |
809 | - | let coeffX8 = fraction(lockDuration, MULT8, maxLockDuration) | |
810 | - | let gWxAmountStart = fraction(userAmount, coeffX8, MULT8) | |
805 | + | let gWxAmountStart = fraction(userAmount, lockDuration, maxLockDuration) | |
811 | 806 | let gwxBurned = min([fraction((t * blocksInPeriod), gWxAmountStart, maxLockDuration), gwxAmount]) | |
812 | 807 | let gwxRemaining = ensurePositive((gwxAmount - gwxBurned), "gwxRemaining") | |
813 | 808 | let lockedGwxAmount = getLockedGwxAmount(userAddress) |
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 SCALE8 = 8 | |
7 | 7 | ||
8 | 8 | let MULT8 = 100000000 | |
9 | 9 | ||
10 | 10 | let POOLWEIGHTMULT = MULT8 | |
11 | 11 | ||
12 | 12 | let contractFilename = "boosting.ride" | |
13 | 13 | ||
14 | 14 | let SCALE18 = 18 | |
15 | 15 | ||
16 | 16 | let MULT18 = 1000000000000000000 | |
17 | 17 | ||
18 | 18 | let MULT18BI = toBigInt(MULT18) | |
19 | + | ||
20 | + | let durationMonthsAllowed = [1, 3, 6, 12, 24, 48] | |
19 | 21 | ||
20 | 22 | let blocksInDay = 1440 | |
21 | 23 | ||
22 | 24 | let blocksInMonth = 43800 | |
23 | 25 | ||
24 | 26 | func wrapErr (msg) = makeString([contractFilename, ": ", msg], "") | |
25 | 27 | ||
26 | 28 | ||
27 | 29 | func throwErr (msg) = throw(wrapErr(msg)) | |
28 | 30 | ||
29 | 31 | ||
30 | 32 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
31 | 33 | ||
32 | 34 | ||
33 | 35 | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
34 | 36 | ||
35 | 37 | ||
36 | 38 | func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal) | |
37 | 39 | ||
38 | 40 | ||
39 | 41 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
40 | 42 | ||
41 | 43 | ||
42 | 44 | func abs (val) = if ((0 > val)) | |
43 | 45 | then -(val) | |
44 | 46 | else val | |
45 | 47 | ||
46 | 48 | ||
47 | 49 | func ensurePositive (v,m) = if ((v >= 0)) | |
48 | 50 | then v | |
49 | 51 | else throwErr((valueOrElse(m, "value") + " should be positive")) | |
50 | 52 | ||
51 | 53 | ||
52 | 54 | func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP) | |
53 | 55 | ||
54 | 56 | ||
55 | 57 | let referralsContractAddressOrFail = addressFromStringValue(getStringOrFail(this, keyReferralsContractAddress())) | |
56 | 58 | ||
57 | 59 | let keyReferralProgramName = makeString(["%s%s", "referral", "programName"], SEP) | |
58 | 60 | ||
59 | 61 | let referralProgramNameDefault = "wxlock" | |
60 | 62 | ||
61 | 63 | let referralProgramName = valueOrElse(getString(this, keyReferralProgramName), referralProgramNameDefault) | |
62 | 64 | ||
63 | 65 | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
64 | 66 | ||
65 | 67 | ||
66 | 68 | let IdxFactoryCfgStakingDapp = 1 | |
67 | 69 | ||
68 | 70 | let IdxFactoryCfgBoostingDapp = 2 | |
69 | 71 | ||
70 | 72 | let IdxFactoryCfgIdoDapp = 3 | |
71 | 73 | ||
72 | 74 | let IdxFactoryCfgTeamDapp = 4 | |
73 | 75 | ||
74 | 76 | let IdxFactoryCfgEmissionDapp = 5 | |
75 | 77 | ||
76 | 78 | let IdxFactoryCfgRestDapp = 6 | |
77 | 79 | ||
78 | 80 | let IdxFactoryCfgSlippageDapp = 7 | |
79 | 81 | ||
80 | 82 | let IdxFactoryCfgDaoDapp = 8 | |
81 | 83 | ||
82 | 84 | let IdxFactoryCfgMarketingDapp = 9 | |
83 | 85 | ||
84 | 86 | let IdxFactoryCfgGwxRewardDapp = 10 | |
85 | 87 | ||
86 | 88 | let IdxFactoryCfgBirdsDapp = 11 | |
87 | 89 | ||
88 | 90 | func keyFactoryCfg () = "%s__factoryConfig" | |
89 | 91 | ||
90 | 92 | ||
91 | 93 | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
92 | 94 | ||
93 | 95 | ||
94 | 96 | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
95 | 97 | ||
96 | 98 | ||
97 | 99 | func keyFactoryPoolWeightHistory (poolAddress,num) = ((("%s%s__poolWeight__" + poolAddress) + "__") + toString(num)) | |
98 | 100 | ||
99 | 101 | ||
100 | 102 | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(this, keyFactoryAddress())) | |
101 | 103 | ||
102 | 104 | ||
103 | 105 | func readFactoryCfgOrFail (factory) = split(getStringOrFail(factory, keyFactoryCfg()), SEP) | |
104 | 106 | ||
105 | 107 | ||
106 | 108 | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
107 | 109 | ||
108 | 110 | ||
109 | 111 | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
110 | 112 | ||
111 | 113 | ||
112 | 114 | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
113 | 115 | ||
114 | 116 | ||
115 | 117 | func getGwxRewardAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgGwxRewardDapp]) | |
116 | 118 | ||
117 | 119 | ||
118 | 120 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
119 | 121 | ||
120 | 122 | ||
121 | 123 | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
122 | 124 | ||
123 | 125 | ||
124 | 126 | func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
125 | 127 | ||
126 | 128 | ||
127 | 129 | func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
128 | 130 | ||
129 | 131 | ||
130 | 132 | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
131 | 133 | ||
132 | 134 | ||
133 | 135 | func keyBoostingV2LastUpdateHeight () = "%s%s__boostingV2__startBlock" | |
134 | 136 | ||
135 | 137 | ||
136 | 138 | func keyBoostingV2Integral () = "%s%s__boostingV2__integral" | |
137 | 139 | ||
138 | 140 | ||
139 | 141 | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
140 | 142 | ||
141 | 143 | ||
142 | 144 | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
143 | 145 | ||
144 | 146 | ||
145 | 147 | func keyNextPergetIntOrDefault () = "%s__nextPeriod" | |
146 | 148 | ||
147 | 149 | ||
148 | 150 | func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight" | |
149 | 151 | ||
150 | 152 | ||
151 | 153 | let IdxCfgAssetId = 1 | |
152 | 154 | ||
153 | 155 | let IdxCfgMinLockAmount = 2 | |
154 | 156 | ||
155 | 157 | let IdxCfgMinLockDuration = 3 | |
156 | 158 | ||
157 | 159 | let IdxCfgMaxLockDuration = 4 | |
158 | 160 | ||
159 | 161 | let IdxCfgMathContract = 5 | |
160 | 162 | ||
161 | 163 | let IdxCfgBlocksInPeriod = 6 | |
162 | 164 | ||
163 | 165 | func keyConfig () = "%s__config" | |
164 | 166 | ||
165 | 167 | ||
166 | 168 | func readConfigArrayOrFail () = split(getStringOrFail(this, keyConfig()), SEP) | |
167 | 169 | ||
168 | 170 | ||
169 | 171 | let cfgArray = readConfigArrayOrFail() | |
170 | 172 | ||
171 | 173 | let assetId = fromBase58String(cfgArray[IdxCfgAssetId]) | |
172 | 174 | ||
173 | 175 | let minLockAmount = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMinLockAmount]), wrapErr("invalid min lock amount")) | |
174 | 176 | ||
175 | 177 | let minLockDuration = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMinLockDuration]), wrapErr("invalid min lock duration")) | |
176 | 178 | ||
177 | 179 | let maxLockDuration = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMaxLockDuration]), wrapErr("invalid max lock duration")) | |
178 | 180 | ||
179 | 181 | let mathContract = valueOrErrorMessage(addressFromString(cfgArray[IdxCfgMathContract]), wrapErr("invalid math contract address")) | |
180 | 182 | ||
181 | 183 | let blocksInPeriod = valueOrErrorMessage(parseInt(cfgArray[IdxCfgBlocksInPeriod]), wrapErr("invalid blocks in period")) | |
182 | 184 | ||
183 | 185 | func formatConfigS (assetId,minLockAmount,minLockDuration,maxLockDuration,mathContract) = makeString(["%s%d%d%d%s", assetId, minLockAmount, minLockDuration, maxLockDuration, mathContract], SEP) | |
184 | 186 | ||
185 | 187 | ||
186 | 188 | func formatConfig (assetId,minLockAmount,minLockDuration,maxLockDuration,mathContract) = formatConfigS(assetId, toString(minLockAmount), toString(minLockDuration), toString(maxLockDuration), mathContract) | |
187 | 189 | ||
188 | 190 | ||
189 | 191 | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
190 | 192 | case s: String => | |
191 | 193 | addressFromStringValue(s) | |
192 | 194 | case _ => | |
193 | 195 | this | |
194 | 196 | } | |
195 | 197 | ||
196 | 198 | ||
197 | 199 | func managerPublicKeyOrUnit () = { | |
198 | 200 | let managerVaultAddress = getManagerVaultAddressOrThis() | |
199 | 201 | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
200 | 202 | case s: String => | |
201 | 203 | fromBase58String(s) | |
202 | 204 | case _: Unit => | |
203 | 205 | unit | |
204 | 206 | case _ => | |
205 | 207 | throw("Match error") | |
206 | 208 | } | |
207 | 209 | } | |
208 | 210 | ||
209 | 211 | ||
210 | 212 | func mustManager (i) = { | |
211 | 213 | let pd = throwErr("Permission denied") | |
212 | 214 | match managerPublicKeyOrUnit() { | |
213 | 215 | case pk: ByteVector => | |
214 | 216 | if ((i.callerPublicKey == pk)) | |
215 | 217 | then true | |
216 | 218 | else pd | |
217 | 219 | case _: Unit => | |
218 | 220 | if ((i.caller == this)) | |
219 | 221 | then true | |
220 | 222 | else pd | |
221 | 223 | case _ => | |
222 | 224 | throw("Match error") | |
223 | 225 | } | |
224 | 226 | } | |
225 | 227 | ||
226 | 228 | ||
227 | 229 | let IdxLockAmount = 1 | |
228 | 230 | ||
229 | 231 | let IdxLockStart = 2 | |
230 | 232 | ||
231 | 233 | let IdxLockDuration = 3 | |
232 | 234 | ||
233 | 235 | let IdxLockLastUpdateTimestamp = 4 | |
234 | 236 | ||
235 | 237 | let IdxLockGwxAmount = 5 | |
236 | 238 | ||
237 | 239 | let IdxLockWxClaimed = 6 | |
238 | 240 | ||
239 | 241 | func keyLockParamsRecord (userAddress,txId) = makeString(["%s%s%s__lock", toString(userAddress), match txId { | |
240 | 242 | case b: ByteVector => | |
241 | 243 | toBase58String(b) | |
242 | 244 | case _: Unit => | |
243 | 245 | "legacy" | |
244 | 246 | case _ => | |
245 | 247 | throw("Match error") | |
246 | 248 | }], SEP) | |
247 | 249 | ||
248 | 250 | ||
249 | 251 | func readLockParamsRecordOrFail (userAddress,txId) = split(getStringOrFail(this, keyLockParamsRecord(userAddress, txId)), SEP) | |
250 | 252 | ||
251 | 253 | ||
252 | 254 | func keyUserGwxAmountTotal (userAddress) = makeString(["%s%s__gwxAmountTotal", toString(userAddress)], SEP) | |
253 | 255 | ||
254 | 256 | ||
255 | 257 | func formatLockParamsRecord (amount,start,duration,gwxAmount,wxClaimed) = makeString(["%d%d%d%d%d%d%d", toString(amount), toString(start), toString(duration), toString(lastBlock.timestamp), toString(gwxAmount), toString(wxClaimed)], SEP) | |
256 | 258 | ||
257 | 259 | ||
258 | 260 | func keyNextUserNum () = "%s__nextUserNum" | |
259 | 261 | ||
260 | 262 | ||
261 | 263 | func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", userAddress], SEP) | |
262 | 264 | ||
263 | 265 | ||
264 | 266 | func keyNum2UserMapping (num) = makeString(["%s%s%s__mapping__num2user", num], SEP) | |
265 | 267 | ||
266 | 268 | ||
267 | 269 | func keyLockParamTotalAmount () = "%s%s__stats__activeTotalLocked" | |
268 | 270 | ||
269 | 271 | ||
270 | 272 | func keyStatsLocksDurationSumInBlocks () = "%s%s__stats__locksDurationSumInBlocks" | |
271 | 273 | ||
272 | 274 | ||
273 | 275 | func keyStatsLocksCount () = "%s%s__stats__locksCount" | |
274 | 276 | ||
275 | 277 | ||
276 | 278 | func keyStatsUsersCount () = "%s%s__stats__activeUsersCount" | |
277 | 279 | ||
278 | 280 | ||
279 | 281 | func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastIntV2", toString(userNum)], SEP) | |
280 | 282 | ||
281 | 283 | ||
282 | 284 | func keyUserLpBoostEmissionLastINTEGRAL (userNum,lpAssetId) = makeString(["%s%d__userBoostEmissionLastIntV2", toString(userNum), lpAssetId], SEP) | |
283 | 285 | ||
284 | 286 | ||
285 | 287 | func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", toString(userNum)], SEP) | |
286 | 288 | ||
287 | 289 | ||
288 | 290 | func keyTotalMaxBoostINTEGRAL () = "%s%s__maxBoostInt__total" | |
289 | 291 | ||
290 | 292 | ||
291 | 293 | func keyUserBoostAvalaibleToClaimTotal (userNum) = makeString(["%s%d__userBoostAvaliableToClaimTotal", toString(userNum)], SEP) | |
292 | 294 | ||
293 | 295 | ||
294 | 296 | func keyUserBoostClaimed (userNum) = makeString(["%s%d__userBoostClaimed", toString(userNum)], SEP) | |
295 | 297 | ||
296 | 298 | ||
297 | 299 | func keyGwxTotal () = "%s%s__gwx__total" | |
298 | 300 | ||
299 | 301 | ||
300 | 302 | func keyVote (amountAssetId,priceAssetId,address,epoch) = makeString(["%s%s%s%s%d", "vote", amountAssetId, priceAssetId, toString(address), toString(epoch)], SEP) | |
301 | 303 | ||
302 | 304 | ||
303 | 305 | func keyStartHeightByEpoch (epoch) = makeString(["%s%d", "startHeight", toString(epoch)], SEP) | |
304 | 306 | ||
305 | 307 | ||
306 | 308 | func keyCurrentEpochUi () = makeString(["%s", "currentEpochUi"], SEP) | |
307 | 309 | ||
308 | 310 | ||
309 | 311 | func keyVotingResultStaked (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStaked", lpAssetIdStr, toString(epoch)], SEP) | |
310 | 312 | ||
311 | 313 | ||
312 | 314 | func keyVotingResultStakedIntegral (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStakedIntegral", lpAssetIdStr, toString(epoch)], SEP) | |
313 | 315 | ||
314 | 316 | ||
315 | 317 | func keyVotingResultStakedLastUpdateHeight (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStakedIntegralLastUpdateHeight", lpAssetIdStr, toString(epoch)], SEP) | |
316 | 318 | ||
317 | 319 | ||
318 | 320 | func keyVotingResultStakedIntegralLast (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "votingResultStakedIntegralLast", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
319 | 321 | ||
320 | 322 | ||
321 | 323 | func keyVoteStakedIntegral (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegral", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
322 | 324 | ||
323 | 325 | ||
324 | 326 | func keyVoteStakedLastUpdateHeight (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegralLastUpdateHeight", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
325 | 327 | ||
326 | 328 | ||
327 | 329 | func keyVoteStakedIntegralLast (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegralLast", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
328 | 330 | ||
329 | 331 | ||
330 | 332 | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s", "staked", userAddressStr, lpAssetIdStr], SEP) | |
331 | 333 | ||
332 | 334 | ||
333 | 335 | let factoryContract = readFactoryAddressOrFail() | |
334 | 336 | ||
335 | 337 | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
336 | 338 | ||
337 | 339 | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
338 | 340 | ||
339 | 341 | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
340 | 342 | ||
341 | 343 | let gwxRewardContract = getGwxRewardAddressOrFail(factoryCfg) | |
342 | 344 | ||
343 | 345 | let lpStakingPoolsContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(makeString(["%s", "lpStakingPoolsContract"], SEP)), wrapErr("lp_staking_pools contract address is undefined"))), wrapErr("invalid lp_staking_pools contract address")) | |
344 | 346 | ||
345 | 347 | let keyVotingEmissionContract = makeString(["%s", "votingEmissionContract"], SEP) | |
346 | 348 | ||
347 | 349 | let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract)) | |
348 | 350 | ||
349 | 351 | let keyVotingEmissionRateContract = makeString(["%s", "votingEmissionRateContract"], SEP) | |
350 | 352 | ||
351 | 353 | let boostCoeff = { | |
352 | 354 | let @ = invoke(emissionContract, "getBoostCoeffREADONLY", nil, nil) | |
353 | 355 | if ($isInstanceOf(@, "Int")) | |
354 | 356 | then @ | |
355 | 357 | else throw(($getType(@) + " couldn't be cast to Int")) | |
356 | 358 | } | |
357 | 359 | ||
358 | 360 | func userNumberByAddressOrFail (userAddress) = match getString(this, keyUser2NumMapping(toString(userAddress))) { | |
359 | 361 | case s: String => | |
360 | 362 | valueOrErrorMessage(parseInt(s), wrapErr("invalid user number")) | |
361 | 363 | case _: Unit => | |
362 | 364 | throwErr("invalid user") | |
363 | 365 | case _ => | |
364 | 366 | throw("Match error") | |
365 | 367 | } | |
366 | 368 | ||
367 | 369 | ||
368 | 370 | func getGwxAmountTotal () = valueOrElse(getInteger(this, keyGwxTotal()), 0) | |
369 | 371 | ||
370 | 372 | ||
371 | 373 | func getLockedGwxAmount (userAddress) = { | |
372 | 374 | let functionName = "getLockedGwxAmount" | |
373 | 375 | let votingEmissionRateContract = valueOrErrorMessage( match getString(votingEmissionContract, keyVotingEmissionRateContract) { | |
374 | 376 | case _: Unit => | |
375 | 377 | unit | |
376 | 378 | case s: String => | |
377 | 379 | addressFromString(s) | |
378 | 380 | case _ => | |
379 | 381 | throw("Match error") | |
380 | 382 | }, wrapErr("invalid voting emission rate address")) | |
381 | 383 | let lockedVotingEmissionRate = { | |
382 | 384 | let @ = invoke(votingEmissionContract, functionName, [toString(userAddress)], nil) | |
383 | 385 | if ($isInstanceOf(@, "Int")) | |
384 | 386 | then @ | |
385 | 387 | else throw(($getType(@) + " couldn't be cast to Int")) | |
386 | 388 | } | |
387 | 389 | let lockedVotingEmission = { | |
388 | 390 | let @ = invoke(votingEmissionRateContract, functionName, [toString(userAddress)], nil) | |
389 | 391 | if ($isInstanceOf(@, "Int")) | |
390 | 392 | then @ | |
391 | 393 | else throw(($getType(@) + " couldn't be cast to Int")) | |
392 | 394 | } | |
393 | 395 | let locked = max([lockedVotingEmissionRate, lockedVotingEmission]) | |
394 | 396 | locked | |
395 | 397 | } | |
396 | 398 | ||
397 | 399 | ||
398 | 400 | func HistoryEntry (type,user,amount,lockStart,duration,gwxAmount,i) = { | |
399 | 401 | let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP) | |
400 | 402 | let historyDATA = makeString(["%d%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount), toString(lockStart), toString(duration), toString(gwxAmount)], SEP) | |
401 | 403 | StringEntry(historyKEY, historyDATA) | |
402 | 404 | } | |
403 | 405 | ||
404 | 406 | ||
405 | 407 | func StatsEntry (totalLockedInc,durationInc,lockCountInc,usersCountInc) = { | |
406 | 408 | let locksDurationSumInBlocksKEY = keyStatsLocksDurationSumInBlocks() | |
407 | 409 | let locksCountKEY = keyStatsLocksCount() | |
408 | 410 | let usersCountKEY = keyStatsUsersCount() | |
409 | 411 | let totalAmountKEY = keyLockParamTotalAmount() | |
410 | 412 | let locksDurationSumInBlocks = getIntOrZero(this, locksDurationSumInBlocksKEY) | |
411 | 413 | let locksCount = getIntOrZero(this, locksCountKEY) | |
412 | 414 | let usersCount = getIntOrZero(this, usersCountKEY) | |
413 | 415 | let totalAmount = getIntOrZero(this, totalAmountKEY) | |
414 | 416 | [IntegerEntry(locksDurationSumInBlocksKEY, (locksDurationSumInBlocks + durationInc)), IntegerEntry(locksCountKEY, (locksCount + lockCountInc)), IntegerEntry(usersCountKEY, (usersCount + usersCountInc)), IntegerEntry(totalAmountKEY, (totalAmount + totalLockedInc))] | |
415 | 417 | } | |
416 | 418 | ||
417 | 419 | ||
418 | 420 | func LockParamsEntry (userAddress,txId,amount,start,duration,gwxAmount,wxClaimed) = [StringEntry(keyLockParamsRecord(userAddress, txId), formatLockParamsRecord(amount, start, duration, gwxAmount, wxClaimed))] | |
419 | 421 | ||
420 | 422 | ||
421 | 423 | func extractOptionalPaymentAmountOrFail (i,expectedAssetId) = if ((size(i.payments) > 1)) | |
422 | 424 | then throwErr("only one payment is allowed") | |
423 | 425 | else if ((size(i.payments) == 0)) | |
424 | 426 | then 0 | |
425 | 427 | else { | |
426 | 428 | let pmt = i.payments[0] | |
427 | 429 | if ((value(pmt.assetId) != expectedAssetId)) | |
428 | 430 | then throwErr("invalid asset id in payment") | |
429 | 431 | else pmt.amount | |
430 | 432 | } | |
431 | 433 | ||
432 | 434 | ||
433 | 435 | func getUserGwxAmountTotal (userAddress) = valueOrElse(getInteger(this, keyUserGwxAmountTotal(userAddress)), 0) | |
434 | 436 | ||
435 | 437 | ||
436 | 438 | func getVotingEmissionEpochInfo () = { | |
437 | - | let $ | |
439 | + | let $t01521415504 = { | |
438 | 440 | let currentEpochUi = value(getInteger(votingEmissionContract, keyCurrentEpochUi())) | |
439 | 441 | let lastFinalizedEpoch = (currentEpochUi - 1) | |
440 | 442 | if ((0 > lastFinalizedEpoch)) | |
441 | 443 | then throwErr("invalid epoch") | |
442 | 444 | else $Tuple2(currentEpochUi, lastFinalizedEpoch) | |
443 | 445 | } | |
444 | - | let currentEpochUi = $ | |
445 | - | let lastFinalizedEpoch = $ | |
446 | + | let currentEpochUi = $t01521415504._1 | |
447 | + | let lastFinalizedEpoch = $t01521415504._2 | |
446 | 448 | let currentEpochStartHeight = value(getInteger(votingEmissionContract, keyStartHeightByEpoch(currentEpochUi))) | |
447 | 449 | $Tuple2(lastFinalizedEpoch, currentEpochStartHeight) | |
448 | 450 | } | |
449 | 451 | ||
450 | 452 | ||
451 | 453 | func getPoolAssetsByLpAssetId (lpAssetIdStr) = { | |
452 | 454 | let idxAmountAssetId = 4 | |
453 | 455 | let idxPriceAssetId = 5 | |
454 | 456 | let poolCfg = { | |
455 | 457 | let @ = invoke(factoryContract, "getPoolConfigByLpAssetIdREADONLY", [lpAssetIdStr], nil) | |
456 | 458 | if ($isInstanceOf(@, "List[Any]")) | |
457 | 459 | then @ | |
458 | 460 | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
459 | 461 | } | |
460 | 462 | let amountAssetId = { | |
461 | 463 | let @ = poolCfg[idxAmountAssetId] | |
462 | 464 | if ($isInstanceOf(@, "String")) | |
463 | 465 | then @ | |
464 | 466 | else throw(($getType(@) + " couldn't be cast to String")) | |
465 | 467 | } | |
466 | 468 | let priceAssetId = { | |
467 | 469 | let @ = poolCfg[idxPriceAssetId] | |
468 | 470 | if ($isInstanceOf(@, "String")) | |
469 | 471 | then @ | |
470 | 472 | else throw(($getType(@) + " couldn't be cast to String")) | |
471 | 473 | } | |
472 | 474 | $Tuple2(amountAssetId, priceAssetId) | |
473 | 475 | } | |
474 | 476 | ||
475 | 477 | ||
476 | 478 | func getUserVoteFinalized (lpAssetIdStr,userAddressStr) = { | |
477 | 479 | let userAddress = addressFromStringValue(userAddressStr) | |
478 | - | let $ | |
479 | - | let lastFinalizedEpoch = $ | |
480 | - | let currentEpochStartHeight = $ | |
481 | - | let $ | |
482 | - | let amountAssetId = $ | |
483 | - | let priceAssetId = $ | |
480 | + | let $t01619516275 = getVotingEmissionEpochInfo() | |
481 | + | let lastFinalizedEpoch = $t01619516275._1 | |
482 | + | let currentEpochStartHeight = $t01619516275._2 | |
483 | + | let $t01627816353 = getPoolAssetsByLpAssetId(lpAssetIdStr) | |
484 | + | let amountAssetId = $t01627816353._1 | |
485 | + | let priceAssetId = $t01627816353._2 | |
484 | 486 | let userVoteKey = keyVote(amountAssetId, priceAssetId, userAddress, lastFinalizedEpoch) | |
485 | 487 | let userVote = valueOrElse(getInteger(votingEmissionContract, userVoteKey), 0) | |
486 | 488 | userVote | |
487 | 489 | } | |
488 | 490 | ||
489 | 491 | ||
490 | 492 | func getUserVoteStaked (lpAssetIdStr,userAddressStr) = { | |
491 | 493 | let stakedByUser = valueOrElse(getInteger(stakingContract, keyStakedByUser(userAddressStr, lpAssetIdStr)), 0) | |
492 | 494 | let userVote = getUserVoteFinalized(lpAssetIdStr, userAddressStr) | |
493 | 495 | if ((stakedByUser == 0)) | |
494 | 496 | then 0 | |
495 | 497 | else userVote | |
496 | 498 | } | |
497 | 499 | ||
498 | 500 | ||
499 | 501 | func getVotingResultStaked (lpAssetIdStr) = { | |
500 | - | let $ | |
501 | - | let lastFinalizedEpoch = $ | |
502 | - | let currentEpochStartHeight = $ | |
502 | + | let $t01689716977 = getVotingEmissionEpochInfo() | |
503 | + | let lastFinalizedEpoch = $t01689716977._1 | |
504 | + | let currentEpochStartHeight = $t01689716977._2 | |
503 | 505 | let votingResultStakedStart = valueOrElse(getInteger(votingEmissionContract, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), 0) | |
504 | 506 | let votingResultStaked = valueOrElse(getInteger(this, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), votingResultStakedStart) | |
505 | 507 | votingResultStaked | |
506 | 508 | } | |
507 | 509 | ||
508 | 510 | ||
509 | 511 | func getVotingResultStakedIntegral (lpAssetIdStr) = { | |
510 | - | let $ | |
511 | - | let lastFinalizedEpoch = $ | |
512 | - | let currentEpochStartHeight = $ | |
512 | + | let $t01733917419 = getVotingEmissionEpochInfo() | |
513 | + | let lastFinalizedEpoch = $t01733917419._1 | |
514 | + | let currentEpochStartHeight = $t01733917419._2 | |
513 | 515 | let votingResultStaked = getVotingResultStaked(lpAssetIdStr) | |
514 | 516 | let votingResultStakedIntegralPrev = valueOrElse(getInteger(this, keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch)), 0) | |
515 | 517 | let votingResultStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch)), currentEpochStartHeight) | |
516 | 518 | let votingResultStakedIntegralDh = (height - votingResultStakedLastUpdateHeight) | |
517 | 519 | let votingResultStakedIntegral = ((votingResultStakedIntegralDh * votingResultStaked) + votingResultStakedIntegralPrev) | |
518 | 520 | votingResultStakedIntegral | |
519 | 521 | } | |
520 | 522 | ||
521 | 523 | ||
522 | 524 | func refreshVotingResultStakedIntegral (lpAssetIdStr,stakedVoteDelta) = { | |
523 | - | let $ | |
524 | - | let lastFinalizedEpoch = $ | |
525 | - | let currentEpochStartHeight = $ | |
525 | + | let $t01825618336 = getVotingEmissionEpochInfo() | |
526 | + | let lastFinalizedEpoch = $t01825618336._1 | |
527 | + | let currentEpochStartHeight = $t01825618336._2 | |
526 | 528 | let votingResultStaked = getVotingResultStaked(lpAssetIdStr) | |
527 | 529 | let votingResultStakedNew = (votingResultStaked + stakedVoteDelta) | |
528 | 530 | let votingResultStakedIntegral = getVotingResultStakedIntegral(lpAssetIdStr) | |
529 | 531 | [IntegerEntry(keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch), votingResultStakedNew), IntegerEntry(keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch), height), IntegerEntry(keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch), votingResultStakedIntegral)] | |
530 | 532 | } | |
531 | 533 | ||
532 | 534 | ||
533 | 535 | func getUserVoteStakedIntegral (lpAssetIdStr,userAddressStr) = { | |
534 | - | let $ | |
535 | - | let lastFinalizedEpoch = $ | |
536 | - | let currentEpochStartHeight = $ | |
536 | + | let $t01894719027 = getVotingEmissionEpochInfo() | |
537 | + | let lastFinalizedEpoch = $t01894719027._1 | |
538 | + | let currentEpochStartHeight = $t01894719027._2 | |
537 | 539 | let userAddress = addressFromStringValue(userAddressStr) | |
538 | 540 | let userVoteStaked = getUserVoteStaked(lpAssetIdStr, userAddressStr) | |
539 | 541 | let userVoteStakedIntegralPrev = valueOrElse(getInteger(this, keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch)), 0) | |
540 | 542 | let userVoteStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVoteStakedLastUpdateHeight(lpAssetIdStr, userAddress, lastFinalizedEpoch)), currentEpochStartHeight) | |
541 | 543 | let userVoteStakedIntegralDh = (height - userVoteStakedLastUpdateHeight) | |
542 | 544 | let userVoteStakedIntegral = ((userVoteStakedIntegralDh * userVoteStaked) + userVoteStakedIntegralPrev) | |
543 | 545 | userVoteStakedIntegral | |
544 | 546 | } | |
545 | 547 | ||
546 | 548 | ||
547 | 549 | func refreshVoteStakedIntegral (lpAssetIdStr,userAddressStr,edge) = { | |
548 | - | let $ | |
549 | - | let lastFinalizedEpoch = $ | |
550 | - | let currentEpochStartHeight = $ | |
550 | + | let $t01981519895 = getVotingEmissionEpochInfo() | |
551 | + | let lastFinalizedEpoch = $t01981519895._1 | |
552 | + | let currentEpochStartHeight = $t01981519895._2 | |
551 | 553 | let userAddress = addressFromStringValue(userAddressStr) | |
552 | 554 | let userVoteFinalized = getUserVoteFinalized(lpAssetIdStr, userAddressStr) | |
553 | 555 | let actions = if ((userVoteFinalized == 0)) | |
554 | 556 | then nil | |
555 | 557 | else { | |
556 | 558 | let stakedVoteDelta = if (edge) | |
557 | 559 | then userVoteFinalized | |
558 | 560 | else -(userVoteFinalized) | |
559 | 561 | let votingResultActions = refreshVotingResultStakedIntegral(lpAssetIdStr, stakedVoteDelta) | |
560 | 562 | let userVoteStakedIntegral = getUserVoteStakedIntegral(lpAssetIdStr, userAddressStr) | |
561 | 563 | let voteActions = [IntegerEntry(keyVoteStakedLastUpdateHeight(lpAssetIdStr, userAddress, lastFinalizedEpoch), height), IntegerEntry(keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch), userVoteStakedIntegral)] | |
562 | 564 | (votingResultActions ++ voteActions) | |
563 | 565 | } | |
564 | 566 | actions | |
565 | 567 | } | |
566 | 568 | ||
567 | 569 | ||
568 | 570 | func getStakedVotesIntegralsDiff (lpAssetIdStr,userAddressStr) = { | |
569 | - | let $ | |
570 | - | let lastFinalizedEpoch = $ | |
571 | - | let currentEpochStartHeight = $ | |
571 | + | let $t02074920829 = getVotingEmissionEpochInfo() | |
572 | + | let lastFinalizedEpoch = $t02074920829._1 | |
573 | + | let currentEpochStartHeight = $t02074920829._2 | |
572 | 574 | let userAddress = addressFromStringValue(userAddressStr) | |
573 | 575 | let userVoteStakedIntegralLastKey = keyVoteStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
574 | 576 | let userVoteStakedIntegralLast = valueOrElse(getInteger(this, userVoteStakedIntegralLastKey), 0) | |
575 | 577 | let votingResultStakedIntegralLastKey = keyVotingResultStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
576 | 578 | let votingResultStakedIntegralLast = valueOrElse(getInteger(this, votingResultStakedIntegralLastKey), 0) | |
577 | 579 | let userVoteStakedIntegral = getUserVoteStakedIntegral(lpAssetIdStr, userAddressStr) | |
578 | 580 | let votingResultStakedIntegral = getVotingResultStakedIntegral(lpAssetIdStr) | |
579 | 581 | let userVoteStakedIntegralDiff = (userVoteStakedIntegral - userVoteStakedIntegralLast) | |
580 | 582 | let votingResultStakedIntegralDiff = (votingResultStakedIntegral - votingResultStakedIntegralLast) | |
581 | 583 | $Tuple3([IntegerEntry(userVoteStakedIntegralLastKey, userVoteStakedIntegral), IntegerEntry(votingResultStakedIntegralLastKey, votingResultStakedIntegral)], userVoteStakedIntegralDiff, votingResultStakedIntegralDiff) | |
582 | 584 | } | |
583 | 585 | ||
584 | 586 | ||
585 | 587 | func refreshBoostEmissionIntegral () = { | |
586 | 588 | let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) | |
587 | 589 | let boostingV2LastUpdateHeightOption = getInteger(this, keyBoostingV2LastUpdateHeight()) | |
588 | 590 | let boostingV2IngergalOption = getInteger(this, keyBoostingV2Integral()) | |
589 | 591 | let emissionEnd = getIntOrFail(emissionContract, keyEmissionEndBlock()) | |
590 | 592 | let h = if ((height > emissionEnd)) | |
591 | 593 | then emissionEnd | |
592 | 594 | else height | |
593 | 595 | let dh = match boostingV2LastUpdateHeightOption { | |
594 | 596 | case lastUpdateHeight: Int => | |
595 | 597 | max([(h - lastUpdateHeight), 0]) | |
596 | 598 | case _: Unit => | |
597 | 599 | 0 | |
598 | 600 | case _ => | |
599 | 601 | throw("Match error") | |
600 | 602 | } | |
601 | 603 | let boostEmissionPerBlock = ((wxEmissionPerBlock * (boostCoeff - 1)) / boostCoeff) | |
602 | 604 | let boostEmissionIntegralPrev = valueOrElse(boostingV2IngergalOption, 0) | |
603 | 605 | let boostEmissionIntegral = ((boostEmissionPerBlock * dh) + boostEmissionIntegralPrev) | |
604 | 606 | $Tuple2([IntegerEntry(keyBoostingV2Integral(), boostEmissionIntegral), IntegerEntry(keyBoostingV2LastUpdateHeight(), height)], boostEmissionIntegral) | |
605 | 607 | } | |
606 | 608 | ||
607 | 609 | ||
608 | 610 | func internalClaimWxBoost (lpAssetIdStr,userAddressStr,readOnly) = { | |
609 | 611 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
610 | 612 | let userNum = userNumberByAddressOrFail(userAddress) | |
611 | 613 | if ((userNum == userNum)) | |
612 | 614 | then { | |
613 | 615 | let EMPTYSTR = "empty" | |
614 | 616 | let poolWeight = if ((lpAssetIdStr != EMPTYSTR)) | |
615 | 617 | then { | |
616 | 618 | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)), wrapErr(("unsupported lp asset " + lpAssetIdStr))) | |
617 | 619 | getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
618 | 620 | } | |
619 | 621 | else if (readOnly) | |
620 | 622 | then 0 | |
621 | 623 | else throwErr(("not readonly mode: unsupported lp asset " + lpAssetIdStr)) | |
622 | 624 | let userLpBoostEmissionLastIntegralKEY = keyUserLpBoostEmissionLastINTEGRAL(userNum, lpAssetIdStr) | |
623 | 625 | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum) | |
624 | 626 | let userBoostEmissionLastIntegral = valueOrElse(getInteger(this, userLpBoostEmissionLastIntegralKEY), getIntOrZero(this, userBoostEmissionLastIntegralKEY)) | |
625 | 627 | let boostEmissionIntegral = refreshBoostEmissionIntegral()._2 | |
626 | 628 | let userBoostEmissionIntegral = (boostEmissionIntegral - userBoostEmissionLastIntegral) | |
627 | 629 | if ((0 > userBoostEmissionIntegral)) | |
628 | 630 | then throwErr("wrong calculations") | |
629 | 631 | else { | |
630 | - | let $ | |
631 | - | let stakedVotesIntegralsActions = $ | |
632 | - | let userVoteIntegralDiff = $ | |
633 | - | let totalVotesIntegralDiff = $ | |
632 | + | let $t02437124510 = getStakedVotesIntegralsDiff(lpAssetIdStr, userAddressStr) | |
633 | + | let stakedVotesIntegralsActions = $t02437124510._1 | |
634 | + | let userVoteIntegralDiff = $t02437124510._2 | |
635 | + | let totalVotesIntegralDiff = $t02437124510._3 | |
634 | 636 | let poolUserBoostEmissionIntegral = fraction(userBoostEmissionIntegral, poolWeight, POOLWEIGHTMULT) | |
635 | 637 | let userBoostAvaliableToClaimTotalNew = if ((totalVotesIntegralDiff == 0)) | |
636 | 638 | then 0 | |
637 | 639 | else fraction(poolUserBoostEmissionIntegral, userVoteIntegralDiff, totalVotesIntegralDiff) | |
638 | 640 | let dataState = ([IntegerEntry(userLpBoostEmissionLastIntegralKEY, boostEmissionIntegral)] ++ stakedVotesIntegralsActions) | |
639 | 641 | let debug = makeString([toString(userBoostEmissionLastIntegral), toString(userBoostEmissionIntegral), toString(poolWeight), toString(userVoteIntegralDiff), toString(totalVotesIntegralDiff)], ":") | |
640 | 642 | $Tuple3(userBoostAvaliableToClaimTotalNew, dataState, debug) | |
641 | 643 | } | |
642 | 644 | } | |
643 | 645 | else throw("Strict value is not equal to itself.") | |
644 | 646 | } | |
645 | 647 | ||
646 | 648 | ||
647 | - | func lockActions (i,durationMonths) = { | |
648 | - | let durationMonthsAllowed = [1, 3, 6, 12, 24, 48] | |
649 | - | if (!(containsElement(durationMonthsAllowed, durationMonths))) | |
650 | - | then throwErr("invalid duration") | |
651 | - | else { | |
652 | - | let duration = (durationMonths * blocksInMonth) | |
653 | - | let assetIdStr = toBase58String(assetId) | |
654 | - | if ((size(i.payments) != 1)) | |
655 | - | then throwErr("invalid payment - exact one payment must be attached") | |
656 | - | else { | |
657 | - | let pmt = i.payments[0] | |
658 | - | let pmtAmount = pmt.amount | |
659 | - | if ((assetId != value(pmt.assetId))) | |
660 | - | then throwErr((("invalid asset is in payment - " + assetIdStr) + " is expected")) | |
661 | - | else { | |
662 | - | let nextUserNumKEY = keyNextUserNum() | |
663 | - | let userAddress = i.caller | |
664 | - | let userAddressStr = toString(userAddress) | |
665 | - | let userIsExisting = isDefined(getString(keyUser2NumMapping(userAddressStr))) | |
666 | - | let userNumStr = if (userIsExisting) | |
667 | - | then value(getString(keyUser2NumMapping(userAddressStr))) | |
668 | - | else toString(getIntOrFail(this, nextUserNumKEY)) | |
669 | - | let userNum = parseIntValue(userNumStr) | |
670 | - | let lockStart = height | |
671 | - | if (if ((minLockAmount > pmtAmount)) | |
672 | - | then (userAddress != lpStakingPoolsContract) | |
673 | - | else false) | |
674 | - | then throwErr(("amount is less then minLockAmount=" + toString(minLockAmount))) | |
675 | - | else if ((minLockDuration > duration)) | |
676 | - | then throwErr(("passed duration is less then minLockDuration=" + toString(minLockDuration))) | |
677 | - | else if ((duration > maxLockDuration)) | |
678 | - | then throwErr(("passed duration is greater then maxLockDuration=" + toString(maxLockDuration))) | |
679 | - | else { | |
680 | - | let coeffX8 = fraction(duration, MULT8, maxLockDuration) | |
681 | - | let gWxAmountStart = fraction(pmtAmount, coeffX8, MULT8) | |
682 | - | let gwxAmountTotal = getGwxAmountTotal() | |
683 | - | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum) | |
684 | - | let boostEmissionIntegral = refreshBoostEmissionIntegral()._2 | |
685 | - | let userGwxAmountTotal = getUserGwxAmountTotal(userAddress) | |
686 | - | let gwxRewardInv = reentrantInvoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes], nil) | |
687 | - | if ((gwxRewardInv == gwxRewardInv)) | |
688 | - | then { | |
689 | - | let arr = if (userIsExisting) | |
690 | - | then nil | |
691 | - | else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)] | |
692 | - | $Tuple2(((((arr ++ LockParamsEntry(userAddress, i.transactionId, pmtAmount, lockStart, duration, gWxAmountStart, 0)) ++ StatsEntry(pmtAmount, duration, 1, if (userIsExisting) | |
693 | - | then 0 | |
694 | - | else 1)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, duration, gWxAmountStart, i)) ++ [IntegerEntry(userBoostEmissionLastIntegralKEY, boostEmissionIntegral), IntegerEntry(keyGwxTotal(), (gwxAmountTotal + gWxAmountStart)), IntegerEntry(keyUserGwxAmountTotal(userAddress), (userGwxAmountTotal + gWxAmountStart))]), gWxAmountStart) | |
695 | - | } | |
696 | - | else throw("Strict value is not equal to itself.") | |
697 | - | } | |
698 | - | } | |
699 | - | } | |
700 | - | } | |
701 | - | } | |
649 | + | func lockActions (i,durationMonths) = if (!(containsElement(durationMonthsAllowed, durationMonths))) | |
650 | + | then throwErr("invalid duration") | |
651 | + | else { | |
652 | + | let duration = (durationMonths * blocksInMonth) | |
653 | + | let assetIdStr = toBase58String(assetId) | |
654 | + | if ((size(i.payments) != 1)) | |
655 | + | then throwErr("invalid payment - exact one payment must be attached") | |
656 | + | else { | |
657 | + | let pmt = i.payments[0] | |
658 | + | let pmtAmount = pmt.amount | |
659 | + | if ((assetId != value(pmt.assetId))) | |
660 | + | then throwErr((("invalid asset is in payment - " + assetIdStr) + " is expected")) | |
661 | + | else { | |
662 | + | let nextUserNumKEY = keyNextUserNum() | |
663 | + | let userAddress = i.caller | |
664 | + | let userAddressStr = toString(userAddress) | |
665 | + | let userIsExisting = isDefined(getString(keyUser2NumMapping(userAddressStr))) | |
666 | + | let userNumStr = if (userIsExisting) | |
667 | + | then value(getString(keyUser2NumMapping(userAddressStr))) | |
668 | + | else toString(getIntOrFail(this, nextUserNumKEY)) | |
669 | + | let userNum = parseIntValue(userNumStr) | |
670 | + | let lockStart = height | |
671 | + | if (if ((minLockAmount > pmtAmount)) | |
672 | + | then (userAddress != lpStakingPoolsContract) | |
673 | + | else false) | |
674 | + | then throwErr(("amount is less then minLockAmount=" + toString(minLockAmount))) | |
675 | + | else if ((minLockDuration > duration)) | |
676 | + | then throwErr(("passed duration is less then minLockDuration=" + toString(minLockDuration))) | |
677 | + | else if ((duration > maxLockDuration)) | |
678 | + | then throwErr(("passed duration is greater then maxLockDuration=" + toString(maxLockDuration))) | |
679 | + | else { | |
680 | + | let gWxAmountStart = fraction(pmtAmount, duration, maxLockDuration) | |
681 | + | let gwxAmountTotal = getGwxAmountTotal() | |
682 | + | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum) | |
683 | + | let boostEmissionIntegral = refreshBoostEmissionIntegral()._2 | |
684 | + | let userGwxAmountTotal = getUserGwxAmountTotal(userAddress) | |
685 | + | let gwxRewardInv = reentrantInvoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes], nil) | |
686 | + | if ((gwxRewardInv == gwxRewardInv)) | |
687 | + | then { | |
688 | + | let arr = if (userIsExisting) | |
689 | + | then nil | |
690 | + | else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)] | |
691 | + | $Tuple2(((((arr ++ LockParamsEntry(userAddress, i.transactionId, pmtAmount, lockStart, duration, gWxAmountStart, 0)) ++ StatsEntry(pmtAmount, duration, 1, if (userIsExisting) | |
692 | + | then 0 | |
693 | + | else 1)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, duration, gWxAmountStart, i)) ++ [IntegerEntry(userBoostEmissionLastIntegralKEY, boostEmissionIntegral), IntegerEntry(keyGwxTotal(), (gwxAmountTotal + gWxAmountStart)), IntegerEntry(keyUserGwxAmountTotal(userAddress), (userGwxAmountTotal + gWxAmountStart))]), gWxAmountStart) | |
694 | + | } | |
695 | + | else throw("Strict value is not equal to itself.") | |
696 | + | } | |
697 | + | } | |
698 | + | } | |
699 | + | } | |
702 | 700 | ||
703 | 701 | ||
704 | 702 | func getWxWithdrawable (userAddress,txIdOption) = { | |
705 | 703 | let userRecordArray = readLockParamsRecordOrFail(userAddress, txIdOption) | |
706 | 704 | let userAmount = parseIntValue(userRecordArray[IdxLockAmount]) | |
707 | 705 | let lockStart = parseIntValue(userRecordArray[IdxLockStart]) | |
708 | 706 | let lockDuration = parseIntValue(userRecordArray[IdxLockDuration]) | |
709 | 707 | let lockEnd = (lockStart + lockDuration) | |
710 | 708 | let wxClaimed = parseIntValue(userRecordArray[IdxLockWxClaimed]) | |
711 | - | let gwxAmount = parseIntValue(userRecordArray[IdxLockGwxAmount]) | |
712 | 709 | let t = ((height - lockStart) / blocksInPeriod) | |
713 | 710 | let exponent = fraction(toBigInt(t), (toBigInt((8 * blocksInPeriod)) * MULT18BI), toBigInt(lockDuration)) | |
714 | 711 | let wxWithdrawable = if ((height > lockEnd)) | |
715 | 712 | then userAmount | |
716 | 713 | else (toInt(fraction(toBigInt(userAmount), (MULT18BI - pow(toBigInt(5), 1, exponent, SCALE18, SCALE18, DOWN)), MULT18BI)) - wxClaimed) | |
717 | 714 | wxWithdrawable | |
718 | 715 | } | |
719 | 716 | ||
720 | 717 | ||
721 | 718 | @Callable(i) | |
722 | 719 | func constructor (factoryAddressStr,lockAssetIdStr,minLockAmount,minDuration,maxDuration,mathContract) = { | |
723 | 720 | let checkCaller = mustManager(i) | |
724 | 721 | if ((checkCaller == checkCaller)) | |
725 | 722 | then ([IntegerEntry(keyNextUserNum(), 0), StringEntry(keyConfig(), formatConfig(lockAssetIdStr, minLockAmount, minDuration, maxDuration, mathContract)), StringEntry(keyFactoryAddress(), factoryAddressStr)] ++ StatsEntry(0, 0, 0, 0)) | |
726 | 723 | else throw("Strict value is not equal to itself.") | |
727 | 724 | } | |
728 | 725 | ||
729 | 726 | ||
730 | 727 | ||
731 | 728 | @Callable(i) | |
732 | 729 | func lockRef (duration,referrerAddress,signature) = { | |
733 | - | let $ | |
734 | - | let lockActionsResult = $ | |
735 | - | let gWxAmountStart = $ | |
730 | + | let $t02930929374 = lockActions(i, duration) | |
731 | + | let lockActionsResult = $t02930929374._1 | |
732 | + | let gWxAmountStart = $t02930929374._2 | |
736 | 733 | let referralAddress = toString(i.caller) | |
737 | 734 | let refInv = if (if ((referrerAddress == "")) | |
738 | 735 | then true | |
739 | 736 | else (signature == base58'')) | |
740 | 737 | then unit | |
741 | 738 | else invoke(referralsContractAddressOrFail, "createPair", [referralProgramName, referrerAddress, referralAddress, signature], nil) | |
742 | 739 | if ((refInv == refInv)) | |
743 | 740 | then { | |
744 | 741 | let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil) | |
745 | 742 | if ((updateRefActivity == updateRefActivity)) | |
746 | 743 | then $Tuple2(lockActionsResult, unit) | |
747 | 744 | else throw("Strict value is not equal to itself.") | |
748 | 745 | } | |
749 | 746 | else throw("Strict value is not equal to itself.") | |
750 | 747 | } | |
751 | 748 | ||
752 | 749 | ||
753 | 750 | ||
754 | 751 | @Callable(i) | |
755 | 752 | func lock (duration) = { | |
756 | - | let $ | |
757 | - | let lockActionsResult = $ | |
758 | - | let gWxAmountStart = $ | |
753 | + | let $t02983229897 = lockActions(i, duration) | |
754 | + | let lockActionsResult = $t02983229897._1 | |
755 | + | let gWxAmountStart = $t02983229897._2 | |
759 | 756 | let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil) | |
760 | 757 | if ((updateRefActivity == updateRefActivity)) | |
761 | 758 | then $Tuple2(lockActionsResult, unit) | |
762 | 759 | else throw("Strict value is not equal to itself.") | |
763 | 760 | } | |
764 | 761 | ||
765 | 762 | ||
766 | 763 | ||
767 | 764 | @Callable(i) | |
768 | 765 | func claimWxBoost (lpAssetIdStr,userAddressStr) = if ((stakingContract != i.caller)) | |
769 | 766 | then throwErr("permissions denied") | |
770 | 767 | else { | |
771 | - | let $ | |
772 | - | let userBoostAvailable = $ | |
773 | - | let dataState = $ | |
774 | - | let debug = $ | |
768 | + | let $t03020730309 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, false) | |
769 | + | let userBoostAvailable = $t03020730309._1 | |
770 | + | let dataState = $t03020730309._2 | |
771 | + | let debug = $t03020730309._3 | |
775 | 772 | $Tuple2(dataState, [userBoostAvailable]) | |
776 | 773 | } | |
777 | 774 | ||
778 | 775 | ||
779 | 776 | ||
780 | 777 | @Callable(i) | |
781 | 778 | func claimWxBoostREADONLY (lpAssetIdStr,userAddressStr) = { | |
782 | - | let $ | |
783 | - | let userBoostAvailable = $ | |
784 | - | let dataState = $ | |
785 | - | let debug = $ | |
779 | + | let $t03044130542 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, true) | |
780 | + | let userBoostAvailable = $t03044130542._1 | |
781 | + | let dataState = $t03044130542._2 | |
782 | + | let debug = $t03044130542._3 | |
786 | 783 | $Tuple2(nil, [userBoostAvailable, debug]) | |
787 | 784 | } | |
788 | 785 | ||
789 | 786 | ||
790 | 787 | ||
791 | 788 | @Callable(i) | |
792 | 789 | func unlock (txIdStr) = { | |
793 | 790 | let userAddress = i.caller | |
794 | 791 | let userAddressStr = toString(userAddress) | |
795 | 792 | let txId = fromBase58String(txIdStr) | |
796 | 793 | let userRecordArray = readLockParamsRecordOrFail(userAddress, if ((txIdStr == "")) | |
797 | 794 | then unit | |
798 | 795 | else txId) | |
799 | 796 | let userAmount = parseIntValue(userRecordArray[IdxLockAmount]) | |
800 | 797 | let lockStart = parseIntValue(userRecordArray[IdxLockStart]) | |
801 | 798 | let lockDuration = parseIntValue(userRecordArray[IdxLockDuration]) | |
802 | - | let lockEnd = (lockStart + lockDuration) | |
803 | 799 | let wxClaimed = parseIntValue(userRecordArray[IdxLockWxClaimed]) | |
804 | 800 | let gwxAmount = parseIntValue(userRecordArray[IdxLockGwxAmount]) | |
805 | 801 | let t = ((height - lockStart) / blocksInPeriod) | |
806 | 802 | let wxWithdrawable = getWxWithdrawable(userAddress, if ((txIdStr == "")) | |
807 | 803 | then unit | |
808 | 804 | else txId) | |
809 | - | let coeffX8 = fraction(lockDuration, MULT8, maxLockDuration) | |
810 | - | let gWxAmountStart = fraction(userAmount, coeffX8, MULT8) | |
805 | + | let gWxAmountStart = fraction(userAmount, lockDuration, maxLockDuration) | |
811 | 806 | let gwxBurned = min([fraction((t * blocksInPeriod), gWxAmountStart, maxLockDuration), gwxAmount]) | |
812 | 807 | let gwxRemaining = ensurePositive((gwxAmount - gwxBurned), "gwxRemaining") | |
813 | 808 | let lockedGwxAmount = getLockedGwxAmount(userAddress) | |
814 | 809 | if ((0 >= userAmount)) | |
815 | 810 | then throwErr("nothing to unlock") | |
816 | 811 | else { | |
817 | 812 | let gwxAmountTotal = getGwxAmountTotal() | |
818 | 813 | let userGwxAmountTotal = getUserGwxAmountTotal(userAddress) | |
819 | 814 | let userGwxAmountTotalNew = ensurePositive((userGwxAmountTotal - gwxBurned), "userGwxAmountTotalNew") | |
820 | 815 | if ((lockedGwxAmount > userGwxAmountTotalNew)) | |
821 | 816 | then throwErr(("locked gwx amount: " + toString(lockedGwxAmount))) | |
822 | 817 | else { | |
823 | 818 | let gwxRewardInv = reentrantInvoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes], nil) | |
824 | 819 | if ((gwxRewardInv == gwxRewardInv)) | |
825 | 820 | then ((((LockParamsEntry(userAddress, txId, userAmount, lockStart, lockDuration, gwxRemaining, (wxClaimed + wxWithdrawable)) ++ StatsEntry(-(wxWithdrawable), 0, 0, 0)) :+ HistoryEntry("unlock", userAddressStr, wxWithdrawable, lockStart, lockDuration, gwxBurned, i)) :+ ScriptTransfer(userAddress, wxWithdrawable, assetId)) ++ [IntegerEntry(keyGwxTotal(), ensurePositive((gwxAmountTotal - gwxBurned), "gwxTotal")), IntegerEntry(keyUserGwxAmountTotal(userAddress), userGwxAmountTotalNew)]) | |
826 | 821 | else throw("Strict value is not equal to itself.") | |
827 | 822 | } | |
828 | 823 | } | |
829 | 824 | } | |
830 | 825 | ||
831 | 826 | ||
832 | 827 | ||
833 | 828 | @Callable(i) | |
834 | 829 | func gwxUserInfoREADONLY (userAddressStr) = { | |
835 | 830 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
836 | 831 | let gwxAmount = getUserGwxAmountTotal(userAddress) | |
837 | 832 | $Tuple2(nil, [gwxAmount]) | |
838 | 833 | } | |
839 | 834 | ||
840 | 835 | ||
841 | 836 | ||
842 | 837 | @Callable(i) | |
843 | 838 | func userMaxDurationREADONLY (userAddressStr) = $Tuple2(nil, $Tuple2("increaseLock", maxLockDuration)) | |
844 | 839 | ||
845 | 840 | ||
846 | 841 | ||
847 | 842 | @Callable(i) | |
848 | 843 | func getUserGwxAmountAtHeightREADONLY (userAddressStr,targetHeight) = { | |
849 | 844 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
850 | 845 | let gwxAmount = getUserGwxAmountTotal(userAddress) | |
851 | 846 | $Tuple2(nil, gwxAmount) | |
852 | 847 | } | |
853 | 848 | ||
854 | 849 | ||
855 | 850 | ||
856 | 851 | @Callable(i) | |
857 | 852 | func getUserGwxAmount (userAddressStr) = { | |
858 | 853 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
859 | 854 | let gwxAmount = getUserGwxAmountTotal(userAddress) | |
860 | 855 | $Tuple2(nil, gwxAmount) | |
861 | 856 | } | |
862 | 857 | ||
863 | 858 | ||
864 | 859 | ||
865 | 860 | @Callable(i) | |
866 | 861 | func getGwxTotalREADONLY () = $Tuple2(nil, getGwxAmountTotal()) | |
867 | 862 | ||
868 | 863 | ||
869 | 864 | ||
870 | 865 | @Callable(i) | |
871 | 866 | func onBoostEmissionUpdate () = { | |
872 | 867 | let checkCaller = if ((i.caller == emissionContract)) | |
873 | 868 | then true | |
874 | 869 | else mustManager(i) | |
875 | 870 | if ((checkCaller == checkCaller)) | |
876 | 871 | then refreshBoostEmissionIntegral() | |
877 | 872 | else throw("Strict value is not equal to itself.") | |
878 | 873 | } | |
879 | 874 | ||
880 | 875 | ||
881 | 876 | ||
882 | 877 | @Callable(i) | |
883 | 878 | func onStakedVoteUpdate (lpAssetIdStr,userAddressStr,edge) = { | |
884 | 879 | let checkCaller = if ((i.caller == stakingContract)) | |
885 | 880 | then true | |
886 | 881 | else mustManager(i) | |
887 | 882 | if ((checkCaller == checkCaller)) | |
888 | 883 | then { | |
889 | 884 | let actions = refreshVoteStakedIntegral(lpAssetIdStr, userAddressStr, edge) | |
890 | 885 | $Tuple2(actions, unit) | |
891 | 886 | } | |
892 | 887 | else throw("Strict value is not equal to itself.") | |
893 | 888 | } | |
894 | 889 | ||
895 | 890 | ||
896 | 891 | ||
897 | 892 | @Callable(i) | |
898 | 893 | func getVotingResultStakedREADONLY (lpAssetIdStr) = $Tuple2(nil, getVotingResultStaked(lpAssetIdStr)) | |
899 | 894 | ||
900 | 895 | ||
901 | 896 | ||
902 | 897 | @Callable(i) | |
903 | 898 | func getVotingResultStakedIntegralREADONLY (lpAssetIdStr) = $Tuple2(nil, getVotingResultStakedIntegral(lpAssetIdStr)) | |
904 | 899 | ||
905 | 900 | ||
906 | 901 | ||
907 | 902 | @Callable(i) | |
908 | 903 | func getUserVoteFinalizedREADONLY (lpAssetIdStr,userAddressStr) = $Tuple2(nil, getUserVoteFinalized(lpAssetIdStr, userAddressStr)) | |
909 | 904 | ||
910 | 905 | ||
911 | 906 | ||
912 | 907 | @Callable(i) | |
913 | 908 | func getUserVoteStakedIntegralREADONLY (lpAssetIdStr,userAddressStr) = $Tuple2(nil, getUserVoteStakedIntegral(lpAssetIdStr, userAddressStr)) | |
914 | 909 | ||
915 | 910 | ||
916 | 911 | @Verifier(tx) | |
917 | 912 | func verify () = { | |
918 | 913 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
919 | 914 | case pk: ByteVector => | |
920 | 915 | pk | |
921 | 916 | case _: Unit => | |
922 | 917 | tx.senderPublicKey | |
923 | 918 | case _ => | |
924 | 919 | throw("Match error") | |
925 | 920 | } | |
926 | 921 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
927 | 922 | } | |
928 | 923 |
github/deemru/w8io/026f985 171.64 ms ◑