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