tx · AU1nZFXy3wQtpsJ99cq94xJBBXgaotqUmCEpc3FNQ2Gg 3N1dMZiRHyPfV3HE1UP73tMqZyrajT8s7Gd: -0.03300000 Waves 2022.11.30 09:50 [2339518] smart account 3N1dMZiRHyPfV3HE1UP73tMqZyrajT8s7Gd > SELF 0.00000000 Waves
{ "type": 13, "id": "AU1nZFXy3wQtpsJ99cq94xJBBXgaotqUmCEpc3FNQ2Gg", "fee": 3300000, "feeAssetId": null, "timestamp": 1669790945808, "version": 1, "sender": "3N1dMZiRHyPfV3HE1UP73tMqZyrajT8s7Gd", "senderPublicKey": "5nXNn4nUrku3ormf7LVLKqY9doTY1LZWZ3uDiDHre72C", "proofs": [ "3FR4rBoNropeCEVAwJs8b1sfkoCAgUwFhjCsudGqSfPGtVxUR9gk5rtLbUtgvFhQ54ZE87BxP4jwT3Dnp3QFhwJG" ], "script": "base64:BgLYKwgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWl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AMBBQJjZQkAzAgCCQCkAwEFAmNiCQDMCAIJAKYDAQUCY2gJAMwIAgkApAMBBQJjYQUDbmlsBQFqAQJncAECZ3EABAJncgQCZEUJAQJlRwADCQABAgUCZEUCCkJ5dGVWZWN0b3IEAmVLBQJkRQUCZUsDCQABAgUCZEUCBFVuaXQIBQJncA9zZW5kZXJQdWJsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgQCZEUFAmdwAwkAAQIFAmRFAgVPcmRlcgQCZGoFAmRFBAJncwkBAmFNAAQCYXoJAQJkaQEFAmRqBAJhQQkA9AMDCAUCZGoJYm9keUJ5dGVzCQCRAwIIBQJkagZwcm9vZnMAAAgFAmRqD3NlbmRlclB1YmxpY0tleQQCYUIJAPQDAwgFAmRqCWJvZHlCeXRlcwkAkQMCCAUCZGoGcHJvb2ZzAAEFAmdzAwMDBQJhegUCYUEHBQJhQgcGCQECYXkDBQJhegUCYUEFAmFCAwkAAQIFAmRFAhRTZXRTY3JpcHRUcmFuc2FjdGlvbgQCZUgFAmRFBAJndAkA9gMBCQEFdmFsdWUBCAUCZUgGc2NyaXB0BAJndQkA2wQBCQEFdmFsdWUBCQCdCAIFAmFKCQECYXcABAJndgkA8QcBBQR0aGlzAwMJAAACBQJndQUCZ3QJAQIhPQIFAmd2BQJndAcGCQD0AwMIBQJncAlib2R5Qnl0ZXMJAJEDAggFAmdwBnByb29mcwAABQJncgkA9AMDCAUCZ3AJYm9keUJ5dGVzCQCRAwIIBQJncAZwcm9vZnMAAAUCZ3JXKual", "chainId": 84, "height": 2339518, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7Cgxn26GCv3fYg5mhhe3N8e76vLxjzur3kGV3vFNHynC Next: Cj5bsnWUv9JuLg9cHUzX5KbmYWs1hdynW2PBFpontbrf Diff:
Old | New | Differences | |
---|---|---|---|
390 | 390 | ||
391 | 391 | ||
392 | 392 | func validateMatcherOrderAllowed (order) = { | |
393 | - | let cfg = getPoolConfig() | |
394 | - | let amtAssetId = cfg[idxAmtAssetId] | |
395 | - | let priceAssetId = cfg[idxPriceAssetId] | |
396 | - | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
397 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
398 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
399 | 393 | let amountAssetAmount = order.amount | |
400 | 394 | let priceAssetAmount = fraction(order.amount, order.price, scale8) | |
401 | - | let $ | |
395 | + | let $t01955919771 = if ((order.orderType == Buy)) | |
402 | 396 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
403 | 397 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
404 | - | let amountAssetBalanceDelta = $ | |
405 | - | let priceAssetBalanceDelta = $ | |
398 | + | let amountAssetBalanceDelta = $t01955919771._1 | |
399 | + | let priceAssetBalanceDelta = $t01955919771._2 | |
406 | 400 | if (if (if (isGlobalShutdown()) | |
407 | 401 | then true | |
408 | - | else ( | |
402 | + | else (cfgPoolStatus == PoolMatcherDisabled)) | |
409 | 403 | then true | |
410 | - | else ( | |
404 | + | else (cfgPoolStatus == PoolShutdown)) | |
411 | 405 | then throw("Exchange operations disabled") | |
412 | - | else { | |
413 | - | let orderAmtAssetStr = assetIdToString(value(order.assetPair.amountAsset)) | |
414 | - | let orderPriceAssetStr = assetIdToString(value(order.assetPair.priceAsset)) | |
415 | - | if (if ((orderAmtAssetStr != amtAssetId)) | |
416 | - | then true | |
417 | - | else (orderPriceAssetStr != priceAssetId)) | |
418 | - | then throw("Wrong order assets.") | |
419 | - | else { | |
420 | - | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
421 | - | let $t02064520745 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
422 | - | let unusedActions = $t02064520745._1 | |
423 | - | let kLpNew = $t02064520745._2 | |
424 | - | let isOrderValid = (kLpNew > kLp) | |
425 | - | isOrderValid | |
426 | - | } | |
427 | - | } | |
406 | + | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
407 | + | then true | |
408 | + | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
409 | + | then throw("Wrong order assets.") | |
410 | + | else { | |
411 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
412 | + | let $t02024220342 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
413 | + | let unusedActions = $t02024220342._1 | |
414 | + | let kLpNew = $t02024220342._2 | |
415 | + | let isOrderValid = (kLpNew > kLp) | |
416 | + | isOrderValid | |
417 | + | } | |
428 | 418 | } | |
429 | 419 | ||
430 | 420 | ||
497 | 487 | else if ((paymentAssetId == cfgPriceAssetId)) | |
498 | 488 | then false | |
499 | 489 | else throwErr("invalid asset") | |
500 | - | let $ | |
490 | + | let $t02302623319 = if (isEval) | |
501 | 491 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
502 | 492 | else if (paymentInAmountAsset) | |
503 | 493 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
504 | 494 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
505 | - | let amountBalanceOld = $ | |
506 | - | let priceBalanceOld = $ | |
507 | - | let $ | |
495 | + | let amountBalanceOld = $t02302623319._1 | |
496 | + | let priceBalanceOld = $t02302623319._2 | |
497 | + | let $t02332323472 = if (paymentInAmountAsset) | |
508 | 498 | then $Tuple2(paymentAmountRaw, 0) | |
509 | 499 | else $Tuple2(0, paymentAmountRaw) | |
510 | - | let amountAssetAmountRaw = $ | |
511 | - | let priceAssetAmountRaw = $ | |
500 | + | let amountAssetAmountRaw = $t02332323472._1 | |
501 | + | let priceAssetAmountRaw = $t02332323472._2 | |
512 | 502 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
513 | 503 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
514 | - | let $ | |
515 | - | let paymentAmount = $ | |
516 | - | let feeAmount = $ | |
504 | + | let $t02359423653 = takeFee(paymentAmountRaw) | |
505 | + | let paymentAmount = $t02359423653._1 | |
506 | + | let feeAmount = $t02359423653._2 | |
517 | 507 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
518 | 508 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
519 | 509 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
536 | 526 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
537 | 527 | let priceOld = fromX18(priceOldX18, scale8) | |
538 | 528 | let loss = { | |
539 | - | let $ | |
529 | + | let $t02513025297 = if (paymentInAmountAsset) | |
540 | 530 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
541 | 531 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
542 | - | let amount = $ | |
543 | - | let balance = $ | |
532 | + | let amount = $t02513025297._1 | |
533 | + | let balance = $t02513025297._2 | |
544 | 534 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
545 | 535 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
546 | 536 | } | |
574 | 564 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
575 | 565 | let redeemedBigInt = toBigInt(paymentAmount) | |
576 | 566 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
577 | - | let $ | |
578 | - | let totalAmount = $ | |
579 | - | let feeAmount = $ | |
580 | - | let $ | |
567 | + | let $t02689926949 = takeFee(amountRaw) | |
568 | + | let totalAmount = $t02689926949._1 | |
569 | + | let feeAmount = $t02689926949._2 | |
570 | + | let $t02695327179 = if (outInAmountAsset) | |
581 | 571 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
582 | 572 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
583 | - | let outAmAmount = $ | |
584 | - | let outPrAmount = $ | |
585 | - | let amBalanceNew = $ | |
586 | - | let prBalanceNew = $ | |
573 | + | let outAmAmount = $t02695327179._1 | |
574 | + | let outPrAmount = $t02695327179._2 | |
575 | + | let amBalanceNew = $t02695327179._3 | |
576 | + | let prBalanceNew = $t02695327179._4 | |
587 | 577 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
588 | 578 | let priceNew = fromX18(priceNewX18, scale8) | |
589 | 579 | let commonState = if (isEval) | |
724 | 714 | else throw("Strict value is not equal to itself.") | |
725 | 715 | } | |
726 | 716 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
727 | - | let $ | |
728 | - | let refreshKLpActions = $ | |
729 | - | let updatedKLp = $ | |
717 | + | let $t03113031195 = refreshKLpInternal(0, 0, 0) | |
718 | + | let refreshKLpActions = $t03113031195._1 | |
719 | + | let updatedKLp = $t03113031195._2 | |
730 | 720 | ((state ++ lpTransfer) ++ refreshKLpActions) | |
731 | 721 | } | |
732 | 722 | else throw("Strict value is not equal to itself.") | |
746 | 736 | else { | |
747 | 737 | let estPut = commonPut(i, maxSlippage, false) | |
748 | 738 | let state = estPut._9 | |
749 | - | let $ | |
750 | - | let refreshKLpActions = $ | |
751 | - | let updatedKLp = $ | |
739 | + | let $t03148131546 = refreshKLpInternal(0, 0, 0) | |
740 | + | let refreshKLpActions = $t03148131546._1 | |
741 | + | let updatedKLp = $t03148131546._2 | |
752 | 742 | (state ++ refreshKLpActions) | |
753 | 743 | } | |
754 | 744 | ||
783 | 773 | let paymentAmountRaw = payment.amount | |
784 | 774 | let userAddress = i.caller | |
785 | 775 | let txId = i.transactionId | |
786 | - | let $ | |
787 | - | if (($ | |
776 | + | let $t03232232474 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
777 | + | if (($t03232232474 == $t03232232474)) | |
788 | 778 | then { | |
789 | - | let paymentInAmountAsset = $ | |
790 | - | let bonus = $ | |
791 | - | let feeAmount = $ | |
792 | - | let commonState = $ | |
793 | - | let emitAmountEstimated = $ | |
779 | + | let paymentInAmountAsset = $t03232232474._5 | |
780 | + | let bonus = $t03232232474._4 | |
781 | + | let feeAmount = $t03232232474._3 | |
782 | + | let commonState = $t03232232474._2 | |
783 | + | let emitAmountEstimated = $t03232232474._1 | |
794 | 784 | let emitAmount = if (if ((minOutAmount > 0)) | |
795 | 785 | then (minOutAmount > emitAmountEstimated) | |
796 | 786 | else false) | |
810 | 800 | let sendFee = if ((feeAmount > 0)) | |
811 | 801 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
812 | 802 | else nil | |
813 | - | let $ | |
803 | + | let $t03306033257 = if ((this == feeCollectorAddress)) | |
814 | 804 | then $Tuple2(0, 0) | |
815 | 805 | else if (paymentInAmountAsset) | |
816 | 806 | then $Tuple2(-(feeAmount), 0) | |
817 | 807 | else $Tuple2(0, -(feeAmount)) | |
818 | - | let amountAssetBalanceDelta = $ | |
819 | - | let priceAssetBalanceDelta = $ | |
820 | - | let $ | |
821 | - | let refreshKLpActions = $ | |
822 | - | let updatedKLp = $ | |
808 | + | let amountAssetBalanceDelta = $t03306033257._1 | |
809 | + | let priceAssetBalanceDelta = $t03306033257._2 | |
810 | + | let $t03326033368 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
811 | + | let refreshKLpActions = $t03326033368._1 | |
812 | + | let updatedKLp = $t03326033368._2 | |
823 | 813 | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
824 | 814 | } | |
825 | 815 | else throw("Strict value is not equal to itself.") | |
833 | 823 | ||
834 | 824 | @Callable(i) | |
835 | 825 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
836 | - | let $ | |
837 | - | let emitAmountEstimated = $ | |
838 | - | let commonState = $ | |
839 | - | let feeAmount = $ | |
840 | - | let bonus = $ | |
841 | - | let paymentInAmountAsset = $ | |
826 | + | let $t03356133718 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
827 | + | let emitAmountEstimated = $t03356133718._1 | |
828 | + | let commonState = $t03356133718._2 | |
829 | + | let feeAmount = $t03356133718._3 | |
830 | + | let bonus = $t03356133718._4 | |
831 | + | let paymentInAmountAsset = $t03356133718._5 | |
842 | 832 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
843 | 833 | } | |
844 | 834 | ||
872 | 862 | let paymentAmount = payment.amount | |
873 | 863 | let userAddress = i.caller | |
874 | 864 | let txId = i.transactionId | |
875 | - | let $ | |
876 | - | if (($ | |
865 | + | let $t03452334676 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
866 | + | if (($t03452334676 == $t03452334676)) | |
877 | 867 | then { | |
878 | - | let outInAmountAsset = $ | |
879 | - | let bonus = $ | |
880 | - | let feeAmount = $ | |
881 | - | let commonState = $ | |
882 | - | let amountEstimated = $ | |
868 | + | let outInAmountAsset = $t03452334676._5 | |
869 | + | let bonus = $t03452334676._4 | |
870 | + | let feeAmount = $t03452334676._3 | |
871 | + | let commonState = $t03452334676._2 | |
872 | + | let amountEstimated = $t03452334676._1 | |
883 | 873 | let amount = if (if ((minOutAmount > 0)) | |
884 | 874 | then (minOutAmount > amountEstimated) | |
885 | 875 | else false) | |
892 | 882 | let sendFee = if ((feeAmount > 0)) | |
893 | 883 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
894 | 884 | else nil | |
895 | - | let $ | |
885 | + | let $t03517635423 = { | |
896 | 886 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
897 | 887 | then 0 | |
898 | 888 | else feeAmount | |
900 | 890 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
901 | 891 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
902 | 892 | } | |
903 | - | let amountAssetBalanceDelta = $ | |
904 | - | let priceAssetBalanceDelta = $ | |
905 | - | let $ | |
906 | - | let refreshKLpActions = $ | |
907 | - | let updatedKLp = $ | |
893 | + | let amountAssetBalanceDelta = $t03517635423._1 | |
894 | + | let priceAssetBalanceDelta = $t03517635423._2 | |
895 | + | let $t03542635534 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
896 | + | let refreshKLpActions = $t03542635534._1 | |
897 | + | let updatedKLp = $t03542635534._2 | |
908 | 898 | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
909 | 899 | } | |
910 | 900 | else throw("Strict value is not equal to itself.") | |
918 | 908 | ||
919 | 909 | @Callable(i) | |
920 | 910 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
921 | - | let $ | |
922 | - | let amountEstimated = $ | |
923 | - | let commonState = $ | |
924 | - | let feeAmount = $ | |
925 | - | let bonus = $ | |
926 | - | let outInAmountAsset = $ | |
911 | + | let $t03571835874 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
912 | + | let amountEstimated = $t03571835874._1 | |
913 | + | let commonState = $t03571835874._2 | |
914 | + | let feeAmount = $t03571835874._3 | |
915 | + | let bonus = $t03571835874._4 | |
916 | + | let outInAmountAsset = $t03571835874._5 | |
927 | 917 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
928 | 918 | } | |
929 | 919 | ||
957 | 947 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
958 | 948 | if ((unstakeInv == unstakeInv)) | |
959 | 949 | then { | |
960 | - | let $ | |
961 | - | if (($ | |
950 | + | let $t03669936850 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
951 | + | if (($t03669936850 == $t03669936850)) | |
962 | 952 | then { | |
963 | - | let outInAmountAsset = $ | |
964 | - | let bonus = $ | |
965 | - | let feeAmount = $ | |
966 | - | let commonState = $ | |
967 | - | let amountEstimated = $ | |
953 | + | let outInAmountAsset = $t03669936850._5 | |
954 | + | let bonus = $t03669936850._4 | |
955 | + | let feeAmount = $t03669936850._3 | |
956 | + | let commonState = $t03669936850._2 | |
957 | + | let amountEstimated = $t03669936850._1 | |
968 | 958 | let amount = if (if ((minOutAmount > 0)) | |
969 | 959 | then (minOutAmount > amountEstimated) | |
970 | 960 | else false) | |
977 | 967 | let sendFee = if ((feeAmount > 0)) | |
978 | 968 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
979 | 969 | else nil | |
980 | - | let $ | |
970 | + | let $t03734537592 = { | |
981 | 971 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
982 | 972 | then 0 | |
983 | 973 | else feeAmount | |
985 | 975 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
986 | 976 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
987 | 977 | } | |
988 | - | let amountAssetBalanceDelta = $ | |
989 | - | let priceAssetBalanceDelta = $ | |
990 | - | let $ | |
991 | - | let refreshKLpActions = $ | |
992 | - | let updatedKLp = $ | |
978 | + | let amountAssetBalanceDelta = $t03734537592._1 | |
979 | + | let priceAssetBalanceDelta = $t03734537592._2 | |
980 | + | let $t03759537703 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
981 | + | let refreshKLpActions = $t03759537703._1 | |
982 | + | let updatedKLp = $t03759537703._2 | |
993 | 983 | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
994 | 984 | } | |
995 | 985 | else throw("Strict value is not equal to itself.") | |
1014 | 1004 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1015 | 1005 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1016 | 1006 | then { | |
1017 | - | let $ | |
1018 | - | let refreshKLpActions = $ | |
1019 | - | let updatedKLp = $ | |
1007 | + | let $t03849538577 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1008 | + | let refreshKLpActions = $t03849538577._1 | |
1009 | + | let updatedKLp = $t03849538577._2 | |
1020 | 1010 | (state ++ refreshKLpActions) | |
1021 | 1011 | } | |
1022 | 1012 | else throw("Strict value is not equal to itself.") | |
1040 | 1030 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1041 | 1031 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1042 | 1032 | then { | |
1043 | - | let $ | |
1044 | - | let refreshKLpActions = $ | |
1045 | - | let updatedKLp = $ | |
1033 | + | let $t03937339454 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1034 | + | let refreshKLpActions = $t03937339454._1 | |
1035 | + | let updatedKLp = $t03937339454._2 | |
1046 | 1036 | (state ++ refreshKLpActions) | |
1047 | 1037 | } | |
1048 | 1038 | else throw("Strict value is not equal to itself.") | |
1078 | 1068 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1079 | 1069 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1080 | 1070 | then { | |
1081 | - | let $ | |
1082 | - | let refreshKLpActions = $ | |
1083 | - | let updatedKLp = $ | |
1071 | + | let $t04042740508 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1072 | + | let refreshKLpActions = $t04042740508._1 | |
1073 | + | let updatedKLp = $t04042740508._2 | |
1084 | 1074 | (state ++ refreshKLpActions) | |
1085 | 1075 | } | |
1086 | 1076 | else throw("Strict value is not equal to itself.") | |
1123 | 1113 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1124 | 1114 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1125 | 1115 | then { | |
1126 | - | let $ | |
1127 | - | let refreshKLpActions = $ | |
1128 | - | let updatedKLp = $ | |
1116 | + | let $t04164841729 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1117 | + | let refreshKLpActions = $t04164841729._1 | |
1118 | + | let updatedKLp = $t04164841729._2 | |
1129 | 1119 | (state ++ refreshKLpActions) | |
1130 | 1120 | } | |
1131 | 1121 | else throw("Strict value is not equal to itself.") | |
1154 | 1144 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1155 | 1145 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1156 | 1146 | then { | |
1157 | - | let $ | |
1158 | - | let actions = $ | |
1159 | - | let updatedKLp = $ | |
1147 | + | let $t04271742772 = refreshKLpInternal(0, 0, 0) | |
1148 | + | let actions = $t04271742772._1 | |
1149 | + | let updatedKLp = $t04271742772._2 | |
1160 | 1150 | $Tuple2(actions, toString(updatedKLp)) | |
1161 | 1151 | } | |
1162 | 1152 | else throw("Strict value is not equal to itself.") |
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 | 345 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
346 | 346 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
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 | 377 | let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 0, DOWN), scale18, lpEmission) | |
378 | 378 | updatedKLp | |
379 | 379 | } | |
380 | 380 | ||
381 | 381 | ||
382 | 382 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
383 | 383 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
384 | 384 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
385 | 385 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
386 | 386 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
387 | 387 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
388 | 388 | $Tuple2(actions, updatedKLp) | |
389 | 389 | } | |
390 | 390 | ||
391 | 391 | ||
392 | 392 | func validateMatcherOrderAllowed (order) = { | |
393 | - | let cfg = getPoolConfig() | |
394 | - | let amtAssetId = cfg[idxAmtAssetId] | |
395 | - | let priceAssetId = cfg[idxPriceAssetId] | |
396 | - | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
397 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
398 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
399 | 393 | let amountAssetAmount = order.amount | |
400 | 394 | let priceAssetAmount = fraction(order.amount, order.price, scale8) | |
401 | - | let $ | |
395 | + | let $t01955919771 = if ((order.orderType == Buy)) | |
402 | 396 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
403 | 397 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
404 | - | let amountAssetBalanceDelta = $ | |
405 | - | let priceAssetBalanceDelta = $ | |
398 | + | let amountAssetBalanceDelta = $t01955919771._1 | |
399 | + | let priceAssetBalanceDelta = $t01955919771._2 | |
406 | 400 | if (if (if (isGlobalShutdown()) | |
407 | 401 | then true | |
408 | - | else ( | |
402 | + | else (cfgPoolStatus == PoolMatcherDisabled)) | |
409 | 403 | then true | |
410 | - | else ( | |
404 | + | else (cfgPoolStatus == PoolShutdown)) | |
411 | 405 | then throw("Exchange operations disabled") | |
412 | - | else { | |
413 | - | let orderAmtAssetStr = assetIdToString(value(order.assetPair.amountAsset)) | |
414 | - | let orderPriceAssetStr = assetIdToString(value(order.assetPair.priceAsset)) | |
415 | - | if (if ((orderAmtAssetStr != amtAssetId)) | |
416 | - | then true | |
417 | - | else (orderPriceAssetStr != priceAssetId)) | |
418 | - | then throw("Wrong order assets.") | |
419 | - | else { | |
420 | - | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
421 | - | let $t02064520745 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
422 | - | let unusedActions = $t02064520745._1 | |
423 | - | let kLpNew = $t02064520745._2 | |
424 | - | let isOrderValid = (kLpNew > kLp) | |
425 | - | isOrderValid | |
426 | - | } | |
427 | - | } | |
406 | + | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
407 | + | then true | |
408 | + | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
409 | + | then throw("Wrong order assets.") | |
410 | + | else { | |
411 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp")) | |
412 | + | let $t02024220342 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
413 | + | let unusedActions = $t02024220342._1 | |
414 | + | let kLpNew = $t02024220342._2 | |
415 | + | let isOrderValid = (kLpNew > kLp) | |
416 | + | isOrderValid | |
417 | + | } | |
428 | 418 | } | |
429 | 419 | ||
430 | 420 | ||
431 | 421 | func commonGet (i) = if ((size(i.payments) != 1)) | |
432 | 422 | then throw("exactly 1 payment is expected") | |
433 | 423 | else { | |
434 | 424 | let pmt = value(i.payments[0]) | |
435 | 425 | let pmtAssetId = value(pmt.assetId) | |
436 | 426 | let pmtAmt = pmt.amount | |
437 | 427 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
438 | 428 | let outAmAmt = res._1 | |
439 | 429 | let outPrAmt = res._2 | |
440 | 430 | let poolStatus = parseIntValue(res._9) | |
441 | 431 | let state = res._10 | |
442 | 432 | if (if (isGlobalShutdown()) | |
443 | 433 | then true | |
444 | 434 | else (poolStatus == PoolShutdown)) | |
445 | 435 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
446 | 436 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
447 | 437 | } | |
448 | 438 | ||
449 | 439 | ||
450 | 440 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
451 | 441 | then throw("exactly 2 payments are expected") | |
452 | 442 | else { | |
453 | 443 | let amAssetPmt = value(i.payments[0]) | |
454 | 444 | let prAssetPmt = value(i.payments[1]) | |
455 | 445 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
456 | 446 | let poolStatus = parseIntValue(estPut._8) | |
457 | 447 | if (if (if (isGlobalShutdown()) | |
458 | 448 | then true | |
459 | 449 | else (poolStatus == PoolPutDisabled)) | |
460 | 450 | then true | |
461 | 451 | else (poolStatus == PoolShutdown)) | |
462 | 452 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
463 | 453 | else estPut | |
464 | 454 | } | |
465 | 455 | ||
466 | 456 | ||
467 | 457 | func emit (amount) = { | |
468 | 458 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
469 | 459 | if ((emitInv == emitInv)) | |
470 | 460 | then { | |
471 | 461 | let emitInvLegacy = match emitInv { | |
472 | 462 | case legacyFactoryContract: Address => | |
473 | 463 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
474 | 464 | case _ => | |
475 | 465 | unit | |
476 | 466 | } | |
477 | 467 | if ((emitInvLegacy == emitInvLegacy)) | |
478 | 468 | then amount | |
479 | 469 | else throw("Strict value is not equal to itself.") | |
480 | 470 | } | |
481 | 471 | else throw("Strict value is not equal to itself.") | |
482 | 472 | } | |
483 | 473 | ||
484 | 474 | ||
485 | 475 | func takeFee (amount) = { | |
486 | 476 | let feeAmount = fraction(amount, fee, scale8) | |
487 | 477 | $Tuple2((amount - feeAmount), feeAmount) | |
488 | 478 | } | |
489 | 479 | ||
490 | 480 | ||
491 | 481 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
492 | 482 | let isEval = (txId == unit) | |
493 | 483 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
494 | 484 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
495 | 485 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
496 | 486 | then true | |
497 | 487 | else if ((paymentAssetId == cfgPriceAssetId)) | |
498 | 488 | then false | |
499 | 489 | else throwErr("invalid asset") | |
500 | - | let $ | |
490 | + | let $t02302623319 = if (isEval) | |
501 | 491 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
502 | 492 | else if (paymentInAmountAsset) | |
503 | 493 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
504 | 494 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
505 | - | let amountBalanceOld = $ | |
506 | - | let priceBalanceOld = $ | |
507 | - | let $ | |
495 | + | let amountBalanceOld = $t02302623319._1 | |
496 | + | let priceBalanceOld = $t02302623319._2 | |
497 | + | let $t02332323472 = if (paymentInAmountAsset) | |
508 | 498 | then $Tuple2(paymentAmountRaw, 0) | |
509 | 499 | else $Tuple2(0, paymentAmountRaw) | |
510 | - | let amountAssetAmountRaw = $ | |
511 | - | let priceAssetAmountRaw = $ | |
500 | + | let amountAssetAmountRaw = $t02332323472._1 | |
501 | + | let priceAssetAmountRaw = $t02332323472._2 | |
512 | 502 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
513 | 503 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
514 | - | let $ | |
515 | - | let paymentAmount = $ | |
516 | - | let feeAmount = $ | |
504 | + | let $t02359423653 = takeFee(paymentAmountRaw) | |
505 | + | let paymentAmount = $t02359423653._1 | |
506 | + | let feeAmount = $t02359423653._2 | |
517 | 507 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
518 | 508 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
519 | 509 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
520 | 510 | let priceNew = fromX18(priceNewX18, scale8) | |
521 | 511 | let paymentBalance = if (paymentInAmountAsset) | |
522 | 512 | then amountBalanceOld | |
523 | 513 | else priceBalanceOld | |
524 | 514 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
525 | 515 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
526 | 516 | let chechSupply = if ((supplyBigInt > big0)) | |
527 | 517 | then true | |
528 | 518 | else throwErr("initial deposit requires all coins") | |
529 | 519 | if ((chechSupply == chechSupply)) | |
530 | 520 | then { | |
531 | 521 | let depositBigInt = toBigInt(paymentAmount) | |
532 | 522 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
533 | 523 | let commonState = if (isEval) | |
534 | 524 | then nil | |
535 | 525 | 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))] | |
536 | 526 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
537 | 527 | let priceOld = fromX18(priceOldX18, scale8) | |
538 | 528 | let loss = { | |
539 | - | let $ | |
529 | + | let $t02513025297 = if (paymentInAmountAsset) | |
540 | 530 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
541 | 531 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
542 | - | let amount = $ | |
543 | - | let balance = $ | |
532 | + | let amount = $t02513025297._1 | |
533 | + | let balance = $t02513025297._2 | |
544 | 534 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
545 | 535 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
546 | 536 | } | |
547 | 537 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
548 | 538 | } | |
549 | 539 | else throw("Strict value is not equal to itself.") | |
550 | 540 | } | |
551 | 541 | ||
552 | 542 | ||
553 | 543 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
554 | 544 | let isEval = (txId == unit) | |
555 | 545 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
556 | 546 | then true | |
557 | 547 | else throwErr("invalid lp asset")] | |
558 | 548 | if ((checks == checks)) | |
559 | 549 | then { | |
560 | 550 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
561 | 551 | then true | |
562 | 552 | else if ((outAssetId == cfgPriceAssetId)) | |
563 | 553 | then false | |
564 | 554 | else throwErr("invalid asset") | |
565 | 555 | let balanceBigInt = if (outInAmountAsset) | |
566 | 556 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
567 | 557 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
568 | 558 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
569 | 559 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
570 | 560 | let outBalance = if (outInAmountAsset) | |
571 | 561 | then amBalanceOld | |
572 | 562 | else prBalanceOld | |
573 | 563 | let outBalanceBigInt = toBigInt(outBalance) | |
574 | 564 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
575 | 565 | let redeemedBigInt = toBigInt(paymentAmount) | |
576 | 566 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
577 | - | let $ | |
578 | - | let totalAmount = $ | |
579 | - | let feeAmount = $ | |
580 | - | let $ | |
567 | + | let $t02689926949 = takeFee(amountRaw) | |
568 | + | let totalAmount = $t02689926949._1 | |
569 | + | let feeAmount = $t02689926949._2 | |
570 | + | let $t02695327179 = if (outInAmountAsset) | |
581 | 571 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
582 | 572 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
583 | - | let outAmAmount = $ | |
584 | - | let outPrAmount = $ | |
585 | - | let amBalanceNew = $ | |
586 | - | let prBalanceNew = $ | |
573 | + | let outAmAmount = $t02695327179._1 | |
574 | + | let outPrAmount = $t02695327179._2 | |
575 | + | let amBalanceNew = $t02695327179._3 | |
576 | + | let prBalanceNew = $t02695327179._4 | |
587 | 577 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
588 | 578 | let priceNew = fromX18(priceNewX18, scale8) | |
589 | 579 | let commonState = if (isEval) | |
590 | 580 | then nil | |
591 | 581 | 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)] | |
592 | 582 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
593 | 583 | let priceOld = fromX18(priceOldX18, scale8) | |
594 | 584 | let loss = { | |
595 | 585 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
596 | 586 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
597 | 587 | } | |
598 | 588 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
599 | 589 | } | |
600 | 590 | else throw("Strict value is not equal to itself.") | |
601 | 591 | } | |
602 | 592 | ||
603 | 593 | ||
604 | 594 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
605 | 595 | case s: String => | |
606 | 596 | fromBase58String(s) | |
607 | 597 | case _: Unit => | |
608 | 598 | unit | |
609 | 599 | case _ => | |
610 | 600 | throw("Match error") | |
611 | 601 | } | |
612 | 602 | ||
613 | 603 | ||
614 | 604 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
615 | 605 | case s: String => | |
616 | 606 | fromBase58String(s) | |
617 | 607 | case _: Unit => | |
618 | 608 | unit | |
619 | 609 | case _ => | |
620 | 610 | throw("Match error") | |
621 | 611 | } | |
622 | 612 | ||
623 | 613 | ||
624 | 614 | func isManager (i) = match managerPublicKeyOrUnit() { | |
625 | 615 | case pk: ByteVector => | |
626 | 616 | (i.callerPublicKey == pk) | |
627 | 617 | case _: Unit => | |
628 | 618 | (i.caller == this) | |
629 | 619 | case _ => | |
630 | 620 | throw("Match error") | |
631 | 621 | } | |
632 | 622 | ||
633 | 623 | ||
634 | 624 | func mustManager (i) = { | |
635 | 625 | let pd = throw("Permission denied") | |
636 | 626 | match managerPublicKeyOrUnit() { | |
637 | 627 | case pk: ByteVector => | |
638 | 628 | if ((i.callerPublicKey == pk)) | |
639 | 629 | then true | |
640 | 630 | else pd | |
641 | 631 | case _: Unit => | |
642 | 632 | if ((i.caller == this)) | |
643 | 633 | then true | |
644 | 634 | else pd | |
645 | 635 | case _ => | |
646 | 636 | throw("Match error") | |
647 | 637 | } | |
648 | 638 | } | |
649 | 639 | ||
650 | 640 | ||
651 | 641 | @Callable(i) | |
652 | 642 | func setManager (pendingManagerPublicKey) = { | |
653 | 643 | let checkCaller = mustManager(i) | |
654 | 644 | if ((checkCaller == checkCaller)) | |
655 | 645 | then { | |
656 | 646 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
657 | 647 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
658 | 648 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
659 | 649 | else throw("Strict value is not equal to itself.") | |
660 | 650 | } | |
661 | 651 | else throw("Strict value is not equal to itself.") | |
662 | 652 | } | |
663 | 653 | ||
664 | 654 | ||
665 | 655 | ||
666 | 656 | @Callable(i) | |
667 | 657 | func confirmManager () = { | |
668 | 658 | let pm = pendingManagerPublicKeyOrUnit() | |
669 | 659 | let hasPM = if (isDefined(pm)) | |
670 | 660 | then true | |
671 | 661 | else throw("No pending manager") | |
672 | 662 | if ((hasPM == hasPM)) | |
673 | 663 | then { | |
674 | 664 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
675 | 665 | then true | |
676 | 666 | else throw("You are not pending manager") | |
677 | 667 | if ((checkPM == checkPM)) | |
678 | 668 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
679 | 669 | else throw("Strict value is not equal to itself.") | |
680 | 670 | } | |
681 | 671 | else throw("Strict value is not equal to itself.") | |
682 | 672 | } | |
683 | 673 | ||
684 | 674 | ||
685 | 675 | ||
686 | 676 | @Callable(i) | |
687 | 677 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
688 | 678 | then throw("Invalid slippageTolerance passed") | |
689 | 679 | else { | |
690 | 680 | let estPut = commonPut(i, slippageTolerance, true) | |
691 | 681 | let emitLpAmt = estPut._2 | |
692 | 682 | let lpAssetId = estPut._7 | |
693 | 683 | let state = estPut._9 | |
694 | 684 | let amDiff = estPut._10 | |
695 | 685 | let prDiff = estPut._11 | |
696 | 686 | let amId = estPut._12 | |
697 | 687 | let prId = estPut._13 | |
698 | 688 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
699 | 689 | if ((emitInv == emitInv)) | |
700 | 690 | then { | |
701 | 691 | let emitInvLegacy = match emitInv { | |
702 | 692 | case legacyFactoryContract: Address => | |
703 | 693 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
704 | 694 | case _ => | |
705 | 695 | unit | |
706 | 696 | } | |
707 | 697 | if ((emitInvLegacy == emitInvLegacy)) | |
708 | 698 | then { | |
709 | 699 | let slippageAInv = if ((amDiff > 0)) | |
710 | 700 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
711 | 701 | else nil | |
712 | 702 | if ((slippageAInv == slippageAInv)) | |
713 | 703 | then { | |
714 | 704 | let slippagePInv = if ((prDiff > 0)) | |
715 | 705 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
716 | 706 | else nil | |
717 | 707 | if ((slippagePInv == slippagePInv)) | |
718 | 708 | then { | |
719 | 709 | let lpTransfer = if (shouldAutoStake) | |
720 | 710 | then { | |
721 | 711 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
722 | 712 | if ((slpStakeInv == slpStakeInv)) | |
723 | 713 | then nil | |
724 | 714 | else throw("Strict value is not equal to itself.") | |
725 | 715 | } | |
726 | 716 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
727 | - | let $ | |
728 | - | let refreshKLpActions = $ | |
729 | - | let updatedKLp = $ | |
717 | + | let $t03113031195 = refreshKLpInternal(0, 0, 0) | |
718 | + | let refreshKLpActions = $t03113031195._1 | |
719 | + | let updatedKLp = $t03113031195._2 | |
730 | 720 | ((state ++ lpTransfer) ++ refreshKLpActions) | |
731 | 721 | } | |
732 | 722 | else throw("Strict value is not equal to itself.") | |
733 | 723 | } | |
734 | 724 | else throw("Strict value is not equal to itself.") | |
735 | 725 | } | |
736 | 726 | else throw("Strict value is not equal to itself.") | |
737 | 727 | } | |
738 | 728 | else throw("Strict value is not equal to itself.") | |
739 | 729 | } | |
740 | 730 | ||
741 | 731 | ||
742 | 732 | ||
743 | 733 | @Callable(i) | |
744 | 734 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
745 | 735 | then throw("Invalid value passed") | |
746 | 736 | else { | |
747 | 737 | let estPut = commonPut(i, maxSlippage, false) | |
748 | 738 | let state = estPut._9 | |
749 | - | let $ | |
750 | - | let refreshKLpActions = $ | |
751 | - | let updatedKLp = $ | |
739 | + | let $t03148131546 = refreshKLpInternal(0, 0, 0) | |
740 | + | let refreshKLpActions = $t03148131546._1 | |
741 | + | let updatedKLp = $t03148131546._2 | |
752 | 742 | (state ++ refreshKLpActions) | |
753 | 743 | } | |
754 | 744 | ||
755 | 745 | ||
756 | 746 | ||
757 | 747 | @Callable(i) | |
758 | 748 | func putOneTkn (minOutAmount,autoStake) = { | |
759 | 749 | let isPoolOneTokenOperationsDisabled = { | |
760 | 750 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
761 | 751 | if ($isInstanceOf(@, "Boolean")) | |
762 | 752 | then @ | |
763 | 753 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
764 | 754 | } | |
765 | 755 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
766 | 756 | then true | |
767 | 757 | else (cfgPoolStatus == PoolPutDisabled)) | |
768 | 758 | then true | |
769 | 759 | else (cfgPoolStatus == PoolShutdown)) | |
770 | 760 | then true | |
771 | 761 | else isPoolOneTokenOperationsDisabled | |
772 | 762 | let checks = [if (if (!(isPutDisabled)) | |
773 | 763 | then true | |
774 | 764 | else isManager(i)) | |
775 | 765 | then true | |
776 | 766 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
777 | 767 | then true | |
778 | 768 | else throwErr("exactly 1 payment are expected")] | |
779 | 769 | if ((checks == checks)) | |
780 | 770 | then { | |
781 | 771 | let payment = i.payments[0] | |
782 | 772 | let paymentAssetId = payment.assetId | |
783 | 773 | let paymentAmountRaw = payment.amount | |
784 | 774 | let userAddress = i.caller | |
785 | 775 | let txId = i.transactionId | |
786 | - | let $ | |
787 | - | if (($ | |
776 | + | let $t03232232474 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
777 | + | if (($t03232232474 == $t03232232474)) | |
788 | 778 | then { | |
789 | - | let paymentInAmountAsset = $ | |
790 | - | let bonus = $ | |
791 | - | let feeAmount = $ | |
792 | - | let commonState = $ | |
793 | - | let emitAmountEstimated = $ | |
779 | + | let paymentInAmountAsset = $t03232232474._5 | |
780 | + | let bonus = $t03232232474._4 | |
781 | + | let feeAmount = $t03232232474._3 | |
782 | + | let commonState = $t03232232474._2 | |
783 | + | let emitAmountEstimated = $t03232232474._1 | |
794 | 784 | let emitAmount = if (if ((minOutAmount > 0)) | |
795 | 785 | then (minOutAmount > emitAmountEstimated) | |
796 | 786 | else false) | |
797 | 787 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
798 | 788 | else emitAmountEstimated | |
799 | 789 | let emitInv = emit(emitAmount) | |
800 | 790 | if ((emitInv == emitInv)) | |
801 | 791 | then { | |
802 | 792 | let lpTransfer = if (autoStake) | |
803 | 793 | then { | |
804 | 794 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
805 | 795 | if ((stakeInv == stakeInv)) | |
806 | 796 | then nil | |
807 | 797 | else throw("Strict value is not equal to itself.") | |
808 | 798 | } | |
809 | 799 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
810 | 800 | let sendFee = if ((feeAmount > 0)) | |
811 | 801 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
812 | 802 | else nil | |
813 | - | let $ | |
803 | + | let $t03306033257 = if ((this == feeCollectorAddress)) | |
814 | 804 | then $Tuple2(0, 0) | |
815 | 805 | else if (paymentInAmountAsset) | |
816 | 806 | then $Tuple2(-(feeAmount), 0) | |
817 | 807 | else $Tuple2(0, -(feeAmount)) | |
818 | - | let amountAssetBalanceDelta = $ | |
819 | - | let priceAssetBalanceDelta = $ | |
820 | - | let $ | |
821 | - | let refreshKLpActions = $ | |
822 | - | let updatedKLp = $ | |
808 | + | let amountAssetBalanceDelta = $t03306033257._1 | |
809 | + | let priceAssetBalanceDelta = $t03306033257._2 | |
810 | + | let $t03326033368 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
811 | + | let refreshKLpActions = $t03326033368._1 | |
812 | + | let updatedKLp = $t03326033368._2 | |
823 | 813 | $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
824 | 814 | } | |
825 | 815 | else throw("Strict value is not equal to itself.") | |
826 | 816 | } | |
827 | 817 | else throw("Strict value is not equal to itself.") | |
828 | 818 | } | |
829 | 819 | else throw("Strict value is not equal to itself.") | |
830 | 820 | } | |
831 | 821 | ||
832 | 822 | ||
833 | 823 | ||
834 | 824 | @Callable(i) | |
835 | 825 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
836 | - | let $ | |
837 | - | let emitAmountEstimated = $ | |
838 | - | let commonState = $ | |
839 | - | let feeAmount = $ | |
840 | - | let bonus = $ | |
841 | - | let paymentInAmountAsset = $ | |
826 | + | let $t03356133718 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
827 | + | let emitAmountEstimated = $t03356133718._1 | |
828 | + | let commonState = $t03356133718._2 | |
829 | + | let feeAmount = $t03356133718._3 | |
830 | + | let bonus = $t03356133718._4 | |
831 | + | let paymentInAmountAsset = $t03356133718._5 | |
842 | 832 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
843 | 833 | } | |
844 | 834 | ||
845 | 835 | ||
846 | 836 | ||
847 | 837 | @Callable(i) | |
848 | 838 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
849 | 839 | let isPoolOneTokenOperationsDisabled = { | |
850 | 840 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
851 | 841 | if ($isInstanceOf(@, "Boolean")) | |
852 | 842 | then @ | |
853 | 843 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
854 | 844 | } | |
855 | 845 | let isGetDisabled = if (if (isGlobalShutdown()) | |
856 | 846 | then true | |
857 | 847 | else (cfgPoolStatus == PoolShutdown)) | |
858 | 848 | then true | |
859 | 849 | else isPoolOneTokenOperationsDisabled | |
860 | 850 | let checks = [if (if (!(isGetDisabled)) | |
861 | 851 | then true | |
862 | 852 | else isManager(i)) | |
863 | 853 | then true | |
864 | 854 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
865 | 855 | then true | |
866 | 856 | else throwErr("exactly 1 payment are expected")] | |
867 | 857 | if ((checks == checks)) | |
868 | 858 | then { | |
869 | 859 | let outAssetId = parseAssetId(outAssetIdStr) | |
870 | 860 | let payment = i.payments[0] | |
871 | 861 | let paymentAssetId = payment.assetId | |
872 | 862 | let paymentAmount = payment.amount | |
873 | 863 | let userAddress = i.caller | |
874 | 864 | let txId = i.transactionId | |
875 | - | let $ | |
876 | - | if (($ | |
865 | + | let $t03452334676 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
866 | + | if (($t03452334676 == $t03452334676)) | |
877 | 867 | then { | |
878 | - | let outInAmountAsset = $ | |
879 | - | let bonus = $ | |
880 | - | let feeAmount = $ | |
881 | - | let commonState = $ | |
882 | - | let amountEstimated = $ | |
868 | + | let outInAmountAsset = $t03452334676._5 | |
869 | + | let bonus = $t03452334676._4 | |
870 | + | let feeAmount = $t03452334676._3 | |
871 | + | let commonState = $t03452334676._2 | |
872 | + | let amountEstimated = $t03452334676._1 | |
883 | 873 | let amount = if (if ((minOutAmount > 0)) | |
884 | 874 | then (minOutAmount > amountEstimated) | |
885 | 875 | else false) | |
886 | 876 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
887 | 877 | else amountEstimated | |
888 | 878 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
889 | 879 | if ((burnInv == burnInv)) | |
890 | 880 | then { | |
891 | 881 | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
892 | 882 | let sendFee = if ((feeAmount > 0)) | |
893 | 883 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
894 | 884 | else nil | |
895 | - | let $ | |
885 | + | let $t03517635423 = { | |
896 | 886 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
897 | 887 | then 0 | |
898 | 888 | else feeAmount | |
899 | 889 | if (outInAmountAsset) | |
900 | 890 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
901 | 891 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
902 | 892 | } | |
903 | - | let amountAssetBalanceDelta = $ | |
904 | - | let priceAssetBalanceDelta = $ | |
905 | - | let $ | |
906 | - | let refreshKLpActions = $ | |
907 | - | let updatedKLp = $ | |
893 | + | let amountAssetBalanceDelta = $t03517635423._1 | |
894 | + | let priceAssetBalanceDelta = $t03517635423._2 | |
895 | + | let $t03542635534 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
896 | + | let refreshKLpActions = $t03542635534._1 | |
897 | + | let updatedKLp = $t03542635534._2 | |
908 | 898 | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
909 | 899 | } | |
910 | 900 | else throw("Strict value is not equal to itself.") | |
911 | 901 | } | |
912 | 902 | else throw("Strict value is not equal to itself.") | |
913 | 903 | } | |
914 | 904 | else throw("Strict value is not equal to itself.") | |
915 | 905 | } | |
916 | 906 | ||
917 | 907 | ||
918 | 908 | ||
919 | 909 | @Callable(i) | |
920 | 910 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
921 | - | let $ | |
922 | - | let amountEstimated = $ | |
923 | - | let commonState = $ | |
924 | - | let feeAmount = $ | |
925 | - | let bonus = $ | |
926 | - | let outInAmountAsset = $ | |
911 | + | let $t03571835874 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
912 | + | let amountEstimated = $t03571835874._1 | |
913 | + | let commonState = $t03571835874._2 | |
914 | + | let feeAmount = $t03571835874._3 | |
915 | + | let bonus = $t03571835874._4 | |
916 | + | let outInAmountAsset = $t03571835874._5 | |
927 | 917 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
928 | 918 | } | |
929 | 919 | ||
930 | 920 | ||
931 | 921 | ||
932 | 922 | @Callable(i) | |
933 | 923 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
934 | 924 | let isPoolOneTokenOperationsDisabled = { | |
935 | 925 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
936 | 926 | if ($isInstanceOf(@, "Boolean")) | |
937 | 927 | then @ | |
938 | 928 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
939 | 929 | } | |
940 | 930 | let isGetDisabled = if (if (isGlobalShutdown()) | |
941 | 931 | then true | |
942 | 932 | else (cfgPoolStatus == PoolShutdown)) | |
943 | 933 | then true | |
944 | 934 | else isPoolOneTokenOperationsDisabled | |
945 | 935 | let checks = [if (if (!(isGetDisabled)) | |
946 | 936 | then true | |
947 | 937 | else isManager(i)) | |
948 | 938 | then true | |
949 | 939 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
950 | 940 | then true | |
951 | 941 | else throwErr("no payments are expected")] | |
952 | 942 | if ((checks == checks)) | |
953 | 943 | then { | |
954 | 944 | let outAssetId = parseAssetId(outAssetIdStr) | |
955 | 945 | let userAddress = i.caller | |
956 | 946 | let txId = i.transactionId | |
957 | 947 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
958 | 948 | if ((unstakeInv == unstakeInv)) | |
959 | 949 | then { | |
960 | - | let $ | |
961 | - | if (($ | |
950 | + | let $t03669936850 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
951 | + | if (($t03669936850 == $t03669936850)) | |
962 | 952 | then { | |
963 | - | let outInAmountAsset = $ | |
964 | - | let bonus = $ | |
965 | - | let feeAmount = $ | |
966 | - | let commonState = $ | |
967 | - | let amountEstimated = $ | |
953 | + | let outInAmountAsset = $t03669936850._5 | |
954 | + | let bonus = $t03669936850._4 | |
955 | + | let feeAmount = $t03669936850._3 | |
956 | + | let commonState = $t03669936850._2 | |
957 | + | let amountEstimated = $t03669936850._1 | |
968 | 958 | let amount = if (if ((minOutAmount > 0)) | |
969 | 959 | then (minOutAmount > amountEstimated) | |
970 | 960 | else false) | |
971 | 961 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
972 | 962 | else amountEstimated | |
973 | 963 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
974 | 964 | if ((burnInv == burnInv)) | |
975 | 965 | then { | |
976 | 966 | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
977 | 967 | let sendFee = if ((feeAmount > 0)) | |
978 | 968 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
979 | 969 | else nil | |
980 | - | let $ | |
970 | + | let $t03734537592 = { | |
981 | 971 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
982 | 972 | then 0 | |
983 | 973 | else feeAmount | |
984 | 974 | if (outInAmountAsset) | |
985 | 975 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
986 | 976 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
987 | 977 | } | |
988 | - | let amountAssetBalanceDelta = $ | |
989 | - | let priceAssetBalanceDelta = $ | |
990 | - | let $ | |
991 | - | let refreshKLpActions = $ | |
992 | - | let updatedKLp = $ | |
978 | + | let amountAssetBalanceDelta = $t03734537592._1 | |
979 | + | let priceAssetBalanceDelta = $t03734537592._2 | |
980 | + | let $t03759537703 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
981 | + | let refreshKLpActions = $t03759537703._1 | |
982 | + | let updatedKLp = $t03759537703._2 | |
993 | 983 | $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
994 | 984 | } | |
995 | 985 | else throw("Strict value is not equal to itself.") | |
996 | 986 | } | |
997 | 987 | else throw("Strict value is not equal to itself.") | |
998 | 988 | } | |
999 | 989 | else throw("Strict value is not equal to itself.") | |
1000 | 990 | } | |
1001 | 991 | else throw("Strict value is not equal to itself.") | |
1002 | 992 | } | |
1003 | 993 | ||
1004 | 994 | ||
1005 | 995 | ||
1006 | 996 | @Callable(i) | |
1007 | 997 | func get () = { | |
1008 | 998 | let res = commonGet(i) | |
1009 | 999 | let outAmtAmt = res._1 | |
1010 | 1000 | let outPrAmt = res._2 | |
1011 | 1001 | let pmtAmt = res._3 | |
1012 | 1002 | let pmtAssetId = res._4 | |
1013 | 1003 | let state = res._5 | |
1014 | 1004 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1015 | 1005 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1016 | 1006 | then { | |
1017 | - | let $ | |
1018 | - | let refreshKLpActions = $ | |
1019 | - | let updatedKLp = $ | |
1007 | + | let $t03849538577 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1008 | + | let refreshKLpActions = $t03849538577._1 | |
1009 | + | let updatedKLp = $t03849538577._2 | |
1020 | 1010 | (state ++ refreshKLpActions) | |
1021 | 1011 | } | |
1022 | 1012 | else throw("Strict value is not equal to itself.") | |
1023 | 1013 | } | |
1024 | 1014 | ||
1025 | 1015 | ||
1026 | 1016 | ||
1027 | 1017 | @Callable(i) | |
1028 | 1018 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1029 | 1019 | let res = commonGet(i) | |
1030 | 1020 | let outAmAmt = res._1 | |
1031 | 1021 | let outPrAmt = res._2 | |
1032 | 1022 | let pmtAmt = res._3 | |
1033 | 1023 | let pmtAssetId = res._4 | |
1034 | 1024 | let state = res._5 | |
1035 | 1025 | if ((noLessThenAmtAsset > outAmAmt)) | |
1036 | 1026 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1037 | 1027 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1038 | 1028 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1039 | 1029 | else { | |
1040 | 1030 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1041 | 1031 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1042 | 1032 | then { | |
1043 | - | let $ | |
1044 | - | let refreshKLpActions = $ | |
1045 | - | let updatedKLp = $ | |
1033 | + | let $t03937339454 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1034 | + | let refreshKLpActions = $t03937339454._1 | |
1035 | + | let updatedKLp = $t03937339454._2 | |
1046 | 1036 | (state ++ refreshKLpActions) | |
1047 | 1037 | } | |
1048 | 1038 | else throw("Strict value is not equal to itself.") | |
1049 | 1039 | } | |
1050 | 1040 | } | |
1051 | 1041 | ||
1052 | 1042 | ||
1053 | 1043 | ||
1054 | 1044 | @Callable(i) | |
1055 | 1045 | func unstakeAndGet (amount) = { | |
1056 | 1046 | let checkPayments = if ((size(i.payments) != 0)) | |
1057 | 1047 | then throw("No payments are expected") | |
1058 | 1048 | else true | |
1059 | 1049 | if ((checkPayments == checkPayments)) | |
1060 | 1050 | then { | |
1061 | 1051 | let cfg = getPoolConfig() | |
1062 | 1052 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1063 | 1053 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1064 | 1054 | if ((unstakeInv == unstakeInv)) | |
1065 | 1055 | then { | |
1066 | 1056 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1067 | 1057 | let outAmAmt = res._1 | |
1068 | 1058 | let outPrAmt = res._2 | |
1069 | 1059 | let poolStatus = parseIntValue(res._9) | |
1070 | 1060 | let state = res._10 | |
1071 | 1061 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1072 | 1062 | then true | |
1073 | 1063 | else (poolStatus == PoolShutdown)) | |
1074 | 1064 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1075 | 1065 | else true | |
1076 | 1066 | if ((checkPoolStatus == checkPoolStatus)) | |
1077 | 1067 | then { | |
1078 | 1068 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1079 | 1069 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1080 | 1070 | then { | |
1081 | - | let $ | |
1082 | - | let refreshKLpActions = $ | |
1083 | - | let updatedKLp = $ | |
1071 | + | let $t04042740508 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1072 | + | let refreshKLpActions = $t04042740508._1 | |
1073 | + | let updatedKLp = $t04042740508._2 | |
1084 | 1074 | (state ++ refreshKLpActions) | |
1085 | 1075 | } | |
1086 | 1076 | else throw("Strict value is not equal to itself.") | |
1087 | 1077 | } | |
1088 | 1078 | else throw("Strict value is not equal to itself.") | |
1089 | 1079 | } | |
1090 | 1080 | else throw("Strict value is not equal to itself.") | |
1091 | 1081 | } | |
1092 | 1082 | else throw("Strict value is not equal to itself.") | |
1093 | 1083 | } | |
1094 | 1084 | ||
1095 | 1085 | ||
1096 | 1086 | ||
1097 | 1087 | @Callable(i) | |
1098 | 1088 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1099 | 1089 | let isGetDisabled = if (isGlobalShutdown()) | |
1100 | 1090 | then true | |
1101 | 1091 | else (cfgPoolStatus == PoolShutdown) | |
1102 | 1092 | let checks = [if (!(isGetDisabled)) | |
1103 | 1093 | then true | |
1104 | 1094 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1105 | 1095 | then true | |
1106 | 1096 | else throw("no payments are expected")] | |
1107 | 1097 | if ((checks == checks)) | |
1108 | 1098 | then { | |
1109 | 1099 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1110 | 1100 | if ((unstakeInv == unstakeInv)) | |
1111 | 1101 | then { | |
1112 | 1102 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1113 | 1103 | let outAmAmt = res._1 | |
1114 | 1104 | let outPrAmt = res._2 | |
1115 | 1105 | let state = res._10 | |
1116 | 1106 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1117 | 1107 | then true | |
1118 | 1108 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1119 | 1109 | then true | |
1120 | 1110 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1121 | 1111 | if ((checkAmounts == checkAmounts)) | |
1122 | 1112 | then { | |
1123 | 1113 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1124 | 1114 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1125 | 1115 | then { | |
1126 | - | let $ | |
1127 | - | let refreshKLpActions = $ | |
1128 | - | let updatedKLp = $ | |
1116 | + | let $t04164841729 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1117 | + | let refreshKLpActions = $t04164841729._1 | |
1118 | + | let updatedKLp = $t04164841729._2 | |
1129 | 1119 | (state ++ refreshKLpActions) | |
1130 | 1120 | } | |
1131 | 1121 | else throw("Strict value is not equal to itself.") | |
1132 | 1122 | } | |
1133 | 1123 | else throw("Strict value is not equal to itself.") | |
1134 | 1124 | } | |
1135 | 1125 | else throw("Strict value is not equal to itself.") | |
1136 | 1126 | } | |
1137 | 1127 | else throw("Strict value is not equal to itself.") | |
1138 | 1128 | } | |
1139 | 1129 | ||
1140 | 1130 | ||
1141 | 1131 | ||
1142 | 1132 | @Callable(i) | |
1143 | 1133 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1144 | 1134 | then throw("permissions denied") | |
1145 | 1135 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1146 | 1136 | ||
1147 | 1137 | ||
1148 | 1138 | ||
1149 | 1139 | @Callable(i) | |
1150 | 1140 | func refreshKLp () = { | |
1151 | 1141 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1152 | 1142 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1153 | 1143 | then unit | |
1154 | 1144 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1155 | 1145 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1156 | 1146 | then { | |
1157 | - | let $ | |
1158 | - | let actions = $ | |
1159 | - | let updatedKLp = $ | |
1147 | + | let $t04271742772 = refreshKLpInternal(0, 0, 0) | |
1148 | + | let actions = $t04271742772._1 | |
1149 | + | let updatedKLp = $t04271742772._2 | |
1160 | 1150 | $Tuple2(actions, toString(updatedKLp)) | |
1161 | 1151 | } | |
1162 | 1152 | else throw("Strict value is not equal to itself.") | |
1163 | 1153 | } | |
1164 | 1154 | ||
1165 | 1155 | ||
1166 | 1156 | ||
1167 | 1157 | @Callable(i) | |
1168 | 1158 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1169 | 1159 | ||
1170 | 1160 | ||
1171 | 1161 | ||
1172 | 1162 | @Callable(i) | |
1173 | 1163 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1174 | 1164 | ||
1175 | 1165 | ||
1176 | 1166 | ||
1177 | 1167 | @Callable(i) | |
1178 | 1168 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1179 | 1169 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1180 | 1170 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1181 | 1171 | } | |
1182 | 1172 | ||
1183 | 1173 | ||
1184 | 1174 | ||
1185 | 1175 | @Callable(i) | |
1186 | 1176 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1187 | 1177 | ||
1188 | 1178 | ||
1189 | 1179 | ||
1190 | 1180 | @Callable(i) | |
1191 | 1181 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1192 | 1182 | ||
1193 | 1183 | ||
1194 | 1184 | ||
1195 | 1185 | @Callable(i) | |
1196 | 1186 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1197 | 1187 | ||
1198 | 1188 | ||
1199 | 1189 | ||
1200 | 1190 | @Callable(i) | |
1201 | 1191 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1202 | 1192 | ||
1203 | 1193 | ||
1204 | 1194 | ||
1205 | 1195 | @Callable(i) | |
1206 | 1196 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1207 | 1197 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1208 | 1198 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1209 | 1199 | } | |
1210 | 1200 | ||
1211 | 1201 | ||
1212 | 1202 | ||
1213 | 1203 | @Callable(i) | |
1214 | 1204 | func statsREADONLY () = { | |
1215 | 1205 | let cfg = getPoolConfig() | |
1216 | 1206 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1217 | 1207 | let amtAssetId = cfg[idxAmtAssetId] | |
1218 | 1208 | let priceAssetId = cfg[idxPriceAssetId] | |
1219 | 1209 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1220 | 1210 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1221 | 1211 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1222 | 1212 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1223 | 1213 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1224 | 1214 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1225 | 1215 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1226 | 1216 | let pricesList = if ((poolLPBalance == 0)) | |
1227 | 1217 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1228 | 1218 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1229 | 1219 | let curPrice = 0 | |
1230 | 1220 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1231 | 1221 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1232 | 1222 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1233 | 1223 | $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)) | |
1234 | 1224 | } | |
1235 | 1225 | ||
1236 | 1226 | ||
1237 | 1227 | ||
1238 | 1228 | @Callable(i) | |
1239 | 1229 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1240 | 1230 | let cfg = getPoolConfig() | |
1241 | 1231 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1242 | 1232 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1243 | 1233 | let amAssetId = fromBase58String(amAssetIdStr) | |
1244 | 1234 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1245 | 1235 | let prAssetId = fromBase58String(prAssetIdStr) | |
1246 | 1236 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1247 | 1237 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1248 | 1238 | let poolStatus = cfg[idxPoolStatus] | |
1249 | 1239 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1250 | 1240 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1251 | 1241 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1252 | 1242 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1253 | 1243 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1254 | 1244 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1255 | 1245 | then zeroBigInt | |
1256 | 1246 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1257 | 1247 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1258 | 1248 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1259 | 1249 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1260 | 1250 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1261 | 1251 | let calcLpAmt = estPut._1 | |
1262 | 1252 | let curPriceCalc = estPut._3 | |
1263 | 1253 | let amBalance = estPut._4 | |
1264 | 1254 | let prBalance = estPut._5 | |
1265 | 1255 | let lpEmission = estPut._6 | |
1266 | 1256 | $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)) | |
1267 | 1257 | } | |
1268 | 1258 | ||
1269 | 1259 | ||
1270 | 1260 | ||
1271 | 1261 | @Callable(i) | |
1272 | 1262 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1273 | 1263 | let cfg = getPoolConfig() | |
1274 | 1264 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1275 | 1265 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1276 | 1266 | let amAssetId = fromBase58String(amAssetIdStr) | |
1277 | 1267 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1278 | 1268 | let prAssetId = fromBase58String(prAssetIdStr) | |
1279 | 1269 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1280 | 1270 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1281 | 1271 | let poolStatus = cfg[idxPoolStatus] | |
1282 | 1272 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1283 | 1273 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1284 | 1274 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1285 | 1275 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1286 | 1276 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1287 | 1277 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1288 | 1278 | then zeroBigInt | |
1289 | 1279 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1290 | 1280 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1291 | 1281 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1292 | 1282 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1293 | 1283 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1294 | 1284 | let calcLpAmt = estPut._1 | |
1295 | 1285 | let curPriceCalc = estPut._3 | |
1296 | 1286 | let amBalance = estPut._4 | |
1297 | 1287 | let prBalance = estPut._5 | |
1298 | 1288 | let lpEmission = estPut._6 | |
1299 | 1289 | $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)) | |
1300 | 1290 | } | |
1301 | 1291 | ||
1302 | 1292 | ||
1303 | 1293 | ||
1304 | 1294 | @Callable(i) | |
1305 | 1295 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1306 | 1296 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1307 | 1297 | let outAmAmt = res._1 | |
1308 | 1298 | let outPrAmt = res._2 | |
1309 | 1299 | let amBalance = res._5 | |
1310 | 1300 | let prBalance = res._6 | |
1311 | 1301 | let lpEmission = res._7 | |
1312 | 1302 | let curPrice = res._8 | |
1313 | 1303 | let poolStatus = parseIntValue(res._9) | |
1314 | 1304 | $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)) | |
1315 | 1305 | } | |
1316 | 1306 | ||
1317 | 1307 | ||
1318 | 1308 | @Verifier(tx) | |
1319 | 1309 | func verify () = { | |
1320 | 1310 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1321 | 1311 | case pk: ByteVector => | |
1322 | 1312 | pk | |
1323 | 1313 | case _: Unit => | |
1324 | 1314 | tx.senderPublicKey | |
1325 | 1315 | case _ => | |
1326 | 1316 | throw("Match error") | |
1327 | 1317 | } | |
1328 | 1318 | match tx { | |
1329 | 1319 | case order: Order => | |
1330 | 1320 | let matcherPub = getMatcherPubOrFail() | |
1331 | 1321 | let orderValid = validateMatcherOrderAllowed(order) | |
1332 | 1322 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1333 | 1323 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1334 | 1324 | if (if (if (orderValid) | |
1335 | 1325 | then senderValid | |
1336 | 1326 | else false) | |
1337 | 1327 | then matcherValid | |
1338 | 1328 | else false) | |
1339 | 1329 | then true | |
1340 | 1330 | else throwOrderError(orderValid, senderValid, matcherValid) | |
1341 | 1331 | case s: SetScriptTransaction => | |
1342 | 1332 | let newHash = blake2b256(value(s.script)) | |
1343 | 1333 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1344 | 1334 | let currentHash = scriptHash(this) | |
1345 | 1335 | if (if ((allowedHash == newHash)) | |
1346 | 1336 | then (currentHash != newHash) | |
1347 | 1337 | else false) | |
1348 | 1338 | then true | |
1349 | 1339 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1350 | 1340 | case _ => | |
1351 | 1341 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1352 | 1342 | } | |
1353 | 1343 | } | |
1354 | 1344 |
github/deemru/w8io/026f985 207.53 ms ◑