1 | | - | {-# STDLIB_VERSION 5 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = "" |
---|
7 | | - | |
---|
8 | | - | func c () = "%s__managerPublicKey" |
---|
9 | | - | |
---|
10 | | - | |
---|
11 | | - | func d () = "%s__pendingManagerPublicKey" |
---|
12 | | - | |
---|
13 | | - | |
---|
14 | | - | func e () = "%s__adminPubKeys" |
---|
15 | | - | |
---|
16 | | - | |
---|
17 | | - | func f (g,h) = makeString(["%s%s", g, h], a) |
---|
18 | | - | |
---|
19 | | - | |
---|
20 | | - | func i (g,h,j) = makeString(["%s%s%s%d", "fixedDeposit", g, h, toString(j)], a) |
---|
21 | | - | |
---|
22 | | - | |
---|
23 | | - | func k (g,h) = makeString(["%s%s%s", "revoked", g, h], a) |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | func l (g) = makeString(["%s%s", "revokedTotal", g], a) |
---|
27 | | - | |
---|
28 | | - | |
---|
29 | | - | func m (g,h) = makeString(["%s%s%s", "vestingStart", g, h], a) |
---|
30 | | - | |
---|
31 | | - | |
---|
32 | | - | func n (g,h) = makeString(["%s%s%s", "vestingEnd", g, h], a) |
---|
33 | | - | |
---|
34 | | - | |
---|
35 | | - | func o (g,h) = makeString(["%s%s%s", "amountPerBlock", g, h], a) |
---|
36 | | - | |
---|
37 | | - | |
---|
38 | | - | func p (g) = makeString(["%s%s", "claimDenied", g], a) |
---|
39 | | - | |
---|
40 | | - | |
---|
41 | | - | func q (r) = throw(makeString(["vesting_multiasset.ride:", r], " ")) |
---|
42 | | - | |
---|
43 | | - | |
---|
44 | | - | func s () = { |
---|
45 | | - | let t = getString(c()) |
---|
46 | | - | if ($isInstanceOf(t, "String")) |
---|
47 | | - | then { |
---|
48 | | - | let u = t |
---|
49 | | - | fromBase58String(u) |
---|
50 | | - | } |
---|
51 | | - | else if ($isInstanceOf(t, "Unit")) |
---|
52 | | - | then unit |
---|
53 | | - | else throw("Match error") |
---|
54 | | - | } |
---|
55 | | - | |
---|
56 | | - | |
---|
57 | | - | func v () = { |
---|
58 | | - | let t = getString(d()) |
---|
59 | | - | if ($isInstanceOf(t, "String")) |
---|
60 | | - | then { |
---|
61 | | - | let u = t |
---|
62 | | - | fromBase58String(u) |
---|
63 | | - | } |
---|
64 | | - | else if ($isInstanceOf(t, "Unit")) |
---|
65 | | - | then unit |
---|
66 | | - | else throw("Match error") |
---|
67 | | - | } |
---|
68 | | - | |
---|
69 | | - | |
---|
70 | | - | func w (x) = { |
---|
71 | | - | let y = q("permission denied") |
---|
72 | | - | let t = s() |
---|
73 | | - | if ($isInstanceOf(t, "ByteVector")) |
---|
74 | | - | then { |
---|
75 | | - | let z = t |
---|
76 | | - | if ((x.callerPublicKey == z)) |
---|
77 | | - | then true |
---|
78 | | - | else y |
---|
79 | | - | } |
---|
80 | | - | else if ($isInstanceOf(t, "Unit")) |
---|
81 | | - | then if ((x.caller == this)) |
---|
82 | | - | then true |
---|
83 | | - | else y |
---|
84 | | - | else throw("Match error") |
---|
85 | | - | } |
---|
86 | | - | |
---|
87 | | - | |
---|
88 | | - | func A (x) = { |
---|
89 | | - | let B = split(valueOrElse(getString(e()), b), a) |
---|
90 | | - | if (containsElement(B, toBase58String(x.callerPublicKey))) |
---|
91 | | - | then true |
---|
92 | | - | else { |
---|
93 | | - | let C = w(x) |
---|
94 | | - | if ((C == C)) |
---|
95 | | - | then true |
---|
96 | | - | else throw("Strict value is not equal to itself.") |
---|
97 | | - | } |
---|
98 | | - | } |
---|
99 | | - | |
---|
100 | | - | |
---|
101 | | - | func D (E,F,G,H) = makeString(["%d%d%d%d%d", E, F, "0", G, H], a) |
---|
102 | | - | |
---|
103 | | - | |
---|
104 | | - | func I (E,F,G,H) = D(toString(E), toString(F), toString(G), toString(H)) |
---|
105 | | - | |
---|
106 | | - | |
---|
107 | | - | func J (g,h) = parseIntValue(split(value(getString(f(g, h))), a)[1]) |
---|
108 | | - | |
---|
109 | | - | |
---|
110 | | - | func K (g,h) = parseIntValue(split(value(getString(f(g, h))), a)[2]) |
---|
111 | | - | |
---|
112 | | - | |
---|
113 | | - | func L (g,h) = parseIntValue(split(value(getString(f(g, h))), a)[3]) |
---|
114 | | - | |
---|
115 | | - | |
---|
116 | | - | func M (g,h) = parseIntValue(split(value(getString(f(g, h))), a)[5]) |
---|
117 | | - | |
---|
118 | | - | |
---|
119 | | - | func N (g,h) = { |
---|
120 | | - | let O = valueOrElse(getBoolean(k(g, h)), false) |
---|
121 | | - | if (O) |
---|
122 | | - | then K(g, h) |
---|
123 | | - | else { |
---|
124 | | - | let P = M(g, h) |
---|
125 | | - | if ((P >= height)) |
---|
126 | | - | then 0 |
---|
127 | | - | else { |
---|
128 | | - | let Q = value(getInteger(n(g, h))) |
---|
129 | | - | if ((height > Q)) |
---|
130 | | - | then K(g, h) |
---|
131 | | - | else { |
---|
132 | | - | let R = (height - P) |
---|
133 | | - | (value(getInteger(o(g, h))) * R) |
---|
134 | | - | } |
---|
135 | | - | } |
---|
136 | | - | } |
---|
137 | | - | } |
---|
138 | | - | |
---|
139 | | - | |
---|
140 | | - | func S (g,h,T) = valueOrElse(getInteger(i(g, h, T)), 0) |
---|
141 | | - | |
---|
142 | | - | |
---|
143 | | - | func U (g,h) = { |
---|
144 | | - | let V = addressFromStringValue(h) |
---|
145 | | - | let W = fromBase58String(g) |
---|
146 | | - | let X = N(g, h) |
---|
147 | | - | let Y = [if ((valueOrElse(getBoolean(p(g)), false) == false)) |
---|
148 | | - | then true |
---|
149 | | - | else q("asset claim denied"), if ((X != 0)) |
---|
150 | | - | then true |
---|
151 | | - | else q("nothing to claim")] |
---|
152 | | - | if ((Y == Y)) |
---|
153 | | - | then { |
---|
154 | | - | let E = J(g, h) |
---|
155 | | - | let F = K(g, h) |
---|
156 | | - | let Z = L(g, h) |
---|
157 | | - | let O = valueOrElse(getBoolean(k(g, h)), false) |
---|
158 | | - | if (O) |
---|
159 | | - | then [ScriptTransfer(V, F, W), StringEntry(f(g, h), I(E, 0, (Z + F), height))] |
---|
160 | | - | else [ScriptTransfer(V, X, W), StringEntry(f(g, h), I(E, (F - X), (Z + X), height))] |
---|
161 | | - | } |
---|
162 | | - | else throw("Strict value is not equal to itself.") |
---|
163 | | - | } |
---|
164 | | - | |
---|
165 | | - | |
---|
166 | | - | func aa (g,h,T) = { |
---|
167 | | - | let ab = getInteger(i(g, h, T)) |
---|
168 | | - | let Y = [if ((valueOrElse(getBoolean(p(g)), false) == false)) |
---|
169 | | - | then true |
---|
170 | | - | else q("asset claim denied"), if ((height > T)) |
---|
171 | | - | then true |
---|
172 | | - | else q("current height must be more than releaseBlock for fixed deposit"), if ((valueOrElse(ab, 0) != 0)) |
---|
173 | | - | then true |
---|
174 | | - | else q("no fixed deposit for assetId/address/height")] |
---|
175 | | - | if ((Y == Y)) |
---|
176 | | - | then { |
---|
177 | | - | let V = addressFromStringValue(h) |
---|
178 | | - | let W = fromBase58String(g) |
---|
179 | | - | let X = value(ab) |
---|
180 | | - | [ScriptTransfer(V, X, W), IntegerEntry(i(g, h, T), 0)] |
---|
181 | | - | } |
---|
182 | | - | else throw("Strict value is not equal to itself.") |
---|
183 | | - | } |
---|
184 | | - | |
---|
185 | | - | |
---|
186 | | - | @Callable(x) |
---|
187 | | - | func withdrawRevoked (g) = { |
---|
188 | | - | let X = valueOrElse(getInteger(l(g)), 0) |
---|
189 | | - | let W = fromBase58String(g) |
---|
190 | | - | let Y = [w(x), if ((X > 0)) |
---|
191 | | - | then true |
---|
192 | | - | else q("revoked amount is zero, nothing to withdraw")] |
---|
193 | | - | if ((Y == Y)) |
---|
194 | | - | then [ScriptTransfer(x.caller, X, W), IntegerEntry(l(g), 0)] |
---|
195 | | - | else throw("Strict value is not equal to itself.") |
---|
196 | | - | } |
---|
197 | | - | |
---|
198 | | - | |
---|
199 | | - | |
---|
200 | | - | @Callable(x) |
---|
201 | | - | func createDepositFor (h,ac) = { |
---|
202 | | - | let X = x.payments[0].amount |
---|
203 | | - | let g = toBase58String(value(x.payments[0].assetId)) |
---|
204 | | - | let ad = (height + ac) |
---|
205 | | - | let ae = (ad - height) |
---|
206 | | - | let af = (X / ae) |
---|
207 | | - | let Y = [if ((ad > height)) |
---|
208 | | - | then true |
---|
209 | | - | else q("endHeight must be more than height"), if ((getString(f(g, h)) == unit)) |
---|
210 | | - | then true |
---|
211 | | - | else q("deposit of this asset for user already exists"), if ((af != 0)) |
---|
212 | | - | then true |
---|
213 | | - | else q("attached amount too small or blocksDuration too large — will claimed zero per block")] |
---|
214 | | - | if ((Y == Y)) |
---|
215 | | - | then [StringEntry(f(g, h), I(X, X, 0, height)), IntegerEntry(m(g, h), height), IntegerEntry(n(g, h), ad), IntegerEntry(o(g, h), af)] |
---|
216 | | - | else throw("Strict value is not equal to itself.") |
---|
217 | | - | } |
---|
218 | | - | |
---|
219 | | - | |
---|
220 | | - | |
---|
221 | | - | @Callable(x) |
---|
222 | | - | func increaseDepositFor (h) = { |
---|
223 | | - | let X = x.payments[0].amount |
---|
224 | | - | let g = toBase58String(value(x.payments[0].assetId)) |
---|
225 | | - | let ag = N(g, h) |
---|
226 | | - | let ah = if ((ag > 0)) |
---|
227 | | - | then U(g, h) |
---|
228 | | - | else unit |
---|
229 | | - | if ((ah == ah)) |
---|
230 | | - | then { |
---|
231 | | - | let ad = value(getInteger(n(g, h))) |
---|
232 | | - | let ae = (ad - height) |
---|
233 | | - | let af = value(getInteger(o(g, h))) |
---|
234 | | - | let ai = (X / ae) |
---|
235 | | - | let aj = J(g, h) |
---|
236 | | - | let ak = K(g, h) |
---|
237 | | - | let al = L(g, h) |
---|
238 | | - | let am = M(g, h) |
---|
239 | | - | let Y = [if ((valueOrElse(getBoolean(k(g, h)), false) == false)) |
---|
240 | | - | then true |
---|
241 | | - | else q("deposit for user is revoked"), if ((getString(f(g, h)) != unit)) |
---|
242 | | - | then true |
---|
243 | | - | else q("deposit for user doesn't exists"), if ((ai != 0)) |
---|
244 | | - | then true |
---|
245 | | - | else q("attached amount too small — increase is zero per block")] |
---|
246 | | - | if ((Y == Y)) |
---|
247 | | - | then [StringEntry(f(g, h), I((aj + X), (ak + X), al, am)), IntegerEntry(o(g, h), (af + ai))] |
---|
248 | | - | else throw("Strict value is not equal to itself.") |
---|
249 | | - | } |
---|
250 | | - | else throw("Strict value is not equal to itself.") |
---|
251 | | - | } |
---|
252 | | - | |
---|
253 | | - | |
---|
254 | | - | |
---|
255 | | - | @Callable(x) |
---|
256 | | - | func revokeDepositFor (g,h) = { |
---|
257 | | - | let E = J(g, h) |
---|
258 | | - | let F = K(g, h) |
---|
259 | | - | let G = L(g, h) |
---|
260 | | - | let H = M(g, h) |
---|
261 | | - | let an = N(g, h) |
---|
262 | | - | let ao = valueOrElse(getInteger(l(g)), 0) |
---|
263 | | - | let ap = (F - an) |
---|
264 | | - | let aq = (ao + ap) |
---|
265 | | - | let Y = [A(x), if ((getString(f(g, h)) != unit)) |
---|
266 | | - | then true |
---|
267 | | - | else q("deposit of this asset for user is not exists"), if ((aq > ao)) |
---|
268 | | - | then true |
---|
269 | | - | else q("newRevokedTotal can't be less or equal than revokedTotal")] |
---|
270 | | - | if ((Y == Y)) |
---|
271 | | - | then [BooleanEntry(k(g, h), true), IntegerEntry(l(g), aq), StringEntry(f(g, h), I(E, an, G, H))] |
---|
272 | | - | else throw("Strict value is not equal to itself.") |
---|
273 | | - | } |
---|
274 | | - | |
---|
275 | | - | |
---|
276 | | - | |
---|
277 | | - | @Callable(x) |
---|
278 | | - | func claim (g) = U(g, toBase58String(x.caller.bytes)) |
---|
279 | | - | |
---|
280 | | - | |
---|
281 | | - | |
---|
282 | | - | @Callable(x) |
---|
283 | | - | func claimFor (g,h) = U(g, h) |
---|
284 | | - | |
---|
285 | | - | |
---|
286 | | - | |
---|
287 | | - | @Callable(x) |
---|
288 | | - | func claimREADONLY (g,h) = { |
---|
289 | | - | let X = N(g, h) |
---|
290 | | - | $Tuple2(nil, X) |
---|
291 | | - | } |
---|
292 | | - | |
---|
293 | | - | |
---|
294 | | - | |
---|
295 | | - | @Callable(x) |
---|
296 | | - | func createFixedDepositFor (h,T) = { |
---|
297 | | - | let X = x.payments[0].amount |
---|
298 | | - | let g = toBase58String(value(x.payments[0].assetId)) |
---|
299 | | - | let ab = i(g, h, T) |
---|
300 | | - | let Y = [if ((T > height)) |
---|
301 | | - | then true |
---|
302 | | - | else q("releaseBlock must be more than height"), if ((getInteger(ab) == unit)) |
---|
303 | | - | then true |
---|
304 | | - | else q("deposit for this height for user already exists")] |
---|
305 | | - | if ((Y == Y)) |
---|
306 | | - | then [IntegerEntry(ab, X)] |
---|
307 | | - | else throw("Strict value is not equal to itself.") |
---|
308 | | - | } |
---|
309 | | - | |
---|
310 | | - | |
---|
311 | | - | |
---|
312 | | - | @Callable(x) |
---|
313 | | - | func claimFixed (g,T) = aa(g, toBase58String(x.caller.bytes), T) |
---|
314 | | - | |
---|
315 | | - | |
---|
316 | | - | |
---|
317 | | - | @Callable(x) |
---|
318 | | - | func claimFixedFor (g,h,T) = aa(g, h, T) |
---|
319 | | - | |
---|
320 | | - | |
---|
321 | | - | |
---|
322 | | - | @Callable(x) |
---|
323 | | - | func claimFixedREADONLY (g,h,T) = { |
---|
324 | | - | let X = S(g, h, T) |
---|
325 | | - | $Tuple2(nil, X) |
---|
326 | | - | } |
---|
327 | | - | |
---|
328 | | - | |
---|
329 | | - | |
---|
330 | | - | @Callable(x) |
---|
331 | | - | func revokeFixedDepositFor (g,h,T) = { |
---|
332 | | - | let Y = [A(x), if ((T > height)) |
---|
333 | | - | then true |
---|
334 | | - | else q("can't revoke deposit in past"), if ((valueOrElse(getInteger(i(g, h, T)), 0) != 0)) |
---|
335 | | - | then true |
---|
336 | | - | else q("deposit for this height for user not exists")] |
---|
337 | | - | if ((Y == Y)) |
---|
338 | | - | then { |
---|
339 | | - | let X = value(getInteger(i(g, h, T))) |
---|
340 | | - | [IntegerEntry(l(g), X), IntegerEntry(i(g, h, T), 0)] |
---|
341 | | - | } |
---|
342 | | - | else throw("Strict value is not equal to itself.") |
---|
343 | | - | } |
---|
344 | | - | |
---|
345 | | - | |
---|
346 | | - | |
---|
347 | | - | @Callable(x) |
---|
348 | | - | func denyAssetClaim (g) = { |
---|
349 | | - | let Y = [A(x), if ((valueOrElse(getBoolean(p(g)), false) == false)) |
---|
350 | | - | then true |
---|
351 | | - | else q("asset already denied")] |
---|
352 | | - | if ((Y == Y)) |
---|
353 | | - | then [BooleanEntry(p(g), true)] |
---|
354 | | - | else throw("Strict value is not equal to itself.") |
---|
355 | | - | } |
---|
356 | | - | |
---|
357 | | - | |
---|
358 | | - | |
---|
359 | | - | @Callable(x) |
---|
360 | | - | func allowAssetClaim (g) = { |
---|
361 | | - | let Y = [A(x), if ((valueOrElse(getBoolean(p(g)), false) == true)) |
---|
362 | | - | then true |
---|
363 | | - | else q("asset already allowed")] |
---|
364 | | - | if ((Y == Y)) |
---|
365 | | - | then [DeleteEntry(p(g))] |
---|
366 | | - | else throw("Strict value is not equal to itself.") |
---|
367 | | - | } |
---|
368 | | - | |
---|
369 | | - | |
---|
370 | | - | |
---|
371 | | - | @Callable(x) |
---|
372 | | - | func stats (g,h) = $Tuple2(nil, [value(getInteger(m(g, h))), value(getInteger(n(g, h))), J(g, h), L(g, h), K(g, h), N(g, h)]) |
---|
373 | | - | |
---|
374 | | - | |
---|
375 | | - | |
---|
376 | | - | @Callable(x) |
---|
377 | | - | func setManager (ar) = { |
---|
378 | | - | let as = w(x) |
---|
379 | | - | if ((as == as)) |
---|
380 | | - | then { |
---|
381 | | - | let at = fromBase58String(ar) |
---|
382 | | - | if ((at == at)) |
---|
383 | | - | then [StringEntry(d(), ar)] |
---|
384 | | - | else throw("Strict value is not equal to itself.") |
---|
385 | | - | } |
---|
386 | | - | else throw("Strict value is not equal to itself.") |
---|
387 | | - | } |
---|
388 | | - | |
---|
389 | | - | |
---|
390 | | - | |
---|
391 | | - | @Callable(x) |
---|
392 | | - | func confirmManager () = { |
---|
393 | | - | let au = v() |
---|
394 | | - | let av = if (isDefined(au)) |
---|
395 | | - | then true |
---|
396 | | - | else q("no pending manager") |
---|
397 | | - | if ((av == av)) |
---|
398 | | - | then { |
---|
399 | | - | let aw = if ((x.callerPublicKey == value(au))) |
---|
400 | | - | then true |
---|
401 | | - | else q("you are not pending manager") |
---|
402 | | - | if ((aw == aw)) |
---|
403 | | - | then [StringEntry(c(), toBase58String(value(au))), DeleteEntry(d())] |
---|
404 | | - | else throw("Strict value is not equal to itself.") |
---|
405 | | - | } |
---|
406 | | - | else throw("Strict value is not equal to itself.") |
---|
407 | | - | } |
---|
408 | | - | |
---|
409 | | - | |
---|
410 | | - | @Verifier(ax) |
---|
411 | | - | func ay () = { |
---|
412 | | - | let az = { |
---|
413 | | - | let t = s() |
---|
414 | | - | if ($isInstanceOf(t, "ByteVector")) |
---|
415 | | - | then { |
---|
416 | | - | let z = t |
---|
417 | | - | z |
---|
418 | | - | } |
---|
419 | | - | else if ($isInstanceOf(t, "Unit")) |
---|
420 | | - | then ax.senderPublicKey |
---|
421 | | - | else throw("Match error") |
---|
422 | | - | } |
---|
423 | | - | sigVerify(ax.bodyBytes, ax.proofs[0], az) |
---|
424 | | - | } |
---|
425 | | - | |
---|
| 1 | + | # no script |
---|