tx · 7Xg5VveGjn4DzoFkobf35GJg1FuEvWTrv3CkV8LXiGBW 3MqjK2SfnefGxk4fiaeRHZaxg6wHAZ6tbd2: -0.03500000 Waves 2022.12.07 15:51 [2349949] smart account 3MqjK2SfnefGxk4fiaeRHZaxg6wHAZ6tbd2 > SELF 0.00000000 Waves
{ "type": 13, "id": "7Xg5VveGjn4DzoFkobf35GJg1FuEvWTrv3CkV8LXiGBW", "fee": 3500000, "feeAssetId": null, "timestamp": 1670417459551, "version": 1, "sender": "3MqjK2SfnefGxk4fiaeRHZaxg6wHAZ6tbd2", "senderPublicKey": "4eCcSEdDzsn3CVYwcVcGA3AbMH8prX8N1GVuLubC57iy", "proofs": [ "3vF1s9GP4ak43tEZaTzYsfK4DSc8oZ6BhzDhv3hD5dz2xN3F69JzLkfWyektbTjAh3acnQSLEiRXsniQQNouQZUJ" ], "script": "base64:BgLYLAgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlk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UU2V0U2NyaXB0VHJhbnNhY3Rpb24EAmVOBQJkSwQCZ0IJAPYDAQkBBXZhbHVlAQgFAmVOBnNjcmlwdAQCZ0MJANsEAQkBBXZhbHVlAQkAnQgCBQJhSgkBAmF3AAQCZ0QJAPEHAQUEdGhpcwMDCQAAAgUCZ0MFAmdCCQECIT0CBQJnRAUCZ0IHBgkA9AMDCAUCZ3gJYm9keUJ5dGVzCQCRAwIIBQJneAZwcm9vZnMAAAUCZ3oJAPQDAwgFAmd4CWJvZHlCeXRlcwkAkQMCCAUCZ3gGcHJvb2ZzAAAFAmd6WfbqsA==", "chainId": 84, "height": 2349949, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7b4xgbnYpj9bfbZyDUsZTzBBDTSYEZppqrFwaZYsLCSy Next: HtTk32K8v2AnrJz5D5bJ2SV85rj72HMHBdRYSBHYDjw5 Diff:
Old | New | Differences | |
---|---|---|---|
703 | 703 | let prId = estPut._13 | |
704 | 704 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
705 | 705 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
706 | - | let | |
707 | - | if (( | |
706 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
707 | + | if ((currentKLp == currentKLp)) | |
708 | 708 | then { | |
709 | - | let | |
710 | - | if (( | |
709 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
710 | + | if ((emitInv == emitInv)) | |
711 | 711 | then { | |
712 | - | let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity) | |
713 | - | if ((lpAssetEmission == lpAssetEmission)) | |
712 | + | let emitInvLegacy = match emitInv { | |
713 | + | case legacyFactoryContract: Address => | |
714 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
715 | + | case _ => | |
716 | + | unit | |
717 | + | } | |
718 | + | if ((emitInvLegacy == emitInvLegacy)) | |
714 | 719 | then { | |
715 | - | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
716 | - | if ((currentKLp == currentKLp)) | |
720 | + | let slippageAInv = if ((amDiff > 0)) | |
721 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
722 | + | else nil | |
723 | + | if ((slippageAInv == slippageAInv)) | |
717 | 724 | then { | |
718 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
719 | - | if ((emitInv == emitInv)) | |
725 | + | let slippagePInv = if ((prDiff > 0)) | |
726 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
727 | + | else nil | |
728 | + | if ((slippagePInv == slippagePInv)) | |
720 | 729 | then { | |
721 | - | let emitInvLegacy = match emitInv { | |
722 | - | case legacyFactoryContract: Address => | |
723 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
724 | - | case _ => | |
725 | - | unit | |
726 | - | } | |
727 | - | if ((emitInvLegacy == emitInvLegacy)) | |
730 | + | let lpTransfer = if (shouldAutoStake) | |
728 | 731 | then { | |
729 | - | let slippageAInv = if ((amDiff > 0)) | |
730 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
731 | - | else nil | |
732 | - | if ((slippageAInv == slippageAInv)) | |
733 | - | then { | |
734 | - | let slippagePInv = if ((prDiff > 0)) | |
735 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
736 | - | else nil | |
737 | - | if ((slippagePInv == slippagePInv)) | |
738 | - | then { | |
739 | - | let lpTransfer = if (shouldAutoStake) | |
740 | - | then { | |
741 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
742 | - | if ((slpStakeInv == slpStakeInv)) | |
743 | - | then nil | |
744 | - | else throw("Strict value is not equal to itself.") | |
745 | - | } | |
746 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
747 | - | let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity | |
748 | - | if ((lpAssetEmissionAfter == lpAssetEmissionAfter)) | |
749 | - | then { | |
750 | - | let $t03248232550 = refreshKLpInternal(0, 0, 0) | |
751 | - | if (($t03248232550 == $t03248232550)) | |
752 | - | then { | |
753 | - | let updatedKLp = $t03248232550._2 | |
754 | - | let refreshKLpActions = $t03248232550._1 | |
755 | - | let error = throwErr(makeString([toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentKLp), toString(updatedKLp), toString(emitLpAmt), toString(amDiff), toString(prDiff), toString(lpAssetEmission), toString(lpAssetEmissionAfter)], " ")) | |
756 | - | if ((error == error)) | |
757 | - | then { | |
758 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
759 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
760 | - | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
761 | - | else throw("Strict value is not equal to itself.") | |
762 | - | } | |
763 | - | else throw("Strict value is not equal to itself.") | |
764 | - | } | |
765 | - | else throw("Strict value is not equal to itself.") | |
766 | - | } | |
767 | - | else throw("Strict value is not equal to itself.") | |
768 | - | } | |
769 | - | else throw("Strict value is not equal to itself.") | |
770 | - | } | |
732 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
733 | + | if ((slpStakeInv == slpStakeInv)) | |
734 | + | then nil | |
735 | + | else throw("Strict value is not equal to itself.") | |
736 | + | } | |
737 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
738 | + | let $t03211432182 = refreshKLpInternal(0, 0, 0) | |
739 | + | if (($t03211432182 == $t03211432182)) | |
740 | + | then { | |
741 | + | let updatedKLp = $t03211432182._2 | |
742 | + | let refreshKLpActions = $t03211432182._1 | |
743 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
744 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
745 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
771 | 746 | else throw("Strict value is not equal to itself.") | |
772 | 747 | } | |
773 | 748 | else throw("Strict value is not equal to itself.") | |
796 | 771 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
797 | 772 | if ((currentKLp == currentKLp)) | |
798 | 773 | then { | |
799 | - | let $ | |
800 | - | let refreshKLpActions = $ | |
801 | - | let updatedKLp = $ | |
774 | + | let $t03274432809 = refreshKLpInternal(0, 0, 0) | |
775 | + | let refreshKLpActions = $t03274432809._1 | |
776 | + | let updatedKLp = $t03274432809._2 | |
802 | 777 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
803 | 778 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
804 | 779 | then (state ++ refreshKLpActions) | |
843 | 818 | else throwErr("payment asset is not supported") | |
844 | 819 | let userAddress = i.caller | |
845 | 820 | let txId = i.transactionId | |
846 | - | let $ | |
847 | - | if (($ | |
821 | + | let $t03399434146 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
822 | + | if (($t03399434146 == $t03399434146)) | |
848 | 823 | then { | |
849 | - | let paymentInAmountAsset = $ | |
850 | - | let bonus = $ | |
851 | - | let feeAmount = $ | |
852 | - | let commonState = $ | |
853 | - | let emitAmountEstimated = $ | |
824 | + | let paymentInAmountAsset = $t03399434146._5 | |
825 | + | let bonus = $t03399434146._4 | |
826 | + | let feeAmount = $t03399434146._3 | |
827 | + | let commonState = $t03399434146._2 | |
828 | + | let emitAmountEstimated = $t03399434146._1 | |
854 | 829 | let emitAmount = if (if ((minOutAmount > 0)) | |
855 | 830 | then (minOutAmount > emitAmountEstimated) | |
856 | 831 | else false) | |
870 | 845 | let sendFee = if ((feeAmount > 0)) | |
871 | 846 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
872 | 847 | else nil | |
873 | - | let $ | |
848 | + | let $t03473234929 = if ((this == feeCollectorAddress)) | |
874 | 849 | then $Tuple2(0, 0) | |
875 | 850 | else if (paymentInAmountAsset) | |
876 | 851 | then $Tuple2(-(feeAmount), 0) | |
877 | 852 | else $Tuple2(0, -(feeAmount)) | |
878 | - | let amountAssetBalanceDelta = $ | |
879 | - | let priceAssetBalanceDelta = $ | |
880 | - | let $ | |
881 | - | let refreshKLpActions = $ | |
882 | - | let updatedKLp = $ | |
853 | + | let amountAssetBalanceDelta = $t03473234929._1 | |
854 | + | let priceAssetBalanceDelta = $t03473234929._2 | |
855 | + | let $t03493235040 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
856 | + | let refreshKLpActions = $t03493235040._1 | |
857 | + | let updatedKLp = $t03493235040._2 | |
883 | 858 | let kLp = value(getString(keyKLp)) | |
884 | 859 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
885 | 860 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
897 | 872 | ||
898 | 873 | @Callable(i) | |
899 | 874 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
900 | - | let $ | |
901 | - | let emitAmountEstimated = $ | |
902 | - | let commonState = $ | |
903 | - | let feeAmount = $ | |
904 | - | let bonus = $ | |
905 | - | let paymentInAmountAsset = $ | |
875 | + | let $t03534635503 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
876 | + | let emitAmountEstimated = $t03534635503._1 | |
877 | + | let commonState = $t03534635503._2 | |
878 | + | let feeAmount = $t03534635503._3 | |
879 | + | let bonus = $t03534635503._4 | |
880 | + | let paymentInAmountAsset = $t03534635503._5 | |
906 | 881 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
907 | 882 | } | |
908 | 883 | ||
937 | 912 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount)) | |
938 | 913 | let userAddress = i.caller | |
939 | 914 | let txId = i.transactionId | |
940 | - | let $ | |
941 | - | if (($ | |
915 | + | let $t03639736550 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
916 | + | if (($t03639736550 == $t03639736550)) | |
942 | 917 | then { | |
943 | - | let outInAmountAsset = $ | |
944 | - | let bonus = $ | |
945 | - | let feeAmount = $ | |
946 | - | let commonState = $ | |
947 | - | let amountEstimated = $ | |
918 | + | let outInAmountAsset = $t03639736550._5 | |
919 | + | let bonus = $t03639736550._4 | |
920 | + | let feeAmount = $t03639736550._3 | |
921 | + | let commonState = $t03639736550._2 | |
922 | + | let amountEstimated = $t03639736550._1 | |
948 | 923 | let amount = if (if ((minOutAmount > 0)) | |
949 | 924 | then (minOutAmount > amountEstimated) | |
950 | 925 | else false) | |
957 | 932 | let sendFee = if ((feeAmount > 0)) | |
958 | 933 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
959 | 934 | else nil | |
960 | - | let $ | |
935 | + | let $t03705037297 = { | |
961 | 936 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
962 | 937 | then 0 | |
963 | 938 | else feeAmount | |
965 | 940 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
966 | 941 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
967 | 942 | } | |
968 | - | let amountAssetBalanceDelta = $ | |
969 | - | let priceAssetBalanceDelta = $ | |
970 | - | let $ | |
971 | - | let refreshKLpActions = $ | |
972 | - | let updatedKLp = $ | |
943 | + | let amountAssetBalanceDelta = $t03705037297._1 | |
944 | + | let priceAssetBalanceDelta = $t03705037297._2 | |
945 | + | let $t03730037408 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
946 | + | let refreshKLpActions = $t03730037408._1 | |
947 | + | let updatedKLp = $t03730037408._2 | |
973 | 948 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
974 | 949 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
975 | 950 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
986 | 961 | ||
987 | 962 | @Callable(i) | |
988 | 963 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
989 | - | let $ | |
990 | - | let amountEstimated = $ | |
991 | - | let commonState = $ | |
992 | - | let feeAmount = $ | |
993 | - | let bonus = $ | |
994 | - | let outInAmountAsset = $ | |
964 | + | let $t03766537821 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
965 | + | let amountEstimated = $t03766537821._1 | |
966 | + | let commonState = $t03766537821._2 | |
967 | + | let feeAmount = $t03766537821._3 | |
968 | + | let bonus = $t03766537821._4 | |
969 | + | let outInAmountAsset = $t03766537821._5 | |
995 | 970 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
996 | 971 | } | |
997 | 972 | ||
1026 | 1001 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1027 | 1002 | if ((unstakeInv == unstakeInv)) | |
1028 | 1003 | then { | |
1029 | - | let $ | |
1030 | - | if (($ | |
1004 | + | let $t03872338874 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1005 | + | if (($t03872338874 == $t03872338874)) | |
1031 | 1006 | then { | |
1032 | - | let outInAmountAsset = $ | |
1033 | - | let bonus = $ | |
1034 | - | let feeAmount = $ | |
1035 | - | let commonState = $ | |
1036 | - | let amountEstimated = $ | |
1007 | + | let outInAmountAsset = $t03872338874._5 | |
1008 | + | let bonus = $t03872338874._4 | |
1009 | + | let feeAmount = $t03872338874._3 | |
1010 | + | let commonState = $t03872338874._2 | |
1011 | + | let amountEstimated = $t03872338874._1 | |
1037 | 1012 | let amount = if (if ((minOutAmount > 0)) | |
1038 | 1013 | then (minOutAmount > amountEstimated) | |
1039 | 1014 | else false) | |
1046 | 1021 | let sendFee = if ((feeAmount > 0)) | |
1047 | 1022 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1048 | 1023 | else nil | |
1049 | - | let $ | |
1024 | + | let $t03936939616 = { | |
1050 | 1025 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1051 | 1026 | then 0 | |
1052 | 1027 | else feeAmount | |
1054 | 1029 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1055 | 1030 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1056 | 1031 | } | |
1057 | - | let amountAssetBalanceDelta = $ | |
1058 | - | let priceAssetBalanceDelta = $ | |
1059 | - | let $ | |
1060 | - | let refreshKLpActions = $ | |
1061 | - | let updatedKLp = $ | |
1032 | + | let amountAssetBalanceDelta = $t03936939616._1 | |
1033 | + | let priceAssetBalanceDelta = $t03936939616._2 | |
1034 | + | let $t03961939727 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1035 | + | let refreshKLpActions = $t03961939727._1 | |
1036 | + | let updatedKLp = $t03961939727._2 | |
1062 | 1037 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1063 | 1038 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1064 | 1039 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1087 | 1062 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1088 | 1063 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1089 | 1064 | then { | |
1090 | - | let $ | |
1091 | - | let refreshKLpActions = $ | |
1092 | - | let updatedKLp = $ | |
1065 | + | let $t04067540757 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1066 | + | let refreshKLpActions = $t04067540757._1 | |
1067 | + | let updatedKLp = $t04067540757._2 | |
1093 | 1068 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1094 | 1069 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1095 | 1070 | then (state ++ refreshKLpActions) | |
1117 | 1092 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1118 | 1093 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1119 | 1094 | then { | |
1120 | - | let $ | |
1121 | - | let refreshKLpActions = $ | |
1122 | - | let updatedKLp = $ | |
1095 | + | let $t04170841789 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1096 | + | let refreshKLpActions = $t04170841789._1 | |
1097 | + | let updatedKLp = $t04170841789._2 | |
1123 | 1098 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1124 | 1099 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1125 | 1100 | then (state ++ refreshKLpActions) | |
1159 | 1134 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1160 | 1135 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1161 | 1136 | then { | |
1162 | - | let $ | |
1163 | - | let refreshKLpActions = $ | |
1164 | - | let updatedKLp = $ | |
1137 | + | let $t04291242993 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1138 | + | let refreshKLpActions = $t04291242993._1 | |
1139 | + | let updatedKLp = $t04291242993._2 | |
1165 | 1140 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1166 | 1141 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1167 | 1142 | then (state ++ refreshKLpActions) | |
1208 | 1183 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1209 | 1184 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1210 | 1185 | then { | |
1211 | - | let $ | |
1212 | - | let refreshKLpActions = $ | |
1213 | - | let updatedKLp = $ | |
1186 | + | let $t04428544366 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1187 | + | let refreshKLpActions = $t04428544366._1 | |
1188 | + | let updatedKLp = $t04428544366._2 | |
1214 | 1189 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1215 | 1190 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1216 | 1191 | then (state ++ refreshKLpActions) | |
1243 | 1218 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1244 | 1219 | then { | |
1245 | 1220 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1246 | - | let $ | |
1247 | - | let kLpUpdateActions = $ | |
1248 | - | let updatedKLp = $ | |
1221 | + | let $t04555345617 = refreshKLpInternal(0, 0, 0) | |
1222 | + | let kLpUpdateActions = $t04555345617._1 | |
1223 | + | let updatedKLp = $t04555345617._2 | |
1249 | 1224 | let actions = if ((kLp != updatedKLp)) | |
1250 | 1225 | then kLpUpdateActions | |
1251 | 1226 | else throwErr("nothing to refresh") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lPdecimals = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale8BigInt = toBigInt(100000000) | |
9 | 9 | ||
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big0 = toBigInt(0) | |
15 | 15 | ||
16 | 16 | let big1 = toBigInt(1) | |
17 | 17 | ||
18 | 18 | let big2 = toBigInt(2) | |
19 | 19 | ||
20 | 20 | let wavesString = "WAVES" | |
21 | 21 | ||
22 | 22 | let SEP = "__" | |
23 | 23 | ||
24 | 24 | let PoolActive = 1 | |
25 | 25 | ||
26 | 26 | let PoolPutDisabled = 2 | |
27 | 27 | ||
28 | 28 | let PoolMatcherDisabled = 3 | |
29 | 29 | ||
30 | 30 | let PoolShutdown = 4 | |
31 | 31 | ||
32 | 32 | let idxPoolAddress = 1 | |
33 | 33 | ||
34 | 34 | let idxPoolStatus = 2 | |
35 | 35 | ||
36 | 36 | let idxPoolLPAssetId = 3 | |
37 | 37 | ||
38 | 38 | let idxAmtAssetId = 4 | |
39 | 39 | ||
40 | 40 | let idxPriceAssetId = 5 | |
41 | 41 | ||
42 | 42 | let idxAmtAssetDcm = 6 | |
43 | 43 | ||
44 | 44 | let idxPriceAssetDcm = 7 | |
45 | 45 | ||
46 | 46 | let idxIAmtAssetId = 8 | |
47 | 47 | ||
48 | 48 | let idxIPriceAssetId = 9 | |
49 | 49 | ||
50 | 50 | let idxLPAssetDcm = 10 | |
51 | 51 | ||
52 | 52 | let idxPoolAmtAssetAmt = 1 | |
53 | 53 | ||
54 | 54 | let idxPoolPriceAssetAmt = 2 | |
55 | 55 | ||
56 | 56 | let idxPoolLPAssetAmt = 3 | |
57 | 57 | ||
58 | 58 | let idxFactoryStakingContract = 1 | |
59 | 59 | ||
60 | 60 | let idxFactorySlippageContract = 7 | |
61 | 61 | ||
62 | 62 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func abs (val) = if ((0 > val)) | |
72 | 72 | then -(val) | |
73 | 73 | else val | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func absBigInt (val) = if ((zeroBigInt > val)) | |
77 | 77 | then -(val) | |
78 | 78 | else val | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func fc () = "%s__factoryContract" | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func mpk () = "%s__managerPublicKey" | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func pmpk () = "%s__pendingManagerPublicKey" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func pl () = "%s%s__price__last" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func aa () = "%s__amountAsset" | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pa () = "%s__priceAsset" | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | let keyFee = "%s__fee" | |
109 | 109 | ||
110 | 110 | let feeDefault = fraction(10, scale8, 10000) | |
111 | 111 | ||
112 | 112 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
113 | 113 | ||
114 | 114 | let keyKLp = makeString(["%s", "kLp"], SEP) | |
115 | 115 | ||
116 | 116 | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
117 | 117 | ||
118 | 118 | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
119 | 119 | ||
120 | 120 | let kLpRefreshDelayDefault = 30 | |
121 | 121 | ||
122 | 122 | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
123 | 123 | ||
124 | 124 | func keyFactoryConfig () = "%s__factoryConfig" | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
131 | 131 | ||
132 | 132 | ||
133 | 133 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func keyAllPoolsShutdown () = "%s__shutdown" | |
140 | 140 | ||
141 | 141 | ||
142 | 142 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
143 | 143 | ||
144 | 144 | ||
145 | 145 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
146 | 146 | ||
147 | 147 | ||
148 | 148 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
149 | 149 | ||
150 | 150 | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
151 | 151 | ||
152 | 152 | ||
153 | 153 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
154 | 154 | ||
155 | 155 | ||
156 | 156 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
157 | 157 | ||
158 | 158 | ||
159 | 159 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
160 | 160 | ||
161 | 161 | ||
162 | 162 | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
163 | 163 | ||
164 | 164 | ||
165 | 165 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
166 | 166 | ||
167 | 167 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
168 | 168 | ||
169 | 169 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
170 | 170 | ||
171 | 171 | ||
172 | 172 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
173 | 173 | ||
174 | 174 | ||
175 | 175 | func getPoolConfig () = { | |
176 | 176 | let amtAsset = getStringOrFail(this, aa()) | |
177 | 177 | let priceAsset = getStringOrFail(this, pa()) | |
178 | 178 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
179 | 179 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
180 | 180 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
181 | 181 | } | |
182 | 182 | ||
183 | 183 | ||
184 | 184 | func parseAssetId (input) = if ((input == wavesString)) | |
185 | 185 | then unit | |
186 | 186 | else fromBase58String(input) | |
187 | 187 | ||
188 | 188 | ||
189 | 189 | func assetIdToString (input) = if ((input == unit)) | |
190 | 190 | then wavesString | |
191 | 191 | else toBase58String(value(input)) | |
192 | 192 | ||
193 | 193 | ||
194 | 194 | func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolStatus]), fromBase58String(poolConfig[idxPoolLPAssetId]), parseAssetId(poolConfig[idxAmtAssetId]), parseAssetId(poolConfig[idxPriceAssetId]), parseIntValue(poolConfig[idxAmtAssetDcm]), parseIntValue(poolConfig[idxPriceAssetDcm])) | |
195 | 195 | ||
196 | 196 | ||
197 | 197 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
198 | 198 | ||
199 | 199 | let $t079158081 = poolConfigParsed | |
200 | 200 | ||
201 | 201 | let cfgPoolAddress = $t079158081._1 | |
202 | 202 | ||
203 | 203 | let cfgPoolStatus = $t079158081._2 | |
204 | 204 | ||
205 | 205 | let cfgLpAssetId = $t079158081._3 | |
206 | 206 | ||
207 | 207 | let cfgAmountAssetId = $t079158081._4 | |
208 | 208 | ||
209 | 209 | let cfgPriceAssetId = $t079158081._5 | |
210 | 210 | ||
211 | 211 | let cfgAmountAssetDecimals = $t079158081._6 | |
212 | 212 | ||
213 | 213 | let cfgPriceAssetDecimals = $t079158081._7 | |
214 | 214 | ||
215 | 215 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
216 | 216 | ||
217 | 217 | ||
218 | 218 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
219 | 219 | ||
220 | 220 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
221 | 221 | ||
222 | 222 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP) | |
223 | 223 | ||
224 | 224 | ||
225 | 225 | func dataGetActionInfo (outAmtAssetAmt,outPriceAssetAmt,inLpAmt,price,txHeight,txTimestamp) = makeString(["%d%d%d%d%d%d", toString(outAmtAssetAmt), toString(outPriceAssetAmt), toString(inLpAmt), toString(price), toString(txHeight), toString(txTimestamp)], SEP) | |
226 | 226 | ||
227 | 227 | ||
228 | 228 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
229 | 229 | then wavesBalance(this).available | |
230 | 230 | else assetBalance(this, fromBase58String(assetId)) | |
231 | 231 | ||
232 | 232 | ||
233 | 233 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
234 | 234 | ||
235 | 235 | ||
236 | 236 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
237 | 237 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
238 | 238 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
239 | 239 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
240 | 240 | } | |
241 | 241 | ||
242 | 242 | ||
243 | 243 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
244 | 244 | let cfg = getPoolConfig() | |
245 | 245 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
246 | 246 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
247 | 247 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
248 | 248 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
249 | 249 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
250 | 250 | let lpAmtX18 = toX18(lpAmt, scale8) | |
251 | 251 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
252 | 252 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
253 | 253 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
254 | 254 | } | |
255 | 255 | ||
256 | 256 | ||
257 | 257 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
258 | 258 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
259 | 259 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
260 | 260 | } | |
261 | 261 | ||
262 | 262 | ||
263 | 263 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
264 | 264 | let cfg = getPoolConfig() | |
265 | 265 | let lpAssetId = cfg[idxPoolLPAssetId] | |
266 | 266 | let amAssetId = cfg[idxAmtAssetId] | |
267 | 267 | let prAssetId = cfg[idxPriceAssetId] | |
268 | 268 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
269 | 269 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
270 | 270 | let poolStatus = cfg[idxPoolStatus] | |
271 | 271 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
272 | 272 | if ((lpAssetId != pmtAssetId)) | |
273 | 273 | then throw("Invalid asset passed.") | |
274 | 274 | else { | |
275 | 275 | let amBalance = getAccBalance(amAssetId) | |
276 | 276 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
277 | 277 | let prBalance = getAccBalance(prAssetId) | |
278 | 278 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
279 | 279 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
280 | 280 | let curPrice = fromX18(curPriceX18, scale8) | |
281 | 281 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
282 | 282 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
283 | 283 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
284 | 284 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
285 | 285 | let outAmAmt = fromX18(outAmAmtX18, amAssetDcm) | |
286 | 286 | let outPrAmt = fromX18(outPrAmtX18, prAssetDcm) | |
287 | 287 | let state = if ((txId58 == "")) | |
288 | 288 | then nil | |
289 | 289 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
290 | 290 | then unit | |
291 | 291 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
292 | 292 | then unit | |
293 | 293 | else fromBase58String(prAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
294 | 294 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
295 | 295 | } | |
296 | 296 | } | |
297 | 297 | ||
298 | 298 | ||
299 | 299 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
300 | 300 | let cfg = getPoolConfig() | |
301 | 301 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
302 | 302 | let amAssetIdStr = cfg[idxAmtAssetId] | |
303 | 303 | let prAssetIdStr = cfg[idxPriceAssetId] | |
304 | 304 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
305 | 305 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
306 | 306 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
307 | 307 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
308 | 308 | let poolStatus = cfg[idxPoolStatus] | |
309 | 309 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
310 | 310 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
311 | 311 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
312 | 312 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
313 | 313 | then true | |
314 | 314 | else (prAssetIdStr != inPrAssetIdStr)) | |
315 | 315 | then throw("Invalid amt or price asset passed.") | |
316 | 316 | else { | |
317 | 317 | let amBalance = if (isEvaluate) | |
318 | 318 | then getAccBalance(amAssetIdStr) | |
319 | 319 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
320 | 320 | let prBalance = if (isEvaluate) | |
321 | 321 | then getAccBalance(prAssetIdStr) | |
322 | 322 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
323 | 323 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
324 | 324 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
325 | 325 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
326 | 326 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
327 | 327 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
328 | 328 | let res = if ((lpEmission == 0)) | |
329 | 329 | then { | |
330 | 330 | let curPriceX18 = zeroBigInt | |
331 | 331 | let slippageX18 = zeroBigInt | |
332 | 332 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
333 | 333 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
334 | 334 | } | |
335 | 335 | else { | |
336 | 336 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
337 | 337 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
338 | 338 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
339 | 339 | if (if ((curPriceX18 != zeroBigInt)) | |
340 | 340 | then (slippageX18 > slippageToleranceX18) | |
341 | 341 | else false) | |
342 | 342 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
343 | 343 | else { | |
344 | 344 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
345 | 345 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
346 | 346 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
347 | 347 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
348 | 348 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
349 | 349 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
350 | 350 | let expAmtAssetAmtX18 = expectedAmts._1 | |
351 | 351 | let expPriceAssetAmtX18 = expectedAmts._2 | |
352 | 352 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
353 | 353 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18) | |
354 | 354 | } | |
355 | 355 | } | |
356 | 356 | let calcLpAmt = res._1 | |
357 | 357 | let calcAmAssetPmt = res._2 | |
358 | 358 | let calcPrAssetPmt = res._3 | |
359 | 359 | let curPrice = fromX18(res._4, scale8) | |
360 | 360 | let slippageCalc = fromX18(res._5, scale8) | |
361 | 361 | if ((0 >= calcLpAmt)) | |
362 | 362 | then throw("Invalid calculations. LP calculated is less than zero.") | |
363 | 363 | else { | |
364 | 364 | let emitLpAmt = if (!(emitLp)) | |
365 | 365 | then 0 | |
366 | 366 | else calcLpAmt | |
367 | 367 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
368 | 368 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
369 | 369 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(calcAmAssetPmt, calcPrAssetPmt, emitLpAmt, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
370 | 370 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
371 | 371 | } | |
372 | 372 | } | |
373 | 373 | } | |
374 | 374 | ||
375 | 375 | ||
376 | 376 | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
377 | 377 | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 12, DOWN), big1, lpEmission) | |
378 | 378 | if ((lpEmission == big0)) | |
379 | 379 | then big0 | |
380 | 380 | else updatedKLp | |
381 | 381 | } | |
382 | 382 | ||
383 | 383 | ||
384 | 384 | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
385 | 385 | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
386 | 386 | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
387 | 387 | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
388 | 388 | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
389 | 389 | currentKLp | |
390 | 390 | } | |
391 | 391 | ||
392 | 392 | ||
393 | 393 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
394 | 394 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
395 | 395 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
396 | 396 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
397 | 397 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
398 | 398 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
399 | 399 | $Tuple2(actions, updatedKLp) | |
400 | 400 | } | |
401 | 401 | ||
402 | 402 | ||
403 | 403 | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
404 | 404 | then true | |
405 | 405 | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
406 | 406 | ||
407 | 407 | ||
408 | 408 | func validateMatcherOrderAllowed (order) = { | |
409 | 409 | let amountAssetAmount = order.amount | |
410 | 410 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
411 | 411 | let $t02034120553 = if ((order.orderType == Buy)) | |
412 | 412 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
413 | 413 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
414 | 414 | let amountAssetBalanceDelta = $t02034120553._1 | |
415 | 415 | let priceAssetBalanceDelta = $t02034120553._2 | |
416 | 416 | if (if (if (isGlobalShutdown()) | |
417 | 417 | then true | |
418 | 418 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
419 | 419 | then true | |
420 | 420 | else (cfgPoolStatus == PoolShutdown)) | |
421 | 421 | then throw("Exchange operations disabled") | |
422 | 422 | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
423 | 423 | then true | |
424 | 424 | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
425 | 425 | then throw("Wrong order assets.") | |
426 | 426 | else { | |
427 | 427 | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
428 | 428 | let $t02102421124 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
429 | 429 | let unusedActions = $t02102421124._1 | |
430 | 430 | let kLpNew = $t02102421124._2 | |
431 | 431 | let isOrderValid = (kLpNew >= kLp) | |
432 | 432 | isOrderValid | |
433 | 433 | } | |
434 | 434 | } | |
435 | 435 | ||
436 | 436 | ||
437 | 437 | func commonGet (i) = if ((size(i.payments) != 1)) | |
438 | 438 | then throw("exactly 1 payment is expected") | |
439 | 439 | else { | |
440 | 440 | let pmt = value(i.payments[0]) | |
441 | 441 | let pmtAssetId = value(pmt.assetId) | |
442 | 442 | let pmtAmt = pmt.amount | |
443 | 443 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
444 | 444 | let outAmAmt = res._1 | |
445 | 445 | let outPrAmt = res._2 | |
446 | 446 | let poolStatus = parseIntValue(res._9) | |
447 | 447 | let state = res._10 | |
448 | 448 | if (if (isGlobalShutdown()) | |
449 | 449 | then true | |
450 | 450 | else (poolStatus == PoolShutdown)) | |
451 | 451 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
452 | 452 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
453 | 453 | } | |
454 | 454 | ||
455 | 455 | ||
456 | 456 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
457 | 457 | then throw("exactly 2 payments are expected") | |
458 | 458 | else { | |
459 | 459 | let amAssetPmt = value(i.payments[0]) | |
460 | 460 | let prAssetPmt = value(i.payments[1]) | |
461 | 461 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
462 | 462 | let poolStatus = parseIntValue(estPut._8) | |
463 | 463 | if (if (if (isGlobalShutdown()) | |
464 | 464 | then true | |
465 | 465 | else (poolStatus == PoolPutDisabled)) | |
466 | 466 | then true | |
467 | 467 | else (poolStatus == PoolShutdown)) | |
468 | 468 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
469 | 469 | else estPut | |
470 | 470 | } | |
471 | 471 | ||
472 | 472 | ||
473 | 473 | func emit (amount) = { | |
474 | 474 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
475 | 475 | if ((emitInv == emitInv)) | |
476 | 476 | then { | |
477 | 477 | let emitInvLegacy = match emitInv { | |
478 | 478 | case legacyFactoryContract: Address => | |
479 | 479 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
480 | 480 | case _ => | |
481 | 481 | unit | |
482 | 482 | } | |
483 | 483 | if ((emitInvLegacy == emitInvLegacy)) | |
484 | 484 | then amount | |
485 | 485 | else throw("Strict value is not equal to itself.") | |
486 | 486 | } | |
487 | 487 | else throw("Strict value is not equal to itself.") | |
488 | 488 | } | |
489 | 489 | ||
490 | 490 | ||
491 | 491 | func takeFee (amount) = { | |
492 | 492 | let feeAmount = fraction(amount, fee, scale8) | |
493 | 493 | $Tuple2((amount - feeAmount), feeAmount) | |
494 | 494 | } | |
495 | 495 | ||
496 | 496 | ||
497 | 497 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
498 | 498 | let isEval = (txId == unit) | |
499 | 499 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
500 | 500 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
501 | 501 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
502 | 502 | then true | |
503 | 503 | else if ((paymentAssetId == cfgPriceAssetId)) | |
504 | 504 | then false | |
505 | 505 | else throwErr("invalid asset") | |
506 | 506 | let $t02380924102 = if (isEval) | |
507 | 507 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
508 | 508 | else if (paymentInAmountAsset) | |
509 | 509 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
510 | 510 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
511 | 511 | let amountBalanceOld = $t02380924102._1 | |
512 | 512 | let priceBalanceOld = $t02380924102._2 | |
513 | 513 | let $t02410624255 = if (paymentInAmountAsset) | |
514 | 514 | then $Tuple2(paymentAmountRaw, 0) | |
515 | 515 | else $Tuple2(0, paymentAmountRaw) | |
516 | 516 | let amountAssetAmountRaw = $t02410624255._1 | |
517 | 517 | let priceAssetAmountRaw = $t02410624255._2 | |
518 | 518 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
519 | 519 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
520 | 520 | let $t02437724436 = takeFee(paymentAmountRaw) | |
521 | 521 | let paymentAmount = $t02437724436._1 | |
522 | 522 | let feeAmount = $t02437724436._2 | |
523 | 523 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
524 | 524 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
525 | 525 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
526 | 526 | let priceNew = fromX18(priceNewX18, scale8) | |
527 | 527 | let paymentBalance = if (paymentInAmountAsset) | |
528 | 528 | then amountBalanceOld | |
529 | 529 | else priceBalanceOld | |
530 | 530 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
531 | 531 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
532 | 532 | let chechSupply = if ((supplyBigInt > big0)) | |
533 | 533 | then true | |
534 | 534 | else throwErr("initial deposit requires all coins") | |
535 | 535 | if ((chechSupply == chechSupply)) | |
536 | 536 | then { | |
537 | 537 | let depositBigInt = toBigInt(paymentAmount) | |
538 | 538 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
539 | 539 | let commonState = if (isEval) | |
540 | 540 | then nil | |
541 | 541 | else [IntegerEntry(pl(), priceNew), IntegerEntry(ph(height, lastBlock.timestamp), priceNew), StringEntry(pau(toString(value(userAddress)), toBase58String(value(txId))), dataPutActionInfo(amountAssetAmountRaw, priceAssetAmountRaw, issueAmount, priceNew, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
542 | 542 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
543 | 543 | let priceOld = fromX18(priceOldX18, scale8) | |
544 | 544 | let loss = { | |
545 | 545 | let $t02591326080 = if (paymentInAmountAsset) | |
546 | 546 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
547 | 547 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
548 | 548 | let amount = $t02591326080._1 | |
549 | 549 | let balance = $t02591326080._2 | |
550 | 550 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
551 | 551 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
552 | 552 | } | |
553 | 553 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
554 | 554 | } | |
555 | 555 | else throw("Strict value is not equal to itself.") | |
556 | 556 | } | |
557 | 557 | ||
558 | 558 | ||
559 | 559 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
560 | 560 | let isEval = (txId == unit) | |
561 | 561 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
562 | 562 | then true | |
563 | 563 | else throwErr("invalid lp asset")] | |
564 | 564 | if ((checks == checks)) | |
565 | 565 | then { | |
566 | 566 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
567 | 567 | then true | |
568 | 568 | else if ((outAssetId == cfgPriceAssetId)) | |
569 | 569 | then false | |
570 | 570 | else throwErr("invalid asset") | |
571 | 571 | let balanceBigInt = if (outInAmountAsset) | |
572 | 572 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
573 | 573 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
574 | 574 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
575 | 575 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
576 | 576 | let outBalance = if (outInAmountAsset) | |
577 | 577 | then amBalanceOld | |
578 | 578 | else prBalanceOld | |
579 | 579 | let outBalanceBigInt = toBigInt(outBalance) | |
580 | 580 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
581 | 581 | let redeemedBigInt = toBigInt(paymentAmount) | |
582 | 582 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
583 | 583 | let $t02768227732 = takeFee(amountRaw) | |
584 | 584 | let totalAmount = $t02768227732._1 | |
585 | 585 | let feeAmount = $t02768227732._2 | |
586 | 586 | let $t02773627962 = if (outInAmountAsset) | |
587 | 587 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
588 | 588 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
589 | 589 | let outAmAmount = $t02773627962._1 | |
590 | 590 | let outPrAmount = $t02773627962._2 | |
591 | 591 | let amBalanceNew = $t02773627962._3 | |
592 | 592 | let prBalanceNew = $t02773627962._4 | |
593 | 593 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
594 | 594 | let priceNew = fromX18(priceNewX18, scale8) | |
595 | 595 | let commonState = if (isEval) | |
596 | 596 | then nil | |
597 | 597 | else [StringEntry(gau(toString(value(userAddress)), toBase58String(value(txId))), dataGetActionInfo(outAmAmount, outPrAmount, paymentAmount, priceNew, height, lastBlock.timestamp)), IntegerEntry(pl(), priceNew), IntegerEntry(ph(height, lastBlock.timestamp), priceNew)] | |
598 | 598 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
599 | 599 | let priceOld = fromX18(priceOldX18, scale8) | |
600 | 600 | let loss = { | |
601 | 601 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
602 | 602 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
603 | 603 | } | |
604 | 604 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
605 | 605 | } | |
606 | 606 | else throw("Strict value is not equal to itself.") | |
607 | 607 | } | |
608 | 608 | ||
609 | 609 | ||
610 | 610 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
611 | 611 | case s: String => | |
612 | 612 | fromBase58String(s) | |
613 | 613 | case _: Unit => | |
614 | 614 | unit | |
615 | 615 | case _ => | |
616 | 616 | throw("Match error") | |
617 | 617 | } | |
618 | 618 | ||
619 | 619 | ||
620 | 620 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
621 | 621 | case s: String => | |
622 | 622 | fromBase58String(s) | |
623 | 623 | case _: Unit => | |
624 | 624 | unit | |
625 | 625 | case _ => | |
626 | 626 | throw("Match error") | |
627 | 627 | } | |
628 | 628 | ||
629 | 629 | ||
630 | 630 | func isManager (i) = match managerPublicKeyOrUnit() { | |
631 | 631 | case pk: ByteVector => | |
632 | 632 | (i.callerPublicKey == pk) | |
633 | 633 | case _: Unit => | |
634 | 634 | (i.caller == this) | |
635 | 635 | case _ => | |
636 | 636 | throw("Match error") | |
637 | 637 | } | |
638 | 638 | ||
639 | 639 | ||
640 | 640 | func mustManager (i) = { | |
641 | 641 | let pd = throw("Permission denied") | |
642 | 642 | match managerPublicKeyOrUnit() { | |
643 | 643 | case pk: ByteVector => | |
644 | 644 | if ((i.callerPublicKey == pk)) | |
645 | 645 | then true | |
646 | 646 | else pd | |
647 | 647 | case _: Unit => | |
648 | 648 | if ((i.caller == this)) | |
649 | 649 | then true | |
650 | 650 | else pd | |
651 | 651 | case _ => | |
652 | 652 | throw("Match error") | |
653 | 653 | } | |
654 | 654 | } | |
655 | 655 | ||
656 | 656 | ||
657 | 657 | @Callable(i) | |
658 | 658 | func setManager (pendingManagerPublicKey) = { | |
659 | 659 | let checkCaller = mustManager(i) | |
660 | 660 | if ((checkCaller == checkCaller)) | |
661 | 661 | then { | |
662 | 662 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
663 | 663 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
664 | 664 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
665 | 665 | else throw("Strict value is not equal to itself.") | |
666 | 666 | } | |
667 | 667 | else throw("Strict value is not equal to itself.") | |
668 | 668 | } | |
669 | 669 | ||
670 | 670 | ||
671 | 671 | ||
672 | 672 | @Callable(i) | |
673 | 673 | func confirmManager () = { | |
674 | 674 | let pm = pendingManagerPublicKeyOrUnit() | |
675 | 675 | let hasPM = if (isDefined(pm)) | |
676 | 676 | then true | |
677 | 677 | else throw("No pending manager") | |
678 | 678 | if ((hasPM == hasPM)) | |
679 | 679 | then { | |
680 | 680 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
681 | 681 | then true | |
682 | 682 | else throw("You are not pending manager") | |
683 | 683 | if ((checkPM == checkPM)) | |
684 | 684 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
685 | 685 | else throw("Strict value is not equal to itself.") | |
686 | 686 | } | |
687 | 687 | else throw("Strict value is not equal to itself.") | |
688 | 688 | } | |
689 | 689 | ||
690 | 690 | ||
691 | 691 | ||
692 | 692 | @Callable(i) | |
693 | 693 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
694 | 694 | then throw("Invalid slippageTolerance passed") | |
695 | 695 | else { | |
696 | 696 | let estPut = commonPut(i, slippageTolerance, true) | |
697 | 697 | let emitLpAmt = estPut._2 | |
698 | 698 | let lpAssetId = estPut._7 | |
699 | 699 | let state = estPut._9 | |
700 | 700 | let amDiff = estPut._10 | |
701 | 701 | let prDiff = estPut._11 | |
702 | 702 | let amId = estPut._12 | |
703 | 703 | let prId = estPut._13 | |
704 | 704 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
705 | 705 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
706 | - | let | |
707 | - | if (( | |
706 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
707 | + | if ((currentKLp == currentKLp)) | |
708 | 708 | then { | |
709 | - | let | |
710 | - | if (( | |
709 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
710 | + | if ((emitInv == emitInv)) | |
711 | 711 | then { | |
712 | - | let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity) | |
713 | - | if ((lpAssetEmission == lpAssetEmission)) | |
712 | + | let emitInvLegacy = match emitInv { | |
713 | + | case legacyFactoryContract: Address => | |
714 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
715 | + | case _ => | |
716 | + | unit | |
717 | + | } | |
718 | + | if ((emitInvLegacy == emitInvLegacy)) | |
714 | 719 | then { | |
715 | - | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
716 | - | if ((currentKLp == currentKLp)) | |
720 | + | let slippageAInv = if ((amDiff > 0)) | |
721 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
722 | + | else nil | |
723 | + | if ((slippageAInv == slippageAInv)) | |
717 | 724 | then { | |
718 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
719 | - | if ((emitInv == emitInv)) | |
725 | + | let slippagePInv = if ((prDiff > 0)) | |
726 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
727 | + | else nil | |
728 | + | if ((slippagePInv == slippagePInv)) | |
720 | 729 | then { | |
721 | - | let emitInvLegacy = match emitInv { | |
722 | - | case legacyFactoryContract: Address => | |
723 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
724 | - | case _ => | |
725 | - | unit | |
726 | - | } | |
727 | - | if ((emitInvLegacy == emitInvLegacy)) | |
730 | + | let lpTransfer = if (shouldAutoStake) | |
728 | 731 | then { | |
729 | - | let slippageAInv = if ((amDiff > 0)) | |
730 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
731 | - | else nil | |
732 | - | if ((slippageAInv == slippageAInv)) | |
733 | - | then { | |
734 | - | let slippagePInv = if ((prDiff > 0)) | |
735 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
736 | - | else nil | |
737 | - | if ((slippagePInv == slippagePInv)) | |
738 | - | then { | |
739 | - | let lpTransfer = if (shouldAutoStake) | |
740 | - | then { | |
741 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
742 | - | if ((slpStakeInv == slpStakeInv)) | |
743 | - | then nil | |
744 | - | else throw("Strict value is not equal to itself.") | |
745 | - | } | |
746 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
747 | - | let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity | |
748 | - | if ((lpAssetEmissionAfter == lpAssetEmissionAfter)) | |
749 | - | then { | |
750 | - | let $t03248232550 = refreshKLpInternal(0, 0, 0) | |
751 | - | if (($t03248232550 == $t03248232550)) | |
752 | - | then { | |
753 | - | let updatedKLp = $t03248232550._2 | |
754 | - | let refreshKLpActions = $t03248232550._1 | |
755 | - | let error = throwErr(makeString([toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentKLp), toString(updatedKLp), toString(emitLpAmt), toString(amDiff), toString(prDiff), toString(lpAssetEmission), toString(lpAssetEmissionAfter)], " ")) | |
756 | - | if ((error == error)) | |
757 | - | then { | |
758 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
759 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
760 | - | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
761 | - | else throw("Strict value is not equal to itself.") | |
762 | - | } | |
763 | - | else throw("Strict value is not equal to itself.") | |
764 | - | } | |
765 | - | else throw("Strict value is not equal to itself.") | |
766 | - | } | |
767 | - | else throw("Strict value is not equal to itself.") | |
768 | - | } | |
769 | - | else throw("Strict value is not equal to itself.") | |
770 | - | } | |
732 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
733 | + | if ((slpStakeInv == slpStakeInv)) | |
734 | + | then nil | |
735 | + | else throw("Strict value is not equal to itself.") | |
736 | + | } | |
737 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
738 | + | let $t03211432182 = refreshKLpInternal(0, 0, 0) | |
739 | + | if (($t03211432182 == $t03211432182)) | |
740 | + | then { | |
741 | + | let updatedKLp = $t03211432182._2 | |
742 | + | let refreshKLpActions = $t03211432182._1 | |
743 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
744 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
745 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
771 | 746 | else throw("Strict value is not equal to itself.") | |
772 | 747 | } | |
773 | 748 | else throw("Strict value is not equal to itself.") | |
774 | 749 | } | |
775 | 750 | else throw("Strict value is not equal to itself.") | |
776 | 751 | } | |
777 | 752 | else throw("Strict value is not equal to itself.") | |
778 | 753 | } | |
779 | 754 | else throw("Strict value is not equal to itself.") | |
780 | 755 | } | |
781 | 756 | else throw("Strict value is not equal to itself.") | |
782 | 757 | } | |
783 | 758 | else throw("Strict value is not equal to itself.") | |
784 | 759 | } | |
785 | 760 | ||
786 | 761 | ||
787 | 762 | ||
788 | 763 | @Callable(i) | |
789 | 764 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
790 | 765 | then throw("Invalid value passed") | |
791 | 766 | else { | |
792 | 767 | let estPut = commonPut(i, maxSlippage, false) | |
793 | 768 | let state = estPut._9 | |
794 | 769 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
795 | 770 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
796 | 771 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
797 | 772 | if ((currentKLp == currentKLp)) | |
798 | 773 | then { | |
799 | - | let $ | |
800 | - | let refreshKLpActions = $ | |
801 | - | let updatedKLp = $ | |
774 | + | let $t03274432809 = refreshKLpInternal(0, 0, 0) | |
775 | + | let refreshKLpActions = $t03274432809._1 | |
776 | + | let updatedKLp = $t03274432809._2 | |
802 | 777 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
803 | 778 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
804 | 779 | then (state ++ refreshKLpActions) | |
805 | 780 | else throw("Strict value is not equal to itself.") | |
806 | 781 | } | |
807 | 782 | else throw("Strict value is not equal to itself.") | |
808 | 783 | } | |
809 | 784 | ||
810 | 785 | ||
811 | 786 | ||
812 | 787 | @Callable(i) | |
813 | 788 | func putOneTkn (minOutAmount,autoStake) = { | |
814 | 789 | let isPoolOneTokenOperationsDisabled = { | |
815 | 790 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
816 | 791 | if ($isInstanceOf(@, "Boolean")) | |
817 | 792 | then @ | |
818 | 793 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
819 | 794 | } | |
820 | 795 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
821 | 796 | then true | |
822 | 797 | else (cfgPoolStatus == PoolPutDisabled)) | |
823 | 798 | then true | |
824 | 799 | else (cfgPoolStatus == PoolShutdown)) | |
825 | 800 | then true | |
826 | 801 | else isPoolOneTokenOperationsDisabled | |
827 | 802 | let checks = [if (if (!(isPutDisabled)) | |
828 | 803 | then true | |
829 | 804 | else isManager(i)) | |
830 | 805 | then true | |
831 | 806 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
832 | 807 | then true | |
833 | 808 | else throwErr("exactly 1 payment are expected")] | |
834 | 809 | if ((checks == checks)) | |
835 | 810 | then { | |
836 | 811 | let payment = i.payments[0] | |
837 | 812 | let paymentAssetId = payment.assetId | |
838 | 813 | let paymentAmountRaw = payment.amount | |
839 | 814 | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
840 | 815 | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
841 | 816 | else if ((paymentAssetId == cfgPriceAssetId)) | |
842 | 817 | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
843 | 818 | else throwErr("payment asset is not supported") | |
844 | 819 | let userAddress = i.caller | |
845 | 820 | let txId = i.transactionId | |
846 | - | let $ | |
847 | - | if (($ | |
821 | + | let $t03399434146 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
822 | + | if (($t03399434146 == $t03399434146)) | |
848 | 823 | then { | |
849 | - | let paymentInAmountAsset = $ | |
850 | - | let bonus = $ | |
851 | - | let feeAmount = $ | |
852 | - | let commonState = $ | |
853 | - | let emitAmountEstimated = $ | |
824 | + | let paymentInAmountAsset = $t03399434146._5 | |
825 | + | let bonus = $t03399434146._4 | |
826 | + | let feeAmount = $t03399434146._3 | |
827 | + | let commonState = $t03399434146._2 | |
828 | + | let emitAmountEstimated = $t03399434146._1 | |
854 | 829 | let emitAmount = if (if ((minOutAmount > 0)) | |
855 | 830 | then (minOutAmount > emitAmountEstimated) | |
856 | 831 | else false) | |
857 | 832 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
858 | 833 | else emitAmountEstimated | |
859 | 834 | let emitInv = emit(emitAmount) | |
860 | 835 | if ((emitInv == emitInv)) | |
861 | 836 | then { | |
862 | 837 | let lpTransfer = if (autoStake) | |
863 | 838 | then { | |
864 | 839 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
865 | 840 | if ((stakeInv == stakeInv)) | |
866 | 841 | then nil | |
867 | 842 | else throw("Strict value is not equal to itself.") | |
868 | 843 | } | |
869 | 844 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
870 | 845 | let sendFee = if ((feeAmount > 0)) | |
871 | 846 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
872 | 847 | else nil | |
873 | - | let $ | |
848 | + | let $t03473234929 = if ((this == feeCollectorAddress)) | |
874 | 849 | then $Tuple2(0, 0) | |
875 | 850 | else if (paymentInAmountAsset) | |
876 | 851 | then $Tuple2(-(feeAmount), 0) | |
877 | 852 | else $Tuple2(0, -(feeAmount)) | |
878 | - | let amountAssetBalanceDelta = $ | |
879 | - | let priceAssetBalanceDelta = $ | |
880 | - | let $ | |
881 | - | let refreshKLpActions = $ | |
882 | - | let updatedKLp = $ | |
853 | + | let amountAssetBalanceDelta = $t03473234929._1 | |
854 | + | let priceAssetBalanceDelta = $t03473234929._2 | |
855 | + | let $t03493235040 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
856 | + | let refreshKLpActions = $t03493235040._1 | |
857 | + | let updatedKLp = $t03493235040._2 | |
883 | 858 | let kLp = value(getString(keyKLp)) | |
884 | 859 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
885 | 860 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
886 | 861 | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
887 | 862 | else throw("Strict value is not equal to itself.") | |
888 | 863 | } | |
889 | 864 | else throw("Strict value is not equal to itself.") | |
890 | 865 | } | |
891 | 866 | else throw("Strict value is not equal to itself.") | |
892 | 867 | } | |
893 | 868 | else throw("Strict value is not equal to itself.") | |
894 | 869 | } | |
895 | 870 | ||
896 | 871 | ||
897 | 872 | ||
898 | 873 | @Callable(i) | |
899 | 874 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
900 | - | let $ | |
901 | - | let emitAmountEstimated = $ | |
902 | - | let commonState = $ | |
903 | - | let feeAmount = $ | |
904 | - | let bonus = $ | |
905 | - | let paymentInAmountAsset = $ | |
875 | + | let $t03534635503 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
876 | + | let emitAmountEstimated = $t03534635503._1 | |
877 | + | let commonState = $t03534635503._2 | |
878 | + | let feeAmount = $t03534635503._3 | |
879 | + | let bonus = $t03534635503._4 | |
880 | + | let paymentInAmountAsset = $t03534635503._5 | |
906 | 881 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
907 | 882 | } | |
908 | 883 | ||
909 | 884 | ||
910 | 885 | ||
911 | 886 | @Callable(i) | |
912 | 887 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
913 | 888 | let isPoolOneTokenOperationsDisabled = { | |
914 | 889 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
915 | 890 | if ($isInstanceOf(@, "Boolean")) | |
916 | 891 | then @ | |
917 | 892 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
918 | 893 | } | |
919 | 894 | let isGetDisabled = if (if (isGlobalShutdown()) | |
920 | 895 | then true | |
921 | 896 | else (cfgPoolStatus == PoolShutdown)) | |
922 | 897 | then true | |
923 | 898 | else isPoolOneTokenOperationsDisabled | |
924 | 899 | let checks = [if (if (!(isGetDisabled)) | |
925 | 900 | then true | |
926 | 901 | else isManager(i)) | |
927 | 902 | then true | |
928 | 903 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
929 | 904 | then true | |
930 | 905 | else throwErr("exactly 1 payment are expected")] | |
931 | 906 | if ((checks == checks)) | |
932 | 907 | then { | |
933 | 908 | let outAssetId = parseAssetId(outAssetIdStr) | |
934 | 909 | let payment = i.payments[0] | |
935 | 910 | let paymentAssetId = payment.assetId | |
936 | 911 | let paymentAmount = payment.amount | |
937 | 912 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount)) | |
938 | 913 | let userAddress = i.caller | |
939 | 914 | let txId = i.transactionId | |
940 | - | let $ | |
941 | - | if (($ | |
915 | + | let $t03639736550 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
916 | + | if (($t03639736550 == $t03639736550)) | |
942 | 917 | then { | |
943 | - | let outInAmountAsset = $ | |
944 | - | let bonus = $ | |
945 | - | let feeAmount = $ | |
946 | - | let commonState = $ | |
947 | - | let amountEstimated = $ | |
918 | + | let outInAmountAsset = $t03639736550._5 | |
919 | + | let bonus = $t03639736550._4 | |
920 | + | let feeAmount = $t03639736550._3 | |
921 | + | let commonState = $t03639736550._2 | |
922 | + | let amountEstimated = $t03639736550._1 | |
948 | 923 | let amount = if (if ((minOutAmount > 0)) | |
949 | 924 | then (minOutAmount > amountEstimated) | |
950 | 925 | else false) | |
951 | 926 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
952 | 927 | else amountEstimated | |
953 | 928 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
954 | 929 | if ((burnInv == burnInv)) | |
955 | 930 | then { | |
956 | 931 | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
957 | 932 | let sendFee = if ((feeAmount > 0)) | |
958 | 933 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
959 | 934 | else nil | |
960 | - | let $ | |
935 | + | let $t03705037297 = { | |
961 | 936 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
962 | 937 | then 0 | |
963 | 938 | else feeAmount | |
964 | 939 | if (outInAmountAsset) | |
965 | 940 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
966 | 941 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
967 | 942 | } | |
968 | - | let amountAssetBalanceDelta = $ | |
969 | - | let priceAssetBalanceDelta = $ | |
970 | - | let $ | |
971 | - | let refreshKLpActions = $ | |
972 | - | let updatedKLp = $ | |
943 | + | let amountAssetBalanceDelta = $t03705037297._1 | |
944 | + | let priceAssetBalanceDelta = $t03705037297._2 | |
945 | + | let $t03730037408 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
946 | + | let refreshKLpActions = $t03730037408._1 | |
947 | + | let updatedKLp = $t03730037408._2 | |
973 | 948 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
974 | 949 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
975 | 950 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
976 | 951 | else throw("Strict value is not equal to itself.") | |
977 | 952 | } | |
978 | 953 | else throw("Strict value is not equal to itself.") | |
979 | 954 | } | |
980 | 955 | else throw("Strict value is not equal to itself.") | |
981 | 956 | } | |
982 | 957 | else throw("Strict value is not equal to itself.") | |
983 | 958 | } | |
984 | 959 | ||
985 | 960 | ||
986 | 961 | ||
987 | 962 | @Callable(i) | |
988 | 963 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
989 | - | let $ | |
990 | - | let amountEstimated = $ | |
991 | - | let commonState = $ | |
992 | - | let feeAmount = $ | |
993 | - | let bonus = $ | |
994 | - | let outInAmountAsset = $ | |
964 | + | let $t03766537821 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
965 | + | let amountEstimated = $t03766537821._1 | |
966 | + | let commonState = $t03766537821._2 | |
967 | + | let feeAmount = $t03766537821._3 | |
968 | + | let bonus = $t03766537821._4 | |
969 | + | let outInAmountAsset = $t03766537821._5 | |
995 | 970 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
996 | 971 | } | |
997 | 972 | ||
998 | 973 | ||
999 | 974 | ||
1000 | 975 | @Callable(i) | |
1001 | 976 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
1002 | 977 | let isPoolOneTokenOperationsDisabled = { | |
1003 | 978 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1004 | 979 | if ($isInstanceOf(@, "Boolean")) | |
1005 | 980 | then @ | |
1006 | 981 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1007 | 982 | } | |
1008 | 983 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1009 | 984 | then true | |
1010 | 985 | else (cfgPoolStatus == PoolShutdown)) | |
1011 | 986 | then true | |
1012 | 987 | else isPoolOneTokenOperationsDisabled | |
1013 | 988 | let checks = [if (if (!(isGetDisabled)) | |
1014 | 989 | then true | |
1015 | 990 | else isManager(i)) | |
1016 | 991 | then true | |
1017 | 992 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1018 | 993 | then true | |
1019 | 994 | else throwErr("no payments are expected")] | |
1020 | 995 | if ((checks == checks)) | |
1021 | 996 | then { | |
1022 | 997 | let outAssetId = parseAssetId(outAssetIdStr) | |
1023 | 998 | let userAddress = i.caller | |
1024 | 999 | let txId = i.transactionId | |
1025 | 1000 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1026 | 1001 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1027 | 1002 | if ((unstakeInv == unstakeInv)) | |
1028 | 1003 | then { | |
1029 | - | let $ | |
1030 | - | if (($ | |
1004 | + | let $t03872338874 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1005 | + | if (($t03872338874 == $t03872338874)) | |
1031 | 1006 | then { | |
1032 | - | let outInAmountAsset = $ | |
1033 | - | let bonus = $ | |
1034 | - | let feeAmount = $ | |
1035 | - | let commonState = $ | |
1036 | - | let amountEstimated = $ | |
1007 | + | let outInAmountAsset = $t03872338874._5 | |
1008 | + | let bonus = $t03872338874._4 | |
1009 | + | let feeAmount = $t03872338874._3 | |
1010 | + | let commonState = $t03872338874._2 | |
1011 | + | let amountEstimated = $t03872338874._1 | |
1037 | 1012 | let amount = if (if ((minOutAmount > 0)) | |
1038 | 1013 | then (minOutAmount > amountEstimated) | |
1039 | 1014 | else false) | |
1040 | 1015 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1041 | 1016 | else amountEstimated | |
1042 | 1017 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1043 | 1018 | if ((burnInv == burnInv)) | |
1044 | 1019 | then { | |
1045 | 1020 | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1046 | 1021 | let sendFee = if ((feeAmount > 0)) | |
1047 | 1022 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1048 | 1023 | else nil | |
1049 | - | let $ | |
1024 | + | let $t03936939616 = { | |
1050 | 1025 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1051 | 1026 | then 0 | |
1052 | 1027 | else feeAmount | |
1053 | 1028 | if (outInAmountAsset) | |
1054 | 1029 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1055 | 1030 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1056 | 1031 | } | |
1057 | - | let amountAssetBalanceDelta = $ | |
1058 | - | let priceAssetBalanceDelta = $ | |
1059 | - | let $ | |
1060 | - | let refreshKLpActions = $ | |
1061 | - | let updatedKLp = $ | |
1032 | + | let amountAssetBalanceDelta = $t03936939616._1 | |
1033 | + | let priceAssetBalanceDelta = $t03936939616._2 | |
1034 | + | let $t03961939727 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1035 | + | let refreshKLpActions = $t03961939727._1 | |
1036 | + | let updatedKLp = $t03961939727._2 | |
1062 | 1037 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1063 | 1038 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1064 | 1039 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1065 | 1040 | else throw("Strict value is not equal to itself.") | |
1066 | 1041 | } | |
1067 | 1042 | else throw("Strict value is not equal to itself.") | |
1068 | 1043 | } | |
1069 | 1044 | else throw("Strict value is not equal to itself.") | |
1070 | 1045 | } | |
1071 | 1046 | else throw("Strict value is not equal to itself.") | |
1072 | 1047 | } | |
1073 | 1048 | else throw("Strict value is not equal to itself.") | |
1074 | 1049 | } | |
1075 | 1050 | ||
1076 | 1051 | ||
1077 | 1052 | ||
1078 | 1053 | @Callable(i) | |
1079 | 1054 | func get () = { | |
1080 | 1055 | let res = commonGet(i) | |
1081 | 1056 | let outAmtAmt = res._1 | |
1082 | 1057 | let outPrAmt = res._2 | |
1083 | 1058 | let pmtAmt = res._3 | |
1084 | 1059 | let pmtAssetId = res._4 | |
1085 | 1060 | let state = res._5 | |
1086 | 1061 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1087 | 1062 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1088 | 1063 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1089 | 1064 | then { | |
1090 | - | let $ | |
1091 | - | let refreshKLpActions = $ | |
1092 | - | let updatedKLp = $ | |
1065 | + | let $t04067540757 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1066 | + | let refreshKLpActions = $t04067540757._1 | |
1067 | + | let updatedKLp = $t04067540757._2 | |
1093 | 1068 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1094 | 1069 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1095 | 1070 | then (state ++ refreshKLpActions) | |
1096 | 1071 | else throw("Strict value is not equal to itself.") | |
1097 | 1072 | } | |
1098 | 1073 | else throw("Strict value is not equal to itself.") | |
1099 | 1074 | } | |
1100 | 1075 | ||
1101 | 1076 | ||
1102 | 1077 | ||
1103 | 1078 | @Callable(i) | |
1104 | 1079 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1105 | 1080 | let res = commonGet(i) | |
1106 | 1081 | let outAmAmt = res._1 | |
1107 | 1082 | let outPrAmt = res._2 | |
1108 | 1083 | let pmtAmt = res._3 | |
1109 | 1084 | let pmtAssetId = res._4 | |
1110 | 1085 | let state = res._5 | |
1111 | 1086 | if ((noLessThenAmtAsset > outAmAmt)) | |
1112 | 1087 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1113 | 1088 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1114 | 1089 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1115 | 1090 | else { | |
1116 | 1091 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1117 | 1092 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1118 | 1093 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1119 | 1094 | then { | |
1120 | - | let $ | |
1121 | - | let refreshKLpActions = $ | |
1122 | - | let updatedKLp = $ | |
1095 | + | let $t04170841789 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1096 | + | let refreshKLpActions = $t04170841789._1 | |
1097 | + | let updatedKLp = $t04170841789._2 | |
1123 | 1098 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1124 | 1099 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1125 | 1100 | then (state ++ refreshKLpActions) | |
1126 | 1101 | else throw("Strict value is not equal to itself.") | |
1127 | 1102 | } | |
1128 | 1103 | else throw("Strict value is not equal to itself.") | |
1129 | 1104 | } | |
1130 | 1105 | } | |
1131 | 1106 | ||
1132 | 1107 | ||
1133 | 1108 | ||
1134 | 1109 | @Callable(i) | |
1135 | 1110 | func unstakeAndGet (amount) = { | |
1136 | 1111 | let checkPayments = if ((size(i.payments) != 0)) | |
1137 | 1112 | then throw("No payments are expected") | |
1138 | 1113 | else true | |
1139 | 1114 | if ((checkPayments == checkPayments)) | |
1140 | 1115 | then { | |
1141 | 1116 | let cfg = getPoolConfig() | |
1142 | 1117 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1143 | 1118 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1144 | 1119 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1145 | 1120 | if ((unstakeInv == unstakeInv)) | |
1146 | 1121 | then { | |
1147 | 1122 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1148 | 1123 | let outAmAmt = res._1 | |
1149 | 1124 | let outPrAmt = res._2 | |
1150 | 1125 | let poolStatus = parseIntValue(res._9) | |
1151 | 1126 | let state = res._10 | |
1152 | 1127 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1153 | 1128 | then true | |
1154 | 1129 | else (poolStatus == PoolShutdown)) | |
1155 | 1130 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1156 | 1131 | else true | |
1157 | 1132 | if ((checkPoolStatus == checkPoolStatus)) | |
1158 | 1133 | then { | |
1159 | 1134 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1160 | 1135 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1161 | 1136 | then { | |
1162 | - | let $ | |
1163 | - | let refreshKLpActions = $ | |
1164 | - | let updatedKLp = $ | |
1137 | + | let $t04291242993 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1138 | + | let refreshKLpActions = $t04291242993._1 | |
1139 | + | let updatedKLp = $t04291242993._2 | |
1165 | 1140 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1166 | 1141 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1167 | 1142 | then (state ++ refreshKLpActions) | |
1168 | 1143 | else throw("Strict value is not equal to itself.") | |
1169 | 1144 | } | |
1170 | 1145 | else throw("Strict value is not equal to itself.") | |
1171 | 1146 | } | |
1172 | 1147 | else throw("Strict value is not equal to itself.") | |
1173 | 1148 | } | |
1174 | 1149 | else throw("Strict value is not equal to itself.") | |
1175 | 1150 | } | |
1176 | 1151 | else throw("Strict value is not equal to itself.") | |
1177 | 1152 | } | |
1178 | 1153 | ||
1179 | 1154 | ||
1180 | 1155 | ||
1181 | 1156 | @Callable(i) | |
1182 | 1157 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1183 | 1158 | let isGetDisabled = if (isGlobalShutdown()) | |
1184 | 1159 | then true | |
1185 | 1160 | else (cfgPoolStatus == PoolShutdown) | |
1186 | 1161 | let checks = [if (!(isGetDisabled)) | |
1187 | 1162 | then true | |
1188 | 1163 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1189 | 1164 | then true | |
1190 | 1165 | else throw("no payments are expected")] | |
1191 | 1166 | if ((checks == checks)) | |
1192 | 1167 | then { | |
1193 | 1168 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1194 | 1169 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1195 | 1170 | if ((unstakeInv == unstakeInv)) | |
1196 | 1171 | then { | |
1197 | 1172 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1198 | 1173 | let outAmAmt = res._1 | |
1199 | 1174 | let outPrAmt = res._2 | |
1200 | 1175 | let state = res._10 | |
1201 | 1176 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1202 | 1177 | then true | |
1203 | 1178 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1204 | 1179 | then true | |
1205 | 1180 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1206 | 1181 | if ((checkAmounts == checkAmounts)) | |
1207 | 1182 | then { | |
1208 | 1183 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1209 | 1184 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1210 | 1185 | then { | |
1211 | - | let $ | |
1212 | - | let refreshKLpActions = $ | |
1213 | - | let updatedKLp = $ | |
1186 | + | let $t04428544366 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1187 | + | let refreshKLpActions = $t04428544366._1 | |
1188 | + | let updatedKLp = $t04428544366._2 | |
1214 | 1189 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1215 | 1190 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1216 | 1191 | then (state ++ refreshKLpActions) | |
1217 | 1192 | else throw("Strict value is not equal to itself.") | |
1218 | 1193 | } | |
1219 | 1194 | else throw("Strict value is not equal to itself.") | |
1220 | 1195 | } | |
1221 | 1196 | else throw("Strict value is not equal to itself.") | |
1222 | 1197 | } | |
1223 | 1198 | else throw("Strict value is not equal to itself.") | |
1224 | 1199 | } | |
1225 | 1200 | else throw("Strict value is not equal to itself.") | |
1226 | 1201 | } | |
1227 | 1202 | ||
1228 | 1203 | ||
1229 | 1204 | ||
1230 | 1205 | @Callable(i) | |
1231 | 1206 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1232 | 1207 | then throw("permissions denied") | |
1233 | 1208 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1234 | 1209 | ||
1235 | 1210 | ||
1236 | 1211 | ||
1237 | 1212 | @Callable(i) | |
1238 | 1213 | func refreshKLp () = { | |
1239 | 1214 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1240 | 1215 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1241 | 1216 | then unit | |
1242 | 1217 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1243 | 1218 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1244 | 1219 | then { | |
1245 | 1220 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1246 | - | let $ | |
1247 | - | let kLpUpdateActions = $ | |
1248 | - | let updatedKLp = $ | |
1221 | + | let $t04555345617 = refreshKLpInternal(0, 0, 0) | |
1222 | + | let kLpUpdateActions = $t04555345617._1 | |
1223 | + | let updatedKLp = $t04555345617._2 | |
1249 | 1224 | let actions = if ((kLp != updatedKLp)) | |
1250 | 1225 | then kLpUpdateActions | |
1251 | 1226 | else throwErr("nothing to refresh") | |
1252 | 1227 | $Tuple2(actions, toString(updatedKLp)) | |
1253 | 1228 | } | |
1254 | 1229 | else throw("Strict value is not equal to itself.") | |
1255 | 1230 | } | |
1256 | 1231 | ||
1257 | 1232 | ||
1258 | 1233 | ||
1259 | 1234 | @Callable(i) | |
1260 | 1235 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1261 | 1236 | ||
1262 | 1237 | ||
1263 | 1238 | ||
1264 | 1239 | @Callable(i) | |
1265 | 1240 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1266 | 1241 | ||
1267 | 1242 | ||
1268 | 1243 | ||
1269 | 1244 | @Callable(i) | |
1270 | 1245 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1271 | 1246 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1272 | 1247 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1273 | 1248 | } | |
1274 | 1249 | ||
1275 | 1250 | ||
1276 | 1251 | ||
1277 | 1252 | @Callable(i) | |
1278 | 1253 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1279 | 1254 | ||
1280 | 1255 | ||
1281 | 1256 | ||
1282 | 1257 | @Callable(i) | |
1283 | 1258 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1284 | 1259 | ||
1285 | 1260 | ||
1286 | 1261 | ||
1287 | 1262 | @Callable(i) | |
1288 | 1263 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1289 | 1264 | ||
1290 | 1265 | ||
1291 | 1266 | ||
1292 | 1267 | @Callable(i) | |
1293 | 1268 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1294 | 1269 | ||
1295 | 1270 | ||
1296 | 1271 | ||
1297 | 1272 | @Callable(i) | |
1298 | 1273 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1299 | 1274 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1300 | 1275 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1301 | 1276 | } | |
1302 | 1277 | ||
1303 | 1278 | ||
1304 | 1279 | ||
1305 | 1280 | @Callable(i) | |
1306 | 1281 | func statsREADONLY () = { | |
1307 | 1282 | let cfg = getPoolConfig() | |
1308 | 1283 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1309 | 1284 | let amtAssetId = cfg[idxAmtAssetId] | |
1310 | 1285 | let priceAssetId = cfg[idxPriceAssetId] | |
1311 | 1286 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1312 | 1287 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1313 | 1288 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1314 | 1289 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1315 | 1290 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1316 | 1291 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1317 | 1292 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1318 | 1293 | let pricesList = if ((poolLPBalance == 0)) | |
1319 | 1294 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1320 | 1295 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1321 | 1296 | let curPrice = 0 | |
1322 | 1297 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1323 | 1298 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1324 | 1299 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1325 | 1300 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP)) | |
1326 | 1301 | } | |
1327 | 1302 | ||
1328 | 1303 | ||
1329 | 1304 | ||
1330 | 1305 | @Callable(i) | |
1331 | 1306 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1332 | 1307 | let cfg = getPoolConfig() | |
1333 | 1308 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1334 | 1309 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1335 | 1310 | let amAssetId = fromBase58String(amAssetIdStr) | |
1336 | 1311 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1337 | 1312 | let prAssetId = fromBase58String(prAssetIdStr) | |
1338 | 1313 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1339 | 1314 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1340 | 1315 | let poolStatus = cfg[idxPoolStatus] | |
1341 | 1316 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1342 | 1317 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1343 | 1318 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1344 | 1319 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1345 | 1320 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1346 | 1321 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1347 | 1322 | then zeroBigInt | |
1348 | 1323 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1349 | 1324 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1350 | 1325 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1351 | 1326 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1352 | 1327 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1353 | 1328 | let calcLpAmt = estPut._1 | |
1354 | 1329 | let curPriceCalc = estPut._3 | |
1355 | 1330 | let amBalance = estPut._4 | |
1356 | 1331 | let prBalance = estPut._5 | |
1357 | 1332 | let lpEmission = estPut._6 | |
1358 | 1333 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
1359 | 1334 | } | |
1360 | 1335 | ||
1361 | 1336 | ||
1362 | 1337 | ||
1363 | 1338 | @Callable(i) | |
1364 | 1339 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1365 | 1340 | let cfg = getPoolConfig() | |
1366 | 1341 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1367 | 1342 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1368 | 1343 | let amAssetId = fromBase58String(amAssetIdStr) | |
1369 | 1344 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1370 | 1345 | let prAssetId = fromBase58String(prAssetIdStr) | |
1371 | 1346 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1372 | 1347 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1373 | 1348 | let poolStatus = cfg[idxPoolStatus] | |
1374 | 1349 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1375 | 1350 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1376 | 1351 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1377 | 1352 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1378 | 1353 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1379 | 1354 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1380 | 1355 | then zeroBigInt | |
1381 | 1356 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1382 | 1357 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1383 | 1358 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1384 | 1359 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1385 | 1360 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1386 | 1361 | let calcLpAmt = estPut._1 | |
1387 | 1362 | let curPriceCalc = estPut._3 | |
1388 | 1363 | let amBalance = estPut._4 | |
1389 | 1364 | let prBalance = estPut._5 | |
1390 | 1365 | let lpEmission = estPut._6 | |
1391 | 1366 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
1392 | 1367 | } | |
1393 | 1368 | ||
1394 | 1369 | ||
1395 | 1370 | ||
1396 | 1371 | @Callable(i) | |
1397 | 1372 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1398 | 1373 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1399 | 1374 | let outAmAmt = res._1 | |
1400 | 1375 | let outPrAmt = res._2 | |
1401 | 1376 | let amBalance = res._5 | |
1402 | 1377 | let prBalance = res._6 | |
1403 | 1378 | let lpEmission = res._7 | |
1404 | 1379 | let curPrice = res._8 | |
1405 | 1380 | let poolStatus = parseIntValue(res._9) | |
1406 | 1381 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), toString(curPrice), toString(poolStatus)], SEP)) | |
1407 | 1382 | } | |
1408 | 1383 | ||
1409 | 1384 | ||
1410 | 1385 | @Verifier(tx) | |
1411 | 1386 | func verify () = { | |
1412 | 1387 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1413 | 1388 | case pk: ByteVector => | |
1414 | 1389 | pk | |
1415 | 1390 | case _: Unit => | |
1416 | 1391 | tx.senderPublicKey | |
1417 | 1392 | case _ => | |
1418 | 1393 | throw("Match error") | |
1419 | 1394 | } | |
1420 | 1395 | match tx { | |
1421 | 1396 | case order: Order => | |
1422 | 1397 | let matcherPub = getMatcherPubOrFail() | |
1423 | 1398 | let orderValid = validateMatcherOrderAllowed(order) | |
1424 | 1399 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1425 | 1400 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1426 | 1401 | if (if (if (orderValid) | |
1427 | 1402 | then senderValid | |
1428 | 1403 | else false) | |
1429 | 1404 | then matcherValid | |
1430 | 1405 | else false) | |
1431 | 1406 | then true | |
1432 | 1407 | else throwOrderError(orderValid, senderValid, matcherValid) | |
1433 | 1408 | case s: SetScriptTransaction => | |
1434 | 1409 | let newHash = blake2b256(value(s.script)) | |
1435 | 1410 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1436 | 1411 | let currentHash = scriptHash(this) | |
1437 | 1412 | if (if ((allowedHash == newHash)) | |
1438 | 1413 | then (currentHash != newHash) | |
1439 | 1414 | else false) | |
1440 | 1415 | then true | |
1441 | 1416 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1442 | 1417 | case _ => | |
1443 | 1418 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1444 | 1419 | } | |
1445 | 1420 | } | |
1446 | 1421 |
github/deemru/w8io/026f985 156.21 ms ◑