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