tx · GdrRXWwTCaUfpvWwP2nJCwiycPCuXDsJYhrpntDzSEo5 3N4PzCkHU7VTJeNCPpT8w9XZLnjTsi2YMHN: -0.01000000 Waves 2022.04.08 11:33 [1999356] smart account 3N4PzCkHU7VTJeNCPpT8w9XZLnjTsi2YMHN > SELF 0.00000000 Waves
{ "type": 13, "id": "GdrRXWwTCaUfpvWwP2nJCwiycPCuXDsJYhrpntDzSEo5", "fee": 1000000, "feeAssetId": null, "timestamp": 1649406892397, "version": 2, "chainId": 84, "sender": "3N4PzCkHU7VTJeNCPpT8w9XZLnjTsi2YMHN", "senderPublicKey": "2DVVUYkJNWCMHSCPWEXRjF3THHEdc5bVinyp2c4z8nV8", "proofs": [ "SLsB7ShW9MQcdJo4SWafNdpLRg7fVhx4ad6kUjpu8FcQ6JunVxupfYWpu3BHGWa595oPTBoBXZKgk5y6My9n1zL" ], "script": "base64:AAIFAAAAAAAAABMIAhIDCgEIEgQKAggBEgQKAggYAAAADwAAAAAUc3Rha2VBbW91bnRUaHJlc2hvbGQAAAAAAAAAAAEAAAAAEWxvY2tQZXJpb2RzSW5EYXlzCQAETAAAAAIAAAAAAAAAAAEJAARMAAAAAgAAAAAAAAAACgkABEwAAAACAAAAAAAAAAAeCQAETAAAAAIAAAAAAAAAAFoJAARMAAAAAgAAAAAAAAAAtAUAAAADbmlsAAAAABhwb3NzaWJsZVRva2Vuc0ZvclJld2FyZHMJAARMAAAAAgIAAAAGUkVEU21iCQAETAAAAAICAAAABHJCVEMFAAAAA25pbAAAAAAHaG91cnMyNAAAAAAABSZcAAAAAAAKYXByOG9mMjAyMgAAAAGABnh4AAAAAAAQY3VycmVudFRpbWVzdGFtcAgFAAAACWxhc3RCbG9jawAAAAl0aW1lc3RhbXAAAAAAB2tleUluaXQCAAAABGluaXQAAAAACmtleUFzc2V0SWQCAAAAB2Fzc2V0SWQAAAAACGtleVRvdGFsAgAAAAxzdGFrZWRfdG90YWwBAAAACWtleVN0YWtlZAAAAAEAAAAHYWRkc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AAAAAACgQAAAALdW5zdGFrZUxpc3QIBQAAAAskdDAzOTQyNDAyMAAAAAJfMQQAAAANdG90YWxVbnN0YWtlZAgFAAAACyR0MDM5NDI0MDIwAAAAAl8yAwkBAAAAAiE9AAAAAgkAAZAAAAABCAUAAAADaW52AAAACHBheW1lbnRzAAAAAAAAAAAACQAAAgAAAAECAAAALVRoZXJlIHNob3VsZCBiZSBubyBwYXltZW50cyBmb3IgdGhpcyBmdW5jdGlvbgMDCQEAAAACIT0AAAACCAUAAAADaW52AAAABmNhbGxlcgUAAAAEdGhpcwkBAAAAAiE9AAAAAgUAAAALdXNlckFkZHJlc3MIBQAAAANpbnYAAAAGY2FsbGVyBwkAAAIAAAABAgAAAExPbmx5IHVzZXJzIHRoZW1zZWx2ZXMgY2FuIHdpdGhkcmF3IHRoZWlyIHVubG9ja2VkIHN0YWtpbmcsIG9yIGFkbWluIGZvciB0aGVtCQAETgAAAAIFAAAAC3Vuc3Rha2VMaXN0CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAAhrZXlUb3RhbAkAAGUAAAACBQAAAAt0b3RhbFN0YWtlZAUAAAANdG90YWxVbnN0YWtlZAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAt1c2VyQWRkcmVzcwUAAAANdG90YWxVbnN0YWtlZAUAAAAHYXNzZXRJZAUAAAADbmlsAAAAAOyZyqY=", "height": 1999356, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BtjiSioBKbapZmQ6YQ7Qo9PkFG2XkcuXTPQ2RuRmEY63 Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let a = | |
4 | + | let a = 1 | |
5 | 5 | ||
6 | - | let b = | |
6 | + | let b = [1, 10, 30, 90, 180] | |
7 | 7 | ||
8 | - | let c = " | |
8 | + | let c = ["REDSmb", "rBTC"] | |
9 | 9 | ||
10 | - | func d (e) = e | |
10 | + | let d = 86400000 | |
11 | + | ||
12 | + | let e = 1649376000000 | |
13 | + | ||
14 | + | let f = lastBlock.timestamp | |
15 | + | ||
16 | + | let g = "init" | |
17 | + | ||
18 | + | let h = "assetId" | |
19 | + | ||
20 | + | let i = "staked_total" | |
21 | + | ||
22 | + | func j (k) = k | |
11 | 23 | ||
12 | 24 | ||
13 | - | let | |
25 | + | let l = valueOrElse(getBoolean(this, g), false) | |
14 | 26 | ||
15 | - | let | |
27 | + | let m = fromBase58String(getStringValue(this, h)) | |
16 | 28 | ||
17 | - | let | |
29 | + | let n = valueOrErrorMessage(getInteger(this, i), (("Can't read field '" + i) + "'")) | |
18 | 30 | ||
19 | - | func | |
31 | + | func o (p) = if ((size(p) != 1)) | |
20 | 32 | then throw("Single payment required") | |
21 | - | else if (( | |
22 | - | then throw(" | |
23 | - | else if (( | |
24 | - | then throw("Payment amount must be greater then | |
25 | - | else | |
33 | + | else if ((p[0].assetId != m)) | |
34 | + | then throw("Only REDSmb token is accepted") | |
35 | + | else if ((a > p[0].amount)) | |
36 | + | then throw(("Payment amount must be greater then threshold " + toString(a))) | |
37 | + | else p[0].amount | |
26 | 38 | ||
27 | 39 | ||
28 | - | func | |
40 | + | func q (r) = valueOrElse(getInteger(this, j(r)), 0) | |
29 | 41 | ||
30 | 42 | ||
31 | - | @Callable( | |
32 | - | func init ( | |
33 | - | let | |
34 | - | if ( | |
43 | + | @Callable(s) | |
44 | + | func init (t) = { | |
45 | + | let u = valueOrErrorMessage(assetInfo(fromBase58String(t)), "Can't find asset").id | |
46 | + | if (l) | |
35 | 47 | then throw("DApp is already init") | |
36 | - | else [BooleanEntry( | |
48 | + | else [BooleanEntry(g, true), StringEntry("assetId", toBase58String(u)), IntegerEntry(i, 0)] | |
37 | 49 | } | |
38 | 50 | ||
39 | 51 | ||
40 | 52 | ||
41 | - | @Callable(m) | |
42 | - | func stake () = { | |
43 | - | let p = toString(m.caller) | |
44 | - | let q = i(m.payments) | |
45 | - | let r = k(p) | |
46 | - | [IntegerEntry(d(p), (r + q)), IntegerEntry(c, (h + q))] | |
53 | + | @Callable(s) | |
54 | + | func createNewStaking (v,w) = { | |
55 | + | let x = toString(s.caller) | |
56 | + | let y = o(s.payments) | |
57 | + | let z = ((f + d) - (f % d)) | |
58 | + | let A = (z + (w * d)) | |
59 | + | let B = ((x + "_") + toBase58String(s.transactionId)) | |
60 | + | let C = makeString([toString(y), v, toString(w), toString(f), toString(A)], ",") | |
61 | + | if (isDefined(getString(this, B))) | |
62 | + | then throw((("Staking '" + B) + "' already exists")) | |
63 | + | else if (!(containsElement(b, w))) | |
64 | + | then throw((("Unsupported number of days " + toString(w)) + " to mine")) | |
65 | + | else if (!(containsElement(c, v))) | |
66 | + | then throw((("Unsupported reward type '" + v) + "'")) | |
67 | + | else [StringEntry(B, C), IntegerEntry(i, (n + y))] | |
47 | 68 | } | |
48 | 69 | ||
49 | 70 | ||
50 | 71 | ||
51 | - | @Callable(m) | |
52 | - | func withdraw (s) = { | |
53 | - | let p = toString(m.caller) | |
54 | - | let t = k(p) | |
55 | - | if ((size(m.payments) != 0)) | |
72 | + | @Callable(s) | |
73 | + | func withdraw (r,D) = { | |
74 | + | let E = valueOrErrorMessage(addressFromString(r), (("Can't parse user address '" + r) + "'")) | |
75 | + | func F (G,H) = { | |
76 | + | let I = { | |
77 | + | let J = split(valueOrErrorMessage(getString(this, ((r + "_") + H)), ((("Staking " + H) + " doesn't exist for user ") + r)), ",") | |
78 | + | if ((size(J) != 5)) | |
79 | + | then throw(("Can't parse parameters of staking " + H)) | |
80 | + | else J | |
81 | + | } | |
82 | + | let K = $Tuple2(parseIntValue(I[0]), parseIntValue(I[4])) | |
83 | + | let L = K._1 | |
84 | + | let M = K._2 | |
85 | + | if ((M > f)) | |
86 | + | then throw(((("Unable to withdraw staking " + H) + " because it is still locked until ") + toString(M))) | |
87 | + | else $Tuple2((G._1 :+ DeleteEntry(((r + "_") + H))), (G._2 + L)) | |
88 | + | } | |
89 | + | ||
90 | + | let N = { | |
91 | + | let O = D | |
92 | + | let P = size(O) | |
93 | + | let Q = $Tuple2(nil, 0) | |
94 | + | func R (S,T) = if ((T >= P)) | |
95 | + | then S | |
96 | + | else F(S, O[T]) | |
97 | + | ||
98 | + | func U (S,T) = if ((T >= P)) | |
99 | + | then S | |
100 | + | else throw("List size exceeds 10") | |
101 | + | ||
102 | + | U(R(R(R(R(R(R(R(R(R(R(Q, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
103 | + | } | |
104 | + | let V = N._1 | |
105 | + | let W = N._2 | |
106 | + | if ((size(s.payments) != 0)) | |
56 | 107 | then throw("There should be no payments for this function") | |
57 | - | else if ((0 >= s)) | |
58 | - | then throw("Amount must be positive") | |
59 | - | else if ((s > h)) | |
60 | - | then throw("You cannot withdraw more funds than total staked on the dApp") | |
61 | - | else if ((s > t)) | |
62 | - | then throw("You don't have enough staked funds available to withdraw") | |
63 | - | else [if ((s == t)) | |
64 | - | then DeleteEntry(d(p)) | |
65 | - | else IntegerEntry(d(p), (t - s)), IntegerEntry(c, (h - s)), ScriptTransfer(m.caller, s, g)] | |
108 | + | else if (if ((s.caller != this)) | |
109 | + | then (E != s.caller) | |
110 | + | else false) | |
111 | + | then throw("Only users themselves can withdraw their unlocked staking, or admin for them") | |
112 | + | else (V ++ [IntegerEntry(i, (n - W)), ScriptTransfer(E, W, m)]) | |
66 | 113 | } | |
67 | 114 | ||
68 | 115 |
github/deemru/w8io/169f3d6 36.64 ms ◑