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