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