tx · Ha51a6tmTwi8QBQAPQiLmMvVdmnNyQRYii4b7W4iV2Gp 3Mvsbd5G4Xoyy4ib7gLCVSix21CyMr4K7jb: -0.01500000 Waves 2023.07.26 17:26 [2682949] smart account 3Mvsbd5G4Xoyy4ib7gLCVSix21CyMr4K7jb > SELF 0.00000000 Waves
{ "type": 13, "id": "Ha51a6tmTwi8QBQAPQiLmMvVdmnNyQRYii4b7W4iV2Gp", "fee": 1500000, "feeAssetId": null, "timestamp": 1690381585737, "version": 2, "chainId": 84, "sender": "3Mvsbd5G4Xoyy4ib7gLCVSix21CyMr4K7jb", "senderPublicKey": "8fnW16MobFGpeokNqZLUEqPaJUXn5zaSGf4ch9A3Ctk7", "proofs": [ "4eTXWABjm9UWPQUVfag5X8QAuAZvg1p6hY1VnLiwCsPuudWP2ofA7o9UuneBxDFNcBw3ChwnFeE8jvdr3QqHjwzs" ], "script": "base64:BgIfCAISAwoBARIAEgMKAQgSAwoBARIDCgEIEgASAwoBCC4ADGNvbnRyYWN0RmlsZQIRbDJtcF9zdGFraW5nLnJpZGUAA1NFUAICX18ABnNjYWxlOACAwtcvABJBRERSRVNTX0JZVEVTX1NJWkUAGgANQkxPQ0tTX0lOX0RBWQCgCwEIdGhyb3dFcnIBA21zZwkAAgEJAKwCAgkArAICBQxjb250cmFjdEZpbGUCAjogBQNtc2cACmtleUFzc2V0SWQJALkJAgkAzAgCAgIlcwkAzAgCAgdhc3NldElkBQNuaWwFA1NFUAATa2V5RW1pc3Npb25QZXJCbG9jawkAuQkCCQDMCAICAiVzCQDMCAICEGVtaXNzaW9uUGVyQmxvY2sFA25pbAUDU0VQABlrZXlFbWlzc2lvblBlcmlvZEluQmxvY2tzCQC5CQIJAMwIAgICJXMJAMwIAgIWZW1pc3Npb25QZXJpb2RJbkJsb2NrcwUDbmlsBQNTRVAADWtleVN0YXJ0QmxvY2sJALkJAgkAzAgCAgIlcwkAzAgCAgpzdGFydEJsb2NrBQNuaWwFA1NFUAAQa2V5VG90YWxM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IGlzIGFscmVhZHkgYWxsb3dlZAUDbmlsAwkAAAIFA2VycgUDZXJyCQEMdm90ZUlOVEVSTkFMBAUTY2FsbGVyQWRkcmVzc1N0cmluZwUJa2V5UHJlZml4BQZRVU9SVU0FBnJlc3VsdAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAECGJ5QWRtaW5zCQAAAggFAnR4AmlkCQDZBAEJAQt2YWx1ZU9yRWxzZQIJAJ0IAgUEdGhpcwkBDmtleUFsbG93ZWRUeElkAAIABAdieU93bmVyAwkAZwIJAJADAQkBDWdldEFkbWluc0xpc3QABQZRVU9SVU0HCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5AwUIYnlBZG1pbnMGBQdieU93bmVyDjHUaQ==", "height": 2682949, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: BHEjHgmBh55akQ9VE6ibfAYhfiSwqmW8uNYMb2gh8n63 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let contractFile = "l2mp_staking.ride" | |
5 | + | ||
6 | + | let SEP = "__" | |
7 | + | ||
8 | + | let scale8 = 100000000 | |
9 | + | ||
10 | + | let ADDRESS_BYTES_SIZE = 26 | |
11 | + | ||
12 | + | let BLOCKS_IN_DAY = 1440 | |
13 | + | ||
14 | + | func throwErr (msg) = throw(((contractFile + ": ") + msg)) | |
15 | + | ||
16 | + | ||
17 | + | let keyAssetId = makeString(["%s", "assetId"], SEP) | |
18 | + | ||
19 | + | let keyEmissionPerBlock = makeString(["%s", "emissionPerBlock"], SEP) | |
20 | + | ||
21 | + | let keyEmissionPeriodInBlocks = makeString(["%s", "emissionPeriodInBlocks"], SEP) | |
22 | + | ||
23 | + | let keyStartBlock = makeString(["%s", "startBlock"], SEP) | |
24 | + | ||
25 | + | let keyTotalLpAmount = makeString(["%s", "totalLpAmount"], SEP) | |
26 | + | ||
27 | + | let keyTotalAssetAmount = makeString(["%s", "totalAssetAmount"], SEP) | |
28 | + | ||
29 | + | func keyUserLpAmount (userAddress) = makeString(["%s%s", "userLpAmount", userAddress], SEP) | |
30 | + | ||
31 | + | ||
32 | + | func keyUserTotalAssetWithdrawn (userAddress) = makeString(["%s%s", "totalAssetWithdrawn", userAddress], SEP) | |
33 | + | ||
34 | + | ||
35 | + | func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP) | |
36 | + | ||
37 | + | ||
38 | + | let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0) | |
39 | + | ||
40 | + | let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0) | |
41 | + | ||
42 | + | let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES") | |
43 | + | ||
44 | + | let assetIdBytes = if ((assetIdString == "WAVES")) | |
45 | + | then unit | |
46 | + | else fromBase58String(assetIdString) | |
47 | + | ||
48 | + | let emissionPeriodInBlocks = valueOrElse(getInteger(this, keyEmissionPeriodInBlocks), BLOCKS_IN_DAY) | |
49 | + | ||
50 | + | let emissionPerPeriod = (valueOrElse(getInteger(this, keyEmissionPerBlock), 0) * emissionPeriodInBlocks) | |
51 | + | ||
52 | + | let heightInPeriods = fraction(height, 1, emissionPeriodInBlocks) | |
53 | + | ||
54 | + | let ADMIN_LIST_SIZE = 5 | |
55 | + | ||
56 | + | let QUORUM = 3 | |
57 | + | ||
58 | + | let TXID_BYTES_LENGTH = 32 | |
59 | + | ||
60 | + | func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP) | |
61 | + | ||
62 | + | ||
63 | + | func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP) | |
64 | + | ||
65 | + | ||
66 | + | func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP) | |
67 | + | ||
68 | + | ||
69 | + | func keyAllowedTxId () = makeString(["%s", "txId"], SEP) | |
70 | + | ||
71 | + | ||
72 | + | func getAdminVote (prefix,admin) = { | |
73 | + | let voteKey = keyFullAdminVote(prefix, admin) | |
74 | + | valueOrElse(getInteger(voteKey), 0) | |
75 | + | } | |
76 | + | ||
77 | + | ||
78 | + | func getAdminsList () = match getString(this, keyAdminAddressList()) { | |
79 | + | case s: String => | |
80 | + | split(s, SEP) | |
81 | + | case _ => | |
82 | + | nil | |
83 | + | } | |
84 | + | ||
85 | + | ||
86 | + | func isInAdminList (address) = containsElement(getAdminsList(), address) | |
87 | + | ||
88 | + | ||
89 | + | func genVotesKeysHelper (a,adminAddress) = { | |
90 | + | let $t026392663 = a | |
91 | + | let result = $t026392663._1 | |
92 | + | let prefix = $t026392663._2 | |
93 | + | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
94 | + | } | |
95 | + | ||
96 | + | ||
97 | + | func genVotesKeys (keyPrefix) = { | |
98 | + | let adminList = keyAdminAddressList() | |
99 | + | let $t028102894 = { | |
100 | + | let $l = getAdminsList() | |
101 | + | let $s = size($l) | |
102 | + | let $acc0 = $Tuple2(nil, keyPrefix) | |
103 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
104 | + | then $a | |
105 | + | else genVotesKeysHelper($a, $l[$i]) | |
106 | + | ||
107 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
108 | + | then $a | |
109 | + | else throw("List size exceeds 5") | |
110 | + | ||
111 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
112 | + | } | |
113 | + | let result = $t028102894._1 | |
114 | + | let prefix = $t028102894._2 | |
115 | + | result | |
116 | + | } | |
117 | + | ||
118 | + | ||
119 | + | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
120 | + | ||
121 | + | ||
122 | + | func countVotes (prefix) = { | |
123 | + | let votes = genVotesKeys(prefix) | |
124 | + | let $l = votes | |
125 | + | let $s = size($l) | |
126 | + | let $acc0 = 0 | |
127 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
128 | + | then $a | |
129 | + | else countVotesHelper($a, $l[$i]) | |
130 | + | ||
131 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
132 | + | then $a | |
133 | + | else throw("List size exceeds 5") | |
134 | + | ||
135 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
136 | + | } | |
137 | + | ||
138 | + | ||
139 | + | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
140 | + | ||
141 | + | ||
142 | + | func getClearVoteEntries (prefix) = { | |
143 | + | let votes = genVotesKeys(prefix) | |
144 | + | let $l = votes | |
145 | + | let $s = size($l) | |
146 | + | let $acc0 = nil | |
147 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
148 | + | then $a | |
149 | + | else clearVotesHelper($a, $l[$i]) | |
150 | + | ||
151 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
152 | + | then $a | |
153 | + | else throw("List size exceeds 5") | |
154 | + | ||
155 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
156 | + | } | |
157 | + | ||
158 | + | ||
159 | + | func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = { | |
160 | + | let voteKey = keyFullAdminVote(keyPrefix, callerAddressString) | |
161 | + | let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString) | |
162 | + | let err = if (!(isInAdminList(callerAddressString))) | |
163 | + | then throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
164 | + | else if ((adminCurrentVote == 1)) | |
165 | + | then throwErr((voteKey + " you already voted")) | |
166 | + | else unit | |
167 | + | if ((err == err)) | |
168 | + | then { | |
169 | + | let votes = countVotes(keyPrefix) | |
170 | + | if (((votes + 1) >= minVotes)) | |
171 | + | then { | |
172 | + | let clearVoteEntries = getClearVoteEntries(keyPrefix) | |
173 | + | (clearVoteEntries ++ voteResult) | |
174 | + | } | |
175 | + | else [IntegerEntry(voteKey, 1)] | |
176 | + | } | |
177 | + | else throw("Strict value is not equal to itself.") | |
178 | + | } | |
179 | + | ||
180 | + | ||
181 | + | func calcTotalProfit () = { | |
182 | + | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
183 | + | let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks) | |
184 | + | let elapsedPeriods = (heightInPeriods - startPeriod) | |
185 | + | max([0, (emissionPerPeriod * elapsedPeriods)]) | |
186 | + | } | |
187 | + | ||
188 | + | ||
189 | + | func getTotalAssetAmountWithProfitOrMaxAvailable () = { | |
190 | + | let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit()) | |
191 | + | let totalAmount = match assetIdBytes { | |
192 | + | case u: Unit => | |
193 | + | min([totalAssetAmountWithProfit, wavesBalance(this).available]) | |
194 | + | case b: ByteVector => | |
195 | + | min([totalAssetAmountWithProfit, assetBalance(this, b)]) | |
196 | + | case _ => | |
197 | + | throw("Match error") | |
198 | + | } | |
199 | + | if ((totalLpAmount == 0)) | |
200 | + | then 0 | |
201 | + | else totalAmount | |
202 | + | } | |
203 | + | ||
204 | + | ||
205 | + | func getCurrentPrice () = if ((totalLpAmount != 0)) | |
206 | + | then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), scale8, totalLpAmount) | |
207 | + | else (1 * scale8) | |
208 | + | ||
209 | + | ||
210 | + | func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0) | |
211 | + | ||
212 | + | ||
213 | + | func getUserAvailableAssetsToWithdraw (userAddress) = { | |
214 | + | let userLpAmount = getUserLpAmount(userAddress) | |
215 | + | let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), scale8) | |
216 | + | if ((0 > userAvailableAssetToWithdraw)) | |
217 | + | then 0 | |
218 | + | else userAvailableAssetToWithdraw | |
219 | + | } | |
220 | + | ||
221 | + | ||
222 | + | func getStakeActions (i,userAddress) = { | |
223 | + | let checks = [if ((size(i.payments) == 1)) | |
224 | + | then true | |
225 | + | else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes)) | |
226 | + | then true | |
227 | + | else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0)) | |
228 | + | then true | |
229 | + | else "payment amount should be greater than 0"] | |
230 | + | if ((checks == checks)) | |
231 | + | then { | |
232 | + | let paymentAmount = i.payments[0].amount | |
233 | + | let paymentLpAmount = fraction(paymentAmount, scale8, getCurrentPrice()) | |
234 | + | let userLpAmount = getUserLpAmount(userAddress) | |
235 | + | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
236 | + | let newTotalLpAmount = (totalLpAmount + paymentLpAmount) | |
237 | + | let newTotalAssetAmount = (totalAssetAmount + paymentAmount) | |
238 | + | let newUserLpAmount = (userLpAmount + paymentLpAmount) | |
239 | + | let newUserTotalStakedAmount = (userTotalStakedAmount + paymentAmount) | |
240 | + | let updateStartHeightAction = if ((totalLpAmount == 0)) | |
241 | + | then [IntegerEntry(keyStartBlock, height)] | |
242 | + | else nil | |
243 | + | ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction) | |
244 | + | } | |
245 | + | else throw("Strict value is not equal to itself.") | |
246 | + | } | |
247 | + | ||
248 | + | ||
249 | + | func getWithdrawActions (i,lpAssetWithdrawAmount) = { | |
250 | + | let userAddress = toString(i.caller) | |
251 | + | let userLpAmount = getUserLpAmount(userAddress) | |
252 | + | let check = [if ((lpAssetWithdrawAmount > 0)) | |
253 | + | then true | |
254 | + | else throwErr("LP amount should be more than 0"), if ((userLpAmount >= lpAssetWithdrawAmount)) | |
255 | + | then true | |
256 | + | else throwErr((("cannot withdraw more than available LP (" + toString(userLpAmount)) + ")"))] | |
257 | + | if ((check == check)) | |
258 | + | then { | |
259 | + | let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount) | |
260 | + | let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), scale8) | |
261 | + | let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount) | |
262 | + | let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), scale8) | |
263 | + | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
264 | + | let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount) | |
265 | + | [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
266 | + | } | |
267 | + | else throw("Strict value is not equal to itself.") | |
268 | + | } | |
269 | + | ||
270 | + | ||
271 | + | @Callable(i) | |
272 | + | func setEmissionPerBlock (emissionPerBlock) = { | |
273 | + | let check = [if ((i.caller == this)) | |
274 | + | then true | |
275 | + | else throwErr("permission denied")] | |
276 | + | if ((check == check)) | |
277 | + | then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))] | |
278 | + | else throw("Strict value is not equal to itself.") | |
279 | + | } | |
280 | + | ||
281 | + | ||
282 | + | ||
283 | + | @Callable(i) | |
284 | + | func stake () = getStakeActions(i, toString(i.caller)) | |
285 | + | ||
286 | + | ||
287 | + | ||
288 | + | @Callable(i) | |
289 | + | func stakeFor (userAddress) = { | |
290 | + | let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE)) | |
291 | + | then true | |
292 | + | else throwErr("address is not valid")] | |
293 | + | if ((check == check)) | |
294 | + | then getStakeActions(i, userAddress) | |
295 | + | else throw("Strict value is not equal to itself.") | |
296 | + | } | |
297 | + | ||
298 | + | ||
299 | + | ||
300 | + | @Callable(i) | |
301 | + | func withdraw (withdrawAssetAmount) = { | |
302 | + | let userAddress = toString(i.caller) | |
303 | + | let userLpAmount = getUserLpAmount(userAddress) | |
304 | + | let lpAmountToWithdraw = fraction(withdrawAssetAmount, scale8, getCurrentPrice()) | |
305 | + | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
306 | + | let minWithdrawAssetAmount = fraction(getCurrentPrice(), 1, scale8, CEILING) | |
307 | + | let check = [if ((withdrawAssetAmount > 0)) | |
308 | + | then true | |
309 | + | else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount)) | |
310 | + | then true | |
311 | + | else throwErr((("cannot withdraw more than available (" + toString(userAvailableAssetToWithdraw)) + ")")), if ((withdrawAssetAmount >= minWithdrawAssetAmount)) | |
312 | + | then true | |
313 | + | else throwErr((("withdraw amount is too small. Min: (" + toString(minWithdrawAssetAmount)) + ")"))] | |
314 | + | if ((check == check)) | |
315 | + | then getWithdrawActions(i, lpAmountToWithdraw) | |
316 | + | else throw("Strict value is not equal to itself.") | |
317 | + | } | |
318 | + | ||
319 | + | ||
320 | + | ||
321 | + | @Callable(i) | |
322 | + | func getUserAssetsREADONLY (userAddress) = { | |
323 | + | let userLpAmount = getUserLpAmount(userAddress) | |
324 | + | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
325 | + | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
326 | + | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
327 | + | $Tuple2(nil, $Tuple5(userLpAmount, userAvailableAssetToWithdraw, getCurrentPrice(), userTotalStakedAmount, userTotalAssetWithdrawn)) | |
328 | + | } | |
329 | + | ||
330 | + | ||
331 | + | ||
332 | + | @Callable(i) | |
333 | + | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable(), getCurrentPrice())) | |
334 | + | ||
335 | + | ||
336 | + | ||
337 | + | @Callable(i) | |
338 | + | func voteForTxId (txId) = { | |
339 | + | let callerAddressString = toBase58String(i.caller.bytes) | |
340 | + | let keyPrefix = keyAllowedTxIdVotePrefix(txId) | |
341 | + | let result = [StringEntry(keyAllowedTxId(), txId)] | |
342 | + | let allowedTxIdOption = getString(this, keyAllowedTxId()) | |
343 | + | let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH)) | |
344 | + | then true | |
345 | + | else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit)) | |
346 | + | then true | |
347 | + | else (value(allowedTxIdOption) != txId)) | |
348 | + | then true | |
349 | + | else throwErr((txId + " is already allowed"))] | |
350 | + | if ((err == err)) | |
351 | + | then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result) | |
352 | + | else throw("Strict value is not equal to itself.") | |
353 | + | } | |
354 | + | ||
355 | + | ||
356 | + | @Verifier(tx) | |
357 | + | func verify () = { | |
358 | + | let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), ""))) | |
359 | + | let byOwner = if ((size(getAdminsList()) >= QUORUM)) | |
360 | + | then false | |
361 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
362 | + | if (byAdmins) | |
363 | + | then true | |
364 | + | else byOwner | |
365 | + | } | |
366 | + |
github/deemru/w8io/169f3d6 27.46 ms ◑