tx · 9VSJDAE3AHniSi75bSKhCVmtHkc9WfD5jg2kNLKT1KBf 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq: -0.01000000 Waves 2023.07.19 17:16 [2672850] smart account 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq > SELF 0.00000000 Waves
{ "type": 13, "id": "9VSJDAE3AHniSi75bSKhCVmtHkc9WfD5jg2kNLKT1KBf", "fee": 1000000, "feeAssetId": null, "timestamp": 1689776256967, "version": 2, "chainId": 84, "sender": "3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq", "senderPublicKey": "57SkjQUEwC1ayCqLbXLuzBqifK6B6SR6rfxtGsbAo3zW", "proofs": [ "3dKGXXkJyYpt42MLsSvpKZgDuYHWagsiNkpda3M3j6ATJgCKrcyj3CLRmT3tq4zqdiVZN45NbG98T4eMdFurK6sa" ], "script": "base64:BgIaCAISAwoBARIAEgMKAQgSAwoBARIDCgEIEgAWAAxjb250cmFjdEZpbGUCEG1ydF9zdGFraW5nLnJpZGUAA1NFUAICX18ABnNjYWxlOACAwtcvABJBRERSRVNTX0JZVEVTX1NJWkUAGgEIdGhyb3dFcnIBA21zZwkAAgEJAKwCAgkArAICBQxjb250cmFjdEZpbGUCAjogBQNtc2cACmtleUFzc2V0SWQJALkJAgkAzAgCAgIlcwkAzAgCAgdhc3NldElkBQNuaWwFA1NFUAATa2V5RW1pc3Npb25QZXJCbG9jawkAuQkCCQDMCAICAiVzCQDMCAICEGVtaXNzaW9uUGVyQmxvY2sFA25pbAUDU0VQAA1rZXlTdGFydEJsb2NrCQC5CQIJAMwIAgICJXMJAMwIAgIKc3RhcnRCbG9jawUDbmlsBQNTRVAAEGtleVRvdGFsTHBBbW91bnQJALkJAgkAzAgCAgIlcwkAzAgCAg10b3RhbExwQW1vdW50BQNuaWwFA1NFUAATa2V5VG90YWxBc3NldEFtb3VudAkAuQkCCQDMCAICAiVzCQDMCAICEHRvdGFsQXNzZXRBbW91bnQFA25pbAUDU0VQ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ABBd1c2VyVG90YWxBc3NldFdpdGhkcmF3bgkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzCQEaa2V5VXNlclRvdGFsQXNzZXRXaXRoZHJhd24BBQt1c2VyQWRkcmVzcwAACQCUCgIFA25pbAkAlwoFBQx1c2VyTHBBbW91bnQFHHVzZXJBdmFpbGFibGVBc3NldFRvV2l0aGRyYXcJAQ9nZXRDdXJyZW50UHJpY2UABRV1c2VyVG90YWxTdGFrZWRBbW91bnQFF3VzZXJUb3RhbEFzc2V0V2l0aGRyYXduAWkBFmdldFRvdGFsQXNzZXRzUkVBRE9OTFkACQCUCgIFA25pbAkAlQoDBQ10b3RhbExwQW1vdW50CQErZ2V0VG90YWxBc3NldEFtb3VudFdpdGhQcm9maXRPck1heEF2YWlsYWJsZQAJAQ9nZXRDdXJyZW50UHJpY2UAAHZVUSA=", "height": 2672850, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BrkV6ZnB28fo3AMKbuDLP5GHPgzyrbBBVsRxAjqjnbJw Next: 8Fa8PH8xvgBTVuXa7AWViEpTjZ8rooSMzJf4SRfVELxi Diff:
Old | New | Differences | |
---|---|---|---|
54 | 54 | ||
55 | 55 | func y () = { | |
56 | 56 | let z = (q + u()) | |
57 | - | let A = s | |
58 | - | if ($isInstanceOf(A, "Unit")) | |
59 | - | then { | |
60 | - | let B = A | |
61 | - | min([z, wavesBalance(this).available]) | |
62 | - | } | |
63 | - | else if ($isInstanceOf(A, "ByteVector")) | |
57 | + | let A = { | |
58 | + | let B = s | |
59 | + | if ($isInstanceOf(B, "Unit")) | |
64 | 60 | then { | |
65 | - | let C = | |
66 | - | min([z, | |
61 | + | let C = B | |
62 | + | min([z, wavesBalance(this).available]) | |
67 | 63 | } | |
68 | - | else throw("Match error") | |
64 | + | else if ($isInstanceOf(B, "ByteVector")) | |
65 | + | then { | |
66 | + | let D = B | |
67 | + | min([z, assetBalance(this, D)]) | |
68 | + | } | |
69 | + | else throw("Match error") | |
70 | + | } | |
71 | + | if ((p == 0)) | |
72 | + | then 0 | |
73 | + | else A | |
69 | 74 | } | |
70 | 75 | ||
71 | 76 | ||
72 | - | func | |
77 | + | func E () = if ((p != 0)) | |
73 | 78 | then fraction(y(), c, p) | |
74 | 79 | else (1 * c) | |
75 | 80 | ||
76 | 81 | ||
77 | - | func | |
78 | - | let | |
82 | + | func F (G,m) = { | |
83 | + | let H = [if ((size(G.payments) == 1)) | |
79 | 84 | then true | |
80 | - | else e("should include 1 payment"), if (( | |
85 | + | else e("should include 1 payment"), if ((G.payments[0].assetId == s)) | |
81 | 86 | then true | |
82 | - | else e(("payment should be in " + r)), if (( | |
87 | + | else e(("payment should be in " + r)), if ((G.payments[0].amount > 0)) | |
83 | 88 | then true | |
84 | 89 | else "payment amount should be greater than 0"] | |
85 | - | if (( | |
90 | + | if ((H == H)) | |
86 | 91 | then { | |
87 | - | let | |
88 | - | let | |
89 | - | let | |
90 | - | let | |
91 | - | let | |
92 | - | let | |
93 | - | let | |
94 | - | let | |
95 | - | let | |
92 | + | let I = G.payments[0].amount | |
93 | + | let J = fraction(I, c, E()) | |
94 | + | let K = t(m) | |
95 | + | let L = valueOrElse(getInteger(this, o(m)), 0) | |
96 | + | let M = (p + J) | |
97 | + | let N = (q + I) | |
98 | + | let O = (K + J) | |
99 | + | let P = (L + I) | |
100 | + | let Q = if ((p == 0)) | |
96 | 101 | then [IntegerEntry(i, height)] | |
97 | 102 | else nil | |
98 | - | ([IntegerEntry(j, | |
103 | + | ([IntegerEntry(j, M), IntegerEntry(k, N), IntegerEntry(l(m), O), IntegerEntry(o(m), P)] ++ Q) | |
99 | 104 | } | |
100 | 105 | else throw("Strict value is not equal to itself.") | |
101 | 106 | } | |
102 | 107 | ||
103 | 108 | ||
104 | - | @Callable( | |
109 | + | @Callable(G) | |
105 | 110 | func setEmissionPerBlock (v) = { | |
106 | - | let | |
111 | + | let R = [if ((G.caller == this)) | |
107 | 112 | then true | |
108 | 113 | else e("permission denied")] | |
109 | - | if (( | |
114 | + | if ((R == R)) | |
110 | 115 | then [IntegerEntry(k, y()), IntegerEntry(i, height), IntegerEntry(h, max([0, v]))] | |
111 | 116 | else throw("Strict value is not equal to itself.") | |
112 | 117 | } | |
113 | 118 | ||
114 | 119 | ||
115 | 120 | ||
116 | - | @Callable( | |
117 | - | func stake () = | |
121 | + | @Callable(G) | |
122 | + | func stake () = F(G, toString(G.caller)) | |
118 | 123 | ||
119 | 124 | ||
120 | 125 | ||
121 | - | @Callable( | |
126 | + | @Callable(G) | |
122 | 127 | func stakeFor (m) = { | |
123 | - | let | |
128 | + | let R = [if ((size(fromBase58String(m)) == d)) | |
124 | 129 | then true | |
125 | 130 | else e("address is not valid")] | |
126 | - | if (( | |
127 | - | then | |
131 | + | if ((R == R)) | |
132 | + | then F(G, m) | |
128 | 133 | else throw("Strict value is not equal to itself.") | |
129 | 134 | } | |
130 | 135 | ||
131 | 136 | ||
132 | 137 | ||
133 | - | @Callable( | |
134 | - | func withdraw ( | |
135 | - | let m = toString( | |
136 | - | let | |
137 | - | let | |
138 | + | @Callable(G) | |
139 | + | func withdraw (S) = { | |
140 | + | let m = toString(G.caller) | |
141 | + | let K = t(m) | |
142 | + | let R = [if ((S > 0)) | |
138 | 143 | then true | |
139 | - | else e("amount should be more than 0"), if (( | |
144 | + | else e("amount should be more than 0"), if ((K >= S)) | |
140 | 145 | then true | |
141 | - | else e((("cannot withdraw more than available (" + toString( | |
142 | - | if (( | |
146 | + | else e((("cannot withdraw more than available (" + toString(K)) + ")"))] | |
147 | + | if ((R == R)) | |
143 | 148 | then { | |
144 | - | let | |
145 | - | let | |
146 | - | let | |
147 | - | let | |
148 | - | let | |
149 | - | let | |
150 | - | [IntegerEntry(j, | |
149 | + | let O = (K - S) | |
150 | + | let T = fraction(S, E(), c) | |
151 | + | let M = (p - S) | |
152 | + | let N = fraction(M, E(), c) | |
153 | + | let U = valueOrElse(getInteger(this, n(m)), 0) | |
154 | + | let V = (U + T) | |
155 | + | [IntegerEntry(j, M), IntegerEntry(k, N), IntegerEntry(l(m), O), IntegerEntry(n(m), V), IntegerEntry(i, height), ScriptTransfer(G.caller, T, s)] | |
151 | 156 | } | |
152 | 157 | else throw("Strict value is not equal to itself.") | |
153 | 158 | } | |
154 | 159 | ||
155 | 160 | ||
156 | 161 | ||
157 | - | @Callable( | |
162 | + | @Callable(G) | |
158 | 163 | func getUserAssetsREADONLY (m) = { | |
159 | - | let J = t(m) | |
160 | - | let V = fraction(J, D(), c) | |
161 | - | $Tuple2(nil, $Tuple3(J, V, D())) | |
164 | + | let K = t(m) | |
165 | + | let W = fraction(K, E(), c) | |
166 | + | let L = valueOrElse(getInteger(this, o(m)), 0) | |
167 | + | let U = valueOrElse(getInteger(this, n(m)), 0) | |
168 | + | $Tuple2(nil, $Tuple5(K, W, E(), L, U)) | |
162 | 169 | } | |
163 | 170 | ||
164 | 171 | ||
165 | 172 | ||
166 | - | @Callable( | |
167 | - | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(p, y(), | |
173 | + | @Callable(G) | |
174 | + | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(p, y(), E())) | |
168 | 175 | ||
169 | 176 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = "mrt_staking.ride" | |
5 | 5 | ||
6 | 6 | let b = "__" | |
7 | 7 | ||
8 | 8 | let c = 100000000 | |
9 | 9 | ||
10 | 10 | let d = 26 | |
11 | 11 | ||
12 | 12 | func e (f) = throw(((a + ": ") + f)) | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | let g = makeString(["%s", "assetId"], b) | |
16 | 16 | ||
17 | 17 | let h = makeString(["%s", "emissionPerBlock"], b) | |
18 | 18 | ||
19 | 19 | let i = makeString(["%s", "startBlock"], b) | |
20 | 20 | ||
21 | 21 | let j = makeString(["%s", "totalLpAmount"], b) | |
22 | 22 | ||
23 | 23 | let k = makeString(["%s", "totalAssetAmount"], b) | |
24 | 24 | ||
25 | 25 | func l (m) = makeString(["%s%s", "userLpAmount", m], b) | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func n (m) = makeString(["%s%s", "totalAssetWithdrawn", m], b) | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func o (m) = makeString(["%s%s", "totalAssetStaked", m], b) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | let p = valueOrElse(getInteger(this, j), 0) | |
35 | 35 | ||
36 | 36 | let q = valueOrElse(getInteger(this, k), 0) | |
37 | 37 | ||
38 | 38 | let r = valueOrElse(getString(this, g), "WAVES") | |
39 | 39 | ||
40 | 40 | let s = if ((r == "WAVES")) | |
41 | 41 | then unit | |
42 | 42 | else fromBase58String(r) | |
43 | 43 | ||
44 | 44 | func t (m) = valueOrElse(getInteger(this, l(m)), 0) | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func u () = { | |
48 | 48 | let v = valueOrElse(getInteger(this, h), 0) | |
49 | 49 | let w = valueOrElse(getInteger(this, i), 0) | |
50 | 50 | let x = (height - w) | |
51 | 51 | max([0, (v * x)]) | |
52 | 52 | } | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func y () = { | |
56 | 56 | let z = (q + u()) | |
57 | - | let A = s | |
58 | - | if ($isInstanceOf(A, "Unit")) | |
59 | - | then { | |
60 | - | let B = A | |
61 | - | min([z, wavesBalance(this).available]) | |
62 | - | } | |
63 | - | else if ($isInstanceOf(A, "ByteVector")) | |
57 | + | let A = { | |
58 | + | let B = s | |
59 | + | if ($isInstanceOf(B, "Unit")) | |
64 | 60 | then { | |
65 | - | let C = | |
66 | - | min([z, | |
61 | + | let C = B | |
62 | + | min([z, wavesBalance(this).available]) | |
67 | 63 | } | |
68 | - | else throw("Match error") | |
64 | + | else if ($isInstanceOf(B, "ByteVector")) | |
65 | + | then { | |
66 | + | let D = B | |
67 | + | min([z, assetBalance(this, D)]) | |
68 | + | } | |
69 | + | else throw("Match error") | |
70 | + | } | |
71 | + | if ((p == 0)) | |
72 | + | then 0 | |
73 | + | else A | |
69 | 74 | } | |
70 | 75 | ||
71 | 76 | ||
72 | - | func | |
77 | + | func E () = if ((p != 0)) | |
73 | 78 | then fraction(y(), c, p) | |
74 | 79 | else (1 * c) | |
75 | 80 | ||
76 | 81 | ||
77 | - | func | |
78 | - | let | |
82 | + | func F (G,m) = { | |
83 | + | let H = [if ((size(G.payments) == 1)) | |
79 | 84 | then true | |
80 | - | else e("should include 1 payment"), if (( | |
85 | + | else e("should include 1 payment"), if ((G.payments[0].assetId == s)) | |
81 | 86 | then true | |
82 | - | else e(("payment should be in " + r)), if (( | |
87 | + | else e(("payment should be in " + r)), if ((G.payments[0].amount > 0)) | |
83 | 88 | then true | |
84 | 89 | else "payment amount should be greater than 0"] | |
85 | - | if (( | |
90 | + | if ((H == H)) | |
86 | 91 | then { | |
87 | - | let | |
88 | - | let | |
89 | - | let | |
90 | - | let | |
91 | - | let | |
92 | - | let | |
93 | - | let | |
94 | - | let | |
95 | - | let | |
92 | + | let I = G.payments[0].amount | |
93 | + | let J = fraction(I, c, E()) | |
94 | + | let K = t(m) | |
95 | + | let L = valueOrElse(getInteger(this, o(m)), 0) | |
96 | + | let M = (p + J) | |
97 | + | let N = (q + I) | |
98 | + | let O = (K + J) | |
99 | + | let P = (L + I) | |
100 | + | let Q = if ((p == 0)) | |
96 | 101 | then [IntegerEntry(i, height)] | |
97 | 102 | else nil | |
98 | - | ([IntegerEntry(j, | |
103 | + | ([IntegerEntry(j, M), IntegerEntry(k, N), IntegerEntry(l(m), O), IntegerEntry(o(m), P)] ++ Q) | |
99 | 104 | } | |
100 | 105 | else throw("Strict value is not equal to itself.") | |
101 | 106 | } | |
102 | 107 | ||
103 | 108 | ||
104 | - | @Callable( | |
109 | + | @Callable(G) | |
105 | 110 | func setEmissionPerBlock (v) = { | |
106 | - | let | |
111 | + | let R = [if ((G.caller == this)) | |
107 | 112 | then true | |
108 | 113 | else e("permission denied")] | |
109 | - | if (( | |
114 | + | if ((R == R)) | |
110 | 115 | then [IntegerEntry(k, y()), IntegerEntry(i, height), IntegerEntry(h, max([0, v]))] | |
111 | 116 | else throw("Strict value is not equal to itself.") | |
112 | 117 | } | |
113 | 118 | ||
114 | 119 | ||
115 | 120 | ||
116 | - | @Callable( | |
117 | - | func stake () = | |
121 | + | @Callable(G) | |
122 | + | func stake () = F(G, toString(G.caller)) | |
118 | 123 | ||
119 | 124 | ||
120 | 125 | ||
121 | - | @Callable( | |
126 | + | @Callable(G) | |
122 | 127 | func stakeFor (m) = { | |
123 | - | let | |
128 | + | let R = [if ((size(fromBase58String(m)) == d)) | |
124 | 129 | then true | |
125 | 130 | else e("address is not valid")] | |
126 | - | if (( | |
127 | - | then | |
131 | + | if ((R == R)) | |
132 | + | then F(G, m) | |
128 | 133 | else throw("Strict value is not equal to itself.") | |
129 | 134 | } | |
130 | 135 | ||
131 | 136 | ||
132 | 137 | ||
133 | - | @Callable( | |
134 | - | func withdraw ( | |
135 | - | let m = toString( | |
136 | - | let | |
137 | - | let | |
138 | + | @Callable(G) | |
139 | + | func withdraw (S) = { | |
140 | + | let m = toString(G.caller) | |
141 | + | let K = t(m) | |
142 | + | let R = [if ((S > 0)) | |
138 | 143 | then true | |
139 | - | else e("amount should be more than 0"), if (( | |
144 | + | else e("amount should be more than 0"), if ((K >= S)) | |
140 | 145 | then true | |
141 | - | else e((("cannot withdraw more than available (" + toString( | |
142 | - | if (( | |
146 | + | else e((("cannot withdraw more than available (" + toString(K)) + ")"))] | |
147 | + | if ((R == R)) | |
143 | 148 | then { | |
144 | - | let | |
145 | - | let | |
146 | - | let | |
147 | - | let | |
148 | - | let | |
149 | - | let | |
150 | - | [IntegerEntry(j, | |
149 | + | let O = (K - S) | |
150 | + | let T = fraction(S, E(), c) | |
151 | + | let M = (p - S) | |
152 | + | let N = fraction(M, E(), c) | |
153 | + | let U = valueOrElse(getInteger(this, n(m)), 0) | |
154 | + | let V = (U + T) | |
155 | + | [IntegerEntry(j, M), IntegerEntry(k, N), IntegerEntry(l(m), O), IntegerEntry(n(m), V), IntegerEntry(i, height), ScriptTransfer(G.caller, T, s)] | |
151 | 156 | } | |
152 | 157 | else throw("Strict value is not equal to itself.") | |
153 | 158 | } | |
154 | 159 | ||
155 | 160 | ||
156 | 161 | ||
157 | - | @Callable( | |
162 | + | @Callable(G) | |
158 | 163 | func getUserAssetsREADONLY (m) = { | |
159 | - | let J = t(m) | |
160 | - | let V = fraction(J, D(), c) | |
161 | - | $Tuple2(nil, $Tuple3(J, V, D())) | |
164 | + | let K = t(m) | |
165 | + | let W = fraction(K, E(), c) | |
166 | + | let L = valueOrElse(getInteger(this, o(m)), 0) | |
167 | + | let U = valueOrElse(getInteger(this, n(m)), 0) | |
168 | + | $Tuple2(nil, $Tuple5(K, W, E(), L, U)) | |
162 | 169 | } | |
163 | 170 | ||
164 | 171 | ||
165 | 172 | ||
166 | - | @Callable( | |
167 | - | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(p, y(), | |
173 | + | @Callable(G) | |
174 | + | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(p, y(), E())) | |
168 | 175 | ||
169 | 176 |
github/deemru/w8io/026f985 48.79 ms ◑