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