35 | | - | func n (h) = if ((h == e)) |
---|
36 | | - | then unit |
---|
37 | | - | else fromBase58String(h) |
---|
38 | | - | |
---|
39 | | - | |
---|
40 | | - | func o (p) = if ((0 > p)) |
---|
41 | | - | then -(p) |
---|
42 | | - | else p |
---|
43 | | - | |
---|
44 | | - | |
---|
45 | | - | func q () = makeString(["%s", "factory"], a) |
---|
46 | | - | |
---|
47 | | - | |
---|
48 | | - | func r () = makeString(["%s", "managerPublicKey"], a) |
---|
49 | | - | |
---|
50 | | - | |
---|
51 | | - | func s () = makeString(["%s", "lpAssetId"], a) |
---|
52 | | - | |
---|
53 | | - | |
---|
54 | | - | func t () = makeString(["%s", "proxyTreasury"], a) |
---|
55 | | - | |
---|
56 | | - | |
---|
57 | | - | func u () = makeString(["%s", "mainTreasury"], a) |
---|
58 | | - | |
---|
59 | | - | |
---|
60 | | - | func v () = makeString(["%s", "businessTreasury"], a) |
---|
61 | | - | |
---|
62 | | - | |
---|
63 | | - | func w () = makeString(["%s", "businessTreasuryPart"], a) |
---|
64 | | - | |
---|
65 | | - | |
---|
66 | | - | func x () = makeString(["%s", "powerContract"], a) |
---|
67 | | - | |
---|
68 | | - | |
---|
69 | | - | func y () = makeString(["%s", "powerShareRatio"], a) |
---|
70 | | - | |
---|
71 | | - | |
---|
72 | | - | func z () = makeString(["%s", "powerAssetId"], a) |
---|
73 | | - | |
---|
74 | | - | |
---|
75 | | - | func A (k) = makeString(["%s%s", "invested", j(k)], a) |
---|
76 | | - | |
---|
77 | | - | |
---|
78 | | - | func B (k) = makeString(["%s%s", "donated", j(k)], a) |
---|
79 | | - | |
---|
80 | | - | |
---|
81 | | - | func C (D) = makeString(["%s%s", "available", toString(D)], a) |
---|
82 | | - | |
---|
83 | | - | |
---|
84 | | - | func E (D) = makeString(["%s%s", "claimed", toString(D)], a) |
---|
85 | | - | |
---|
86 | | - | |
---|
87 | | - | func F () = makeString(["%s", "currentPeriod"], a) |
---|
88 | | - | |
---|
89 | | - | |
---|
90 | | - | func G (H) = makeString(["%s%d", "price", toString(H)], a) |
---|
91 | | - | |
---|
92 | | - | |
---|
93 | | - | func I (H) = makeString(["%s%d", "startHeight", toString(H)], a) |
---|
94 | | - | |
---|
95 | | - | |
---|
96 | | - | func J (H) = makeString(["%s%d", "powerManagerBonus", toString(H)], a) |
---|
97 | | - | |
---|
98 | | - | |
---|
99 | | - | func K (H) = makeString(["%s%d", "claimWavesAmount", toString(H)], a) |
---|
100 | | - | |
---|
101 | | - | |
---|
102 | | - | func L () = "%s__periodLength" |
---|
103 | | - | |
---|
104 | | - | |
---|
105 | | - | func M () = "%s__investPeriodLength" |
---|
106 | | - | |
---|
107 | | - | |
---|
108 | | - | func N () = "%s__blockProcessingReward" |
---|
109 | | - | |
---|
110 | | - | |
---|
111 | | - | func O () = "%s__nextBlockToProcess" |
---|
112 | | - | |
---|
113 | | - | |
---|
114 | | - | func P (Q) = makeString(["%s%d", "blockProcessed", toString(Q)], a) |
---|
115 | | - | |
---|
116 | | - | |
---|
117 | | - | func R () = "%s__withdrawal" |
---|
118 | | - | |
---|
119 | | - | |
---|
120 | | - | func S (H) = makeString(["%s%d", "withdrawalPeriod", toString(H)], a) |
---|
121 | | - | |
---|
122 | | - | |
---|
123 | | - | func T (D,U) = makeString(["%s%s%s", "withdrawal", toString(D), toBase58String(U)], a) |
---|
124 | | - | |
---|
125 | | - | |
---|
126 | | - | func V (W,X,Y,Z) = { |
---|
127 | | - | let aa = { |
---|
128 | | - | let l = Z |
---|
129 | | - | if ($isInstanceOf(l, "ByteVector")) |
---|
130 | | - | then { |
---|
131 | | - | let m = l |
---|
132 | | - | toBase58String(m) |
---|
133 | | - | } |
---|
134 | | - | else if ($isInstanceOf(l, "Unit")) |
---|
135 | | - | then "SOON" |
---|
136 | | - | else throw("Match error") |
---|
137 | | - | } |
---|
138 | | - | makeString(["%s%d%d%s", W, toString(X), toString(Y), aa], a) |
---|
139 | | - | } |
---|
140 | | - | |
---|
141 | | - | |
---|
142 | | - | func ab (D,U) = makeString(["%s%s%s", "withdrawalHistory", toString(D), toBase58String(U)], a) |
---|
143 | | - | |
---|
144 | | - | |
---|
145 | | - | func ac (H) = makeString(["%s%d", "periodReward", toString(H)], a) |
---|
146 | | - | |
---|
147 | | - | |
---|
148 | | - | func ad (H) = makeString(["%s%d", "periodRewardAmount", toString(H)], a) |
---|
149 | | - | |
---|
150 | | - | |
---|
151 | | - | func ae (h) = { |
---|
152 | | - | let af = split(h, a) |
---|
153 | | - | if ((size(af) == 5)) |
---|
154 | | - | then { |
---|
155 | | - | let W = af[1] |
---|
156 | | - | let X = valueOrErrorMessage(parseInt(af[2]), g("invalid lpAssetAmount")) |
---|
157 | | - | let Y = valueOrErrorMessage(parseInt(af[3]), g("invalid targetPeriod")) |
---|
158 | | - | let Z = af[4] |
---|
159 | | - | $Tuple4(W, X, Y, Z) |
---|
160 | | - | } |
---|
161 | | - | else i("invalid withdrawal request value") |
---|
162 | | - | } |
---|
163 | | - | |
---|
164 | | - | |
---|
165 | | - | let ag = { |
---|
166 | | - | let l = getString(this, q()) |
---|
167 | | - | if ($isInstanceOf(l, "String")) |
---|
168 | | - | then { |
---|
169 | | - | let h = l |
---|
170 | | - | addressFromString(h) |
---|
171 | | - | } |
---|
172 | | - | else if ($isInstanceOf(l, "Unit")) |
---|
173 | | - | then unit |
---|
174 | | - | else throw("Match error") |
---|
175 | | - | } |
---|
176 | | - | |
---|
177 | | - | let ah = valueOrErrorMessage(ag, g("invalid factory address")) |
---|
178 | | - | |
---|
179 | | - | let ai = { |
---|
180 | | - | let l = ag |
---|
181 | | - | if ($isInstanceOf(l, "Address")) |
---|
182 | | - | then { |
---|
183 | | - | let aj = l |
---|
184 | | - | let ak = getString(aj, s()) |
---|
185 | | - | if ($isInstanceOf(ak, "String")) |
---|
186 | | - | then { |
---|
187 | | - | let h = ak |
---|
188 | | - | fromBase58String(h) |
---|
189 | | - | } |
---|
190 | | - | else if ($isInstanceOf(ak, "Unit")) |
---|
191 | | - | then unit |
---|
192 | | - | else throw("Match error") |
---|
193 | | - | } |
---|
194 | | - | else if ($isInstanceOf(l, "Unit")) |
---|
195 | | - | then unit |
---|
196 | | - | else throw("Match error") |
---|
197 | | - | } |
---|
198 | | - | |
---|
199 | | - | let al = valueOrErrorMessage(ai, g("invalid lpAssetId")) |
---|
200 | | - | |
---|
201 | | - | let am = { |
---|
202 | | - | let l = ag |
---|
203 | | - | if ($isInstanceOf(l, "Address")) |
---|
204 | | - | then { |
---|
205 | | - | let aj = l |
---|
206 | | - | let ak = getString(aj, t()) |
---|
207 | | - | if ($isInstanceOf(ak, "String")) |
---|
208 | | - | then { |
---|
209 | | - | let h = ak |
---|
210 | | - | addressFromString(h) |
---|
211 | | - | } |
---|
212 | | - | else if ($isInstanceOf(ak, "Unit")) |
---|
213 | | - | then unit |
---|
214 | | - | else throw("Match error") |
---|
215 | | - | } |
---|
216 | | - | else if ($isInstanceOf(l, "Unit")) |
---|
217 | | - | then unit |
---|
218 | | - | else throw("Match error") |
---|
219 | | - | } |
---|
220 | | - | |
---|
221 | | - | let an = valueOrErrorMessage(am, g("invalid proxy treasury address")) |
---|
222 | | - | |
---|
223 | | - | let ao = { |
---|
224 | | - | let l = ag |
---|
225 | | - | if ($isInstanceOf(l, "Address")) |
---|
226 | | - | then { |
---|
227 | | - | let aj = l |
---|
228 | | - | let ak = getString(aj, u()) |
---|
229 | | - | if ($isInstanceOf(ak, "String")) |
---|
230 | | - | then { |
---|
231 | | - | let h = ak |
---|
232 | | - | addressFromString(h) |
---|
233 | | - | } |
---|
234 | | - | else if ($isInstanceOf(ak, "Unit")) |
---|
235 | | - | then unit |
---|
236 | | - | else throw("Match error") |
---|
237 | | - | } |
---|
238 | | - | else if ($isInstanceOf(l, "Unit")) |
---|
239 | | - | then unit |
---|
240 | | - | else throw("Match error") |
---|
241 | | - | } |
---|
242 | | - | |
---|
243 | | - | let ap = { |
---|
244 | | - | let l = ag |
---|
245 | | - | if ($isInstanceOf(l, "Address")) |
---|
246 | | - | then { |
---|
247 | | - | let aj = l |
---|
248 | | - | let ak = getString(aj, v()) |
---|
249 | | - | if ($isInstanceOf(ak, "String")) |
---|
250 | | - | then { |
---|
251 | | - | let h = ak |
---|
252 | | - | addressFromString(h) |
---|
253 | | - | } |
---|
254 | | - | else if ($isInstanceOf(ak, "Unit")) |
---|
255 | | - | then unit |
---|
256 | | - | else throw("Match error") |
---|
257 | | - | } |
---|
258 | | - | else if ($isInstanceOf(l, "Unit")) |
---|
259 | | - | then unit |
---|
260 | | - | else throw("Match error") |
---|
261 | | - | } |
---|
262 | | - | |
---|
263 | | - | let aq = valueOrErrorMessage(ao, g("invalid main treasury address")) |
---|
264 | | - | |
---|
265 | | - | let ar = valueOrErrorMessage(ap, g("invalid business treasury address")) |
---|
266 | | - | |
---|
267 | | - | let as = { |
---|
268 | | - | let l = ag |
---|
269 | | - | if ($isInstanceOf(l, "Address")) |
---|
270 | | - | then { |
---|
271 | | - | let aj = l |
---|
272 | | - | let ak = getString(aj, x()) |
---|
273 | | - | if ($isInstanceOf(ak, "String")) |
---|
274 | | - | then { |
---|
275 | | - | let h = ak |
---|
276 | | - | addressFromString(h) |
---|
277 | | - | } |
---|
278 | | - | else if ($isInstanceOf(ak, "Unit")) |
---|
279 | | - | then unit |
---|
280 | | - | else throw("Match error") |
---|
281 | | - | } |
---|
282 | | - | else if ($isInstanceOf(l, "Unit")) |
---|
283 | | - | then unit |
---|
284 | | - | else throw("Match error") |
---|
285 | | - | } |
---|
286 | | - | |
---|
287 | | - | let at = valueOrErrorMessage(as, g("invalid power contract address")) |
---|
288 | | - | |
---|
289 | | - | let au = valueOrErrorMessage(getString(ah, z()), g("power asset id not found")) |
---|
290 | | - | |
---|
291 | | - | func av () = { |
---|
292 | | - | let l = ag |
---|
293 | | - | if ($isInstanceOf(l, "Address")) |
---|
294 | | - | then { |
---|
295 | | - | let aw = l |
---|
296 | | - | let ak = getString(aw, r()) |
---|
297 | | - | if ($isInstanceOf(ak, "String")) |
---|
298 | | - | then { |
---|
299 | | - | let ax = ak |
---|
300 | | - | fromBase58String(ax) |
---|
301 | | - | } |
---|
302 | | - | else unit |
---|
303 | | - | } |
---|
304 | | - | else unit |
---|
305 | | - | } |
---|
306 | | - | |
---|
307 | | - | |
---|
308 | | - | func ay (az,aA) = if ((az.caller == aA)) |
---|
309 | | - | then true |
---|
310 | | - | else i("permission denied") |
---|
311 | | - | |
---|
312 | | - | |
---|
313 | | - | func aB (az) = ay(az, ah) |
---|
314 | | - | |
---|
315 | | - | |
---|
316 | | - | func aC (aD,aE) = { |
---|
317 | | - | let h = size(aD) |
---|
318 | | - | let aF = aD[0] |
---|
319 | | - | let aG = aF._1 |
---|
320 | | - | let aH = aF._2 |
---|
321 | | - | let aI = aD[1] |
---|
322 | | - | let aJ = aI._1 |
---|
323 | | - | let aK = aI._2 |
---|
324 | | - | let aL = aD[2] |
---|
325 | | - | let aM = aL._1 |
---|
326 | | - | let aN = aL._2 |
---|
327 | | - | if (if ((h > 0)) |
---|
328 | | - | then (aG == aE) |
---|
329 | | - | else false) |
---|
330 | | - | then aH |
---|
331 | | - | else if (if ((h > 1)) |
---|
332 | | - | then (aJ == aE) |
---|
333 | | - | else false) |
---|
334 | | - | then aK |
---|
335 | | - | else if (if ((h > 2)) |
---|
336 | | - | then (aM == aE) |
---|
337 | | - | else false) |
---|
338 | | - | then aN |
---|
339 | | - | else unit |
---|
340 | | - | } |
---|
341 | | - | |
---|
342 | | - | |
---|
343 | | - | func aO (aP) = { |
---|
344 | | - | let aQ = valueOrElse(getInteger(ah, R()), 0) |
---|
345 | | - | let aR = valueOrErrorMessage(assetInfo(al), g("invalid lpAsset info")).quantity |
---|
346 | | - | let aS = fraction(aP, c, (aR - aQ)) |
---|
347 | | - | let aT = if ((aS != 0)) |
---|
348 | | - | then true |
---|
349 | | - | else i("LP price cannot be 0") |
---|
350 | | - | if ((aT == aT)) |
---|
351 | | - | then { |
---|
352 | | - | let aU = (aR - aQ) |
---|
353 | | - | $Tuple3(aS, aQ, aU) |
---|
354 | | - | } |
---|
355 | | - | else throw("Strict value is not equal to itself.") |
---|
356 | | - | } |
---|
357 | | - | |
---|
358 | | - | |
---|
359 | | - | func aV (aW,U) = { |
---|
360 | | - | let D = Address(aW) |
---|
361 | | - | let aX = valueOrErrorMessage(getInteger(ah, F()), g("invalid period")) |
---|
362 | | - | let aY = valueOrErrorMessage(getString(ah, T(D, U)), g("invalid withdrawal request")) |
---|
363 | | - | let aZ = ae(aY) |
---|
364 | | - | let W = aZ._1 |
---|
365 | | - | let X = aZ._2 |
---|
366 | | - | let ba = aZ._3 |
---|
367 | | - | let Z = aZ._4 |
---|
368 | | - | if ((ba > aX)) |
---|
369 | | - | then i("invalid withdrawal request period") |
---|
370 | | - | else { |
---|
371 | | - | let bb = valueOrErrorMessage(getInteger(ah, G(ba)), g("invalid price")) |
---|
372 | | - | let bc = if ((bb > 0)) |
---|
373 | | - | then fraction(X, bb, c) |
---|
374 | | - | else 0 |
---|
375 | | - | let Y = (ba - 1) |
---|
376 | | - | let bd = getStringValue(ah, ac(Y)) |
---|
377 | | - | let be = getStringValue(ah, ad(Y)) |
---|
378 | | - | let bf = valueOrElse(getInteger(ah, S(Y)), 0) |
---|
379 | | - | let bg = if ((bf == 0)) |
---|
380 | | - | then 0 |
---|
381 | | - | else fraction(X, c, bf) |
---|
382 | | - | func bh (bi,bj) = { |
---|
383 | | - | let bk = fraction(parseIntValue(bj), bg, c) |
---|
384 | | - | (bi :+ toString(bk)) |
---|
385 | | - | } |
---|
386 | | - | |
---|
387 | | - | let bl = split_51C(be, a) |
---|
388 | | - | let bm = value(bl[0]) |
---|
389 | | - | let bn = removeByIndex(split_51C(be, a), 0) |
---|
390 | | - | let bo = { |
---|
391 | | - | let bp = bn |
---|
392 | | - | let bq = size(bp) |
---|
393 | | - | let br = nil |
---|
394 | | - | func bs (bt,bu) = if ((bu >= bq)) |
---|
395 | | - | then bt |
---|
396 | | - | else bh(bt, bp[bu]) |
---|
397 | | - | |
---|
398 | | - | func bv (bt,bu) = if ((bu >= bq)) |
---|
399 | | - | then bt |
---|
400 | | - | else throw("List size exceeds 10") |
---|
401 | | - | |
---|
402 | | - | bv(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(br, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) |
---|
403 | | - | } |
---|
404 | | - | let bw = makeString([bm, makeString(bo, a)], a) |
---|
405 | | - | $Tuple6(D, X, Y, bc, bd, bw) |
---|
406 | | - | } |
---|
407 | | - | } |
---|
408 | | - | |
---|
409 | | - | |
---|
410 | | - | func bx (aW,U) = { |
---|
411 | | - | let by = aV(aW, U) |
---|
412 | | - | let D = by._1 |
---|
413 | | - | let X = by._2 |
---|
414 | | - | let Y = by._3 |
---|
415 | | - | let bc = by._4 |
---|
416 | | - | let bd = by._5 |
---|
417 | | - | let be = by._6 |
---|
418 | | - | let bz = makeString(removeByIndex(split_51C(bd, a), 0), ":") |
---|
419 | | - | let bA = makeString(removeByIndex(split_51C(be, a), 0), ":") |
---|
420 | | - | makeString(["%d%s%s", toString(bc), bz, bA], a) |
---|
421 | | - | } |
---|
422 | | - | |
---|
423 | | - | |
---|
424 | | - | func bB (bC) = { |
---|
425 | | - | let bD = max([0, min([valueOrElse(getInteger(ah, y()), 0), c])]) |
---|
426 | | - | let bE = max([0, min([valueOrElse(getInteger(ah, w()), 0), c])]) |
---|
427 | | - | let bF = fraction(bC, bD, c) |
---|
428 | | - | let bG = fraction(bC, bE, c) |
---|
429 | | - | let bH = ((bC - bF) - bG) |
---|
430 | | - | if ((bH > 0)) |
---|
431 | | - | then $Tuple3(bF, bG, bH) |
---|
432 | | - | else i("amount to main treasury cannot be negative") |
---|
433 | | - | } |
---|
434 | | - | |
---|
435 | | - | |
---|
436 | | - | func bI (bj) = { |
---|
437 | | - | let bJ = bB(bj) |
---|
438 | | - | let bF = bJ._1 |
---|
439 | | - | let bG = bJ._2 |
---|
440 | | - | let bH = bJ._3 |
---|
441 | | - | let bK = valueOrErrorMessage(getInteger(ah, N()), g("invalid block processing reward")) |
---|
442 | | - | let bL = (bK / f) |
---|
443 | | - | let bM = (bH - bK) |
---|
444 | | - | $Tuple5(bF, bG, bK, bM, bj) |
---|
445 | | - | } |
---|
446 | | - | |
---|
447 | | - | |
---|
448 | | - | @Callable(az) |
---|
449 | | - | func rewardSplitREADONLY () = { |
---|
450 | | - | let bN = (height - 1) |
---|
451 | | - | let bO = valueOrErrorMessage(blockInfoByHeight(bN), g("invalid block info")) |
---|
452 | | - | let bP = valueOrErrorMessage(aC(bO.rewards, an), g(("invalid treasury reward for height " + toString(bN)))) |
---|
453 | | - | $Tuple2(nil, bI(bP)) |
---|
454 | | - | } |
---|
455 | | - | |
---|
456 | | - | |
---|
457 | | - | |
---|
458 | | - | @Callable(az) |
---|
459 | | - | func claimLP (aW) = { |
---|
460 | | - | let bQ = aB(az) |
---|
461 | | - | if ((bQ == bQ)) |
---|
462 | | - | then { |
---|
463 | | - | let D = Address(aW) |
---|
464 | | - | let bR = valueOrElse(getInteger(ah, C(D)), 0) |
---|
465 | | - | let bS = valueOrElse(getInteger(ah, E(D)), 0) |
---|
466 | | - | let bT = if ((bR > 0)) |
---|
467 | | - | then [invoke(ah, "transferAsset", [aW, bR, al], nil), invoke(ah, "integerEntry", [C(D), 0], nil), invoke(ah, "integerEntry", [E(D), (bS + bR)], nil)] |
---|
468 | | - | else i("nothing to claim") |
---|
469 | | - | $Tuple2(nil, bT) |
---|
470 | | - | } |
---|
471 | | - | else throw("Strict value is not equal to itself.") |
---|
472 | | - | } |
---|
473 | | - | |
---|
474 | | - | |
---|
475 | | - | |
---|
476 | | - | @Callable(az) |
---|
477 | | - | func finalize (aW,bU,aP,bV,bW) = { |
---|
478 | | - | let bQ = aB(az) |
---|
479 | | - | if ((bQ == bQ)) |
---|
480 | | - | then { |
---|
481 | | - | let aX = valueOrErrorMessage(getInteger(ah, F()), g("invalid period")) |
---|
482 | | - | let bX = valueOrErrorMessage(getInteger(ah, L()), g("invalid period length")) |
---|
483 | | - | let bY = valueOrErrorMessage(getInteger(ah, I(aX)), g("invalid start height")) |
---|
484 | | - | let bZ = valueOrErrorMessage(getInteger(ah, G(aX)), g("invalid price")) |
---|
485 | | - | let ca = valueOrErrorMessage(getInteger(ah, O()), g("invalid next block to process")) |
---|
486 | | - | let cb = ((bY + bX) - 1) |
---|
487 | | - | let cc = [if ((az.originCaller == aq)) |
---|
488 | | - | then true |
---|
489 | | - | else i("permission denied"), if ((ca > cb)) |
---|
490 | | - | then true |
---|
491 | | - | else i("unprocessed blocks"), if ((bU >= 0)) |
---|
492 | | - | then true |
---|
493 | | - | else i("invalid donation part"), if ((aP >= 0)) |
---|
494 | | - | then true |
---|
495 | | - | else i("invalid lp part"), if ((bV >= 0)) |
---|
496 | | - | then true |
---|
497 | | - | else i("invalid claim part"), if ((bW >= 0)) |
---|
498 | | - | then true |
---|
499 | | - | else i("invalid PWR stake part")] |
---|
500 | | - | if ((cc == cc)) |
---|
501 | | - | then { |
---|
502 | | - | let cd = aO(aP) |
---|
503 | | - | let aS = cd._1 |
---|
504 | | - | let aQ = cd._2 |
---|
505 | | - | let aU = cd._3 |
---|
506 | | - | let ce = (aX + 1) |
---|
507 | | - | func cf (cg,ch) = { |
---|
508 | | - | let ci = cg |
---|
509 | | - | let cj = ci._1 |
---|
510 | | - | let ck = ci._2 |
---|
511 | | - | let be = ci._3 |
---|
512 | | - | let cl = ch.amount |
---|
513 | | - | let cm = ch.assetId |
---|
514 | | - | let cn = ("%s" + makeString([ck, j(cm)], a)) |
---|
515 | | - | let co = ("%d" + makeString([be, toString(cl)], a)) |
---|
516 | | - | let cp = ScriptTransfer(ah, cl, cm) |
---|
517 | | - | $Tuple3((cj :+ cp), cn, co) |
---|
518 | | - | } |
---|
519 | | - | |
---|
520 | | - | let cq = { |
---|
521 | | - | let bp = az.payments |
---|
522 | | - | let bq = size(bp) |
---|
523 | | - | let br = $Tuple3(nil, "", "") |
---|
524 | | - | func bs (bt,bu) = if ((bu >= bq)) |
---|
525 | | - | then bt |
---|
526 | | - | else cf(bt, bp[bu]) |
---|
527 | | - | |
---|
528 | | - | func bv (bt,bu) = if ((bu >= bq)) |
---|
529 | | - | then bt |
---|
530 | | - | else throw("List size exceeds 10") |
---|
531 | | - | |
---|
532 | | - | bv(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(br, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) |
---|
533 | | - | } |
---|
534 | | - | let cj = cq._1 |
---|
535 | | - | let cr = cq._2 |
---|
536 | | - | let cs = cq._3 |
---|
537 | | - | let bT = [invoke(ah, "integerEntry", [J(aX), bW], nil), invoke(ah, "integerEntry", [K(aX), bV], nil), invoke(ah, "integerEntry", [F(), ce], nil), invoke(ah, "integerEntry", [G(ce), aS], nil), invoke(ah, "integerEntry", [I(ce), (cb + 1)], nil), invoke(ah, "burn", [aQ], nil), invoke(ah, "integerEntry", [R(), 0], nil), invoke(ah, "integerEntry", [S(aX), aQ], nil), invoke(ah, "integerEntry", [A(unit), aP], nil), invoke(ah, "integerEntry", [B(unit), bU], nil), invoke(ah, "stringEntry", [ac(aX), cr], nil), invoke(ah, "stringEntry", [ad(aX), cs], nil)] |
---|
538 | | - | $Tuple2(cj, bT) |
---|
539 | | - | } |
---|
540 | | - | else throw("Strict value is not equal to itself.") |
---|
541 | | - | } |
---|
542 | | - | else throw("Strict value is not equal to itself.") |
---|
543 | | - | } |
---|
544 | | - | |
---|
545 | | - | |
---|
546 | | - | |
---|
547 | | - | @Callable(az) |
---|
548 | | - | func finalizeREADONLY (bU,aP,bV,bW) = { |
---|
549 | | - | let aX = valueOrErrorMessage(getInteger(ah, F()), g("invalid period")) |
---|
550 | | - | let bX = valueOrErrorMessage(getInteger(ah, L()), g("invalid period length")) |
---|
551 | | - | let bY = valueOrErrorMessage(getInteger(ah, I(aX)), g("invalid start height")) |
---|
552 | | - | let bZ = valueOrErrorMessage(getInteger(ah, G(aX)), g("invalid price")) |
---|
553 | | - | let ca = valueOrErrorMessage(getInteger(ah, O()), g("invalid next block to process")) |
---|
554 | | - | let cb = ((bY + bX) - 1) |
---|
555 | | - | let cc = [if ((ca > cb)) |
---|
556 | | - | then true |
---|
557 | | - | else i("unprocessed blocks"), if ((bU >= 0)) |
---|
558 | | - | then true |
---|
559 | | - | else i("invalid donation part"), if ((aP >= 0)) |
---|
560 | | - | then true |
---|
561 | | - | else i("invalid lp part"), if ((bV >= 0)) |
---|
562 | | - | then true |
---|
563 | | - | else i("invalid claim part"), if ((bW >= 0)) |
---|
564 | | - | then true |
---|
565 | | - | else i("invalid PWR stake part")] |
---|
566 | | - | if ((cc == cc)) |
---|
567 | | - | then { |
---|
568 | | - | let ct = aO(aP) |
---|
569 | | - | let aS = ct._1 |
---|
570 | | - | let aQ = ct._2 |
---|
571 | | - | let aU = ct._3 |
---|
572 | | - | $Tuple2(nil, $Tuple6(bV, aP, bU, aS, aQ, aU)) |
---|
573 | | - | } |
---|
574 | | - | else throw("Strict value is not equal to itself.") |
---|
575 | | - | } |
---|
576 | | - | |
---|
577 | | - | |
---|
578 | | - | |
---|
579 | | - | @Callable(az) |
---|
580 | | - | func invest (aW) = { |
---|
581 | | - | let bQ = aB(az) |
---|
582 | | - | if ((bQ == bQ)) |
---|
583 | | - | then { |
---|
584 | | - | let D = Address(aW) |
---|
585 | | - | let aX = valueOrErrorMessage(getInteger(ah, F()), g("invalid period")) |
---|
586 | | - | let bY = valueOrErrorMessage(getInteger(ah, I(aX)), g("invalid start height")) |
---|
587 | | - | let cu = getIntegerValue(ah, M()) |
---|
588 | | - | let cv = if (((bY + cu) > height)) |
---|
589 | | - | then true |
---|
590 | | - | else i("too late to invest in this period") |
---|
591 | | - | if ((cv == cv)) |
---|
592 | | - | then { |
---|
593 | | - | let bZ = valueOrErrorMessage(getInteger(ah, G(aX)), g("invalid price")) |
---|
594 | | - | let ch = if ((size(az.payments) == 1)) |
---|
595 | | - | then az.payments[0] |
---|
596 | | - | else i("invalid payments") |
---|
597 | | - | let cw = if (if ((ch.assetId == unit)) |
---|
598 | | - | then (ch.amount > 0) |
---|
599 | | - | else false) |
---|
600 | | - | then $Tuple2(ch.amount, ch.assetId) |
---|
601 | | - | else i("invalid payment amount") |
---|
602 | | - | let cl = cw._1 |
---|
603 | | - | let cm = cw._2 |
---|
604 | | - | let cx = valueOrElse(getInteger(ah, w()), 0) |
---|
605 | | - | let cy = fraction(cl, (c - cx), c) |
---|
606 | | - | let X = if ((bZ > 0)) |
---|
607 | | - | then fraction(cy, c, bZ) |
---|
608 | | - | else 0 |
---|
609 | | - | let cz = valueOrElse(getInteger(ah, A(unit)), 0) |
---|
610 | | - | let cg = [ScriptTransfer(aq, cy, cm), ScriptTransfer(ar, cx, cm)] |
---|
611 | | - | let bT = [invoke(ah, "integerEntry", [A(unit), (cz + cy)], nil), invoke(ah, "reissue", [X], nil), invoke(ah, "transferAsset", [aW, X, al], nil)] |
---|
612 | | - | $Tuple2(cg, bT) |
---|
613 | | - | } |
---|
614 | | - | else throw("Strict value is not equal to itself.") |
---|
615 | | - | } |
---|
616 | | - | else throw("Strict value is not equal to itself.") |
---|
617 | | - | } |
---|
618 | | - | |
---|
619 | | - | |
---|
620 | | - | |
---|
621 | | - | @Callable(az) |
---|
622 | | - | func withdraw (aW) = { |
---|
623 | | - | let bQ = aB(az) |
---|
624 | | - | if ((bQ == bQ)) |
---|
625 | | - | then { |
---|
626 | | - | let D = Address(aW) |
---|
627 | | - | let aX = valueOrErrorMessage(getInteger(ah, F()), g("invalid period")) |
---|
628 | | - | let bX = valueOrErrorMessage(getInteger(ah, L()), g("invalid period length")) |
---|
629 | | - | let bY = valueOrErrorMessage(getInteger(ah, I(aX)), g("invalid start height")) |
---|
630 | | - | let cv = if (((bY + bX) > height)) |
---|
631 | | - | then true |
---|
632 | | - | else i("too late to withdraw in this period") |
---|
633 | | - | if ((cv == cv)) |
---|
634 | | - | then { |
---|
635 | | - | let ch = if ((size(az.payments) == 1)) |
---|
636 | | - | then az.payments[0] |
---|
637 | | - | else i(g("invalid payments")) |
---|
638 | | - | let cm = if ((ch.assetId == al)) |
---|
639 | | - | then al |
---|
640 | | - | else i("invalid payment asset") |
---|
641 | | - | let cl = if ((ch.amount > 0)) |
---|
642 | | - | then ch.amount |
---|
643 | | - | else i("invalid payment amount") |
---|
644 | | - | let cA = valueOrElse(getInteger(ah, R()), 0) |
---|
645 | | - | let cg = [ScriptTransfer(ah, cl, cm)] |
---|
646 | | - | let bT = [invoke(ah, "integerEntry", [R(), (cA + cl)], nil), invoke(ah, "stringEntry", [T(D, az.transactionId), V(d, cl, (aX + 1), unit)], nil)] |
---|
647 | | - | if ((bT == bT)) |
---|
648 | | - | then $Tuple2(cg, bT) |
---|
649 | | - | else throw("Strict value is not equal to itself.") |
---|
650 | | - | } |
---|
651 | | - | else throw("Strict value is not equal to itself.") |
---|
652 | | - | } |
---|
653 | | - | else throw("Strict value is not equal to itself.") |
---|
654 | | - | } |
---|
655 | | - | |
---|
656 | | - | |
---|
657 | | - | |
---|
658 | | - | @Callable(az) |
---|
659 | | - | func cancelWithdraw (aW,U) = { |
---|
660 | | - | let bQ = aB(az) |
---|
661 | | - | if ((bQ == bQ)) |
---|
662 | | - | then i("cancelWithdraw is deprecated") |
---|
663 | | - | else throw("Strict value is not equal to itself.") |
---|
664 | | - | } |
---|
665 | | - | |
---|
666 | | - | |
---|
667 | | - | |
---|
668 | | - | @Callable(az) |
---|
669 | | - | func claimCollateral (aW,U) = { |
---|
670 | | - | let bQ = aB(az) |
---|
671 | | - | if ((bQ == bQ)) |
---|
672 | | - | then { |
---|
673 | | - | let cB = aV(aW, fromBase58String(U)) |
---|
674 | | - | let D = cB._1 |
---|
675 | | - | let X = cB._2 |
---|
676 | | - | let Y = cB._3 |
---|
677 | | - | let bc = cB._4 |
---|
678 | | - | let bd = cB._5 |
---|
679 | | - | let be = cB._6 |
---|
680 | | - | let cC = removeByIndex(split_51C(bd, a), 0) |
---|
681 | | - | let bl = removeByIndex(split_51C(be, a), 0) |
---|
682 | | - | let bT = [invoke(ah, "deleteEntry", [T(D, fromBase58String(U))], nil), invoke(ah, "integerEntry", [ab(D, fromBase58String(U)), X], nil), invoke(ah, "transferAssets", [aW, cC, bl], nil)] |
---|
683 | | - | $Tuple2(nil, bT) |
---|
684 | | - | } |
---|
685 | | - | else throw("Strict value is not equal to itself.") |
---|
686 | | - | } |
---|
687 | | - | |
---|
688 | | - | |
---|
689 | | - | |
---|
690 | | - | @Callable(az) |
---|
691 | | - | func claimCollateralBulk (aW,cD) = { |
---|
692 | | - | let bQ = aB(az) |
---|
693 | | - | if ((bQ == bQ)) |
---|
694 | | - | then { |
---|
695 | | - | func cf (cE,U) = { |
---|
696 | | - | let cF = aV(aW, fromBase58String(U)) |
---|
697 | | - | let D = cF._1 |
---|
698 | | - | let X = cF._2 |
---|
699 | | - | let Y = cF._3 |
---|
700 | | - | let bc = cF._4 |
---|
701 | | - | let bd = cF._5 |
---|
702 | | - | let be = cF._6 |
---|
703 | | - | let cC = removeByIndex(split_51C(bd, a), 0) |
---|
704 | | - | let bl = removeByIndex(split_51C(be, a), 0) |
---|
705 | | - | let cG = [invoke(ah, "deleteEntry", [T(D, fromBase58String(U))], nil), invoke(ah, "integerEntry", [ab(D, fromBase58String(U)), X], nil), invoke(ah, "transferAssets", [aW, cC, bl], nil)] |
---|
706 | | - | (cE ++ cG) |
---|
707 | | - | } |
---|
708 | | - | |
---|
709 | | - | let cH = { |
---|
710 | | - | let bp = cD |
---|
711 | | - | let bq = size(bp) |
---|
712 | | - | let br = nil |
---|
713 | | - | func bs (bt,bu) = if ((bu >= bq)) |
---|
714 | | - | then bt |
---|
715 | | - | else cf(bt, bp[bu]) |
---|
716 | | - | |
---|
717 | | - | func bv (bt,bu) = if ((bu >= bq)) |
---|
718 | | - | then bt |
---|
719 | | - | else throw("List size exceeds 10") |
---|
720 | | - | |
---|
721 | | - | bv(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(br, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) |
---|
722 | | - | } |
---|
723 | | - | $Tuple2(nil, cH) |
---|
724 | | - | } |
---|
725 | | - | else throw("Strict value is not equal to itself.") |
---|
726 | | - | } |
---|
727 | | - | |
---|
728 | | - | |
---|
729 | | - | |
---|
730 | | - | @Callable(az) |
---|
731 | | - | func claimCollateralREADONLY (aW,U) = { |
---|
732 | | - | let cI = bx(aW, fromBase58String(U)) |
---|
733 | | - | $Tuple2(nil, cI) |
---|
734 | | - | } |
---|
735 | | - | |
---|
736 | | - | |
---|
737 | | - | |
---|
738 | | - | @Callable(az) |
---|
739 | | - | func claimCollateralBulkREADONLY (aW,cD) = { |
---|
740 | | - | func cJ (cE,U) = { |
---|
741 | | - | let cI = bx(aW, fromBase58String(U)) |
---|
742 | | - | (cE :+ cI) |
---|
743 | | - | } |
---|
744 | | - | |
---|
745 | | - | let cK = { |
---|
746 | | - | let bp = cD |
---|
747 | | - | let bq = size(bp) |
---|
748 | | - | let br = nil |
---|
749 | | - | func bs (bt,bu) = if ((bu >= bq)) |
---|
750 | | - | then bt |
---|
751 | | - | else cJ(bt, bp[bu]) |
---|
752 | | - | |
---|
753 | | - | func bv (bt,bu) = if ((bu >= bq)) |
---|
754 | | - | then bt |
---|
755 | | - | else throw("List size exceeds 10") |
---|
756 | | - | |
---|
757 | | - | bv(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(br, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) |
---|
758 | | - | } |
---|
759 | | - | $Tuple2(nil, cK) |
---|
760 | | - | } |
---|
761 | | - | |
---|
762 | | - | |
---|
763 | | - | |
---|
764 | | - | @Callable(az) |
---|
765 | | - | func processBlocks (aW) = { |
---|
766 | | - | let bQ = aB(az) |
---|
767 | | - | if ((bQ == bQ)) |
---|
768 | | - | then { |
---|
769 | | - | let D = Address(aW) |
---|
770 | | - | let aX = valueOrErrorMessage(getInteger(ah, F()), g("invalid period")) |
---|
771 | | - | let bX = valueOrErrorMessage(getInteger(ah, L()), g("invalid period length")) |
---|
772 | | - | let bY = valueOrErrorMessage(getInteger(ah, I(aX)), g("invalid start height")) |
---|
773 | | - | let bZ = valueOrErrorMessage(getInteger(ah, G(aX)), g("invalid price")) |
---|
774 | | - | let ca = valueOrErrorMessage(getInteger(ah, O()), g("invalid next block to process")) |
---|
775 | | - | let cb = ((bY + bX) - 1) |
---|
776 | | - | let cL = if (if (if ((height >= ca)) |
---|
777 | | - | then if ((ca >= bY)) |
---|
778 | | - | then true |
---|
779 | | - | else (aX == 0) |
---|
780 | | - | else false) |
---|
781 | | - | then (cb >= ca) |
---|
782 | | - | else false) |
---|
783 | | - | then min([((cb - ca) + 1), f]) |
---|
784 | | - | else i(g("invalid target block")) |
---|
785 | | - | let bK = valueOrErrorMessage(getInteger(ah, N()), g("invalid block processing reward")) |
---|
786 | | - | let bL = (bK / cL) |
---|
787 | | - | let cM = (bK - (bL * cL)) |
---|
788 | | - | func cN (cO,cP) = if ((cP >= cL)) |
---|
789 | | - | then cO |
---|
790 | | - | else { |
---|
791 | | - | let bN = (ca + cP) |
---|
792 | | - | let bO = valueOrErrorMessage(blockInfoByHeight(bN), g("invalid block info")) |
---|
793 | | - | let bP = valueOrErrorMessage(aC(bO.rewards, an), g(("invalid treasury reward for height " + toString(bN)))) |
---|
794 | | - | let cQ = bO.generator |
---|
795 | | - | let bR = valueOrElse(getInteger(ah, C(cQ)), 0) |
---|
796 | | - | let cR = if ((cP == (cL - 1))) |
---|
797 | | - | then (bL + cM) |
---|
798 | | - | else bL |
---|
799 | | - | let cS = bB(bP) |
---|
800 | | - | let cT = cS._1 |
---|
801 | | - | let bG = cS._2 |
---|
802 | | - | let bH = cS._3 |
---|
803 | | - | let X = if ((bZ > 0)) |
---|
804 | | - | then fraction((bH - cR), c, bZ) |
---|
805 | | - | else 0 |
---|
806 | | - | let cU = [invoke(ah, "stringEntry", [P(bN), makeString([toBase58String(az.transactionId), toString(aX), toString(cQ), toBase58String(aW), toString(bP), toString(cR), toString(X), toString(cT)], a)], nil), invoke(ah, "integerEntry", [C(cQ), (bR + X)], nil)] |
---|
807 | | - | if ((cU == cU)) |
---|
808 | | - | then { |
---|
809 | | - | let cV = cO |
---|
810 | | - | let cW = cV._1 |
---|
811 | | - | let cX = cV._2 |
---|
812 | | - | let cY = cV._3 |
---|
813 | | - | let cZ = cV._4 |
---|
814 | | - | let da = cZ |
---|
815 | | - | let db = da._1 |
---|
816 | | - | let dc = da._2 |
---|
817 | | - | let dd = (dc :+ $Tuple2(toString(cQ), cT)) |
---|
818 | | - | $Tuple4((cW + X), (cX + bP), (cY + bG), $Tuple2((db + cT), dd)) |
---|
819 | | - | } |
---|
820 | | - | else throw("Strict value is not equal to itself.") |
---|
821 | | - | } |
---|
822 | | - | |
---|
823 | | - | let de = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] |
---|
824 | | - | let df = { |
---|
825 | | - | let bp = de |
---|
826 | | - | let bq = size(bp) |
---|
827 | | - | let br = $Tuple4(0, 0, 0, $Tuple2(0, nil)) |
---|
828 | | - | func bs (bt,bu) = if ((bu >= bq)) |
---|
829 | | - | then bt |
---|
830 | | - | else cN(bt, bp[bu]) |
---|
831 | | - | |
---|
832 | | - | func bv (bt,bu) = if ((bu >= bq)) |
---|
833 | | - | then bt |
---|
834 | | - | else throw("List size exceeds 20") |
---|
835 | | - | |
---|
836 | | - | bv(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(bs(br, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
837 | | - | } |
---|
838 | | - | if ((df == df)) |
---|
839 | | - | then { |
---|
840 | | - | let cZ = df._4 |
---|
841 | | - | let dg = df._3 |
---|
842 | | - | let dh = df._2 |
---|
843 | | - | let di = df._1 |
---|
844 | | - | let dj = cZ |
---|
845 | | - | let dk = dj._1 |
---|
846 | | - | let dl = dj._2 |
---|
847 | | - | let dm = (((dh - dg) - bK) - dk) |
---|
848 | | - | let cz = valueOrElse(getInteger(ah, A(unit)), 0) |
---|
849 | | - | let dn = if ((dk > 0)) |
---|
850 | | - | then { |
---|
851 | | - | let do = [invoke(ah, "transferFromProxyTreasury", [ah.bytes, dk], nil)] |
---|
852 | | - | if ((do == do)) |
---|
853 | | - | then { |
---|
854 | | - | let dp = invoke(ah, "swap", [au, e, dk], nil) |
---|
855 | | - | if ((dp == dp)) |
---|
856 | | - | then { |
---|
857 | | - | let dq = { |
---|
858 | | - | let l = dp |
---|
859 | | - | if ($isInstanceOf(l, "Int")) |
---|
860 | | - | then { |
---|
861 | | - | let dr = l |
---|
862 | | - | dr |
---|
863 | | - | } |
---|
864 | | - | else 0 |
---|
865 | | - | } |
---|
866 | | - | func ds (cO,dt) = { |
---|
867 | | - | let du = dt |
---|
868 | | - | let cQ = du._1 |
---|
869 | | - | let dv = du._2 |
---|
870 | | - | if ((dk > 0)) |
---|
871 | | - | then { |
---|
872 | | - | let dw = fraction(dv, dq, dk) |
---|
873 | | - | let dx = invoke(ah, "powerStake", [fromBase58String(cQ), fromBase58String(au), dw], nil) |
---|
874 | | - | if ((dx == dx)) |
---|
875 | | - | then nil |
---|
876 | | - | else throw("Strict value is not equal to itself.") |
---|
877 | | - | } |
---|
878 | | - | else nil |
---|
879 | | - | } |
---|
880 | | - | |
---|
881 | | - | let dy = { |
---|
882 | | - | let bp = dl |
---|
883 | | - | let bq = size(bp) |
---|
884 | | - | let br = 0 |
---|
885 | | - | func dz (bt,bu) = if ((bu >= bq)) |
---|
886 | | - | then bt |
---|
887 | | - | else ds(bt, bp[bu]) |
---|
888 | | - | |
---|
889 | | - | func dA (bt,bu) = if ((bu >= bq)) |
---|
890 | | - | then bt |
---|
891 | | - | else throw("List size exceeds 20") |
---|
892 | | - | |
---|
893 | | - | dA(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(dz(br, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) |
---|
894 | | - | } |
---|
895 | | - | if ((dy == dy)) |
---|
896 | | - | then nil |
---|
897 | | - | else throw("Strict value is not equal to itself.") |
---|
898 | | - | } |
---|
899 | | - | else throw("Strict value is not equal to itself.") |
---|
900 | | - | } |
---|
901 | | - | else throw("Strict value is not equal to itself.") |
---|
902 | | - | } |
---|
903 | | - | else nil |
---|
904 | | - | if ((dn == dn)) |
---|
905 | | - | then { |
---|
906 | | - | let cg = [invoke(ah, "reissue", [di], nil), invoke(ah, "integerEntry", [O(), (ca + cL)], nil), invoke(ah, "transferFromProxyTreasury", [aq.bytes, dm], nil), invoke(ah, "transferFromProxyTreasury", [aW, bK], nil), invoke(ah, "transferFromProxyTreasury", [ar.bytes, dg], nil), invoke(ah, "integerEntry", [A(unit), (cz + dm)], nil)] |
---|
907 | | - | if ((cg == cg)) |
---|
908 | | - | then $Tuple2(nil, unit) |
---|
909 | | - | else throw("Strict value is not equal to itself.") |
---|
910 | | - | } |
---|
911 | | - | else throw("Strict value is not equal to itself.") |
---|
912 | | - | } |
---|
913 | | - | else throw("Strict value is not equal to itself.") |
---|
914 | | - | } |
---|
915 | | - | else throw("Strict value is not equal to itself.") |
---|
916 | | - | } |
---|
917 | | - | |
---|
918 | | - | |
---|
919 | | - | @Verifier(dB) |
---|
920 | | - | func dC () = { |
---|
921 | | - | let dD = { |
---|
922 | | - | let l = av() |
---|
923 | | - | if ($isInstanceOf(l, "ByteVector")) |
---|
924 | | - | then { |
---|
925 | | - | let ax = l |
---|
926 | | - | ax |
---|
927 | | - | } |
---|
928 | | - | else dB.senderPublicKey |
---|
929 | | - | } |
---|
930 | | - | sigVerify(dB.bodyBytes, dB.proofs[0], dD) |
---|
931 | | - | } |
---|
| 14 | + | @Verifier(d) |
---|
| 15 | + | func e () = sigVerify(d.bodyBytes, d.proofs[0], d.senderPublicKey) |
---|