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