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