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