tx · AWYtP1AhZwTeeY9ZNmZb6wTEyvQm5opQ7Gaa8eDGFRUX 3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt: -0.04300000 Waves 2023.04.05 11:51 [2521028] smart account 3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt > SELF 0.00000000 Waves
{ "type": 13, "id": "AWYtP1AhZwTeeY9ZNmZb6wTEyvQm5opQ7Gaa8eDGFRUX", "fee": 4300000, "feeAssetId": null, "timestamp": 1680684703602, "version": 2, "chainId": 84, "sender": "3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt", "senderPublicKey": "Aig94J3pRT3J41eXw33rJrs67gTCECiMVRZrbtuoARit", "proofs": [ "moL2oZ3iB21rpFn75SeSiVkwbh8Ri1C44f5qi8kgCHXhjw6qv6CxVLabqapJoPo2YPdQsRPm9FZzQcgJJWwQCWQ" ], "script": "base64:BgLENwgCEgASBQoDAQQBEgcKBQEEAQgBEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEG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EFAmR3CQDMCAIJAKQDAQUCZHQJAMwIAgkApgMBBQJkegkAzAgCCQCkAwEFAmRzBQNuaWwFAWoBAmlsAQJpbQAEAmluBAJiWAkBAmdpAAMJAAECBQJiWAIKQnl0ZVZlY3RvcgQCZ20FAmJYBQJnbQMJAAECBQJiWAIEVW5pdAgFAmlsD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yBAJiWAUCaWwDCQABAgUCYlgCBU9yZGVyBAJlTAUCYlgEAmlvCQECYmQABAJpcAkBAmVLAQUCZUwEAmFLCAUCaXACXzEEAmFMCAUCaXACXzIEAmFNCQD0AwMIBQJlTAlib2R5Qnl0ZXMJAJEDAggFAmVMBnByb29mcwAACAUCZUwPc2VuZGVyUHVibGljS2V5BAJhTgkA9AMDCAUCZUwJYm9keUJ5dGVzCQCRAwIIBQJlTAZwcm9vZnMAAQUCaW8DAwMFAmFLBQJhTQcFAmFOBwYJAQJhSgQFAmFLBQJhTAUCYU0FAmFOAwkAAQIFAmJYAhRTZXRTY3JpcHRUcmFuc2FjdGlvbgQCZ2oFAmJYAwkA9AMDCAUCaWwJYm9keUJ5dGVzCQCRAwIIBQJpbAZwcm9vZnMAAAUCaW4GBAJpcQkA9gMBCQEFdmFsdWUBCAUCZ2oGc2NyaXB0BAJpcgkA2wQBCQEFdmFsdWUBCQCdCAIFAmFWCQECYUgABAJpcwkA8QcBBQR0aGlzAwkAAAIFAmlyBQJpcQkBAiE9AgUCaXMFAmlxBwkA9AMDCAUCaWwJYm9keUJ5dGVzCQCRAwIIBQJpbAZwcm9vZnMAAAUCaW4Trefl", "height": 2521028, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9qQ6X1T13bqxRr7K6NghYqRmHord1Xpf8SmWA3diTisq Next: GrHZ4cfkLfXobMgWSizqFsZApU3cjhehrPz1Z5ZKGSzh Diff:
Old | New | Differences | |
---|---|---|---|
430 | 430 | } | |
431 | 431 | ||
432 | 432 | ||
433 | - | func | |
433 | + | func getWithdrawAssetState (assetId,getAmount) = match getLeaseProxyConfig(assetId) { | |
434 | 434 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
435 | - | let $ | |
436 | - | let isLeasable = $ | |
437 | - | let leasedRatio = $ | |
438 | - | let minBalance = $ | |
439 | - | let proxyAddress = $ | |
440 | - | let proxyAssetId = $ | |
441 | - | let proxyRateMul = $ | |
442 | - | let stakingProfitAddress = $ | |
435 | + | let $t01651616625 = a | |
436 | + | let isLeasable = $t01651616625._1 | |
437 | + | let leasedRatio = $t01651616625._2 | |
438 | + | let minBalance = $t01651616625._3 | |
439 | + | let proxyAddress = $t01651616625._4 | |
440 | + | let proxyAssetId = $t01651616625._5 | |
441 | + | let proxyRateMul = $t01651616625._6 | |
442 | + | let stakingProfitAddress = $t01651616625._7 | |
443 | 443 | if (isLeasable) | |
444 | - | then withdraw(assetId, amount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
444 | + | then { | |
445 | + | let newTotalCalcBalance = max([0, ((getAccBalance(assetId) - getAmount) - minBalance)]) | |
446 | + | if ((newTotalCalcBalance == newTotalCalcBalance)) | |
447 | + | then { | |
448 | + | let newAdditionalBalance = fraction(leasedRatio, newTotalCalcBalance, 100) | |
449 | + | if ((newAdditionalBalance == newAdditionalBalance)) | |
450 | + | then { | |
451 | + | let withdrawAmount = max([0, (getAdditionalBalanceOrZero(assetId) - newAdditionalBalance)]) | |
452 | + | if ((withdrawAmount == withdrawAmount)) | |
453 | + | then withdraw(assetId, withdrawAmount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
454 | + | else throw("Strict value is not equal to itself.") | |
455 | + | } | |
456 | + | else throw("Strict value is not equal to itself.") | |
457 | + | } | |
458 | + | else throw("Strict value is not equal to itself.") | |
459 | + | } | |
445 | 460 | else nil | |
446 | 461 | case _ => | |
447 | - | throwErr((("[" + assetId) + "] | |
462 | + | throwErr((("[" + assetId) + "] getWithdrawAssetState() error")) | |
448 | 463 | } | |
449 | - | ||
450 | - | ||
451 | - | func getWithdrawAssetState (assetId,amount) = { | |
452 | - | let assetOnPool = match parseAssetId(assetId) { | |
453 | - | case b: ByteVector => | |
454 | - | assetBalance(this, b) | |
455 | - | case w: Unit => | |
456 | - | wavesBalance(this).available | |
457 | - | case _ => | |
458 | - | throw("Match error") | |
459 | - | } | |
460 | - | if ((amount > assetOnPool)) | |
461 | - | then { | |
462 | - | let amountDiff = (amount - assetOnPool) | |
463 | - | withdrawAssetWrapper(assetId, amountDiff) | |
464 | - | } | |
465 | - | else nil | |
466 | - | } | |
467 | 464 | ||
468 | 465 | ||
469 | 466 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
523 | 520 | let PrAmtWithdrawState = getWithdrawAssetState(prAssetId, outPrAmt) | |
524 | 521 | if ((PrAmtWithdrawState == PrAmtWithdrawState)) | |
525 | 522 | then { | |
526 | - | let reb = invoke(this, "rebalance", nil, nil) | |
527 | - | if ((reb == reb)) | |
528 | - | then { | |
529 | - | let state = if ((txId58 == "")) | |
530 | - | then nil | |
531 | - | else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
532 | - | then unit | |
533 | - | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
534 | - | then unit | |
535 | - | 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)]) | |
536 | - | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
537 | - | } | |
538 | - | else throw("Strict value is not equal to itself.") | |
523 | + | let state = if ((txId58 == "")) | |
524 | + | then nil | |
525 | + | else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
526 | + | then unit | |
527 | + | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
528 | + | then unit | |
529 | + | 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)]) | |
530 | + | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
539 | 531 | } | |
540 | 532 | else throw("Strict value is not equal to itself.") | |
541 | 533 | } | |
660 | 652 | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
661 | 653 | let amountAssetAmount = order.amount | |
662 | 654 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
663 | - | let $ | |
655 | + | let $t02870728919 = if ((order.orderType == Buy)) | |
664 | 656 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
665 | 657 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
666 | - | let amountAssetBalanceDelta = $ | |
667 | - | let priceAssetBalanceDelta = $ | |
658 | + | let amountAssetBalanceDelta = $t02870728919._1 | |
659 | + | let priceAssetBalanceDelta = $t02870728919._2 | |
668 | 660 | if (if (if (isGlobalShutdown()) | |
669 | 661 | then true | |
670 | 662 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
677 | 669 | then throw("Wrong order assets.") | |
678 | 670 | else { | |
679 | 671 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
680 | - | let $ | |
681 | - | let unusedActions = $ | |
682 | - | let kLpNew = $ | |
672 | + | let $t02935929459 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
673 | + | let unusedActions = $t02935929459._1 | |
674 | + | let kLpNew = $t02935929459._2 | |
683 | 675 | let isOrderValid = (kLpNew >= kLp) | |
684 | 676 | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
685 | 677 | $Tuple2(isOrderValid, info) | |
758 | 750 | else if ((paymentAssetId == cfgPriceAssetId)) | |
759 | 751 | then false | |
760 | 752 | else throwErr("invalid asset") | |
761 | - | let $ | |
753 | + | let $t03257232865 = if (isEval) | |
762 | 754 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
763 | 755 | else if (paymentInAmountAsset) | |
764 | 756 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
765 | 757 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
766 | - | let amountBalanceOld = $ | |
767 | - | let priceBalanceOld = $ | |
768 | - | let $ | |
758 | + | let amountBalanceOld = $t03257232865._1 | |
759 | + | let priceBalanceOld = $t03257232865._2 | |
760 | + | let $t03286933018 = if (paymentInAmountAsset) | |
769 | 761 | then $Tuple2(paymentAmountRaw, 0) | |
770 | 762 | else $Tuple2(0, paymentAmountRaw) | |
771 | - | let amountAssetAmountRaw = $ | |
772 | - | let priceAssetAmountRaw = $ | |
763 | + | let amountAssetAmountRaw = $t03286933018._1 | |
764 | + | let priceAssetAmountRaw = $t03286933018._2 | |
773 | 765 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
774 | 766 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
775 | - | let $ | |
776 | - | let paymentAmount = $ | |
777 | - | let feeAmount = $ | |
767 | + | let $t03315033214 = takeFee(paymentAmountRaw, inFee) | |
768 | + | let paymentAmount = $t03315033214._1 | |
769 | + | let feeAmount = $t03315033214._2 | |
778 | 770 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
779 | 771 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
780 | 772 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
797 | 789 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
798 | 790 | let priceOld = fromX18(priceOldX18, scale8) | |
799 | 791 | let loss = { | |
800 | - | let $ | |
792 | + | let $t03489535062 = if (paymentInAmountAsset) | |
801 | 793 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
802 | 794 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
803 | - | let amount = $ | |
804 | - | let balance = $ | |
795 | + | let amount = $t03489535062._1 | |
796 | + | let balance = $t03489535062._2 | |
805 | 797 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
806 | 798 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
807 | 799 | } | |
841 | 833 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
842 | 834 | let redeemedBigInt = toBigInt(paymentAmount) | |
843 | 835 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
844 | - | let $ | |
845 | - | let totalAmount = $ | |
846 | - | let feeAmount = $ | |
847 | - | let $ | |
836 | + | let $t03714037196 = takeFee(amountRaw, outFee) | |
837 | + | let totalAmount = $t03714037196._1 | |
838 | + | let feeAmount = $t03714037196._2 | |
839 | + | let $t03720037426 = if (outInAmountAsset) | |
848 | 840 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
849 | 841 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
850 | - | let outAmAmount = $ | |
851 | - | let outPrAmount = $ | |
852 | - | let amBalanceNew = $ | |
853 | - | let prBalanceNew = $ | |
842 | + | let outAmAmount = $t03720037426._1 | |
843 | + | let outPrAmount = $t03720037426._2 | |
844 | + | let amBalanceNew = $t03720037426._3 | |
845 | + | let prBalanceNew = $t03720037426._4 | |
854 | 846 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
855 | 847 | let priceNew = fromX18(priceNewX18, scale8) | |
856 | 848 | let commonState = if (isEval) | |
922 | 914 | ||
923 | 915 | @Callable(i) | |
924 | 916 | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = { | |
925 | - | let $ | |
917 | + | let $t03931239617 = if ((isReverse == false)) | |
926 | 918 | then { | |
927 | 919 | let assetOut = getStringOrFail(this, pa()) | |
928 | 920 | let assetIn = getStringOrFail(this, aa()) | |
933 | 925 | let assetIn = getStringOrFail(this, pa()) | |
934 | 926 | $Tuple2(assetOut, assetIn) | |
935 | 927 | } | |
936 | - | let assetOut = $ | |
937 | - | let assetIn = $ | |
928 | + | let assetOut = $t03931239617._1 | |
929 | + | let assetIn = $t03931239617._2 | |
938 | 930 | let poolAssetInBalance = getAccBalance(assetIn) | |
939 | 931 | let poolAssetOutBalance = getAccBalance(assetOut) | |
940 | 932 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
993 | 985 | } | |
994 | 986 | let withdrawState = getWithdrawAssetState(assetOut, amountOut) | |
995 | 987 | if ((withdrawState == withdrawState)) | |
996 | - | then { | |
997 | - | let reb = invoke(this, "rebalance", nil, nil) | |
998 | - | if ((reb == reb)) | |
999 | - | then $Tuple2((withdrawState ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut) | |
1000 | - | else throw("Strict value is not equal to itself.") | |
1001 | - | } | |
988 | + | then $Tuple2((withdrawState ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut) | |
1002 | 989 | else throw("Strict value is not equal to itself.") | |
1003 | 990 | } | |
1004 | 991 | else throw("Strict value is not equal to itself.") | |
1091 | 1078 | else throw("Strict value is not equal to itself.") | |
1092 | 1079 | } | |
1093 | 1080 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1094 | - | let $ | |
1095 | - | if (($ | |
1081 | + | let $t04477045232 = refreshKLpInternal(0, 0, 0) | |
1082 | + | if (($t04477045232 == $t04477045232)) | |
1096 | 1083 | then { | |
1097 | - | let updatedKLp = $ | |
1098 | - | let refreshKLpActions = $ | |
1084 | + | let updatedKLp = $t04477045232._2 | |
1085 | + | let refreshKLpActions = $t04477045232._1 | |
1099 | 1086 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1100 | 1087 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1101 | 1088 | then { | |
1132 | 1119 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1133 | 1120 | if ((currentKLp == currentKLp)) | |
1134 | 1121 | then { | |
1135 | - | let $ | |
1136 | - | let refreshKLpActions = $ | |
1137 | - | let updatedKLp = $ | |
1122 | + | let $t04584445909 = refreshKLpInternal(0, 0, 0) | |
1123 | + | let refreshKLpActions = $t04584445909._1 | |
1124 | + | let updatedKLp = $t04584445909._2 | |
1138 | 1125 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1139 | 1126 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1140 | 1127 | then (state ++ refreshKLpActions) | |
1181 | 1168 | then { | |
1182 | 1169 | let userAddress = i.caller | |
1183 | 1170 | let txId = i.transactionId | |
1184 | - | let $ | |
1185 | - | if (($ | |
1171 | + | let $t04709747249 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
1172 | + | if (($t04709747249 == $t04709747249)) | |
1186 | 1173 | then { | |
1187 | - | let paymentInAmountAsset = $ | |
1188 | - | let bonus = $ | |
1189 | - | let feeAmount = $ | |
1190 | - | let commonState = $ | |
1191 | - | let emitAmountEstimated = $ | |
1174 | + | let paymentInAmountAsset = $t04709747249._5 | |
1175 | + | let bonus = $t04709747249._4 | |
1176 | + | let feeAmount = $t04709747249._3 | |
1177 | + | let commonState = $t04709747249._2 | |
1178 | + | let emitAmountEstimated = $t04709747249._1 | |
1192 | 1179 | let emitAmount = if (if ((minOutAmount > 0)) | |
1193 | 1180 | then (minOutAmount > emitAmountEstimated) | |
1194 | 1181 | else false) | |
1208 | 1195 | let sendFee = if ((feeAmount > 0)) | |
1209 | 1196 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
1210 | 1197 | else nil | |
1211 | - | let $ | |
1198 | + | let $t04783548032 = if ((this == feeCollectorAddress)) | |
1212 | 1199 | then $Tuple2(0, 0) | |
1213 | 1200 | else if (paymentInAmountAsset) | |
1214 | 1201 | then $Tuple2(-(feeAmount), 0) | |
1215 | 1202 | else $Tuple2(0, -(feeAmount)) | |
1216 | - | let amountAssetBalanceDelta = $ | |
1217 | - | let priceAssetBalanceDelta = $ | |
1218 | - | let $ | |
1219 | - | let refreshKLpActions = $ | |
1220 | - | let updatedKLp = $ | |
1203 | + | let amountAssetBalanceDelta = $t04783548032._1 | |
1204 | + | let priceAssetBalanceDelta = $t04783548032._2 | |
1205 | + | let $t04803548143 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1206 | + | let refreshKLpActions = $t04803548143._1 | |
1207 | + | let updatedKLp = $t04803548143._2 | |
1221 | 1208 | let kLp = value(getString(keyKLp)) | |
1222 | 1209 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1223 | 1210 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1242 | 1229 | ||
1243 | 1230 | @Callable(i) | |
1244 | 1231 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
1245 | - | let $ | |
1246 | - | let emitAmountEstimated = $ | |
1247 | - | let commonState = $ | |
1248 | - | let feeAmount = $ | |
1249 | - | let bonus = $ | |
1250 | - | let paymentInAmountAsset = $ | |
1232 | + | let $t04849848655 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
1233 | + | let emitAmountEstimated = $t04849848655._1 | |
1234 | + | let commonState = $t04849848655._2 | |
1235 | + | let feeAmount = $t04849848655._3 | |
1236 | + | let bonus = $t04849848655._4 | |
1237 | + | let paymentInAmountAsset = $t04849848655._5 | |
1251 | 1238 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
1252 | 1239 | } | |
1253 | 1240 | ||
1284 | 1271 | then { | |
1285 | 1272 | let userAddress = i.caller | |
1286 | 1273 | let txId = i.transactionId | |
1287 | - | let $ | |
1288 | - | if (($ | |
1274 | + | let $t04954049693 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
1275 | + | if (($t04954049693 == $t04954049693)) | |
1289 | 1276 | then { | |
1290 | - | let outInAmountAsset = $ | |
1291 | - | let bonus = $ | |
1292 | - | let feeAmount = $ | |
1293 | - | let commonState = $ | |
1294 | - | let amountEstimated = $ | |
1277 | + | let outInAmountAsset = $t04954049693._5 | |
1278 | + | let bonus = $t04954049693._4 | |
1279 | + | let feeAmount = $t04954049693._3 | |
1280 | + | let commonState = $t04954049693._2 | |
1281 | + | let amountEstimated = $t04954049693._1 | |
1295 | 1282 | let amount = if (if ((minOutAmount > 0)) | |
1296 | 1283 | then (minOutAmount > amountEstimated) | |
1297 | 1284 | else false) | |
1313 | 1300 | let sendFee = if ((feeAmount > 0)) | |
1314 | 1301 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1315 | 1302 | else nil | |
1316 | - | let $ | |
1303 | + | let $t05044950696 = { | |
1317 | 1304 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1318 | 1305 | then 0 | |
1319 | 1306 | else feeAmount | |
1321 | 1308 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1322 | 1309 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1323 | 1310 | } | |
1324 | - | let amountAssetBalanceDelta = $ | |
1325 | - | let priceAssetBalanceDelta = $ | |
1326 | - | let $ | |
1327 | - | let refreshKLpActions = $ | |
1328 | - | let updatedKLp = $ | |
1311 | + | let amountAssetBalanceDelta = $t05044950696._1 | |
1312 | + | let priceAssetBalanceDelta = $t05044950696._2 | |
1313 | + | let $t05069950807 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1314 | + | let refreshKLpActions = $t05069950807._1 | |
1315 | + | let updatedKLp = $t05069950807._2 | |
1329 | 1316 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1330 | 1317 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1331 | - | then { | |
1332 | - | let reb = invoke(this, "rebalance", nil, nil) | |
1333 | - | if ((reb == reb)) | |
1334 | - | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1335 | - | else throw("Strict value is not equal to itself.") | |
1336 | - | } | |
1318 | + | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1337 | 1319 | else throw("Strict value is not equal to itself.") | |
1338 | 1320 | } | |
1339 | 1321 | else throw("Strict value is not equal to itself.") | |
1351 | 1333 | ||
1352 | 1334 | @Callable(i) | |
1353 | 1335 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
1354 | - | let $ | |
1355 | - | let amountEstimated = $ | |
1356 | - | let commonState = $ | |
1357 | - | let feeAmount = $ | |
1358 | - | let bonus = $ | |
1359 | - | let outInAmountAsset = $ | |
1336 | + | let $t05108551241 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1337 | + | let amountEstimated = $t05108551241._1 | |
1338 | + | let commonState = $t05108551241._2 | |
1339 | + | let feeAmount = $t05108551241._3 | |
1340 | + | let bonus = $t05108551241._4 | |
1341 | + | let outInAmountAsset = $t05108551241._5 | |
1360 | 1342 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
1361 | 1343 | } | |
1362 | 1344 | ||
1393 | 1375 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1394 | 1376 | if ((unstakeInv == unstakeInv)) | |
1395 | 1377 | then { | |
1396 | - | let $ | |
1397 | - | if (($ | |
1378 | + | let $t05214652297 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1379 | + | if (($t05214652297 == $t05214652297)) | |
1398 | 1380 | then { | |
1399 | - | let outInAmountAsset = $ | |
1400 | - | let bonus = $ | |
1401 | - | let feeAmount = $ | |
1402 | - | let commonState = $ | |
1403 | - | let amountEstimated = $ | |
1381 | + | let outInAmountAsset = $t05214652297._5 | |
1382 | + | let bonus = $t05214652297._4 | |
1383 | + | let feeAmount = $t05214652297._3 | |
1384 | + | let commonState = $t05214652297._2 | |
1385 | + | let amountEstimated = $t05214652297._1 | |
1404 | 1386 | let amount = if (if ((minOutAmount > 0)) | |
1405 | 1387 | then (minOutAmount > amountEstimated) | |
1406 | 1388 | else false) | |
1416 | 1398 | let sendFee = if ((feeAmount > 0)) | |
1417 | 1399 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1418 | 1400 | else nil | |
1419 | - | let $ | |
1401 | + | let $t05286253109 = { | |
1420 | 1402 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1421 | 1403 | then 0 | |
1422 | 1404 | else feeAmount | |
1424 | 1406 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1425 | 1407 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1426 | 1408 | } | |
1427 | - | let amountAssetBalanceDelta = $ | |
1428 | - | let priceAssetBalanceDelta = $ | |
1429 | - | let $ | |
1430 | - | let refreshKLpActions = $ | |
1431 | - | let updatedKLp = $ | |
1409 | + | let amountAssetBalanceDelta = $t05286253109._1 | |
1410 | + | let priceAssetBalanceDelta = $t05286253109._2 | |
1411 | + | let $t05311253220 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1412 | + | let refreshKLpActions = $t05311253220._1 | |
1413 | + | let updatedKLp = $t05311253220._2 | |
1432 | 1414 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1433 | 1415 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1434 | - | then { | |
1435 | - | let reb = invoke(this, "rebalance", nil, nil) | |
1436 | - | if ((reb == reb)) | |
1437 | - | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1438 | - | else throw("Strict value is not equal to itself.") | |
1439 | - | } | |
1416 | + | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1440 | 1417 | else throw("Strict value is not equal to itself.") | |
1441 | 1418 | } | |
1442 | 1419 | else throw("Strict value is not equal to itself.") | |
1468 | 1445 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1469 | 1446 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1470 | 1447 | then { | |
1471 | - | let $ | |
1472 | - | let refreshKLpActions = $ | |
1473 | - | let updatedKLp = $ | |
1448 | + | let $t05418754269 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1449 | + | let refreshKLpActions = $t05418754269._1 | |
1450 | + | let updatedKLp = $t05418754269._2 | |
1474 | 1451 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1475 | 1452 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1476 | 1453 | then (state ++ refreshKLpActions) | |
1502 | 1479 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1503 | 1480 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1504 | 1481 | then { | |
1505 | - | let $ | |
1506 | - | let refreshKLpActions = $ | |
1507 | - | let updatedKLp = $ | |
1482 | + | let $t05521855299 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1483 | + | let refreshKLpActions = $t05521855299._1 | |
1484 | + | let updatedKLp = $t05521855299._2 | |
1508 | 1485 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1509 | 1486 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1510 | 1487 | then (state ++ refreshKLpActions) | |
1548 | 1525 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1549 | 1526 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1550 | 1527 | then { | |
1551 | - | let $ | |
1552 | - | let refreshKLpActions = $ | |
1553 | - | let updatedKLp = $ | |
1528 | + | let $t05642556506 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1529 | + | let refreshKLpActions = $t05642556506._1 | |
1530 | + | let updatedKLp = $t05642556506._2 | |
1554 | 1531 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1555 | 1532 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1556 | 1533 | then (state ++ refreshKLpActions) | |
1601 | 1578 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1602 | 1579 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1603 | 1580 | then { | |
1604 | - | let $ | |
1605 | - | let refreshKLpActions = $ | |
1606 | - | let updatedKLp = $ | |
1581 | + | let $t05780157882 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1582 | + | let refreshKLpActions = $t05780157882._1 | |
1583 | + | let updatedKLp = $t05780157882._2 | |
1607 | 1584 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1608 | 1585 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1609 | 1586 | then (state ++ refreshKLpActions) | |
1638 | 1615 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1639 | 1616 | then { | |
1640 | 1617 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1641 | - | let $ | |
1642 | - | let kLpUpdateActions = $ | |
1643 | - | let updatedKLp = $ | |
1618 | + | let $t05906959133 = refreshKLpInternal(0, 0, 0) | |
1619 | + | let kLpUpdateActions = $t05906959133._1 | |
1620 | + | let updatedKLp = $t05906959133._2 | |
1644 | 1621 | let actions = if ((kLp != updatedKLp)) | |
1645 | 1622 | then kLpUpdateActions | |
1646 | 1623 | else throwErr("nothing to refresh") | |
1815 | 1792 | match tx { | |
1816 | 1793 | case order: Order => | |
1817 | 1794 | let matcherPub = getMatcherPubOrFail() | |
1818 | - | let $ | |
1819 | - | let orderValid = $ | |
1820 | - | let orderValidInfo = $ | |
1795 | + | let $t06779567864 = validateMatcherOrderAllowed(order) | |
1796 | + | let orderValid = $t06779567864._1 | |
1797 | + | let orderValidInfo = $t06779567864._2 | |
1821 | 1798 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1822 | 1799 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1823 | 1800 | if (if (if (orderValid) |
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 toX18BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func abs (val) = if ((0 > val)) | |
78 | 78 | then -(val) | |
79 | 79 | else val | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func absBigInt (val) = if ((zeroBigInt > val)) | |
83 | 83 | then -(val) | |
84 | 84 | else val | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func swapContract () = "%s__swapContract" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func fc () = "%s__factoryContract" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func mpk () = "%s__managerPublicKey" | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pmpk () = "%s__pendingManagerPublicKey" | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func pl () = "%s%s__price__last" | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | func aa () = "%s__amountAsset" | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | func pa () = "%s__priceAsset" | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | let keyFee = "%s__fee" | |
118 | 118 | ||
119 | 119 | let feeDefault = fraction(10, scale8, 10000) | |
120 | 120 | ||
121 | 121 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
122 | 122 | ||
123 | 123 | let keyKLp = makeString(["%s", "kLp"], SEP) | |
124 | 124 | ||
125 | 125 | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
126 | 126 | ||
127 | 127 | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
128 | 128 | ||
129 | 129 | let kLpRefreshDelayDefault = 30 | |
130 | 130 | ||
131 | 131 | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
132 | 132 | ||
133 | 133 | func keySWavesAssetId () = "%s__sWavesAssetId" | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func keySWavesProxyAddress () = "%s__sWavesProxyAddress" | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func keyAdditionalBalance (assetId) = makeString(["%s%s", "additionalBalance", assetId], SEP) | |
140 | 140 | ||
141 | 141 | ||
142 | 142 | func keyStakingAssetBalance (assetId) = makeString(["%s%s", "stakingAssetBalance", assetId], SEP) | |
143 | 143 | ||
144 | 144 | ||
145 | 145 | func getAdditionalBalanceOrZero (assetId) = valueOrElse(getInteger(this, keyAdditionalBalance(assetId)), 0) | |
146 | 146 | ||
147 | 147 | ||
148 | 148 | func getStakingAssetBalanceOrZero (assetId) = valueOrElse(getInteger(this, keyStakingAssetBalance(assetId)), 0) | |
149 | 149 | ||
150 | 150 | ||
151 | 151 | func keyFactoryConfig () = "%s__factoryConfig" | |
152 | 152 | ||
153 | 153 | ||
154 | 154 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
155 | 155 | ||
156 | 156 | ||
157 | 157 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
158 | 158 | ||
159 | 159 | ||
160 | 160 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
161 | 161 | ||
162 | 162 | ||
163 | 163 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
164 | 164 | ||
165 | 165 | ||
166 | 166 | func keyAllPoolsShutdown () = "%s__shutdown" | |
167 | 167 | ||
168 | 168 | ||
169 | 169 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
170 | 170 | ||
171 | 171 | ||
172 | 172 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
173 | 173 | ||
174 | 174 | ||
175 | 175 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
176 | 176 | ||
177 | 177 | func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
178 | 178 | ||
179 | 179 | ||
180 | 180 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
181 | 181 | ||
182 | 182 | ||
183 | 183 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
184 | 184 | ||
185 | 185 | ||
186 | 186 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
187 | 187 | ||
188 | 188 | ||
189 | 189 | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
190 | 190 | ||
191 | 191 | ||
192 | 192 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
193 | 193 | ||
194 | 194 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
195 | 195 | ||
196 | 196 | let inFee = { | |
197 | 197 | let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil) | |
198 | 198 | if ($isInstanceOf(@, "Int")) | |
199 | 199 | then @ | |
200 | 200 | else throw(($getType(@) + " couldn't be cast to Int")) | |
201 | 201 | } | |
202 | 202 | ||
203 | 203 | let outFee = { | |
204 | 204 | let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil) | |
205 | 205 | if ($isInstanceOf(@, "Int")) | |
206 | 206 | then @ | |
207 | 207 | else throw(($getType(@) + " couldn't be cast to Int")) | |
208 | 208 | } | |
209 | 209 | ||
210 | 210 | func sWavesId () = getStringOrFail(factoryContract, keySWavesAssetId()) | |
211 | 211 | ||
212 | 212 | ||
213 | 213 | func sWavesProxy () = getStringOrFail(factoryContract, keySWavesProxyAddress()) | |
214 | 214 | ||
215 | 215 | ||
216 | 216 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
217 | 217 | ||
218 | 218 | ||
219 | 219 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
220 | 220 | ||
221 | 221 | ||
222 | 222 | func getPoolConfig () = { | |
223 | 223 | let amtAsset = getStringOrFail(this, aa()) | |
224 | 224 | let priceAsset = getStringOrFail(this, pa()) | |
225 | 225 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
226 | 226 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
227 | 227 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
228 | 228 | } | |
229 | 229 | ||
230 | 230 | ||
231 | 231 | func parseAssetId (input) = if ((input == wavesString)) | |
232 | 232 | then unit | |
233 | 233 | else fromBase58String(input) | |
234 | 234 | ||
235 | 235 | ||
236 | 236 | func assetIdToString (input) = if ((input == unit)) | |
237 | 237 | then wavesString | |
238 | 238 | else toBase58String(value(input)) | |
239 | 239 | ||
240 | 240 | ||
241 | 241 | 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])) | |
242 | 242 | ||
243 | 243 | ||
244 | 244 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
245 | 245 | ||
246 | 246 | let $t092979463 = poolConfigParsed | |
247 | 247 | ||
248 | 248 | let cfgPoolAddress = $t092979463._1 | |
249 | 249 | ||
250 | 250 | let cfgPoolStatus = $t092979463._2 | |
251 | 251 | ||
252 | 252 | let cfgLpAssetId = $t092979463._3 | |
253 | 253 | ||
254 | 254 | let cfgAmountAssetId = $t092979463._4 | |
255 | 255 | ||
256 | 256 | let cfgPriceAssetId = $t092979463._5 | |
257 | 257 | ||
258 | 258 | let cfgAmountAssetDecimals = $t092979463._6 | |
259 | 259 | ||
260 | 260 | let cfgPriceAssetDecimals = $t092979463._7 | |
261 | 261 | ||
262 | 262 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
263 | 263 | ||
264 | 264 | ||
265 | 265 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
266 | 266 | ||
267 | 267 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
268 | 268 | ||
269 | 269 | 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) | |
270 | 270 | ||
271 | 271 | ||
272 | 272 | 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) | |
273 | 273 | ||
274 | 274 | ||
275 | 275 | func getAccBalance (assetId) = { | |
276 | 276 | let balanceOnPool = if ((assetId == "WAVES")) | |
277 | 277 | then wavesBalance(this).available | |
278 | 278 | else assetBalance(this, fromBase58String(assetId)) | |
279 | 279 | let totalBalance = ((balanceOnPool + getAdditionalBalanceOrZero(assetId)) - getStakingAssetBalanceOrZero(assetId)) | |
280 | 280 | max([0, totalBalance]) | |
281 | 281 | } | |
282 | 282 | ||
283 | 283 | ||
284 | 284 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
285 | 285 | ||
286 | 286 | ||
287 | 287 | func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
288 | 288 | ||
289 | 289 | ||
290 | 290 | func getRate (proxy) = { | |
291 | 291 | let inv = invoke(proxy, "getRate", nil, nil) | |
292 | 292 | if ((inv == inv)) | |
293 | 293 | then match inv { | |
294 | 294 | case r: Int => | |
295 | 295 | r | |
296 | 296 | case _ => | |
297 | 297 | throwErr("proxy.getRate() unexpected value") | |
298 | 298 | } | |
299 | 299 | else throw("Strict value is not equal to itself.") | |
300 | 300 | } | |
301 | 301 | ||
302 | 302 | ||
303 | 303 | func deposit (assetId,amount,stakingAssetId,proxy) = { | |
304 | 304 | let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId) | |
305 | 305 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
306 | 306 | then { | |
307 | 307 | let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId) | |
308 | 308 | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
309 | 309 | then { | |
310 | 310 | let asset = parseAssetId(assetId) | |
311 | 311 | if ((amount > 0)) | |
312 | 312 | then { | |
313 | 313 | let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)]) | |
314 | 314 | if ((depositInvoke == depositInvoke)) | |
315 | 315 | then match depositInvoke { | |
316 | 316 | case receivedStakingAsset: Int => | |
317 | 317 | let newAdditionalBalance = (currentAdditionalBalance + amount) | |
318 | 318 | let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset) | |
319 | 319 | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
320 | 320 | case _ => | |
321 | 321 | nil | |
322 | 322 | } | |
323 | 323 | else throw("Strict value is not equal to itself.") | |
324 | 324 | } | |
325 | 325 | else nil | |
326 | 326 | } | |
327 | 327 | else throw("Strict value is not equal to itself.") | |
328 | 328 | } | |
329 | 329 | else throw("Strict value is not equal to itself.") | |
330 | 330 | } | |
331 | 331 | ||
332 | 332 | ||
333 | 333 | func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = { | |
334 | 334 | let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId) | |
335 | 335 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
336 | 336 | then { | |
337 | 337 | let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId) | |
338 | 338 | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
339 | 339 | then { | |
340 | 340 | let currentProxyRate = getRate(proxy) | |
341 | 341 | if ((currentProxyRate == currentProxyRate)) | |
342 | 342 | then { | |
343 | 343 | let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance) | |
344 | 344 | let stakingAsset = parseAssetId(stakingAssetId) | |
345 | 345 | let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate) | |
346 | 346 | let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate) | |
347 | 347 | let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)]) | |
348 | 348 | if ((sendStakingAssetAmount > 0)) | |
349 | 349 | then { | |
350 | 350 | let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)]) | |
351 | 351 | if ((withdrawInvoke == withdrawInvoke)) | |
352 | 352 | then match withdrawInvoke { | |
353 | 353 | case receivedAssets: Int => | |
354 | 354 | let newAdditionalBalance = (currentAdditionalBalance - receivedAssets) | |
355 | 355 | let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount) | |
356 | 356 | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), ScriptTransfer(profitAddress, profitAmount, parseAssetId(stakingAssetId))] | |
357 | 357 | case _ => | |
358 | 358 | nil | |
359 | 359 | } | |
360 | 360 | else throw("Strict value is not equal to itself.") | |
361 | 361 | } | |
362 | 362 | else nil | |
363 | 363 | } | |
364 | 364 | else throw("Strict value is not equal to itself.") | |
365 | 365 | } | |
366 | 366 | else throw("Strict value is not equal to itself.") | |
367 | 367 | } | |
368 | 368 | else throw("Strict value is not equal to itself.") | |
369 | 369 | } | |
370 | 370 | ||
371 | 371 | ||
372 | 372 | func getLeaseProxyConfig (assetId) = invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) | |
373 | 373 | ||
374 | 374 | ||
375 | 375 | func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = { | |
376 | 376 | let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId) | |
377 | 377 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
378 | 378 | then { | |
379 | 379 | let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId) | |
380 | 380 | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
381 | 381 | then { | |
382 | 382 | let availableBalance = match parseAssetId(assetId) { | |
383 | 383 | case b: ByteVector => | |
384 | 384 | assetBalance(this, b) | |
385 | 385 | case u: Unit => | |
386 | 386 | wavesBalance(this).available | |
387 | 387 | case _ => | |
388 | 388 | throw("Match error") | |
389 | 389 | } | |
390 | 390 | if ((availableBalance == availableBalance)) | |
391 | 391 | then { | |
392 | 392 | let wholeBalance = max([0, ((availableBalance + currentAdditionalBalance) - minBalance)]) | |
393 | 393 | let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100) | |
394 | 394 | let diff = (currentAdditionalBalance - targetAdditionalBalance) | |
395 | 395 | if ((diff == 0)) | |
396 | 396 | then nil | |
397 | 397 | else if ((0 > diff)) | |
398 | 398 | then { | |
399 | 399 | let sendAssetAmount = -(diff) | |
400 | 400 | deposit(assetId, sendAssetAmount, stakingAssetId, proxy) | |
401 | 401 | } | |
402 | 402 | else { | |
403 | 403 | let getAssetAmount = diff | |
404 | 404 | withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress) | |
405 | 405 | } | |
406 | 406 | } | |
407 | 407 | else throw("Strict value is not equal to itself.") | |
408 | 408 | } | |
409 | 409 | else throw("Strict value is not equal to itself.") | |
410 | 410 | } | |
411 | 411 | else throw("Strict value is not equal to itself.") | |
412 | 412 | } | |
413 | 413 | ||
414 | 414 | ||
415 | 415 | func rebalanceAsset (assetId) = match getLeaseProxyConfig(assetId) { | |
416 | 416 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
417 | 417 | let $t01581415923 = a | |
418 | 418 | let isLeasable = $t01581415923._1 | |
419 | 419 | let leasedRatio = $t01581415923._2 | |
420 | 420 | let minBalance = $t01581415923._3 | |
421 | 421 | let proxyAddress = $t01581415923._4 | |
422 | 422 | let proxyAssetId = $t01581415923._5 | |
423 | 423 | let proxyRateMul = $t01581415923._6 | |
424 | 424 | let stakingProfitAddress = $t01581415923._7 | |
425 | 425 | if (isLeasable) | |
426 | 426 | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
427 | 427 | else nil | |
428 | 428 | case _ => | |
429 | 429 | throwErr((("[" + assetId) + "] Rebalance error")) | |
430 | 430 | } | |
431 | 431 | ||
432 | 432 | ||
433 | - | func | |
433 | + | func getWithdrawAssetState (assetId,getAmount) = match getLeaseProxyConfig(assetId) { | |
434 | 434 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
435 | - | let $ | |
436 | - | let isLeasable = $ | |
437 | - | let leasedRatio = $ | |
438 | - | let minBalance = $ | |
439 | - | let proxyAddress = $ | |
440 | - | let proxyAssetId = $ | |
441 | - | let proxyRateMul = $ | |
442 | - | let stakingProfitAddress = $ | |
435 | + | let $t01651616625 = a | |
436 | + | let isLeasable = $t01651616625._1 | |
437 | + | let leasedRatio = $t01651616625._2 | |
438 | + | let minBalance = $t01651616625._3 | |
439 | + | let proxyAddress = $t01651616625._4 | |
440 | + | let proxyAssetId = $t01651616625._5 | |
441 | + | let proxyRateMul = $t01651616625._6 | |
442 | + | let stakingProfitAddress = $t01651616625._7 | |
443 | 443 | if (isLeasable) | |
444 | - | then withdraw(assetId, amount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
444 | + | then { | |
445 | + | let newTotalCalcBalance = max([0, ((getAccBalance(assetId) - getAmount) - minBalance)]) | |
446 | + | if ((newTotalCalcBalance == newTotalCalcBalance)) | |
447 | + | then { | |
448 | + | let newAdditionalBalance = fraction(leasedRatio, newTotalCalcBalance, 100) | |
449 | + | if ((newAdditionalBalance == newAdditionalBalance)) | |
450 | + | then { | |
451 | + | let withdrawAmount = max([0, (getAdditionalBalanceOrZero(assetId) - newAdditionalBalance)]) | |
452 | + | if ((withdrawAmount == withdrawAmount)) | |
453 | + | then withdraw(assetId, withdrawAmount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
454 | + | else throw("Strict value is not equal to itself.") | |
455 | + | } | |
456 | + | else throw("Strict value is not equal to itself.") | |
457 | + | } | |
458 | + | else throw("Strict value is not equal to itself.") | |
459 | + | } | |
445 | 460 | else nil | |
446 | 461 | case _ => | |
447 | - | throwErr((("[" + assetId) + "] | |
462 | + | throwErr((("[" + assetId) + "] getWithdrawAssetState() error")) | |
448 | 463 | } | |
449 | - | ||
450 | - | ||
451 | - | func getWithdrawAssetState (assetId,amount) = { | |
452 | - | let assetOnPool = match parseAssetId(assetId) { | |
453 | - | case b: ByteVector => | |
454 | - | assetBalance(this, b) | |
455 | - | case w: Unit => | |
456 | - | wavesBalance(this).available | |
457 | - | case _ => | |
458 | - | throw("Match error") | |
459 | - | } | |
460 | - | if ((amount > assetOnPool)) | |
461 | - | then { | |
462 | - | let amountDiff = (amount - assetOnPool) | |
463 | - | withdrawAssetWrapper(assetId, amountDiff) | |
464 | - | } | |
465 | - | else nil | |
466 | - | } | |
467 | 464 | ||
468 | 465 | ||
469 | 466 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
470 | 467 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
471 | 468 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
472 | 469 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
473 | 470 | } | |
474 | 471 | ||
475 | 472 | ||
476 | 473 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
477 | 474 | let cfg = getPoolConfig() | |
478 | 475 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
479 | 476 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
480 | 477 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
481 | 478 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
482 | 479 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
483 | 480 | let lpAmtX18 = toX18(lpAmt, scale8) | |
484 | 481 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
485 | 482 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
486 | 483 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
487 | 484 | } | |
488 | 485 | ||
489 | 486 | ||
490 | 487 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
491 | 488 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
492 | 489 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
493 | 490 | } | |
494 | 491 | ||
495 | 492 | ||
496 | 493 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
497 | 494 | let cfg = getPoolConfig() | |
498 | 495 | let lpAssetId = cfg[idxPoolLPAssetId] | |
499 | 496 | let amAssetId = cfg[idxAmtAssetId] | |
500 | 497 | let prAssetId = cfg[idxPriceAssetId] | |
501 | 498 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
502 | 499 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
503 | 500 | let poolStatus = cfg[idxPoolStatus] | |
504 | 501 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
505 | 502 | if ((lpAssetId != pmtAssetId)) | |
506 | 503 | then throw("Invalid asset passed.") | |
507 | 504 | else { | |
508 | 505 | let amBalance = getAccBalance(amAssetId) | |
509 | 506 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
510 | 507 | let prBalance = getAccBalance(prAssetId) | |
511 | 508 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
512 | 509 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
513 | 510 | let curPrice = fromX18(curPriceX18, scale8) | |
514 | 511 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
515 | 512 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
516 | 513 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
517 | 514 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
518 | 515 | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
519 | 516 | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
520 | 517 | let AmAmtWithdrawState = getWithdrawAssetState(amAssetId, outAmAmt) | |
521 | 518 | if ((AmAmtWithdrawState == AmAmtWithdrawState)) | |
522 | 519 | then { | |
523 | 520 | let PrAmtWithdrawState = getWithdrawAssetState(prAssetId, outPrAmt) | |
524 | 521 | if ((PrAmtWithdrawState == PrAmtWithdrawState)) | |
525 | 522 | then { | |
526 | - | let reb = invoke(this, "rebalance", nil, nil) | |
527 | - | if ((reb == reb)) | |
528 | - | then { | |
529 | - | let state = if ((txId58 == "")) | |
530 | - | then nil | |
531 | - | else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
532 | - | then unit | |
533 | - | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
534 | - | then unit | |
535 | - | 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)]) | |
536 | - | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
537 | - | } | |
538 | - | else throw("Strict value is not equal to itself.") | |
523 | + | let state = if ((txId58 == "")) | |
524 | + | then nil | |
525 | + | else ((AmAmtWithdrawState ++ PrAmtWithdrawState) ++ [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
526 | + | then unit | |
527 | + | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
528 | + | then unit | |
529 | + | 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)]) | |
530 | + | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
539 | 531 | } | |
540 | 532 | else throw("Strict value is not equal to itself.") | |
541 | 533 | } | |
542 | 534 | else throw("Strict value is not equal to itself.") | |
543 | 535 | } | |
544 | 536 | } | |
545 | 537 | ||
546 | 538 | ||
547 | 539 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
548 | 540 | let cfg = getPoolConfig() | |
549 | 541 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
550 | 542 | let amAssetIdStr = cfg[idxAmtAssetId] | |
551 | 543 | let prAssetIdStr = cfg[idxPriceAssetId] | |
552 | 544 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
553 | 545 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
554 | 546 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
555 | 547 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
556 | 548 | let poolStatus = cfg[idxPoolStatus] | |
557 | 549 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
558 | 550 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
559 | 551 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
560 | 552 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
561 | 553 | then true | |
562 | 554 | else (prAssetIdStr != inPrAssetIdStr)) | |
563 | 555 | then throw("Invalid amt or price asset passed.") | |
564 | 556 | else { | |
565 | 557 | let amBalance = if (isEvaluate) | |
566 | 558 | then getAccBalance(amAssetIdStr) | |
567 | 559 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
568 | 560 | let prBalance = if (isEvaluate) | |
569 | 561 | then getAccBalance(prAssetIdStr) | |
570 | 562 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
571 | 563 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
572 | 564 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
573 | 565 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
574 | 566 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
575 | 567 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
576 | 568 | let res = if ((lpEmission == 0)) | |
577 | 569 | then { | |
578 | 570 | let curPriceX18 = zeroBigInt | |
579 | 571 | let slippageX18 = zeroBigInt | |
580 | 572 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
581 | 573 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
582 | 574 | } | |
583 | 575 | else { | |
584 | 576 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
585 | 577 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
586 | 578 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
587 | 579 | if (if ((curPriceX18 != zeroBigInt)) | |
588 | 580 | then (slippageX18 > slippageToleranceX18) | |
589 | 581 | else false) | |
590 | 582 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
591 | 583 | else { | |
592 | 584 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
593 | 585 | let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
594 | 586 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
595 | 587 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
596 | 588 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
597 | 589 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
598 | 590 | let expAmtAssetAmtX18 = expectedAmts._1 | |
599 | 591 | let expPriceAssetAmtX18 = expectedAmts._2 | |
600 | 592 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
601 | 593 | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18) | |
602 | 594 | } | |
603 | 595 | } | |
604 | 596 | let calcLpAmt = res._1 | |
605 | 597 | let calcAmAssetPmt = res._2 | |
606 | 598 | let calcPrAssetPmt = res._3 | |
607 | 599 | let curPrice = fromX18(res._4, scale8) | |
608 | 600 | let slippageCalc = fromX18(res._5, scale8) | |
609 | 601 | if ((0 >= calcLpAmt)) | |
610 | 602 | then throw("Invalid calculations. LP calculated is less than zero.") | |
611 | 603 | else { | |
612 | 604 | let emitLpAmt = if (!(emitLp)) | |
613 | 605 | then 0 | |
614 | 606 | else calcLpAmt | |
615 | 607 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
616 | 608 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
617 | 609 | 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))] | |
618 | 610 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
619 | 611 | } | |
620 | 612 | } | |
621 | 613 | } | |
622 | 614 | ||
623 | 615 | ||
624 | 616 | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
625 | 617 | let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)) | |
626 | 618 | let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals)) | |
627 | 619 | let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
628 | 620 | if ((lpEmission == big0)) | |
629 | 621 | then big0 | |
630 | 622 | else updatedKLp | |
631 | 623 | } | |
632 | 624 | ||
633 | 625 | ||
634 | 626 | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
635 | 627 | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
636 | 628 | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
637 | 629 | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
638 | 630 | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
639 | 631 | currentKLp | |
640 | 632 | } | |
641 | 633 | ||
642 | 634 | ||
643 | 635 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
644 | 636 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
645 | 637 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
646 | 638 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
647 | 639 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
648 | 640 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
649 | 641 | $Tuple2(actions, updatedKLp) | |
650 | 642 | } | |
651 | 643 | ||
652 | 644 | ||
653 | 645 | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
654 | 646 | then true | |
655 | 647 | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
656 | 648 | ||
657 | 649 | ||
658 | 650 | func validateMatcherOrderAllowed (order) = { | |
659 | 651 | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
660 | 652 | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
661 | 653 | let amountAssetAmount = order.amount | |
662 | 654 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
663 | - | let $ | |
655 | + | let $t02870728919 = if ((order.orderType == Buy)) | |
664 | 656 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
665 | 657 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
666 | - | let amountAssetBalanceDelta = $ | |
667 | - | let priceAssetBalanceDelta = $ | |
658 | + | let amountAssetBalanceDelta = $t02870728919._1 | |
659 | + | let priceAssetBalanceDelta = $t02870728919._2 | |
668 | 660 | if (if (if (isGlobalShutdown()) | |
669 | 661 | then true | |
670 | 662 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
671 | 663 | then true | |
672 | 664 | else (cfgPoolStatus == PoolShutdown)) | |
673 | 665 | then throw("Exchange operations disabled") | |
674 | 666 | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
675 | 667 | then true | |
676 | 668 | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
677 | 669 | then throw("Wrong order assets.") | |
678 | 670 | else { | |
679 | 671 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
680 | - | let $ | |
681 | - | let unusedActions = $ | |
682 | - | let kLpNew = $ | |
672 | + | let $t02935929459 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
673 | + | let unusedActions = $t02935929459._1 | |
674 | + | let kLpNew = $t02935929459._2 | |
683 | 675 | let isOrderValid = (kLpNew >= kLp) | |
684 | 676 | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
685 | 677 | $Tuple2(isOrderValid, info) | |
686 | 678 | } | |
687 | 679 | } | |
688 | 680 | ||
689 | 681 | ||
690 | 682 | func commonGet (i) = if ((size(i.payments) != 1)) | |
691 | 683 | then throw("exactly 1 payment is expected") | |
692 | 684 | else { | |
693 | 685 | let pmt = value(i.payments[0]) | |
694 | 686 | let pmtAssetId = value(pmt.assetId) | |
695 | 687 | let pmtAmt = pmt.amount | |
696 | 688 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
697 | 689 | let outAmAmt = res._1 | |
698 | 690 | let outPrAmt = res._2 | |
699 | 691 | let poolStatus = parseIntValue(res._9) | |
700 | 692 | let state = res._10 | |
701 | 693 | if (if (isGlobalShutdown()) | |
702 | 694 | then true | |
703 | 695 | else (poolStatus == PoolShutdown)) | |
704 | 696 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
705 | 697 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
706 | 698 | } | |
707 | 699 | ||
708 | 700 | ||
709 | 701 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
710 | 702 | then throw("exactly 2 payments are expected") | |
711 | 703 | else { | |
712 | 704 | let amAssetPmt = value(i.payments[0]) | |
713 | 705 | let prAssetPmt = value(i.payments[1]) | |
714 | 706 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
715 | 707 | let poolStatus = parseIntValue(estPut._8) | |
716 | 708 | if (if (if (isGlobalShutdown()) | |
717 | 709 | then true | |
718 | 710 | else (poolStatus == PoolPutDisabled)) | |
719 | 711 | then true | |
720 | 712 | else (poolStatus == PoolShutdown)) | |
721 | 713 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
722 | 714 | else estPut | |
723 | 715 | } | |
724 | 716 | ||
725 | 717 | ||
726 | 718 | func emit (amount) = { | |
727 | 719 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
728 | 720 | if ((emitInv == emitInv)) | |
729 | 721 | then { | |
730 | 722 | let emitInvLegacy = match emitInv { | |
731 | 723 | case legacyFactoryContract: Address => | |
732 | 724 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
733 | 725 | case _ => | |
734 | 726 | unit | |
735 | 727 | } | |
736 | 728 | if ((emitInvLegacy == emitInvLegacy)) | |
737 | 729 | then amount | |
738 | 730 | else throw("Strict value is not equal to itself.") | |
739 | 731 | } | |
740 | 732 | else throw("Strict value is not equal to itself.") | |
741 | 733 | } | |
742 | 734 | ||
743 | 735 | ||
744 | 736 | func takeFee (amount,fee) = { | |
745 | 737 | let feeAmount = if ((fee == 0)) | |
746 | 738 | then 0 | |
747 | 739 | else fraction(amount, fee, scale8) | |
748 | 740 | $Tuple2((amount - feeAmount), feeAmount) | |
749 | 741 | } | |
750 | 742 | ||
751 | 743 | ||
752 | 744 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
753 | 745 | let isEval = (txId == unit) | |
754 | 746 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
755 | 747 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
756 | 748 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
757 | 749 | then true | |
758 | 750 | else if ((paymentAssetId == cfgPriceAssetId)) | |
759 | 751 | then false | |
760 | 752 | else throwErr("invalid asset") | |
761 | - | let $ | |
753 | + | let $t03257232865 = if (isEval) | |
762 | 754 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
763 | 755 | else if (paymentInAmountAsset) | |
764 | 756 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
765 | 757 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
766 | - | let amountBalanceOld = $ | |
767 | - | let priceBalanceOld = $ | |
768 | - | let $ | |
758 | + | let amountBalanceOld = $t03257232865._1 | |
759 | + | let priceBalanceOld = $t03257232865._2 | |
760 | + | let $t03286933018 = if (paymentInAmountAsset) | |
769 | 761 | then $Tuple2(paymentAmountRaw, 0) | |
770 | 762 | else $Tuple2(0, paymentAmountRaw) | |
771 | - | let amountAssetAmountRaw = $ | |
772 | - | let priceAssetAmountRaw = $ | |
763 | + | let amountAssetAmountRaw = $t03286933018._1 | |
764 | + | let priceAssetAmountRaw = $t03286933018._2 | |
773 | 765 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
774 | 766 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
775 | - | let $ | |
776 | - | let paymentAmount = $ | |
777 | - | let feeAmount = $ | |
767 | + | let $t03315033214 = takeFee(paymentAmountRaw, inFee) | |
768 | + | let paymentAmount = $t03315033214._1 | |
769 | + | let feeAmount = $t03315033214._2 | |
778 | 770 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
779 | 771 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
780 | 772 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
781 | 773 | let priceNew = fromX18(priceNewX18, scale8) | |
782 | 774 | let paymentBalance = if (paymentInAmountAsset) | |
783 | 775 | then amountBalanceOld | |
784 | 776 | else priceBalanceOld | |
785 | 777 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
786 | 778 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
787 | 779 | let chechSupply = if ((supplyBigInt > big0)) | |
788 | 780 | then true | |
789 | 781 | else throwErr("initial deposit requires all coins") | |
790 | 782 | if ((chechSupply == chechSupply)) | |
791 | 783 | then { | |
792 | 784 | let depositBigInt = toBigInt(paymentAmount) | |
793 | 785 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
794 | 786 | let commonState = if (isEval) | |
795 | 787 | then nil | |
796 | 788 | 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))] | |
797 | 789 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
798 | 790 | let priceOld = fromX18(priceOldX18, scale8) | |
799 | 791 | let loss = { | |
800 | - | let $ | |
792 | + | let $t03489535062 = if (paymentInAmountAsset) | |
801 | 793 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
802 | 794 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
803 | - | let amount = $ | |
804 | - | let balance = $ | |
795 | + | let amount = $t03489535062._1 | |
796 | + | let balance = $t03489535062._2 | |
805 | 797 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
806 | 798 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
807 | 799 | } | |
808 | 800 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
809 | 801 | } | |
810 | 802 | else throw("Strict value is not equal to itself.") | |
811 | 803 | } | |
812 | 804 | ||
813 | 805 | ||
814 | 806 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
815 | 807 | let isEval = (txId == unit) | |
816 | 808 | let cfg = getPoolConfig() | |
817 | 809 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
818 | 810 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
819 | 811 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
820 | 812 | then true | |
821 | 813 | else throwErr("invalid lp asset")] | |
822 | 814 | if ((checks == checks)) | |
823 | 815 | then { | |
824 | 816 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
825 | 817 | then true | |
826 | 818 | else if ((outAssetId == cfgPriceAssetId)) | |
827 | 819 | then false | |
828 | 820 | else throwErr("invalid asset") | |
829 | 821 | let balanceBigInt = if (outInAmountAsset) | |
830 | 822 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
831 | 823 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
832 | 824 | let outInAmountAssetDecimals = if (outInAmountAsset) | |
833 | 825 | then amtAssetDcm | |
834 | 826 | else priceAssetDcm | |
835 | 827 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
836 | 828 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
837 | 829 | let outBalance = if (outInAmountAsset) | |
838 | 830 | then amBalanceOld | |
839 | 831 | else prBalanceOld | |
840 | 832 | let outBalanceBigInt = toBigInt(outBalance) | |
841 | 833 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
842 | 834 | let redeemedBigInt = toBigInt(paymentAmount) | |
843 | 835 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
844 | - | let $ | |
845 | - | let totalAmount = $ | |
846 | - | let feeAmount = $ | |
847 | - | let $ | |
836 | + | let $t03714037196 = takeFee(amountRaw, outFee) | |
837 | + | let totalAmount = $t03714037196._1 | |
838 | + | let feeAmount = $t03714037196._2 | |
839 | + | let $t03720037426 = if (outInAmountAsset) | |
848 | 840 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
849 | 841 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
850 | - | let outAmAmount = $ | |
851 | - | let outPrAmount = $ | |
852 | - | let amBalanceNew = $ | |
853 | - | let prBalanceNew = $ | |
842 | + | let outAmAmount = $t03720037426._1 | |
843 | + | let outPrAmount = $t03720037426._2 | |
844 | + | let amBalanceNew = $t03720037426._3 | |
845 | + | let prBalanceNew = $t03720037426._4 | |
854 | 846 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
855 | 847 | let priceNew = fromX18(priceNewX18, scale8) | |
856 | 848 | let commonState = if (isEval) | |
857 | 849 | then nil | |
858 | 850 | 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)] | |
859 | 851 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
860 | 852 | let priceOld = fromX18(priceOldX18, scale8) | |
861 | 853 | let loss = { | |
862 | 854 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
863 | 855 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
864 | 856 | } | |
865 | 857 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
866 | 858 | } | |
867 | 859 | else throw("Strict value is not equal to itself.") | |
868 | 860 | } | |
869 | 861 | ||
870 | 862 | ||
871 | 863 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
872 | 864 | case s: String => | |
873 | 865 | fromBase58String(s) | |
874 | 866 | case _: Unit => | |
875 | 867 | unit | |
876 | 868 | case _ => | |
877 | 869 | throw("Match error") | |
878 | 870 | } | |
879 | 871 | ||
880 | 872 | ||
881 | 873 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
882 | 874 | case s: String => | |
883 | 875 | fromBase58String(s) | |
884 | 876 | case _: Unit => | |
885 | 877 | unit | |
886 | 878 | case _ => | |
887 | 879 | throw("Match error") | |
888 | 880 | } | |
889 | 881 | ||
890 | 882 | ||
891 | 883 | func isManager (i) = match managerPublicKeyOrUnit() { | |
892 | 884 | case pk: ByteVector => | |
893 | 885 | (i.callerPublicKey == pk) | |
894 | 886 | case _: Unit => | |
895 | 887 | (i.caller == this) | |
896 | 888 | case _ => | |
897 | 889 | throw("Match error") | |
898 | 890 | } | |
899 | 891 | ||
900 | 892 | ||
901 | 893 | func mustManager (i) = { | |
902 | 894 | let pd = throw("Permission denied") | |
903 | 895 | match managerPublicKeyOrUnit() { | |
904 | 896 | case pk: ByteVector => | |
905 | 897 | if ((i.callerPublicKey == pk)) | |
906 | 898 | then true | |
907 | 899 | else pd | |
908 | 900 | case _: Unit => | |
909 | 901 | if ((i.caller == this)) | |
910 | 902 | then true | |
911 | 903 | else pd | |
912 | 904 | case _ => | |
913 | 905 | throw("Match error") | |
914 | 906 | } | |
915 | 907 | } | |
916 | 908 | ||
917 | 909 | ||
918 | 910 | @Callable(i) | |
919 | 911 | func rebalance () = (rebalanceAsset(getStringOrFail(this, aa())) ++ rebalanceAsset(getStringOrFail(this, pa()))) | |
920 | 912 | ||
921 | 913 | ||
922 | 914 | ||
923 | 915 | @Callable(i) | |
924 | 916 | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = { | |
925 | - | let $ | |
917 | + | let $t03931239617 = if ((isReverse == false)) | |
926 | 918 | then { | |
927 | 919 | let assetOut = getStringOrFail(this, pa()) | |
928 | 920 | let assetIn = getStringOrFail(this, aa()) | |
929 | 921 | $Tuple2(assetOut, assetIn) | |
930 | 922 | } | |
931 | 923 | else { | |
932 | 924 | let assetOut = getStringOrFail(this, aa()) | |
933 | 925 | let assetIn = getStringOrFail(this, pa()) | |
934 | 926 | $Tuple2(assetOut, assetIn) | |
935 | 927 | } | |
936 | - | let assetOut = $ | |
937 | - | let assetIn = $ | |
928 | + | let assetOut = $t03931239617._1 | |
929 | + | let assetIn = $t03931239617._2 | |
938 | 930 | let poolAssetInBalance = getAccBalance(assetIn) | |
939 | 931 | let poolAssetOutBalance = getAccBalance(assetOut) | |
940 | 932 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
941 | 933 | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
942 | 934 | let newK = (((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
943 | 935 | let checkK = if ((newK >= oldK)) | |
944 | 936 | then true | |
945 | 937 | else throw("new K is fewer error") | |
946 | 938 | if ((checkK == checkK)) | |
947 | 939 | then $Tuple2(nil, amountOut) | |
948 | 940 | else throw("Strict value is not equal to itself.") | |
949 | 941 | } | |
950 | 942 | ||
951 | 943 | ||
952 | 944 | ||
953 | 945 | @Callable(i) | |
954 | 946 | func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = { | |
955 | 947 | let swapContact = { | |
956 | 948 | let @ = invoke(factoryContract, "getSwapContractREADONLY", nil, nil) | |
957 | 949 | if ($isInstanceOf(@, "String")) | |
958 | 950 | then @ | |
959 | 951 | else throw(($getType(@) + " couldn't be cast to String")) | |
960 | 952 | } | |
961 | 953 | let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn)) | |
962 | 954 | then true | |
963 | 955 | else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact))) | |
964 | 956 | then true | |
965 | 957 | else throwErr("Permission denied")] | |
966 | 958 | if ((checks == checks)) | |
967 | 959 | then { | |
968 | 960 | let pmt = value(i.payments[0]) | |
969 | 961 | let assetIn = assetIdToString(pmt.assetId) | |
970 | 962 | let assetOut = if ((isReverse == false)) | |
971 | 963 | then getStringOrFail(this, pa()) | |
972 | 964 | else getStringOrFail(this, aa()) | |
973 | 965 | let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
974 | 966 | let poolAssetOutBalance = getAccBalance(assetOut) | |
975 | 967 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
976 | 968 | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
977 | 969 | let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
978 | 970 | let checkK = if ((newK >= oldK)) | |
979 | 971 | then true | |
980 | 972 | else throw("new K is fewer error") | |
981 | 973 | if ((checkK == checkK)) | |
982 | 974 | then { | |
983 | 975 | let checkMin = if ((amountOut >= amountOutMin)) | |
984 | 976 | then true | |
985 | 977 | else throw("Exchange result is fewer coins than expected") | |
986 | 978 | if ((checkMin == checkMin)) | |
987 | 979 | then { | |
988 | 980 | let lsConf = match getLeaseProxyConfig(assetOut) { | |
989 | 981 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
990 | 982 | a | |
991 | 983 | case _ => | |
992 | 984 | throw("error lease config") | |
993 | 985 | } | |
994 | 986 | let withdrawState = getWithdrawAssetState(assetOut, amountOut) | |
995 | 987 | if ((withdrawState == withdrawState)) | |
996 | - | then { | |
997 | - | let reb = invoke(this, "rebalance", nil, nil) | |
998 | - | if ((reb == reb)) | |
999 | - | then $Tuple2((withdrawState ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut) | |
1000 | - | else throw("Strict value is not equal to itself.") | |
1001 | - | } | |
988 | + | then $Tuple2((withdrawState ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut) | |
1002 | 989 | else throw("Strict value is not equal to itself.") | |
1003 | 990 | } | |
1004 | 991 | else throw("Strict value is not equal to itself.") | |
1005 | 992 | } | |
1006 | 993 | else throw("Strict value is not equal to itself.") | |
1007 | 994 | } | |
1008 | 995 | else throw("Strict value is not equal to itself.") | |
1009 | 996 | } | |
1010 | 997 | ||
1011 | 998 | ||
1012 | 999 | ||
1013 | 1000 | @Callable(i) | |
1014 | 1001 | func setManager (pendingManagerPublicKey) = { | |
1015 | 1002 | let checkCaller = mustManager(i) | |
1016 | 1003 | if ((checkCaller == checkCaller)) | |
1017 | 1004 | then { | |
1018 | 1005 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
1019 | 1006 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
1020 | 1007 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
1021 | 1008 | else throw("Strict value is not equal to itself.") | |
1022 | 1009 | } | |
1023 | 1010 | else throw("Strict value is not equal to itself.") | |
1024 | 1011 | } | |
1025 | 1012 | ||
1026 | 1013 | ||
1027 | 1014 | ||
1028 | 1015 | @Callable(i) | |
1029 | 1016 | func confirmManager () = { | |
1030 | 1017 | let pm = pendingManagerPublicKeyOrUnit() | |
1031 | 1018 | let hasPM = if (isDefined(pm)) | |
1032 | 1019 | then true | |
1033 | 1020 | else throw("No pending manager") | |
1034 | 1021 | if ((hasPM == hasPM)) | |
1035 | 1022 | then { | |
1036 | 1023 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
1037 | 1024 | then true | |
1038 | 1025 | else throw("You are not pending manager") | |
1039 | 1026 | if ((checkPM == checkPM)) | |
1040 | 1027 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
1041 | 1028 | else throw("Strict value is not equal to itself.") | |
1042 | 1029 | } | |
1043 | 1030 | else throw("Strict value is not equal to itself.") | |
1044 | 1031 | } | |
1045 | 1032 | ||
1046 | 1033 | ||
1047 | 1034 | ||
1048 | 1035 | @Callable(i) | |
1049 | 1036 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
1050 | 1037 | then throw("Invalid slippageTolerance passed") | |
1051 | 1038 | else { | |
1052 | 1039 | let estPut = commonPut(i, slippageTolerance, true) | |
1053 | 1040 | let emitLpAmt = estPut._2 | |
1054 | 1041 | let lpAssetId = estPut._7 | |
1055 | 1042 | let state = estPut._9 | |
1056 | 1043 | let amDiff = estPut._10 | |
1057 | 1044 | let prDiff = estPut._11 | |
1058 | 1045 | let amId = estPut._12 | |
1059 | 1046 | let prId = estPut._13 | |
1060 | 1047 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1061 | 1048 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1062 | 1049 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1063 | 1050 | if ((currentKLp == currentKLp)) | |
1064 | 1051 | then { | |
1065 | 1052 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
1066 | 1053 | if ((emitInv == emitInv)) | |
1067 | 1054 | then { | |
1068 | 1055 | let emitInvLegacy = match emitInv { | |
1069 | 1056 | case legacyFactoryContract: Address => | |
1070 | 1057 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
1071 | 1058 | case _ => | |
1072 | 1059 | unit | |
1073 | 1060 | } | |
1074 | 1061 | if ((emitInvLegacy == emitInvLegacy)) | |
1075 | 1062 | then { | |
1076 | 1063 | let slippageAInv = if ((amDiff > 0)) | |
1077 | 1064 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
1078 | 1065 | else nil | |
1079 | 1066 | if ((slippageAInv == slippageAInv)) | |
1080 | 1067 | then { | |
1081 | 1068 | let slippagePInv = if ((prDiff > 0)) | |
1082 | 1069 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
1083 | 1070 | else nil | |
1084 | 1071 | if ((slippagePInv == slippagePInv)) | |
1085 | 1072 | then { | |
1086 | 1073 | let lpTransfer = if (shouldAutoStake) | |
1087 | 1074 | then { | |
1088 | 1075 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
1089 | 1076 | if ((slpStakeInv == slpStakeInv)) | |
1090 | 1077 | then nil | |
1091 | 1078 | else throw("Strict value is not equal to itself.") | |
1092 | 1079 | } | |
1093 | 1080 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1094 | - | let $ | |
1095 | - | if (($ | |
1081 | + | let $t04477045232 = refreshKLpInternal(0, 0, 0) | |
1082 | + | if (($t04477045232 == $t04477045232)) | |
1096 | 1083 | then { | |
1097 | - | let updatedKLp = $ | |
1098 | - | let refreshKLpActions = $ | |
1084 | + | let updatedKLp = $t04477045232._2 | |
1085 | + | let refreshKLpActions = $t04477045232._1 | |
1099 | 1086 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1100 | 1087 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1101 | 1088 | then { | |
1102 | 1089 | let reb = invoke(this, "rebalance", nil, nil) | |
1103 | 1090 | if ((reb == reb)) | |
1104 | 1091 | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
1105 | 1092 | else throw("Strict value is not equal to itself.") | |
1106 | 1093 | } | |
1107 | 1094 | else throw("Strict value is not equal to itself.") | |
1108 | 1095 | } | |
1109 | 1096 | else throw("Strict value is not equal to itself.") | |
1110 | 1097 | } | |
1111 | 1098 | else throw("Strict value is not equal to itself.") | |
1112 | 1099 | } | |
1113 | 1100 | else throw("Strict value is not equal to itself.") | |
1114 | 1101 | } | |
1115 | 1102 | else throw("Strict value is not equal to itself.") | |
1116 | 1103 | } | |
1117 | 1104 | else throw("Strict value is not equal to itself.") | |
1118 | 1105 | } | |
1119 | 1106 | else throw("Strict value is not equal to itself.") | |
1120 | 1107 | } | |
1121 | 1108 | ||
1122 | 1109 | ||
1123 | 1110 | ||
1124 | 1111 | @Callable(i) | |
1125 | 1112 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
1126 | 1113 | then throw("Invalid value passed") | |
1127 | 1114 | else { | |
1128 | 1115 | let estPut = commonPut(i, maxSlippage, false) | |
1129 | 1116 | let state = estPut._9 | |
1130 | 1117 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1131 | 1118 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1132 | 1119 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1133 | 1120 | if ((currentKLp == currentKLp)) | |
1134 | 1121 | then { | |
1135 | - | let $ | |
1136 | - | let refreshKLpActions = $ | |
1137 | - | let updatedKLp = $ | |
1122 | + | let $t04584445909 = refreshKLpInternal(0, 0, 0) | |
1123 | + | let refreshKLpActions = $t04584445909._1 | |
1124 | + | let updatedKLp = $t04584445909._2 | |
1138 | 1125 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1139 | 1126 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1140 | 1127 | then (state ++ refreshKLpActions) | |
1141 | 1128 | else throw("Strict value is not equal to itself.") | |
1142 | 1129 | } | |
1143 | 1130 | else throw("Strict value is not equal to itself.") | |
1144 | 1131 | } | |
1145 | 1132 | ||
1146 | 1133 | ||
1147 | 1134 | ||
1148 | 1135 | @Callable(i) | |
1149 | 1136 | func putOneTkn (minOutAmount,autoStake) = { | |
1150 | 1137 | let isPoolOneTokenOperationsDisabled = { | |
1151 | 1138 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1152 | 1139 | if ($isInstanceOf(@, "Boolean")) | |
1153 | 1140 | then @ | |
1154 | 1141 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1155 | 1142 | } | |
1156 | 1143 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
1157 | 1144 | then true | |
1158 | 1145 | else (cfgPoolStatus == PoolPutDisabled)) | |
1159 | 1146 | then true | |
1160 | 1147 | else (cfgPoolStatus == PoolShutdown)) | |
1161 | 1148 | then true | |
1162 | 1149 | else isPoolOneTokenOperationsDisabled | |
1163 | 1150 | let checks = [if (if (!(isPutDisabled)) | |
1164 | 1151 | then true | |
1165 | 1152 | else isManager(i)) | |
1166 | 1153 | then true | |
1167 | 1154 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1168 | 1155 | then true | |
1169 | 1156 | else throwErr("exactly 1 payment are expected")] | |
1170 | 1157 | if ((checks == checks)) | |
1171 | 1158 | then { | |
1172 | 1159 | let payment = i.payments[0] | |
1173 | 1160 | let paymentAssetId = payment.assetId | |
1174 | 1161 | let paymentAmountRaw = payment.amount | |
1175 | 1162 | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
1176 | 1163 | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
1177 | 1164 | else if ((paymentAssetId == cfgPriceAssetId)) | |
1178 | 1165 | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
1179 | 1166 | else throwErr("payment asset is not supported") | |
1180 | 1167 | if ((currentKLp == currentKLp)) | |
1181 | 1168 | then { | |
1182 | 1169 | let userAddress = i.caller | |
1183 | 1170 | let txId = i.transactionId | |
1184 | - | let $ | |
1185 | - | if (($ | |
1171 | + | let $t04709747249 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
1172 | + | if (($t04709747249 == $t04709747249)) | |
1186 | 1173 | then { | |
1187 | - | let paymentInAmountAsset = $ | |
1188 | - | let bonus = $ | |
1189 | - | let feeAmount = $ | |
1190 | - | let commonState = $ | |
1191 | - | let emitAmountEstimated = $ | |
1174 | + | let paymentInAmountAsset = $t04709747249._5 | |
1175 | + | let bonus = $t04709747249._4 | |
1176 | + | let feeAmount = $t04709747249._3 | |
1177 | + | let commonState = $t04709747249._2 | |
1178 | + | let emitAmountEstimated = $t04709747249._1 | |
1192 | 1179 | let emitAmount = if (if ((minOutAmount > 0)) | |
1193 | 1180 | then (minOutAmount > emitAmountEstimated) | |
1194 | 1181 | else false) | |
1195 | 1182 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1196 | 1183 | else emitAmountEstimated | |
1197 | 1184 | let emitInv = emit(emitAmount) | |
1198 | 1185 | if ((emitInv == emitInv)) | |
1199 | 1186 | then { | |
1200 | 1187 | let lpTransfer = if (autoStake) | |
1201 | 1188 | then { | |
1202 | 1189 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
1203 | 1190 | if ((stakeInv == stakeInv)) | |
1204 | 1191 | then nil | |
1205 | 1192 | else throw("Strict value is not equal to itself.") | |
1206 | 1193 | } | |
1207 | 1194 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
1208 | 1195 | let sendFee = if ((feeAmount > 0)) | |
1209 | 1196 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
1210 | 1197 | else nil | |
1211 | - | let $ | |
1198 | + | let $t04783548032 = if ((this == feeCollectorAddress)) | |
1212 | 1199 | then $Tuple2(0, 0) | |
1213 | 1200 | else if (paymentInAmountAsset) | |
1214 | 1201 | then $Tuple2(-(feeAmount), 0) | |
1215 | 1202 | else $Tuple2(0, -(feeAmount)) | |
1216 | - | let amountAssetBalanceDelta = $ | |
1217 | - | let priceAssetBalanceDelta = $ | |
1218 | - | let $ | |
1219 | - | let refreshKLpActions = $ | |
1220 | - | let updatedKLp = $ | |
1203 | + | let amountAssetBalanceDelta = $t04783548032._1 | |
1204 | + | let priceAssetBalanceDelta = $t04783548032._2 | |
1205 | + | let $t04803548143 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1206 | + | let refreshKLpActions = $t04803548143._1 | |
1207 | + | let updatedKLp = $t04803548143._2 | |
1221 | 1208 | let kLp = value(getString(keyKLp)) | |
1222 | 1209 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1223 | 1210 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1224 | 1211 | then { | |
1225 | 1212 | let reb = invoke(this, "rebalance", nil, nil) | |
1226 | 1213 | if ((reb == reb)) | |
1227 | 1214 | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1228 | 1215 | else throw("Strict value is not equal to itself.") | |
1229 | 1216 | } | |
1230 | 1217 | else throw("Strict value is not equal to itself.") | |
1231 | 1218 | } | |
1232 | 1219 | else throw("Strict value is not equal to itself.") | |
1233 | 1220 | } | |
1234 | 1221 | else throw("Strict value is not equal to itself.") | |
1235 | 1222 | } | |
1236 | 1223 | else throw("Strict value is not equal to itself.") | |
1237 | 1224 | } | |
1238 | 1225 | else throw("Strict value is not equal to itself.") | |
1239 | 1226 | } | |
1240 | 1227 | ||
1241 | 1228 | ||
1242 | 1229 | ||
1243 | 1230 | @Callable(i) | |
1244 | 1231 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
1245 | - | let $ | |
1246 | - | let emitAmountEstimated = $ | |
1247 | - | let commonState = $ | |
1248 | - | let feeAmount = $ | |
1249 | - | let bonus = $ | |
1250 | - | let paymentInAmountAsset = $ | |
1232 | + | let $t04849848655 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
1233 | + | let emitAmountEstimated = $t04849848655._1 | |
1234 | + | let commonState = $t04849848655._2 | |
1235 | + | let feeAmount = $t04849848655._3 | |
1236 | + | let bonus = $t04849848655._4 | |
1237 | + | let paymentInAmountAsset = $t04849848655._5 | |
1251 | 1238 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
1252 | 1239 | } | |
1253 | 1240 | ||
1254 | 1241 | ||
1255 | 1242 | ||
1256 | 1243 | @Callable(i) | |
1257 | 1244 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
1258 | 1245 | let isPoolOneTokenOperationsDisabled = { | |
1259 | 1246 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1260 | 1247 | if ($isInstanceOf(@, "Boolean")) | |
1261 | 1248 | then @ | |
1262 | 1249 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1263 | 1250 | } | |
1264 | 1251 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1265 | 1252 | then true | |
1266 | 1253 | else (cfgPoolStatus == PoolShutdown)) | |
1267 | 1254 | then true | |
1268 | 1255 | else isPoolOneTokenOperationsDisabled | |
1269 | 1256 | let checks = [if (if (!(isGetDisabled)) | |
1270 | 1257 | then true | |
1271 | 1258 | else isManager(i)) | |
1272 | 1259 | then true | |
1273 | 1260 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1274 | 1261 | then true | |
1275 | 1262 | else throwErr("exactly 1 payment are expected")] | |
1276 | 1263 | if ((checks == checks)) | |
1277 | 1264 | then { | |
1278 | 1265 | let outAssetId = parseAssetId(outAssetIdStr) | |
1279 | 1266 | let payment = i.payments[0] | |
1280 | 1267 | let paymentAssetId = payment.assetId | |
1281 | 1268 | let paymentAmount = payment.amount | |
1282 | 1269 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1283 | 1270 | if ((currentKLp == currentKLp)) | |
1284 | 1271 | then { | |
1285 | 1272 | let userAddress = i.caller | |
1286 | 1273 | let txId = i.transactionId | |
1287 | - | let $ | |
1288 | - | if (($ | |
1274 | + | let $t04954049693 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
1275 | + | if (($t04954049693 == $t04954049693)) | |
1289 | 1276 | then { | |
1290 | - | let outInAmountAsset = $ | |
1291 | - | let bonus = $ | |
1292 | - | let feeAmount = $ | |
1293 | - | let commonState = $ | |
1294 | - | let amountEstimated = $ | |
1277 | + | let outInAmountAsset = $t04954049693._5 | |
1278 | + | let bonus = $t04954049693._4 | |
1279 | + | let feeAmount = $t04954049693._3 | |
1280 | + | let commonState = $t04954049693._2 | |
1281 | + | let amountEstimated = $t04954049693._1 | |
1295 | 1282 | let amount = if (if ((minOutAmount > 0)) | |
1296 | 1283 | then (minOutAmount > amountEstimated) | |
1297 | 1284 | else false) | |
1298 | 1285 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1299 | 1286 | else amountEstimated | |
1300 | 1287 | let lsConf = match getLeaseProxyConfig(outAssetIdStr) { | |
1301 | 1288 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
1302 | 1289 | a | |
1303 | 1290 | case _ => | |
1304 | 1291 | throw("error lease config") | |
1305 | 1292 | } | |
1306 | 1293 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
1307 | 1294 | if ((burnInv == burnInv)) | |
1308 | 1295 | then { | |
1309 | 1296 | let withdrawState = getWithdrawAssetState(outAssetIdStr, amount) | |
1310 | 1297 | if ((withdrawState == withdrawState)) | |
1311 | 1298 | then { | |
1312 | 1299 | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1313 | 1300 | let sendFee = if ((feeAmount > 0)) | |
1314 | 1301 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1315 | 1302 | else nil | |
1316 | - | let $ | |
1303 | + | let $t05044950696 = { | |
1317 | 1304 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1318 | 1305 | then 0 | |
1319 | 1306 | else feeAmount | |
1320 | 1307 | if (outInAmountAsset) | |
1321 | 1308 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1322 | 1309 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1323 | 1310 | } | |
1324 | - | let amountAssetBalanceDelta = $ | |
1325 | - | let priceAssetBalanceDelta = $ | |
1326 | - | let $ | |
1327 | - | let refreshKLpActions = $ | |
1328 | - | let updatedKLp = $ | |
1311 | + | let amountAssetBalanceDelta = $t05044950696._1 | |
1312 | + | let priceAssetBalanceDelta = $t05044950696._2 | |
1313 | + | let $t05069950807 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1314 | + | let refreshKLpActions = $t05069950807._1 | |
1315 | + | let updatedKLp = $t05069950807._2 | |
1329 | 1316 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1330 | 1317 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1331 | - | then { | |
1332 | - | let reb = invoke(this, "rebalance", nil, nil) | |
1333 | - | if ((reb == reb)) | |
1334 | - | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1335 | - | else throw("Strict value is not equal to itself.") | |
1336 | - | } | |
1318 | + | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1337 | 1319 | else throw("Strict value is not equal to itself.") | |
1338 | 1320 | } | |
1339 | 1321 | else throw("Strict value is not equal to itself.") | |
1340 | 1322 | } | |
1341 | 1323 | else throw("Strict value is not equal to itself.") | |
1342 | 1324 | } | |
1343 | 1325 | else throw("Strict value is not equal to itself.") | |
1344 | 1326 | } | |
1345 | 1327 | else throw("Strict value is not equal to itself.") | |
1346 | 1328 | } | |
1347 | 1329 | else throw("Strict value is not equal to itself.") | |
1348 | 1330 | } | |
1349 | 1331 | ||
1350 | 1332 | ||
1351 | 1333 | ||
1352 | 1334 | @Callable(i) | |
1353 | 1335 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
1354 | - | let $ | |
1355 | - | let amountEstimated = $ | |
1356 | - | let commonState = $ | |
1357 | - | let feeAmount = $ | |
1358 | - | let bonus = $ | |
1359 | - | let outInAmountAsset = $ | |
1336 | + | let $t05108551241 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1337 | + | let amountEstimated = $t05108551241._1 | |
1338 | + | let commonState = $t05108551241._2 | |
1339 | + | let feeAmount = $t05108551241._3 | |
1340 | + | let bonus = $t05108551241._4 | |
1341 | + | let outInAmountAsset = $t05108551241._5 | |
1360 | 1342 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
1361 | 1343 | } | |
1362 | 1344 | ||
1363 | 1345 | ||
1364 | 1346 | ||
1365 | 1347 | @Callable(i) | |
1366 | 1348 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
1367 | 1349 | let isPoolOneTokenOperationsDisabled = { | |
1368 | 1350 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1369 | 1351 | if ($isInstanceOf(@, "Boolean")) | |
1370 | 1352 | then @ | |
1371 | 1353 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1372 | 1354 | } | |
1373 | 1355 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1374 | 1356 | then true | |
1375 | 1357 | else (cfgPoolStatus == PoolShutdown)) | |
1376 | 1358 | then true | |
1377 | 1359 | else isPoolOneTokenOperationsDisabled | |
1378 | 1360 | let checks = [if (if (!(isGetDisabled)) | |
1379 | 1361 | then true | |
1380 | 1362 | else isManager(i)) | |
1381 | 1363 | then true | |
1382 | 1364 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1383 | 1365 | then true | |
1384 | 1366 | else throwErr("no payments are expected")] | |
1385 | 1367 | if ((checks == checks)) | |
1386 | 1368 | then { | |
1387 | 1369 | let outAssetId = parseAssetId(outAssetIdStr) | |
1388 | 1370 | let userAddress = i.caller | |
1389 | 1371 | let txId = i.transactionId | |
1390 | 1372 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1391 | 1373 | if ((currentKLp == currentKLp)) | |
1392 | 1374 | then { | |
1393 | 1375 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1394 | 1376 | if ((unstakeInv == unstakeInv)) | |
1395 | 1377 | then { | |
1396 | - | let $ | |
1397 | - | if (($ | |
1378 | + | let $t05214652297 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1379 | + | if (($t05214652297 == $t05214652297)) | |
1398 | 1380 | then { | |
1399 | - | let outInAmountAsset = $ | |
1400 | - | let bonus = $ | |
1401 | - | let feeAmount = $ | |
1402 | - | let commonState = $ | |
1403 | - | let amountEstimated = $ | |
1381 | + | let outInAmountAsset = $t05214652297._5 | |
1382 | + | let bonus = $t05214652297._4 | |
1383 | + | let feeAmount = $t05214652297._3 | |
1384 | + | let commonState = $t05214652297._2 | |
1385 | + | let amountEstimated = $t05214652297._1 | |
1404 | 1386 | let amount = if (if ((minOutAmount > 0)) | |
1405 | 1387 | then (minOutAmount > amountEstimated) | |
1406 | 1388 | else false) | |
1407 | 1389 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1408 | 1390 | else amountEstimated | |
1409 | 1391 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1410 | 1392 | if ((burnInv == burnInv)) | |
1411 | 1393 | then { | |
1412 | 1394 | let withdrawState = getWithdrawAssetState(outAssetIdStr, amount) | |
1413 | 1395 | if ((withdrawState == withdrawState)) | |
1414 | 1396 | then { | |
1415 | 1397 | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1416 | 1398 | let sendFee = if ((feeAmount > 0)) | |
1417 | 1399 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1418 | 1400 | else nil | |
1419 | - | let $ | |
1401 | + | let $t05286253109 = { | |
1420 | 1402 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1421 | 1403 | then 0 | |
1422 | 1404 | else feeAmount | |
1423 | 1405 | if (outInAmountAsset) | |
1424 | 1406 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1425 | 1407 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1426 | 1408 | } | |
1427 | - | let amountAssetBalanceDelta = $ | |
1428 | - | let priceAssetBalanceDelta = $ | |
1429 | - | let $ | |
1430 | - | let refreshKLpActions = $ | |
1431 | - | let updatedKLp = $ | |
1409 | + | let amountAssetBalanceDelta = $t05286253109._1 | |
1410 | + | let priceAssetBalanceDelta = $t05286253109._2 | |
1411 | + | let $t05311253220 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1412 | + | let refreshKLpActions = $t05311253220._1 | |
1413 | + | let updatedKLp = $t05311253220._2 | |
1432 | 1414 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1433 | 1415 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1434 | - | then { | |
1435 | - | let reb = invoke(this, "rebalance", nil, nil) | |
1436 | - | if ((reb == reb)) | |
1437 | - | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1438 | - | else throw("Strict value is not equal to itself.") | |
1439 | - | } | |
1416 | + | then $Tuple2(((((commonState ++ withdrawState) ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1440 | 1417 | else throw("Strict value is not equal to itself.") | |
1441 | 1418 | } | |
1442 | 1419 | else throw("Strict value is not equal to itself.") | |
1443 | 1420 | } | |
1444 | 1421 | else throw("Strict value is not equal to itself.") | |
1445 | 1422 | } | |
1446 | 1423 | else throw("Strict value is not equal to itself.") | |
1447 | 1424 | } | |
1448 | 1425 | else throw("Strict value is not equal to itself.") | |
1449 | 1426 | } | |
1450 | 1427 | else throw("Strict value is not equal to itself.") | |
1451 | 1428 | } | |
1452 | 1429 | else throw("Strict value is not equal to itself.") | |
1453 | 1430 | } | |
1454 | 1431 | ||
1455 | 1432 | ||
1456 | 1433 | ||
1457 | 1434 | @Callable(i) | |
1458 | 1435 | func get () = { | |
1459 | 1436 | let res = commonGet(i) | |
1460 | 1437 | let outAmtAmt = res._1 | |
1461 | 1438 | let outPrAmt = res._2 | |
1462 | 1439 | let pmtAmt = res._3 | |
1463 | 1440 | let pmtAssetId = res._4 | |
1464 | 1441 | let state = res._5 | |
1465 | 1442 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1466 | 1443 | if ((currentKLp == currentKLp)) | |
1467 | 1444 | then { | |
1468 | 1445 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1469 | 1446 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1470 | 1447 | then { | |
1471 | - | let $ | |
1472 | - | let refreshKLpActions = $ | |
1473 | - | let updatedKLp = $ | |
1448 | + | let $t05418754269 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1449 | + | let refreshKLpActions = $t05418754269._1 | |
1450 | + | let updatedKLp = $t05418754269._2 | |
1474 | 1451 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1475 | 1452 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1476 | 1453 | then (state ++ refreshKLpActions) | |
1477 | 1454 | else throw("Strict value is not equal to itself.") | |
1478 | 1455 | } | |
1479 | 1456 | else throw("Strict value is not equal to itself.") | |
1480 | 1457 | } | |
1481 | 1458 | else throw("Strict value is not equal to itself.") | |
1482 | 1459 | } | |
1483 | 1460 | ||
1484 | 1461 | ||
1485 | 1462 | ||
1486 | 1463 | @Callable(i) | |
1487 | 1464 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1488 | 1465 | let res = commonGet(i) | |
1489 | 1466 | let outAmAmt = res._1 | |
1490 | 1467 | let outPrAmt = res._2 | |
1491 | 1468 | let pmtAmt = res._3 | |
1492 | 1469 | let pmtAssetId = res._4 | |
1493 | 1470 | let state = res._5 | |
1494 | 1471 | if ((noLessThenAmtAsset > outAmAmt)) | |
1495 | 1472 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1496 | 1473 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1497 | 1474 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1498 | 1475 | else { | |
1499 | 1476 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1500 | 1477 | if ((currentKLp == currentKLp)) | |
1501 | 1478 | then { | |
1502 | 1479 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1503 | 1480 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1504 | 1481 | then { | |
1505 | - | let $ | |
1506 | - | let refreshKLpActions = $ | |
1507 | - | let updatedKLp = $ | |
1482 | + | let $t05521855299 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1483 | + | let refreshKLpActions = $t05521855299._1 | |
1484 | + | let updatedKLp = $t05521855299._2 | |
1508 | 1485 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1509 | 1486 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1510 | 1487 | then (state ++ refreshKLpActions) | |
1511 | 1488 | else throw("Strict value is not equal to itself.") | |
1512 | 1489 | } | |
1513 | 1490 | else throw("Strict value is not equal to itself.") | |
1514 | 1491 | } | |
1515 | 1492 | else throw("Strict value is not equal to itself.") | |
1516 | 1493 | } | |
1517 | 1494 | } | |
1518 | 1495 | ||
1519 | 1496 | ||
1520 | 1497 | ||
1521 | 1498 | @Callable(i) | |
1522 | 1499 | func unstakeAndGet (amount) = { | |
1523 | 1500 | let checkPayments = if ((size(i.payments) != 0)) | |
1524 | 1501 | then throw("No payments are expected") | |
1525 | 1502 | else true | |
1526 | 1503 | if ((checkPayments == checkPayments)) | |
1527 | 1504 | then { | |
1528 | 1505 | let cfg = getPoolConfig() | |
1529 | 1506 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1530 | 1507 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1531 | 1508 | if ((currentKLp == currentKLp)) | |
1532 | 1509 | then { | |
1533 | 1510 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1534 | 1511 | if ((unstakeInv == unstakeInv)) | |
1535 | 1512 | then { | |
1536 | 1513 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1537 | 1514 | let outAmAmt = res._1 | |
1538 | 1515 | let outPrAmt = res._2 | |
1539 | 1516 | let poolStatus = parseIntValue(res._9) | |
1540 | 1517 | let state = res._10 | |
1541 | 1518 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1542 | 1519 | then true | |
1543 | 1520 | else (poolStatus == PoolShutdown)) | |
1544 | 1521 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1545 | 1522 | else true | |
1546 | 1523 | if ((checkPoolStatus == checkPoolStatus)) | |
1547 | 1524 | then { | |
1548 | 1525 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1549 | 1526 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1550 | 1527 | then { | |
1551 | - | let $ | |
1552 | - | let refreshKLpActions = $ | |
1553 | - | let updatedKLp = $ | |
1528 | + | let $t05642556506 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1529 | + | let refreshKLpActions = $t05642556506._1 | |
1530 | + | let updatedKLp = $t05642556506._2 | |
1554 | 1531 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1555 | 1532 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1556 | 1533 | then (state ++ refreshKLpActions) | |
1557 | 1534 | else throw("Strict value is not equal to itself.") | |
1558 | 1535 | } | |
1559 | 1536 | else throw("Strict value is not equal to itself.") | |
1560 | 1537 | } | |
1561 | 1538 | else throw("Strict value is not equal to itself.") | |
1562 | 1539 | } | |
1563 | 1540 | else throw("Strict value is not equal to itself.") | |
1564 | 1541 | } | |
1565 | 1542 | else throw("Strict value is not equal to itself.") | |
1566 | 1543 | } | |
1567 | 1544 | else throw("Strict value is not equal to itself.") | |
1568 | 1545 | } | |
1569 | 1546 | ||
1570 | 1547 | ||
1571 | 1548 | ||
1572 | 1549 | @Callable(i) | |
1573 | 1550 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1574 | 1551 | let isGetDisabled = if (isGlobalShutdown()) | |
1575 | 1552 | then true | |
1576 | 1553 | else (cfgPoolStatus == PoolShutdown) | |
1577 | 1554 | let checks = [if (!(isGetDisabled)) | |
1578 | 1555 | then true | |
1579 | 1556 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1580 | 1557 | then true | |
1581 | 1558 | else throw("no payments are expected")] | |
1582 | 1559 | if ((checks == checks)) | |
1583 | 1560 | then { | |
1584 | 1561 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1585 | 1562 | if ((currentKLp == currentKLp)) | |
1586 | 1563 | then { | |
1587 | 1564 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1588 | 1565 | if ((unstakeInv == unstakeInv)) | |
1589 | 1566 | then { | |
1590 | 1567 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1591 | 1568 | let outAmAmt = res._1 | |
1592 | 1569 | let outPrAmt = res._2 | |
1593 | 1570 | let state = res._10 | |
1594 | 1571 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1595 | 1572 | then true | |
1596 | 1573 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1597 | 1574 | then true | |
1598 | 1575 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1599 | 1576 | if ((checkAmounts == checkAmounts)) | |
1600 | 1577 | then { | |
1601 | 1578 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1602 | 1579 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1603 | 1580 | then { | |
1604 | - | let $ | |
1605 | - | let refreshKLpActions = $ | |
1606 | - | let updatedKLp = $ | |
1581 | + | let $t05780157882 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1582 | + | let refreshKLpActions = $t05780157882._1 | |
1583 | + | let updatedKLp = $t05780157882._2 | |
1607 | 1584 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1608 | 1585 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1609 | 1586 | then (state ++ refreshKLpActions) | |
1610 | 1587 | else throw("Strict value is not equal to itself.") | |
1611 | 1588 | } | |
1612 | 1589 | else throw("Strict value is not equal to itself.") | |
1613 | 1590 | } | |
1614 | 1591 | else throw("Strict value is not equal to itself.") | |
1615 | 1592 | } | |
1616 | 1593 | else throw("Strict value is not equal to itself.") | |
1617 | 1594 | } | |
1618 | 1595 | else throw("Strict value is not equal to itself.") | |
1619 | 1596 | } | |
1620 | 1597 | else throw("Strict value is not equal to itself.") | |
1621 | 1598 | } | |
1622 | 1599 | ||
1623 | 1600 | ||
1624 | 1601 | ||
1625 | 1602 | @Callable(i) | |
1626 | 1603 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1627 | 1604 | then throw("permissions denied") | |
1628 | 1605 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1629 | 1606 | ||
1630 | 1607 | ||
1631 | 1608 | ||
1632 | 1609 | @Callable(i) | |
1633 | 1610 | func refreshKLp () = { | |
1634 | 1611 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1635 | 1612 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1636 | 1613 | then unit | |
1637 | 1614 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1638 | 1615 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1639 | 1616 | then { | |
1640 | 1617 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1641 | - | let $ | |
1642 | - | let kLpUpdateActions = $ | |
1643 | - | let updatedKLp = $ | |
1618 | + | let $t05906959133 = refreshKLpInternal(0, 0, 0) | |
1619 | + | let kLpUpdateActions = $t05906959133._1 | |
1620 | + | let updatedKLp = $t05906959133._2 | |
1644 | 1621 | let actions = if ((kLp != updatedKLp)) | |
1645 | 1622 | then kLpUpdateActions | |
1646 | 1623 | else throwErr("nothing to refresh") | |
1647 | 1624 | $Tuple2(actions, toString(updatedKLp)) | |
1648 | 1625 | } | |
1649 | 1626 | else throw("Strict value is not equal to itself.") | |
1650 | 1627 | } | |
1651 | 1628 | ||
1652 | 1629 | ||
1653 | 1630 | ||
1654 | 1631 | @Callable(i) | |
1655 | 1632 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1656 | 1633 | ||
1657 | 1634 | ||
1658 | 1635 | ||
1659 | 1636 | @Callable(i) | |
1660 | 1637 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1661 | 1638 | ||
1662 | 1639 | ||
1663 | 1640 | ||
1664 | 1641 | @Callable(i) | |
1665 | 1642 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1666 | 1643 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1667 | 1644 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1668 | 1645 | } | |
1669 | 1646 | ||
1670 | 1647 | ||
1671 | 1648 | ||
1672 | 1649 | @Callable(i) | |
1673 | 1650 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1674 | 1651 | ||
1675 | 1652 | ||
1676 | 1653 | ||
1677 | 1654 | @Callable(i) | |
1678 | 1655 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1679 | 1656 | ||
1680 | 1657 | ||
1681 | 1658 | ||
1682 | 1659 | @Callable(i) | |
1683 | 1660 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1684 | 1661 | ||
1685 | 1662 | ||
1686 | 1663 | ||
1687 | 1664 | @Callable(i) | |
1688 | 1665 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1689 | 1666 | ||
1690 | 1667 | ||
1691 | 1668 | ||
1692 | 1669 | @Callable(i) | |
1693 | 1670 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1694 | 1671 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1695 | 1672 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1696 | 1673 | } | |
1697 | 1674 | ||
1698 | 1675 | ||
1699 | 1676 | ||
1700 | 1677 | @Callable(i) | |
1701 | 1678 | func statsREADONLY () = { | |
1702 | 1679 | let cfg = getPoolConfig() | |
1703 | 1680 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1704 | 1681 | let amtAssetId = cfg[idxAmtAssetId] | |
1705 | 1682 | let priceAssetId = cfg[idxPriceAssetId] | |
1706 | 1683 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1707 | 1684 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1708 | 1685 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1709 | 1686 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1710 | 1687 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1711 | 1688 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1712 | 1689 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1713 | 1690 | let pricesList = if ((poolLPBalance == 0)) | |
1714 | 1691 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1715 | 1692 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1716 | 1693 | let curPrice = 0 | |
1717 | 1694 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1718 | 1695 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1719 | 1696 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1720 | 1697 | $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)) | |
1721 | 1698 | } | |
1722 | 1699 | ||
1723 | 1700 | ||
1724 | 1701 | ||
1725 | 1702 | @Callable(i) | |
1726 | 1703 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1727 | 1704 | let cfg = getPoolConfig() | |
1728 | 1705 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1729 | 1706 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1730 | 1707 | let amAssetId = fromBase58String(amAssetIdStr) | |
1731 | 1708 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1732 | 1709 | let prAssetId = fromBase58String(prAssetIdStr) | |
1733 | 1710 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1734 | 1711 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1735 | 1712 | let poolStatus = cfg[idxPoolStatus] | |
1736 | 1713 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1737 | 1714 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1738 | 1715 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1739 | 1716 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1740 | 1717 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1741 | 1718 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1742 | 1719 | then zeroBigInt | |
1743 | 1720 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1744 | 1721 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1745 | 1722 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1746 | 1723 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1747 | 1724 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1748 | 1725 | let calcLpAmt = estPut._1 | |
1749 | 1726 | let curPriceCalc = estPut._3 | |
1750 | 1727 | let amBalance = estPut._4 | |
1751 | 1728 | let prBalance = estPut._5 | |
1752 | 1729 | let lpEmission = estPut._6 | |
1753 | 1730 | $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)) | |
1754 | 1731 | } | |
1755 | 1732 | ||
1756 | 1733 | ||
1757 | 1734 | ||
1758 | 1735 | @Callable(i) | |
1759 | 1736 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1760 | 1737 | let cfg = getPoolConfig() | |
1761 | 1738 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1762 | 1739 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1763 | 1740 | let amAssetId = fromBase58String(amAssetIdStr) | |
1764 | 1741 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1765 | 1742 | let prAssetId = fromBase58String(prAssetIdStr) | |
1766 | 1743 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1767 | 1744 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1768 | 1745 | let poolStatus = cfg[idxPoolStatus] | |
1769 | 1746 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1770 | 1747 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1771 | 1748 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1772 | 1749 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1773 | 1750 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1774 | 1751 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1775 | 1752 | then zeroBigInt | |
1776 | 1753 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1777 | 1754 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1778 | 1755 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1779 | 1756 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1780 | 1757 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1781 | 1758 | let calcLpAmt = estPut._1 | |
1782 | 1759 | let curPriceCalc = estPut._3 | |
1783 | 1760 | let amBalance = estPut._4 | |
1784 | 1761 | let prBalance = estPut._5 | |
1785 | 1762 | let lpEmission = estPut._6 | |
1786 | 1763 | $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)) | |
1787 | 1764 | } | |
1788 | 1765 | ||
1789 | 1766 | ||
1790 | 1767 | ||
1791 | 1768 | @Callable(i) | |
1792 | 1769 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1793 | 1770 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1794 | 1771 | let outAmAmt = res._1 | |
1795 | 1772 | let outPrAmt = res._2 | |
1796 | 1773 | let amBalance = res._5 | |
1797 | 1774 | let prBalance = res._6 | |
1798 | 1775 | let lpEmission = res._7 | |
1799 | 1776 | let curPrice = res._8 | |
1800 | 1777 | let poolStatus = parseIntValue(res._9) | |
1801 | 1778 | $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)) | |
1802 | 1779 | } | |
1803 | 1780 | ||
1804 | 1781 | ||
1805 | 1782 | @Verifier(tx) | |
1806 | 1783 | func verify () = { | |
1807 | 1784 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1808 | 1785 | case pk: ByteVector => | |
1809 | 1786 | pk | |
1810 | 1787 | case _: Unit => | |
1811 | 1788 | tx.senderPublicKey | |
1812 | 1789 | case _ => | |
1813 | 1790 | throw("Match error") | |
1814 | 1791 | } | |
1815 | 1792 | match tx { | |
1816 | 1793 | case order: Order => | |
1817 | 1794 | let matcherPub = getMatcherPubOrFail() | |
1818 | - | let $ | |
1819 | - | let orderValid = $ | |
1820 | - | let orderValidInfo = $ | |
1795 | + | let $t06779567864 = validateMatcherOrderAllowed(order) | |
1796 | + | let orderValid = $t06779567864._1 | |
1797 | + | let orderValidInfo = $t06779567864._2 | |
1821 | 1798 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1822 | 1799 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1823 | 1800 | if (if (if (orderValid) | |
1824 | 1801 | then senderValid | |
1825 | 1802 | else false) | |
1826 | 1803 | then matcherValid | |
1827 | 1804 | else false) | |
1828 | 1805 | then true | |
1829 | 1806 | else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid) | |
1830 | 1807 | case s: SetScriptTransaction => | |
1831 | 1808 | if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)) | |
1832 | 1809 | then true | |
1833 | 1810 | else { | |
1834 | 1811 | let newHash = blake2b256(value(s.script)) | |
1835 | 1812 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1836 | 1813 | let currentHash = scriptHash(this) | |
1837 | 1814 | if ((allowedHash == newHash)) | |
1838 | 1815 | then (currentHash != newHash) | |
1839 | 1816 | else false | |
1840 | 1817 | } | |
1841 | 1818 | case _ => | |
1842 | 1819 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1843 | 1820 | } | |
1844 | 1821 | } | |
1845 | 1822 |
github/deemru/w8io/026f985 245.53 ms ◑