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