tx · DFXagidqvtSvNB9NXPAufUXbiARjqbYWAzG5P5EGVEr5 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh: -0.01000000 Waves 2022.12.07 02:15 [2349132] smart account 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh > SELF 0.00000000 Waves
{ "type": 13, "id": "DFXagidqvtSvNB9NXPAufUXbiARjqbYWAzG5P5EGVEr5", "fee": 1000000, "feeAssetId": null, "timestamp": 1670368515842, "version": 2, "chainId": 84, "sender": "3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh", "senderPublicKey": "HscGVyJG5M3NMHWKfQbucCBsFLGPi8VmTxTAmcBbaWTa", "proofs": [ "4g7vNi655wbvPg1MN5ALWQ93WV7jsaBkCLqB8g7ki51jhNir2yHrZWpwDLgNmnR1fUZLmiUzznJDU3rTYxisr1nr" ], "script": "base64:BgITCAISAwoBCBIDCgEIEgASAwoBARcABlNjYWxlNgDAhD0ABlNjYWxlOACAwtcvAAdTY2FsZTE2CQBoAgUGU2NhbGU4BQZTY2FsZTgACnZhbGlkYXRvcnMJAMwIAgIjM05BbXFHanhSQlJQb1JIWlVVcXZoaU5TNmF4bkdwaW5MSEMFA25pbAAPbW9uZXlCb3hBZGRyZXNzCQEHQWRkcmVzcwEBGgFUZKnP467xWXotJQOt2k8QiNBvrQpHH8SpAAdhc3NldElkAixISG1hRlFwVW9id0t4emp6NEVDYUJQdG9GNjlrdWpLd1UyY296YVV6VHNndgALcHV6emxlUG9vbHMJAMwIAgIjM042U3RKZGdtVGZBUnNSTm45WHQ1ckRZRXMzcHI0S0d5MXYFA25pbAEKZ2V0QmFsYW5jZQEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgRVbml0BAF4BQckbWF0Y2gwCAkA7wcBBQR0aGlzCWF2YWlsYWJsZQkA8AcCBQR0aGlzCQEFdmFsdWUBBQdhc3NldElkAQl0cnlHZXRJbnQCB2FkZHJlc3MDa2V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ted Prev: G27ZPgtsToTpCweFXxVRqoJHodazBMLqGLut2KGefwFv Next: GwJ2diYt1z551jVSUAc6byKiP5tgonYWVGtyF4AAmvvy Diff:
Old | New | Differences | |
---|---|---|---|
134 | 134 | ||
135 | 135 | ||
136 | 136 | func P (r,F) = { | |
137 | - | let Q = if ((F > a)) | |
138 | - | then throw(("1) Fee " + toString(F))) | |
139 | - | else "" | |
137 | + | let Q = v(r, F) | |
140 | 138 | if ((Q == Q)) | |
141 | - | then { | |
142 | - | let R = v(r, F) | |
143 | - | if ((R == R)) | |
144 | - | then [ScriptTransfer(e, F, fromBase58String(f))] | |
145 | - | else throw("Strict value is not equal to itself.") | |
146 | - | } | |
139 | + | then [ScriptTransfer(e, F, fromBase58String(f))] | |
147 | 140 | else throw("Strict value is not equal to itself.") | |
148 | 141 | } | |
149 | 142 | ||
150 | 143 | ||
151 | - | func | |
144 | + | func R () = { | |
152 | 145 | let u = o(this, "currentPool") | |
153 | 146 | if ((u == "")) | |
154 | 147 | then throw(("Cannot find pool with id " + u)) | |
155 | 148 | else { | |
156 | 149 | let w = q(u) | |
157 | - | let | |
158 | - | if (( | |
159 | - | then | |
150 | + | let S = v(u, w) | |
151 | + | if ((S == S)) | |
152 | + | then S | |
160 | 153 | else throw("Strict value is not equal to itself.") | |
161 | 154 | } | |
162 | 155 | } | |
163 | 156 | ||
164 | 157 | ||
165 | - | func | |
158 | + | func T (U,w) = { | |
166 | 159 | let C = fraction(w, b, G()) | |
167 | - | (K(C) ++ [IntegerEntry(( | |
160 | + | (K(C) ++ [IntegerEntry((U + "_staked"), (k(this, (U + "_staked")) + C))]) | |
168 | 161 | } | |
169 | 162 | ||
170 | 163 | ||
171 | - | func | |
164 | + | func V (U,w) = { | |
172 | 165 | let C = fraction(w, b, G()) | |
173 | - | let | |
174 | - | let | |
175 | - | then | |
166 | + | let W = k(this, (U + "_staked")) | |
167 | + | let X = if ((C > W)) | |
168 | + | then W | |
176 | 169 | else C | |
177 | - | (K(-( | |
170 | + | (K(-(X)) ++ [IntegerEntry((U + "_staked"), (W - X))]) | |
178 | 171 | } | |
179 | 172 | ||
180 | 173 | ||
181 | - | func | |
182 | - | let | |
183 | - | if (( | |
184 | - | then [ScriptTransfer( | |
174 | + | func Y (u,Z,w) = { | |
175 | + | let S = v(u, w) | |
176 | + | if ((S == S)) | |
177 | + | then [ScriptTransfer(Z, w, fromBase58String(f))] | |
185 | 178 | else throw("Strict value is not equal to itself.") | |
186 | 179 | } | |
187 | 180 | ||
188 | 181 | ||
189 | - | @Callable( | |
182 | + | @Callable(aa) | |
190 | 183 | func init (r) = { | |
191 | 184 | let u = o(this, "currentPool") | |
192 | - | if ((indexOf(d, toString( | |
185 | + | if ((indexOf(d, toString(aa.caller)) == unit)) | |
193 | 186 | then throw("Access denied") | |
194 | 187 | else if ((u == "")) | |
195 | 188 | then [StringEntry("currentPool", r)] | |
198 | 191 | ||
199 | 192 | ||
200 | 193 | ||
201 | - | @Callable( | |
194 | + | @Callable(aa) | |
202 | 195 | func rebalance (r) = { | |
203 | 196 | let u = o(this, "currentPool") | |
204 | - | if ((indexOf(d, toString( | |
197 | + | if ((indexOf(d, toString(aa.caller)) == unit)) | |
205 | 198 | then throw("Access denied") | |
206 | 199 | else if ((u == r)) | |
207 | 200 | then throw(("Already supplied to" + u)) | |
208 | 201 | else { | |
209 | - | let y = | |
202 | + | let y = R() | |
210 | 203 | if ((y == y)) | |
211 | 204 | then M(r) | |
212 | 205 | else throw("Strict value is not equal to itself.") | |
215 | 208 | ||
216 | 209 | ||
217 | 210 | ||
218 | - | @Callable( | |
211 | + | @Callable(aa) | |
219 | 212 | func stake () = { | |
220 | - | let | |
221 | - | let w = | |
213 | + | let U = toString(aa.caller) | |
214 | + | let w = aa.payments[0].amount | |
222 | 215 | let u = o(this, "currentPool") | |
223 | 216 | if (if ((0 >= w)) | |
224 | 217 | then true | |
225 | - | else ( | |
218 | + | else (aa.payments[0].assetId != fromBase58String(f))) | |
226 | 219 | then throw("invalid token attached") | |
227 | 220 | else if ((u == "")) | |
228 | 221 | then throw("Pool not initialized") | |
229 | 222 | else { | |
230 | 223 | let F = z() | |
231 | - | let | |
224 | + | let ab = if ((F > a)) | |
232 | 225 | then "" | |
233 | 226 | else "" | |
234 | - | if (( | |
235 | - | then ((U | |
227 | + | if ((ab == ab)) | |
228 | + | then ((T(U, w) ++ M(u)) ++ P(u, F)) | |
236 | 229 | else throw("Strict value is not equal to itself.") | |
237 | 230 | } | |
238 | 231 | } | |
239 | 232 | ||
240 | 233 | ||
241 | 234 | ||
242 | - | @Callable( | |
235 | + | @Callable(aa) | |
243 | 236 | func unstake (w) = { | |
244 | - | let | |
237 | + | let U = toString(aa.caller) | |
245 | 238 | let u = o(this, "currentPool") | |
246 | 239 | let ac = fromBase58String(f) | |
247 | 240 | let F = z() | |
248 | - | let | |
241 | + | let ab = if ((F > a)) | |
249 | 242 | then "" | |
250 | 243 | else "" | |
251 | - | if (( | |
252 | - | then (( | |
244 | + | if ((ab == ab)) | |
245 | + | then ((V(U, w) ++ Y(u, aa.caller, w)) ++ P(u, F)) | |
253 | 246 | else throw("Strict value is not equal to itself.") | |
254 | 247 | } | |
255 | 248 | ||
256 | 249 | ||
257 | - | @Verifier( | |
258 | - | func ad () = sigVerify( | |
250 | + | @Verifier(S) | |
251 | + | func ad () = sigVerify(S.bodyBytes, S.proofs[0], S.senderPublicKey) | |
259 | 252 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = 1000000 | |
5 | 5 | ||
6 | 6 | let b = 100000000 | |
7 | 7 | ||
8 | 8 | let c = (b * b) | |
9 | 9 | ||
10 | 10 | let d = ["3NAmqGjxRBRPoRHZUUqvhiNS6axnGpinLHC"] | |
11 | 11 | ||
12 | 12 | let e = Address(base58'3My6LmrRSRvJ73T14oT5k53SGPavGFoacWc') | |
13 | 13 | ||
14 | 14 | let f = "HHmaFQpUobwKxzjz4ECaBPtoF69kujKwU2cozaUzTsgv" | |
15 | 15 | ||
16 | 16 | let g = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v"] | |
17 | 17 | ||
18 | 18 | func h (f) = { | |
19 | 19 | let i = f | |
20 | 20 | if ($isInstanceOf(i, "Unit")) | |
21 | 21 | then { | |
22 | 22 | let j = i | |
23 | 23 | wavesBalance(this).available | |
24 | 24 | } | |
25 | 25 | else assetBalance(this, value(f)) | |
26 | 26 | } | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func k (l,m) = { | |
30 | 30 | let i = getInteger(l, m) | |
31 | 31 | if ($isInstanceOf(i, "Int")) | |
32 | 32 | then { | |
33 | 33 | let n = i | |
34 | 34 | n | |
35 | 35 | } | |
36 | 36 | else 0 | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func o (l,m) = { | |
41 | 41 | let i = getString(l, m) | |
42 | 42 | if ($isInstanceOf(i, "String")) | |
43 | 43 | then { | |
44 | 44 | let n = i | |
45 | 45 | n | |
46 | 46 | } | |
47 | 47 | else "" | |
48 | 48 | } | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func p (f) = { | |
52 | 52 | let i = f | |
53 | 53 | if ($isInstanceOf(i, "ByteVector")) | |
54 | 54 | then { | |
55 | 55 | let n = i | |
56 | 56 | toBase58String(n) | |
57 | 57 | } | |
58 | 58 | else "WAVES" | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func q (r) = { | |
63 | 63 | let s = assetBalance(Address(fromBase58String(r)), fromBase58String(f)) | |
64 | 64 | s | |
65 | 65 | } | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func t () = { | |
69 | 69 | let u = o(this, "currentPool") | |
70 | 70 | if ((u == "")) | |
71 | 71 | then throw(("Cannot find pool with id " + u)) | |
72 | 72 | else q(u) | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func v (r,w) = { | |
77 | 77 | let x = Address(fromBase58String(r)) | |
78 | 78 | let y = if ((w > 0)) | |
79 | 79 | then invoke(x, "withdraw", [f, w], nil) | |
80 | 80 | else "" | |
81 | 81 | if ((y == y)) | |
82 | 82 | then y | |
83 | 83 | else throw("Strict value is not equal to itself.") | |
84 | 84 | } | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func z () = { | |
88 | 88 | let A = k(this, "global_staked") | |
89 | 89 | let B = k(this, "global_lastCheckSRate") | |
90 | 90 | let C = fraction(A, B, b) | |
91 | 91 | let D = t() | |
92 | 92 | let E = (D - C) | |
93 | 93 | let F = fraction(E, 5000000, b) | |
94 | 94 | if ((F > 0)) | |
95 | 95 | then F | |
96 | 96 | else 0 | |
97 | 97 | } | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | func G () = { | |
101 | 101 | let H = k(this, "global_lastCheckSRate") | |
102 | 102 | let A = k(this, "global_staked") | |
103 | 103 | let I = fraction(A, H, b) | |
104 | 104 | if ((H == 0)) | |
105 | 105 | then b | |
106 | 106 | else if ((I == 0)) | |
107 | 107 | then H | |
108 | 108 | else { | |
109 | 109 | let J = fraction(H, (fraction((fraction(t(), a, I) - a), (b - 5000000), b) + a), a) | |
110 | 110 | if ((b > J)) | |
111 | 111 | then H | |
112 | 112 | else J | |
113 | 113 | } | |
114 | 114 | } | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | func K (L) = { | |
118 | 118 | let A = k(this, "global_staked") | |
119 | 119 | let J = G() | |
120 | 120 | [IntegerEntry("global_staked", (A + L)), IntegerEntry("global_lastCheckSRate", J)] | |
121 | 121 | } | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | func M (r) = if ((indexOf(g, r) == unit)) | |
125 | 125 | then throw(("Unknown poolId " + r)) | |
126 | 126 | else { | |
127 | 127 | let N = fromBase58String(f) | |
128 | 128 | let s = h(N) | |
129 | 129 | let O = invoke(Address(fromBase58String(r)), "supply", nil, [AttachedPayment(N, s)]) | |
130 | 130 | if ((O == O)) | |
131 | 131 | then [StringEntry("currentPool", r)] | |
132 | 132 | else throw("Strict value is not equal to itself.") | |
133 | 133 | } | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func P (r,F) = { | |
137 | - | let Q = if ((F > a)) | |
138 | - | then throw(("1) Fee " + toString(F))) | |
139 | - | else "" | |
137 | + | let Q = v(r, F) | |
140 | 138 | if ((Q == Q)) | |
141 | - | then { | |
142 | - | let R = v(r, F) | |
143 | - | if ((R == R)) | |
144 | - | then [ScriptTransfer(e, F, fromBase58String(f))] | |
145 | - | else throw("Strict value is not equal to itself.") | |
146 | - | } | |
139 | + | then [ScriptTransfer(e, F, fromBase58String(f))] | |
147 | 140 | else throw("Strict value is not equal to itself.") | |
148 | 141 | } | |
149 | 142 | ||
150 | 143 | ||
151 | - | func | |
144 | + | func R () = { | |
152 | 145 | let u = o(this, "currentPool") | |
153 | 146 | if ((u == "")) | |
154 | 147 | then throw(("Cannot find pool with id " + u)) | |
155 | 148 | else { | |
156 | 149 | let w = q(u) | |
157 | - | let | |
158 | - | if (( | |
159 | - | then | |
150 | + | let S = v(u, w) | |
151 | + | if ((S == S)) | |
152 | + | then S | |
160 | 153 | else throw("Strict value is not equal to itself.") | |
161 | 154 | } | |
162 | 155 | } | |
163 | 156 | ||
164 | 157 | ||
165 | - | func | |
158 | + | func T (U,w) = { | |
166 | 159 | let C = fraction(w, b, G()) | |
167 | - | (K(C) ++ [IntegerEntry(( | |
160 | + | (K(C) ++ [IntegerEntry((U + "_staked"), (k(this, (U + "_staked")) + C))]) | |
168 | 161 | } | |
169 | 162 | ||
170 | 163 | ||
171 | - | func | |
164 | + | func V (U,w) = { | |
172 | 165 | let C = fraction(w, b, G()) | |
173 | - | let | |
174 | - | let | |
175 | - | then | |
166 | + | let W = k(this, (U + "_staked")) | |
167 | + | let X = if ((C > W)) | |
168 | + | then W | |
176 | 169 | else C | |
177 | - | (K(-( | |
170 | + | (K(-(X)) ++ [IntegerEntry((U + "_staked"), (W - X))]) | |
178 | 171 | } | |
179 | 172 | ||
180 | 173 | ||
181 | - | func | |
182 | - | let | |
183 | - | if (( | |
184 | - | then [ScriptTransfer( | |
174 | + | func Y (u,Z,w) = { | |
175 | + | let S = v(u, w) | |
176 | + | if ((S == S)) | |
177 | + | then [ScriptTransfer(Z, w, fromBase58String(f))] | |
185 | 178 | else throw("Strict value is not equal to itself.") | |
186 | 179 | } | |
187 | 180 | ||
188 | 181 | ||
189 | - | @Callable( | |
182 | + | @Callable(aa) | |
190 | 183 | func init (r) = { | |
191 | 184 | let u = o(this, "currentPool") | |
192 | - | if ((indexOf(d, toString( | |
185 | + | if ((indexOf(d, toString(aa.caller)) == unit)) | |
193 | 186 | then throw("Access denied") | |
194 | 187 | else if ((u == "")) | |
195 | 188 | then [StringEntry("currentPool", r)] | |
196 | 189 | else nil | |
197 | 190 | } | |
198 | 191 | ||
199 | 192 | ||
200 | 193 | ||
201 | - | @Callable( | |
194 | + | @Callable(aa) | |
202 | 195 | func rebalance (r) = { | |
203 | 196 | let u = o(this, "currentPool") | |
204 | - | if ((indexOf(d, toString( | |
197 | + | if ((indexOf(d, toString(aa.caller)) == unit)) | |
205 | 198 | then throw("Access denied") | |
206 | 199 | else if ((u == r)) | |
207 | 200 | then throw(("Already supplied to" + u)) | |
208 | 201 | else { | |
209 | - | let y = | |
202 | + | let y = R() | |
210 | 203 | if ((y == y)) | |
211 | 204 | then M(r) | |
212 | 205 | else throw("Strict value is not equal to itself.") | |
213 | 206 | } | |
214 | 207 | } | |
215 | 208 | ||
216 | 209 | ||
217 | 210 | ||
218 | - | @Callable( | |
211 | + | @Callable(aa) | |
219 | 212 | func stake () = { | |
220 | - | let | |
221 | - | let w = | |
213 | + | let U = toString(aa.caller) | |
214 | + | let w = aa.payments[0].amount | |
222 | 215 | let u = o(this, "currentPool") | |
223 | 216 | if (if ((0 >= w)) | |
224 | 217 | then true | |
225 | - | else ( | |
218 | + | else (aa.payments[0].assetId != fromBase58String(f))) | |
226 | 219 | then throw("invalid token attached") | |
227 | 220 | else if ((u == "")) | |
228 | 221 | then throw("Pool not initialized") | |
229 | 222 | else { | |
230 | 223 | let F = z() | |
231 | - | let | |
224 | + | let ab = if ((F > a)) | |
232 | 225 | then "" | |
233 | 226 | else "" | |
234 | - | if (( | |
235 | - | then ((U | |
227 | + | if ((ab == ab)) | |
228 | + | then ((T(U, w) ++ M(u)) ++ P(u, F)) | |
236 | 229 | else throw("Strict value is not equal to itself.") | |
237 | 230 | } | |
238 | 231 | } | |
239 | 232 | ||
240 | 233 | ||
241 | 234 | ||
242 | - | @Callable( | |
235 | + | @Callable(aa) | |
243 | 236 | func unstake (w) = { | |
244 | - | let | |
237 | + | let U = toString(aa.caller) | |
245 | 238 | let u = o(this, "currentPool") | |
246 | 239 | let ac = fromBase58String(f) | |
247 | 240 | let F = z() | |
248 | - | let | |
241 | + | let ab = if ((F > a)) | |
249 | 242 | then "" | |
250 | 243 | else "" | |
251 | - | if (( | |
252 | - | then (( | |
244 | + | if ((ab == ab)) | |
245 | + | then ((V(U, w) ++ Y(u, aa.caller, w)) ++ P(u, F)) | |
253 | 246 | else throw("Strict value is not equal to itself.") | |
254 | 247 | } | |
255 | 248 | ||
256 | 249 | ||
257 | - | @Verifier( | |
258 | - | func ad () = sigVerify( | |
250 | + | @Verifier(S) | |
251 | + | func ad () = sigVerify(S.bodyBytes, S.proofs[0], S.senderPublicKey) | |
259 | 252 |
github/deemru/w8io/026f985 47.99 ms ◑