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