tx · Da9izXKegxKrVUvuCfcCHS12kjTRndnjD14BLAkUwYvn 3MpKmkFmjoGLpPWhScheYrN7fjdJAFp9tEX: -0.01000000 Waves 2020.10.08 22:23 [1212007] smart account 3MpKmkFmjoGLpPWhScheYrN7fjdJAFp9tEX > SELF 0.00000000 Waves
{ "type": 13, "id": "Da9izXKegxKrVUvuCfcCHS12kjTRndnjD14BLAkUwYvn", "fee": 1000000, "feeAssetId": null, "timestamp": 1602185080147, "version": 2, "chainId": 84, "sender": "3MpKmkFmjoGLpPWhScheYrN7fjdJAFp9tEX", "senderPublicKey": "33Gr5uEJMDMKdRs25QUDvTeQ7q5EpGcAdPztrFvQWdv9", "proofs": [ "2mRkbM51QrrTUuVekTL9ioWBfELy9sBEK4UnTmkUigT6zGcBWLv6MnJ4hEVBnF1p6cVSGXoprrZnBLG93fi3uqdz" ], "script": "base64:AAIDAAAAAAAAAAkIARIAEgMKAQEAAAAEAAAAAA9mcm9zdEJsb2NrQ291bnQAAAAAAAAAAGQAAAAAB3BlcmNlbnQAAAAAAAAAABQBAAAADGdldFN0YXRpc3RpYwAAAAAEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwIAAAAJc3RhdGlzdGljAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWECAAAADTBfMF8wXzBfMF8wXzABAAAAB2dldFVzZXIAAAABAAAABHVzZXIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAAEdXNlcgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAgAAABcwXzBfMF8wXzBfMF8wXzBfMF8wXzBfMAAAAAIAAAABaQEAAAAHZGVwb3NpdAAAAAAEAAAAA3BtdAkBAAAAB2V4dHJhY3QAAAABCAUAAAABaQAAAAdwYXltZW50AwkBAAAACWlzRGVmaW5lZAAAAAEIBQAA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ZlcmlmeQAAAAAEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAABAAAAIB5Mc/KsxWEMv4BJo38ZZBpINTekTDQU9f6eMly2/EEyBnXw3T8=", "height": 1212007, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 8QVQi1t1PQcSguL7XCiqVshFVx9vMUsSz1k8pQr8rjgX Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let frostBlockCount = 100 | |
5 | + | ||
6 | + | let percent = 20 | |
7 | + | ||
8 | + | func getStatistic () = match getString(this, "statistic") { | |
9 | + | case a: String => | |
10 | + | a | |
11 | + | case _ => | |
12 | + | "0_0_0_0_0_0_0" | |
13 | + | } | |
14 | + | ||
15 | + | ||
16 | + | func getUser (user) = match getString(this, user) { | |
17 | + | case a: String => | |
18 | + | a | |
19 | + | case _ => | |
20 | + | "0_0_0_0_0_0_0_0_0_0_0_0" | |
21 | + | } | |
22 | + | ||
23 | + | ||
24 | + | @Callable(i) | |
25 | + | func deposit () = { | |
26 | + | let pmt = extract(i.payment) | |
27 | + | if (isDefined(pmt.assetId)) | |
28 | + | then throw("can hodl waves only at the moment") | |
29 | + | else { | |
30 | + | let currentKey = toBase58String(i.caller.bytes) | |
31 | + | if ((currentKey == "3N2hHaqEEXjFHE5G8NTw6v7KNMwcHob2Ena")) | |
32 | + | then WriteSet([DataEntry("statistic", getStatistic())]) | |
33 | + | else { | |
34 | + | let statistic = split(getStatistic(), "_") | |
35 | + | let blockHeight = lastBlock.height | |
36 | + | let sum = ((pmt.amount / 100) * (100 + percent)) | |
37 | + | let user = split(getUser(currentKey), "_") | |
38 | + | let userData2 = parseIntValue(user[2]) | |
39 | + | WriteSet([DataEntry("statistic", ((((((((((((toString((parseIntValue(statistic[0]) + pmt.amount)) + "_") + toString((parseIntValue(statistic[1]) + 1))) + "_") + statistic[2]) + "_") + statistic[3]) + "_") + statistic[4]) + "_") + statistic[5]) + "_") + statistic[6])), DataEntry(currentKey, (((((((((((((((((((((toString((parseIntValue(user[0]) + pmt.amount)) + "_") + toString((parseIntValue(user[1]) + sum))) + "_") + toString((userData2 + sum))) + "_") + toString(((userData2 + sum) / frostBlockCount))) + "_") + toString(blockHeight)) + user[5]) + "_") + user[6]) + "_") + user[7]) + "_") + user[8]) + "_") + user[9]) + "_") + user[10]) + "_") + user[11]))]) | |
40 | + | } | |
41 | + | } | |
42 | + | } | |
43 | + | ||
44 | + | ||
45 | + | ||
46 | + | @Callable(i) | |
47 | + | func withdraw (amount) = { | |
48 | + | let currentKey = toBase58String(i.caller.bytes) | |
49 | + | let user = split(getUser(currentKey), "_") | |
50 | + | let statistic = split(getStatistic(), "_") | |
51 | + | let oldAmount = parseIntValue(user[2]) | |
52 | + | let newAmount = (oldAmount - amount) | |
53 | + | let blockHeight = lastBlock.height | |
54 | + | let frostBlockHeight = parseIntValue(user[1]) | |
55 | + | let defrostBlockHeight = (frostBlockHeight + frostBlockCount) | |
56 | + | let sumWithdraw = (parseIntValue(user[2]) + amount) | |
57 | + | let maxWithdraw = if ((blockHeight >= defrostBlockHeight)) | |
58 | + | then oldAmount | |
59 | + | else ((frostBlockCount - (defrostBlockHeight - blockHeight)) * (oldAmount / frostBlockCount)) | |
60 | + | if ((0 > amount)) | |
61 | + | then throw("Can't withdraw negative amount") | |
62 | + | else if ((amount > maxWithdraw)) | |
63 | + | then throw(("Max sum: " + toString(maxWithdraw))) | |
64 | + | else if ((0 > newAmount)) | |
65 | + | then throw("Not enough balance") | |
66 | + | else ScriptResult(WriteSet([DataEntry("statistic", (((((((((statistic[0] + "_") + statistic[1]) + "_") + toString((parseIntValue(statistic[2]) + amount))) + "_") + toString((parseIntValue(statistic[1]) + 1))) + "_") + statistic[4]) + statistic[5])), DataEntry(currentKey, ((((((((((((((((((((((user[0] + "_") + user[1]) + "_") + toString(newAmount)) + "_") + user[3]) + "_") + toString(blockHeight)) + "_") + toString((parseIntValue(user[5]) + amount))) + "_") + toString((parseIntValue(user[6]) + amount))) + "_") + user[7]) + "_") + user[8]) + "_") + user[9]) + "_") + user[10]) + "_") + user[11]))]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
67 | + | } | |
68 | + | ||
69 | + | ||
70 | + | @Verifier(tx) | |
71 | + | func verify () = match tx { | |
72 | + | case d: SetScriptTransaction => | |
73 | + | sigVerify(tx.bodyBytes, tx.proofs[0], base58'33Gr5uEJMDMKdRs25QUDvTeQ7q5EpGcAdPztrFvQWdv9') | |
74 | + | case _ => | |
75 | + | true | |
76 | + | } | |
77 | + |
github/deemru/w8io/169f3d6 21.99 ms ◑