tx · 8ZFeaUGZtBBCY2G3oeGG4ttWHxAffx4tQhExjDXMjAWV 3N1WjhmF3EyutvrvtsfsSLbhmiLU8Bc1Toy: -0.01400000 Waves 2023.01.27 13:11 [2423235] smart account 3N1WjhmF3EyutvrvtsfsSLbhmiLU8Bc1Toy > SELF 0.00000000 Waves
{ "type": 13, "id": "8ZFeaUGZtBBCY2G3oeGG4ttWHxAffx4tQhExjDXMjAWV", "fee": 1400000, "feeAssetId": null, "timestamp": 1674814321281, "version": 1, "sender": "3N1WjhmF3EyutvrvtsfsSLbhmiLU8Bc1Toy", "senderPublicKey": "8PYTpiaoJ6s5TkL4uwQK1Z575gkArpvk8mmAQ2b8P9dZ", "proofs": [ "2pQnggBUTA8hY1JQaD6DUtxuSx588xXsWNCsRJZvPo61Wzp2vB2cijUFtRQn6836E87idU8f3HFrGuomAumv4NnL" ], "script": "base64:BgIRCAISCAoGCAgCAgICEgMKAQEtAAtQcm90b2NvbFNFUAIBOgADU0VQAgJfXwAScGVyY2VudFByaWNlT2Zmc2V0AF8BCGtleVByaWNlAQZzeW1ib2wJAKwCAgINJXMlc19fcHJpY2VfXwUGc3ltYm9sAQprZXlPcmFjbGVzAAIVJXMlc19fY29uZmlnX19vcmFjbGVzAQxrZXlHcm91cERhdGEBCGdyb3VwTnVtCQCsAgICDSVzJWRfX2dyb3VwX18FCGdyb3VwTnVtAQ9rZXlNaW5Db25zZW5zdXMAAholcyVzX19jb25maWdfX21pbkNvbnNlbnN1cwEPa2V5UHJpY2VGYWlsdXJlAQZzeW1ib2wJALkJAgkAzAgCAhslcyVzJWRfX2ZpbmFsaXphdGlvbkZhaWx1cmUJAMwIAgUGc3ltYm9sCQDMCAIJAKQDAQUGaGVpZ2h0BQNuaWwFA1NFUAENa2V5TGFzdEhlaWdodAEGc3ltYm9sCQCsAgICEiVzJXNfX2xhc3RIZWlnaHRfXwUGc3ltYm9sARBrZXlQcmljZUJ5SGVpZ2h0AgZzeW1ib2wBaAkAuQkCCQDMCAICF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lZHMgMjEJAQUkZjBfMgIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIJAQUkZjBfMQIFBSRhY2MwAAAAAQACAAMABAAFAAYABwAIAAkACgALAAwADQAOAA8AEAARABIAEwAUABUJAJQKAgUDbmlsCQCWCgQFBXByaWNlBQhwcmljZUF2ZwgFDG1pbk1heFNUUlVDVAJfMQgFDG1pbk1heFNUUlVDVAJfMgBfgqvE", "chainId": 84, "height": 2423235, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9fj6gJYfu3x5KgBaQh6EChQwRQV7QybNfRRN4eU3SnNk Next: HLAmkic12CEcaCRssiCeCPrWKY4t1KaCpG8KYeytqv9J Diff:
Old | New | Differences | |
---|---|---|---|
58 | 58 | func keyBlackSwarmPrice (h,symbol) = makeString(["%s%s%s%d__isBlocked", symbol, "blackSwarmPrice", toString(h)], SEP) | |
59 | 59 | ||
60 | 60 | ||
61 | + | let DAYMILLIS = 86400000 | |
62 | + | ||
63 | + | let H4MILLIS = 14400000 | |
64 | + | ||
65 | + | func toPeriod (timestamp,period) = ((timestamp / period) * period) | |
66 | + | ||
67 | + | ||
68 | + | func keyStats1stPeriod (symbol) = makeString(["%s%s", "stats1stPeriod", symbol], SEP) | |
69 | + | ||
70 | + | ||
71 | + | func keyStatsPriceSum (symbol) = makeString(["%s%s", "statsPriceSum", symbol], SEP) | |
72 | + | ||
73 | + | ||
74 | + | func keyStatsCountSum (symbol) = makeString(["%s%s", "statsCountSum", symbol], SEP) | |
75 | + | ||
76 | + | ||
77 | + | func keyStatsByPeriodPriceSum (symbol,period) = makeString(["%s%s%d", "statsPriceSum", symbol, period], SEP) | |
78 | + | ||
79 | + | ||
80 | + | func keyStatsByPeriodCountSum (symbol,period) = makeString(["%s%s%d", "statsCountSum", symbol, period], SEP) | |
81 | + | ||
82 | + | ||
83 | + | func keyStatsByPeriodMin (symbol,period) = makeString(["%s%s%d", "statsPriceMin", symbol, period], SEP) | |
84 | + | ||
85 | + | ||
86 | + | func keyStatsByPeriodMax (symbol,period) = makeString(["%s%s%d", "statsPriceMax", symbol, period], SEP) | |
87 | + | ||
88 | + | ||
89 | + | func StatsEntry (symbol,price) = { | |
90 | + | let period = toPeriod(lastBlock.timestamp, H4MILLIS) | |
91 | + | let periodStr = toString(period) | |
92 | + | let stats1stPeriodKEY = keyStats1stPeriod(symbol) | |
93 | + | let statsPriceSumKEY = keyStatsPriceSum(symbol) | |
94 | + | let statsCountSumKEY = keyStatsCountSum(symbol) | |
95 | + | let statsByPeriodPriceSumKEY = keyStatsByPeriodPriceSum(symbol, periodStr) | |
96 | + | let statsByPeriodCountSumKEY = keyStatsByPeriodCountSum(symbol, periodStr) | |
97 | + | let statsByPeriodMinKEY = keyStatsByPeriodMin(symbol, periodStr) | |
98 | + | let statsByPeriodMaxKEY = keyStatsByPeriodMax(symbol, periodStr) | |
99 | + | let statsPriceSum = parseBigIntValue(valueOrElse(getString(this, statsPriceSumKEY), "0")) | |
100 | + | let statsCountSum = valueOrElse(getInteger(this, statsCountSumKEY), 0) | |
101 | + | let statsByPeriodMin = valueOrElse(getInteger(this, statsByPeriodMinKEY), 9223372036854775) | |
102 | + | let statsByPeriodMax = valueOrElse(getInteger(this, statsByPeriodMaxKEY), 0) | |
103 | + | let newStatsPriceSum = (statsPriceSum + toBigInt(price)) | |
104 | + | let newStatsCountSum = (statsCountSum + 1) | |
105 | + | let newStatsByPeriodPriceSum = newStatsPriceSum | |
106 | + | let newStatsByPeriodCountSum = newStatsCountSum | |
107 | + | let newStatsByPeriodMin = min([statsByPeriodMin, price]) | |
108 | + | let newStatsByPeriodMax = max([statsByPeriodMax, price]) | |
109 | + | let stats1stPeriod = valueOrElse(getInteger(this, stats1stPeriodKEY), -1) | |
110 | + | ([StringEntry(statsPriceSumKEY, toString(newStatsPriceSum)), IntegerEntry(statsCountSumKEY, newStatsCountSum), StringEntry(statsByPeriodPriceSumKEY, toString(newStatsByPeriodPriceSum)), IntegerEntry(statsByPeriodCountSumKEY, newStatsByPeriodCountSum), IntegerEntry(statsByPeriodMinKEY, newStatsByPeriodMin), IntegerEntry(statsByPeriodMaxKEY, newStatsByPeriodMax)] ++ (if ((0 > stats1stPeriod)) | |
111 | + | then [IntegerEntry(stats1stPeriodKEY, period)] | |
112 | + | else nil)) | |
113 | + | } | |
114 | + | ||
115 | + | ||
61 | 116 | func isGroupFinalaized (groupNum,finHeightStr) = isDefined(getBoolean(this, keyGroupStatus(groupNum, finHeightStr))) | |
62 | 117 | ||
63 | 118 | ||
92 | 147 | ||
93 | 148 | ||
94 | 149 | func throwBlockedError () = throw("contract is blocked by EMERGENCY SHUTDOWN action") | |
150 | + | ||
151 | + | ||
152 | + | func PriceEntry (symbol,newPrice,isMarketOpened) = { | |
153 | + | let idx = valueOrElse(getInteger(this, keyIdx(symbol)), 0) | |
154 | + | let newIdx = (idx + 1) | |
155 | + | [IntegerEntry(keyPrice(symbol), newPrice), IntegerEntry(keyLastHeight(symbol), height), IntegerEntry(keyPriceByHeight(symbol, height), newPrice), IntegerEntry(keyIdx(symbol), newIdx), IntegerEntry(keyIdx2Height(symbol, newIdx), height), IntegerEntry(keyHeight2Idx(symbol, height), newIdx), BooleanEntry(keyIsMarketOpened(symbol), isMarketOpened)] | |
156 | + | } | |
157 | + | ||
158 | + | ||
159 | + | func finalizeUsdnUsdtOnchain () = { | |
160 | + | let symbol = "USDN-USDT" | |
161 | + | let usdnId = "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT" | |
162 | + | let usdtId = "5Sh9KghfkZyhjwuodovDhB6PghDUGBHiAPZ4MkrPgKtX" | |
163 | + | let usdnAmount = 1000000000 | |
164 | + | let wxPoolAddressStr = "3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT" | |
165 | + | let wxPoolAddress = addressFromStringValue(wxPoolAddressStr) | |
166 | + | let $t075807719 = { | |
167 | + | let @ = invoke(wxPoolAddress, "putOneTknV2WithBonusREADONLY", [usdnAmount, usdnId], nil) | |
168 | + | if ($isInstanceOf(@, "(Int, Int, Int)")) | |
169 | + | then @ | |
170 | + | else throw(($getType(@) + " couldn't be cast to (Int, Int, Int)")) | |
171 | + | } | |
172 | + | let lpAmount = $t075807719._1 | |
173 | + | let feeAmount1 = $t075807719._2 | |
174 | + | let bonus = $t075807719._3 | |
175 | + | let $t077227840 = { | |
176 | + | let @ = invoke(wxPoolAddress, "getOneTknV2READONLY", [usdtId, lpAmount], nil) | |
177 | + | if ($isInstanceOf(@, "(Int, Int)")) | |
178 | + | then @ | |
179 | + | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
180 | + | } | |
181 | + | let usdtAmount = $t077227840._1 | |
182 | + | let feeAmount2 = $t077227840._2 | |
183 | + | let newPrice = fraction(usdtAmount, 1000000, usdnAmount) | |
184 | + | (PriceEntry(symbol, newPrice, true) ++ StatsEntry(symbol, newPrice)) | |
185 | + | } | |
95 | 186 | ||
96 | 187 | ||
97 | 188 | func finalizePriceV2Common (position,groupNum,groupDataStr,msgArray,signs) = { | |
139 | 230 | if ((verificationsCount >= minConsensus)) | |
140 | 231 | then { | |
141 | 232 | let price = valueOrElse(getInteger(this, keyPrice(symbol)), 0) | |
142 | - | let idx = valueOrElse(getInteger(this, keyIdx(symbol)), 0) | |
143 | 233 | if (if ((price != 0)) | |
144 | 234 | then if ((newPrice >= (price + ((price * percentPriceOffset) / 100)))) | |
145 | 235 | then true | |
149 | 239 | let reason = "automatic emergency shutdown because of large price variability" | |
150 | 240 | [BooleanEntry(keyIsBlocked(symbol), true), StringEntry(keyIsBlockedSender(symbol), toString(this)), StringEntry(keyIsBlockedReason(symbol), reason), IntegerEntry(keyBlackSwarmPrice(height, symbol), newPrice)] | |
151 | 241 | } | |
152 | - | else { | |
153 | - | let newIdx = (idx + 1) | |
154 | - | [IntegerEntry(keyPrice(symbol), newPrice), IntegerEntry(keyLastHeight(symbol), height), IntegerEntry(keyPriceByHeight(symbol, height), newPrice), IntegerEntry(keyIdx(symbol), newIdx), IntegerEntry(keyIdx2Height(symbol, newIdx), height), IntegerEntry(keyHeight2Idx(symbol, height), newIdx), BooleanEntry(keyIsMarketOpened(symbol), isMarketOpened)] | |
155 | - | } | |
242 | + | else (PriceEntry(symbol, newPrice, isMarketOpened) ++ StatsEntry(symbol, newPrice)) | |
156 | 243 | } | |
157 | 244 | else PriceFailedResult(symbol, ((((((((("verificationsCount = " + toString(verificationsCount)) + "signs0.length=") + toString(size(signs))) + " msg0 = ") + priceMsgStr) + " sig0 = ") + toBase58String(sig0)) + " key0 = ") + pubKeyOraclesList[0])) | |
158 | 245 | } | |
189 | 276 | let msgArray = split(msg, ProtocolSEP) | |
190 | 277 | if (((size(msgArray) % 3) != 0)) | |
191 | 278 | then throw(("msg parameters count must be multiple of 3: msgArray.size=" + toString(size(msg)))) | |
192 | - | else ((((finalizePriceV2Common(0, groupNum, groupDataStr, msgArray, signs0) ++ finalizePriceV2Common(1, groupNum, groupDataStr, msgArray, signs1)) ++ finalizePriceV2Common(2, groupNum, groupDataStr, msgArray, signs2)) ++ | |
279 | + | else ((((finalizePriceV2Common(0, groupNum, groupDataStr, msgArray, signs0) ++ finalizePriceV2Common(1, groupNum, groupDataStr, msgArray, signs1)) ++ finalizePriceV2Common(2, groupNum, groupDataStr, msgArray, signs2)) ++ finalizeUsdnUsdtOnchain()) :+ BooleanEntry(keyGroupStatus(groupNum, finHeightStr), true)) | |
193 | 280 | } | |
194 | 281 | } | |
195 | 282 | ||
196 | 283 | ||
197 | 284 | ||
198 | 285 | @Callable(i) | |
199 | - | func price (hours) = $Tuple2(nil, $Tuple4(979527, 973333, 972222, 979999)) | |
286 | + | func price (hours) = { | |
287 | + | let symbol = "USDN-USDT" | |
288 | + | let periodSTEP = H4MILLIS | |
289 | + | let maxHours = 80 | |
290 | + | let iters = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] | |
291 | + | if ((hours > maxHours)) | |
292 | + | then throw("hours is greater then max 80") | |
293 | + | else if ((4 > hours)) | |
294 | + | then throw("hours is less then min value 4") | |
295 | + | else { | |
296 | + | let currTime = lastBlock.timestamp | |
297 | + | let startTime = ((currTime - (hours * 3600000)) - H4MILLIS) | |
298 | + | let period = toPeriod(currTime, periodSTEP) | |
299 | + | let periodStr = toString(period) | |
300 | + | let smallestPeriod = getIntegerValue(this, keyStats1stPeriod(symbol)) | |
301 | + | let startPeriodTmp = toPeriod(startTime, periodSTEP) | |
302 | + | let isEnoughData = (startPeriodTmp >= smallestPeriod) | |
303 | + | let startPeriod = if (isEnoughData) | |
304 | + | then startPeriodTmp | |
305 | + | else smallestPeriod | |
306 | + | let startPeriodStr = toString(startPeriod) | |
307 | + | let startPriceSumX = parseBigIntValue(getStringValue(this, keyStatsByPeriodPriceSum(symbol, startPeriodStr))) | |
308 | + | let startCountSum = getIntegerValue(this, keyStatsByPeriodCountSum(symbol, startPeriodStr)) | |
309 | + | let endPriceSumX = if (isEnoughData) | |
310 | + | then parseBigIntValue(getStringValue(this, keyStatsByPeriodPriceSum(symbol, periodStr))) | |
311 | + | else toBigInt(0) | |
312 | + | let endCountSum = if (isEnoughData) | |
313 | + | then getIntegerValue(this, keyStatsByPeriodCountSum(symbol, periodStr)) | |
314 | + | else 0 | |
315 | + | let priceSum = toInt((endPriceSumX - startPriceSumX)) | |
316 | + | let priceCount = (endCountSum - startCountSum) | |
317 | + | let priceAvg = (priceSum / priceCount) | |
318 | + | if ((0 >= priceAvg)) | |
319 | + | then throw("calculation error") | |
320 | + | else { | |
321 | + | func findMinMax (minAndMax,nextIdx) = { | |
322 | + | let periodToCheck = (period - (nextIdx * periodSTEP)) | |
323 | + | if ((startPeriod > periodToCheck)) | |
324 | + | then minAndMax | |
325 | + | else { | |
326 | + | let periodToCheckStr = toString(periodToCheck) | |
327 | + | let minVal = minAndMax._1 | |
328 | + | let maxVal = minAndMax._2 | |
329 | + | let newMinVal = getIntegerValue(this, keyStatsByPeriodMin(symbol, periodToCheckStr)) | |
330 | + | let newMaxVal = getIntegerValue(this, keyStatsByPeriodMax(symbol, periodToCheckStr)) | |
331 | + | $Tuple2(min([minVal, newMinVal]), max([maxVal, newMaxVal])) | |
332 | + | } | |
333 | + | } | |
334 | + | ||
335 | + | let price = getIntegerValue(this, keyPrice(symbol)) | |
336 | + | let minMaxSTRUCT = { | |
337 | + | let $l = iters | |
338 | + | let $s = size($l) | |
339 | + | let $acc0 = $Tuple2(9223372036854775, 0) | |
340 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
341 | + | then $a | |
342 | + | else findMinMax($a, $l[$i]) | |
343 | + | ||
344 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
345 | + | then $a | |
346 | + | else throw("List size exceeds 21") | |
347 | + | ||
348 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21) | |
349 | + | } | |
350 | + | $Tuple2(nil, $Tuple4(price, priceAvg, minMaxSTRUCT._1, minMaxSTRUCT._2)) | |
351 | + | } | |
352 | + | } | |
353 | + | } | |
200 | 354 | ||
201 | 355 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ProtocolSEP = ":" | |
5 | 5 | ||
6 | 6 | let SEP = "__" | |
7 | 7 | ||
8 | 8 | let percentPriceOffset = 95 | |
9 | 9 | ||
10 | 10 | func keyPrice (symbol) = ("%s%s__price__" + symbol) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func keyOracles () = "%s%s__config__oracles" | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func keyGroupData (groupNum) = ("%s%d__group__" + groupNum) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func keyMinConsensus () = "%s%s__config__minConsensus" | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func keyPriceFailure (symbol) = makeString(["%s%s%d__finalizationFailure", symbol, toString(height)], SEP) | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func keyLastHeight (symbol) = ("%s%s__lastHeight__" + symbol) | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func keyPriceByHeight (symbol,h) = makeString(["%s%s%d__priceByHeight", symbol, toString(h)], SEP) | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func keyIdx (symbol) = ("%s%s__idxCurrent__" + symbol) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func keyIdx2Height (symbol,idx) = makeString(["%s%s%d__idx2Height", symbol, toString(idx)], SEP) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func keyHeight2Idx (symbol,h) = makeString(["%s%s%d__height2Idx", symbol, toString(h)], SEP) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func keyGroupStatus (groupNum,finHeightStr) = makeString(["%s%d%d__groupStatus", groupNum, finHeightStr], SEP) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func keyIsMarketOpened (symbol) = ("%s%s__isMarketOpened__" + symbol) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func keyEmptyPriceMsg (position) = makeString(["%s%d%d__emptyPriceMsg", toString(height), toString(position)], SEP) | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func keyIsBlocked (symbol) = ("%s%s__isBlocked__" + symbol) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func keyIsBlockedSender (symbol) = makeString(["%s%s%s__isBlocked", symbol, "sender"], SEP) | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func keyIsBlockedReason (symbol) = makeString(["%s%s%s__isBlocked", symbol, "reason"], SEP) | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func keyBlackSwarmPrice (h,symbol) = makeString(["%s%s%s%d__isBlocked", symbol, "blackSwarmPrice", toString(h)], SEP) | |
59 | 59 | ||
60 | 60 | ||
61 | + | let DAYMILLIS = 86400000 | |
62 | + | ||
63 | + | let H4MILLIS = 14400000 | |
64 | + | ||
65 | + | func toPeriod (timestamp,period) = ((timestamp / period) * period) | |
66 | + | ||
67 | + | ||
68 | + | func keyStats1stPeriod (symbol) = makeString(["%s%s", "stats1stPeriod", symbol], SEP) | |
69 | + | ||
70 | + | ||
71 | + | func keyStatsPriceSum (symbol) = makeString(["%s%s", "statsPriceSum", symbol], SEP) | |
72 | + | ||
73 | + | ||
74 | + | func keyStatsCountSum (symbol) = makeString(["%s%s", "statsCountSum", symbol], SEP) | |
75 | + | ||
76 | + | ||
77 | + | func keyStatsByPeriodPriceSum (symbol,period) = makeString(["%s%s%d", "statsPriceSum", symbol, period], SEP) | |
78 | + | ||
79 | + | ||
80 | + | func keyStatsByPeriodCountSum (symbol,period) = makeString(["%s%s%d", "statsCountSum", symbol, period], SEP) | |
81 | + | ||
82 | + | ||
83 | + | func keyStatsByPeriodMin (symbol,period) = makeString(["%s%s%d", "statsPriceMin", symbol, period], SEP) | |
84 | + | ||
85 | + | ||
86 | + | func keyStatsByPeriodMax (symbol,period) = makeString(["%s%s%d", "statsPriceMax", symbol, period], SEP) | |
87 | + | ||
88 | + | ||
89 | + | func StatsEntry (symbol,price) = { | |
90 | + | let period = toPeriod(lastBlock.timestamp, H4MILLIS) | |
91 | + | let periodStr = toString(period) | |
92 | + | let stats1stPeriodKEY = keyStats1stPeriod(symbol) | |
93 | + | let statsPriceSumKEY = keyStatsPriceSum(symbol) | |
94 | + | let statsCountSumKEY = keyStatsCountSum(symbol) | |
95 | + | let statsByPeriodPriceSumKEY = keyStatsByPeriodPriceSum(symbol, periodStr) | |
96 | + | let statsByPeriodCountSumKEY = keyStatsByPeriodCountSum(symbol, periodStr) | |
97 | + | let statsByPeriodMinKEY = keyStatsByPeriodMin(symbol, periodStr) | |
98 | + | let statsByPeriodMaxKEY = keyStatsByPeriodMax(symbol, periodStr) | |
99 | + | let statsPriceSum = parseBigIntValue(valueOrElse(getString(this, statsPriceSumKEY), "0")) | |
100 | + | let statsCountSum = valueOrElse(getInteger(this, statsCountSumKEY), 0) | |
101 | + | let statsByPeriodMin = valueOrElse(getInteger(this, statsByPeriodMinKEY), 9223372036854775) | |
102 | + | let statsByPeriodMax = valueOrElse(getInteger(this, statsByPeriodMaxKEY), 0) | |
103 | + | let newStatsPriceSum = (statsPriceSum + toBigInt(price)) | |
104 | + | let newStatsCountSum = (statsCountSum + 1) | |
105 | + | let newStatsByPeriodPriceSum = newStatsPriceSum | |
106 | + | let newStatsByPeriodCountSum = newStatsCountSum | |
107 | + | let newStatsByPeriodMin = min([statsByPeriodMin, price]) | |
108 | + | let newStatsByPeriodMax = max([statsByPeriodMax, price]) | |
109 | + | let stats1stPeriod = valueOrElse(getInteger(this, stats1stPeriodKEY), -1) | |
110 | + | ([StringEntry(statsPriceSumKEY, toString(newStatsPriceSum)), IntegerEntry(statsCountSumKEY, newStatsCountSum), StringEntry(statsByPeriodPriceSumKEY, toString(newStatsByPeriodPriceSum)), IntegerEntry(statsByPeriodCountSumKEY, newStatsByPeriodCountSum), IntegerEntry(statsByPeriodMinKEY, newStatsByPeriodMin), IntegerEntry(statsByPeriodMaxKEY, newStatsByPeriodMax)] ++ (if ((0 > stats1stPeriod)) | |
111 | + | then [IntegerEntry(stats1stPeriodKEY, period)] | |
112 | + | else nil)) | |
113 | + | } | |
114 | + | ||
115 | + | ||
61 | 116 | func isGroupFinalaized (groupNum,finHeightStr) = isDefined(getBoolean(this, keyGroupStatus(groupNum, finHeightStr))) | |
62 | 117 | ||
63 | 118 | ||
64 | 119 | func readGroupDataOrFail (groupNum) = { | |
65 | 120 | let k = keyGroupData(groupNum) | |
66 | 121 | let groupDataOpt = getString(this, k) | |
67 | 122 | if (isDefined(groupDataOpt)) | |
68 | 123 | then value(groupDataOpt) | |
69 | 124 | else throw(("empty group data for key=" + k)) | |
70 | 125 | } | |
71 | 126 | ||
72 | 127 | ||
73 | 128 | let pubKeyOraclesList = split(getStringValue(this, keyOracles()), ",") | |
74 | 129 | ||
75 | 130 | let oracleCount = size(pubKeyOraclesList) | |
76 | 131 | ||
77 | 132 | let minConsensus = valueOrElse(getInteger(this, keyMinConsensus()), 3) | |
78 | 133 | ||
79 | 134 | func PriceFailedResult (symbol,msg) = [StringEntry(keyPriceFailure(symbol), msg)] | |
80 | 135 | ||
81 | 136 | ||
82 | 137 | func throwInvalidFinalizationHeight (finHeightStr) = throw(((("invalid finalization height: height=" + toString(height)) + " finalizationHeight=") + finHeightStr)) | |
83 | 138 | ||
84 | 139 | ||
85 | 140 | func throwGroupAlreadyFinalized (groupNum,finHeightStr) = throw((((("prices for groupNum=" + groupNum) + " at ") + finHeightStr) + " height have been already finalized")) | |
86 | 141 | ||
87 | 142 | ||
88 | 143 | func throwInvalidSignsParamLength (num,param) = throw(((((("invalid signs" + toString(num)) + " parameter: actual.size=") + toString(size(param))) + " base58Val=") + toBase58String(param))) | |
89 | 144 | ||
90 | 145 | ||
91 | 146 | func throwOutOfTurnFinalization () = throw(((("Out of turn finalization: " + toString(height)) + " block should be finalize by ") + pubKeyOraclesList[(height % oracleCount)])) | |
92 | 147 | ||
93 | 148 | ||
94 | 149 | func throwBlockedError () = throw("contract is blocked by EMERGENCY SHUTDOWN action") | |
150 | + | ||
151 | + | ||
152 | + | func PriceEntry (symbol,newPrice,isMarketOpened) = { | |
153 | + | let idx = valueOrElse(getInteger(this, keyIdx(symbol)), 0) | |
154 | + | let newIdx = (idx + 1) | |
155 | + | [IntegerEntry(keyPrice(symbol), newPrice), IntegerEntry(keyLastHeight(symbol), height), IntegerEntry(keyPriceByHeight(symbol, height), newPrice), IntegerEntry(keyIdx(symbol), newIdx), IntegerEntry(keyIdx2Height(symbol, newIdx), height), IntegerEntry(keyHeight2Idx(symbol, height), newIdx), BooleanEntry(keyIsMarketOpened(symbol), isMarketOpened)] | |
156 | + | } | |
157 | + | ||
158 | + | ||
159 | + | func finalizeUsdnUsdtOnchain () = { | |
160 | + | let symbol = "USDN-USDT" | |
161 | + | let usdnId = "25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT" | |
162 | + | let usdtId = "5Sh9KghfkZyhjwuodovDhB6PghDUGBHiAPZ4MkrPgKtX" | |
163 | + | let usdnAmount = 1000000000 | |
164 | + | let wxPoolAddressStr = "3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT" | |
165 | + | let wxPoolAddress = addressFromStringValue(wxPoolAddressStr) | |
166 | + | let $t075807719 = { | |
167 | + | let @ = invoke(wxPoolAddress, "putOneTknV2WithBonusREADONLY", [usdnAmount, usdnId], nil) | |
168 | + | if ($isInstanceOf(@, "(Int, Int, Int)")) | |
169 | + | then @ | |
170 | + | else throw(($getType(@) + " couldn't be cast to (Int, Int, Int)")) | |
171 | + | } | |
172 | + | let lpAmount = $t075807719._1 | |
173 | + | let feeAmount1 = $t075807719._2 | |
174 | + | let bonus = $t075807719._3 | |
175 | + | let $t077227840 = { | |
176 | + | let @ = invoke(wxPoolAddress, "getOneTknV2READONLY", [usdtId, lpAmount], nil) | |
177 | + | if ($isInstanceOf(@, "(Int, Int)")) | |
178 | + | then @ | |
179 | + | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
180 | + | } | |
181 | + | let usdtAmount = $t077227840._1 | |
182 | + | let feeAmount2 = $t077227840._2 | |
183 | + | let newPrice = fraction(usdtAmount, 1000000, usdnAmount) | |
184 | + | (PriceEntry(symbol, newPrice, true) ++ StatsEntry(symbol, newPrice)) | |
185 | + | } | |
95 | 186 | ||
96 | 187 | ||
97 | 188 | func finalizePriceV2Common (position,groupNum,groupDataStr,msgArray,signs) = { | |
98 | 189 | let msgOffset = (position * 3) | |
99 | 190 | if ((msgOffset >= size(msgArray))) | |
100 | 191 | then [StringEntry(keyEmptyPriceMsg(position), "price data is empty")] | |
101 | 192 | else { | |
102 | 193 | let symbol = msgArray[(msgOffset + 0)] | |
103 | 194 | let newPriceStr = msgArray[(msgOffset + 1)] | |
104 | 195 | let isMarketOpenedStr = msgArray[(msgOffset + 2)] | |
105 | 196 | let newPriceOpt = parseInt(newPriceStr) | |
106 | 197 | let isMarketOpenedOpt = parseInt(isMarketOpenedStr) | |
107 | 198 | let sig0 = take(signs, 64) | |
108 | 199 | let sig1 = take(drop(signs, 64), 64) | |
109 | 200 | let sig2 = take(drop(signs, 128), 64) | |
110 | 201 | let sig3 = take(drop(signs, 192), 64) | |
111 | 202 | let sig4 = takeRight(signs, 64) | |
112 | 203 | let isBlocked = valueOrElse(getBoolean(this, keyIsBlocked(symbol)), false) | |
113 | 204 | if ((symbol == "")) | |
114 | 205 | then nil | |
115 | 206 | else if (isBlocked) | |
116 | 207 | then PriceFailedResult(symbol, (symbol + " is blocked")) | |
117 | 208 | else if (contains(groupDataStr, symbol)) | |
118 | 209 | then if (if (isDefined(newPriceOpt)) | |
119 | 210 | then isDefined(isMarketOpenedOpt) | |
120 | 211 | else false) | |
121 | 212 | then { | |
122 | 213 | let newPrice = value(newPriceOpt) | |
123 | 214 | let isMarketOpened = if ((value(isMarketOpenedOpt) == 1)) | |
124 | 215 | then true | |
125 | 216 | else false | |
126 | 217 | let priceMsgStr = makeString(["WAVES-DORA2", groupNum, toString(height), symbol, newPriceStr, isMarketOpenedStr], ProtocolSEP) | |
127 | 218 | let priceMsg = toBytes(priceMsgStr) | |
128 | 219 | let verificationsCount = (((((if (sigVerify_8Kb(priceMsg, sig0, fromBase58String(pubKeyOraclesList[0]))) | |
129 | 220 | then 1 | |
130 | 221 | else 0) + (if (sigVerify_8Kb(priceMsg, sig1, fromBase58String(pubKeyOraclesList[1]))) | |
131 | 222 | then 1 | |
132 | 223 | else 0)) + (if (sigVerify_8Kb(priceMsg, sig2, fromBase58String(pubKeyOraclesList[2]))) | |
133 | 224 | then 1 | |
134 | 225 | else 0)) + (if (sigVerify_8Kb(priceMsg, sig3, fromBase58String(pubKeyOraclesList[3]))) | |
135 | 226 | then 1 | |
136 | 227 | else 0)) + (if (sigVerify_8Kb(priceMsg, sig4, fromBase58String(pubKeyOraclesList[4]))) | |
137 | 228 | then 1 | |
138 | 229 | else 0)) | |
139 | 230 | if ((verificationsCount >= minConsensus)) | |
140 | 231 | then { | |
141 | 232 | let price = valueOrElse(getInteger(this, keyPrice(symbol)), 0) | |
142 | - | let idx = valueOrElse(getInteger(this, keyIdx(symbol)), 0) | |
143 | 233 | if (if ((price != 0)) | |
144 | 234 | then if ((newPrice >= (price + ((price * percentPriceOffset) / 100)))) | |
145 | 235 | then true | |
146 | 236 | else ((price - ((price * percentPriceOffset) / 100)) >= newPrice) | |
147 | 237 | else false) | |
148 | 238 | then { | |
149 | 239 | let reason = "automatic emergency shutdown because of large price variability" | |
150 | 240 | [BooleanEntry(keyIsBlocked(symbol), true), StringEntry(keyIsBlockedSender(symbol), toString(this)), StringEntry(keyIsBlockedReason(symbol), reason), IntegerEntry(keyBlackSwarmPrice(height, symbol), newPrice)] | |
151 | 241 | } | |
152 | - | else { | |
153 | - | let newIdx = (idx + 1) | |
154 | - | [IntegerEntry(keyPrice(symbol), newPrice), IntegerEntry(keyLastHeight(symbol), height), IntegerEntry(keyPriceByHeight(symbol, height), newPrice), IntegerEntry(keyIdx(symbol), newIdx), IntegerEntry(keyIdx2Height(symbol, newIdx), height), IntegerEntry(keyHeight2Idx(symbol, height), newIdx), BooleanEntry(keyIsMarketOpened(symbol), isMarketOpened)] | |
155 | - | } | |
242 | + | else (PriceEntry(symbol, newPrice, isMarketOpened) ++ StatsEntry(symbol, newPrice)) | |
156 | 243 | } | |
157 | 244 | else PriceFailedResult(symbol, ((((((((("verificationsCount = " + toString(verificationsCount)) + "signs0.length=") + toString(size(signs))) + " msg0 = ") + priceMsgStr) + " sig0 = ") + toBase58String(sig0)) + " key0 = ") + pubKeyOraclesList[0])) | |
158 | 245 | } | |
159 | 246 | else PriceFailedResult(symbol, ((("data parsing error: newPrice=" + newPriceStr) + " isMarketOpened=") + isMarketOpenedStr)) | |
160 | 247 | else PriceFailedResult(symbol, ((symbol + " doesn't exist in group: groupDataStr=") + groupDataStr)) | |
161 | 248 | } | |
162 | 249 | } | |
163 | 250 | ||
164 | 251 | ||
165 | 252 | @Callable(i) | |
166 | 253 | func finalizeDORA2 (header,msg,signs0,signs1,signs2,signs3) = { | |
167 | 254 | let headerArray = split(header, ProtocolSEP) | |
168 | 255 | let groupNum = headerArray[1] | |
169 | 256 | let finHeightStr = headerArray[2] | |
170 | 257 | let finHeight = parseIntValue(finHeightStr) | |
171 | 258 | let signsLength = (64 * oracleCount) | |
172 | 259 | if ((height != finHeight)) | |
173 | 260 | then throwInvalidFinalizationHeight(finHeightStr) | |
174 | 261 | else if (isGroupFinalaized(groupNum, finHeightStr)) | |
175 | 262 | then throwGroupAlreadyFinalized(groupNum, finHeightStr) | |
176 | 263 | else if ((pubKeyOraclesList[(height % oracleCount)] != toBase58String(i.callerPublicKey))) | |
177 | 264 | then throwOutOfTurnFinalization() | |
178 | 265 | else if ((size(signs0) != signsLength)) | |
179 | 266 | then throwInvalidSignsParamLength(0, signs0) | |
180 | 267 | else if ((size(signs1) != signsLength)) | |
181 | 268 | then throwInvalidSignsParamLength(1, signs1) | |
182 | 269 | else if ((size(signs2) != signsLength)) | |
183 | 270 | then throwInvalidSignsParamLength(2, signs2) | |
184 | 271 | else if ((size(signs3) != signsLength)) | |
185 | 272 | then throwInvalidSignsParamLength(3, signs3) | |
186 | 273 | else { | |
187 | 274 | let groupDataKey = keyGroupData(groupNum) | |
188 | 275 | let groupDataStr = valueOrErrorMessage(getString(this, groupDataKey), ("empty group data for key=" + groupDataKey)) | |
189 | 276 | let msgArray = split(msg, ProtocolSEP) | |
190 | 277 | if (((size(msgArray) % 3) != 0)) | |
191 | 278 | then throw(("msg parameters count must be multiple of 3: msgArray.size=" + toString(size(msg)))) | |
192 | - | else ((((finalizePriceV2Common(0, groupNum, groupDataStr, msgArray, signs0) ++ finalizePriceV2Common(1, groupNum, groupDataStr, msgArray, signs1)) ++ finalizePriceV2Common(2, groupNum, groupDataStr, msgArray, signs2)) ++ | |
279 | + | else ((((finalizePriceV2Common(0, groupNum, groupDataStr, msgArray, signs0) ++ finalizePriceV2Common(1, groupNum, groupDataStr, msgArray, signs1)) ++ finalizePriceV2Common(2, groupNum, groupDataStr, msgArray, signs2)) ++ finalizeUsdnUsdtOnchain()) :+ BooleanEntry(keyGroupStatus(groupNum, finHeightStr), true)) | |
193 | 280 | } | |
194 | 281 | } | |
195 | 282 | ||
196 | 283 | ||
197 | 284 | ||
198 | 285 | @Callable(i) | |
199 | - | func price (hours) = $Tuple2(nil, $Tuple4(979527, 973333, 972222, 979999)) | |
286 | + | func price (hours) = { | |
287 | + | let symbol = "USDN-USDT" | |
288 | + | let periodSTEP = H4MILLIS | |
289 | + | let maxHours = 80 | |
290 | + | let iters = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] | |
291 | + | if ((hours > maxHours)) | |
292 | + | then throw("hours is greater then max 80") | |
293 | + | else if ((4 > hours)) | |
294 | + | then throw("hours is less then min value 4") | |
295 | + | else { | |
296 | + | let currTime = lastBlock.timestamp | |
297 | + | let startTime = ((currTime - (hours * 3600000)) - H4MILLIS) | |
298 | + | let period = toPeriod(currTime, periodSTEP) | |
299 | + | let periodStr = toString(period) | |
300 | + | let smallestPeriod = getIntegerValue(this, keyStats1stPeriod(symbol)) | |
301 | + | let startPeriodTmp = toPeriod(startTime, periodSTEP) | |
302 | + | let isEnoughData = (startPeriodTmp >= smallestPeriod) | |
303 | + | let startPeriod = if (isEnoughData) | |
304 | + | then startPeriodTmp | |
305 | + | else smallestPeriod | |
306 | + | let startPeriodStr = toString(startPeriod) | |
307 | + | let startPriceSumX = parseBigIntValue(getStringValue(this, keyStatsByPeriodPriceSum(symbol, startPeriodStr))) | |
308 | + | let startCountSum = getIntegerValue(this, keyStatsByPeriodCountSum(symbol, startPeriodStr)) | |
309 | + | let endPriceSumX = if (isEnoughData) | |
310 | + | then parseBigIntValue(getStringValue(this, keyStatsByPeriodPriceSum(symbol, periodStr))) | |
311 | + | else toBigInt(0) | |
312 | + | let endCountSum = if (isEnoughData) | |
313 | + | then getIntegerValue(this, keyStatsByPeriodCountSum(symbol, periodStr)) | |
314 | + | else 0 | |
315 | + | let priceSum = toInt((endPriceSumX - startPriceSumX)) | |
316 | + | let priceCount = (endCountSum - startCountSum) | |
317 | + | let priceAvg = (priceSum / priceCount) | |
318 | + | if ((0 >= priceAvg)) | |
319 | + | then throw("calculation error") | |
320 | + | else { | |
321 | + | func findMinMax (minAndMax,nextIdx) = { | |
322 | + | let periodToCheck = (period - (nextIdx * periodSTEP)) | |
323 | + | if ((startPeriod > periodToCheck)) | |
324 | + | then minAndMax | |
325 | + | else { | |
326 | + | let periodToCheckStr = toString(periodToCheck) | |
327 | + | let minVal = minAndMax._1 | |
328 | + | let maxVal = minAndMax._2 | |
329 | + | let newMinVal = getIntegerValue(this, keyStatsByPeriodMin(symbol, periodToCheckStr)) | |
330 | + | let newMaxVal = getIntegerValue(this, keyStatsByPeriodMax(symbol, periodToCheckStr)) | |
331 | + | $Tuple2(min([minVal, newMinVal]), max([maxVal, newMaxVal])) | |
332 | + | } | |
333 | + | } | |
334 | + | ||
335 | + | let price = getIntegerValue(this, keyPrice(symbol)) | |
336 | + | let minMaxSTRUCT = { | |
337 | + | let $l = iters | |
338 | + | let $s = size($l) | |
339 | + | let $acc0 = $Tuple2(9223372036854775, 0) | |
340 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
341 | + | then $a | |
342 | + | else findMinMax($a, $l[$i]) | |
343 | + | ||
344 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
345 | + | then $a | |
346 | + | else throw("List size exceeds 21") | |
347 | + | ||
348 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21) | |
349 | + | } | |
350 | + | $Tuple2(nil, $Tuple4(price, priceAvg, minMaxSTRUCT._1, minMaxSTRUCT._2)) | |
351 | + | } | |
352 | + | } | |
353 | + | } | |
200 | 354 | ||
201 | 355 |
github/deemru/w8io/026f985 52.38 ms ◑