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