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