tx · DYadHYxnezfEUD9ixbp4g11rYNndCmzJkKbxD1mfmR3r 3N8zA3j2sHG1F3VGcUcm6A1NVXbFArVt3bV: -0.03500000 Waves 2022.12.07 16:01 [2349956] smart account 3N8zA3j2sHG1F3VGcUcm6A1NVXbFArVt3bV > SELF 0.00000000 Waves
{ "type": 13, "id": "DYadHYxnezfEUD9ixbp4g11rYNndCmzJkKbxD1mfmR3r", "fee": 3500000, "feeAssetId": null, "timestamp": 1670417900960, "version": 1, "sender": "3N8zA3j2sHG1F3VGcUcm6A1NVXbFArVt3bV", "senderPublicKey": "HUFUGJzGXiwdbHEELirotDoiq8roKRzpTTM1vPq5QgpM", "proofs": [ "Fz3MjSZ3ojGQEVCvkg11sYqSK337A7ojumX6TZtFJ91RjP3293YEi5vkYX6UWabVuU4iuRYGuEeV1JWKe1sPcUj" ], "script": "base64:BgL1LAgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQXNzZXREY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MJAJEDAggFAmd6BnByb29mcwAABQJnQkW6zQo=", "chainId": 84, "height": 2349956, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7f1qYc3UvtCvggqwci3W4VSx3hmQqb8bz7dpbWRxczP4 Next: BE1WWpSPekPh2Co76GK6RCZRBSMuBxbwqhbozcfqqJwp Diff:
Old | New | Differences | |
---|---|---|---|
342 | 342 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
343 | 343 | else { | |
344 | 344 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
345 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
346 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
345 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18, CEILING) | |
346 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18, CEILING) | |
347 | 347 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
348 | 348 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
349 | 349 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
374 | 374 | ||
375 | 375 | ||
376 | 376 | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
377 | - | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, | |
377 | + | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
378 | 378 | if ((lpEmission == big0)) | |
379 | 379 | then big0 | |
380 | 380 | else updatedKLp | |
408 | 408 | func validateMatcherOrderAllowed (order) = { | |
409 | 409 | let amountAssetAmount = order.amount | |
410 | 410 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
411 | - | let $ | |
411 | + | let $t02035920571 = if ((order.orderType == Buy)) | |
412 | 412 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
413 | 413 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
414 | - | let amountAssetBalanceDelta = $ | |
415 | - | let priceAssetBalanceDelta = $ | |
414 | + | let amountAssetBalanceDelta = $t02035920571._1 | |
415 | + | let priceAssetBalanceDelta = $t02035920571._2 | |
416 | 416 | if (if (if (isGlobalShutdown()) | |
417 | 417 | then true | |
418 | 418 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
425 | 425 | then throw("Wrong order assets.") | |
426 | 426 | else { | |
427 | 427 | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
428 | - | let $ | |
429 | - | let unusedActions = $ | |
430 | - | let kLpNew = $ | |
428 | + | let $t02104221142 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
429 | + | let unusedActions = $t02104221142._1 | |
430 | + | let kLpNew = $t02104221142._2 | |
431 | 431 | let isOrderValid = (kLpNew >= kLp) | |
432 | 432 | isOrderValid | |
433 | 433 | } | |
503 | 503 | else if ((paymentAssetId == cfgPriceAssetId)) | |
504 | 504 | then false | |
505 | 505 | else throwErr("invalid asset") | |
506 | - | let $ | |
506 | + | let $t02382724120 = if (isEval) | |
507 | 507 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
508 | 508 | else if (paymentInAmountAsset) | |
509 | 509 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
510 | 510 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
511 | - | let amountBalanceOld = $ | |
512 | - | let priceBalanceOld = $ | |
513 | - | let $ | |
511 | + | let amountBalanceOld = $t02382724120._1 | |
512 | + | let priceBalanceOld = $t02382724120._2 | |
513 | + | let $t02412424273 = if (paymentInAmountAsset) | |
514 | 514 | then $Tuple2(paymentAmountRaw, 0) | |
515 | 515 | else $Tuple2(0, paymentAmountRaw) | |
516 | - | let amountAssetAmountRaw = $ | |
517 | - | let priceAssetAmountRaw = $ | |
516 | + | let amountAssetAmountRaw = $t02412424273._1 | |
517 | + | let priceAssetAmountRaw = $t02412424273._2 | |
518 | 518 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
519 | 519 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
520 | - | let $ | |
521 | - | let paymentAmount = $ | |
522 | - | let feeAmount = $ | |
520 | + | let $t02439524454 = takeFee(paymentAmountRaw) | |
521 | + | let paymentAmount = $t02439524454._1 | |
522 | + | let feeAmount = $t02439524454._2 | |
523 | 523 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
524 | 524 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
525 | 525 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
542 | 542 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
543 | 543 | let priceOld = fromX18(priceOldX18, scale8) | |
544 | 544 | let loss = { | |
545 | - | let $ | |
545 | + | let $t02593126098 = if (paymentInAmountAsset) | |
546 | 546 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
547 | 547 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
548 | - | let amount = $ | |
549 | - | let balance = $ | |
548 | + | let amount = $t02593126098._1 | |
549 | + | let balance = $t02593126098._2 | |
550 | 550 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
551 | 551 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
552 | 552 | } | |
580 | 580 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
581 | 581 | let redeemedBigInt = toBigInt(paymentAmount) | |
582 | 582 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
583 | - | let $ | |
584 | - | let totalAmount = $ | |
585 | - | let feeAmount = $ | |
586 | - | let $ | |
583 | + | let $t02770027750 = takeFee(amountRaw) | |
584 | + | let totalAmount = $t02770027750._1 | |
585 | + | let feeAmount = $t02770027750._2 | |
586 | + | let $t02775427980 = if (outInAmountAsset) | |
587 | 587 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
588 | 588 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
589 | - | let outAmAmount = $ | |
590 | - | let outPrAmount = $ | |
591 | - | let amBalanceNew = $ | |
592 | - | let prBalanceNew = $ | |
589 | + | let outAmAmount = $t02775427980._1 | |
590 | + | let outPrAmount = $t02775427980._2 | |
591 | + | let amBalanceNew = $t02775427980._3 | |
592 | + | let prBalanceNew = $t02775427980._4 | |
593 | 593 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
594 | 594 | let priceNew = fromX18(priceNewX18, scale8) | |
595 | 595 | let commonState = if (isEval) | |
703 | 703 | let prId = estPut._13 | |
704 | 704 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
705 | 705 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
706 | - | let | |
707 | - | if (( | |
706 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt) | |
707 | + | if ((amountAssetBalance == amountAssetBalance)) | |
708 | 708 | then { | |
709 | - | let | |
710 | - | if (( | |
709 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt) | |
710 | + | if ((priceAssetBalance == priceAssetBalance)) | |
711 | 711 | then { | |
712 | - | let emitInvLegacy = match emitInv { | |
713 | - | case legacyFactoryContract: Address => | |
714 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
715 | - | case _ => | |
716 | - | unit | |
717 | - | } | |
718 | - | if ((emitInvLegacy == emitInvLegacy)) | |
712 | + | let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity) | |
713 | + | if ((lpAssetEmission == lpAssetEmission)) | |
719 | 714 | then { | |
720 | - | let slippageAInv = if ((amDiff > 0)) | |
721 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
722 | - | else nil | |
723 | - | if ((slippageAInv == slippageAInv)) | |
715 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
716 | + | if ((currentKLp == currentKLp)) | |
724 | 717 | then { | |
725 | - | let slippagePInv = if ((prDiff > 0)) | |
726 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
727 | - | else nil | |
728 | - | if ((slippagePInv == slippagePInv)) | |
718 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
719 | + | if ((emitInv == emitInv)) | |
729 | 720 | then { | |
730 | - | let lpTransfer = if (shouldAutoStake) | |
721 | + | let emitInvLegacy = match emitInv { | |
722 | + | case legacyFactoryContract: Address => | |
723 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
724 | + | case _ => | |
725 | + | unit | |
726 | + | } | |
727 | + | if ((emitInvLegacy == emitInvLegacy)) | |
731 | 728 | then { | |
732 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
733 | - | if ((slpStakeInv == slpStakeInv)) | |
734 | - | then nil | |
735 | - | else throw("Strict value is not equal to itself.") | |
736 | - | } | |
737 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
738 | - | let $t03211432182 = refreshKLpInternal(0, 0, 0) | |
739 | - | if (($t03211432182 == $t03211432182)) | |
740 | - | then { | |
741 | - | let updatedKLp = $t03211432182._2 | |
742 | - | let refreshKLpActions = $t03211432182._1 | |
743 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
744 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
745 | - | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
729 | + | let slippageAInv = if ((amDiff > 0)) | |
730 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
731 | + | else nil | |
732 | + | if ((slippageAInv == slippageAInv)) | |
733 | + | then { | |
734 | + | let slippagePInv = if ((prDiff > 0)) | |
735 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
736 | + | else nil | |
737 | + | if ((slippagePInv == slippagePInv)) | |
738 | + | then { | |
739 | + | let lpTransfer = if (shouldAutoStake) | |
740 | + | then { | |
741 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
742 | + | if ((slpStakeInv == slpStakeInv)) | |
743 | + | then nil | |
744 | + | else throw("Strict value is not equal to itself.") | |
745 | + | } | |
746 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
747 | + | let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity | |
748 | + | if ((lpAssetEmissionAfter == lpAssetEmissionAfter)) | |
749 | + | then { | |
750 | + | let $t03250032568 = refreshKLpInternal(0, 0, 0) | |
751 | + | if (($t03250032568 == $t03250032568)) | |
752 | + | then { | |
753 | + | let updatedKLp = $t03250032568._2 | |
754 | + | let refreshKLpActions = $t03250032568._1 | |
755 | + | let error = throwErr(makeString([toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentKLp), toString(updatedKLp), toString(emitLpAmt), toString(amDiff), toString(prDiff), toString(lpAssetEmission), toString(lpAssetEmissionAfter)], " ")) | |
756 | + | if ((error == error)) | |
757 | + | then { | |
758 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
759 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
760 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
761 | + | else throw("Strict value is not equal to itself.") | |
762 | + | } | |
763 | + | else throw("Strict value is not equal to itself.") | |
764 | + | } | |
765 | + | else throw("Strict value is not equal to itself.") | |
766 | + | } | |
767 | + | else throw("Strict value is not equal to itself.") | |
768 | + | } | |
769 | + | else throw("Strict value is not equal to itself.") | |
770 | + | } | |
746 | 771 | else throw("Strict value is not equal to itself.") | |
747 | 772 | } | |
748 | 773 | else throw("Strict value is not equal to itself.") | |
771 | 796 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
772 | 797 | if ((currentKLp == currentKLp)) | |
773 | 798 | then { | |
774 | - | let $ | |
775 | - | let refreshKLpActions = $ | |
776 | - | let updatedKLp = $ | |
799 | + | let $t03350033565 = refreshKLpInternal(0, 0, 0) | |
800 | + | let refreshKLpActions = $t03350033565._1 | |
801 | + | let updatedKLp = $t03350033565._2 | |
777 | 802 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
778 | 803 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
779 | 804 | then (state ++ refreshKLpActions) | |
818 | 843 | else throwErr("payment asset is not supported") | |
819 | 844 | let userAddress = i.caller | |
820 | 845 | let txId = i.transactionId | |
821 | - | let $ | |
822 | - | if (($ | |
846 | + | let $t03475034902 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
847 | + | if (($t03475034902 == $t03475034902)) | |
823 | 848 | then { | |
824 | - | let paymentInAmountAsset = $ | |
825 | - | let bonus = $ | |
826 | - | let feeAmount = $ | |
827 | - | let commonState = $ | |
828 | - | let emitAmountEstimated = $ | |
849 | + | let paymentInAmountAsset = $t03475034902._5 | |
850 | + | let bonus = $t03475034902._4 | |
851 | + | let feeAmount = $t03475034902._3 | |
852 | + | let commonState = $t03475034902._2 | |
853 | + | let emitAmountEstimated = $t03475034902._1 | |
829 | 854 | let emitAmount = if (if ((minOutAmount > 0)) | |
830 | 855 | then (minOutAmount > emitAmountEstimated) | |
831 | 856 | else false) | |
845 | 870 | let sendFee = if ((feeAmount > 0)) | |
846 | 871 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
847 | 872 | else nil | |
848 | - | let $ | |
873 | + | let $t03548835685 = if ((this == feeCollectorAddress)) | |
849 | 874 | then $Tuple2(0, 0) | |
850 | 875 | else if (paymentInAmountAsset) | |
851 | 876 | then $Tuple2(-(feeAmount), 0) | |
852 | 877 | else $Tuple2(0, -(feeAmount)) | |
853 | - | let amountAssetBalanceDelta = $ | |
854 | - | let priceAssetBalanceDelta = $ | |
855 | - | let $ | |
856 | - | let refreshKLpActions = $ | |
857 | - | let updatedKLp = $ | |
878 | + | let amountAssetBalanceDelta = $t03548835685._1 | |
879 | + | let priceAssetBalanceDelta = $t03548835685._2 | |
880 | + | let $t03568835796 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
881 | + | let refreshKLpActions = $t03568835796._1 | |
882 | + | let updatedKLp = $t03568835796._2 | |
858 | 883 | let kLp = value(getString(keyKLp)) | |
859 | 884 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
860 | 885 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
872 | 897 | ||
873 | 898 | @Callable(i) | |
874 | 899 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
875 | - | let $ | |
876 | - | let emitAmountEstimated = $ | |
877 | - | let commonState = $ | |
878 | - | let feeAmount = $ | |
879 | - | let bonus = $ | |
880 | - | let paymentInAmountAsset = $ | |
900 | + | let $t03610236259 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
901 | + | let emitAmountEstimated = $t03610236259._1 | |
902 | + | let commonState = $t03610236259._2 | |
903 | + | let feeAmount = $t03610236259._3 | |
904 | + | let bonus = $t03610236259._4 | |
905 | + | let paymentInAmountAsset = $t03610236259._5 | |
881 | 906 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
882 | 907 | } | |
883 | 908 | ||
912 | 937 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount)) | |
913 | 938 | let userAddress = i.caller | |
914 | 939 | let txId = i.transactionId | |
915 | - | let $ | |
916 | - | if (($ | |
940 | + | let $t03715337306 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
941 | + | if (($t03715337306 == $t03715337306)) | |
917 | 942 | then { | |
918 | - | let outInAmountAsset = $ | |
919 | - | let bonus = $ | |
920 | - | let feeAmount = $ | |
921 | - | let commonState = $ | |
922 | - | let amountEstimated = $ | |
943 | + | let outInAmountAsset = $t03715337306._5 | |
944 | + | let bonus = $t03715337306._4 | |
945 | + | let feeAmount = $t03715337306._3 | |
946 | + | let commonState = $t03715337306._2 | |
947 | + | let amountEstimated = $t03715337306._1 | |
923 | 948 | let amount = if (if ((minOutAmount > 0)) | |
924 | 949 | then (minOutAmount > amountEstimated) | |
925 | 950 | else false) | |
932 | 957 | let sendFee = if ((feeAmount > 0)) | |
933 | 958 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
934 | 959 | else nil | |
935 | - | let $ | |
960 | + | let $t03780638053 = { | |
936 | 961 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
937 | 962 | then 0 | |
938 | 963 | else feeAmount | |
940 | 965 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
941 | 966 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
942 | 967 | } | |
943 | - | let amountAssetBalanceDelta = $ | |
944 | - | let priceAssetBalanceDelta = $ | |
945 | - | let $ | |
946 | - | let refreshKLpActions = $ | |
947 | - | let updatedKLp = $ | |
968 | + | let amountAssetBalanceDelta = $t03780638053._1 | |
969 | + | let priceAssetBalanceDelta = $t03780638053._2 | |
970 | + | let $t03805638164 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
971 | + | let refreshKLpActions = $t03805638164._1 | |
972 | + | let updatedKLp = $t03805638164._2 | |
948 | 973 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
949 | 974 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
950 | 975 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
961 | 986 | ||
962 | 987 | @Callable(i) | |
963 | 988 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
964 | - | let $ | |
965 | - | let amountEstimated = $ | |
966 | - | let commonState = $ | |
967 | - | let feeAmount = $ | |
968 | - | let bonus = $ | |
969 | - | let outInAmountAsset = $ | |
989 | + | let $t03842138577 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
990 | + | let amountEstimated = $t03842138577._1 | |
991 | + | let commonState = $t03842138577._2 | |
992 | + | let feeAmount = $t03842138577._3 | |
993 | + | let bonus = $t03842138577._4 | |
994 | + | let outInAmountAsset = $t03842138577._5 | |
970 | 995 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
971 | 996 | } | |
972 | 997 | ||
1001 | 1026 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1002 | 1027 | if ((unstakeInv == unstakeInv)) | |
1003 | 1028 | then { | |
1004 | - | let $ | |
1005 | - | if (($ | |
1029 | + | let $t03947939630 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1030 | + | if (($t03947939630 == $t03947939630)) | |
1006 | 1031 | then { | |
1007 | - | let outInAmountAsset = $ | |
1008 | - | let bonus = $ | |
1009 | - | let feeAmount = $ | |
1010 | - | let commonState = $ | |
1011 | - | let amountEstimated = $ | |
1032 | + | let outInAmountAsset = $t03947939630._5 | |
1033 | + | let bonus = $t03947939630._4 | |
1034 | + | let feeAmount = $t03947939630._3 | |
1035 | + | let commonState = $t03947939630._2 | |
1036 | + | let amountEstimated = $t03947939630._1 | |
1012 | 1037 | let amount = if (if ((minOutAmount > 0)) | |
1013 | 1038 | then (minOutAmount > amountEstimated) | |
1014 | 1039 | else false) | |
1021 | 1046 | let sendFee = if ((feeAmount > 0)) | |
1022 | 1047 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1023 | 1048 | else nil | |
1024 | - | let $ | |
1049 | + | let $t04012540372 = { | |
1025 | 1050 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1026 | 1051 | then 0 | |
1027 | 1052 | else feeAmount | |
1029 | 1054 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1030 | 1055 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1031 | 1056 | } | |
1032 | - | let amountAssetBalanceDelta = $ | |
1033 | - | let priceAssetBalanceDelta = $ | |
1034 | - | let $ | |
1035 | - | let refreshKLpActions = $ | |
1036 | - | let updatedKLp = $ | |
1057 | + | let amountAssetBalanceDelta = $t04012540372._1 | |
1058 | + | let priceAssetBalanceDelta = $t04012540372._2 | |
1059 | + | let $t04037540483 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1060 | + | let refreshKLpActions = $t04037540483._1 | |
1061 | + | let updatedKLp = $t04037540483._2 | |
1037 | 1062 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1038 | 1063 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1039 | 1064 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1062 | 1087 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1063 | 1088 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1064 | 1089 | then { | |
1065 | - | let $ | |
1066 | - | let refreshKLpActions = $ | |
1067 | - | let updatedKLp = $ | |
1090 | + | let $t04143141513 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1091 | + | let refreshKLpActions = $t04143141513._1 | |
1092 | + | let updatedKLp = $t04143141513._2 | |
1068 | 1093 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1069 | 1094 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1070 | 1095 | then (state ++ refreshKLpActions) | |
1092 | 1117 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1093 | 1118 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1094 | 1119 | then { | |
1095 | - | let $ | |
1096 | - | let refreshKLpActions = $ | |
1097 | - | let updatedKLp = $ | |
1120 | + | let $t04246442545 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1121 | + | let refreshKLpActions = $t04246442545._1 | |
1122 | + | let updatedKLp = $t04246442545._2 | |
1098 | 1123 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1099 | 1124 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1100 | 1125 | then (state ++ refreshKLpActions) | |
1134 | 1159 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1135 | 1160 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1136 | 1161 | then { | |
1137 | - | let $ | |
1138 | - | let refreshKLpActions = $ | |
1139 | - | let updatedKLp = $ | |
1162 | + | let $t04366843749 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1163 | + | let refreshKLpActions = $t04366843749._1 | |
1164 | + | let updatedKLp = $t04366843749._2 | |
1140 | 1165 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1141 | 1166 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1142 | 1167 | then (state ++ refreshKLpActions) | |
1183 | 1208 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1184 | 1209 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1185 | 1210 | then { | |
1186 | - | let $ | |
1187 | - | let refreshKLpActions = $ | |
1188 | - | let updatedKLp = $ | |
1211 | + | let $t04504145122 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1212 | + | let refreshKLpActions = $t04504145122._1 | |
1213 | + | let updatedKLp = $t04504145122._2 | |
1189 | 1214 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1190 | 1215 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1191 | 1216 | then (state ++ refreshKLpActions) | |
1218 | 1243 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1219 | 1244 | then { | |
1220 | 1245 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1221 | - | let $ | |
1222 | - | let kLpUpdateActions = $ | |
1223 | - | let updatedKLp = $ | |
1246 | + | let $t04630946373 = refreshKLpInternal(0, 0, 0) | |
1247 | + | let kLpUpdateActions = $t04630946373._1 | |
1248 | + | let updatedKLp = $t04630946373._2 | |
1224 | 1249 | let actions = if ((kLp != updatedKLp)) | |
1225 | 1250 | then kLpUpdateActions | |
1226 | 1251 | else throwErr("nothing to refresh") |
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 fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func abs (val) = if ((0 > val)) | |
72 | 72 | then -(val) | |
73 | 73 | else val | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func absBigInt (val) = if ((zeroBigInt > val)) | |
77 | 77 | then -(val) | |
78 | 78 | else val | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func fc () = "%s__factoryContract" | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func mpk () = "%s__managerPublicKey" | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func pmpk () = "%s__pendingManagerPublicKey" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func pl () = "%s%s__price__last" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func aa () = "%s__amountAsset" | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pa () = "%s__priceAsset" | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | let keyFee = "%s__fee" | |
109 | 109 | ||
110 | 110 | let feeDefault = fraction(10, scale8, 10000) | |
111 | 111 | ||
112 | 112 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
113 | 113 | ||
114 | 114 | let keyKLp = makeString(["%s", "kLp"], SEP) | |
115 | 115 | ||
116 | 116 | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
117 | 117 | ||
118 | 118 | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
119 | 119 | ||
120 | 120 | let kLpRefreshDelayDefault = 30 | |
121 | 121 | ||
122 | 122 | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
123 | 123 | ||
124 | 124 | func keyFactoryConfig () = "%s__factoryConfig" | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
131 | 131 | ||
132 | 132 | ||
133 | 133 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func keyAllPoolsShutdown () = "%s__shutdown" | |
140 | 140 | ||
141 | 141 | ||
142 | 142 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
143 | 143 | ||
144 | 144 | ||
145 | 145 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
146 | 146 | ||
147 | 147 | ||
148 | 148 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
149 | 149 | ||
150 | 150 | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
151 | 151 | ||
152 | 152 | ||
153 | 153 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
154 | 154 | ||
155 | 155 | ||
156 | 156 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
157 | 157 | ||
158 | 158 | ||
159 | 159 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
160 | 160 | ||
161 | 161 | ||
162 | 162 | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
163 | 163 | ||
164 | 164 | ||
165 | 165 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
166 | 166 | ||
167 | 167 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
168 | 168 | ||
169 | 169 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
170 | 170 | ||
171 | 171 | ||
172 | 172 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
173 | 173 | ||
174 | 174 | ||
175 | 175 | func getPoolConfig () = { | |
176 | 176 | let amtAsset = getStringOrFail(this, aa()) | |
177 | 177 | let priceAsset = getStringOrFail(this, pa()) | |
178 | 178 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
179 | 179 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
180 | 180 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
181 | 181 | } | |
182 | 182 | ||
183 | 183 | ||
184 | 184 | func parseAssetId (input) = if ((input == wavesString)) | |
185 | 185 | then unit | |
186 | 186 | else fromBase58String(input) | |
187 | 187 | ||
188 | 188 | ||
189 | 189 | func assetIdToString (input) = if ((input == unit)) | |
190 | 190 | then wavesString | |
191 | 191 | else toBase58String(value(input)) | |
192 | 192 | ||
193 | 193 | ||
194 | 194 | 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])) | |
195 | 195 | ||
196 | 196 | ||
197 | 197 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
198 | 198 | ||
199 | 199 | let $t079158081 = poolConfigParsed | |
200 | 200 | ||
201 | 201 | let cfgPoolAddress = $t079158081._1 | |
202 | 202 | ||
203 | 203 | let cfgPoolStatus = $t079158081._2 | |
204 | 204 | ||
205 | 205 | let cfgLpAssetId = $t079158081._3 | |
206 | 206 | ||
207 | 207 | let cfgAmountAssetId = $t079158081._4 | |
208 | 208 | ||
209 | 209 | let cfgPriceAssetId = $t079158081._5 | |
210 | 210 | ||
211 | 211 | let cfgAmountAssetDecimals = $t079158081._6 | |
212 | 212 | ||
213 | 213 | let cfgPriceAssetDecimals = $t079158081._7 | |
214 | 214 | ||
215 | 215 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
216 | 216 | ||
217 | 217 | ||
218 | 218 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
219 | 219 | ||
220 | 220 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
221 | 221 | ||
222 | 222 | 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) | |
223 | 223 | ||
224 | 224 | ||
225 | 225 | 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) | |
226 | 226 | ||
227 | 227 | ||
228 | 228 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
229 | 229 | then wavesBalance(this).available | |
230 | 230 | else assetBalance(this, fromBase58String(assetId)) | |
231 | 231 | ||
232 | 232 | ||
233 | 233 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
234 | 234 | ||
235 | 235 | ||
236 | 236 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
237 | 237 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
238 | 238 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
239 | 239 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
240 | 240 | } | |
241 | 241 | ||
242 | 242 | ||
243 | 243 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
244 | 244 | let cfg = getPoolConfig() | |
245 | 245 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
246 | 246 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
247 | 247 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
248 | 248 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
249 | 249 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
250 | 250 | let lpAmtX18 = toX18(lpAmt, scale8) | |
251 | 251 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
252 | 252 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
253 | 253 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
254 | 254 | } | |
255 | 255 | ||
256 | 256 | ||
257 | 257 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
258 | 258 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
259 | 259 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
260 | 260 | } | |
261 | 261 | ||
262 | 262 | ||
263 | 263 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
264 | 264 | let cfg = getPoolConfig() | |
265 | 265 | let lpAssetId = cfg[idxPoolLPAssetId] | |
266 | 266 | let amAssetId = cfg[idxAmtAssetId] | |
267 | 267 | let prAssetId = cfg[idxPriceAssetId] | |
268 | 268 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
269 | 269 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
270 | 270 | let poolStatus = cfg[idxPoolStatus] | |
271 | 271 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
272 | 272 | if ((lpAssetId != pmtAssetId)) | |
273 | 273 | then throw("Invalid asset passed.") | |
274 | 274 | else { | |
275 | 275 | let amBalance = getAccBalance(amAssetId) | |
276 | 276 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
277 | 277 | let prBalance = getAccBalance(prAssetId) | |
278 | 278 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
279 | 279 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
280 | 280 | let curPrice = fromX18(curPriceX18, scale8) | |
281 | 281 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
282 | 282 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
283 | 283 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
284 | 284 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
285 | 285 | let outAmAmt = fromX18(outAmAmtX18, amAssetDcm) | |
286 | 286 | let outPrAmt = fromX18(outPrAmtX18, prAssetDcm) | |
287 | 287 | let state = if ((txId58 == "")) | |
288 | 288 | then nil | |
289 | 289 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
290 | 290 | then unit | |
291 | 291 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
292 | 292 | then unit | |
293 | 293 | 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)] | |
294 | 294 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
295 | 295 | } | |
296 | 296 | } | |
297 | 297 | ||
298 | 298 | ||
299 | 299 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
300 | 300 | let cfg = getPoolConfig() | |
301 | 301 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
302 | 302 | let amAssetIdStr = cfg[idxAmtAssetId] | |
303 | 303 | let prAssetIdStr = cfg[idxPriceAssetId] | |
304 | 304 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
305 | 305 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
306 | 306 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
307 | 307 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
308 | 308 | let poolStatus = cfg[idxPoolStatus] | |
309 | 309 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
310 | 310 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
311 | 311 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
312 | 312 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
313 | 313 | then true | |
314 | 314 | else (prAssetIdStr != inPrAssetIdStr)) | |
315 | 315 | then throw("Invalid amt or price asset passed.") | |
316 | 316 | else { | |
317 | 317 | let amBalance = if (isEvaluate) | |
318 | 318 | then getAccBalance(amAssetIdStr) | |
319 | 319 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
320 | 320 | let prBalance = if (isEvaluate) | |
321 | 321 | then getAccBalance(prAssetIdStr) | |
322 | 322 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
323 | 323 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
324 | 324 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
325 | 325 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
326 | 326 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
327 | 327 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
328 | 328 | let res = if ((lpEmission == 0)) | |
329 | 329 | then { | |
330 | 330 | let curPriceX18 = zeroBigInt | |
331 | 331 | let slippageX18 = zeroBigInt | |
332 | 332 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
333 | 333 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
334 | 334 | } | |
335 | 335 | else { | |
336 | 336 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
337 | 337 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
338 | 338 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
339 | 339 | if (if ((curPriceX18 != zeroBigInt)) | |
340 | 340 | then (slippageX18 > slippageToleranceX18) | |
341 | 341 | else false) | |
342 | 342 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
343 | 343 | else { | |
344 | 344 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
345 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
346 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
345 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18, CEILING) | |
346 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18, CEILING) | |
347 | 347 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
348 | 348 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
349 | 349 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
350 | 350 | let expAmtAssetAmtX18 = expectedAmts._1 | |
351 | 351 | let expPriceAssetAmtX18 = expectedAmts._2 | |
352 | 352 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
353 | 353 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18) | |
354 | 354 | } | |
355 | 355 | } | |
356 | 356 | let calcLpAmt = res._1 | |
357 | 357 | let calcAmAssetPmt = res._2 | |
358 | 358 | let calcPrAssetPmt = res._3 | |
359 | 359 | let curPrice = fromX18(res._4, scale8) | |
360 | 360 | let slippageCalc = fromX18(res._5, scale8) | |
361 | 361 | if ((0 >= calcLpAmt)) | |
362 | 362 | then throw("Invalid calculations. LP calculated is less than zero.") | |
363 | 363 | else { | |
364 | 364 | let emitLpAmt = if (!(emitLp)) | |
365 | 365 | then 0 | |
366 | 366 | else calcLpAmt | |
367 | 367 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
368 | 368 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
369 | 369 | 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))] | |
370 | 370 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
371 | 371 | } | |
372 | 372 | } | |
373 | 373 | } | |
374 | 374 | ||
375 | 375 | ||
376 | 376 | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
377 | - | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, | |
377 | + | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
378 | 378 | if ((lpEmission == big0)) | |
379 | 379 | then big0 | |
380 | 380 | else updatedKLp | |
381 | 381 | } | |
382 | 382 | ||
383 | 383 | ||
384 | 384 | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
385 | 385 | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
386 | 386 | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
387 | 387 | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
388 | 388 | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
389 | 389 | currentKLp | |
390 | 390 | } | |
391 | 391 | ||
392 | 392 | ||
393 | 393 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
394 | 394 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
395 | 395 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
396 | 396 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
397 | 397 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
398 | 398 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
399 | 399 | $Tuple2(actions, updatedKLp) | |
400 | 400 | } | |
401 | 401 | ||
402 | 402 | ||
403 | 403 | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
404 | 404 | then true | |
405 | 405 | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
406 | 406 | ||
407 | 407 | ||
408 | 408 | func validateMatcherOrderAllowed (order) = { | |
409 | 409 | let amountAssetAmount = order.amount | |
410 | 410 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
411 | - | let $ | |
411 | + | let $t02035920571 = if ((order.orderType == Buy)) | |
412 | 412 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
413 | 413 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
414 | - | let amountAssetBalanceDelta = $ | |
415 | - | let priceAssetBalanceDelta = $ | |
414 | + | let amountAssetBalanceDelta = $t02035920571._1 | |
415 | + | let priceAssetBalanceDelta = $t02035920571._2 | |
416 | 416 | if (if (if (isGlobalShutdown()) | |
417 | 417 | then true | |
418 | 418 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
419 | 419 | then true | |
420 | 420 | else (cfgPoolStatus == PoolShutdown)) | |
421 | 421 | then throw("Exchange operations disabled") | |
422 | 422 | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
423 | 423 | then true | |
424 | 424 | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
425 | 425 | then throw("Wrong order assets.") | |
426 | 426 | else { | |
427 | 427 | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
428 | - | let $ | |
429 | - | let unusedActions = $ | |
430 | - | let kLpNew = $ | |
428 | + | let $t02104221142 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
429 | + | let unusedActions = $t02104221142._1 | |
430 | + | let kLpNew = $t02104221142._2 | |
431 | 431 | let isOrderValid = (kLpNew >= kLp) | |
432 | 432 | isOrderValid | |
433 | 433 | } | |
434 | 434 | } | |
435 | 435 | ||
436 | 436 | ||
437 | 437 | func commonGet (i) = if ((size(i.payments) != 1)) | |
438 | 438 | then throw("exactly 1 payment is expected") | |
439 | 439 | else { | |
440 | 440 | let pmt = value(i.payments[0]) | |
441 | 441 | let pmtAssetId = value(pmt.assetId) | |
442 | 442 | let pmtAmt = pmt.amount | |
443 | 443 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
444 | 444 | let outAmAmt = res._1 | |
445 | 445 | let outPrAmt = res._2 | |
446 | 446 | let poolStatus = parseIntValue(res._9) | |
447 | 447 | let state = res._10 | |
448 | 448 | if (if (isGlobalShutdown()) | |
449 | 449 | then true | |
450 | 450 | else (poolStatus == PoolShutdown)) | |
451 | 451 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
452 | 452 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
453 | 453 | } | |
454 | 454 | ||
455 | 455 | ||
456 | 456 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
457 | 457 | then throw("exactly 2 payments are expected") | |
458 | 458 | else { | |
459 | 459 | let amAssetPmt = value(i.payments[0]) | |
460 | 460 | let prAssetPmt = value(i.payments[1]) | |
461 | 461 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
462 | 462 | let poolStatus = parseIntValue(estPut._8) | |
463 | 463 | if (if (if (isGlobalShutdown()) | |
464 | 464 | then true | |
465 | 465 | else (poolStatus == PoolPutDisabled)) | |
466 | 466 | then true | |
467 | 467 | else (poolStatus == PoolShutdown)) | |
468 | 468 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
469 | 469 | else estPut | |
470 | 470 | } | |
471 | 471 | ||
472 | 472 | ||
473 | 473 | func emit (amount) = { | |
474 | 474 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
475 | 475 | if ((emitInv == emitInv)) | |
476 | 476 | then { | |
477 | 477 | let emitInvLegacy = match emitInv { | |
478 | 478 | case legacyFactoryContract: Address => | |
479 | 479 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
480 | 480 | case _ => | |
481 | 481 | unit | |
482 | 482 | } | |
483 | 483 | if ((emitInvLegacy == emitInvLegacy)) | |
484 | 484 | then amount | |
485 | 485 | else throw("Strict value is not equal to itself.") | |
486 | 486 | } | |
487 | 487 | else throw("Strict value is not equal to itself.") | |
488 | 488 | } | |
489 | 489 | ||
490 | 490 | ||
491 | 491 | func takeFee (amount) = { | |
492 | 492 | let feeAmount = fraction(amount, fee, scale8) | |
493 | 493 | $Tuple2((amount - feeAmount), feeAmount) | |
494 | 494 | } | |
495 | 495 | ||
496 | 496 | ||
497 | 497 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
498 | 498 | let isEval = (txId == unit) | |
499 | 499 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
500 | 500 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
501 | 501 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
502 | 502 | then true | |
503 | 503 | else if ((paymentAssetId == cfgPriceAssetId)) | |
504 | 504 | then false | |
505 | 505 | else throwErr("invalid asset") | |
506 | - | let $ | |
506 | + | let $t02382724120 = if (isEval) | |
507 | 507 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
508 | 508 | else if (paymentInAmountAsset) | |
509 | 509 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
510 | 510 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
511 | - | let amountBalanceOld = $ | |
512 | - | let priceBalanceOld = $ | |
513 | - | let $ | |
511 | + | let amountBalanceOld = $t02382724120._1 | |
512 | + | let priceBalanceOld = $t02382724120._2 | |
513 | + | let $t02412424273 = if (paymentInAmountAsset) | |
514 | 514 | then $Tuple2(paymentAmountRaw, 0) | |
515 | 515 | else $Tuple2(0, paymentAmountRaw) | |
516 | - | let amountAssetAmountRaw = $ | |
517 | - | let priceAssetAmountRaw = $ | |
516 | + | let amountAssetAmountRaw = $t02412424273._1 | |
517 | + | let priceAssetAmountRaw = $t02412424273._2 | |
518 | 518 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
519 | 519 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
520 | - | let $ | |
521 | - | let paymentAmount = $ | |
522 | - | let feeAmount = $ | |
520 | + | let $t02439524454 = takeFee(paymentAmountRaw) | |
521 | + | let paymentAmount = $t02439524454._1 | |
522 | + | let feeAmount = $t02439524454._2 | |
523 | 523 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
524 | 524 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
525 | 525 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
526 | 526 | let priceNew = fromX18(priceNewX18, scale8) | |
527 | 527 | let paymentBalance = if (paymentInAmountAsset) | |
528 | 528 | then amountBalanceOld | |
529 | 529 | else priceBalanceOld | |
530 | 530 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
531 | 531 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
532 | 532 | let chechSupply = if ((supplyBigInt > big0)) | |
533 | 533 | then true | |
534 | 534 | else throwErr("initial deposit requires all coins") | |
535 | 535 | if ((chechSupply == chechSupply)) | |
536 | 536 | then { | |
537 | 537 | let depositBigInt = toBigInt(paymentAmount) | |
538 | 538 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
539 | 539 | let commonState = if (isEval) | |
540 | 540 | then nil | |
541 | 541 | 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))] | |
542 | 542 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
543 | 543 | let priceOld = fromX18(priceOldX18, scale8) | |
544 | 544 | let loss = { | |
545 | - | let $ | |
545 | + | let $t02593126098 = if (paymentInAmountAsset) | |
546 | 546 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
547 | 547 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
548 | - | let amount = $ | |
549 | - | let balance = $ | |
548 | + | let amount = $t02593126098._1 | |
549 | + | let balance = $t02593126098._2 | |
550 | 550 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
551 | 551 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
552 | 552 | } | |
553 | 553 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
554 | 554 | } | |
555 | 555 | else throw("Strict value is not equal to itself.") | |
556 | 556 | } | |
557 | 557 | ||
558 | 558 | ||
559 | 559 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
560 | 560 | let isEval = (txId == unit) | |
561 | 561 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
562 | 562 | then true | |
563 | 563 | else throwErr("invalid lp asset")] | |
564 | 564 | if ((checks == checks)) | |
565 | 565 | then { | |
566 | 566 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
567 | 567 | then true | |
568 | 568 | else if ((outAssetId == cfgPriceAssetId)) | |
569 | 569 | then false | |
570 | 570 | else throwErr("invalid asset") | |
571 | 571 | let balanceBigInt = if (outInAmountAsset) | |
572 | 572 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
573 | 573 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
574 | 574 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
575 | 575 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
576 | 576 | let outBalance = if (outInAmountAsset) | |
577 | 577 | then amBalanceOld | |
578 | 578 | else prBalanceOld | |
579 | 579 | let outBalanceBigInt = toBigInt(outBalance) | |
580 | 580 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
581 | 581 | let redeemedBigInt = toBigInt(paymentAmount) | |
582 | 582 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
583 | - | let $ | |
584 | - | let totalAmount = $ | |
585 | - | let feeAmount = $ | |
586 | - | let $ | |
583 | + | let $t02770027750 = takeFee(amountRaw) | |
584 | + | let totalAmount = $t02770027750._1 | |
585 | + | let feeAmount = $t02770027750._2 | |
586 | + | let $t02775427980 = if (outInAmountAsset) | |
587 | 587 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
588 | 588 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
589 | - | let outAmAmount = $ | |
590 | - | let outPrAmount = $ | |
591 | - | let amBalanceNew = $ | |
592 | - | let prBalanceNew = $ | |
589 | + | let outAmAmount = $t02775427980._1 | |
590 | + | let outPrAmount = $t02775427980._2 | |
591 | + | let amBalanceNew = $t02775427980._3 | |
592 | + | let prBalanceNew = $t02775427980._4 | |
593 | 593 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
594 | 594 | let priceNew = fromX18(priceNewX18, scale8) | |
595 | 595 | let commonState = if (isEval) | |
596 | 596 | then nil | |
597 | 597 | 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)] | |
598 | 598 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
599 | 599 | let priceOld = fromX18(priceOldX18, scale8) | |
600 | 600 | let loss = { | |
601 | 601 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
602 | 602 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
603 | 603 | } | |
604 | 604 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
605 | 605 | } | |
606 | 606 | else throw("Strict value is not equal to itself.") | |
607 | 607 | } | |
608 | 608 | ||
609 | 609 | ||
610 | 610 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
611 | 611 | case s: String => | |
612 | 612 | fromBase58String(s) | |
613 | 613 | case _: Unit => | |
614 | 614 | unit | |
615 | 615 | case _ => | |
616 | 616 | throw("Match error") | |
617 | 617 | } | |
618 | 618 | ||
619 | 619 | ||
620 | 620 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
621 | 621 | case s: String => | |
622 | 622 | fromBase58String(s) | |
623 | 623 | case _: Unit => | |
624 | 624 | unit | |
625 | 625 | case _ => | |
626 | 626 | throw("Match error") | |
627 | 627 | } | |
628 | 628 | ||
629 | 629 | ||
630 | 630 | func isManager (i) = match managerPublicKeyOrUnit() { | |
631 | 631 | case pk: ByteVector => | |
632 | 632 | (i.callerPublicKey == pk) | |
633 | 633 | case _: Unit => | |
634 | 634 | (i.caller == this) | |
635 | 635 | case _ => | |
636 | 636 | throw("Match error") | |
637 | 637 | } | |
638 | 638 | ||
639 | 639 | ||
640 | 640 | func mustManager (i) = { | |
641 | 641 | let pd = throw("Permission denied") | |
642 | 642 | match managerPublicKeyOrUnit() { | |
643 | 643 | case pk: ByteVector => | |
644 | 644 | if ((i.callerPublicKey == pk)) | |
645 | 645 | then true | |
646 | 646 | else pd | |
647 | 647 | case _: Unit => | |
648 | 648 | if ((i.caller == this)) | |
649 | 649 | then true | |
650 | 650 | else pd | |
651 | 651 | case _ => | |
652 | 652 | throw("Match error") | |
653 | 653 | } | |
654 | 654 | } | |
655 | 655 | ||
656 | 656 | ||
657 | 657 | @Callable(i) | |
658 | 658 | func setManager (pendingManagerPublicKey) = { | |
659 | 659 | let checkCaller = mustManager(i) | |
660 | 660 | if ((checkCaller == checkCaller)) | |
661 | 661 | then { | |
662 | 662 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
663 | 663 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
664 | 664 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
665 | 665 | else throw("Strict value is not equal to itself.") | |
666 | 666 | } | |
667 | 667 | else throw("Strict value is not equal to itself.") | |
668 | 668 | } | |
669 | 669 | ||
670 | 670 | ||
671 | 671 | ||
672 | 672 | @Callable(i) | |
673 | 673 | func confirmManager () = { | |
674 | 674 | let pm = pendingManagerPublicKeyOrUnit() | |
675 | 675 | let hasPM = if (isDefined(pm)) | |
676 | 676 | then true | |
677 | 677 | else throw("No pending manager") | |
678 | 678 | if ((hasPM == hasPM)) | |
679 | 679 | then { | |
680 | 680 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
681 | 681 | then true | |
682 | 682 | else throw("You are not pending manager") | |
683 | 683 | if ((checkPM == checkPM)) | |
684 | 684 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
685 | 685 | else throw("Strict value is not equal to itself.") | |
686 | 686 | } | |
687 | 687 | else throw("Strict value is not equal to itself.") | |
688 | 688 | } | |
689 | 689 | ||
690 | 690 | ||
691 | 691 | ||
692 | 692 | @Callable(i) | |
693 | 693 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
694 | 694 | then throw("Invalid slippageTolerance passed") | |
695 | 695 | else { | |
696 | 696 | let estPut = commonPut(i, slippageTolerance, true) | |
697 | 697 | let emitLpAmt = estPut._2 | |
698 | 698 | let lpAssetId = estPut._7 | |
699 | 699 | let state = estPut._9 | |
700 | 700 | let amDiff = estPut._10 | |
701 | 701 | let prDiff = estPut._11 | |
702 | 702 | let amId = estPut._12 | |
703 | 703 | let prId = estPut._13 | |
704 | 704 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
705 | 705 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
706 | - | let | |
707 | - | if (( | |
706 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt) | |
707 | + | if ((amountAssetBalance == amountAssetBalance)) | |
708 | 708 | then { | |
709 | - | let | |
710 | - | if (( | |
709 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt) | |
710 | + | if ((priceAssetBalance == priceAssetBalance)) | |
711 | 711 | then { | |
712 | - | let emitInvLegacy = match emitInv { | |
713 | - | case legacyFactoryContract: Address => | |
714 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
715 | - | case _ => | |
716 | - | unit | |
717 | - | } | |
718 | - | if ((emitInvLegacy == emitInvLegacy)) | |
712 | + | let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity) | |
713 | + | if ((lpAssetEmission == lpAssetEmission)) | |
719 | 714 | then { | |
720 | - | let slippageAInv = if ((amDiff > 0)) | |
721 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
722 | - | else nil | |
723 | - | if ((slippageAInv == slippageAInv)) | |
715 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
716 | + | if ((currentKLp == currentKLp)) | |
724 | 717 | then { | |
725 | - | let slippagePInv = if ((prDiff > 0)) | |
726 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
727 | - | else nil | |
728 | - | if ((slippagePInv == slippagePInv)) | |
718 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
719 | + | if ((emitInv == emitInv)) | |
729 | 720 | then { | |
730 | - | let lpTransfer = if (shouldAutoStake) | |
721 | + | let emitInvLegacy = match emitInv { | |
722 | + | case legacyFactoryContract: Address => | |
723 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
724 | + | case _ => | |
725 | + | unit | |
726 | + | } | |
727 | + | if ((emitInvLegacy == emitInvLegacy)) | |
731 | 728 | then { | |
732 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
733 | - | if ((slpStakeInv == slpStakeInv)) | |
734 | - | then nil | |
735 | - | else throw("Strict value is not equal to itself.") | |
736 | - | } | |
737 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
738 | - | let $t03211432182 = refreshKLpInternal(0, 0, 0) | |
739 | - | if (($t03211432182 == $t03211432182)) | |
740 | - | then { | |
741 | - | let updatedKLp = $t03211432182._2 | |
742 | - | let refreshKLpActions = $t03211432182._1 | |
743 | - | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
744 | - | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
745 | - | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
729 | + | let slippageAInv = if ((amDiff > 0)) | |
730 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
731 | + | else nil | |
732 | + | if ((slippageAInv == slippageAInv)) | |
733 | + | then { | |
734 | + | let slippagePInv = if ((prDiff > 0)) | |
735 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
736 | + | else nil | |
737 | + | if ((slippagePInv == slippagePInv)) | |
738 | + | then { | |
739 | + | let lpTransfer = if (shouldAutoStake) | |
740 | + | then { | |
741 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
742 | + | if ((slpStakeInv == slpStakeInv)) | |
743 | + | then nil | |
744 | + | else throw("Strict value is not equal to itself.") | |
745 | + | } | |
746 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
747 | + | let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity | |
748 | + | if ((lpAssetEmissionAfter == lpAssetEmissionAfter)) | |
749 | + | then { | |
750 | + | let $t03250032568 = refreshKLpInternal(0, 0, 0) | |
751 | + | if (($t03250032568 == $t03250032568)) | |
752 | + | then { | |
753 | + | let updatedKLp = $t03250032568._2 | |
754 | + | let refreshKLpActions = $t03250032568._1 | |
755 | + | let error = throwErr(makeString([toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentKLp), toString(updatedKLp), toString(emitLpAmt), toString(amDiff), toString(prDiff), toString(lpAssetEmission), toString(lpAssetEmissionAfter)], " ")) | |
756 | + | if ((error == error)) | |
757 | + | then { | |
758 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
759 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
760 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
761 | + | else throw("Strict value is not equal to itself.") | |
762 | + | } | |
763 | + | else throw("Strict value is not equal to itself.") | |
764 | + | } | |
765 | + | else throw("Strict value is not equal to itself.") | |
766 | + | } | |
767 | + | else throw("Strict value is not equal to itself.") | |
768 | + | } | |
769 | + | else throw("Strict value is not equal to itself.") | |
770 | + | } | |
746 | 771 | else throw("Strict value is not equal to itself.") | |
747 | 772 | } | |
748 | 773 | else throw("Strict value is not equal to itself.") | |
749 | 774 | } | |
750 | 775 | else throw("Strict value is not equal to itself.") | |
751 | 776 | } | |
752 | 777 | else throw("Strict value is not equal to itself.") | |
753 | 778 | } | |
754 | 779 | else throw("Strict value is not equal to itself.") | |
755 | 780 | } | |
756 | 781 | else throw("Strict value is not equal to itself.") | |
757 | 782 | } | |
758 | 783 | else throw("Strict value is not equal to itself.") | |
759 | 784 | } | |
760 | 785 | ||
761 | 786 | ||
762 | 787 | ||
763 | 788 | @Callable(i) | |
764 | 789 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
765 | 790 | then throw("Invalid value passed") | |
766 | 791 | else { | |
767 | 792 | let estPut = commonPut(i, maxSlippage, false) | |
768 | 793 | let state = estPut._9 | |
769 | 794 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
770 | 795 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
771 | 796 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
772 | 797 | if ((currentKLp == currentKLp)) | |
773 | 798 | then { | |
774 | - | let $ | |
775 | - | let refreshKLpActions = $ | |
776 | - | let updatedKLp = $ | |
799 | + | let $t03350033565 = refreshKLpInternal(0, 0, 0) | |
800 | + | let refreshKLpActions = $t03350033565._1 | |
801 | + | let updatedKLp = $t03350033565._2 | |
777 | 802 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
778 | 803 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
779 | 804 | then (state ++ refreshKLpActions) | |
780 | 805 | else throw("Strict value is not equal to itself.") | |
781 | 806 | } | |
782 | 807 | else throw("Strict value is not equal to itself.") | |
783 | 808 | } | |
784 | 809 | ||
785 | 810 | ||
786 | 811 | ||
787 | 812 | @Callable(i) | |
788 | 813 | func putOneTkn (minOutAmount,autoStake) = { | |
789 | 814 | let isPoolOneTokenOperationsDisabled = { | |
790 | 815 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
791 | 816 | if ($isInstanceOf(@, "Boolean")) | |
792 | 817 | then @ | |
793 | 818 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
794 | 819 | } | |
795 | 820 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
796 | 821 | then true | |
797 | 822 | else (cfgPoolStatus == PoolPutDisabled)) | |
798 | 823 | then true | |
799 | 824 | else (cfgPoolStatus == PoolShutdown)) | |
800 | 825 | then true | |
801 | 826 | else isPoolOneTokenOperationsDisabled | |
802 | 827 | let checks = [if (if (!(isPutDisabled)) | |
803 | 828 | then true | |
804 | 829 | else isManager(i)) | |
805 | 830 | then true | |
806 | 831 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
807 | 832 | then true | |
808 | 833 | else throwErr("exactly 1 payment are expected")] | |
809 | 834 | if ((checks == checks)) | |
810 | 835 | then { | |
811 | 836 | let payment = i.payments[0] | |
812 | 837 | let paymentAssetId = payment.assetId | |
813 | 838 | let paymentAmountRaw = payment.amount | |
814 | 839 | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
815 | 840 | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
816 | 841 | else if ((paymentAssetId == cfgPriceAssetId)) | |
817 | 842 | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
818 | 843 | else throwErr("payment asset is not supported") | |
819 | 844 | let userAddress = i.caller | |
820 | 845 | let txId = i.transactionId | |
821 | - | let $ | |
822 | - | if (($ | |
846 | + | let $t03475034902 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
847 | + | if (($t03475034902 == $t03475034902)) | |
823 | 848 | then { | |
824 | - | let paymentInAmountAsset = $ | |
825 | - | let bonus = $ | |
826 | - | let feeAmount = $ | |
827 | - | let commonState = $ | |
828 | - | let emitAmountEstimated = $ | |
849 | + | let paymentInAmountAsset = $t03475034902._5 | |
850 | + | let bonus = $t03475034902._4 | |
851 | + | let feeAmount = $t03475034902._3 | |
852 | + | let commonState = $t03475034902._2 | |
853 | + | let emitAmountEstimated = $t03475034902._1 | |
829 | 854 | let emitAmount = if (if ((minOutAmount > 0)) | |
830 | 855 | then (minOutAmount > emitAmountEstimated) | |
831 | 856 | else false) | |
832 | 857 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
833 | 858 | else emitAmountEstimated | |
834 | 859 | let emitInv = emit(emitAmount) | |
835 | 860 | if ((emitInv == emitInv)) | |
836 | 861 | then { | |
837 | 862 | let lpTransfer = if (autoStake) | |
838 | 863 | then { | |
839 | 864 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
840 | 865 | if ((stakeInv == stakeInv)) | |
841 | 866 | then nil | |
842 | 867 | else throw("Strict value is not equal to itself.") | |
843 | 868 | } | |
844 | 869 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
845 | 870 | let sendFee = if ((feeAmount > 0)) | |
846 | 871 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
847 | 872 | else nil | |
848 | - | let $ | |
873 | + | let $t03548835685 = if ((this == feeCollectorAddress)) | |
849 | 874 | then $Tuple2(0, 0) | |
850 | 875 | else if (paymentInAmountAsset) | |
851 | 876 | then $Tuple2(-(feeAmount), 0) | |
852 | 877 | else $Tuple2(0, -(feeAmount)) | |
853 | - | let amountAssetBalanceDelta = $ | |
854 | - | let priceAssetBalanceDelta = $ | |
855 | - | let $ | |
856 | - | let refreshKLpActions = $ | |
857 | - | let updatedKLp = $ | |
878 | + | let amountAssetBalanceDelta = $t03548835685._1 | |
879 | + | let priceAssetBalanceDelta = $t03548835685._2 | |
880 | + | let $t03568835796 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
881 | + | let refreshKLpActions = $t03568835796._1 | |
882 | + | let updatedKLp = $t03568835796._2 | |
858 | 883 | let kLp = value(getString(keyKLp)) | |
859 | 884 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
860 | 885 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
861 | 886 | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
862 | 887 | else throw("Strict value is not equal to itself.") | |
863 | 888 | } | |
864 | 889 | else throw("Strict value is not equal to itself.") | |
865 | 890 | } | |
866 | 891 | else throw("Strict value is not equal to itself.") | |
867 | 892 | } | |
868 | 893 | else throw("Strict value is not equal to itself.") | |
869 | 894 | } | |
870 | 895 | ||
871 | 896 | ||
872 | 897 | ||
873 | 898 | @Callable(i) | |
874 | 899 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
875 | - | let $ | |
876 | - | let emitAmountEstimated = $ | |
877 | - | let commonState = $ | |
878 | - | let feeAmount = $ | |
879 | - | let bonus = $ | |
880 | - | let paymentInAmountAsset = $ | |
900 | + | let $t03610236259 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
901 | + | let emitAmountEstimated = $t03610236259._1 | |
902 | + | let commonState = $t03610236259._2 | |
903 | + | let feeAmount = $t03610236259._3 | |
904 | + | let bonus = $t03610236259._4 | |
905 | + | let paymentInAmountAsset = $t03610236259._5 | |
881 | 906 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
882 | 907 | } | |
883 | 908 | ||
884 | 909 | ||
885 | 910 | ||
886 | 911 | @Callable(i) | |
887 | 912 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
888 | 913 | let isPoolOneTokenOperationsDisabled = { | |
889 | 914 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
890 | 915 | if ($isInstanceOf(@, "Boolean")) | |
891 | 916 | then @ | |
892 | 917 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
893 | 918 | } | |
894 | 919 | let isGetDisabled = if (if (isGlobalShutdown()) | |
895 | 920 | then true | |
896 | 921 | else (cfgPoolStatus == PoolShutdown)) | |
897 | 922 | then true | |
898 | 923 | else isPoolOneTokenOperationsDisabled | |
899 | 924 | let checks = [if (if (!(isGetDisabled)) | |
900 | 925 | then true | |
901 | 926 | else isManager(i)) | |
902 | 927 | then true | |
903 | 928 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
904 | 929 | then true | |
905 | 930 | else throwErr("exactly 1 payment are expected")] | |
906 | 931 | if ((checks == checks)) | |
907 | 932 | then { | |
908 | 933 | let outAssetId = parseAssetId(outAssetIdStr) | |
909 | 934 | let payment = i.payments[0] | |
910 | 935 | let paymentAssetId = payment.assetId | |
911 | 936 | let paymentAmount = payment.amount | |
912 | 937 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount)) | |
913 | 938 | let userAddress = i.caller | |
914 | 939 | let txId = i.transactionId | |
915 | - | let $ | |
916 | - | if (($ | |
940 | + | let $t03715337306 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
941 | + | if (($t03715337306 == $t03715337306)) | |
917 | 942 | then { | |
918 | - | let outInAmountAsset = $ | |
919 | - | let bonus = $ | |
920 | - | let feeAmount = $ | |
921 | - | let commonState = $ | |
922 | - | let amountEstimated = $ | |
943 | + | let outInAmountAsset = $t03715337306._5 | |
944 | + | let bonus = $t03715337306._4 | |
945 | + | let feeAmount = $t03715337306._3 | |
946 | + | let commonState = $t03715337306._2 | |
947 | + | let amountEstimated = $t03715337306._1 | |
923 | 948 | let amount = if (if ((minOutAmount > 0)) | |
924 | 949 | then (minOutAmount > amountEstimated) | |
925 | 950 | else false) | |
926 | 951 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
927 | 952 | else amountEstimated | |
928 | 953 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
929 | 954 | if ((burnInv == burnInv)) | |
930 | 955 | then { | |
931 | 956 | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
932 | 957 | let sendFee = if ((feeAmount > 0)) | |
933 | 958 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
934 | 959 | else nil | |
935 | - | let $ | |
960 | + | let $t03780638053 = { | |
936 | 961 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
937 | 962 | then 0 | |
938 | 963 | else feeAmount | |
939 | 964 | if (outInAmountAsset) | |
940 | 965 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
941 | 966 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
942 | 967 | } | |
943 | - | let amountAssetBalanceDelta = $ | |
944 | - | let priceAssetBalanceDelta = $ | |
945 | - | let $ | |
946 | - | let refreshKLpActions = $ | |
947 | - | let updatedKLp = $ | |
968 | + | let amountAssetBalanceDelta = $t03780638053._1 | |
969 | + | let priceAssetBalanceDelta = $t03780638053._2 | |
970 | + | let $t03805638164 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
971 | + | let refreshKLpActions = $t03805638164._1 | |
972 | + | let updatedKLp = $t03805638164._2 | |
948 | 973 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
949 | 974 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
950 | 975 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
951 | 976 | else throw("Strict value is not equal to itself.") | |
952 | 977 | } | |
953 | 978 | else throw("Strict value is not equal to itself.") | |
954 | 979 | } | |
955 | 980 | else throw("Strict value is not equal to itself.") | |
956 | 981 | } | |
957 | 982 | else throw("Strict value is not equal to itself.") | |
958 | 983 | } | |
959 | 984 | ||
960 | 985 | ||
961 | 986 | ||
962 | 987 | @Callable(i) | |
963 | 988 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
964 | - | let $ | |
965 | - | let amountEstimated = $ | |
966 | - | let commonState = $ | |
967 | - | let feeAmount = $ | |
968 | - | let bonus = $ | |
969 | - | let outInAmountAsset = $ | |
989 | + | let $t03842138577 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
990 | + | let amountEstimated = $t03842138577._1 | |
991 | + | let commonState = $t03842138577._2 | |
992 | + | let feeAmount = $t03842138577._3 | |
993 | + | let bonus = $t03842138577._4 | |
994 | + | let outInAmountAsset = $t03842138577._5 | |
970 | 995 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
971 | 996 | } | |
972 | 997 | ||
973 | 998 | ||
974 | 999 | ||
975 | 1000 | @Callable(i) | |
976 | 1001 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
977 | 1002 | let isPoolOneTokenOperationsDisabled = { | |
978 | 1003 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
979 | 1004 | if ($isInstanceOf(@, "Boolean")) | |
980 | 1005 | then @ | |
981 | 1006 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
982 | 1007 | } | |
983 | 1008 | let isGetDisabled = if (if (isGlobalShutdown()) | |
984 | 1009 | then true | |
985 | 1010 | else (cfgPoolStatus == PoolShutdown)) | |
986 | 1011 | then true | |
987 | 1012 | else isPoolOneTokenOperationsDisabled | |
988 | 1013 | let checks = [if (if (!(isGetDisabled)) | |
989 | 1014 | then true | |
990 | 1015 | else isManager(i)) | |
991 | 1016 | then true | |
992 | 1017 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
993 | 1018 | then true | |
994 | 1019 | else throwErr("no payments are expected")] | |
995 | 1020 | if ((checks == checks)) | |
996 | 1021 | then { | |
997 | 1022 | let outAssetId = parseAssetId(outAssetIdStr) | |
998 | 1023 | let userAddress = i.caller | |
999 | 1024 | let txId = i.transactionId | |
1000 | 1025 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1001 | 1026 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1002 | 1027 | if ((unstakeInv == unstakeInv)) | |
1003 | 1028 | then { | |
1004 | - | let $ | |
1005 | - | if (($ | |
1029 | + | let $t03947939630 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1030 | + | if (($t03947939630 == $t03947939630)) | |
1006 | 1031 | then { | |
1007 | - | let outInAmountAsset = $ | |
1008 | - | let bonus = $ | |
1009 | - | let feeAmount = $ | |
1010 | - | let commonState = $ | |
1011 | - | let amountEstimated = $ | |
1032 | + | let outInAmountAsset = $t03947939630._5 | |
1033 | + | let bonus = $t03947939630._4 | |
1034 | + | let feeAmount = $t03947939630._3 | |
1035 | + | let commonState = $t03947939630._2 | |
1036 | + | let amountEstimated = $t03947939630._1 | |
1012 | 1037 | let amount = if (if ((minOutAmount > 0)) | |
1013 | 1038 | then (minOutAmount > amountEstimated) | |
1014 | 1039 | else false) | |
1015 | 1040 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1016 | 1041 | else amountEstimated | |
1017 | 1042 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1018 | 1043 | if ((burnInv == burnInv)) | |
1019 | 1044 | then { | |
1020 | 1045 | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1021 | 1046 | let sendFee = if ((feeAmount > 0)) | |
1022 | 1047 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1023 | 1048 | else nil | |
1024 | - | let $ | |
1049 | + | let $t04012540372 = { | |
1025 | 1050 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1026 | 1051 | then 0 | |
1027 | 1052 | else feeAmount | |
1028 | 1053 | if (outInAmountAsset) | |
1029 | 1054 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1030 | 1055 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1031 | 1056 | } | |
1032 | - | let amountAssetBalanceDelta = $ | |
1033 | - | let priceAssetBalanceDelta = $ | |
1034 | - | let $ | |
1035 | - | let refreshKLpActions = $ | |
1036 | - | let updatedKLp = $ | |
1057 | + | let amountAssetBalanceDelta = $t04012540372._1 | |
1058 | + | let priceAssetBalanceDelta = $t04012540372._2 | |
1059 | + | let $t04037540483 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1060 | + | let refreshKLpActions = $t04037540483._1 | |
1061 | + | let updatedKLp = $t04037540483._2 | |
1037 | 1062 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1038 | 1063 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1039 | 1064 | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1040 | 1065 | else throw("Strict value is not equal to itself.") | |
1041 | 1066 | } | |
1042 | 1067 | else throw("Strict value is not equal to itself.") | |
1043 | 1068 | } | |
1044 | 1069 | else throw("Strict value is not equal to itself.") | |
1045 | 1070 | } | |
1046 | 1071 | else throw("Strict value is not equal to itself.") | |
1047 | 1072 | } | |
1048 | 1073 | else throw("Strict value is not equal to itself.") | |
1049 | 1074 | } | |
1050 | 1075 | ||
1051 | 1076 | ||
1052 | 1077 | ||
1053 | 1078 | @Callable(i) | |
1054 | 1079 | func get () = { | |
1055 | 1080 | let res = commonGet(i) | |
1056 | 1081 | let outAmtAmt = res._1 | |
1057 | 1082 | let outPrAmt = res._2 | |
1058 | 1083 | let pmtAmt = res._3 | |
1059 | 1084 | let pmtAssetId = res._4 | |
1060 | 1085 | let state = res._5 | |
1061 | 1086 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1062 | 1087 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1063 | 1088 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1064 | 1089 | then { | |
1065 | - | let $ | |
1066 | - | let refreshKLpActions = $ | |
1067 | - | let updatedKLp = $ | |
1090 | + | let $t04143141513 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1091 | + | let refreshKLpActions = $t04143141513._1 | |
1092 | + | let updatedKLp = $t04143141513._2 | |
1068 | 1093 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1069 | 1094 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1070 | 1095 | then (state ++ refreshKLpActions) | |
1071 | 1096 | else throw("Strict value is not equal to itself.") | |
1072 | 1097 | } | |
1073 | 1098 | else throw("Strict value is not equal to itself.") | |
1074 | 1099 | } | |
1075 | 1100 | ||
1076 | 1101 | ||
1077 | 1102 | ||
1078 | 1103 | @Callable(i) | |
1079 | 1104 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1080 | 1105 | let res = commonGet(i) | |
1081 | 1106 | let outAmAmt = res._1 | |
1082 | 1107 | let outPrAmt = res._2 | |
1083 | 1108 | let pmtAmt = res._3 | |
1084 | 1109 | let pmtAssetId = res._4 | |
1085 | 1110 | let state = res._5 | |
1086 | 1111 | if ((noLessThenAmtAsset > outAmAmt)) | |
1087 | 1112 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1088 | 1113 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1089 | 1114 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1090 | 1115 | else { | |
1091 | 1116 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt)) | |
1092 | 1117 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1093 | 1118 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1094 | 1119 | then { | |
1095 | - | let $ | |
1096 | - | let refreshKLpActions = $ | |
1097 | - | let updatedKLp = $ | |
1120 | + | let $t04246442545 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1121 | + | let refreshKLpActions = $t04246442545._1 | |
1122 | + | let updatedKLp = $t04246442545._2 | |
1098 | 1123 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1099 | 1124 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1100 | 1125 | then (state ++ refreshKLpActions) | |
1101 | 1126 | else throw("Strict value is not equal to itself.") | |
1102 | 1127 | } | |
1103 | 1128 | else throw("Strict value is not equal to itself.") | |
1104 | 1129 | } | |
1105 | 1130 | } | |
1106 | 1131 | ||
1107 | 1132 | ||
1108 | 1133 | ||
1109 | 1134 | @Callable(i) | |
1110 | 1135 | func unstakeAndGet (amount) = { | |
1111 | 1136 | let checkPayments = if ((size(i.payments) != 0)) | |
1112 | 1137 | then throw("No payments are expected") | |
1113 | 1138 | else true | |
1114 | 1139 | if ((checkPayments == checkPayments)) | |
1115 | 1140 | then { | |
1116 | 1141 | let cfg = getPoolConfig() | |
1117 | 1142 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1118 | 1143 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1119 | 1144 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1120 | 1145 | if ((unstakeInv == unstakeInv)) | |
1121 | 1146 | then { | |
1122 | 1147 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1123 | 1148 | let outAmAmt = res._1 | |
1124 | 1149 | let outPrAmt = res._2 | |
1125 | 1150 | let poolStatus = parseIntValue(res._9) | |
1126 | 1151 | let state = res._10 | |
1127 | 1152 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1128 | 1153 | then true | |
1129 | 1154 | else (poolStatus == PoolShutdown)) | |
1130 | 1155 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1131 | 1156 | else true | |
1132 | 1157 | if ((checkPoolStatus == checkPoolStatus)) | |
1133 | 1158 | then { | |
1134 | 1159 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1135 | 1160 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1136 | 1161 | then { | |
1137 | - | let $ | |
1138 | - | let refreshKLpActions = $ | |
1139 | - | let updatedKLp = $ | |
1162 | + | let $t04366843749 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1163 | + | let refreshKLpActions = $t04366843749._1 | |
1164 | + | let updatedKLp = $t04366843749._2 | |
1140 | 1165 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1141 | 1166 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1142 | 1167 | then (state ++ refreshKLpActions) | |
1143 | 1168 | else throw("Strict value is not equal to itself.") | |
1144 | 1169 | } | |
1145 | 1170 | else throw("Strict value is not equal to itself.") | |
1146 | 1171 | } | |
1147 | 1172 | else throw("Strict value is not equal to itself.") | |
1148 | 1173 | } | |
1149 | 1174 | else throw("Strict value is not equal to itself.") | |
1150 | 1175 | } | |
1151 | 1176 | else throw("Strict value is not equal to itself.") | |
1152 | 1177 | } | |
1153 | 1178 | ||
1154 | 1179 | ||
1155 | 1180 | ||
1156 | 1181 | @Callable(i) | |
1157 | 1182 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1158 | 1183 | let isGetDisabled = if (isGlobalShutdown()) | |
1159 | 1184 | then true | |
1160 | 1185 | else (cfgPoolStatus == PoolShutdown) | |
1161 | 1186 | let checks = [if (!(isGetDisabled)) | |
1162 | 1187 | then true | |
1163 | 1188 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1164 | 1189 | then true | |
1165 | 1190 | else throw("no payments are expected")] | |
1166 | 1191 | if ((checks == checks)) | |
1167 | 1192 | then { | |
1168 | 1193 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1169 | 1194 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1170 | 1195 | if ((unstakeInv == unstakeInv)) | |
1171 | 1196 | then { | |
1172 | 1197 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1173 | 1198 | let outAmAmt = res._1 | |
1174 | 1199 | let outPrAmt = res._2 | |
1175 | 1200 | let state = res._10 | |
1176 | 1201 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1177 | 1202 | then true | |
1178 | 1203 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1179 | 1204 | then true | |
1180 | 1205 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1181 | 1206 | if ((checkAmounts == checkAmounts)) | |
1182 | 1207 | then { | |
1183 | 1208 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1184 | 1209 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1185 | 1210 | then { | |
1186 | - | let $ | |
1187 | - | let refreshKLpActions = $ | |
1188 | - | let updatedKLp = $ | |
1211 | + | let $t04504145122 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1212 | + | let refreshKLpActions = $t04504145122._1 | |
1213 | + | let updatedKLp = $t04504145122._2 | |
1189 | 1214 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1190 | 1215 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1191 | 1216 | then (state ++ refreshKLpActions) | |
1192 | 1217 | else throw("Strict value is not equal to itself.") | |
1193 | 1218 | } | |
1194 | 1219 | else throw("Strict value is not equal to itself.") | |
1195 | 1220 | } | |
1196 | 1221 | else throw("Strict value is not equal to itself.") | |
1197 | 1222 | } | |
1198 | 1223 | else throw("Strict value is not equal to itself.") | |
1199 | 1224 | } | |
1200 | 1225 | else throw("Strict value is not equal to itself.") | |
1201 | 1226 | } | |
1202 | 1227 | ||
1203 | 1228 | ||
1204 | 1229 | ||
1205 | 1230 | @Callable(i) | |
1206 | 1231 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1207 | 1232 | then throw("permissions denied") | |
1208 | 1233 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1209 | 1234 | ||
1210 | 1235 | ||
1211 | 1236 | ||
1212 | 1237 | @Callable(i) | |
1213 | 1238 | func refreshKLp () = { | |
1214 | 1239 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1215 | 1240 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1216 | 1241 | then unit | |
1217 | 1242 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1218 | 1243 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1219 | 1244 | then { | |
1220 | 1245 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1221 | - | let $ | |
1222 | - | let kLpUpdateActions = $ | |
1223 | - | let updatedKLp = $ | |
1246 | + | let $t04630946373 = refreshKLpInternal(0, 0, 0) | |
1247 | + | let kLpUpdateActions = $t04630946373._1 | |
1248 | + | let updatedKLp = $t04630946373._2 | |
1224 | 1249 | let actions = if ((kLp != updatedKLp)) | |
1225 | 1250 | then kLpUpdateActions | |
1226 | 1251 | else throwErr("nothing to refresh") | |
1227 | 1252 | $Tuple2(actions, toString(updatedKLp)) | |
1228 | 1253 | } | |
1229 | 1254 | else throw("Strict value is not equal to itself.") | |
1230 | 1255 | } | |
1231 | 1256 | ||
1232 | 1257 | ||
1233 | 1258 | ||
1234 | 1259 | @Callable(i) | |
1235 | 1260 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1236 | 1261 | ||
1237 | 1262 | ||
1238 | 1263 | ||
1239 | 1264 | @Callable(i) | |
1240 | 1265 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1241 | 1266 | ||
1242 | 1267 | ||
1243 | 1268 | ||
1244 | 1269 | @Callable(i) | |
1245 | 1270 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1246 | 1271 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1247 | 1272 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1248 | 1273 | } | |
1249 | 1274 | ||
1250 | 1275 | ||
1251 | 1276 | ||
1252 | 1277 | @Callable(i) | |
1253 | 1278 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1254 | 1279 | ||
1255 | 1280 | ||
1256 | 1281 | ||
1257 | 1282 | @Callable(i) | |
1258 | 1283 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1259 | 1284 | ||
1260 | 1285 | ||
1261 | 1286 | ||
1262 | 1287 | @Callable(i) | |
1263 | 1288 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1264 | 1289 | ||
1265 | 1290 | ||
1266 | 1291 | ||
1267 | 1292 | @Callable(i) | |
1268 | 1293 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1269 | 1294 | ||
1270 | 1295 | ||
1271 | 1296 | ||
1272 | 1297 | @Callable(i) | |
1273 | 1298 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1274 | 1299 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1275 | 1300 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1276 | 1301 | } | |
1277 | 1302 | ||
1278 | 1303 | ||
1279 | 1304 | ||
1280 | 1305 | @Callable(i) | |
1281 | 1306 | func statsREADONLY () = { | |
1282 | 1307 | let cfg = getPoolConfig() | |
1283 | 1308 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1284 | 1309 | let amtAssetId = cfg[idxAmtAssetId] | |
1285 | 1310 | let priceAssetId = cfg[idxPriceAssetId] | |
1286 | 1311 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1287 | 1312 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1288 | 1313 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1289 | 1314 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1290 | 1315 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1291 | 1316 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1292 | 1317 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1293 | 1318 | let pricesList = if ((poolLPBalance == 0)) | |
1294 | 1319 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1295 | 1320 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1296 | 1321 | let curPrice = 0 | |
1297 | 1322 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1298 | 1323 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1299 | 1324 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1300 | 1325 | $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)) | |
1301 | 1326 | } | |
1302 | 1327 | ||
1303 | 1328 | ||
1304 | 1329 | ||
1305 | 1330 | @Callable(i) | |
1306 | 1331 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1307 | 1332 | let cfg = getPoolConfig() | |
1308 | 1333 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1309 | 1334 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1310 | 1335 | let amAssetId = fromBase58String(amAssetIdStr) | |
1311 | 1336 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1312 | 1337 | let prAssetId = fromBase58String(prAssetIdStr) | |
1313 | 1338 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1314 | 1339 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1315 | 1340 | let poolStatus = cfg[idxPoolStatus] | |
1316 | 1341 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1317 | 1342 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1318 | 1343 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1319 | 1344 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1320 | 1345 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1321 | 1346 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1322 | 1347 | then zeroBigInt | |
1323 | 1348 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1324 | 1349 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1325 | 1350 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1326 | 1351 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1327 | 1352 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1328 | 1353 | let calcLpAmt = estPut._1 | |
1329 | 1354 | let curPriceCalc = estPut._3 | |
1330 | 1355 | let amBalance = estPut._4 | |
1331 | 1356 | let prBalance = estPut._5 | |
1332 | 1357 | let lpEmission = estPut._6 | |
1333 | 1358 | $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)) | |
1334 | 1359 | } | |
1335 | 1360 | ||
1336 | 1361 | ||
1337 | 1362 | ||
1338 | 1363 | @Callable(i) | |
1339 | 1364 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1340 | 1365 | let cfg = getPoolConfig() | |
1341 | 1366 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1342 | 1367 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1343 | 1368 | let amAssetId = fromBase58String(amAssetIdStr) | |
1344 | 1369 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1345 | 1370 | let prAssetId = fromBase58String(prAssetIdStr) | |
1346 | 1371 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1347 | 1372 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1348 | 1373 | let poolStatus = cfg[idxPoolStatus] | |
1349 | 1374 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1350 | 1375 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1351 | 1376 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1352 | 1377 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1353 | 1378 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1354 | 1379 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1355 | 1380 | then zeroBigInt | |
1356 | 1381 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1357 | 1382 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1358 | 1383 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1359 | 1384 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1360 | 1385 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1361 | 1386 | let calcLpAmt = estPut._1 | |
1362 | 1387 | let curPriceCalc = estPut._3 | |
1363 | 1388 | let amBalance = estPut._4 | |
1364 | 1389 | let prBalance = estPut._5 | |
1365 | 1390 | let lpEmission = estPut._6 | |
1366 | 1391 | $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)) | |
1367 | 1392 | } | |
1368 | 1393 | ||
1369 | 1394 | ||
1370 | 1395 | ||
1371 | 1396 | @Callable(i) | |
1372 | 1397 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1373 | 1398 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1374 | 1399 | let outAmAmt = res._1 | |
1375 | 1400 | let outPrAmt = res._2 | |
1376 | 1401 | let amBalance = res._5 | |
1377 | 1402 | let prBalance = res._6 | |
1378 | 1403 | let lpEmission = res._7 | |
1379 | 1404 | let curPrice = res._8 | |
1380 | 1405 | let poolStatus = parseIntValue(res._9) | |
1381 | 1406 | $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)) | |
1382 | 1407 | } | |
1383 | 1408 | ||
1384 | 1409 | ||
1385 | 1410 | @Verifier(tx) | |
1386 | 1411 | func verify () = { | |
1387 | 1412 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1388 | 1413 | case pk: ByteVector => | |
1389 | 1414 | pk | |
1390 | 1415 | case _: Unit => | |
1391 | 1416 | tx.senderPublicKey | |
1392 | 1417 | case _ => | |
1393 | 1418 | throw("Match error") | |
1394 | 1419 | } | |
1395 | 1420 | match tx { | |
1396 | 1421 | case order: Order => | |
1397 | 1422 | let matcherPub = getMatcherPubOrFail() | |
1398 | 1423 | let orderValid = validateMatcherOrderAllowed(order) | |
1399 | 1424 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1400 | 1425 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1401 | 1426 | if (if (if (orderValid) | |
1402 | 1427 | then senderValid | |
1403 | 1428 | else false) | |
1404 | 1429 | then matcherValid | |
1405 | 1430 | else false) | |
1406 | 1431 | then true | |
1407 | 1432 | else throwOrderError(orderValid, senderValid, matcherValid) | |
1408 | 1433 | case s: SetScriptTransaction => | |
1409 | 1434 | let newHash = blake2b256(value(s.script)) | |
1410 | 1435 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1411 | 1436 | let currentHash = scriptHash(this) | |
1412 | 1437 | if (if ((allowedHash == newHash)) | |
1413 | 1438 | then (currentHash != newHash) | |
1414 | 1439 | else false) | |
1415 | 1440 | then true | |
1416 | 1441 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1417 | 1442 | case _ => | |
1418 | 1443 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1419 | 1444 | } | |
1420 | 1445 | } | |
1421 | 1446 |
github/deemru/w8io/026f985 185.81 ms ◑