tx · 2BxzSun9bdECvdFx65B5UjpGouhuFGnnfqE3JdhFLXd6 3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz: -0.02300000 Waves 2023.03.10 12:12 [2483780] smart account 3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz > SELF 0.00000000 Waves
{ "type": 13, "id": "2BxzSun9bdECvdFx65B5UjpGouhuFGnnfqE3JdhFLXd6", "fee": 2300000, "feeAssetId": null, "timestamp": 1678439539535, "version": 2, "chainId": 84, "sender": "3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz", "senderPublicKey": "D28XoueZWsMfm8Y5pa6C5ZFuYoWgre2Wm8tzJANJgMnq", "proofs": [ "bHnobnXRSzi5vdLLyiSacAuGVHZw8RvAM4bfQSfZ1THL8S3WJ5XfgcCc6wKTrQ4kSKFUMDXXriiM7bpL3kqxurj" ], "script": "base64:BgKrIAgCEgMKAQgSAwoBCBIDCgEIEgASABIECgIIARIGCgQCAQICEgMKAQgSAwoBCBIFCgMICAQSBgoEARgIGBIECgIYCBIECgIICBIECgIICBIDCgEIEgQKAggIIgZTQ0FMRTgiBU1VTFQzIgVNVUxUOCIHU0NBTEUxOCIGTVVMVDE4IgNTRVAiDlBPT0xXRUlHSFRNVUxUIgp6ZXJvQmlnSW50IglvbmVCaWdJbnQiB3dyYXBFcnIiA21zZyIIdGhyb3dFcnIiCWFzQW55TGlzdCIDdmFsIgckbWF0Y2gwIgp2YWxBbnlMeXN0IgVhc0ludCIGdmFsSW50Ighhc1N0cmluZyIGdmFsU3RyIgxhc0J5dGVWZWN0b3IiBnZhbEJpbiIPZ2V0U3RyaW5nT3JGYWlsIgdhZGRyZXNzIgNrZXkiGGdldFN0cmluZ0J5QWRkcmVzc09yRmFpbCIMZ2V0SW50T3JaZXJvIg9nZXRJbnRPckRlZmF1bHQiCmRlZmF1bHRWYWwiDGdldEludE9yRmFpbCIZZ2V0QmlnSW50RnJvbVN0cmluZ09yWmVybyIcZ2V0Qm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AAMJAAECBQFvAgpCeXRlVmVjdG9yBAJjcAUBbwUCY3ADCQABAgUBbwIEVW5pdAgFAmRDD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJkQwlib2R5Qnl0ZXMJAJEDAggFAmRDBnByb29mcwAABQJkRQFUL/M=", "height": 2483780, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9wdw25zHJFRAv4HbHsdQntcoacSpWEMTi5Ue4KoWDW6m Next: BCgjAX1cXff2ep4f9E1YwtMHZaLerpCf831HCJy58phs Diff:
Old | New | Differences | |
---|---|---|---|
18 | 18 | let zeroBigInt = toBigInt(0) | |
19 | 19 | ||
20 | 20 | let oneBigInt = toBigInt(1) | |
21 | + | ||
22 | + | func wrapErr (msg) = makeString(["staking.ride:", toString(this), msg], " ") | |
23 | + | ||
24 | + | ||
25 | + | func throwErr (msg) = throw(wrapErr(msg)) | |
26 | + | ||
21 | 27 | ||
22 | 28 | func asAnyList (val) = match val { | |
23 | 29 | case valAnyLyst: List[Any] => | |
248 | 254 | else throw(($getType(@) + " couldn't be cast to Int")) | |
249 | 255 | } | |
250 | 256 | ||
257 | + | 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")) | |
258 | + | ||
251 | 259 | func keyNextUser (lpAssetId) = makeString(["%s%s", lpAssetId, "nextUser"], SEP) | |
252 | 260 | ||
253 | 261 | ||
357 | 365 | ||
358 | 366 | ||
359 | 367 | func refreshINTEGRALS (lpAssetIdStr,userAddressStr,poolAddressStr,lpDeltaAmount) = { | |
360 | - | let $ | |
361 | - | let wxPerLpIntegralNew = $ | |
362 | - | let poolIntegralSTATE = $ | |
363 | - | let poolDEBUG = $ | |
368 | + | let $t01476214884 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, lpDeltaAmount) | |
369 | + | let wxPerLpIntegralNew = $t01476214884._1 | |
370 | + | let poolIntegralSTATE = $t01476214884._2 | |
371 | + | let poolDEBUG = $t01476214884._3 | |
364 | 372 | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
365 | 373 | let stakedByUser = readStaked(stakedByUserKEY) | |
366 | 374 | let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr) | |
417 | 425 | case _ => | |
418 | 426 | throw("Match error") | |
419 | 427 | } | |
428 | + | ||
429 | + | ||
430 | + | func unstakeActions (i,lpAssetId,poolAddress,userAddress,lpAssetRecipientAddress,amount) = { | |
431 | + | let userAddressStr = toString(userAddress) | |
432 | + | let lpAssetIdStr = toBase58String(lpAssetId) | |
433 | + | let poolAddressStr = toString(poolAddress) | |
434 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
435 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
436 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
437 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
438 | + | let integralSTATE = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount))._2 | |
439 | + | let listName = getUsersListName(lpAssetIdStr) | |
440 | + | let listActions = if (if (containsNode(listName, userAddressStr)) | |
441 | + | then (amount == stakedByUser) | |
442 | + | else false) | |
443 | + | then deleteNodeActions(listName, userAddressStr) | |
444 | + | else nil | |
445 | + | let refreshStakedVote = if ((amount == stakedByUser)) | |
446 | + | then invoke(boostingContract, "onStakedVoteUpdate", [lpAssetIdStr, userAddressStr, false], nil) | |
447 | + | else unit | |
448 | + | if ((refreshStakedVote == refreshStakedVote)) | |
449 | + | then { | |
450 | + | let claimedByUserMinReward = getBigIntFromStringOrZero(this, keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr)) | |
451 | + | let wxToClaimUserNew = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0)._1 | |
452 | + | let availableToClaim = (wxToClaimUserNew - claimedByUserMinReward) | |
453 | + | let throwIfNothingToClaim = true | |
454 | + | let r = if ((availableToClaim > zeroBigInt)) | |
455 | + | then invoke(this, "claimWxINTERNAL", [lpAssetIdStr, userAddressStr, throwIfNothingToClaim], nil) | |
456 | + | else unit | |
457 | + | if ((r == r)) | |
458 | + | then if ((amount > stakedByUser)) | |
459 | + | then throw(((((((("passed amount=" + toString(amount)) + " is greater than available=") + toString(stakedByUser)) + ". lpAssetId=") + lpAssetIdStr) + ". stakedByUserKEY=") + stakedByUserKEY)) | |
460 | + | else (([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(lpAssetRecipientAddress, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) ++ listActions) | |
461 | + | else throw("Strict value is not equal to itself.") | |
462 | + | } | |
463 | + | else throw("Strict value is not equal to itself.") | |
464 | + | } | |
420 | 465 | ||
421 | 466 | ||
422 | 467 | @Callable(i) | |
498 | 543 | if ((refreshStakedVote == refreshStakedVote)) | |
499 | 544 | then { | |
500 | 545 | let stakedTotal = readStaked(stakedTotalKEY) | |
501 | - | let $ | |
502 | - | let wxToClaimUserNew = $ | |
503 | - | let integralSTATE = $ | |
504 | - | let debug = $ | |
546 | + | let $t02160621723 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, amount) | |
547 | + | let wxToClaimUserNew = $t02160621723._1 | |
548 | + | let integralSTATE = $t02160621723._2 | |
549 | + | let debug = $t02160621723._3 | |
505 | 550 | let listName = getUsersListName(lpAssetIdStr) | |
506 | 551 | let listActions = if (containsNode(listName, userAddressStr)) | |
507 | 552 | then nil | |
517 | 562 | func unstake (lpAssetIdStr,amount) = { | |
518 | 563 | let lpAssetId = fromBase58String(lpAssetIdStr) | |
519 | 564 | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
520 | - | let poolAddon = valueOrElse(getString(addressFromStringValue(poolAddressStr), keyAddonAddr()), poolAddressStr) | |
565 | + | let poolAddress = addressFromStringValue(poolAddressStr) | |
566 | + | let poolAddon = valueOrElse(getString(poolAddress, keyAddonAddr()), poolAddressStr) | |
521 | 567 | let callerStr = toString(i.caller) | |
522 | - | let | |
568 | + | let userAddress = if (if ((callerStr == poolAddressStr)) | |
523 | 569 | then true | |
524 | 570 | else (callerStr == poolAddon)) | |
525 | - | then toString(i.originCaller) | |
526 | - | else callerStr | |
527 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
528 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
529 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
530 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
531 | - | let integralSTATE = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount))._2 | |
532 | - | let listName = getUsersListName(lpAssetIdStr) | |
533 | - | let listActions = if (if (containsNode(listName, userAddressStr)) | |
534 | - | then (amount == stakedByUser) | |
535 | - | else false) | |
536 | - | then deleteNodeActions(listName, userAddressStr) | |
537 | - | else nil | |
538 | - | let refreshStakedVote = if ((amount == stakedByUser)) | |
539 | - | then invoke(boostingContract, "onStakedVoteUpdate", [lpAssetIdStr, userAddressStr, false], nil) | |
540 | - | else unit | |
541 | - | if ((refreshStakedVote == refreshStakedVote)) | |
542 | - | then { | |
543 | - | let claimedByUserMinReward = getBigIntFromStringOrZero(this, keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr)) | |
544 | - | let poolAddress = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
545 | - | let wxToClaimUserNew = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddress, 0)._1 | |
546 | - | let availableToClaim = (wxToClaimUserNew - claimedByUserMinReward) | |
547 | - | let r = if ((availableToClaim > zeroBigInt)) | |
548 | - | then invoke(this, "claimWxINTERNAL", [lpAssetIdStr, userAddressStr], nil) | |
549 | - | else unit | |
550 | - | if ((r == r)) | |
551 | - | then if ((amount > stakedByUser)) | |
552 | - | then throw(((((((("passed amount=" + toString(amount)) + " is greater than available=") + toString(stakedByUser)) + ". lpAssetId=") + lpAssetIdStr) + ". stakedByUserKEY=") + stakedByUserKEY)) | |
553 | - | else (([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) ++ listActions) | |
554 | - | else throw("Strict value is not equal to itself.") | |
555 | - | } | |
571 | + | then i.originCaller | |
572 | + | else i.caller | |
573 | + | let lpAssetRecipientAddress = i.caller | |
574 | + | unstakeActions(i, lpAssetId, poolAddress, userAddress, lpAssetRecipientAddress, amount) | |
575 | + | } | |
576 | + | ||
577 | + | ||
578 | + | ||
579 | + | @Callable(i) | |
580 | + | func unstakeINTERNAL (lpAssetId,amount,userAddress,lpAssetRecipientAddress) = { | |
581 | + | let lpAssetIdStr = toBase58String(lpAssetId) | |
582 | + | let poolAddress = addressFromStringValue(valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))) | |
583 | + | let checkCaller = if ((i.caller == poolAddress)) | |
584 | + | then true | |
585 | + | else permissionDeniedError | |
586 | + | if ((checkCaller == checkCaller)) | |
587 | + | then unstakeActions(i, lpAssetId, poolAddress, Address(userAddress), Address(lpAssetRecipientAddress), amount) | |
556 | 588 | else throw("Strict value is not equal to itself.") | |
557 | 589 | } | |
558 | 590 | ||
561 | 593 | @Callable(i) | |
562 | 594 | func claimWx (lpAssetIdStr) = { | |
563 | 595 | let userAddressStr = toString(i.caller) | |
564 | - | let result = invoke(this, "claimWxINTERNAL", [lpAssetIdStr, userAddressStr], nil) | |
596 | + | let throwIfNothingToClaim = true | |
597 | + | let result = invoke(this, "claimWxINTERNAL", [lpAssetIdStr, userAddressStr, throwIfNothingToClaim], nil) | |
565 | 598 | $Tuple2(nil, result) | |
566 | 599 | } | |
567 | 600 | ||
568 | 601 | ||
569 | 602 | ||
570 | 603 | @Callable(i) | |
571 | - | func claimWxINTERNAL (lpAssetIdStr,userAddressStr) = { | |
604 | + | func claimWxDoNotThrow (lpAssetIdStr) = { | |
605 | + | let userAddressStr = toString(i.caller) | |
606 | + | let throwIfNothingToClaim = false | |
607 | + | let result = invoke(this, "claimWxINTERNAL", [lpAssetIdStr, userAddressStr, throwIfNothingToClaim], nil) | |
608 | + | $Tuple2(nil, result) | |
609 | + | } | |
610 | + | ||
611 | + | ||
612 | + | ||
613 | + | @Callable(i) | |
614 | + | func claimWxINTERNAL (lpAssetIdStr,userAddressStr,throwIfNothingToClaim) = { | |
572 | 615 | let checkCaller = mustThis(i) | |
573 | 616 | if ((checkCaller == checkCaller)) | |
574 | 617 | then { | |
582 | 625 | let claimedByUserMinReward = getBigIntFromStringOrZero(this, claimedByUserMinRewardKEY) | |
583 | 626 | let claimedByUserBoostReward = getBigIntFromStringOrZero(this, claimedByUserBoostRewardKEY) | |
584 | 627 | let claimedTotal = getBigIntFromStringOrZero(this, claimedTotalKEY) | |
585 | - | let $ | |
586 | - | let wxToClaimUserNew = $ | |
587 | - | let integralSTATE = $ | |
588 | - | let debug = $ | |
628 | + | let $t02510925221 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
629 | + | let wxToClaimUserNew = $t02510925221._1 | |
630 | + | let integralSTATE = $t02510925221._2 | |
631 | + | let debug = $t02510925221._3 | |
589 | 632 | let availableToClaim = max([(wxToClaimUserNew - claimedByUserMinReward), zeroBigInt]) | |
590 | 633 | if ((zeroBigInt >= availableToClaim)) | |
591 | - | then throw("nothing to claim") | |
634 | + | then if (throwIfNothingToClaim) | |
635 | + | then throw("nothing to claim") | |
636 | + | else $Tuple2(nil, 0) | |
592 | 637 | else { | |
593 | 638 | let wxAmountBoostTotal = max([asInt(asAnyList(invoke(boostingContract, "claimWxBoost", [lpAssetIdStr, userAddressStr], nil))[0]), 0]) | |
594 | 639 | let minRewardPart = availableToClaim | |
595 | 640 | let boostRewardPart = min([(minRewardPart * toBigInt((boostCoeff - 1))), toBigInt(wxAmountBoostTotal)]) | |
641 | + | let totalReward = (minRewardPart + boostRewardPart) | |
596 | 642 | let wxAssetId = asByteVector(asAnyList(invoke(emissionContract, "emit", [toInt(minRewardPart)], nil))[0]) | |
597 | 643 | let emitBoost = asAnyList(invoke(emissionContract, "emit", [toInt(boostRewardPart)], nil)) | |
598 | 644 | if ((emitBoost == emitBoost)) | |
601 | 647 | let claimedByUserMinRewardPlusPart = (claimedByUserMinReward + minRewardPart) | |
602 | 648 | let claimedByUserBoostRewardPlusBoostRewardPart = (claimedByUserBoostReward + boostRewardPart) | |
603 | 649 | let claimedTotalPlusAvailableToClaim = (claimedTotal + availableToClaim) | |
604 | - | [StringEntry(claimedByUserKEY, toString(claimedByUserValue)), StringEntry(claimedByUserMinRewardKEY, toString(claimedByUserMinRewardPlusPart)), StringEntry(claimedByUserBoostRewardKEY, toString(claimedByUserBoostRewardPlusBoostRewardPart)), StringEntry(claimedTotalKEY, toString(claimedTotalPlusAvailableToClaim)), ScriptTransfer(userAddress, toInt(minRewardPart), wxAssetId), ScriptTransfer(userAddress, toInt(boostRewardPart), wxAssetId), OperationHistoryEntry("claim", userAddressStr, lpAssetIdStr, toInt(availableToClaim), i.transactionId)] | |
650 | + | $Tuple2([StringEntry(claimedByUserKEY, toString(claimedByUserValue)), StringEntry(claimedByUserMinRewardKEY, toString(claimedByUserMinRewardPlusPart)), StringEntry(claimedByUserBoostRewardKEY, toString(claimedByUserBoostRewardPlusBoostRewardPart)), StringEntry(claimedTotalKEY, toString(claimedTotalPlusAvailableToClaim)), ScriptTransfer(userAddress, toInt(minRewardPart), wxAssetId), ScriptTransfer(userAddress, toInt(boostRewardPart), wxAssetId), OperationHistoryEntry("claim", userAddressStr, lpAssetIdStr, toInt(availableToClaim), i.transactionId)], toInt(totalReward)) | |
605 | 651 | } | |
606 | 652 | else throw("Strict value is not equal to itself.") | |
607 | 653 | } | |
671 | 717 | else (height - emissionStartBlock) | |
672 | 718 | let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, POOLWEIGHTMULT) | |
673 | 719 | let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal) | |
674 | - | let $ | |
675 | - | let wxToClaimUserNew = $ | |
676 | - | let integralSTATE = $ | |
677 | - | let debug = $ | |
720 | + | let $t02926929381 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
721 | + | let wxToClaimUserNew = $t02926929381._1 | |
722 | + | let integralSTATE = $t02926929381._2 | |
723 | + | let debug = $t02926929381._3 | |
678 | 724 | let availableToClaim = max([(wxToClaimUserNew - claimedByUserMinReward), zeroBigInt]) | |
679 | 725 | let boostInvResult = asAnyList(invoke(boostingContract, "claimWxBoostREADONLY", [lpAssetIdStr, userAddressStr], nil)) | |
680 | 726 | let wxAmountBoostTotal = max([asInt(boostInvResult[0]), 0]) | |
683 | 729 | let boostRewardPart = min([(minRewardPart * toBigInt((boostCoeff - 1))), toBigInt(wxAmountBoostTotal)]) | |
684 | 730 | let totalReward = (minRewardPart + boostRewardPart) | |
685 | 731 | $Tuple2(nil, makeString(["%s%s%d%d%d%d%s", lpAssetIdStr, userAddressStr, toString(totalReward), toString(claimedByUser), toString(minRewardPart), toString(boostRewardPart), "soon"], SEP)) | |
732 | + | } | |
733 | + | ||
734 | + | ||
735 | + | ||
736 | + | @Callable(i) | |
737 | + | func stakedByUserREADONLY (lpAssetIdStr,userAddressStr) = { | |
738 | + | let stakedByUser = valueOrElse(getInteger(keyStakedByUser(userAddressStr, lpAssetIdStr)), 0) | |
739 | + | $Tuple2(nil, stakedByUser) | |
686 | 740 | } | |
687 | 741 | ||
688 | 742 | ||
712 | 766 | let poolAddress = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetId)) | |
713 | 767 | let wxToClaimUserNew = refreshINTEGRALS(lpAssetId, userAddress, poolAddress, 0)._1 | |
714 | 768 | let availableToClaim = (wxToClaimUserNew - claimedByUserMinReward) | |
769 | + | let throwIfNothingToClaim = true | |
715 | 770 | let r = if ((availableToClaim > zeroBigInt)) | |
716 | - | then invoke(this, "claimWxINTERNAL", [lpAssetId, userAddress], nil) | |
771 | + | then invoke(this, "claimWxINTERNAL", [lpAssetId, userAddress, throwIfNothingToClaim], nil) | |
717 | 772 | else unit | |
718 | 773 | if ((r == r)) | |
719 | 774 | then { | |
741 | 796 | func onModifyWeight (lpAssetIdStr,poolAddressStr) = if ((i.caller != factoryContract)) | |
742 | 797 | then throw("permissions denied") | |
743 | 798 | else { | |
744 | - | let $ | |
745 | - | let wxPerLpIntegralNew = $ | |
746 | - | let poolIntegralSTATE = $ | |
747 | - | let poolDEBUG = $ | |
799 | + | let $t03200232112 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, 0) | |
800 | + | let wxPerLpIntegralNew = $t03200232112._1 | |
801 | + | let poolIntegralSTATE = $t03200232112._2 | |
802 | + | let poolDEBUG = $t03200232112._3 | |
748 | 803 | poolIntegralSTATE | |
749 | 804 | } | |
750 | 805 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SCALE8 = 8 | |
5 | 5 | ||
6 | 6 | let MULT3 = 1000 | |
7 | 7 | ||
8 | 8 | let MULT8 = 100000000 | |
9 | 9 | ||
10 | 10 | let SCALE18 = 18 | |
11 | 11 | ||
12 | 12 | let MULT18 = toBigInt(1000000000000000000) | |
13 | 13 | ||
14 | 14 | let SEP = "__" | |
15 | 15 | ||
16 | 16 | let POOLWEIGHTMULT = MULT8 | |
17 | 17 | ||
18 | 18 | let zeroBigInt = toBigInt(0) | |
19 | 19 | ||
20 | 20 | let oneBigInt = toBigInt(1) | |
21 | + | ||
22 | + | func wrapErr (msg) = makeString(["staking.ride:", toString(this), msg], " ") | |
23 | + | ||
24 | + | ||
25 | + | func throwErr (msg) = throw(wrapErr(msg)) | |
26 | + | ||
21 | 27 | ||
22 | 28 | func asAnyList (val) = match val { | |
23 | 29 | case valAnyLyst: List[Any] => | |
24 | 30 | valAnyLyst | |
25 | 31 | case _ => | |
26 | 32 | throw("fail to cast into List[Any]") | |
27 | 33 | } | |
28 | 34 | ||
29 | 35 | ||
30 | 36 | func asInt (val) = match val { | |
31 | 37 | case valInt: Int => | |
32 | 38 | valInt | |
33 | 39 | case _ => | |
34 | 40 | throw("fail to cast into Int") | |
35 | 41 | } | |
36 | 42 | ||
37 | 43 | ||
38 | 44 | func asString (val) = match val { | |
39 | 45 | case valStr: String => | |
40 | 46 | valStr | |
41 | 47 | case _ => | |
42 | 48 | throw("fail to cast into Int") | |
43 | 49 | } | |
44 | 50 | ||
45 | 51 | ||
46 | 52 | func asByteVector (val) = match val { | |
47 | 53 | case valBin: ByteVector => | |
48 | 54 | valBin | |
49 | 55 | case _ => | |
50 | 56 | throw("fail to cast into Int") | |
51 | 57 | } | |
52 | 58 | ||
53 | 59 | ||
54 | 60 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (("mandatory this." + key) + " is not defined")) | |
55 | 61 | ||
56 | 62 | ||
57 | 63 | func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
58 | 64 | ||
59 | 65 | ||
60 | 66 | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) | |
61 | 67 | ||
62 | 68 | ||
63 | 69 | func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal) | |
64 | 70 | ||
65 | 71 | ||
66 | 72 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined")) | |
67 | 73 | ||
68 | 74 | ||
69 | 75 | func getBigIntFromStringOrZero (address,key) = value(parseBigInt(valueOrElse(getString(address, key), "0"))) | |
70 | 76 | ||
71 | 77 | ||
72 | 78 | func getBigIntFromStringOrDefault (address,key,defaultVal) = match getString(address, key) { | |
73 | 79 | case s: String => | |
74 | 80 | value(parseBigInt(s)) | |
75 | 81 | case _: Unit => | |
76 | 82 | defaultVal | |
77 | 83 | case _ => | |
78 | 84 | throw("Match error") | |
79 | 85 | } | |
80 | 86 | ||
81 | 87 | ||
82 | 88 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), MULT18, toBigInt(origScaleMult)) | |
83 | 89 | ||
84 | 90 | ||
85 | 91 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), MULT18)) | |
86 | 92 | ||
87 | 93 | ||
88 | 94 | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
89 | 95 | ||
90 | 96 | ||
91 | 97 | func keyVotingEmissionContract () = "%s__votingEmissionContract" | |
92 | 98 | ||
93 | 99 | ||
94 | 100 | let IdxFactoryCfgStakingDapp = 1 | |
95 | 101 | ||
96 | 102 | let IdxFactoryCfgBoostingDapp = 2 | |
97 | 103 | ||
98 | 104 | let IdxFactoryCfgIdoDapp = 3 | |
99 | 105 | ||
100 | 106 | let IdxFactoryCfgTeamDapp = 4 | |
101 | 107 | ||
102 | 108 | let IdxFactoryCfgEmissionDapp = 5 | |
103 | 109 | ||
104 | 110 | let IdxFactoryCfgRestDapp = 6 | |
105 | 111 | ||
106 | 112 | let IdxFactoryCfgSlippageDapp = 7 | |
107 | 113 | ||
108 | 114 | func keyFactoryCfg () = "%s__factoryConfig" | |
109 | 115 | ||
110 | 116 | ||
111 | 117 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
112 | 118 | ||
113 | 119 | ||
114 | 120 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
115 | 121 | ||
116 | 122 | ||
117 | 123 | func keyStablePoolAddonAddr () = "%s__stablePoolAddonAddr" | |
118 | 124 | ||
119 | 125 | ||
120 | 126 | func keyAddonAddr () = "%s__addonAddr" | |
121 | 127 | ||
122 | 128 | ||
123 | 129 | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
124 | 130 | ||
125 | 131 | ||
126 | 132 | func keyFactoryLpList () = "%s__lpTokensList" | |
127 | 133 | ||
128 | 134 | ||
129 | 135 | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
130 | 136 | ||
131 | 137 | ||
132 | 138 | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
133 | 139 | ||
134 | 140 | ||
135 | 141 | func readLpList (factory) = split(valueOrElse(getString(factory, keyFactoryLpList()), ""), SEP) | |
136 | 142 | ||
137 | 143 | ||
138 | 144 | func readFactoryCfgOrFail (factory) = split(getStringByAddressOrFail(factory, keyFactoryCfg()), SEP) | |
139 | 145 | ||
140 | 146 | ||
141 | 147 | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
142 | 148 | ||
143 | 149 | ||
144 | 150 | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
145 | 151 | ||
146 | 152 | ||
147 | 153 | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
148 | 154 | ||
149 | 155 | ||
150 | 156 | func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
151 | 157 | ||
152 | 158 | ||
153 | 159 | func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
154 | 160 | ||
155 | 161 | ||
156 | 162 | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
157 | 163 | ||
158 | 164 | ||
159 | 165 | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
160 | 166 | ||
161 | 167 | ||
162 | 168 | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
163 | 169 | ||
164 | 170 | ||
165 | 171 | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) | |
166 | 172 | ||
167 | 173 | ||
168 | 174 | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) | |
169 | 175 | ||
170 | 176 | ||
171 | 177 | func keyClaimedByUser (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP) | |
172 | 178 | ||
173 | 179 | ||
174 | 180 | func keyClaimedByUserMinReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedMinReward", userAddressStr, lpAssetIdStr], SEP) | |
175 | 181 | ||
176 | 182 | ||
177 | 183 | func keyClaimedByUserBoostReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedBoostReward", userAddressStr, lpAssetIdStr], SEP) | |
178 | 184 | ||
179 | 185 | ||
180 | 186 | func keyClaimedTotal (lpAssetIdStr) = makeString(["%s%s%s__claimed__total", lpAssetIdStr], SEP) | |
181 | 187 | ||
182 | 188 | ||
183 | 189 | func readStaked (key) = valueOrElse(getInteger(this, key), 0) | |
184 | 190 | ||
185 | 191 | ||
186 | 192 | func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP) | |
187 | 193 | ||
188 | 194 | ||
189 | 195 | func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP) | |
190 | 196 | ||
191 | 197 | ||
192 | 198 | func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP) | |
193 | 199 | ||
194 | 200 | ||
195 | 201 | func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP) | |
196 | 202 | ||
197 | 203 | ||
198 | 204 | func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP) | |
199 | 205 | ||
200 | 206 | ||
201 | 207 | func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP) | |
202 | 208 | ||
203 | 209 | ||
204 | 210 | func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP) | |
205 | 211 | ||
206 | 212 | ||
207 | 213 | func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP) | |
208 | 214 | ||
209 | 215 | ||
210 | 216 | func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP) | |
211 | 217 | ||
212 | 218 | ||
213 | 219 | func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP) | |
214 | 220 | ||
215 | 221 | ||
216 | 222 | func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP) | |
217 | 223 | ||
218 | 224 | ||
219 | 225 | func keyWxPerLpX18 (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLpX18"], SEP) | |
220 | 226 | ||
221 | 227 | ||
222 | 228 | func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP) | |
223 | 229 | ||
224 | 230 | ||
225 | 231 | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
226 | 232 | ||
227 | 233 | ||
228 | 234 | func formatHistoryRecord (userAddress,lpAssetId,type,amount) = makeString(["%s%s%s%d%d%d", userAddress, lpAssetId, type, toString(height), toString(lastBlock.timestamp), toString(amount)], SEP) | |
229 | 235 | ||
230 | 236 | ||
231 | 237 | func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount)) | |
232 | 238 | ||
233 | 239 | ||
234 | 240 | let factoryAddress = getStringOrFail(this, keyFactoryAddress()) | |
235 | 241 | ||
236 | 242 | let factoryContract = addressFromStringValue(factoryAddress) | |
237 | 243 | ||
238 | 244 | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
239 | 245 | ||
240 | 246 | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
241 | 247 | ||
242 | 248 | let boostingContract = getBoostingAddressOrFail(factoryCfg) | |
243 | 249 | ||
244 | 250 | let boostCoeff = { | |
245 | 251 | let @ = invoke(emissionContract, "getBoostCoeffREADONLY", nil, nil) | |
246 | 252 | if ($isInstanceOf(@, "Int")) | |
247 | 253 | then @ | |
248 | 254 | else throw(($getType(@) + " couldn't be cast to Int")) | |
249 | 255 | } | |
250 | 256 | ||
257 | + | 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")) | |
258 | + | ||
251 | 259 | func keyNextUser (lpAssetId) = makeString(["%s%s", lpAssetId, "nextUser"], SEP) | |
252 | 260 | ||
253 | 261 | ||
254 | 262 | func getUsersListName (lpAssetId) = makeString(["users", lpAssetId], SEP) | |
255 | 263 | ||
256 | 264 | ||
257 | 265 | func keyListHead (listName) = makeString(["%s%s%s", listName, "head"], SEP) | |
258 | 266 | ||
259 | 267 | ||
260 | 268 | func keyListSize (listName) = makeString(["%s%s%s", listName, "size"], SEP) | |
261 | 269 | ||
262 | 270 | ||
263 | 271 | func keyListPrev (listName,id) = makeString(["%s%s%s%s", listName, id, "prev"], SEP) | |
264 | 272 | ||
265 | 273 | ||
266 | 274 | func keyListNext (listName,id) = makeString(["%s%s%s%s", listName, id, "next"], SEP) | |
267 | 275 | ||
268 | 276 | ||
269 | 277 | func containsNode (listName,id) = { | |
270 | 278 | let headOrUnit = getString(this, keyListHead(listName)) | |
271 | 279 | let prevOrUnit = getString(this, keyListPrev(listName, id)) | |
272 | 280 | let nextOrUnit = getString(this, keyListNext(listName, id)) | |
273 | 281 | if (if ((id == valueOrElse(headOrUnit, ""))) | |
274 | 282 | then true | |
275 | 283 | else (prevOrUnit != unit)) | |
276 | 284 | then true | |
277 | 285 | else (nextOrUnit != unit) | |
278 | 286 | } | |
279 | 287 | ||
280 | 288 | ||
281 | 289 | func insertNodeActions (listName,id) = { | |
282 | 290 | let headOrUnit = getString(this, keyListHead(listName)) | |
283 | 291 | let listSize = valueOrElse(getInteger(this, keyListSize(listName)), 0) | |
284 | 292 | let checkNode = if (!(containsNode(listName, id))) | |
285 | 293 | then true | |
286 | 294 | else throw("Node exists") | |
287 | 295 | if ((checkNode == checkNode)) | |
288 | 296 | then (([IntegerEntry(keyListSize(listName), (listSize + 1))] ++ (if ((headOrUnit != unit)) | |
289 | 297 | then [StringEntry(keyListNext(listName, id), value(headOrUnit)), StringEntry(keyListPrev(listName, value(headOrUnit)), id)] | |
290 | 298 | else nil)) ++ [StringEntry(keyListHead(listName), id)]) | |
291 | 299 | else throw("Strict value is not equal to itself.") | |
292 | 300 | } | |
293 | 301 | ||
294 | 302 | ||
295 | 303 | func deleteNodeActions (listName,id) = { | |
296 | 304 | let headOrUnit = getString(this, keyListHead(listName)) | |
297 | 305 | let listSize = valueOrElse(getInteger(this, keyListSize(listName)), 0) | |
298 | 306 | let prevOrUnit = getString(this, keyListPrev(listName, id)) | |
299 | 307 | let nextOrUnit = getString(this, keyListNext(listName, id)) | |
300 | 308 | ([IntegerEntry(keyListSize(listName), (listSize - 1))] ++ (if (if ((prevOrUnit != unit)) | |
301 | 309 | then (nextOrUnit != unit) | |
302 | 310 | else false) | |
303 | 311 | then [StringEntry(keyListNext(listName, value(prevOrUnit)), value(nextOrUnit)), StringEntry(keyListPrev(listName, value(nextOrUnit)), value(prevOrUnit)), DeleteEntry(keyListPrev(listName, id)), DeleteEntry(keyListNext(listName, id))] | |
304 | 312 | else if ((nextOrUnit != unit)) | |
305 | 313 | then [StringEntry(keyListHead(listName), value(nextOrUnit)), DeleteEntry(keyListNext(listName, id)), DeleteEntry(keyListPrev(listName, value(nextOrUnit)))] | |
306 | 314 | else if ((prevOrUnit != unit)) | |
307 | 315 | then [DeleteEntry(keyListPrev(listName, id)), DeleteEntry(keyListNext(listName, value(prevOrUnit)))] | |
308 | 316 | else if ((id == valueOrElse(headOrUnit, ""))) | |
309 | 317 | then [DeleteEntry(keyListHead(listName))] | |
310 | 318 | else throw(((("invalid node: " + listName) + ".") + id)))) | |
311 | 319 | } | |
312 | 320 | ||
313 | 321 | ||
314 | 322 | func calcWxPerLpIntegralUserLast (stakedByUser,wxPerLpIntegralUserLastUpdHeightOrZero,wxPerLpIntegralNew,wxPerLpIntegralUserLastKEY) = if (if ((wxPerLpIntegralUserLastUpdHeightOrZero == zeroBigInt)) | |
315 | 323 | then (stakedByUser > zeroBigInt) | |
316 | 324 | else false) | |
317 | 325 | then zeroBigInt | |
318 | 326 | else if ((stakedByUser == zeroBigInt)) | |
319 | 327 | then wxPerLpIntegralNew | |
320 | 328 | else if (if ((wxPerLpIntegralUserLastUpdHeightOrZero > zeroBigInt)) | |
321 | 329 | then (stakedByUser > zeroBigInt) | |
322 | 330 | else false) | |
323 | 331 | then value(parseBigInt(getStringOrFail(this, wxPerLpIntegralUserLastKEY))) | |
324 | 332 | else throw("calcWxPerLpIntegralUserLast: unexpected state") | |
325 | 333 | ||
326 | 334 | ||
327 | 335 | func refreshPoolINTEGRALS (lpAssetIdStr,poolAddressStr,lpDeltaAmount) = { | |
328 | 336 | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
329 | 337 | let stakedTotal = toBigInt(readStaked(stakedTotalKEY)) | |
330 | 338 | let nonZeroStakedTotal = if ((stakedTotal == zeroBigInt)) | |
331 | 339 | then oneBigInt | |
332 | 340 | else stakedTotal | |
333 | 341 | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
334 | 342 | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
335 | 343 | let wxEmissionPerBlockX3 = (getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) * MULT3) | |
336 | 344 | let poolWxEmissionPerBlockX3 = fraction(wxEmissionPerBlockX3, poolWeight, (POOLWEIGHTMULT * boostCoeff)) | |
337 | 345 | let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr) | |
338 | 346 | let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr) | |
339 | 347 | let wxPerLpKEY = keyWxPerLp(lpAssetIdStr) | |
340 | 348 | let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock) | |
341 | 349 | let wxPerLpIntegral = getBigIntFromStringOrZero(this, wxPerLpIntegralKEY) | |
342 | 350 | let wxPerLpOrZeroX3 = 0 | |
343 | 351 | let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0]) | |
344 | 352 | let wxPerLpX3 = if ((wxPerLpOrZeroX3 != 0)) | |
345 | 353 | then toBigInt(wxPerLpOrZeroX3) | |
346 | 354 | else fraction(toBigInt(poolWxEmissionPerBlockX3), toBigInt(MULT8), nonZeroStakedTotal) | |
347 | 355 | let stakedTotalNew = (stakedTotal + toBigInt(lpDeltaAmount)) | |
348 | 356 | let nonZeroStakedTotalNew = if ((stakedTotalNew == zeroBigInt)) | |
349 | 357 | then oneBigInt | |
350 | 358 | else stakedTotalNew | |
351 | 359 | let wxPerLpIntegralNew = (wxPerLpIntegral + (wxPerLpX3 * toBigInt(dh))) | |
352 | 360 | let wxPerLpX3New = (toBigInt(poolWxEmissionPerBlockX3) / nonZeroStakedTotalNew) | |
353 | 361 | let wxPerLpIntegralLastUpdHeightNew = height | |
354 | 362 | let debug = makeString([toString(wxPerLpIntegralNew), toString(dh), toString(wxPerLpX3), toString(stakedTotal), toString(poolWxEmissionPerBlockX3), toString(wxEmissionPerBlockX3), toString(poolWeight)], "::") | |
355 | 363 | $Tuple3(wxPerLpIntegralNew, [StringEntry(wxPerLpIntegralKEY, toString(wxPerLpIntegralNew)), IntegerEntry(wxPerLpIntegralLastUpdHeightKEY, wxPerLpIntegralLastUpdHeightNew), StringEntry(wxPerLpKEY, toString(wxPerLpX3New))], debug) | |
356 | 364 | } | |
357 | 365 | ||
358 | 366 | ||
359 | 367 | func refreshINTEGRALS (lpAssetIdStr,userAddressStr,poolAddressStr,lpDeltaAmount) = { | |
360 | - | let $ | |
361 | - | let wxPerLpIntegralNew = $ | |
362 | - | let poolIntegralSTATE = $ | |
363 | - | let poolDEBUG = $ | |
368 | + | let $t01476214884 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, lpDeltaAmount) | |
369 | + | let wxPerLpIntegralNew = $t01476214884._1 | |
370 | + | let poolIntegralSTATE = $t01476214884._2 | |
371 | + | let poolDEBUG = $t01476214884._3 | |
364 | 372 | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
365 | 373 | let stakedByUser = readStaked(stakedByUserKEY) | |
366 | 374 | let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr) | |
367 | 375 | let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr) | |
368 | 376 | let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr) | |
369 | 377 | let wxToClaimUser = getBigIntFromStringOrZero(this, wxToClaimUserKEY) | |
370 | 378 | let wxPerLpIntegralUserLastUpdHeightOrZero = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY) | |
371 | 379 | let wxPerLpIntegralUserLast = calcWxPerLpIntegralUserLast(toBigInt(stakedByUser), toBigInt(wxPerLpIntegralUserLastUpdHeightOrZero), wxPerLpIntegralNew, wxPerLpIntegralUserLastKEY) | |
372 | 380 | let MULT11 = (MULT8 * MULT3) | |
373 | 381 | let wxToClaimUserNew = max([(wxToClaimUser + fraction((wxPerLpIntegralNew - wxPerLpIntegralUserLast), toBigInt(stakedByUser), toBigInt(MULT11))), zeroBigInt]) | |
374 | 382 | let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew | |
375 | 383 | let wxPerLpIntegralUserLastUpdHeightNew = height | |
376 | 384 | let debug = makeString([toString(wxToClaimUser), toString(wxPerLpIntegralUserLast), toString(stakedByUser), poolDEBUG, toString(height)], "::") | |
377 | 385 | $Tuple3(wxToClaimUserNew, (poolIntegralSTATE ++ [StringEntry(wxToClaimUserKEY, toString(wxToClaimUserNew)), IntegerEntry(wxPerLpIntegralUserLastUpdHeightKEY, wxPerLpIntegralUserLastUpdHeightNew), StringEntry(wxPerLpIntegralUserLastKEY, toString(wxPerLpIntegralUserLastNew))]), debug) | |
378 | 386 | } | |
379 | 387 | ||
380 | 388 | ||
381 | 389 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
382 | 390 | case s: String => | |
383 | 391 | fromBase58String(s) | |
384 | 392 | case _: Unit => | |
385 | 393 | unit | |
386 | 394 | case _ => | |
387 | 395 | throw("Match error") | |
388 | 396 | } | |
389 | 397 | ||
390 | 398 | ||
391 | 399 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
392 | 400 | case s: String => | |
393 | 401 | fromBase58String(s) | |
394 | 402 | case _: Unit => | |
395 | 403 | unit | |
396 | 404 | case _ => | |
397 | 405 | throw("Match error") | |
398 | 406 | } | |
399 | 407 | ||
400 | 408 | ||
401 | 409 | let permissionDeniedError = throw("Permission denied") | |
402 | 410 | ||
403 | 411 | func mustThis (i) = if ((i.caller == this)) | |
404 | 412 | then true | |
405 | 413 | else permissionDeniedError | |
406 | 414 | ||
407 | 415 | ||
408 | 416 | func mustManager (i) = match managerPublicKeyOrUnit() { | |
409 | 417 | case pk: ByteVector => | |
410 | 418 | if ((i.callerPublicKey == pk)) | |
411 | 419 | then true | |
412 | 420 | else permissionDeniedError | |
413 | 421 | case _: Unit => | |
414 | 422 | if ((i.caller == this)) | |
415 | 423 | then true | |
416 | 424 | else permissionDeniedError | |
417 | 425 | case _ => | |
418 | 426 | throw("Match error") | |
419 | 427 | } | |
428 | + | ||
429 | + | ||
430 | + | func unstakeActions (i,lpAssetId,poolAddress,userAddress,lpAssetRecipientAddress,amount) = { | |
431 | + | let userAddressStr = toString(userAddress) | |
432 | + | let lpAssetIdStr = toBase58String(lpAssetId) | |
433 | + | let poolAddressStr = toString(poolAddress) | |
434 | + | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
435 | + | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
436 | + | let stakedByUser = readStaked(stakedByUserKEY) | |
437 | + | let stakedTotal = readStaked(stakedTotalKEY) | |
438 | + | let integralSTATE = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount))._2 | |
439 | + | let listName = getUsersListName(lpAssetIdStr) | |
440 | + | let listActions = if (if (containsNode(listName, userAddressStr)) | |
441 | + | then (amount == stakedByUser) | |
442 | + | else false) | |
443 | + | then deleteNodeActions(listName, userAddressStr) | |
444 | + | else nil | |
445 | + | let refreshStakedVote = if ((amount == stakedByUser)) | |
446 | + | then invoke(boostingContract, "onStakedVoteUpdate", [lpAssetIdStr, userAddressStr, false], nil) | |
447 | + | else unit | |
448 | + | if ((refreshStakedVote == refreshStakedVote)) | |
449 | + | then { | |
450 | + | let claimedByUserMinReward = getBigIntFromStringOrZero(this, keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr)) | |
451 | + | let wxToClaimUserNew = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0)._1 | |
452 | + | let availableToClaim = (wxToClaimUserNew - claimedByUserMinReward) | |
453 | + | let throwIfNothingToClaim = true | |
454 | + | let r = if ((availableToClaim > zeroBigInt)) | |
455 | + | then invoke(this, "claimWxINTERNAL", [lpAssetIdStr, userAddressStr, throwIfNothingToClaim], nil) | |
456 | + | else unit | |
457 | + | if ((r == r)) | |
458 | + | then if ((amount > stakedByUser)) | |
459 | + | then throw(((((((("passed amount=" + toString(amount)) + " is greater than available=") + toString(stakedByUser)) + ". lpAssetId=") + lpAssetIdStr) + ". stakedByUserKEY=") + stakedByUserKEY)) | |
460 | + | else (([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(lpAssetRecipientAddress, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) ++ listActions) | |
461 | + | else throw("Strict value is not equal to itself.") | |
462 | + | } | |
463 | + | else throw("Strict value is not equal to itself.") | |
464 | + | } | |
420 | 465 | ||
421 | 466 | ||
422 | 467 | @Callable(i) | |
423 | 468 | func constructor (factoryAddressStr) = { | |
424 | 469 | let checkCaller = mustManager(i) | |
425 | 470 | if ((checkCaller == checkCaller)) | |
426 | 471 | then [StringEntry(keyFactoryAddress(), factoryAddressStr)] | |
427 | 472 | else throw("Strict value is not equal to itself.") | |
428 | 473 | } | |
429 | 474 | ||
430 | 475 | ||
431 | 476 | ||
432 | 477 | @Callable(i) | |
433 | 478 | func constructorV2 (votingEmissionContract) = { | |
434 | 479 | let cheks = [mustManager(i), if ((addressFromString(votingEmissionContract) != unit)) | |
435 | 480 | then true | |
436 | 481 | else "invalid voting emission contract address"] | |
437 | 482 | if ((cheks == cheks)) | |
438 | 483 | then [StringEntry(keyVotingEmissionContract(), votingEmissionContract)] | |
439 | 484 | else throw("Strict value is not equal to itself.") | |
440 | 485 | } | |
441 | 486 | ||
442 | 487 | ||
443 | 488 | ||
444 | 489 | @Callable(i) | |
445 | 490 | func setManager (pendingManagerPublicKey) = { | |
446 | 491 | let checkCaller = mustManager(i) | |
447 | 492 | if ((checkCaller == checkCaller)) | |
448 | 493 | then { | |
449 | 494 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
450 | 495 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
451 | 496 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
452 | 497 | else throw("Strict value is not equal to itself.") | |
453 | 498 | } | |
454 | 499 | else throw("Strict value is not equal to itself.") | |
455 | 500 | } | |
456 | 501 | ||
457 | 502 | ||
458 | 503 | ||
459 | 504 | @Callable(i) | |
460 | 505 | func confirmManager () = { | |
461 | 506 | let pm = pendingManagerPublicKeyOrUnit() | |
462 | 507 | let hasPM = if (isDefined(pm)) | |
463 | 508 | then true | |
464 | 509 | else throw("No pending manager") | |
465 | 510 | if ((hasPM == hasPM)) | |
466 | 511 | then { | |
467 | 512 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
468 | 513 | then true | |
469 | 514 | else throw("You are not pending manager") | |
470 | 515 | if ((checkPM == checkPM)) | |
471 | 516 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
472 | 517 | else throw("Strict value is not equal to itself.") | |
473 | 518 | } | |
474 | 519 | else throw("Strict value is not equal to itself.") | |
475 | 520 | } | |
476 | 521 | ||
477 | 522 | ||
478 | 523 | ||
479 | 524 | @Callable(i) | |
480 | 525 | func stake () = if ((size(i.payments) != 1)) | |
481 | 526 | then throw("invalid payment - exact one payment must be attached") | |
482 | 527 | else { | |
483 | 528 | let pmt = i.payments[0] | |
484 | 529 | let lpAssetId = value(pmt.assetId) | |
485 | 530 | let lpAssetIdStr = toBase58String(lpAssetId) | |
486 | 531 | let amount = pmt.amount | |
487 | 532 | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
488 | 533 | let callerStr = toString(i.caller) | |
489 | 534 | let userAddressStr = if ((callerStr == poolAddressStr)) | |
490 | 535 | then toString(i.originCaller) | |
491 | 536 | else callerStr | |
492 | 537 | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
493 | 538 | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
494 | 539 | let stakedByUser = readStaked(stakedByUserKEY) | |
495 | 540 | let refreshStakedVote = if ((stakedByUser == 0)) | |
496 | 541 | then invoke(boostingContract, "onStakedVoteUpdate", [lpAssetIdStr, userAddressStr, true], nil) | |
497 | 542 | else unit | |
498 | 543 | if ((refreshStakedVote == refreshStakedVote)) | |
499 | 544 | then { | |
500 | 545 | let stakedTotal = readStaked(stakedTotalKEY) | |
501 | - | let $ | |
502 | - | let wxToClaimUserNew = $ | |
503 | - | let integralSTATE = $ | |
504 | - | let debug = $ | |
546 | + | let $t02160621723 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, amount) | |
547 | + | let wxToClaimUserNew = $t02160621723._1 | |
548 | + | let integralSTATE = $t02160621723._2 | |
549 | + | let debug = $t02160621723._3 | |
505 | 550 | let listName = getUsersListName(lpAssetIdStr) | |
506 | 551 | let listActions = if (containsNode(listName, userAddressStr)) | |
507 | 552 | then nil | |
508 | 553 | else insertNodeActions(listName, userAddressStr) | |
509 | 554 | (([IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) ++ listActions) | |
510 | 555 | } | |
511 | 556 | else throw("Strict value is not equal to itself.") | |
512 | 557 | } | |
513 | 558 | ||
514 | 559 | ||
515 | 560 | ||
516 | 561 | @Callable(i) | |
517 | 562 | func unstake (lpAssetIdStr,amount) = { | |
518 | 563 | let lpAssetId = fromBase58String(lpAssetIdStr) | |
519 | 564 | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
520 | - | let poolAddon = valueOrElse(getString(addressFromStringValue(poolAddressStr), keyAddonAddr()), poolAddressStr) | |
565 | + | let poolAddress = addressFromStringValue(poolAddressStr) | |
566 | + | let poolAddon = valueOrElse(getString(poolAddress, keyAddonAddr()), poolAddressStr) | |
521 | 567 | let callerStr = toString(i.caller) | |
522 | - | let | |
568 | + | let userAddress = if (if ((callerStr == poolAddressStr)) | |
523 | 569 | then true | |
524 | 570 | else (callerStr == poolAddon)) | |
525 | - | then toString(i.originCaller) | |
526 | - | else callerStr | |
527 | - | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
528 | - | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
529 | - | let stakedByUser = readStaked(stakedByUserKEY) | |
530 | - | let stakedTotal = readStaked(stakedTotalKEY) | |
531 | - | let integralSTATE = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount))._2 | |
532 | - | let listName = getUsersListName(lpAssetIdStr) | |
533 | - | let listActions = if (if (containsNode(listName, userAddressStr)) | |
534 | - | then (amount == stakedByUser) | |
535 | - | else false) | |
536 | - | then deleteNodeActions(listName, userAddressStr) | |
537 | - | else nil | |
538 | - | let refreshStakedVote = if ((amount == stakedByUser)) | |
539 | - | then invoke(boostingContract, "onStakedVoteUpdate", [lpAssetIdStr, userAddressStr, false], nil) | |
540 | - | else unit | |
541 | - | if ((refreshStakedVote == refreshStakedVote)) | |
542 | - | then { | |
543 | - | let claimedByUserMinReward = getBigIntFromStringOrZero(this, keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr)) | |
544 | - | let poolAddress = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
545 | - | let wxToClaimUserNew = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddress, 0)._1 | |
546 | - | let availableToClaim = (wxToClaimUserNew - claimedByUserMinReward) | |
547 | - | let r = if ((availableToClaim > zeroBigInt)) | |
548 | - | then invoke(this, "claimWxINTERNAL", [lpAssetIdStr, userAddressStr], nil) | |
549 | - | else unit | |
550 | - | if ((r == r)) | |
551 | - | then if ((amount > stakedByUser)) | |
552 | - | then throw(((((((("passed amount=" + toString(amount)) + " is greater than available=") + toString(stakedByUser)) + ". lpAssetId=") + lpAssetIdStr) + ". stakedByUserKEY=") + stakedByUserKEY)) | |
553 | - | else (([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE) ++ listActions) | |
554 | - | else throw("Strict value is not equal to itself.") | |
555 | - | } | |
571 | + | then i.originCaller | |
572 | + | else i.caller | |
573 | + | let lpAssetRecipientAddress = i.caller | |
574 | + | unstakeActions(i, lpAssetId, poolAddress, userAddress, lpAssetRecipientAddress, amount) | |
575 | + | } | |
576 | + | ||
577 | + | ||
578 | + | ||
579 | + | @Callable(i) | |
580 | + | func unstakeINTERNAL (lpAssetId,amount,userAddress,lpAssetRecipientAddress) = { | |
581 | + | let lpAssetIdStr = toBase58String(lpAssetId) | |
582 | + | let poolAddress = addressFromStringValue(valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))) | |
583 | + | let checkCaller = if ((i.caller == poolAddress)) | |
584 | + | then true | |
585 | + | else permissionDeniedError | |
586 | + | if ((checkCaller == checkCaller)) | |
587 | + | then unstakeActions(i, lpAssetId, poolAddress, Address(userAddress), Address(lpAssetRecipientAddress), amount) | |
556 | 588 | else throw("Strict value is not equal to itself.") | |
557 | 589 | } | |
558 | 590 | ||
559 | 591 | ||
560 | 592 | ||
561 | 593 | @Callable(i) | |
562 | 594 | func claimWx (lpAssetIdStr) = { | |
563 | 595 | let userAddressStr = toString(i.caller) | |
564 | - | let result = invoke(this, "claimWxINTERNAL", [lpAssetIdStr, userAddressStr], nil) | |
596 | + | let throwIfNothingToClaim = true | |
597 | + | let result = invoke(this, "claimWxINTERNAL", [lpAssetIdStr, userAddressStr, throwIfNothingToClaim], nil) | |
565 | 598 | $Tuple2(nil, result) | |
566 | 599 | } | |
567 | 600 | ||
568 | 601 | ||
569 | 602 | ||
570 | 603 | @Callable(i) | |
571 | - | func claimWxINTERNAL (lpAssetIdStr,userAddressStr) = { | |
604 | + | func claimWxDoNotThrow (lpAssetIdStr) = { | |
605 | + | let userAddressStr = toString(i.caller) | |
606 | + | let throwIfNothingToClaim = false | |
607 | + | let result = invoke(this, "claimWxINTERNAL", [lpAssetIdStr, userAddressStr, throwIfNothingToClaim], nil) | |
608 | + | $Tuple2(nil, result) | |
609 | + | } | |
610 | + | ||
611 | + | ||
612 | + | ||
613 | + | @Callable(i) | |
614 | + | func claimWxINTERNAL (lpAssetIdStr,userAddressStr,throwIfNothingToClaim) = { | |
572 | 615 | let checkCaller = mustThis(i) | |
573 | 616 | if ((checkCaller == checkCaller)) | |
574 | 617 | then { | |
575 | 618 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), "claimWxINTERNAL: invalid user address") | |
576 | 619 | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
577 | 620 | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
578 | 621 | let claimedTotalKEY = keyClaimedTotal(lpAssetIdStr) | |
579 | 622 | let claimedByUserMinRewardKEY = keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr) | |
580 | 623 | let claimedByUserBoostRewardKEY = keyClaimedByUserBoostReward(lpAssetIdStr, userAddressStr) | |
581 | 624 | let claimedByUser = getBigIntFromStringOrZero(this, claimedByUserKEY) | |
582 | 625 | let claimedByUserMinReward = getBigIntFromStringOrZero(this, claimedByUserMinRewardKEY) | |
583 | 626 | let claimedByUserBoostReward = getBigIntFromStringOrZero(this, claimedByUserBoostRewardKEY) | |
584 | 627 | let claimedTotal = getBigIntFromStringOrZero(this, claimedTotalKEY) | |
585 | - | let $ | |
586 | - | let wxToClaimUserNew = $ | |
587 | - | let integralSTATE = $ | |
588 | - | let debug = $ | |
628 | + | let $t02510925221 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
629 | + | let wxToClaimUserNew = $t02510925221._1 | |
630 | + | let integralSTATE = $t02510925221._2 | |
631 | + | let debug = $t02510925221._3 | |
589 | 632 | let availableToClaim = max([(wxToClaimUserNew - claimedByUserMinReward), zeroBigInt]) | |
590 | 633 | if ((zeroBigInt >= availableToClaim)) | |
591 | - | then throw("nothing to claim") | |
634 | + | then if (throwIfNothingToClaim) | |
635 | + | then throw("nothing to claim") | |
636 | + | else $Tuple2(nil, 0) | |
592 | 637 | else { | |
593 | 638 | let wxAmountBoostTotal = max([asInt(asAnyList(invoke(boostingContract, "claimWxBoost", [lpAssetIdStr, userAddressStr], nil))[0]), 0]) | |
594 | 639 | let minRewardPart = availableToClaim | |
595 | 640 | let boostRewardPart = min([(minRewardPart * toBigInt((boostCoeff - 1))), toBigInt(wxAmountBoostTotal)]) | |
641 | + | let totalReward = (minRewardPart + boostRewardPart) | |
596 | 642 | let wxAssetId = asByteVector(asAnyList(invoke(emissionContract, "emit", [toInt(minRewardPart)], nil))[0]) | |
597 | 643 | let emitBoost = asAnyList(invoke(emissionContract, "emit", [toInt(boostRewardPart)], nil)) | |
598 | 644 | if ((emitBoost == emitBoost)) | |
599 | 645 | then { | |
600 | 646 | let claimedByUserValue = ((claimedByUser + minRewardPart) + boostRewardPart) | |
601 | 647 | let claimedByUserMinRewardPlusPart = (claimedByUserMinReward + minRewardPart) | |
602 | 648 | let claimedByUserBoostRewardPlusBoostRewardPart = (claimedByUserBoostReward + boostRewardPart) | |
603 | 649 | let claimedTotalPlusAvailableToClaim = (claimedTotal + availableToClaim) | |
604 | - | [StringEntry(claimedByUserKEY, toString(claimedByUserValue)), StringEntry(claimedByUserMinRewardKEY, toString(claimedByUserMinRewardPlusPart)), StringEntry(claimedByUserBoostRewardKEY, toString(claimedByUserBoostRewardPlusBoostRewardPart)), StringEntry(claimedTotalKEY, toString(claimedTotalPlusAvailableToClaim)), ScriptTransfer(userAddress, toInt(minRewardPart), wxAssetId), ScriptTransfer(userAddress, toInt(boostRewardPart), wxAssetId), OperationHistoryEntry("claim", userAddressStr, lpAssetIdStr, toInt(availableToClaim), i.transactionId)] | |
650 | + | $Tuple2([StringEntry(claimedByUserKEY, toString(claimedByUserValue)), StringEntry(claimedByUserMinRewardKEY, toString(claimedByUserMinRewardPlusPart)), StringEntry(claimedByUserBoostRewardKEY, toString(claimedByUserBoostRewardPlusBoostRewardPart)), StringEntry(claimedTotalKEY, toString(claimedTotalPlusAvailableToClaim)), ScriptTransfer(userAddress, toInt(minRewardPart), wxAssetId), ScriptTransfer(userAddress, toInt(boostRewardPart), wxAssetId), OperationHistoryEntry("claim", userAddressStr, lpAssetIdStr, toInt(availableToClaim), i.transactionId)], toInt(totalReward)) | |
605 | 651 | } | |
606 | 652 | else throw("Strict value is not equal to itself.") | |
607 | 653 | } | |
608 | 654 | } | |
609 | 655 | else throw("Strict value is not equal to itself.") | |
610 | 656 | } | |
611 | 657 | ||
612 | 658 | ||
613 | 659 | ||
614 | 660 | @Callable(i) | |
615 | 661 | func claimWxBulkInternalREADONLY (currentIter,lpAssetIds,userAddressStr,resAcc) = if ((currentIter == size(lpAssetIds))) | |
616 | 662 | then $Tuple2(nil, resAcc) | |
617 | 663 | else { | |
618 | 664 | let lpAssetId = lpAssetIds[currentIter] | |
619 | 665 | let info = split({ | |
620 | 666 | let @ = invoke(this, "claimWxREADONLY", [lpAssetId, userAddressStr], nil) | |
621 | 667 | if ($isInstanceOf(@, "String")) | |
622 | 668 | then @ | |
623 | 669 | else throw(($getType(@) + " couldn't be cast to String")) | |
624 | 670 | }, SEP) | |
625 | 671 | let unclaimed = info[3] | |
626 | 672 | let claimed = info[4] | |
627 | 673 | let userVoteFinalized = { | |
628 | 674 | let @ = invoke(boostingContract, "getUserVoteFinalizedREADONLY", [lpAssetId, userAddressStr], nil) | |
629 | 675 | if ($isInstanceOf(@, "Int")) | |
630 | 676 | then @ | |
631 | 677 | else throw(($getType(@) + " couldn't be cast to Int")) | |
632 | 678 | } | |
633 | 679 | let res = (resAcc :+ makeString(["%d%d%d", unclaimed, claimed, toString(userVoteFinalized)], SEP)) | |
634 | 680 | let inv = { | |
635 | 681 | let @ = invoke(this, "claimWxBulkInternalREADONLY", [(currentIter + 1), lpAssetIds, userAddressStr, res], nil) | |
636 | 682 | if ($isInstanceOf(@, "List[Any]")) | |
637 | 683 | then @ | |
638 | 684 | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
639 | 685 | } | |
640 | 686 | if ((inv == inv)) | |
641 | 687 | then $Tuple2(nil, inv) | |
642 | 688 | else throw("Strict value is not equal to itself.") | |
643 | 689 | } | |
644 | 690 | ||
645 | 691 | ||
646 | 692 | ||
647 | 693 | @Callable(i) | |
648 | 694 | func claimWxBulkREADONLY (lpAssetIds,userAddressStr) = { | |
649 | 695 | let res = invoke(this, "claimWxBulkInternalREADONLY", [0, lpAssetIds, userAddressStr, nil], nil) | |
650 | 696 | $Tuple2(nil, res) | |
651 | 697 | } | |
652 | 698 | ||
653 | 699 | ||
654 | 700 | ||
655 | 701 | @Callable(i) | |
656 | 702 | func claimWxREADONLY (lpAssetIdStr,userAddressStr) = { | |
657 | 703 | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) | |
658 | 704 | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) | |
659 | 705 | let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr) | |
660 | 706 | let claimedByUserMinRewardKEY = keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr) | |
661 | 707 | let stakedByUser = readStaked(stakedByUserKEY) | |
662 | 708 | let stakedTotal = readStaked(stakedTotalKEY) | |
663 | 709 | let claimedByUser = getBigIntFromStringOrZero(this, claimedByUserKEY) | |
664 | 710 | let claimedByUserMinReward = getBigIntFromStringOrZero(this, claimedByUserMinRewardKEY) | |
665 | 711 | let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)) | |
666 | 712 | let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
667 | 713 | let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent()) | |
668 | 714 | let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock()) | |
669 | 715 | let passedBlocks = if ((emissionStartBlock > height)) | |
670 | 716 | then 0 | |
671 | 717 | else (height - emissionStartBlock) | |
672 | 718 | let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, POOLWEIGHTMULT) | |
673 | 719 | let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal) | |
674 | - | let $ | |
675 | - | let wxToClaimUserNew = $ | |
676 | - | let integralSTATE = $ | |
677 | - | let debug = $ | |
720 | + | let $t02926929381 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0) | |
721 | + | let wxToClaimUserNew = $t02926929381._1 | |
722 | + | let integralSTATE = $t02926929381._2 | |
723 | + | let debug = $t02926929381._3 | |
678 | 724 | let availableToClaim = max([(wxToClaimUserNew - claimedByUserMinReward), zeroBigInt]) | |
679 | 725 | let boostInvResult = asAnyList(invoke(boostingContract, "claimWxBoostREADONLY", [lpAssetIdStr, userAddressStr], nil)) | |
680 | 726 | let wxAmountBoostTotal = max([asInt(boostInvResult[0]), 0]) | |
681 | 727 | let boostDebug = asString(boostInvResult[1]) | |
682 | 728 | let minRewardPart = availableToClaim | |
683 | 729 | let boostRewardPart = min([(minRewardPart * toBigInt((boostCoeff - 1))), toBigInt(wxAmountBoostTotal)]) | |
684 | 730 | let totalReward = (minRewardPart + boostRewardPart) | |
685 | 731 | $Tuple2(nil, makeString(["%s%s%d%d%d%d%s", lpAssetIdStr, userAddressStr, toString(totalReward), toString(claimedByUser), toString(minRewardPart), toString(boostRewardPart), "soon"], SEP)) | |
732 | + | } | |
733 | + | ||
734 | + | ||
735 | + | ||
736 | + | @Callable(i) | |
737 | + | func stakedByUserREADONLY (lpAssetIdStr,userAddressStr) = { | |
738 | + | let stakedByUser = valueOrElse(getInteger(keyStakedByUser(userAddressStr, lpAssetIdStr)), 0) | |
739 | + | $Tuple2(nil, stakedByUser) | |
686 | 740 | } | |
687 | 741 | ||
688 | 742 | ||
689 | 743 | ||
690 | 744 | @Callable(i) | |
691 | 745 | func usersListTraversal (lpAssetId) = { | |
692 | 746 | let checkCaller = if ((toBase58String(i.caller.bytes) == valueOrElse(getString(this, keyVotingEmissionContract()), ""))) | |
693 | 747 | then true | |
694 | 748 | else mustManager(i) | |
695 | 749 | if ((checkCaller == checkCaller)) | |
696 | 750 | then { | |
697 | 751 | let listName = getUsersListName(lpAssetId) | |
698 | 752 | let userOrUnit = getString(keyNextUser(lpAssetId)) | |
699 | 753 | let headOrUnit = getString(keyListHead(listName)) | |
700 | 754 | match userOrUnit { | |
701 | 755 | case _: Unit => | |
702 | 756 | match headOrUnit { | |
703 | 757 | case _: Unit => | |
704 | 758 | $Tuple2(nil, false) | |
705 | 759 | case head: String => | |
706 | 760 | $Tuple2([StringEntry(keyNextUser(lpAssetId), head)], true) | |
707 | 761 | case _ => | |
708 | 762 | throw("Match error") | |
709 | 763 | } | |
710 | 764 | case userAddress: String => | |
711 | 765 | let claimedByUserMinReward = getBigIntFromStringOrZero(this, keyClaimedByUserMinReward(lpAssetId, userAddress)) | |
712 | 766 | let poolAddress = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetId)) | |
713 | 767 | let wxToClaimUserNew = refreshINTEGRALS(lpAssetId, userAddress, poolAddress, 0)._1 | |
714 | 768 | let availableToClaim = (wxToClaimUserNew - claimedByUserMinReward) | |
769 | + | let throwIfNothingToClaim = true | |
715 | 770 | let r = if ((availableToClaim > zeroBigInt)) | |
716 | - | then invoke(this, "claimWxINTERNAL", [lpAssetId, userAddress], nil) | |
771 | + | then invoke(this, "claimWxINTERNAL", [lpAssetId, userAddress, throwIfNothingToClaim], nil) | |
717 | 772 | else unit | |
718 | 773 | if ((r == r)) | |
719 | 774 | then { | |
720 | 775 | let nextUserOrUnit = getString(keyListNext(listName, userAddress)) | |
721 | 776 | match nextUserOrUnit { | |
722 | 777 | case _: Unit => | |
723 | 778 | $Tuple2([DeleteEntry(keyNextUser(lpAssetId))], false) | |
724 | 779 | case nextUser: String => | |
725 | 780 | $Tuple2([StringEntry(keyNextUser(lpAssetId), nextUser)], true) | |
726 | 781 | case _ => | |
727 | 782 | throw("Match error") | |
728 | 783 | } | |
729 | 784 | } | |
730 | 785 | else throw("Strict value is not equal to itself.") | |
731 | 786 | case _ => | |
732 | 787 | throw("Match error") | |
733 | 788 | } | |
734 | 789 | } | |
735 | 790 | else throw("Strict value is not equal to itself.") | |
736 | 791 | } | |
737 | 792 | ||
738 | 793 | ||
739 | 794 | ||
740 | 795 | @Callable(i) | |
741 | 796 | func onModifyWeight (lpAssetIdStr,poolAddressStr) = if ((i.caller != factoryContract)) | |
742 | 797 | then throw("permissions denied") | |
743 | 798 | else { | |
744 | - | let $ | |
745 | - | let wxPerLpIntegralNew = $ | |
746 | - | let poolIntegralSTATE = $ | |
747 | - | let poolDEBUG = $ | |
799 | + | let $t03200232112 = refreshPoolINTEGRALS(lpAssetIdStr, poolAddressStr, 0) | |
800 | + | let wxPerLpIntegralNew = $t03200232112._1 | |
801 | + | let poolIntegralSTATE = $t03200232112._2 | |
802 | + | let poolDEBUG = $t03200232112._3 | |
748 | 803 | poolIntegralSTATE | |
749 | 804 | } | |
750 | 805 | ||
751 | 806 | ||
752 | 807 | @Verifier(tx) | |
753 | 808 | func verify () = { | |
754 | 809 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
755 | 810 | case pk: ByteVector => | |
756 | 811 | pk | |
757 | 812 | case _: Unit => | |
758 | 813 | tx.senderPublicKey | |
759 | 814 | case _ => | |
760 | 815 | throw("Match error") | |
761 | 816 | } | |
762 | 817 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
763 | 818 | } | |
764 | 819 |
github/deemru/w8io/026f985 90.54 ms ◑