tx · Fk835C8Gt8cQwmH2Mh665wwrrZNvV8Dkkcw54ypSC9mT 3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn: -0.03300000 Waves 2022.11.28 16:06 [2336995] smart account 3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn > SELF 0.00000000 Waves
{ "type": 13, "id": "Fk835C8Gt8cQwmH2Mh665wwrrZNvV8Dkkcw54ypSC9mT", "fee": 3300000, "feeAssetId": null, "timestamp": 1669640838821, "version": 1, "sender": "3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn", "senderPublicKey": "HpuFV1RhaXZ5gaJNgeLjyAKy3D5q7fMKdNFYYbPDafnb", "proofs": [ "46ndXnaZMY5WDEsYDr3SK6vt635UnzAiq65jkqaPnbrwk4atHE3k5mcaJaMC99Y78B5wy74RynVDUsC3YtUv6Ki6" ], "script": "base64:BgL+KwgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQXNzZXREY20iE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zCQCRAwIIBQJncgZwcm9vZnMAAAUCZ3TgLAlD", "chainId": 84, "height": 2336995, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7xWqFVy6Rk9nkinXfpREKbd7Lb3FRWBo67BGtb4o19SR Next: BHxSq7pJM8RaVAE9Tem7MZBu8Mo6yLjj9s3zZKqaPVGV Diff:
Old | New | Differences | |
---|---|---|---|
783 | 783 | let paymentAmountRaw = payment.amount | |
784 | 784 | let userAddress = i.caller | |
785 | 785 | let txId = i.transactionId | |
786 | - | let $t03272532874 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
787 | - | let emitAmountEstimated = $t03272532874._1 | |
788 | - | let commonState = $t03272532874._2 | |
789 | - | let feeAmount = $t03272532874._3 | |
790 | - | let bonus = $t03272532874._4 | |
791 | - | let paymentInAmountAsset = $t03272532874._5 | |
792 | - | let emitAmount = if (if ((minOutAmount > 0)) | |
793 | - | then (minOutAmount > emitAmountEstimated) | |
794 | - | else false) | |
795 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
796 | - | else emitAmountEstimated | |
797 | - | let emitInv = emit(emitAmount) | |
798 | - | if ((emitInv == emitInv)) | |
786 | + | let $t03272532877 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
787 | + | if (($t03272532877 == $t03272532877)) | |
799 | 788 | then { | |
800 | - | let lpTransfer = if (autoStake) | |
789 | + | let paymentInAmountAsset = $t03272532877._5 | |
790 | + | let bonus = $t03272532877._4 | |
791 | + | let feeAmount = $t03272532877._3 | |
792 | + | let commonState = $t03272532877._2 | |
793 | + | let emitAmountEstimated = $t03272532877._1 | |
794 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
795 | + | then (minOutAmount > emitAmountEstimated) | |
796 | + | else false) | |
797 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
798 | + | else emitAmountEstimated | |
799 | + | let emitInv = emit(emitAmount) | |
800 | + | if ((emitInv == emitInv)) | |
801 | 801 | then { | |
802 | - | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
803 | - | if ((stakeInv == stakeInv)) | |
804 | - | then nil | |
805 | - | else throw("Strict value is not equal to itself.") | |
802 | + | let lpTransfer = if (autoStake) | |
803 | + | then { | |
804 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
805 | + | if ((stakeInv == stakeInv)) | |
806 | + | then nil | |
807 | + | else throw("Strict value is not equal to itself.") | |
808 | + | } | |
809 | + | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
810 | + | let sendFee = if ((feeAmount > 0)) | |
811 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
812 | + | else nil | |
813 | + | let $t03346333660 = if ((this == feeCollectorAddress)) | |
814 | + | then $Tuple2(0, 0) | |
815 | + | else if (paymentInAmountAsset) | |
816 | + | then $Tuple2(-(feeAmount), 0) | |
817 | + | else $Tuple2(0, -(feeAmount)) | |
818 | + | let amountAssetBalanceDelta = $t03346333660._1 | |
819 | + | let priceAssetBalanceDelta = $t03346333660._2 | |
820 | + | let $t03366333771 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
821 | + | let refreshKLpActions = $t03366333771._1 | |
822 | + | let updatedKLp = $t03366333771._2 | |
823 | + | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
806 | 824 | } | |
807 | - | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
808 | - | let sendFee = if ((feeAmount > 0)) | |
809 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
810 | - | else nil | |
811 | - | let $t03346033657 = if ((this == feeCollectorAddress)) | |
812 | - | then $Tuple2(0, 0) | |
813 | - | else if (paymentInAmountAsset) | |
814 | - | then $Tuple2(-(feeAmount), 0) | |
815 | - | else $Tuple2(0, -(feeAmount)) | |
816 | - | let amountAssetBalanceDelta = $t03346033657._1 | |
817 | - | let priceAssetBalanceDelta = $t03346033657._2 | |
818 | - | let $t03366033768 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
819 | - | let refreshKLpActions = $t03366033768._1 | |
820 | - | let updatedKLp = $t03366033768._2 | |
821 | - | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
825 | + | else throw("Strict value is not equal to itself.") | |
822 | 826 | } | |
823 | 827 | else throw("Strict value is not equal to itself.") | |
824 | 828 | } | |
829 | 833 | ||
830 | 834 | @Callable(i) | |
831 | 835 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
832 | - | let $ | |
833 | - | let emitAmountEstimated = $ | |
834 | - | let commonState = $ | |
835 | - | let feeAmount = $ | |
836 | - | let bonus = $ | |
837 | - | let paymentInAmountAsset = $ | |
836 | + | let $t03396434121 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
837 | + | let emitAmountEstimated = $t03396434121._1 | |
838 | + | let commonState = $t03396434121._2 | |
839 | + | let feeAmount = $t03396434121._3 | |
840 | + | let bonus = $t03396434121._4 | |
841 | + | let paymentInAmountAsset = $t03396434121._5 | |
838 | 842 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
839 | 843 | } | |
840 | 844 | ||
868 | 872 | let paymentAmount = payment.amount | |
869 | 873 | let userAddress = i.caller | |
870 | 874 | let txId = i.transactionId | |
871 | - | let $t03492335073 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
872 | - | let amountEstimated = $t03492335073._1 | |
873 | - | let commonState = $t03492335073._2 | |
874 | - | let feeAmount = $t03492335073._3 | |
875 | - | let bonus = $t03492335073._4 | |
876 | - | let outInAmountAsset = $t03492335073._5 | |
877 | - | let amount = if (if ((minOutAmount > 0)) | |
878 | - | then (minOutAmount > amountEstimated) | |
879 | - | else false) | |
880 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
881 | - | else amountEstimated | |
882 | - | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
883 | - | if ((burnInv == burnInv)) | |
875 | + | let $t03492635079 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
876 | + | if (($t03492635079 == $t03492635079)) | |
884 | 877 | then { | |
885 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
886 | - | let sendFee = if ((feeAmount > 0)) | |
887 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
888 | - | else nil | |
889 | - | let $t03557335820 = { | |
890 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
891 | - | then 0 | |
892 | - | else feeAmount | |
893 | - | if (outInAmountAsset) | |
894 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
895 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
896 | - | } | |
897 | - | let amountAssetBalanceDelta = $t03557335820._1 | |
898 | - | let priceAssetBalanceDelta = $t03557335820._2 | |
899 | - | let $t03582335931 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
900 | - | let refreshKLpActions = $t03582335931._1 | |
901 | - | let updatedKLp = $t03582335931._2 | |
902 | - | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
878 | + | let outInAmountAsset = $t03492635079._5 | |
879 | + | let bonus = $t03492635079._4 | |
880 | + | let feeAmount = $t03492635079._3 | |
881 | + | let commonState = $t03492635079._2 | |
882 | + | let amountEstimated = $t03492635079._1 | |
883 | + | let amount = if (if ((minOutAmount > 0)) | |
884 | + | then (minOutAmount > amountEstimated) | |
885 | + | else false) | |
886 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
887 | + | else amountEstimated | |
888 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
889 | + | if ((burnInv == burnInv)) | |
890 | + | then { | |
891 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
892 | + | let sendFee = if ((feeAmount > 0)) | |
893 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
894 | + | else nil | |
895 | + | let $t03557935826 = { | |
896 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
897 | + | then 0 | |
898 | + | else feeAmount | |
899 | + | if (outInAmountAsset) | |
900 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
901 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
902 | + | } | |
903 | + | let amountAssetBalanceDelta = $t03557935826._1 | |
904 | + | let priceAssetBalanceDelta = $t03557935826._2 | |
905 | + | let $t03582935937 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
906 | + | let refreshKLpActions = $t03582935937._1 | |
907 | + | let updatedKLp = $t03582935937._2 | |
908 | + | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
909 | + | } | |
910 | + | else throw("Strict value is not equal to itself.") | |
903 | 911 | } | |
904 | 912 | else throw("Strict value is not equal to itself.") | |
905 | 913 | } | |
910 | 918 | ||
911 | 919 | @Callable(i) | |
912 | 920 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
913 | - | let $ | |
914 | - | let amountEstimated = $ | |
915 | - | let commonState = $ | |
916 | - | let feeAmount = $ | |
917 | - | let bonus = $ | |
918 | - | let outInAmountAsset = $ | |
921 | + | let $t03612136277 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
922 | + | let amountEstimated = $t03612136277._1 | |
923 | + | let commonState = $t03612136277._2 | |
924 | + | let feeAmount = $t03612136277._3 | |
925 | + | let bonus = $t03612136277._4 | |
926 | + | let outInAmountAsset = $t03612136277._5 | |
919 | 927 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
920 | 928 | } | |
921 | 929 | ||
949 | 957 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
950 | 958 | if ((unstakeInv == unstakeInv)) | |
951 | 959 | then { | |
952 | - | let $t03709637244 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
953 | - | let amountEstimated = $t03709637244._1 | |
954 | - | let commonState = $t03709637244._2 | |
955 | - | let feeAmount = $t03709637244._3 | |
956 | - | let bonus = $t03709637244._4 | |
957 | - | let outInAmountAsset = $t03709637244._5 | |
958 | - | let amount = if (if ((minOutAmount > 0)) | |
959 | - | then (minOutAmount > amountEstimated) | |
960 | - | else false) | |
961 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
962 | - | else amountEstimated | |
963 | - | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
964 | - | if ((burnInv == burnInv)) | |
960 | + | let $t03710237253 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
961 | + | if (($t03710237253 == $t03710237253)) | |
965 | 962 | then { | |
966 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
967 | - | let sendFee = if ((feeAmount > 0)) | |
968 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
969 | - | else nil | |
970 | - | let $t03773937986 = { | |
971 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
972 | - | then 0 | |
973 | - | else feeAmount | |
974 | - | if (outInAmountAsset) | |
975 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
976 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
977 | - | } | |
978 | - | let amountAssetBalanceDelta = $t03773937986._1 | |
979 | - | let priceAssetBalanceDelta = $t03773937986._2 | |
980 | - | let $t03798938097 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
981 | - | let refreshKLpActions = $t03798938097._1 | |
982 | - | let updatedKLp = $t03798938097._2 | |
983 | - | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
963 | + | let outInAmountAsset = $t03710237253._5 | |
964 | + | let bonus = $t03710237253._4 | |
965 | + | let feeAmount = $t03710237253._3 | |
966 | + | let commonState = $t03710237253._2 | |
967 | + | let amountEstimated = $t03710237253._1 | |
968 | + | let amount = if (if ((minOutAmount > 0)) | |
969 | + | then (minOutAmount > amountEstimated) | |
970 | + | else false) | |
971 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
972 | + | else amountEstimated | |
973 | + | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
974 | + | if ((burnInv == burnInv)) | |
975 | + | then { | |
976 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
977 | + | let sendFee = if ((feeAmount > 0)) | |
978 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
979 | + | else nil | |
980 | + | let $t03774837995 = { | |
981 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
982 | + | then 0 | |
983 | + | else feeAmount | |
984 | + | if (outInAmountAsset) | |
985 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
986 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
987 | + | } | |
988 | + | let amountAssetBalanceDelta = $t03774837995._1 | |
989 | + | let priceAssetBalanceDelta = $t03774837995._2 | |
990 | + | let $t03799838106 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
991 | + | let refreshKLpActions = $t03799838106._1 | |
992 | + | let updatedKLp = $t03799838106._2 | |
993 | + | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
994 | + | } | |
995 | + | else throw("Strict value is not equal to itself.") | |
984 | 996 | } | |
985 | 997 | else throw("Strict value is not equal to itself.") | |
986 | 998 | } | |
1002 | 1014 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1003 | 1015 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1004 | 1016 | then { | |
1005 | - | let $ | |
1006 | - | let refreshKLpActions = $ | |
1007 | - | let updatedKLp = $ | |
1017 | + | let $t03889838980 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1018 | + | let refreshKLpActions = $t03889838980._1 | |
1019 | + | let updatedKLp = $t03889838980._2 | |
1008 | 1020 | (state ++ refreshKLpActions) | |
1009 | 1021 | } | |
1010 | 1022 | else throw("Strict value is not equal to itself.") | |
1028 | 1040 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1029 | 1041 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1030 | 1042 | then { | |
1031 | - | let $ | |
1032 | - | let refreshKLpActions = $ | |
1033 | - | let updatedKLp = $ | |
1043 | + | let $t03977639857 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1044 | + | let refreshKLpActions = $t03977639857._1 | |
1045 | + | let updatedKLp = $t03977639857._2 | |
1034 | 1046 | (state ++ refreshKLpActions) | |
1035 | 1047 | } | |
1036 | 1048 | else throw("Strict value is not equal to itself.") | |
1066 | 1078 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1067 | 1079 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1068 | 1080 | then { | |
1069 | - | let $ | |
1070 | - | let refreshKLpActions = $ | |
1071 | - | let updatedKLp = $ | |
1081 | + | let $t04083040911 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1082 | + | let refreshKLpActions = $t04083040911._1 | |
1083 | + | let updatedKLp = $t04083040911._2 | |
1072 | 1084 | (state ++ refreshKLpActions) | |
1073 | 1085 | } | |
1074 | 1086 | else throw("Strict value is not equal to itself.") | |
1111 | 1123 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1112 | 1124 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1113 | 1125 | then { | |
1114 | - | let $ | |
1115 | - | let refreshKLpActions = $ | |
1116 | - | let updatedKLp = $ | |
1126 | + | let $t04205142132 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1127 | + | let refreshKLpActions = $t04205142132._1 | |
1128 | + | let updatedKLp = $t04205142132._2 | |
1117 | 1129 | (state ++ refreshKLpActions) | |
1118 | 1130 | } | |
1119 | 1131 | else throw("Strict value is not equal to itself.") | |
1142 | 1154 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1143 | 1155 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1144 | 1156 | then { | |
1145 | - | let $ | |
1146 | - | let actions = $ | |
1147 | - | let updatedKLp = $ | |
1157 | + | let $t04312043175 = refreshKLpInternal(0, 0, 0) | |
1158 | + | let actions = $t04312043175._1 | |
1159 | + | let updatedKLp = $t04312043175._2 | |
1148 | 1160 | $Tuple2(actions, toString(updatedKLp)) | |
1149 | 1161 | } | |
1150 | 1162 | else throw("Strict value is not equal to itself.") |
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, 0, DOWN), scale18, lpEmission) | |
378 | 378 | updatedKLp | |
379 | 379 | } | |
380 | 380 | ||
381 | 381 | ||
382 | 382 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
383 | 383 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
384 | 384 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
385 | 385 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
386 | 386 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
387 | 387 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
388 | 388 | $Tuple2(actions, updatedKLp) | |
389 | 389 | } | |
390 | 390 | ||
391 | 391 | ||
392 | 392 | func validateMatcherOrderAllowed (order) = { | |
393 | 393 | let cfg = getPoolConfig() | |
394 | 394 | let amtAssetId = cfg[idxAmtAssetId] | |
395 | 395 | let priceAssetId = cfg[idxPriceAssetId] | |
396 | 396 | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
397 | 397 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
398 | 398 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
399 | 399 | let amountAssetAmount = order.amount | |
400 | 400 | let priceAssetAmount = fraction(order.amount, order.price, scale8) | |
401 | 401 | let $t01983820050 = if ((order.orderType == Buy)) | |
402 | 402 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
403 | 403 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
404 | 404 | let amountAssetBalanceDelta = $t01983820050._1 | |
405 | 405 | let priceAssetBalanceDelta = $t01983820050._2 | |
406 | 406 | if (if (if (isGlobalShutdown()) | |
407 | 407 | then true | |
408 | 408 | else (poolStatus == PoolMatcherDisabled)) | |
409 | 409 | then true | |
410 | 410 | else (poolStatus == PoolShutdown)) | |
411 | 411 | then throw("Exchange operations disabled") | |
412 | 412 | else { | |
413 | 413 | let orderAmtAssetStr = assetIdToString(value(order.assetPair.amountAsset)) | |
414 | 414 | let orderPriceAssetStr = assetIdToString(value(order.assetPair.priceAsset)) | |
415 | 415 | if (if ((orderAmtAssetStr != amtAssetId)) | |
416 | 416 | then true | |
417 | 417 | else (orderPriceAssetStr != priceAssetId)) | |
418 | 418 | then throw("Wrong order assets.") | |
419 | 419 | else { | |
420 | 420 | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
421 | 421 | let $t02064520745 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
422 | 422 | let unusedActions = $t02064520745._1 | |
423 | 423 | let kLpNew = $t02064520745._2 | |
424 | 424 | let isOrderValid = (kLpNew > kLp) | |
425 | 425 | isOrderValid | |
426 | 426 | } | |
427 | 427 | } | |
428 | 428 | } | |
429 | 429 | ||
430 | 430 | ||
431 | 431 | func commonGet (i) = if ((size(i.payments) != 1)) | |
432 | 432 | then throw("exactly 1 payment is expected") | |
433 | 433 | else { | |
434 | 434 | let pmt = value(i.payments[0]) | |
435 | 435 | let pmtAssetId = value(pmt.assetId) | |
436 | 436 | let pmtAmt = pmt.amount | |
437 | 437 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
438 | 438 | let outAmAmt = res._1 | |
439 | 439 | let outPrAmt = res._2 | |
440 | 440 | let poolStatus = parseIntValue(res._9) | |
441 | 441 | let state = res._10 | |
442 | 442 | if (if (isGlobalShutdown()) | |
443 | 443 | then true | |
444 | 444 | else (poolStatus == PoolShutdown)) | |
445 | 445 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
446 | 446 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
447 | 447 | } | |
448 | 448 | ||
449 | 449 | ||
450 | 450 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
451 | 451 | then throw("exactly 2 payments are expected") | |
452 | 452 | else { | |
453 | 453 | let amAssetPmt = value(i.payments[0]) | |
454 | 454 | let prAssetPmt = value(i.payments[1]) | |
455 | 455 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
456 | 456 | let poolStatus = parseIntValue(estPut._8) | |
457 | 457 | if (if (if (isGlobalShutdown()) | |
458 | 458 | then true | |
459 | 459 | else (poolStatus == PoolPutDisabled)) | |
460 | 460 | then true | |
461 | 461 | else (poolStatus == PoolShutdown)) | |
462 | 462 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
463 | 463 | else estPut | |
464 | 464 | } | |
465 | 465 | ||
466 | 466 | ||
467 | 467 | func emit (amount) = { | |
468 | 468 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
469 | 469 | if ((emitInv == emitInv)) | |
470 | 470 | then { | |
471 | 471 | let emitInvLegacy = match emitInv { | |
472 | 472 | case legacyFactoryContract: Address => | |
473 | 473 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
474 | 474 | case _ => | |
475 | 475 | unit | |
476 | 476 | } | |
477 | 477 | if ((emitInvLegacy == emitInvLegacy)) | |
478 | 478 | then amount | |
479 | 479 | else throw("Strict value is not equal to itself.") | |
480 | 480 | } | |
481 | 481 | else throw("Strict value is not equal to itself.") | |
482 | 482 | } | |
483 | 483 | ||
484 | 484 | ||
485 | 485 | func takeFee (amount) = { | |
486 | 486 | let feeAmount = fraction(amount, fee, scale8) | |
487 | 487 | $Tuple2((amount - feeAmount), feeAmount) | |
488 | 488 | } | |
489 | 489 | ||
490 | 490 | ||
491 | 491 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
492 | 492 | let isEval = (txId == unit) | |
493 | 493 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
494 | 494 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
495 | 495 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
496 | 496 | then true | |
497 | 497 | else if ((paymentAssetId == cfgPriceAssetId)) | |
498 | 498 | then false | |
499 | 499 | else throwErr("invalid asset") | |
500 | 500 | let $t02342923722 = if (isEval) | |
501 | 501 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
502 | 502 | else if (paymentInAmountAsset) | |
503 | 503 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
504 | 504 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
505 | 505 | let amountBalanceOld = $t02342923722._1 | |
506 | 506 | let priceBalanceOld = $t02342923722._2 | |
507 | 507 | let $t02372623875 = if (paymentInAmountAsset) | |
508 | 508 | then $Tuple2(paymentAmountRaw, 0) | |
509 | 509 | else $Tuple2(0, paymentAmountRaw) | |
510 | 510 | let amountAssetAmountRaw = $t02372623875._1 | |
511 | 511 | let priceAssetAmountRaw = $t02372623875._2 | |
512 | 512 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
513 | 513 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
514 | 514 | let $t02399724056 = takeFee(paymentAmountRaw) | |
515 | 515 | let paymentAmount = $t02399724056._1 | |
516 | 516 | let feeAmount = $t02399724056._2 | |
517 | 517 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
518 | 518 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
519 | 519 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
520 | 520 | let priceNew = fromX18(priceNewX18, scale8) | |
521 | 521 | let paymentBalance = if (paymentInAmountAsset) | |
522 | 522 | then amountBalanceOld | |
523 | 523 | else priceBalanceOld | |
524 | 524 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
525 | 525 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
526 | 526 | let chechSupply = if ((supplyBigInt > big0)) | |
527 | 527 | then true | |
528 | 528 | else throwErr("initial deposit requires all coins") | |
529 | 529 | if ((chechSupply == chechSupply)) | |
530 | 530 | then { | |
531 | 531 | let depositBigInt = toBigInt(paymentAmount) | |
532 | 532 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
533 | 533 | let commonState = if (isEval) | |
534 | 534 | then nil | |
535 | 535 | 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))] | |
536 | 536 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
537 | 537 | let priceOld = fromX18(priceOldX18, scale8) | |
538 | 538 | let loss = { | |
539 | 539 | let $t02553325700 = if (paymentInAmountAsset) | |
540 | 540 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
541 | 541 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
542 | 542 | let amount = $t02553325700._1 | |
543 | 543 | let balance = $t02553325700._2 | |
544 | 544 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
545 | 545 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
546 | 546 | } | |
547 | 547 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
548 | 548 | } | |
549 | 549 | else throw("Strict value is not equal to itself.") | |
550 | 550 | } | |
551 | 551 | ||
552 | 552 | ||
553 | 553 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
554 | 554 | let isEval = (txId == unit) | |
555 | 555 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
556 | 556 | then true | |
557 | 557 | else throwErr("invalid lp asset")] | |
558 | 558 | if ((checks == checks)) | |
559 | 559 | then { | |
560 | 560 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
561 | 561 | then true | |
562 | 562 | else if ((outAssetId == cfgPriceAssetId)) | |
563 | 563 | then false | |
564 | 564 | else throwErr("invalid asset") | |
565 | 565 | let balanceBigInt = if (outInAmountAsset) | |
566 | 566 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
567 | 567 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
568 | 568 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
569 | 569 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
570 | 570 | let outBalance = if (outInAmountAsset) | |
571 | 571 | then amBalanceOld | |
572 | 572 | else prBalanceOld | |
573 | 573 | let outBalanceBigInt = toBigInt(outBalance) | |
574 | 574 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
575 | 575 | let redeemedBigInt = toBigInt(paymentAmount) | |
576 | 576 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
577 | 577 | let $t02730227352 = takeFee(amountRaw) | |
578 | 578 | let totalAmount = $t02730227352._1 | |
579 | 579 | let feeAmount = $t02730227352._2 | |
580 | 580 | let $t02735627582 = if (outInAmountAsset) | |
581 | 581 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
582 | 582 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
583 | 583 | let outAmAmount = $t02735627582._1 | |
584 | 584 | let outPrAmount = $t02735627582._2 | |
585 | 585 | let amBalanceNew = $t02735627582._3 | |
586 | 586 | let prBalanceNew = $t02735627582._4 | |
587 | 587 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
588 | 588 | let priceNew = fromX18(priceNewX18, scale8) | |
589 | 589 | let commonState = if (isEval) | |
590 | 590 | then nil | |
591 | 591 | 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)] | |
592 | 592 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
593 | 593 | let priceOld = fromX18(priceOldX18, scale8) | |
594 | 594 | let loss = { | |
595 | 595 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
596 | 596 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
597 | 597 | } | |
598 | 598 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
599 | 599 | } | |
600 | 600 | else throw("Strict value is not equal to itself.") | |
601 | 601 | } | |
602 | 602 | ||
603 | 603 | ||
604 | 604 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
605 | 605 | case s: String => | |
606 | 606 | fromBase58String(s) | |
607 | 607 | case _: Unit => | |
608 | 608 | unit | |
609 | 609 | case _ => | |
610 | 610 | throw("Match error") | |
611 | 611 | } | |
612 | 612 | ||
613 | 613 | ||
614 | 614 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
615 | 615 | case s: String => | |
616 | 616 | fromBase58String(s) | |
617 | 617 | case _: Unit => | |
618 | 618 | unit | |
619 | 619 | case _ => | |
620 | 620 | throw("Match error") | |
621 | 621 | } | |
622 | 622 | ||
623 | 623 | ||
624 | 624 | func isManager (i) = match managerPublicKeyOrUnit() { | |
625 | 625 | case pk: ByteVector => | |
626 | 626 | (i.callerPublicKey == pk) | |
627 | 627 | case _: Unit => | |
628 | 628 | (i.caller == this) | |
629 | 629 | case _ => | |
630 | 630 | throw("Match error") | |
631 | 631 | } | |
632 | 632 | ||
633 | 633 | ||
634 | 634 | func mustManager (i) = { | |
635 | 635 | let pd = throw("Permission denied") | |
636 | 636 | match managerPublicKeyOrUnit() { | |
637 | 637 | case pk: ByteVector => | |
638 | 638 | if ((i.callerPublicKey == pk)) | |
639 | 639 | then true | |
640 | 640 | else pd | |
641 | 641 | case _: Unit => | |
642 | 642 | if ((i.caller == this)) | |
643 | 643 | then true | |
644 | 644 | else pd | |
645 | 645 | case _ => | |
646 | 646 | throw("Match error") | |
647 | 647 | } | |
648 | 648 | } | |
649 | 649 | ||
650 | 650 | ||
651 | 651 | @Callable(i) | |
652 | 652 | func setManager (pendingManagerPublicKey) = { | |
653 | 653 | let checkCaller = mustManager(i) | |
654 | 654 | if ((checkCaller == checkCaller)) | |
655 | 655 | then { | |
656 | 656 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
657 | 657 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
658 | 658 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
659 | 659 | else throw("Strict value is not equal to itself.") | |
660 | 660 | } | |
661 | 661 | else throw("Strict value is not equal to itself.") | |
662 | 662 | } | |
663 | 663 | ||
664 | 664 | ||
665 | 665 | ||
666 | 666 | @Callable(i) | |
667 | 667 | func confirmManager () = { | |
668 | 668 | let pm = pendingManagerPublicKeyOrUnit() | |
669 | 669 | let hasPM = if (isDefined(pm)) | |
670 | 670 | then true | |
671 | 671 | else throw("No pending manager") | |
672 | 672 | if ((hasPM == hasPM)) | |
673 | 673 | then { | |
674 | 674 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
675 | 675 | then true | |
676 | 676 | else throw("You are not pending manager") | |
677 | 677 | if ((checkPM == checkPM)) | |
678 | 678 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
679 | 679 | else throw("Strict value is not equal to itself.") | |
680 | 680 | } | |
681 | 681 | else throw("Strict value is not equal to itself.") | |
682 | 682 | } | |
683 | 683 | ||
684 | 684 | ||
685 | 685 | ||
686 | 686 | @Callable(i) | |
687 | 687 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
688 | 688 | then throw("Invalid slippageTolerance passed") | |
689 | 689 | else { | |
690 | 690 | let estPut = commonPut(i, slippageTolerance, true) | |
691 | 691 | let emitLpAmt = estPut._2 | |
692 | 692 | let lpAssetId = estPut._7 | |
693 | 693 | let state = estPut._9 | |
694 | 694 | let amDiff = estPut._10 | |
695 | 695 | let prDiff = estPut._11 | |
696 | 696 | let amId = estPut._12 | |
697 | 697 | let prId = estPut._13 | |
698 | 698 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
699 | 699 | if ((emitInv == emitInv)) | |
700 | 700 | then { | |
701 | 701 | let emitInvLegacy = match emitInv { | |
702 | 702 | case legacyFactoryContract: Address => | |
703 | 703 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
704 | 704 | case _ => | |
705 | 705 | unit | |
706 | 706 | } | |
707 | 707 | if ((emitInvLegacy == emitInvLegacy)) | |
708 | 708 | then { | |
709 | 709 | let slippageAInv = if ((amDiff > 0)) | |
710 | 710 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
711 | 711 | else nil | |
712 | 712 | if ((slippageAInv == slippageAInv)) | |
713 | 713 | then { | |
714 | 714 | let slippagePInv = if ((prDiff > 0)) | |
715 | 715 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
716 | 716 | else nil | |
717 | 717 | if ((slippagePInv == slippagePInv)) | |
718 | 718 | then { | |
719 | 719 | let lpTransfer = if (shouldAutoStake) | |
720 | 720 | then { | |
721 | 721 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
722 | 722 | if ((slpStakeInv == slpStakeInv)) | |
723 | 723 | then nil | |
724 | 724 | else throw("Strict value is not equal to itself.") | |
725 | 725 | } | |
726 | 726 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
727 | 727 | let $t03153331598 = refreshKLpInternal(0, 0, 0) | |
728 | 728 | let refreshKLpActions = $t03153331598._1 | |
729 | 729 | let updatedKLp = $t03153331598._2 | |
730 | 730 | ((state ++ lpTransfer) ++ refreshKLpActions) | |
731 | 731 | } | |
732 | 732 | else throw("Strict value is not equal to itself.") | |
733 | 733 | } | |
734 | 734 | else throw("Strict value is not equal to itself.") | |
735 | 735 | } | |
736 | 736 | else throw("Strict value is not equal to itself.") | |
737 | 737 | } | |
738 | 738 | else throw("Strict value is not equal to itself.") | |
739 | 739 | } | |
740 | 740 | ||
741 | 741 | ||
742 | 742 | ||
743 | 743 | @Callable(i) | |
744 | 744 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
745 | 745 | then throw("Invalid value passed") | |
746 | 746 | else { | |
747 | 747 | let estPut = commonPut(i, maxSlippage, false) | |
748 | 748 | let state = estPut._9 | |
749 | 749 | let $t03188431949 = refreshKLpInternal(0, 0, 0) | |
750 | 750 | let refreshKLpActions = $t03188431949._1 | |
751 | 751 | let updatedKLp = $t03188431949._2 | |
752 | 752 | (state ++ refreshKLpActions) | |
753 | 753 | } | |
754 | 754 | ||
755 | 755 | ||
756 | 756 | ||
757 | 757 | @Callable(i) | |
758 | 758 | func putOneTkn (minOutAmount,autoStake) = { | |
759 | 759 | let isPoolOneTokenOperationsDisabled = { | |
760 | 760 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
761 | 761 | if ($isInstanceOf(@, "Boolean")) | |
762 | 762 | then @ | |
763 | 763 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
764 | 764 | } | |
765 | 765 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
766 | 766 | then true | |
767 | 767 | else (cfgPoolStatus == PoolPutDisabled)) | |
768 | 768 | then true | |
769 | 769 | else (cfgPoolStatus == PoolShutdown)) | |
770 | 770 | then true | |
771 | 771 | else isPoolOneTokenOperationsDisabled | |
772 | 772 | let checks = [if (if (!(isPutDisabled)) | |
773 | 773 | then true | |
774 | 774 | else isManager(i)) | |
775 | 775 | then true | |
776 | 776 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
777 | 777 | then true | |
778 | 778 | else throwErr("exactly 1 payment are expected")] | |
779 | 779 | if ((checks == checks)) | |
780 | 780 | then { | |
781 | 781 | let payment = i.payments[0] | |
782 | 782 | let paymentAssetId = payment.assetId | |
783 | 783 | let paymentAmountRaw = payment.amount | |
784 | 784 | let userAddress = i.caller | |
785 | 785 | let txId = i.transactionId | |
786 | - | let $t03272532874 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
787 | - | let emitAmountEstimated = $t03272532874._1 | |
788 | - | let commonState = $t03272532874._2 | |
789 | - | let feeAmount = $t03272532874._3 | |
790 | - | let bonus = $t03272532874._4 | |
791 | - | let paymentInAmountAsset = $t03272532874._5 | |
792 | - | let emitAmount = if (if ((minOutAmount > 0)) | |
793 | - | then (minOutAmount > emitAmountEstimated) | |
794 | - | else false) | |
795 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
796 | - | else emitAmountEstimated | |
797 | - | let emitInv = emit(emitAmount) | |
798 | - | if ((emitInv == emitInv)) | |
786 | + | let $t03272532877 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
787 | + | if (($t03272532877 == $t03272532877)) | |
799 | 788 | then { | |
800 | - | let lpTransfer = if (autoStake) | |
789 | + | let paymentInAmountAsset = $t03272532877._5 | |
790 | + | let bonus = $t03272532877._4 | |
791 | + | let feeAmount = $t03272532877._3 | |
792 | + | let commonState = $t03272532877._2 | |
793 | + | let emitAmountEstimated = $t03272532877._1 | |
794 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
795 | + | then (minOutAmount > emitAmountEstimated) | |
796 | + | else false) | |
797 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
798 | + | else emitAmountEstimated | |
799 | + | let emitInv = emit(emitAmount) | |
800 | + | if ((emitInv == emitInv)) | |
801 | 801 | then { | |
802 | - | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
803 | - | if ((stakeInv == stakeInv)) | |
804 | - | then nil | |
805 | - | else throw("Strict value is not equal to itself.") | |
802 | + | let lpTransfer = if (autoStake) | |
803 | + | then { | |
804 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
805 | + | if ((stakeInv == stakeInv)) | |
806 | + | then nil | |
807 | + | else throw("Strict value is not equal to itself.") | |
808 | + | } | |
809 | + | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
810 | + | let sendFee = if ((feeAmount > 0)) | |
811 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
812 | + | else nil | |
813 | + | let $t03346333660 = if ((this == feeCollectorAddress)) | |
814 | + | then $Tuple2(0, 0) | |
815 | + | else if (paymentInAmountAsset) | |
816 | + | then $Tuple2(-(feeAmount), 0) | |
817 | + | else $Tuple2(0, -(feeAmount)) | |
818 | + | let amountAssetBalanceDelta = $t03346333660._1 | |
819 | + | let priceAssetBalanceDelta = $t03346333660._2 | |
820 | + | let $t03366333771 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
821 | + | let refreshKLpActions = $t03366333771._1 | |
822 | + | let updatedKLp = $t03366333771._2 | |
823 | + | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
806 | 824 | } | |
807 | - | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
808 | - | let sendFee = if ((feeAmount > 0)) | |
809 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
810 | - | else nil | |
811 | - | let $t03346033657 = if ((this == feeCollectorAddress)) | |
812 | - | then $Tuple2(0, 0) | |
813 | - | else if (paymentInAmountAsset) | |
814 | - | then $Tuple2(-(feeAmount), 0) | |
815 | - | else $Tuple2(0, -(feeAmount)) | |
816 | - | let amountAssetBalanceDelta = $t03346033657._1 | |
817 | - | let priceAssetBalanceDelta = $t03346033657._2 | |
818 | - | let $t03366033768 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
819 | - | let refreshKLpActions = $t03366033768._1 | |
820 | - | let updatedKLp = $t03366033768._2 | |
821 | - | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
825 | + | else throw("Strict value is not equal to itself.") | |
822 | 826 | } | |
823 | 827 | else throw("Strict value is not equal to itself.") | |
824 | 828 | } | |
825 | 829 | else throw("Strict value is not equal to itself.") | |
826 | 830 | } | |
827 | 831 | ||
828 | 832 | ||
829 | 833 | ||
830 | 834 | @Callable(i) | |
831 | 835 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
832 | - | let $ | |
833 | - | let emitAmountEstimated = $ | |
834 | - | let commonState = $ | |
835 | - | let feeAmount = $ | |
836 | - | let bonus = $ | |
837 | - | let paymentInAmountAsset = $ | |
836 | + | let $t03396434121 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
837 | + | let emitAmountEstimated = $t03396434121._1 | |
838 | + | let commonState = $t03396434121._2 | |
839 | + | let feeAmount = $t03396434121._3 | |
840 | + | let bonus = $t03396434121._4 | |
841 | + | let paymentInAmountAsset = $t03396434121._5 | |
838 | 842 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
839 | 843 | } | |
840 | 844 | ||
841 | 845 | ||
842 | 846 | ||
843 | 847 | @Callable(i) | |
844 | 848 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
845 | 849 | let isPoolOneTokenOperationsDisabled = { | |
846 | 850 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
847 | 851 | if ($isInstanceOf(@, "Boolean")) | |
848 | 852 | then @ | |
849 | 853 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
850 | 854 | } | |
851 | 855 | let isGetDisabled = if (if (isGlobalShutdown()) | |
852 | 856 | then true | |
853 | 857 | else (cfgPoolStatus == PoolShutdown)) | |
854 | 858 | then true | |
855 | 859 | else isPoolOneTokenOperationsDisabled | |
856 | 860 | let checks = [if (if (!(isGetDisabled)) | |
857 | 861 | then true | |
858 | 862 | else isManager(i)) | |
859 | 863 | then true | |
860 | 864 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
861 | 865 | then true | |
862 | 866 | else throwErr("exactly 1 payment are expected")] | |
863 | 867 | if ((checks == checks)) | |
864 | 868 | then { | |
865 | 869 | let outAssetId = parseAssetId(outAssetIdStr) | |
866 | 870 | let payment = i.payments[0] | |
867 | 871 | let paymentAssetId = payment.assetId | |
868 | 872 | let paymentAmount = payment.amount | |
869 | 873 | let userAddress = i.caller | |
870 | 874 | let txId = i.transactionId | |
871 | - | let $t03492335073 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
872 | - | let amountEstimated = $t03492335073._1 | |
873 | - | let commonState = $t03492335073._2 | |
874 | - | let feeAmount = $t03492335073._3 | |
875 | - | let bonus = $t03492335073._4 | |
876 | - | let outInAmountAsset = $t03492335073._5 | |
877 | - | let amount = if (if ((minOutAmount > 0)) | |
878 | - | then (minOutAmount > amountEstimated) | |
879 | - | else false) | |
880 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
881 | - | else amountEstimated | |
882 | - | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
883 | - | if ((burnInv == burnInv)) | |
875 | + | let $t03492635079 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
876 | + | if (($t03492635079 == $t03492635079)) | |
884 | 877 | then { | |
885 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
886 | - | let sendFee = if ((feeAmount > 0)) | |
887 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
888 | - | else nil | |
889 | - | let $t03557335820 = { | |
890 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
891 | - | then 0 | |
892 | - | else feeAmount | |
893 | - | if (outInAmountAsset) | |
894 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
895 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
896 | - | } | |
897 | - | let amountAssetBalanceDelta = $t03557335820._1 | |
898 | - | let priceAssetBalanceDelta = $t03557335820._2 | |
899 | - | let $t03582335931 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
900 | - | let refreshKLpActions = $t03582335931._1 | |
901 | - | let updatedKLp = $t03582335931._2 | |
902 | - | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
878 | + | let outInAmountAsset = $t03492635079._5 | |
879 | + | let bonus = $t03492635079._4 | |
880 | + | let feeAmount = $t03492635079._3 | |
881 | + | let commonState = $t03492635079._2 | |
882 | + | let amountEstimated = $t03492635079._1 | |
883 | + | let amount = if (if ((minOutAmount > 0)) | |
884 | + | then (minOutAmount > amountEstimated) | |
885 | + | else false) | |
886 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
887 | + | else amountEstimated | |
888 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
889 | + | if ((burnInv == burnInv)) | |
890 | + | then { | |
891 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
892 | + | let sendFee = if ((feeAmount > 0)) | |
893 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
894 | + | else nil | |
895 | + | let $t03557935826 = { | |
896 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
897 | + | then 0 | |
898 | + | else feeAmount | |
899 | + | if (outInAmountAsset) | |
900 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
901 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
902 | + | } | |
903 | + | let amountAssetBalanceDelta = $t03557935826._1 | |
904 | + | let priceAssetBalanceDelta = $t03557935826._2 | |
905 | + | let $t03582935937 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
906 | + | let refreshKLpActions = $t03582935937._1 | |
907 | + | let updatedKLp = $t03582935937._2 | |
908 | + | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
909 | + | } | |
910 | + | else throw("Strict value is not equal to itself.") | |
903 | 911 | } | |
904 | 912 | else throw("Strict value is not equal to itself.") | |
905 | 913 | } | |
906 | 914 | else throw("Strict value is not equal to itself.") | |
907 | 915 | } | |
908 | 916 | ||
909 | 917 | ||
910 | 918 | ||
911 | 919 | @Callable(i) | |
912 | 920 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
913 | - | let $ | |
914 | - | let amountEstimated = $ | |
915 | - | let commonState = $ | |
916 | - | let feeAmount = $ | |
917 | - | let bonus = $ | |
918 | - | let outInAmountAsset = $ | |
921 | + | let $t03612136277 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
922 | + | let amountEstimated = $t03612136277._1 | |
923 | + | let commonState = $t03612136277._2 | |
924 | + | let feeAmount = $t03612136277._3 | |
925 | + | let bonus = $t03612136277._4 | |
926 | + | let outInAmountAsset = $t03612136277._5 | |
919 | 927 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
920 | 928 | } | |
921 | 929 | ||
922 | 930 | ||
923 | 931 | ||
924 | 932 | @Callable(i) | |
925 | 933 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
926 | 934 | let isPoolOneTokenOperationsDisabled = { | |
927 | 935 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
928 | 936 | if ($isInstanceOf(@, "Boolean")) | |
929 | 937 | then @ | |
930 | 938 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
931 | 939 | } | |
932 | 940 | let isGetDisabled = if (if (isGlobalShutdown()) | |
933 | 941 | then true | |
934 | 942 | else (cfgPoolStatus == PoolShutdown)) | |
935 | 943 | then true | |
936 | 944 | else isPoolOneTokenOperationsDisabled | |
937 | 945 | let checks = [if (if (!(isGetDisabled)) | |
938 | 946 | then true | |
939 | 947 | else isManager(i)) | |
940 | 948 | then true | |
941 | 949 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
942 | 950 | then true | |
943 | 951 | else throwErr("no payments are expected")] | |
944 | 952 | if ((checks == checks)) | |
945 | 953 | then { | |
946 | 954 | let outAssetId = parseAssetId(outAssetIdStr) | |
947 | 955 | let userAddress = i.caller | |
948 | 956 | let txId = i.transactionId | |
949 | 957 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
950 | 958 | if ((unstakeInv == unstakeInv)) | |
951 | 959 | then { | |
952 | - | let $t03709637244 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
953 | - | let amountEstimated = $t03709637244._1 | |
954 | - | let commonState = $t03709637244._2 | |
955 | - | let feeAmount = $t03709637244._3 | |
956 | - | let bonus = $t03709637244._4 | |
957 | - | let outInAmountAsset = $t03709637244._5 | |
958 | - | let amount = if (if ((minOutAmount > 0)) | |
959 | - | then (minOutAmount > amountEstimated) | |
960 | - | else false) | |
961 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
962 | - | else amountEstimated | |
963 | - | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
964 | - | if ((burnInv == burnInv)) | |
960 | + | let $t03710237253 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
961 | + | if (($t03710237253 == $t03710237253)) | |
965 | 962 | then { | |
966 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
967 | - | let sendFee = if ((feeAmount > 0)) | |
968 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
969 | - | else nil | |
970 | - | let $t03773937986 = { | |
971 | - | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
972 | - | then 0 | |
973 | - | else feeAmount | |
974 | - | if (outInAmountAsset) | |
975 | - | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
976 | - | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
977 | - | } | |
978 | - | let amountAssetBalanceDelta = $t03773937986._1 | |
979 | - | let priceAssetBalanceDelta = $t03773937986._2 | |
980 | - | let $t03798938097 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
981 | - | let refreshKLpActions = $t03798938097._1 | |
982 | - | let updatedKLp = $t03798938097._2 | |
983 | - | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
963 | + | let outInAmountAsset = $t03710237253._5 | |
964 | + | let bonus = $t03710237253._4 | |
965 | + | let feeAmount = $t03710237253._3 | |
966 | + | let commonState = $t03710237253._2 | |
967 | + | let amountEstimated = $t03710237253._1 | |
968 | + | let amount = if (if ((minOutAmount > 0)) | |
969 | + | then (minOutAmount > amountEstimated) | |
970 | + | else false) | |
971 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
972 | + | else amountEstimated | |
973 | + | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
974 | + | if ((burnInv == burnInv)) | |
975 | + | then { | |
976 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
977 | + | let sendFee = if ((feeAmount > 0)) | |
978 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
979 | + | else nil | |
980 | + | let $t03774837995 = { | |
981 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
982 | + | then 0 | |
983 | + | else feeAmount | |
984 | + | if (outInAmountAsset) | |
985 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
986 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
987 | + | } | |
988 | + | let amountAssetBalanceDelta = $t03774837995._1 | |
989 | + | let priceAssetBalanceDelta = $t03774837995._2 | |
990 | + | let $t03799838106 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
991 | + | let refreshKLpActions = $t03799838106._1 | |
992 | + | let updatedKLp = $t03799838106._2 | |
993 | + | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
994 | + | } | |
995 | + | else throw("Strict value is not equal to itself.") | |
984 | 996 | } | |
985 | 997 | else throw("Strict value is not equal to itself.") | |
986 | 998 | } | |
987 | 999 | else throw("Strict value is not equal to itself.") | |
988 | 1000 | } | |
989 | 1001 | else throw("Strict value is not equal to itself.") | |
990 | 1002 | } | |
991 | 1003 | ||
992 | 1004 | ||
993 | 1005 | ||
994 | 1006 | @Callable(i) | |
995 | 1007 | func get () = { | |
996 | 1008 | let res = commonGet(i) | |
997 | 1009 | let outAmtAmt = res._1 | |
998 | 1010 | let outPrAmt = res._2 | |
999 | 1011 | let pmtAmt = res._3 | |
1000 | 1012 | let pmtAssetId = res._4 | |
1001 | 1013 | let state = res._5 | |
1002 | 1014 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1003 | 1015 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1004 | 1016 | then { | |
1005 | - | let $ | |
1006 | - | let refreshKLpActions = $ | |
1007 | - | let updatedKLp = $ | |
1017 | + | let $t03889838980 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1018 | + | let refreshKLpActions = $t03889838980._1 | |
1019 | + | let updatedKLp = $t03889838980._2 | |
1008 | 1020 | (state ++ refreshKLpActions) | |
1009 | 1021 | } | |
1010 | 1022 | else throw("Strict value is not equal to itself.") | |
1011 | 1023 | } | |
1012 | 1024 | ||
1013 | 1025 | ||
1014 | 1026 | ||
1015 | 1027 | @Callable(i) | |
1016 | 1028 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1017 | 1029 | let res = commonGet(i) | |
1018 | 1030 | let outAmAmt = res._1 | |
1019 | 1031 | let outPrAmt = res._2 | |
1020 | 1032 | let pmtAmt = res._3 | |
1021 | 1033 | let pmtAssetId = res._4 | |
1022 | 1034 | let state = res._5 | |
1023 | 1035 | if ((noLessThenAmtAsset > outAmAmt)) | |
1024 | 1036 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1025 | 1037 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1026 | 1038 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1027 | 1039 | else { | |
1028 | 1040 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1029 | 1041 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1030 | 1042 | then { | |
1031 | - | let $ | |
1032 | - | let refreshKLpActions = $ | |
1033 | - | let updatedKLp = $ | |
1043 | + | let $t03977639857 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1044 | + | let refreshKLpActions = $t03977639857._1 | |
1045 | + | let updatedKLp = $t03977639857._2 | |
1034 | 1046 | (state ++ refreshKLpActions) | |
1035 | 1047 | } | |
1036 | 1048 | else throw("Strict value is not equal to itself.") | |
1037 | 1049 | } | |
1038 | 1050 | } | |
1039 | 1051 | ||
1040 | 1052 | ||
1041 | 1053 | ||
1042 | 1054 | @Callable(i) | |
1043 | 1055 | func unstakeAndGet (amount) = { | |
1044 | 1056 | let checkPayments = if ((size(i.payments) != 0)) | |
1045 | 1057 | then throw("No payments are expected") | |
1046 | 1058 | else true | |
1047 | 1059 | if ((checkPayments == checkPayments)) | |
1048 | 1060 | then { | |
1049 | 1061 | let cfg = getPoolConfig() | |
1050 | 1062 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1051 | 1063 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1052 | 1064 | if ((unstakeInv == unstakeInv)) | |
1053 | 1065 | then { | |
1054 | 1066 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1055 | 1067 | let outAmAmt = res._1 | |
1056 | 1068 | let outPrAmt = res._2 | |
1057 | 1069 | let poolStatus = parseIntValue(res._9) | |
1058 | 1070 | let state = res._10 | |
1059 | 1071 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1060 | 1072 | then true | |
1061 | 1073 | else (poolStatus == PoolShutdown)) | |
1062 | 1074 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1063 | 1075 | else true | |
1064 | 1076 | if ((checkPoolStatus == checkPoolStatus)) | |
1065 | 1077 | then { | |
1066 | 1078 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1067 | 1079 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1068 | 1080 | then { | |
1069 | - | let $ | |
1070 | - | let refreshKLpActions = $ | |
1071 | - | let updatedKLp = $ | |
1081 | + | let $t04083040911 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1082 | + | let refreshKLpActions = $t04083040911._1 | |
1083 | + | let updatedKLp = $t04083040911._2 | |
1072 | 1084 | (state ++ refreshKLpActions) | |
1073 | 1085 | } | |
1074 | 1086 | else throw("Strict value is not equal to itself.") | |
1075 | 1087 | } | |
1076 | 1088 | else throw("Strict value is not equal to itself.") | |
1077 | 1089 | } | |
1078 | 1090 | else throw("Strict value is not equal to itself.") | |
1079 | 1091 | } | |
1080 | 1092 | else throw("Strict value is not equal to itself.") | |
1081 | 1093 | } | |
1082 | 1094 | ||
1083 | 1095 | ||
1084 | 1096 | ||
1085 | 1097 | @Callable(i) | |
1086 | 1098 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1087 | 1099 | let isGetDisabled = if (isGlobalShutdown()) | |
1088 | 1100 | then true | |
1089 | 1101 | else (cfgPoolStatus == PoolShutdown) | |
1090 | 1102 | let checks = [if (!(isGetDisabled)) | |
1091 | 1103 | then true | |
1092 | 1104 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1093 | 1105 | then true | |
1094 | 1106 | else throw("no payments are expected")] | |
1095 | 1107 | if ((checks == checks)) | |
1096 | 1108 | then { | |
1097 | 1109 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1098 | 1110 | if ((unstakeInv == unstakeInv)) | |
1099 | 1111 | then { | |
1100 | 1112 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1101 | 1113 | let outAmAmt = res._1 | |
1102 | 1114 | let outPrAmt = res._2 | |
1103 | 1115 | let state = res._10 | |
1104 | 1116 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1105 | 1117 | then true | |
1106 | 1118 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1107 | 1119 | then true | |
1108 | 1120 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1109 | 1121 | if ((checkAmounts == checkAmounts)) | |
1110 | 1122 | then { | |
1111 | 1123 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1112 | 1124 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1113 | 1125 | then { | |
1114 | - | let $ | |
1115 | - | let refreshKLpActions = $ | |
1116 | - | let updatedKLp = $ | |
1126 | + | let $t04205142132 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1127 | + | let refreshKLpActions = $t04205142132._1 | |
1128 | + | let updatedKLp = $t04205142132._2 | |
1117 | 1129 | (state ++ refreshKLpActions) | |
1118 | 1130 | } | |
1119 | 1131 | else throw("Strict value is not equal to itself.") | |
1120 | 1132 | } | |
1121 | 1133 | else throw("Strict value is not equal to itself.") | |
1122 | 1134 | } | |
1123 | 1135 | else throw("Strict value is not equal to itself.") | |
1124 | 1136 | } | |
1125 | 1137 | else throw("Strict value is not equal to itself.") | |
1126 | 1138 | } | |
1127 | 1139 | ||
1128 | 1140 | ||
1129 | 1141 | ||
1130 | 1142 | @Callable(i) | |
1131 | 1143 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1132 | 1144 | then throw("permissions denied") | |
1133 | 1145 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1134 | 1146 | ||
1135 | 1147 | ||
1136 | 1148 | ||
1137 | 1149 | @Callable(i) | |
1138 | 1150 | func refreshKLp () = { | |
1139 | 1151 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1140 | 1152 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1141 | 1153 | then unit | |
1142 | 1154 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1143 | 1155 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1144 | 1156 | then { | |
1145 | - | let $ | |
1146 | - | let actions = $ | |
1147 | - | let updatedKLp = $ | |
1157 | + | let $t04312043175 = refreshKLpInternal(0, 0, 0) | |
1158 | + | let actions = $t04312043175._1 | |
1159 | + | let updatedKLp = $t04312043175._2 | |
1148 | 1160 | $Tuple2(actions, toString(updatedKLp)) | |
1149 | 1161 | } | |
1150 | 1162 | else throw("Strict value is not equal to itself.") | |
1151 | 1163 | } | |
1152 | 1164 | ||
1153 | 1165 | ||
1154 | 1166 | ||
1155 | 1167 | @Callable(i) | |
1156 | 1168 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1157 | 1169 | ||
1158 | 1170 | ||
1159 | 1171 | ||
1160 | 1172 | @Callable(i) | |
1161 | 1173 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1162 | 1174 | ||
1163 | 1175 | ||
1164 | 1176 | ||
1165 | 1177 | @Callable(i) | |
1166 | 1178 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1167 | 1179 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1168 | 1180 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1169 | 1181 | } | |
1170 | 1182 | ||
1171 | 1183 | ||
1172 | 1184 | ||
1173 | 1185 | @Callable(i) | |
1174 | 1186 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1175 | 1187 | ||
1176 | 1188 | ||
1177 | 1189 | ||
1178 | 1190 | @Callable(i) | |
1179 | 1191 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1180 | 1192 | ||
1181 | 1193 | ||
1182 | 1194 | ||
1183 | 1195 | @Callable(i) | |
1184 | 1196 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1185 | 1197 | ||
1186 | 1198 | ||
1187 | 1199 | ||
1188 | 1200 | @Callable(i) | |
1189 | 1201 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1190 | 1202 | ||
1191 | 1203 | ||
1192 | 1204 | ||
1193 | 1205 | @Callable(i) | |
1194 | 1206 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1195 | 1207 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1196 | 1208 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1197 | 1209 | } | |
1198 | 1210 | ||
1199 | 1211 | ||
1200 | 1212 | ||
1201 | 1213 | @Callable(i) | |
1202 | 1214 | func statsREADONLY () = { | |
1203 | 1215 | let cfg = getPoolConfig() | |
1204 | 1216 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1205 | 1217 | let amtAssetId = cfg[idxAmtAssetId] | |
1206 | 1218 | let priceAssetId = cfg[idxPriceAssetId] | |
1207 | 1219 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1208 | 1220 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1209 | 1221 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1210 | 1222 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1211 | 1223 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1212 | 1224 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1213 | 1225 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1214 | 1226 | let pricesList = if ((poolLPBalance == 0)) | |
1215 | 1227 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1216 | 1228 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1217 | 1229 | let curPrice = 0 | |
1218 | 1230 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1219 | 1231 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1220 | 1232 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1221 | 1233 | $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)) | |
1222 | 1234 | } | |
1223 | 1235 | ||
1224 | 1236 | ||
1225 | 1237 | ||
1226 | 1238 | @Callable(i) | |
1227 | 1239 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1228 | 1240 | let cfg = getPoolConfig() | |
1229 | 1241 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1230 | 1242 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1231 | 1243 | let amAssetId = fromBase58String(amAssetIdStr) | |
1232 | 1244 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1233 | 1245 | let prAssetId = fromBase58String(prAssetIdStr) | |
1234 | 1246 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1235 | 1247 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1236 | 1248 | let poolStatus = cfg[idxPoolStatus] | |
1237 | 1249 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1238 | 1250 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1239 | 1251 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1240 | 1252 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1241 | 1253 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1242 | 1254 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1243 | 1255 | then zeroBigInt | |
1244 | 1256 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1245 | 1257 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1246 | 1258 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1247 | 1259 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1248 | 1260 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1249 | 1261 | let calcLpAmt = estPut._1 | |
1250 | 1262 | let curPriceCalc = estPut._3 | |
1251 | 1263 | let amBalance = estPut._4 | |
1252 | 1264 | let prBalance = estPut._5 | |
1253 | 1265 | let lpEmission = estPut._6 | |
1254 | 1266 | $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)) | |
1255 | 1267 | } | |
1256 | 1268 | ||
1257 | 1269 | ||
1258 | 1270 | ||
1259 | 1271 | @Callable(i) | |
1260 | 1272 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1261 | 1273 | let cfg = getPoolConfig() | |
1262 | 1274 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1263 | 1275 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1264 | 1276 | let amAssetId = fromBase58String(amAssetIdStr) | |
1265 | 1277 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1266 | 1278 | let prAssetId = fromBase58String(prAssetIdStr) | |
1267 | 1279 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1268 | 1280 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1269 | 1281 | let poolStatus = cfg[idxPoolStatus] | |
1270 | 1282 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1271 | 1283 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1272 | 1284 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1273 | 1285 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1274 | 1286 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1275 | 1287 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1276 | 1288 | then zeroBigInt | |
1277 | 1289 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1278 | 1290 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1279 | 1291 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1280 | 1292 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1281 | 1293 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1282 | 1294 | let calcLpAmt = estPut._1 | |
1283 | 1295 | let curPriceCalc = estPut._3 | |
1284 | 1296 | let amBalance = estPut._4 | |
1285 | 1297 | let prBalance = estPut._5 | |
1286 | 1298 | let lpEmission = estPut._6 | |
1287 | 1299 | $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)) | |
1288 | 1300 | } | |
1289 | 1301 | ||
1290 | 1302 | ||
1291 | 1303 | ||
1292 | 1304 | @Callable(i) | |
1293 | 1305 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1294 | 1306 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1295 | 1307 | let outAmAmt = res._1 | |
1296 | 1308 | let outPrAmt = res._2 | |
1297 | 1309 | let amBalance = res._5 | |
1298 | 1310 | let prBalance = res._6 | |
1299 | 1311 | let lpEmission = res._7 | |
1300 | 1312 | let curPrice = res._8 | |
1301 | 1313 | let poolStatus = parseIntValue(res._9) | |
1302 | 1314 | $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)) | |
1303 | 1315 | } | |
1304 | 1316 | ||
1305 | 1317 | ||
1306 | 1318 | @Verifier(tx) | |
1307 | 1319 | func verify () = { | |
1308 | 1320 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1309 | 1321 | case pk: ByteVector => | |
1310 | 1322 | pk | |
1311 | 1323 | case _: Unit => | |
1312 | 1324 | tx.senderPublicKey | |
1313 | 1325 | case _ => | |
1314 | 1326 | throw("Match error") | |
1315 | 1327 | } | |
1316 | 1328 | match tx { | |
1317 | 1329 | case order: Order => | |
1318 | 1330 | let matcherPub = getMatcherPubOrFail() | |
1319 | 1331 | let orderValid = validateMatcherOrderAllowed(order) | |
1320 | 1332 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1321 | 1333 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1322 | 1334 | if (if (if (orderValid) | |
1323 | 1335 | then senderValid | |
1324 | 1336 | else false) | |
1325 | 1337 | then matcherValid | |
1326 | 1338 | else false) | |
1327 | 1339 | then true | |
1328 | 1340 | else throwOrderError(orderValid, senderValid, matcherValid) | |
1329 | 1341 | case s: SetScriptTransaction => | |
1330 | 1342 | let newHash = blake2b256(value(s.script)) | |
1331 | 1343 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1332 | 1344 | let currentHash = scriptHash(this) | |
1333 | 1345 | if (if ((allowedHash == newHash)) | |
1334 | 1346 | then (currentHash != newHash) | |
1335 | 1347 | else false) | |
1336 | 1348 | then true | |
1337 | 1349 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1338 | 1350 | case _ => | |
1339 | 1351 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1340 | 1352 | } | |
1341 | 1353 | } | |
1342 | 1354 |
github/deemru/w8io/026f985 135.31 ms ◑