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