tx · G89ozM5oMdzQVFmVCeZfciDrGBswoSB3gpk2jssadzfi 3N3wgpZuw6MWRgf7XouSYL26EZSHCBYKgd6: -0.10000000 Waves 2020.04.02 05:43 [935946] smart account 3N3wgpZuw6MWRgf7XouSYL26EZSHCBYKgd6 > SELF 0.00000000 Waves
{ "type": 13, "id": "G89ozM5oMdzQVFmVCeZfciDrGBswoSB3gpk2jssadzfi", "fee": 10000000, "feeAssetId": null, "timestamp": 1585795438022, "version": 1, "sender": "3N3wgpZuw6MWRgf7XouSYL26EZSHCBYKgd6", "senderPublicKey": "9ZPbyU1ZXeXBHtwUPjdeVo3xNdu7TqRN7S81nrZznxs3", "proofs": [ "4rayWbcFQWZL5xmsmrBfQvqtYRAWbsqYo8jxmRAf4xkjbN9rp8GK9DEgVgQ6WYfV8EDK2nR2xraVJyLmNELVYSL5" ], "script": "base64:AAIDAAAAAAAAABIIARIDCgEIEgcKBQEBAQEBEgAAAAAZAQAAABZjb252ZXJ0V2F2ZXNUb05ldXRyaW5vAAAAAgAAAAZhbW91bnQAAAAFcHJpY2UJAABrAAAAAwkAAGsAAAADBQAAAAZhbW91bnQFAAAABXByaWNlAAAAAAAAAABkAAAAAAAAD0JAAAAAAAAF9eEAAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAgAAAAABAAAAGGdldE51bWJlckJ5QWRkcmVzc0FuZEtleQAAAAIAAAAHYWRkcmVzcwAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAAdhZGRyZXNzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAA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hMQAAAAAAAAAAAgUAAAADbmlsAAAAAFVEkfI=", "chainId": 84, "height": 935946, "spentComplexity": 0 } View: original | compacted Prev: GSixjZM77jD9t73PGiGGDBwjzCF9F7UB2yJvVsCzyTTu Next: CZxQS9EYmdhF62s7WanLMejjGT24du9nwiE4oyhP3uvT Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getNumberByKey (key) = match getInteger(this, key) { | |
5 | - | case a: Int => | |
6 | - | a | |
7 | - | case _ => | |
8 | - | 0 | |
9 | - | } | |
4 | + | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, 100), 1000000, 100000000) | |
10 | 5 | ||
11 | 6 | ||
12 | 7 | func getStringByKey (key) = match getString(this, key) { | |
17 | 12 | } | |
18 | 13 | ||
19 | 14 | ||
20 | - | func | |
21 | - | case a: | |
15 | + | func getNumberByAddressAndKey (address,key) = match getInteger(addressFromStringValue(address), key) { | |
16 | + | case a: Int => | |
22 | 17 | a | |
23 | 18 | case _ => | |
24 | - | false | |
19 | + | 0 | |
20 | + | } | |
21 | + | ||
22 | + | ||
23 | + | func getOracleProvideHeight (ownerPub,height) = match getInteger(addressFromPublicKey(ownerPub), ("price_" + toString(height))) { | |
24 | + | case a: Int => | |
25 | + | a | |
26 | + | case _ => | |
27 | + | 0 | |
28 | + | } | |
29 | + | ||
30 | + | ||
31 | + | func getNumberByKey (key) = match getInteger(this, key) { | |
32 | + | case a: Int => | |
33 | + | a | |
34 | + | case _ => | |
35 | + | 0 | |
25 | 36 | } | |
26 | 37 | ||
27 | 38 | ||
33 | 44 | } | |
34 | 45 | ||
35 | 46 | ||
36 | - | func getNumberByAddressAndKey (address,key) = match getInteger(address, key) { | |
47 | + | func dropElementInJsonArray (array,element) = { | |
48 | + | let splitedArray = split(array, element) | |
49 | + | if ((take(splitedArray[1], 1) == ",")) | |
50 | + | then (splitedArray[0] + drop(splitedArray[1], 1)) | |
51 | + | else (dropRight(splitedArray[0], 1) + splitedArray[1]) | |
52 | + | } | |
53 | + | ||
54 | + | ||
55 | + | func convertJsonArrayToList (jsonArray) = split(jsonArray, ",") | |
56 | + | ||
57 | + | ||
58 | + | let price = match getInteger(this, "price") { | |
37 | 59 | case a: Int => | |
38 | 60 | a | |
39 | 61 | case _ => | |
40 | 62 | 0 | |
41 | 63 | } | |
42 | 64 | ||
65 | + | let priceIndex = match getInteger(this, "price_index") { | |
66 | + | case a: Int => | |
67 | + | a | |
68 | + | case _ => | |
69 | + | 0 | |
70 | + | } | |
43 | 71 | ||
44 | - | let WAVELET = 100000000 | |
72 | + | let isBlocked = match getBoolean(this, "is_blocked") { | |
73 | + | case a: Boolean => | |
74 | + | a | |
75 | + | case _ => | |
76 | + | false | |
77 | + | } | |
45 | 78 | ||
46 | - | let | |
79 | + | let percentPriceOffset = 7 | |
47 | 80 | ||
48 | - | let | |
81 | + | let pubKeyOracles = getStringByKey("oracles") | |
49 | 82 | ||
50 | - | let | |
83 | + | let pubKeyOraclesList = convertJsonArrayToList(pubKeyOracles) | |
51 | 84 | ||
52 | - | let | |
85 | + | let bftCoefficientOracle = 4 | |
53 | 86 | ||
54 | - | let | |
87 | + | let neutrinoAddress = addressFromPublicKey(fromBase58String("J4hU7VqLs2JAJXwFnjicQ97XShyZEqt8REC8fJHkTdKd")) | |
55 | 88 | ||
56 | - | let | |
89 | + | let liquidationAddress = addressFromPublicKey(fromBase58String("HDqeggkNi96GMzyGv4AQMQms43nwSrvgMjTDznyivt8R")) | |
57 | 90 | ||
58 | - | let | |
91 | + | let neutrinoAsset = fromBase58String("EyizrdEpB9yuh45Zv3f2UfxKLjcecrmvcq5DSP9fEwum") | |
59 | 92 | ||
60 | - | let NeutrinoContractKey = "neutrino_contract" | |
93 | + | let neutrinoLockedBalance = match getInteger(neutrinoAddress, "balance_lock_neutrino") { | |
94 | + | case a: Int => | |
95 | + | a | |
96 | + | case _ => | |
97 | + | 0 | |
98 | + | } | |
61 | 99 | ||
62 | - | let PriceKey = "price" | |
100 | + | let wavesLockedBalance = match getInteger(neutrinoAddress, "balance_lock_waves") { | |
101 | + | case a: Int => | |
102 | + | a | |
103 | + | case _ => | |
104 | + | 0 | |
105 | + | } | |
63 | 106 | ||
64 | - | let | |
107 | + | let reserve = (wavesBalance(neutrinoAddress) - wavesLockedBalance) | |
65 | 108 | ||
66 | - | let | |
109 | + | let neutrinoSupply = (((neutrinoLockedBalance + extract(assetInfo(neutrinoAsset)).quantity) - assetBalance(neutrinoAddress, neutrinoAsset)) - assetBalance(liquidationAddress, neutrinoAsset)) | |
67 | 110 | ||
68 | - | let | |
111 | + | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve, price)) | |
69 | 112 | ||
70 | - | let BalanceLockedkKey = "balance_lock_" | |
71 | - | ||
72 | - | let WavesLockedBalanceKey = (BalanceLockedkKey + "waves") | |
73 | - | ||
74 | - | let NeutrinoLockedBalanceKey = (BalanceLockedkKey + "neutrino") | |
75 | - | ||
76 | - | let LiquidationContractKey = "liquidation_contract" | |
77 | - | ||
78 | - | let FirstOrderKey = "order_first" | |
79 | - | ||
80 | - | func getRoiByOrderIdKey (orderId) = ("debug_order_roi_" + orderId) | |
113 | + | func findPricesInRange (prices) = { | |
114 | + | let minPercentBound = 90 | |
115 | + | let maxPercentBound = 110 | |
116 | + | let p0 = prices[0] | |
117 | + | let check0 = if ((0 >= prices[0])) | |
118 | + | then [0] | |
119 | + | else { | |
120 | + | let p01 = ((prices[1] * 100) / p0) | |
121 | + | let p02 = ((prices[2] * 100) / p0) | |
122 | + | let p03 = ((prices[3] * 100) / p0) | |
123 | + | let p04 = ((prices[4] * 100) / p0) | |
124 | + | let array1 = if (if ((maxPercentBound > p01)) | |
125 | + | then (p01 > minPercentBound) | |
126 | + | else false) | |
127 | + | then [1, 0] | |
128 | + | else [0] | |
129 | + | let array2 = if (if ((maxPercentBound > p02)) | |
130 | + | then (p02 > minPercentBound) | |
131 | + | else false) | |
132 | + | then 2 :: array1 | |
133 | + | else array1 | |
134 | + | let array3 = if (if ((maxPercentBound > p03)) | |
135 | + | then (p03 > minPercentBound) | |
136 | + | else false) | |
137 | + | then 3 :: array2 | |
138 | + | else array2 | |
139 | + | if (if ((maxPercentBound > p04)) | |
140 | + | then (p04 > minPercentBound) | |
141 | + | else false) | |
142 | + | then 4 :: array3 | |
143 | + | else array3 | |
144 | + | } | |
145 | + | let check1 = if ((size(check0) >= 3)) | |
146 | + | then check0 | |
147 | + | else { | |
148 | + | let p1 = prices[1] | |
149 | + | if ((0 >= p1)) | |
150 | + | then [1] | |
151 | + | else { | |
152 | + | let p10 = ((prices[0] * 100) / p1) | |
153 | + | let p12 = ((prices[2] * 100) / p1) | |
154 | + | let p13 = ((prices[3] * 100) / p1) | |
155 | + | let p14 = ((prices[4] * 100) / p1) | |
156 | + | let array1 = if (if ((maxPercentBound > p10)) | |
157 | + | then (p10 > minPercentBound) | |
158 | + | else false) | |
159 | + | then [0, 1] | |
160 | + | else [1] | |
161 | + | let array2 = if (if ((maxPercentBound > p12)) | |
162 | + | then (p12 > minPercentBound) | |
163 | + | else false) | |
164 | + | then 2 :: array1 | |
165 | + | else array1 | |
166 | + | let array3 = if (if ((maxPercentBound > p13)) | |
167 | + | then (p13 > minPercentBound) | |
168 | + | else false) | |
169 | + | then 3 :: array2 | |
170 | + | else array2 | |
171 | + | if (if ((maxPercentBound > p14)) | |
172 | + | then (p14 > minPercentBound) | |
173 | + | else false) | |
174 | + | then 4 :: array3 | |
175 | + | else array3 | |
176 | + | } | |
177 | + | } | |
178 | + | let check2 = if ((size(check1) >= 3)) | |
179 | + | then check1 | |
180 | + | else { | |
181 | + | let p2 = prices[2] | |
182 | + | if ((0 >= p2)) | |
183 | + | then [2] | |
184 | + | else { | |
185 | + | let p20 = ((prices[0] * 100) / p2) | |
186 | + | let p21 = ((prices[1] * 100) / p2) | |
187 | + | let p23 = ((prices[3] * 100) / p2) | |
188 | + | let p24 = ((prices[4] * 100) / p2) | |
189 | + | let array1 = if (if ((maxPercentBound > p20)) | |
190 | + | then (p20 > minPercentBound) | |
191 | + | else false) | |
192 | + | then [0, 2] | |
193 | + | else [2] | |
194 | + | let array2 = if (if ((maxPercentBound > p21)) | |
195 | + | then (p21 > minPercentBound) | |
196 | + | else false) | |
197 | + | then 1 :: array1 | |
198 | + | else array1 | |
199 | + | let array3 = if (if ((maxPercentBound > p23)) | |
200 | + | then (p23 > minPercentBound) | |
201 | + | else false) | |
202 | + | then 3 :: array2 | |
203 | + | else array2 | |
204 | + | if (if ((maxPercentBound > p24)) | |
205 | + | then (p24 > minPercentBound) | |
206 | + | else false) | |
207 | + | then 4 :: array3 | |
208 | + | else array3 | |
209 | + | } | |
210 | + | } | |
211 | + | let check3 = if ((size(check2) >= 3)) | |
212 | + | then check2 | |
213 | + | else { | |
214 | + | let p3 = prices[3] | |
215 | + | if ((0 >= p3)) | |
216 | + | then [3] | |
217 | + | else { | |
218 | + | let p30 = ((prices[0] * 100) / p3) | |
219 | + | let p31 = ((prices[1] * 100) / p3) | |
220 | + | let p32 = ((prices[2] * 100) / p3) | |
221 | + | let p34 = ((prices[4] * 100) / p3) | |
222 | + | let array1 = if (if ((maxPercentBound > p30)) | |
223 | + | then (p30 > minPercentBound) | |
224 | + | else false) | |
225 | + | then [0, 3] | |
226 | + | else [3] | |
227 | + | let array2 = if (if ((maxPercentBound > p31)) | |
228 | + | then (p31 > minPercentBound) | |
229 | + | else false) | |
230 | + | then 1 :: array1 | |
231 | + | else array1 | |
232 | + | let array3 = if (if ((maxPercentBound > p32)) | |
233 | + | then (p32 > minPercentBound) | |
234 | + | else false) | |
235 | + | then 2 :: array2 | |
236 | + | else array2 | |
237 | + | if (if ((maxPercentBound > p34)) | |
238 | + | then (p34 > minPercentBound) | |
239 | + | else false) | |
240 | + | then 4 :: array3 | |
241 | + | else array3 | |
242 | + | } | |
243 | + | } | |
244 | + | if ((size(check3) >= 3)) | |
245 | + | then check3 | |
246 | + | else { | |
247 | + | let p4 = prices[4] | |
248 | + | if ((0 >= p4)) | |
249 | + | then [4] | |
250 | + | else { | |
251 | + | let p40 = ((prices[0] * 100) / p4) | |
252 | + | let p41 = ((prices[1] * 100) / p4) | |
253 | + | let p42 = ((prices[2] * 100) / p4) | |
254 | + | let p43 = ((prices[3] * 100) / p4) | |
255 | + | let array1 = if (if ((maxPercentBound > p40)) | |
256 | + | then (p40 > minPercentBound) | |
257 | + | else false) | |
258 | + | then [0, 4] | |
259 | + | else [4] | |
260 | + | let array2 = if (if ((maxPercentBound > p41)) | |
261 | + | then (p41 > minPercentBound) | |
262 | + | else false) | |
263 | + | then 1 :: array1 | |
264 | + | else array1 | |
265 | + | let array3 = if (if ((maxPercentBound > p42)) | |
266 | + | then (p42 > minPercentBound) | |
267 | + | else false) | |
268 | + | then 2 :: array2 | |
269 | + | else array2 | |
270 | + | if (if ((maxPercentBound > p43)) | |
271 | + | then (p43 > minPercentBound) | |
272 | + | else false) | |
273 | + | then 3 :: array3 | |
274 | + | else array3 | |
275 | + | } | |
276 | + | } | |
277 | + | } | |
81 | 278 | ||
82 | 279 | ||
83 | - | func getOrderPriceKey (orderId) = ("order_price_" + orderId) | |
84 | - | ||
85 | - | ||
86 | - | func getOrderTotalKey (orderId) = ("order_total_" + orderId) | |
87 | - | ||
88 | - | ||
89 | - | func getOrderOwnerKey (orderId) = ("order_owner_" + orderId) | |
90 | - | ||
91 | - | ||
92 | - | func getOrderHeightKey (orderId) = ("order_height_" + orderId) | |
93 | - | ||
94 | - | ||
95 | - | func getOrderStatusKey (orderId) = ("order_status_" + orderId) | |
96 | - | ||
97 | - | ||
98 | - | func getOrderFilledTotalKey (orderId) = ("order_filled_total_" + orderId) | |
99 | - | ||
100 | - | ||
101 | - | func getPrevOrderKey (orderId) = ("order_prev_" + orderId) | |
102 | - | ||
103 | - | ||
104 | - | func getNextOrderKey (orderId) = ("order_next_" + orderId) | |
105 | - | ||
106 | - | ||
107 | - | func convertNeutrinoToWaves (amount,price) = fraction(fraction(amount, 100, price), WAVELET, PAULI) | |
108 | - | ||
109 | - | ||
110 | - | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, 100), PAULI, WAVELET) | |
111 | - | ||
112 | - | ||
113 | - | func convertWavesToBond (amount,price) = convertWavesToNeutrino(amount, price) | |
114 | - | ||
115 | - | ||
116 | - | func convertBondToWaves (amount,price) = convertNeutrinoToWaves(amount, price) | |
117 | - | ||
118 | - | ||
119 | - | let neutrinoContract = addressFromStringValue("3PC9BfRwJWWiw9AREE2B3eWzCks3CYtg4yo") | |
120 | - | ||
121 | - | let controlContract = addressFromStringValue("3P5Bfd58PPfNvBM2Hy8QfbcDqMeNtzg7KfP") | |
122 | - | ||
123 | - | let liquidationContract = addressFromStringValue("3P4PCxsJqMzQBALo8zANHtBDZRRquobHQp7") | |
124 | - | ||
125 | - | let neutrinoAssetId = fromBase58String("DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p") | |
126 | - | ||
127 | - | let bondAssetId = fromBase58String("6nSpVyNH7yM69eg446wrQR94ipbbcmZMU1ENPwanC97g") | |
128 | - | ||
129 | - | let isBlocked = getBoolByAddressAndKey(controlContract, "is_blocked") | |
130 | - | ||
131 | - | let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey) | |
132 | - | ||
133 | - | let neutrinoLockedBalance = getNumberByAddressAndKey(neutrinoContract, NeutrinoLockedBalanceKey) | |
134 | - | ||
135 | - | let reserve = (wavesBalance(neutrinoContract) - getNumberByAddressAndKey(neutrinoContract, WavesLockedBalanceKey)) | |
136 | - | ||
137 | - | let neutrinoSupply = (((neutrinoLockedBalance + extract(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(liquidationContract, neutrinoAssetId)) | |
138 | - | ||
139 | - | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve, currentPrice)) | |
140 | - | ||
141 | - | let firstOrder = getStringByKey(FirstOrderKey) | |
142 | - | ||
143 | - | func getOrderPrice (id) = getNumberByKey(getOrderPriceKey(id)) | |
144 | - | ||
145 | - | ||
146 | - | func getOrderTotal (id) = getNumberByKey(getOrderTotalKey(id)) | |
147 | - | ||
148 | - | ||
149 | - | func getOrderOwner (id) = getStringByKey(getOrderOwnerKey(id)) | |
150 | - | ||
151 | - | ||
152 | - | func getOrderStatus (id) = getStringByKey(getOrderStatusKey(id)) | |
153 | - | ||
154 | - | ||
155 | - | func getOrderFilledTotal (id) = getNumberByKey(getOrderFilledTotalKey(id)) | |
156 | - | ||
157 | - | ||
158 | - | func getPrevOrder (id) = getStringByKey(getPrevOrderKey(id)) | |
159 | - | ||
160 | - | ||
161 | - | func getNextOrder (id) = getStringByKey(getNextOrderKey(id)) | |
280 | + | func formattingPriceMsg (price,height) = toBytes((((("WAVESNEUTRINOPREFIX" + "_") + toString(height)) + "_") + toString(price))) | |
162 | 281 | ||
163 | 282 | ||
164 | 283 | @Callable(i) | |
165 | - | func sellBond (arg) = { | |
166 | - | let bondBalance = assetBalance(this, bondAssetId) | |
167 | - | let deficitPositive = if ((0 >= deficit)) | |
168 | - | then 0 | |
169 | - | else deficit | |
170 | - | let bondAmount = if ((deficitPositive >= bondBalance)) | |
171 | - | then bondBalance | |
172 | - | else deficitPositive | |
173 | - | let returnAmount = if ((deficitPositive >= bondBalance)) | |
174 | - | then 0 | |
175 | - | else (bondBalance - deficitPositive) | |
176 | - | WriteSet([DataEntry(FirstOrderKey, arg), DataEntry(getOrderStatusKey(firstOrder), (arg + "zzz"))]) | |
284 | + | func callEmergencyShutdown (reason) = { | |
285 | + | let AutoEmergencyOracleAddress = "3Mwho43kPZa9w1y91NJsAoYxgQpsg3JjGby" | |
286 | + | let callerAddress = toString(i.caller) | |
287 | + | if ((AutoEmergencyOracleAddress != callerAddress)) | |
288 | + | then throw("caller must be one an emergency oracle") | |
289 | + | else WriteSet([DataEntry("is_blocked", true), DataEntry("is_blocked_caller", callerAddress), DataEntry("is_blocked_reason", reason)]) | |
177 | 290 | } | |
291 | + | ||
292 | + | ||
293 | + | ||
294 | + | @Callable(i) | |
295 | + | func finalizeCurrentPrice (price1,price2,price3,price4,price5) = if (isBlocked) | |
296 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
297 | + | else if (( match getInteger(this, ("price_" + toString(height))) { | |
298 | + | case a: Int => | |
299 | + | a | |
300 | + | case _ => | |
301 | + | 0 | |
302 | + | } != 0)) | |
303 | + | then throw("wait next block") | |
304 | + | else { | |
305 | + | let prices = [if ((price1 > 0)) | |
306 | + | then price1 | |
307 | + | else 0, if ((price2 > 0)) | |
308 | + | then price2 | |
309 | + | else 0, if ((price3 > 0)) | |
310 | + | then price3 | |
311 | + | else 0, if ((price4 > 0)) | |
312 | + | then price4 | |
313 | + | else 0, if ((price5 > 0)) | |
314 | + | then price5 | |
315 | + | else 0] | |
316 | + | if (((1 + 1) > 3)) | |
317 | + | then throw("running here!") | |
318 | + | else { | |
319 | + | let pricesInRange = findPricesInRange(prices) | |
320 | + | let priceProvidingCount = size(pricesInRange) | |
321 | + | if ((3 > priceProvidingCount)) | |
322 | + | then throw(((((((((((((((((((((("Could not finalize price because of big variation: height=" + toString(height)) + " | |
323 | + | ") + pubKeyOraclesList[0]) + "=") + toString(prices[0])) + " | |
324 | + | ") + pubKeyOraclesList[1]) + "=") + toString(prices[1])) + " | |
325 | + | ") + pubKeyOraclesList[2]) + "=") + toString(prices[2])) + " | |
326 | + | ") + pubKeyOraclesList[3]) + "=") + toString(prices[3])) + " | |
327 | + | ") + pubKeyOraclesList[4]) + "=") + toString(prices[4]))) | |
328 | + | else { | |
329 | + | let sum1 = ((prices[pricesInRange[0]] + prices[pricesInRange[1]]) + prices[pricesInRange[2]]) | |
330 | + | let sum2 = if ((priceProvidingCount >= 4)) | |
331 | + | then (sum1 + prices[pricesInRange[3]]) | |
332 | + | else sum1 | |
333 | + | let priceSum = if ((priceProvidingCount >= 5)) | |
334 | + | then (sum2 + prices[pricesInRange[4]]) | |
335 | + | else sum2 | |
336 | + | if ((priceProvidingCount >= 6)) | |
337 | + | then throw("Invalid pricesInRange creation") | |
338 | + | else { | |
339 | + | let newPrice = (priceSum / priceProvidingCount) | |
340 | + | if (if ((newPrice >= (price + ((price * percentPriceOffset) / 100)))) | |
341 | + | then true | |
342 | + | else ((price - ((price * percentPriceOffset) / 100)) >= newPrice)) | |
343 | + | then WriteSet([DataEntry("is_blocked", true), DataEntry((("black_swarm_price" + "_") + toString(height)), newPrice)]) | |
344 | + | else { | |
345 | + | let newPriceIndex = (priceIndex + 1) | |
346 | + | WriteSet([DataEntry("price", newPrice), DataEntry(("price_" + toString(height)), newPrice), DataEntry("price_index", newPriceIndex), DataEntry(("price_index_" + toString(newPriceIndex)), height), DataEntry(("deficit_" + toString(height)), deficit), DataEntry(("neutrinoSupply_" + toString(height)), neutrinoSupply), DataEntry(("deficit_percent_" + toString(height)), if ((neutrinoSupply != 0)) | |
347 | + | then ((deficit * 100) / neutrinoSupply) | |
348 | + | else 0)]) | |
349 | + | } | |
350 | + | } | |
351 | + | } | |
352 | + | } | |
353 | + | } | |
354 | + | ||
355 | + | ||
356 | + | ||
357 | + | @Callable(i) | |
358 | + | func finalizeCurrentPrice1 () = if ((1 > 4)) | |
359 | + | then throw("") | |
360 | + | else { | |
361 | + | let newPriceIndex = (priceIndex + 1) | |
362 | + | WriteSet([DataEntry("data1", 100), DataEntry("price_", (getNumberByKey("data1") * 2))]) | |
363 | + | } | |
178 | 364 | ||
179 | 365 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getNumberByKey (key) = match getInteger(this, key) { | |
5 | - | case a: Int => | |
6 | - | a | |
7 | - | case _ => | |
8 | - | 0 | |
9 | - | } | |
4 | + | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, 100), 1000000, 100000000) | |
10 | 5 | ||
11 | 6 | ||
12 | 7 | func getStringByKey (key) = match getString(this, key) { | |
13 | 8 | case a: String => | |
14 | 9 | a | |
15 | 10 | case _ => | |
16 | 11 | "" | |
17 | 12 | } | |
18 | 13 | ||
19 | 14 | ||
20 | - | func | |
21 | - | case a: | |
15 | + | func getNumberByAddressAndKey (address,key) = match getInteger(addressFromStringValue(address), key) { | |
16 | + | case a: Int => | |
22 | 17 | a | |
23 | 18 | case _ => | |
24 | - | false | |
19 | + | 0 | |
20 | + | } | |
21 | + | ||
22 | + | ||
23 | + | func getOracleProvideHeight (ownerPub,height) = match getInteger(addressFromPublicKey(ownerPub), ("price_" + toString(height))) { | |
24 | + | case a: Int => | |
25 | + | a | |
26 | + | case _ => | |
27 | + | 0 | |
28 | + | } | |
29 | + | ||
30 | + | ||
31 | + | func getNumberByKey (key) = match getInteger(this, key) { | |
32 | + | case a: Int => | |
33 | + | a | |
34 | + | case _ => | |
35 | + | 0 | |
25 | 36 | } | |
26 | 37 | ||
27 | 38 | ||
28 | 39 | func getStringByAddressAndKey (address,key) = match getString(address, key) { | |
29 | 40 | case a: String => | |
30 | 41 | a | |
31 | 42 | case _ => | |
32 | 43 | "" | |
33 | 44 | } | |
34 | 45 | ||
35 | 46 | ||
36 | - | func getNumberByAddressAndKey (address,key) = match getInteger(address, key) { | |
47 | + | func dropElementInJsonArray (array,element) = { | |
48 | + | let splitedArray = split(array, element) | |
49 | + | if ((take(splitedArray[1], 1) == ",")) | |
50 | + | then (splitedArray[0] + drop(splitedArray[1], 1)) | |
51 | + | else (dropRight(splitedArray[0], 1) + splitedArray[1]) | |
52 | + | } | |
53 | + | ||
54 | + | ||
55 | + | func convertJsonArrayToList (jsonArray) = split(jsonArray, ",") | |
56 | + | ||
57 | + | ||
58 | + | let price = match getInteger(this, "price") { | |
37 | 59 | case a: Int => | |
38 | 60 | a | |
39 | 61 | case _ => | |
40 | 62 | 0 | |
41 | 63 | } | |
42 | 64 | ||
65 | + | let priceIndex = match getInteger(this, "price_index") { | |
66 | + | case a: Int => | |
67 | + | a | |
68 | + | case _ => | |
69 | + | 0 | |
70 | + | } | |
43 | 71 | ||
44 | - | let WAVELET = 100000000 | |
72 | + | let isBlocked = match getBoolean(this, "is_blocked") { | |
73 | + | case a: Boolean => | |
74 | + | a | |
75 | + | case _ => | |
76 | + | false | |
77 | + | } | |
45 | 78 | ||
46 | - | let | |
79 | + | let percentPriceOffset = 7 | |
47 | 80 | ||
48 | - | let | |
81 | + | let pubKeyOracles = getStringByKey("oracles") | |
49 | 82 | ||
50 | - | let | |
83 | + | let pubKeyOraclesList = convertJsonArrayToList(pubKeyOracles) | |
51 | 84 | ||
52 | - | let | |
85 | + | let bftCoefficientOracle = 4 | |
53 | 86 | ||
54 | - | let | |
87 | + | let neutrinoAddress = addressFromPublicKey(fromBase58String("J4hU7VqLs2JAJXwFnjicQ97XShyZEqt8REC8fJHkTdKd")) | |
55 | 88 | ||
56 | - | let | |
89 | + | let liquidationAddress = addressFromPublicKey(fromBase58String("HDqeggkNi96GMzyGv4AQMQms43nwSrvgMjTDznyivt8R")) | |
57 | 90 | ||
58 | - | let | |
91 | + | let neutrinoAsset = fromBase58String("EyizrdEpB9yuh45Zv3f2UfxKLjcecrmvcq5DSP9fEwum") | |
59 | 92 | ||
60 | - | let NeutrinoContractKey = "neutrino_contract" | |
93 | + | let neutrinoLockedBalance = match getInteger(neutrinoAddress, "balance_lock_neutrino") { | |
94 | + | case a: Int => | |
95 | + | a | |
96 | + | case _ => | |
97 | + | 0 | |
98 | + | } | |
61 | 99 | ||
62 | - | let PriceKey = "price" | |
100 | + | let wavesLockedBalance = match getInteger(neutrinoAddress, "balance_lock_waves") { | |
101 | + | case a: Int => | |
102 | + | a | |
103 | + | case _ => | |
104 | + | 0 | |
105 | + | } | |
63 | 106 | ||
64 | - | let | |
107 | + | let reserve = (wavesBalance(neutrinoAddress) - wavesLockedBalance) | |
65 | 108 | ||
66 | - | let | |
109 | + | let neutrinoSupply = (((neutrinoLockedBalance + extract(assetInfo(neutrinoAsset)).quantity) - assetBalance(neutrinoAddress, neutrinoAsset)) - assetBalance(liquidationAddress, neutrinoAsset)) | |
67 | 110 | ||
68 | - | let | |
111 | + | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve, price)) | |
69 | 112 | ||
70 | - | let BalanceLockedkKey = "balance_lock_" | |
71 | - | ||
72 | - | let WavesLockedBalanceKey = (BalanceLockedkKey + "waves") | |
73 | - | ||
74 | - | let NeutrinoLockedBalanceKey = (BalanceLockedkKey + "neutrino") | |
75 | - | ||
76 | - | let LiquidationContractKey = "liquidation_contract" | |
77 | - | ||
78 | - | let FirstOrderKey = "order_first" | |
79 | - | ||
80 | - | func getRoiByOrderIdKey (orderId) = ("debug_order_roi_" + orderId) | |
113 | + | func findPricesInRange (prices) = { | |
114 | + | let minPercentBound = 90 | |
115 | + | let maxPercentBound = 110 | |
116 | + | let p0 = prices[0] | |
117 | + | let check0 = if ((0 >= prices[0])) | |
118 | + | then [0] | |
119 | + | else { | |
120 | + | let p01 = ((prices[1] * 100) / p0) | |
121 | + | let p02 = ((prices[2] * 100) / p0) | |
122 | + | let p03 = ((prices[3] * 100) / p0) | |
123 | + | let p04 = ((prices[4] * 100) / p0) | |
124 | + | let array1 = if (if ((maxPercentBound > p01)) | |
125 | + | then (p01 > minPercentBound) | |
126 | + | else false) | |
127 | + | then [1, 0] | |
128 | + | else [0] | |
129 | + | let array2 = if (if ((maxPercentBound > p02)) | |
130 | + | then (p02 > minPercentBound) | |
131 | + | else false) | |
132 | + | then 2 :: array1 | |
133 | + | else array1 | |
134 | + | let array3 = if (if ((maxPercentBound > p03)) | |
135 | + | then (p03 > minPercentBound) | |
136 | + | else false) | |
137 | + | then 3 :: array2 | |
138 | + | else array2 | |
139 | + | if (if ((maxPercentBound > p04)) | |
140 | + | then (p04 > minPercentBound) | |
141 | + | else false) | |
142 | + | then 4 :: array3 | |
143 | + | else array3 | |
144 | + | } | |
145 | + | let check1 = if ((size(check0) >= 3)) | |
146 | + | then check0 | |
147 | + | else { | |
148 | + | let p1 = prices[1] | |
149 | + | if ((0 >= p1)) | |
150 | + | then [1] | |
151 | + | else { | |
152 | + | let p10 = ((prices[0] * 100) / p1) | |
153 | + | let p12 = ((prices[2] * 100) / p1) | |
154 | + | let p13 = ((prices[3] * 100) / p1) | |
155 | + | let p14 = ((prices[4] * 100) / p1) | |
156 | + | let array1 = if (if ((maxPercentBound > p10)) | |
157 | + | then (p10 > minPercentBound) | |
158 | + | else false) | |
159 | + | then [0, 1] | |
160 | + | else [1] | |
161 | + | let array2 = if (if ((maxPercentBound > p12)) | |
162 | + | then (p12 > minPercentBound) | |
163 | + | else false) | |
164 | + | then 2 :: array1 | |
165 | + | else array1 | |
166 | + | let array3 = if (if ((maxPercentBound > p13)) | |
167 | + | then (p13 > minPercentBound) | |
168 | + | else false) | |
169 | + | then 3 :: array2 | |
170 | + | else array2 | |
171 | + | if (if ((maxPercentBound > p14)) | |
172 | + | then (p14 > minPercentBound) | |
173 | + | else false) | |
174 | + | then 4 :: array3 | |
175 | + | else array3 | |
176 | + | } | |
177 | + | } | |
178 | + | let check2 = if ((size(check1) >= 3)) | |
179 | + | then check1 | |
180 | + | else { | |
181 | + | let p2 = prices[2] | |
182 | + | if ((0 >= p2)) | |
183 | + | then [2] | |
184 | + | else { | |
185 | + | let p20 = ((prices[0] * 100) / p2) | |
186 | + | let p21 = ((prices[1] * 100) / p2) | |
187 | + | let p23 = ((prices[3] * 100) / p2) | |
188 | + | let p24 = ((prices[4] * 100) / p2) | |
189 | + | let array1 = if (if ((maxPercentBound > p20)) | |
190 | + | then (p20 > minPercentBound) | |
191 | + | else false) | |
192 | + | then [0, 2] | |
193 | + | else [2] | |
194 | + | let array2 = if (if ((maxPercentBound > p21)) | |
195 | + | then (p21 > minPercentBound) | |
196 | + | else false) | |
197 | + | then 1 :: array1 | |
198 | + | else array1 | |
199 | + | let array3 = if (if ((maxPercentBound > p23)) | |
200 | + | then (p23 > minPercentBound) | |
201 | + | else false) | |
202 | + | then 3 :: array2 | |
203 | + | else array2 | |
204 | + | if (if ((maxPercentBound > p24)) | |
205 | + | then (p24 > minPercentBound) | |
206 | + | else false) | |
207 | + | then 4 :: array3 | |
208 | + | else array3 | |
209 | + | } | |
210 | + | } | |
211 | + | let check3 = if ((size(check2) >= 3)) | |
212 | + | then check2 | |
213 | + | else { | |
214 | + | let p3 = prices[3] | |
215 | + | if ((0 >= p3)) | |
216 | + | then [3] | |
217 | + | else { | |
218 | + | let p30 = ((prices[0] * 100) / p3) | |
219 | + | let p31 = ((prices[1] * 100) / p3) | |
220 | + | let p32 = ((prices[2] * 100) / p3) | |
221 | + | let p34 = ((prices[4] * 100) / p3) | |
222 | + | let array1 = if (if ((maxPercentBound > p30)) | |
223 | + | then (p30 > minPercentBound) | |
224 | + | else false) | |
225 | + | then [0, 3] | |
226 | + | else [3] | |
227 | + | let array2 = if (if ((maxPercentBound > p31)) | |
228 | + | then (p31 > minPercentBound) | |
229 | + | else false) | |
230 | + | then 1 :: array1 | |
231 | + | else array1 | |
232 | + | let array3 = if (if ((maxPercentBound > p32)) | |
233 | + | then (p32 > minPercentBound) | |
234 | + | else false) | |
235 | + | then 2 :: array2 | |
236 | + | else array2 | |
237 | + | if (if ((maxPercentBound > p34)) | |
238 | + | then (p34 > minPercentBound) | |
239 | + | else false) | |
240 | + | then 4 :: array3 | |
241 | + | else array3 | |
242 | + | } | |
243 | + | } | |
244 | + | if ((size(check3) >= 3)) | |
245 | + | then check3 | |
246 | + | else { | |
247 | + | let p4 = prices[4] | |
248 | + | if ((0 >= p4)) | |
249 | + | then [4] | |
250 | + | else { | |
251 | + | let p40 = ((prices[0] * 100) / p4) | |
252 | + | let p41 = ((prices[1] * 100) / p4) | |
253 | + | let p42 = ((prices[2] * 100) / p4) | |
254 | + | let p43 = ((prices[3] * 100) / p4) | |
255 | + | let array1 = if (if ((maxPercentBound > p40)) | |
256 | + | then (p40 > minPercentBound) | |
257 | + | else false) | |
258 | + | then [0, 4] | |
259 | + | else [4] | |
260 | + | let array2 = if (if ((maxPercentBound > p41)) | |
261 | + | then (p41 > minPercentBound) | |
262 | + | else false) | |
263 | + | then 1 :: array1 | |
264 | + | else array1 | |
265 | + | let array3 = if (if ((maxPercentBound > p42)) | |
266 | + | then (p42 > minPercentBound) | |
267 | + | else false) | |
268 | + | then 2 :: array2 | |
269 | + | else array2 | |
270 | + | if (if ((maxPercentBound > p43)) | |
271 | + | then (p43 > minPercentBound) | |
272 | + | else false) | |
273 | + | then 3 :: array3 | |
274 | + | else array3 | |
275 | + | } | |
276 | + | } | |
277 | + | } | |
81 | 278 | ||
82 | 279 | ||
83 | - | func getOrderPriceKey (orderId) = ("order_price_" + orderId) | |
84 | - | ||
85 | - | ||
86 | - | func getOrderTotalKey (orderId) = ("order_total_" + orderId) | |
87 | - | ||
88 | - | ||
89 | - | func getOrderOwnerKey (orderId) = ("order_owner_" + orderId) | |
90 | - | ||
91 | - | ||
92 | - | func getOrderHeightKey (orderId) = ("order_height_" + orderId) | |
93 | - | ||
94 | - | ||
95 | - | func getOrderStatusKey (orderId) = ("order_status_" + orderId) | |
96 | - | ||
97 | - | ||
98 | - | func getOrderFilledTotalKey (orderId) = ("order_filled_total_" + orderId) | |
99 | - | ||
100 | - | ||
101 | - | func getPrevOrderKey (orderId) = ("order_prev_" + orderId) | |
102 | - | ||
103 | - | ||
104 | - | func getNextOrderKey (orderId) = ("order_next_" + orderId) | |
105 | - | ||
106 | - | ||
107 | - | func convertNeutrinoToWaves (amount,price) = fraction(fraction(amount, 100, price), WAVELET, PAULI) | |
108 | - | ||
109 | - | ||
110 | - | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, 100), PAULI, WAVELET) | |
111 | - | ||
112 | - | ||
113 | - | func convertWavesToBond (amount,price) = convertWavesToNeutrino(amount, price) | |
114 | - | ||
115 | - | ||
116 | - | func convertBondToWaves (amount,price) = convertNeutrinoToWaves(amount, price) | |
117 | - | ||
118 | - | ||
119 | - | let neutrinoContract = addressFromStringValue("3PC9BfRwJWWiw9AREE2B3eWzCks3CYtg4yo") | |
120 | - | ||
121 | - | let controlContract = addressFromStringValue("3P5Bfd58PPfNvBM2Hy8QfbcDqMeNtzg7KfP") | |
122 | - | ||
123 | - | let liquidationContract = addressFromStringValue("3P4PCxsJqMzQBALo8zANHtBDZRRquobHQp7") | |
124 | - | ||
125 | - | let neutrinoAssetId = fromBase58String("DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p") | |
126 | - | ||
127 | - | let bondAssetId = fromBase58String("6nSpVyNH7yM69eg446wrQR94ipbbcmZMU1ENPwanC97g") | |
128 | - | ||
129 | - | let isBlocked = getBoolByAddressAndKey(controlContract, "is_blocked") | |
130 | - | ||
131 | - | let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey) | |
132 | - | ||
133 | - | let neutrinoLockedBalance = getNumberByAddressAndKey(neutrinoContract, NeutrinoLockedBalanceKey) | |
134 | - | ||
135 | - | let reserve = (wavesBalance(neutrinoContract) - getNumberByAddressAndKey(neutrinoContract, WavesLockedBalanceKey)) | |
136 | - | ||
137 | - | let neutrinoSupply = (((neutrinoLockedBalance + extract(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(liquidationContract, neutrinoAssetId)) | |
138 | - | ||
139 | - | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve, currentPrice)) | |
140 | - | ||
141 | - | let firstOrder = getStringByKey(FirstOrderKey) | |
142 | - | ||
143 | - | func getOrderPrice (id) = getNumberByKey(getOrderPriceKey(id)) | |
144 | - | ||
145 | - | ||
146 | - | func getOrderTotal (id) = getNumberByKey(getOrderTotalKey(id)) | |
147 | - | ||
148 | - | ||
149 | - | func getOrderOwner (id) = getStringByKey(getOrderOwnerKey(id)) | |
150 | - | ||
151 | - | ||
152 | - | func getOrderStatus (id) = getStringByKey(getOrderStatusKey(id)) | |
153 | - | ||
154 | - | ||
155 | - | func getOrderFilledTotal (id) = getNumberByKey(getOrderFilledTotalKey(id)) | |
156 | - | ||
157 | - | ||
158 | - | func getPrevOrder (id) = getStringByKey(getPrevOrderKey(id)) | |
159 | - | ||
160 | - | ||
161 | - | func getNextOrder (id) = getStringByKey(getNextOrderKey(id)) | |
280 | + | func formattingPriceMsg (price,height) = toBytes((((("WAVESNEUTRINOPREFIX" + "_") + toString(height)) + "_") + toString(price))) | |
162 | 281 | ||
163 | 282 | ||
164 | 283 | @Callable(i) | |
165 | - | func sellBond (arg) = { | |
166 | - | let bondBalance = assetBalance(this, bondAssetId) | |
167 | - | let deficitPositive = if ((0 >= deficit)) | |
168 | - | then 0 | |
169 | - | else deficit | |
170 | - | let bondAmount = if ((deficitPositive >= bondBalance)) | |
171 | - | then bondBalance | |
172 | - | else deficitPositive | |
173 | - | let returnAmount = if ((deficitPositive >= bondBalance)) | |
174 | - | then 0 | |
175 | - | else (bondBalance - deficitPositive) | |
176 | - | WriteSet([DataEntry(FirstOrderKey, arg), DataEntry(getOrderStatusKey(firstOrder), (arg + "zzz"))]) | |
284 | + | func callEmergencyShutdown (reason) = { | |
285 | + | let AutoEmergencyOracleAddress = "3Mwho43kPZa9w1y91NJsAoYxgQpsg3JjGby" | |
286 | + | let callerAddress = toString(i.caller) | |
287 | + | if ((AutoEmergencyOracleAddress != callerAddress)) | |
288 | + | then throw("caller must be one an emergency oracle") | |
289 | + | else WriteSet([DataEntry("is_blocked", true), DataEntry("is_blocked_caller", callerAddress), DataEntry("is_blocked_reason", reason)]) | |
177 | 290 | } | |
291 | + | ||
292 | + | ||
293 | + | ||
294 | + | @Callable(i) | |
295 | + | func finalizeCurrentPrice (price1,price2,price3,price4,price5) = if (isBlocked) | |
296 | + | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
297 | + | else if (( match getInteger(this, ("price_" + toString(height))) { | |
298 | + | case a: Int => | |
299 | + | a | |
300 | + | case _ => | |
301 | + | 0 | |
302 | + | } != 0)) | |
303 | + | then throw("wait next block") | |
304 | + | else { | |
305 | + | let prices = [if ((price1 > 0)) | |
306 | + | then price1 | |
307 | + | else 0, if ((price2 > 0)) | |
308 | + | then price2 | |
309 | + | else 0, if ((price3 > 0)) | |
310 | + | then price3 | |
311 | + | else 0, if ((price4 > 0)) | |
312 | + | then price4 | |
313 | + | else 0, if ((price5 > 0)) | |
314 | + | then price5 | |
315 | + | else 0] | |
316 | + | if (((1 + 1) > 3)) | |
317 | + | then throw("running here!") | |
318 | + | else { | |
319 | + | let pricesInRange = findPricesInRange(prices) | |
320 | + | let priceProvidingCount = size(pricesInRange) | |
321 | + | if ((3 > priceProvidingCount)) | |
322 | + | then throw(((((((((((((((((((((("Could not finalize price because of big variation: height=" + toString(height)) + " | |
323 | + | ") + pubKeyOraclesList[0]) + "=") + toString(prices[0])) + " | |
324 | + | ") + pubKeyOraclesList[1]) + "=") + toString(prices[1])) + " | |
325 | + | ") + pubKeyOraclesList[2]) + "=") + toString(prices[2])) + " | |
326 | + | ") + pubKeyOraclesList[3]) + "=") + toString(prices[3])) + " | |
327 | + | ") + pubKeyOraclesList[4]) + "=") + toString(prices[4]))) | |
328 | + | else { | |
329 | + | let sum1 = ((prices[pricesInRange[0]] + prices[pricesInRange[1]]) + prices[pricesInRange[2]]) | |
330 | + | let sum2 = if ((priceProvidingCount >= 4)) | |
331 | + | then (sum1 + prices[pricesInRange[3]]) | |
332 | + | else sum1 | |
333 | + | let priceSum = if ((priceProvidingCount >= 5)) | |
334 | + | then (sum2 + prices[pricesInRange[4]]) | |
335 | + | else sum2 | |
336 | + | if ((priceProvidingCount >= 6)) | |
337 | + | then throw("Invalid pricesInRange creation") | |
338 | + | else { | |
339 | + | let newPrice = (priceSum / priceProvidingCount) | |
340 | + | if (if ((newPrice >= (price + ((price * percentPriceOffset) / 100)))) | |
341 | + | then true | |
342 | + | else ((price - ((price * percentPriceOffset) / 100)) >= newPrice)) | |
343 | + | then WriteSet([DataEntry("is_blocked", true), DataEntry((("black_swarm_price" + "_") + toString(height)), newPrice)]) | |
344 | + | else { | |
345 | + | let newPriceIndex = (priceIndex + 1) | |
346 | + | WriteSet([DataEntry("price", newPrice), DataEntry(("price_" + toString(height)), newPrice), DataEntry("price_index", newPriceIndex), DataEntry(("price_index_" + toString(newPriceIndex)), height), DataEntry(("deficit_" + toString(height)), deficit), DataEntry(("neutrinoSupply_" + toString(height)), neutrinoSupply), DataEntry(("deficit_percent_" + toString(height)), if ((neutrinoSupply != 0)) | |
347 | + | then ((deficit * 100) / neutrinoSupply) | |
348 | + | else 0)]) | |
349 | + | } | |
350 | + | } | |
351 | + | } | |
352 | + | } | |
353 | + | } | |
354 | + | ||
355 | + | ||
356 | + | ||
357 | + | @Callable(i) | |
358 | + | func finalizeCurrentPrice1 () = if ((1 > 4)) | |
359 | + | then throw("") | |
360 | + | else { | |
361 | + | let newPriceIndex = (priceIndex + 1) | |
362 | + | WriteSet([DataEntry("data1", 100), DataEntry("price_", (getNumberByKey("data1") * 2))]) | |
363 | + | } | |
178 | 364 | ||
179 | 365 |
github/deemru/w8io/169f3d6 56.21 ms ◑