tx · 4Xn2yWJ11jtwZGd8bcVyt3yWpasLQ28iRcPNK4MCJsFj 3PFoA1JFDoLWQJ3DqzAHNrrWR4riVuBfHks: -0.01000000 Waves 2022.04.20 12:48 [3082028] smart account 3PFoA1JFDoLWQJ3DqzAHNrrWR4riVuBfHks > SELF 0.00000000 Waves
{ "type": 13, "id": "4Xn2yWJ11jtwZGd8bcVyt3yWpasLQ28iRcPNK4MCJsFj", "fee": 1000000, "feeAssetId": null, "timestamp": 1650448135178, "version": 1, "sender": "3PFoA1JFDoLWQJ3DqzAHNrrWR4riVuBfHks", "senderPublicKey": "5wDXuHuaDELQu1VzL96PvhJeSpJGXHu9W9v3booheS1R", "proofs": [ "5KenwVjFgXbMj4yDoQgKL45mepNppaZ8VY3fTbF2xyXW63ZRVFyetrvBu7hWy5xcXXuYrCxFL7rwKWiTEu6cRAju" ], "script": "base64:AAIFAAAAAAAAAA4IAhIDCgEIEgUKAwgIAQAAAAgBAAAAEHdyaXRlQ29uc3RTdHJpbmcAAAACAAAAA2tleQAAAAV2YWx1ZQMJAQAAAAEhAAAAAQkBAAAACWlzRGVmaW5lZAAAAAEJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5CQEAAAALU3RyaW5nRW50cnkAAAACBQAAAANrZXkFAAAABXZhbHVlCQAAAgAAAAEJAAEsAAAAAgIAAAAVYWxyZWFkeSBpbml0aWFsaXplZDogBQAAAANrZXkAAAAAC2NvbmZpZ1N0b3JlAgAAAAZjb25maWcAAAAADWNvbmZpZ0FkZHJlc3MJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAEJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMFAAAAC2NvbmZpZ1N0b3JlAAAAABJtYXliZU9yYWNsZUFkZHJlc3MEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAANY29uZmlnQWRkcmVzcwIAAAAOb3JhY2xlX2FkZHJlc3MDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN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kcmF3bldpdGhpbkN1cnJlbnRFcG9jaAIAAAAQIGN1cnJlbnQgZXBvY2g6IAkAAaQAAAABBQAAABFjdXJyZW50RXBvY2hTdGFydAIAAAABLQkAAaQAAAABBQAAAA9jdXJyZW50RXBvY2hFbmQJAAUUAAAAAgkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACBQAAAAVzdG9yZQkAASwAAAACCQABLAAAAAIJAAGkAAAAAQUAAAARY3VycmVudEVwb2NoU3RhcnQCAAAAAXwJAAGkAAAAAQkAAGQAAAACBQAAAB91c2VyV2l0aGRyYXduV2l0aGluQ3VycmVudEVwb2NoBQAAAAZhbW91bnQFAAAAA25pbAkAAGUAAAACCQAAZQAAAAIFAAAAA2xtdAUAAAAfdXNlcldpdGhkcmF3bldpdGhpbkN1cnJlbnRFcG9jaAUAAAAGYW1vdW50CQAFFAAAAAIFAAAAA25pbAD//////////wAAAADHHj18", "chainId": 87, "height": 3082028, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FzidwHtWi5zc35JvbRdjVK1kwXbEejDAEge9yV5B1Xr5 Next: Dszrxn96N3zTGY9qbVdwZ9k6gTwHuhxbvBGwqPK4TZ3t Diff:
Old | New | Differences | |
---|---|---|---|
24 | 24 | func limit (assetId) = getInteger(configAddress, (assetId + "_WithdrawLimitAcc")) | |
25 | 25 | ||
26 | 26 | ||
27 | - | func userWithdrawnWithinEpochStore ( | |
27 | + | func userWithdrawnWithinEpochStore (user,assetId) = ((("withdrawn_" + user) + "_") + assetId) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | @Callable(i) | |
34 | 34 | ||
35 | 35 | @Callable(i) | |
36 | 36 | func validateWithdrawLimit (assetId,user,amount) = match limit(assetId) { | |
37 | - | case | |
37 | + | case lmt: Int => | |
38 | 38 | let currentEpochStart = ((HEIGHT / timeframe) * timeframe) | |
39 | 39 | let currentEpochEnd = ((1 + (HEIGHT / timeframe)) * timeframe) | |
40 | - | let store = userWithdrawnWithinEpochStore(currentEpochStart, user, assetId) | |
41 | - | let userWithdrawnWithinTheEpoch = valueOrElse(getInteger(store), 0) | |
42 | - | if (((userWithdrawnWithinTheEpoch + amount) > l)) | |
43 | - | then throw(((((((("breaching withdraw limit per " + toString(l)) + " ") + assetId) + " over ") + toString(timeframe)) + " blocks. Available: ") + toString((l - userWithdrawnWithinTheEpoch)))) | |
44 | - | else $Tuple2([IntegerEntry(store, (userWithdrawnWithinTheEpoch + amount))], (l - userWithdrawnWithinTheEpoch)) | |
40 | + | let store = userWithdrawnWithinEpochStore(user, assetId) | |
41 | + | let $t012941518 = match getString(store) { | |
42 | + | case s: String => | |
43 | + | let data = split(s, "|") | |
44 | + | $Tuple2(parseIntValue(data[0]), parseIntValue(data[1])) | |
45 | + | case _ => | |
46 | + | $Tuple2(0, 0) | |
47 | + | } | |
48 | + | let epoch = $t012941518._1 | |
49 | + | let withdrawn = $t012941518._2 | |
50 | + | let userWithdrawnWithinCurrentEpoch = if ((epoch == currentEpochStart)) | |
51 | + | then withdrawn | |
52 | + | else 0 | |
53 | + | if (((userWithdrawnWithinCurrentEpoch + amount) > lmt)) | |
54 | + | then throw(((((((((((("breaching withdraw limit per " + toString(lmt)) + " ") + assetId) + " over ") + toString(timeframe)) + " blocks. Available: ") + toString((lmt - userWithdrawnWithinCurrentEpoch))) + " current epoch: ") + toString(currentEpochStart)) + "-") + toString(currentEpochEnd))) | |
55 | + | else $Tuple2([StringEntry(store, ((toString(currentEpochStart) + "|") + toString((userWithdrawnWithinCurrentEpoch + amount))))], ((lmt - userWithdrawnWithinCurrentEpoch) - amount)) | |
45 | 56 | case _ => | |
46 | 57 | $Tuple2(nil, -1) | |
47 | 58 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func writeConstString (key,value) = if (!(isDefined(getString(this, key)))) | |
5 | 5 | then StringEntry(key, value) | |
6 | 6 | else throw(("already initialized: " + key)) | |
7 | 7 | ||
8 | 8 | ||
9 | 9 | let configStore = "config" | |
10 | 10 | ||
11 | 11 | let configAddress = addressFromStringValue(getStringValue(this, configStore)) | |
12 | 12 | ||
13 | 13 | let maybeOracleAddress = match getString(configAddress, "oracle_address") { | |
14 | 14 | case s: String => | |
15 | 15 | addressFromString(s) | |
16 | 16 | case _ => | |
17 | 17 | unit | |
18 | 18 | } | |
19 | 19 | ||
20 | 20 | let HEIGHT = height | |
21 | 21 | ||
22 | 22 | let timeframe = valueOrElse(getInteger(configAddress, "WithdrawLimitTimeframe"), 1) | |
23 | 23 | ||
24 | 24 | func limit (assetId) = getInteger(configAddress, (assetId + "_WithdrawLimitAcc")) | |
25 | 25 | ||
26 | 26 | ||
27 | - | func userWithdrawnWithinEpochStore ( | |
27 | + | func userWithdrawnWithinEpochStore (user,assetId) = ((("withdrawn_" + user) + "_") + assetId) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | @Callable(i) | |
31 | 31 | func initialize (ca) = [writeConstString(configStore, ca)] | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | ||
35 | 35 | @Callable(i) | |
36 | 36 | func validateWithdrawLimit (assetId,user,amount) = match limit(assetId) { | |
37 | - | case | |
37 | + | case lmt: Int => | |
38 | 38 | let currentEpochStart = ((HEIGHT / timeframe) * timeframe) | |
39 | 39 | let currentEpochEnd = ((1 + (HEIGHT / timeframe)) * timeframe) | |
40 | - | let store = userWithdrawnWithinEpochStore(currentEpochStart, user, assetId) | |
41 | - | let userWithdrawnWithinTheEpoch = valueOrElse(getInteger(store), 0) | |
42 | - | if (((userWithdrawnWithinTheEpoch + amount) > l)) | |
43 | - | then throw(((((((("breaching withdraw limit per " + toString(l)) + " ") + assetId) + " over ") + toString(timeframe)) + " blocks. Available: ") + toString((l - userWithdrawnWithinTheEpoch)))) | |
44 | - | else $Tuple2([IntegerEntry(store, (userWithdrawnWithinTheEpoch + amount))], (l - userWithdrawnWithinTheEpoch)) | |
40 | + | let store = userWithdrawnWithinEpochStore(user, assetId) | |
41 | + | let $t012941518 = match getString(store) { | |
42 | + | case s: String => | |
43 | + | let data = split(s, "|") | |
44 | + | $Tuple2(parseIntValue(data[0]), parseIntValue(data[1])) | |
45 | + | case _ => | |
46 | + | $Tuple2(0, 0) | |
47 | + | } | |
48 | + | let epoch = $t012941518._1 | |
49 | + | let withdrawn = $t012941518._2 | |
50 | + | let userWithdrawnWithinCurrentEpoch = if ((epoch == currentEpochStart)) | |
51 | + | then withdrawn | |
52 | + | else 0 | |
53 | + | if (((userWithdrawnWithinCurrentEpoch + amount) > lmt)) | |
54 | + | then throw(((((((((((("breaching withdraw limit per " + toString(lmt)) + " ") + assetId) + " over ") + toString(timeframe)) + " blocks. Available: ") + toString((lmt - userWithdrawnWithinCurrentEpoch))) + " current epoch: ") + toString(currentEpochStart)) + "-") + toString(currentEpochEnd))) | |
55 | + | else $Tuple2([StringEntry(store, ((toString(currentEpochStart) + "|") + toString((userWithdrawnWithinCurrentEpoch + amount))))], ((lmt - userWithdrawnWithinCurrentEpoch) - amount)) | |
45 | 56 | case _ => | |
46 | 57 | $Tuple2(nil, -1) | |
47 | 58 | } | |
48 | 59 | ||
49 | 60 |
github/deemru/w8io/3ef1775 27.55 ms ◑