tx · 8MMAPLgc1dx9wweySh4pAuwYek7XLArWYsFvws4y56t8 3N4NS7d4Jo9a6F14LiFUKKYVdUkkf2eP4Zx: -0.02000000 Waves 2020.09.16 14:01 [1179740] smart account 3N4NS7d4Jo9a6F14LiFUKKYVdUkkf2eP4Zx > SELF 0.00000000 Waves
{ "type": 13, "id": "8MMAPLgc1dx9wweySh4pAuwYek7XLArWYsFvws4y56t8", "fee": 2000000, "feeAssetId": null, "timestamp": 1600254072425, "version": 1, "sender": "3N4NS7d4Jo9a6F14LiFUKKYVdUkkf2eP4Zx", "senderPublicKey": "NaY7sqttWGpnVrcb6uE8xPp2VnMjT7fhv3q1TKGL9ar", "proofs": [ "5qxZySHaRhDBxC1oE9cvroMN2NU68cbYog1H41BoCiMUg42P4pQGmJZ3v5ti2gq4TNUDYYTZk9do7fzjFwkT6vyQ", "4LJ668ukgRi4VAPgfbKTzz6mLkVpAgU3M7kkk2um1PohyvTfqNzceNUXBE3P1E3PHDNQM5fjdqBEWAfszm4c41v6", "4Y8C8WV26B2svptWwVeFHJQveULEvcXK1br3q52wejZCsM7rUP2SJuygB1PiuvAz8QFTCNiSBYzeRwUD1d7we1ai" ], "script": "base64:AAIEAAAAAAAAABUIAhIDCgEIEgwKCgECAQIBAgECAQIAAAAUAQAAABZjb252ZXJ0V2F2ZXNUb05ldXRyaW5vAAAAAgAAAAZhbW91bnQAAAAFcHJpY2UJAABrAAAAAwkAAGsAAAADBQAAAAZhbW91bnQFAAAABXByaWNlAAAAAAAAD0JAAAAAAAAAD0JAAAAAAAAF9eEAAQAAABhnZXROdW1iZXJCeUFkZHJlc3NBbmRLZXkAAAACAAAAB2FkZHJlc3MAAAADa2V5CQEAAAALdmFsdWVPckVsc2UAAAACCQAEGgAAAAIJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAEFAAAAB2FkZHJlc3MFAAAAA2tleQAAAAAAAAAAAAEAAAAYZ2V0U3RyaW5nQnlBZGRyZXNzQW5kS2V5AAAAAgAAA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sNVdSWEZTandjVGJOZktjSnM4WnFYbVNTV1lzU1ZKVXRNdk1xWmo1aEg0TmMFAAAAA25pbAQAAAAFY291bnQJAABkAAAAAgkAAGQAAAACCQAAZAAAAAIDCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAkAAlkAAAABCQABkQAAAAIFAAAAEHB1YktleUFkbWluc0xpc3QAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAADCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAQkAAlkAAAABCQABkQAAAAIFAAAAEHB1YktleUFkbWluc0xpc3QAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAAAAAAADCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAgkAAlkAAAABCQABkQAAAAIFAAAAEHB1YktleUFkbWluc0xpc3QAAAAAAAAAAAIAAAAAAAAAAAEAAAAAAAAAAAADCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAwkAAlkAAAABCQABkQAAAAIFAAAAEHB1YktleUFkbWluc0xpc3QAAAAAAAAAAAMAAAAAAAAAAAIAAAAAAAAAAAAJAABnAAAAAgUAAAAFY291bnQAAAAAAAAAAAMhUNXD", "chainId": 84, "height": 1179740, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FnaSDvZJ9CqkxySJfcFzA1vj6Ux1DGV9bURgun74yWz5 Next: DDvS8M4E879kMFRKsuKngHG2f7MvRzNqCVFo2BfgSdWD Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, 1000000), 1000000, 100000000) | |
5 | 5 | ||
6 | 6 | ||
7 | - | func getStringByKey (key) = match getString(this, key) { | |
8 | - | case a: String => | |
9 | - | a | |
10 | - | case _ => | |
11 | - | "" | |
12 | - | } | |
7 | + | func getNumberByAddressAndKey (address,key) = valueOrElse(getInteger(addressFromStringValue(address), key), 0) | |
13 | 8 | ||
14 | 9 | ||
15 | - | func getNumberByAddressAndKey (address,key) = match getInteger(addressFromStringValue(address), key) { | |
16 | - | case a: Int => | |
17 | - | a | |
18 | - | case _ => | |
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 getStringByAddressAndKey (address,key) = match getString(address, key) { | |
32 | - | case a: String => | |
33 | - | a | |
34 | - | case _ => | |
35 | - | "" | |
36 | - | } | |
37 | - | ||
38 | - | ||
39 | - | func dropElementInJsonArray (array,element) = { | |
40 | - | let splitedArray = split(array, element) | |
41 | - | if ((take(splitedArray[1], 1) == ",")) | |
42 | - | then (splitedArray[0] + drop(splitedArray[1], 1)) | |
43 | - | else (dropRight(splitedArray[0], 1) + splitedArray[1]) | |
44 | - | } | |
10 | + | func getStringByAddressAndKey (address,key) = valueOrElse(getString(address, key), "") | |
45 | 11 | ||
46 | 12 | ||
47 | 13 | func convertJsonArrayToList (jsonArray) = split(jsonArray, ",") | |
48 | 14 | ||
49 | 15 | ||
50 | - | let price = match getInteger(this, "price") { | |
51 | - | case a: Int => | |
52 | - | a | |
53 | - | case _ => | |
54 | - | 0 | |
55 | - | } | |
16 | + | let price = valueOrElse(getInteger(this, "price"), 0) | |
56 | 17 | ||
57 | - | let priceIndex = match getInteger(this, "price_index") { | |
58 | - | case a: Int => | |
59 | - | a | |
60 | - | case _ => | |
61 | - | 0 | |
62 | - | } | |
18 | + | let priceIndex = valueOrElse(getInteger(this, "price_index"), 0) | |
63 | 19 | ||
64 | - | let isBlocked = match getBoolean(this, "is_blocked") { | |
65 | - | case a: Boolean => | |
66 | - | a | |
67 | - | case _ => | |
68 | - | false | |
69 | - | } | |
20 | + | let isBlocked = valueOrElse(getBoolean(this, "is_blocked"), false) | |
70 | 21 | ||
71 | 22 | let percentPriceOffset = 25 | |
72 | 23 | ||
73 | - | let pubKeyOracles = | |
24 | + | let pubKeyOracles = valueOrElse(getString(this, "oracles"), "") | |
74 | 25 | ||
75 | 26 | let pubKeyOraclesList = convertJsonArrayToList(pubKeyOracles) | |
76 | 27 | ||
77 | - | let | |
28 | + | let neutrinoAddress = Address(base58'3Mzbx34Ex5rRbn39vUHx9kiwh3nneF8S5we') | |
78 | 29 | ||
79 | - | let | |
30 | + | let liquidationAddress = Address(base58'3N5nmMvMH8o3RPEyCKCaoWahBTYTexnZy62') | |
80 | 31 | ||
81 | - | let | |
32 | + | let neutrinoAsset = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT' | |
82 | 33 | ||
83 | - | let | |
34 | + | let neutrinoLockedBalance = valueOrElse(getInteger(neutrinoAddress, "balance_lock_neutrino"), 0) | |
84 | 35 | ||
85 | - | let neutrinoLockedBalance = match getInteger(neutrinoAddress, "balance_lock_neutrino") { | |
86 | - | case a: Int => | |
87 | - | a | |
88 | - | case _ => | |
89 | - | 0 | |
90 | - | } | |
36 | + | let wavesLockedBalance = valueOrElse(getInteger(neutrinoAddress, "balance_lock_waves"), 0) | |
91 | 37 | ||
92 | - | let wavesLockedBalance = match getInteger(neutrinoAddress, "balance_lock_waves") { | |
93 | - | case a: Int => | |
94 | - | a | |
95 | - | case _ => | |
96 | - | 0 | |
97 | - | } | |
38 | + | let reserve = (wavesBalance(neutrinoAddress).regular - wavesLockedBalance) | |
98 | 39 | ||
99 | - | let reserve = (wavesBalance(neutrinoAddress) - wavesLockedBalance) | |
100 | - | ||
101 | - | let neutrinoSupply = (((neutrinoLockedBalance + extract(assetInfo(neutrinoAsset)).quantity) - assetBalance(neutrinoAddress, neutrinoAsset)) - assetBalance(liquidationAddress, neutrinoAsset)) | |
40 | + | let neutrinoSupply = (((neutrinoLockedBalance + value(assetInfo(neutrinoAsset)).quantity) - assetBalance(neutrinoAddress, neutrinoAsset)) - assetBalance(liquidationAddress, neutrinoAsset)) | |
102 | 41 | ||
103 | 42 | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve, price)) | |
104 | 43 | ||
269 | 208 | } | |
270 | 209 | ||
271 | 210 | ||
272 | - | func formattingPriceMsg (price | |
211 | + | func formattingPriceMsg (price) = toBytes((((("WAVESNEUTRINOPREFIX" + "_") + toString(height)) + "_") + toString(price))) | |
273 | 212 | ||
274 | 213 | ||
275 | 214 | @Callable(i) | |
278 | 217 | let callerAddress = toString(i.caller) | |
279 | 218 | if ((AutoEmergencyOracleAddress != callerAddress)) | |
280 | 219 | then throw("caller must be one an emergency oracle") | |
281 | - | else | |
220 | + | else [BooleanEntry("is_blocked", true), StringEntry("is_blocked_caller", callerAddress), StringEntry("is_blocked_reason", reason)] | |
282 | 221 | } | |
283 | 222 | ||
284 | 223 | ||
286 | 225 | @Callable(i) | |
287 | 226 | func finalizeCurrentPrice (price1,sign1,price2,sign2,price3,sign3,price4,sign4,price5,sign5) = if (isBlocked) | |
288 | 227 | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
289 | - | else if (( match getInteger(this, ("price_" + toString(height))) { | |
290 | - | case a: Int => | |
291 | - | a | |
292 | - | case _ => | |
293 | - | 0 | |
294 | - | } != 0)) | |
228 | + | else if ((valueOrElse(getInteger(this, ("price_" + toString(height))), 0) != 0)) | |
295 | 229 | then throw("wait next block") | |
296 | 230 | else if ((pubKeyOraclesList[(height % 5)] != toBase58String(i.callerPublicKey))) | |
297 | 231 | then throw(((("Out of turn finalization: " + toString(height)) + " block should be finalize by ") + pubKeyOraclesList[(height % 5)])) | |
298 | 232 | else { | |
299 | - | let prices = [if (sigVerify(formattingPriceMsg(price1 | |
233 | + | let prices = [if (sigVerify_8Kb(formattingPriceMsg(price1), sign1, fromBase58String(pubKeyOraclesList[0]))) | |
300 | 234 | then price1 | |
301 | - | else 0, if (sigVerify(formattingPriceMsg(price2 | |
235 | + | else 0, if (sigVerify_8Kb(formattingPriceMsg(price2), sign2, fromBase58String(pubKeyOraclesList[1]))) | |
302 | 236 | then price2 | |
303 | - | else 0, if (sigVerify(formattingPriceMsg(price3 | |
237 | + | else 0, if (sigVerify_8Kb(formattingPriceMsg(price3), sign3, fromBase58String(pubKeyOraclesList[2]))) | |
304 | 238 | then price3 | |
305 | - | else 0, if (sigVerify(formattingPriceMsg(price4 | |
239 | + | else 0, if (sigVerify_8Kb(formattingPriceMsg(price4), sign4, fromBase58String(pubKeyOraclesList[3]))) | |
306 | 240 | then price4 | |
307 | - | else 0, if (sigVerify(formattingPriceMsg(price5 | |
241 | + | else 0, if (sigVerify_8Kb(formattingPriceMsg(price5), sign5, fromBase58String(pubKeyOraclesList[4]))) | |
308 | 242 | then price5 | |
309 | 243 | else 0] | |
310 | - | let pricesInRange = findPricesInRange(prices) | |
311 | - | let priceProvidingCount = size(pricesInRange) | |
312 | - | if ((3 > priceProvidingCount)) | |
313 | - | then throw(((((((((((((((((((((("Could not finalize price because of big variation: height=" + toString(height)) + " | |
244 | + | let zeroPriceCount = if ((prices[0] == 0)) | |
245 | + | then 1 | |
246 | + | else (0 + (if ((prices[1] == 0)) | |
247 | + | then 1 | |
248 | + | else (0 + (if ((prices[2] == 0)) | |
249 | + | then 1 | |
250 | + | else (0 + (if ((prices[3] == 0)) | |
251 | + | then 1 | |
252 | + | else (0 + (if ((prices[4] == 0)) | |
253 | + | then 1 | |
254 | + | else 0)))))))) | |
255 | + | if ((zeroPriceCount >= 3)) | |
256 | + | then throw("3 prices or more are equals to 0") | |
257 | + | else { | |
258 | + | let pricesInRange = findPricesInRange(prices) | |
259 | + | let priceProvidingCount = size(pricesInRange) | |
260 | + | if ((3 > priceProvidingCount)) | |
261 | + | then throw(((((((((((((((((((((("Could not finalize price because of big variation: height=" + toString(height)) + " | |
314 | 262 | ") + pubKeyOraclesList[0]) + "=") + toString(prices[0])) + " | |
315 | 263 | ") + pubKeyOraclesList[1]) + "=") + toString(prices[1])) + " | |
316 | 264 | ") + pubKeyOraclesList[2]) + "=") + toString(prices[2])) + " | |
317 | 265 | ") + pubKeyOraclesList[3]) + "=") + toString(prices[3])) + " | |
318 | 266 | ") + pubKeyOraclesList[4]) + "=") + toString(prices[4]))) | |
319 | - | else { | |
320 | - | let sum1 = ((prices[pricesInRange[0]] + prices[pricesInRange[1]]) + prices[pricesInRange[2]]) | |
321 | - | let sum2 = if ((priceProvidingCount >= 4)) | |
322 | - | then (sum1 + prices[pricesInRange[3]]) | |
323 | - | else sum1 | |
324 | - | let priceSum = if ((priceProvidingCount >= 5)) | |
325 | - | then (sum2 + prices[pricesInRange[4]]) | |
326 | - | else sum2 | |
327 | - | if ((priceProvidingCount >= 6)) | |
328 | - | then throw("Invalid pricesInRange creation") | |
329 | 267 | else { | |
330 | - | let newPrice = (priceSum / priceProvidingCount) | |
331 | - | if (if ((newPrice >= (price + ((price * percentPriceOffset) / 100)))) | |
332 | - | then true | |
333 | - | else ((price - ((price * percentPriceOffset) / 100)) >= newPrice)) | |
334 | - | then { | |
335 | - | let reason = "automatic emergency shutdown because of large price variability" | |
336 | - | WriteSet([DataEntry("is_blocked", true), DataEntry("is_blocked_caller", toString(this)), DataEntry("is_blocked_reason", reason), DataEntry((("black_swarm_price" + "_") + toString(height)), newPrice)]) | |
337 | - | } | |
268 | + | let sum1 = ((prices[pricesInRange[0]] + prices[pricesInRange[1]]) + prices[pricesInRange[2]]) | |
269 | + | let sum2 = if ((priceProvidingCount >= 4)) | |
270 | + | then (sum1 + prices[pricesInRange[3]]) | |
271 | + | else sum1 | |
272 | + | let priceSum = if ((priceProvidingCount >= 5)) | |
273 | + | then (sum2 + prices[pricesInRange[4]]) | |
274 | + | else sum2 | |
275 | + | if ((priceProvidingCount >= 6)) | |
276 | + | then throw("Invalid pricesInRange creation") | |
338 | 277 | else { | |
339 | - | let newPriceIndex = (priceIndex + 1) | |
340 | - | 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)) | |
341 | - | then ((deficit * 100) / neutrinoSupply) | |
342 | - | else 0)]) | |
278 | + | let newPrice = (priceSum / priceProvidingCount) | |
279 | + | if (if ((newPrice >= (price + ((price * percentPriceOffset) / 100)))) | |
280 | + | then true | |
281 | + | else ((price - ((price * percentPriceOffset) / 100)) >= newPrice)) | |
282 | + | then { | |
283 | + | let reason = "automatic emergency shutdown because of large price variability" | |
284 | + | [BooleanEntry("is_blocked", true), StringEntry("is_blocked_caller", toString(this)), StringEntry("is_blocked_reason", reason), IntegerEntry((("black_swarm_price" + "_") + toString(height)), newPrice)] | |
285 | + | } | |
286 | + | else { | |
287 | + | let newPriceIndex = (priceIndex + 1) | |
288 | + | [IntegerEntry("price", newPrice), IntegerEntry(("price_" + toString(height)), newPrice), IntegerEntry("price_index", newPriceIndex), IntegerEntry(("price_index_" + toString(newPriceIndex)), height), IntegerEntry(("deficit_" + toString(height)), deficit), IntegerEntry(("neutrinoSupply_" + toString(height)), neutrinoSupply), IntegerEntry(("deficit_percent_" + toString(height)), if ((neutrinoSupply != 0)) | |
289 | + | then ((deficit * 100) / neutrinoSupply) | |
290 | + | else 0)] | |
291 | + | } | |
343 | 292 | } | |
344 | 293 | } | |
345 | 294 | } | |
346 | 295 | } | |
347 | - | ||
348 | - | ||
349 | - | ||
350 | - | @Callable(i) | |
351 | - | func updateReservesAndNeutrinoSupply () = { | |
352 | - | func getNumberByKeyInternal (key) = match getInteger(this, key) { | |
353 | - | case a: Int => | |
354 | - | a | |
355 | - | case _ => | |
356 | - | 0 | |
357 | - | } | |
358 | - | ||
359 | - | let idx = getNumberByKeyInternal("updateReservesAndNeutrinoSupplyIdx") | |
360 | - | let newIdx = (idx + 1) | |
361 | - | WriteSet([DataEntry("updateReservesAndNeutrinoSupplyIdx", newIdx), DataEntry("reserve", reserve), DataEntry("neutrinoSupply", neutrinoSupply), DataEntry("deficit", deficit)]) | |
362 | - | } | |
363 | 296 | ||
364 | 297 | ||
365 | 298 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, 1000000), 1000000, 100000000) | |
5 | 5 | ||
6 | 6 | ||
7 | - | func getStringByKey (key) = match getString(this, key) { | |
8 | - | case a: String => | |
9 | - | a | |
10 | - | case _ => | |
11 | - | "" | |
12 | - | } | |
7 | + | func getNumberByAddressAndKey (address,key) = valueOrElse(getInteger(addressFromStringValue(address), key), 0) | |
13 | 8 | ||
14 | 9 | ||
15 | - | func getNumberByAddressAndKey (address,key) = match getInteger(addressFromStringValue(address), key) { | |
16 | - | case a: Int => | |
17 | - | a | |
18 | - | case _ => | |
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 getStringByAddressAndKey (address,key) = match getString(address, key) { | |
32 | - | case a: String => | |
33 | - | a | |
34 | - | case _ => | |
35 | - | "" | |
36 | - | } | |
37 | - | ||
38 | - | ||
39 | - | func dropElementInJsonArray (array,element) = { | |
40 | - | let splitedArray = split(array, element) | |
41 | - | if ((take(splitedArray[1], 1) == ",")) | |
42 | - | then (splitedArray[0] + drop(splitedArray[1], 1)) | |
43 | - | else (dropRight(splitedArray[0], 1) + splitedArray[1]) | |
44 | - | } | |
10 | + | func getStringByAddressAndKey (address,key) = valueOrElse(getString(address, key), "") | |
45 | 11 | ||
46 | 12 | ||
47 | 13 | func convertJsonArrayToList (jsonArray) = split(jsonArray, ",") | |
48 | 14 | ||
49 | 15 | ||
50 | - | let price = match getInteger(this, "price") { | |
51 | - | case a: Int => | |
52 | - | a | |
53 | - | case _ => | |
54 | - | 0 | |
55 | - | } | |
16 | + | let price = valueOrElse(getInteger(this, "price"), 0) | |
56 | 17 | ||
57 | - | let priceIndex = match getInteger(this, "price_index") { | |
58 | - | case a: Int => | |
59 | - | a | |
60 | - | case _ => | |
61 | - | 0 | |
62 | - | } | |
18 | + | let priceIndex = valueOrElse(getInteger(this, "price_index"), 0) | |
63 | 19 | ||
64 | - | let isBlocked = match getBoolean(this, "is_blocked") { | |
65 | - | case a: Boolean => | |
66 | - | a | |
67 | - | case _ => | |
68 | - | false | |
69 | - | } | |
20 | + | let isBlocked = valueOrElse(getBoolean(this, "is_blocked"), false) | |
70 | 21 | ||
71 | 22 | let percentPriceOffset = 25 | |
72 | 23 | ||
73 | - | let pubKeyOracles = | |
24 | + | let pubKeyOracles = valueOrElse(getString(this, "oracles"), "") | |
74 | 25 | ||
75 | 26 | let pubKeyOraclesList = convertJsonArrayToList(pubKeyOracles) | |
76 | 27 | ||
77 | - | let | |
28 | + | let neutrinoAddress = Address(base58'3Mzbx34Ex5rRbn39vUHx9kiwh3nneF8S5we') | |
78 | 29 | ||
79 | - | let | |
30 | + | let liquidationAddress = Address(base58'3N5nmMvMH8o3RPEyCKCaoWahBTYTexnZy62') | |
80 | 31 | ||
81 | - | let | |
32 | + | let neutrinoAsset = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT' | |
82 | 33 | ||
83 | - | let | |
34 | + | let neutrinoLockedBalance = valueOrElse(getInteger(neutrinoAddress, "balance_lock_neutrino"), 0) | |
84 | 35 | ||
85 | - | let neutrinoLockedBalance = match getInteger(neutrinoAddress, "balance_lock_neutrino") { | |
86 | - | case a: Int => | |
87 | - | a | |
88 | - | case _ => | |
89 | - | 0 | |
90 | - | } | |
36 | + | let wavesLockedBalance = valueOrElse(getInteger(neutrinoAddress, "balance_lock_waves"), 0) | |
91 | 37 | ||
92 | - | let wavesLockedBalance = match getInteger(neutrinoAddress, "balance_lock_waves") { | |
93 | - | case a: Int => | |
94 | - | a | |
95 | - | case _ => | |
96 | - | 0 | |
97 | - | } | |
38 | + | let reserve = (wavesBalance(neutrinoAddress).regular - wavesLockedBalance) | |
98 | 39 | ||
99 | - | let reserve = (wavesBalance(neutrinoAddress) - wavesLockedBalance) | |
100 | - | ||
101 | - | let neutrinoSupply = (((neutrinoLockedBalance + extract(assetInfo(neutrinoAsset)).quantity) - assetBalance(neutrinoAddress, neutrinoAsset)) - assetBalance(liquidationAddress, neutrinoAsset)) | |
40 | + | let neutrinoSupply = (((neutrinoLockedBalance + value(assetInfo(neutrinoAsset)).quantity) - assetBalance(neutrinoAddress, neutrinoAsset)) - assetBalance(liquidationAddress, neutrinoAsset)) | |
102 | 41 | ||
103 | 42 | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve, price)) | |
104 | 43 | ||
105 | 44 | func findPricesInRange (prices) = { | |
106 | 45 | let minPercentBound = 90 | |
107 | 46 | let maxPercentBound = 110 | |
108 | 47 | let p0 = prices[0] | |
109 | 48 | let check0 = if ((0 >= prices[0])) | |
110 | 49 | then [0] | |
111 | 50 | else { | |
112 | 51 | let p01 = ((prices[1] * 100) / p0) | |
113 | 52 | let p02 = ((prices[2] * 100) / p0) | |
114 | 53 | let p03 = ((prices[3] * 100) / p0) | |
115 | 54 | let p04 = ((prices[4] * 100) / p0) | |
116 | 55 | let array1 = if (if ((maxPercentBound > p01)) | |
117 | 56 | then (p01 > minPercentBound) | |
118 | 57 | else false) | |
119 | 58 | then [1, 0] | |
120 | 59 | else [0] | |
121 | 60 | let array2 = if (if ((maxPercentBound > p02)) | |
122 | 61 | then (p02 > minPercentBound) | |
123 | 62 | else false) | |
124 | 63 | then 2 :: array1 | |
125 | 64 | else array1 | |
126 | 65 | let array3 = if (if ((maxPercentBound > p03)) | |
127 | 66 | then (p03 > minPercentBound) | |
128 | 67 | else false) | |
129 | 68 | then 3 :: array2 | |
130 | 69 | else array2 | |
131 | 70 | if (if ((maxPercentBound > p04)) | |
132 | 71 | then (p04 > minPercentBound) | |
133 | 72 | else false) | |
134 | 73 | then 4 :: array3 | |
135 | 74 | else array3 | |
136 | 75 | } | |
137 | 76 | let check1 = if ((size(check0) >= 3)) | |
138 | 77 | then check0 | |
139 | 78 | else { | |
140 | 79 | let p1 = prices[1] | |
141 | 80 | if ((0 >= p1)) | |
142 | 81 | then [1] | |
143 | 82 | else { | |
144 | 83 | let p10 = ((prices[0] * 100) / p1) | |
145 | 84 | let p12 = ((prices[2] * 100) / p1) | |
146 | 85 | let p13 = ((prices[3] * 100) / p1) | |
147 | 86 | let p14 = ((prices[4] * 100) / p1) | |
148 | 87 | let array1 = if (if ((maxPercentBound > p10)) | |
149 | 88 | then (p10 > minPercentBound) | |
150 | 89 | else false) | |
151 | 90 | then [0, 1] | |
152 | 91 | else [1] | |
153 | 92 | let array2 = if (if ((maxPercentBound > p12)) | |
154 | 93 | then (p12 > minPercentBound) | |
155 | 94 | else false) | |
156 | 95 | then 2 :: array1 | |
157 | 96 | else array1 | |
158 | 97 | let array3 = if (if ((maxPercentBound > p13)) | |
159 | 98 | then (p13 > minPercentBound) | |
160 | 99 | else false) | |
161 | 100 | then 3 :: array2 | |
162 | 101 | else array2 | |
163 | 102 | if (if ((maxPercentBound > p14)) | |
164 | 103 | then (p14 > minPercentBound) | |
165 | 104 | else false) | |
166 | 105 | then 4 :: array3 | |
167 | 106 | else array3 | |
168 | 107 | } | |
169 | 108 | } | |
170 | 109 | let check2 = if ((size(check1) >= 3)) | |
171 | 110 | then check1 | |
172 | 111 | else { | |
173 | 112 | let p2 = prices[2] | |
174 | 113 | if ((0 >= p2)) | |
175 | 114 | then [2] | |
176 | 115 | else { | |
177 | 116 | let p20 = ((prices[0] * 100) / p2) | |
178 | 117 | let p21 = ((prices[1] * 100) / p2) | |
179 | 118 | let p23 = ((prices[3] * 100) / p2) | |
180 | 119 | let p24 = ((prices[4] * 100) / p2) | |
181 | 120 | let array1 = if (if ((maxPercentBound > p20)) | |
182 | 121 | then (p20 > minPercentBound) | |
183 | 122 | else false) | |
184 | 123 | then [0, 2] | |
185 | 124 | else [2] | |
186 | 125 | let array2 = if (if ((maxPercentBound > p21)) | |
187 | 126 | then (p21 > minPercentBound) | |
188 | 127 | else false) | |
189 | 128 | then 1 :: array1 | |
190 | 129 | else array1 | |
191 | 130 | let array3 = if (if ((maxPercentBound > p23)) | |
192 | 131 | then (p23 > minPercentBound) | |
193 | 132 | else false) | |
194 | 133 | then 3 :: array2 | |
195 | 134 | else array2 | |
196 | 135 | if (if ((maxPercentBound > p24)) | |
197 | 136 | then (p24 > minPercentBound) | |
198 | 137 | else false) | |
199 | 138 | then 4 :: array3 | |
200 | 139 | else array3 | |
201 | 140 | } | |
202 | 141 | } | |
203 | 142 | let check3 = if ((size(check2) >= 3)) | |
204 | 143 | then check2 | |
205 | 144 | else { | |
206 | 145 | let p3 = prices[3] | |
207 | 146 | if ((0 >= p3)) | |
208 | 147 | then [3] | |
209 | 148 | else { | |
210 | 149 | let p30 = ((prices[0] * 100) / p3) | |
211 | 150 | let p31 = ((prices[1] * 100) / p3) | |
212 | 151 | let p32 = ((prices[2] * 100) / p3) | |
213 | 152 | let p34 = ((prices[4] * 100) / p3) | |
214 | 153 | let array1 = if (if ((maxPercentBound > p30)) | |
215 | 154 | then (p30 > minPercentBound) | |
216 | 155 | else false) | |
217 | 156 | then [0, 3] | |
218 | 157 | else [3] | |
219 | 158 | let array2 = if (if ((maxPercentBound > p31)) | |
220 | 159 | then (p31 > minPercentBound) | |
221 | 160 | else false) | |
222 | 161 | then 1 :: array1 | |
223 | 162 | else array1 | |
224 | 163 | let array3 = if (if ((maxPercentBound > p32)) | |
225 | 164 | then (p32 > minPercentBound) | |
226 | 165 | else false) | |
227 | 166 | then 2 :: array2 | |
228 | 167 | else array2 | |
229 | 168 | if (if ((maxPercentBound > p34)) | |
230 | 169 | then (p34 > minPercentBound) | |
231 | 170 | else false) | |
232 | 171 | then 4 :: array3 | |
233 | 172 | else array3 | |
234 | 173 | } | |
235 | 174 | } | |
236 | 175 | if ((size(check3) >= 3)) | |
237 | 176 | then check3 | |
238 | 177 | else { | |
239 | 178 | let p4 = prices[4] | |
240 | 179 | if ((0 >= p4)) | |
241 | 180 | then [4] | |
242 | 181 | else { | |
243 | 182 | let p40 = ((prices[0] * 100) / p4) | |
244 | 183 | let p41 = ((prices[1] * 100) / p4) | |
245 | 184 | let p42 = ((prices[2] * 100) / p4) | |
246 | 185 | let p43 = ((prices[3] * 100) / p4) | |
247 | 186 | let array1 = if (if ((maxPercentBound > p40)) | |
248 | 187 | then (p40 > minPercentBound) | |
249 | 188 | else false) | |
250 | 189 | then [0, 4] | |
251 | 190 | else [4] | |
252 | 191 | let array2 = if (if ((maxPercentBound > p41)) | |
253 | 192 | then (p41 > minPercentBound) | |
254 | 193 | else false) | |
255 | 194 | then 1 :: array1 | |
256 | 195 | else array1 | |
257 | 196 | let array3 = if (if ((maxPercentBound > p42)) | |
258 | 197 | then (p42 > minPercentBound) | |
259 | 198 | else false) | |
260 | 199 | then 2 :: array2 | |
261 | 200 | else array2 | |
262 | 201 | if (if ((maxPercentBound > p43)) | |
263 | 202 | then (p43 > minPercentBound) | |
264 | 203 | else false) | |
265 | 204 | then 3 :: array3 | |
266 | 205 | else array3 | |
267 | 206 | } | |
268 | 207 | } | |
269 | 208 | } | |
270 | 209 | ||
271 | 210 | ||
272 | - | func formattingPriceMsg (price | |
211 | + | func formattingPriceMsg (price) = toBytes((((("WAVESNEUTRINOPREFIX" + "_") + toString(height)) + "_") + toString(price))) | |
273 | 212 | ||
274 | 213 | ||
275 | 214 | @Callable(i) | |
276 | 215 | func callEmergencyShutdown (reason) = { | |
277 | 216 | let AutoEmergencyOracleAddress = "3N65UDbSkK72XdSgH3NhvJ8HaH57x8VmoW3" | |
278 | 217 | let callerAddress = toString(i.caller) | |
279 | 218 | if ((AutoEmergencyOracleAddress != callerAddress)) | |
280 | 219 | then throw("caller must be one an emergency oracle") | |
281 | - | else | |
220 | + | else [BooleanEntry("is_blocked", true), StringEntry("is_blocked_caller", callerAddress), StringEntry("is_blocked_reason", reason)] | |
282 | 221 | } | |
283 | 222 | ||
284 | 223 | ||
285 | 224 | ||
286 | 225 | @Callable(i) | |
287 | 226 | func finalizeCurrentPrice (price1,sign1,price2,sign2,price3,sign3,price4,sign4,price5,sign5) = if (isBlocked) | |
288 | 227 | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
289 | - | else if (( match getInteger(this, ("price_" + toString(height))) { | |
290 | - | case a: Int => | |
291 | - | a | |
292 | - | case _ => | |
293 | - | 0 | |
294 | - | } != 0)) | |
228 | + | else if ((valueOrElse(getInteger(this, ("price_" + toString(height))), 0) != 0)) | |
295 | 229 | then throw("wait next block") | |
296 | 230 | else if ((pubKeyOraclesList[(height % 5)] != toBase58String(i.callerPublicKey))) | |
297 | 231 | then throw(((("Out of turn finalization: " + toString(height)) + " block should be finalize by ") + pubKeyOraclesList[(height % 5)])) | |
298 | 232 | else { | |
299 | - | let prices = [if (sigVerify(formattingPriceMsg(price1 | |
233 | + | let prices = [if (sigVerify_8Kb(formattingPriceMsg(price1), sign1, fromBase58String(pubKeyOraclesList[0]))) | |
300 | 234 | then price1 | |
301 | - | else 0, if (sigVerify(formattingPriceMsg(price2 | |
235 | + | else 0, if (sigVerify_8Kb(formattingPriceMsg(price2), sign2, fromBase58String(pubKeyOraclesList[1]))) | |
302 | 236 | then price2 | |
303 | - | else 0, if (sigVerify(formattingPriceMsg(price3 | |
237 | + | else 0, if (sigVerify_8Kb(formattingPriceMsg(price3), sign3, fromBase58String(pubKeyOraclesList[2]))) | |
304 | 238 | then price3 | |
305 | - | else 0, if (sigVerify(formattingPriceMsg(price4 | |
239 | + | else 0, if (sigVerify_8Kb(formattingPriceMsg(price4), sign4, fromBase58String(pubKeyOraclesList[3]))) | |
306 | 240 | then price4 | |
307 | - | else 0, if (sigVerify(formattingPriceMsg(price5 | |
241 | + | else 0, if (sigVerify_8Kb(formattingPriceMsg(price5), sign5, fromBase58String(pubKeyOraclesList[4]))) | |
308 | 242 | then price5 | |
309 | 243 | else 0] | |
310 | - | let pricesInRange = findPricesInRange(prices) | |
311 | - | let priceProvidingCount = size(pricesInRange) | |
312 | - | if ((3 > priceProvidingCount)) | |
313 | - | then throw(((((((((((((((((((((("Could not finalize price because of big variation: height=" + toString(height)) + " | |
244 | + | let zeroPriceCount = if ((prices[0] == 0)) | |
245 | + | then 1 | |
246 | + | else (0 + (if ((prices[1] == 0)) | |
247 | + | then 1 | |
248 | + | else (0 + (if ((prices[2] == 0)) | |
249 | + | then 1 | |
250 | + | else (0 + (if ((prices[3] == 0)) | |
251 | + | then 1 | |
252 | + | else (0 + (if ((prices[4] == 0)) | |
253 | + | then 1 | |
254 | + | else 0)))))))) | |
255 | + | if ((zeroPriceCount >= 3)) | |
256 | + | then throw("3 prices or more are equals to 0") | |
257 | + | else { | |
258 | + | let pricesInRange = findPricesInRange(prices) | |
259 | + | let priceProvidingCount = size(pricesInRange) | |
260 | + | if ((3 > priceProvidingCount)) | |
261 | + | then throw(((((((((((((((((((((("Could not finalize price because of big variation: height=" + toString(height)) + " | |
314 | 262 | ") + pubKeyOraclesList[0]) + "=") + toString(prices[0])) + " | |
315 | 263 | ") + pubKeyOraclesList[1]) + "=") + toString(prices[1])) + " | |
316 | 264 | ") + pubKeyOraclesList[2]) + "=") + toString(prices[2])) + " | |
317 | 265 | ") + pubKeyOraclesList[3]) + "=") + toString(prices[3])) + " | |
318 | 266 | ") + pubKeyOraclesList[4]) + "=") + toString(prices[4]))) | |
319 | - | else { | |
320 | - | let sum1 = ((prices[pricesInRange[0]] + prices[pricesInRange[1]]) + prices[pricesInRange[2]]) | |
321 | - | let sum2 = if ((priceProvidingCount >= 4)) | |
322 | - | then (sum1 + prices[pricesInRange[3]]) | |
323 | - | else sum1 | |
324 | - | let priceSum = if ((priceProvidingCount >= 5)) | |
325 | - | then (sum2 + prices[pricesInRange[4]]) | |
326 | - | else sum2 | |
327 | - | if ((priceProvidingCount >= 6)) | |
328 | - | then throw("Invalid pricesInRange creation") | |
329 | 267 | else { | |
330 | - | let newPrice = (priceSum / priceProvidingCount) | |
331 | - | if (if ((newPrice >= (price + ((price * percentPriceOffset) / 100)))) | |
332 | - | then true | |
333 | - | else ((price - ((price * percentPriceOffset) / 100)) >= newPrice)) | |
334 | - | then { | |
335 | - | let reason = "automatic emergency shutdown because of large price variability" | |
336 | - | WriteSet([DataEntry("is_blocked", true), DataEntry("is_blocked_caller", toString(this)), DataEntry("is_blocked_reason", reason), DataEntry((("black_swarm_price" + "_") + toString(height)), newPrice)]) | |
337 | - | } | |
268 | + | let sum1 = ((prices[pricesInRange[0]] + prices[pricesInRange[1]]) + prices[pricesInRange[2]]) | |
269 | + | let sum2 = if ((priceProvidingCount >= 4)) | |
270 | + | then (sum1 + prices[pricesInRange[3]]) | |
271 | + | else sum1 | |
272 | + | let priceSum = if ((priceProvidingCount >= 5)) | |
273 | + | then (sum2 + prices[pricesInRange[4]]) | |
274 | + | else sum2 | |
275 | + | if ((priceProvidingCount >= 6)) | |
276 | + | then throw("Invalid pricesInRange creation") | |
338 | 277 | else { | |
339 | - | let newPriceIndex = (priceIndex + 1) | |
340 | - | 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)) | |
341 | - | then ((deficit * 100) / neutrinoSupply) | |
342 | - | else 0)]) | |
278 | + | let newPrice = (priceSum / priceProvidingCount) | |
279 | + | if (if ((newPrice >= (price + ((price * percentPriceOffset) / 100)))) | |
280 | + | then true | |
281 | + | else ((price - ((price * percentPriceOffset) / 100)) >= newPrice)) | |
282 | + | then { | |
283 | + | let reason = "automatic emergency shutdown because of large price variability" | |
284 | + | [BooleanEntry("is_blocked", true), StringEntry("is_blocked_caller", toString(this)), StringEntry("is_blocked_reason", reason), IntegerEntry((("black_swarm_price" + "_") + toString(height)), newPrice)] | |
285 | + | } | |
286 | + | else { | |
287 | + | let newPriceIndex = (priceIndex + 1) | |
288 | + | [IntegerEntry("price", newPrice), IntegerEntry(("price_" + toString(height)), newPrice), IntegerEntry("price_index", newPriceIndex), IntegerEntry(("price_index_" + toString(newPriceIndex)), height), IntegerEntry(("deficit_" + toString(height)), deficit), IntegerEntry(("neutrinoSupply_" + toString(height)), neutrinoSupply), IntegerEntry(("deficit_percent_" + toString(height)), if ((neutrinoSupply != 0)) | |
289 | + | then ((deficit * 100) / neutrinoSupply) | |
290 | + | else 0)] | |
291 | + | } | |
343 | 292 | } | |
344 | 293 | } | |
345 | 294 | } | |
346 | 295 | } | |
347 | - | ||
348 | - | ||
349 | - | ||
350 | - | @Callable(i) | |
351 | - | func updateReservesAndNeutrinoSupply () = { | |
352 | - | func getNumberByKeyInternal (key) = match getInteger(this, key) { | |
353 | - | case a: Int => | |
354 | - | a | |
355 | - | case _ => | |
356 | - | 0 | |
357 | - | } | |
358 | - | ||
359 | - | let idx = getNumberByKeyInternal("updateReservesAndNeutrinoSupplyIdx") | |
360 | - | let newIdx = (idx + 1) | |
361 | - | WriteSet([DataEntry("updateReservesAndNeutrinoSupplyIdx", newIdx), DataEntry("reserve", reserve), DataEntry("neutrinoSupply", neutrinoSupply), DataEntry("deficit", deficit)]) | |
362 | - | } | |
363 | 296 | ||
364 | 297 | ||
365 | 298 | @Verifier(tx) | |
366 | 299 | func verify () = { | |
367 | 300 | let pubKeyAdminsList = ["GXxmZaCigPgJsT6d1cLr8nUXA65nGX8V7FuAzzrY8wQE", "3xumx4hrPpeeoo79HLGbZCgfz95L39ZFdxxwWeSUC2Pu", "D4CqtK5fBsnzRo33ZMhrM7niLseDH2uRoK6weBq2JQ3A", "5WRXFSjwcTbNfKcJs8ZqXmSSWYsSVJUtMvMqZj5hH4Nc"] | |
368 | 301 | let count = ((((if (sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(pubKeyAdminsList[0]))) | |
369 | 302 | then 1 | |
370 | 303 | else 0) + (if (sigVerify(tx.bodyBytes, tx.proofs[1], fromBase58String(pubKeyAdminsList[1]))) | |
371 | 304 | then 1 | |
372 | 305 | else 0)) + (if (sigVerify(tx.bodyBytes, tx.proofs[2], fromBase58String(pubKeyAdminsList[2]))) | |
373 | 306 | then 1 | |
374 | 307 | else 0)) + (if (sigVerify(tx.bodyBytes, tx.proofs[3], fromBase58String(pubKeyAdminsList[3]))) | |
375 | 308 | then 2 | |
376 | 309 | else 0)) | |
377 | 310 | (count >= 3) | |
378 | 311 | } | |
379 | 312 |
github/deemru/w8io/169f3d6 54.12 ms ◑