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