1 | | - | {-# STDLIB_VERSION 6 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = 100000000 |
---|
7 | | - | |
---|
8 | | - | let c = 10 |
---|
9 | | - | |
---|
10 | | - | let d = 0 |
---|
11 | | - | |
---|
12 | | - | let e = 1 |
---|
13 | | - | |
---|
14 | | - | let f = makeString(["%s", "epochLength"], a) |
---|
15 | | - | |
---|
16 | | - | let g = makeString(["%s%s", "epochLength__new"], a) |
---|
17 | | - | |
---|
18 | | - | func h (i) = makeString(["%s%d", "epochLength", toString(i)], a) |
---|
19 | | - | |
---|
20 | | - | |
---|
21 | | - | let j = makeString(["%s", "currentEpoch"], a) |
---|
22 | | - | |
---|
23 | | - | let k = makeString(["%s", "maxDepth"], a) |
---|
24 | | - | |
---|
25 | | - | let l = makeString(["%s", "votingEmissionCandidateContract"], a) |
---|
26 | | - | |
---|
27 | | - | let m = makeString(["%s", "factoryContract"], a) |
---|
28 | | - | |
---|
29 | | - | let n = makeString(["%s", "boostingContract"], a) |
---|
30 | | - | |
---|
31 | | - | let o = makeString(["%s", "stakingContract"], a) |
---|
32 | | - | |
---|
33 | | - | let p = makeString(["%s", "finalizationStage"], a) |
---|
34 | | - | |
---|
35 | | - | let q = makeString(["%s", "nextPool"], a) |
---|
36 | | - | |
---|
37 | | - | let r = makeString(["%s", "nextUser"], a) |
---|
38 | | - | |
---|
39 | | - | let s = makeString(["%s", "startHeight"], a) |
---|
40 | | - | |
---|
41 | | - | let t = makeString(["%s", "currentEpochUi"], a) |
---|
42 | | - | |
---|
43 | | - | let u = makeString(["%s", "startHeightUi"], a) |
---|
44 | | - | |
---|
45 | | - | let v = makeString(["%s", "force"], a) |
---|
46 | | - | |
---|
47 | | - | func w (i) = makeString(["%s%d", "startHeight", toString(i)], a) |
---|
48 | | - | |
---|
49 | | - | |
---|
50 | | - | func x (i) = makeString(["%s%d", "finalized", toString(i)], a) |
---|
51 | | - | |
---|
52 | | - | |
---|
53 | | - | func y (z) = { |
---|
54 | | - | let A = z |
---|
55 | | - | let B = A._1 |
---|
56 | | - | let C = A._2 |
---|
57 | | - | makeString(["%s%s%s", "inList", B, C], a) |
---|
58 | | - | } |
---|
59 | | - | |
---|
60 | | - | |
---|
61 | | - | func D (E,i) = makeString(["%s%s%d", "used", toString(E), toString(i)], a) |
---|
62 | | - | |
---|
63 | | - | |
---|
64 | | - | func F (z,E,i) = { |
---|
65 | | - | let G = z |
---|
66 | | - | let B = G._1 |
---|
67 | | - | let C = G._2 |
---|
68 | | - | makeString(["%s%s%s%s%d", "vote", B, C, toString(E), toString(i)], a) |
---|
69 | | - | } |
---|
70 | | - | |
---|
71 | | - | |
---|
72 | | - | func H (z,i) = { |
---|
73 | | - | let I = z |
---|
74 | | - | let B = I._1 |
---|
75 | | - | let C = I._2 |
---|
76 | | - | makeString(["%s%s%s%d", "votingResult", B, C, toString(i)], a) |
---|
77 | | - | } |
---|
78 | | - | |
---|
79 | | - | |
---|
80 | | - | func J (K,i) = makeString(["%s%s%d", "votingResultStaked", K, toString(i)], a) |
---|
81 | | - | |
---|
82 | | - | |
---|
83 | | - | func L (z,i) = { |
---|
84 | | - | let M = z |
---|
85 | | - | let B = M._1 |
---|
86 | | - | let C = M._2 |
---|
87 | | - | makeString(["%s%s%s%d", "poolShare", B, C, toString(i)], a) |
---|
88 | | - | } |
---|
89 | | - | |
---|
90 | | - | |
---|
91 | | - | func N (i) = makeString(["%s%d", "totalVotes", toString(i)], a) |
---|
92 | | - | |
---|
93 | | - | |
---|
94 | | - | func O (K,P) = makeString(["%s%s%s", "staked", P, K], a) |
---|
95 | | - | |
---|
96 | | - | |
---|
97 | | - | func Q (R) = makeString(["voting_emission.ride:", R], " ") |
---|
98 | | - | |
---|
99 | | - | |
---|
100 | | - | func S (R) = throw(Q(R)) |
---|
101 | | - | |
---|
102 | | - | |
---|
103 | | - | func T (E,U,V) = { |
---|
104 | | - | let W = makeString(["mandatory ", toString(E), ".", U, " is not defined"], "") |
---|
105 | | - | valueOrErrorMessage({ |
---|
106 | | - | let X = V |
---|
107 | | - | if ($isInstanceOf(X, "String")) |
---|
108 | | - | then { |
---|
109 | | - | let Y = X |
---|
110 | | - | getString(E, U) |
---|
111 | | - | } |
---|
112 | | - | else if ($isInstanceOf(X, "Int")) |
---|
113 | | - | then { |
---|
114 | | - | let Z = X |
---|
115 | | - | getInteger(E, U) |
---|
116 | | - | } |
---|
117 | | - | else throw("invalid entry type") |
---|
118 | | - | }, W) |
---|
119 | | - | } |
---|
120 | | - | |
---|
121 | | - | |
---|
122 | | - | func aa (E,U) = { |
---|
123 | | - | let ab = T(E, U, "") |
---|
124 | | - | if ($isInstanceOf(ab, "String")) |
---|
125 | | - | then ab |
---|
126 | | - | else throw(($getType(ab) + " couldn't be cast to String")) |
---|
127 | | - | } |
---|
128 | | - | |
---|
129 | | - | |
---|
130 | | - | func ac (E,U) = { |
---|
131 | | - | let ab = T(E, U, 0) |
---|
132 | | - | if ($isInstanceOf(ab, "Int")) |
---|
133 | | - | then ab |
---|
134 | | - | else throw(($getType(ab) + " couldn't be cast to Int")) |
---|
135 | | - | } |
---|
136 | | - | |
---|
137 | | - | |
---|
138 | | - | func ad (z) = ((z._1 + a) + z._2) |
---|
139 | | - | |
---|
140 | | - | |
---|
141 | | - | func ae (Y) = { |
---|
142 | | - | let af = split(Y, a) |
---|
143 | | - | if ((size(af) == 2)) |
---|
144 | | - | then $Tuple2(af[0], af[1]) |
---|
145 | | - | else throw("invalid pool string") |
---|
146 | | - | } |
---|
147 | | - | |
---|
148 | | - | |
---|
149 | | - | func ag (B,C) = { |
---|
150 | | - | func ah (ai) = ("%s%s%s__mappings__baseAsset2internalId__" + ai) |
---|
151 | | - | |
---|
152 | | - | func aj (ak,al) = (((("%d%d%s%s__" + toString(ak)) + "__") + toString(al)) + "__mappings__poolAssets2PoolContract") |
---|
153 | | - | |
---|
154 | | - | func am (an) = (("%s%s%s__" + an) + "__mappings__poolContract2LpAsset") |
---|
155 | | - | |
---|
156 | | - | let ao = addressFromStringValue(aa(this, m)) |
---|
157 | | - | let ap = ac(ao, ah(B)) |
---|
158 | | - | let aq = ac(ao, ah(C)) |
---|
159 | | - | let an = aa(ao, aj(ap, aq)) |
---|
160 | | - | let ar = aa(ao, am(an)) |
---|
161 | | - | ar |
---|
162 | | - | } |
---|
163 | | - | |
---|
164 | | - | |
---|
165 | | - | func as (z) = { |
---|
166 | | - | let at = z |
---|
167 | | - | let B = at._1 |
---|
168 | | - | let C = at._2 |
---|
169 | | - | let ao = addressFromStringValue(aa(this, m)) |
---|
170 | | - | let ab = invoke(ao, "checkWxEmissionPoolLabel", [B, C], nil) |
---|
171 | | - | if ($isInstanceOf(ab, "Boolean")) |
---|
172 | | - | then ab |
---|
173 | | - | else throw(($getType(ab) + " couldn't be cast to Boolean")) |
---|
174 | | - | } |
---|
175 | | - | |
---|
176 | | - | |
---|
177 | | - | let au = "pools" |
---|
178 | | - | |
---|
179 | | - | func av (z) = { |
---|
180 | | - | let aw = z |
---|
181 | | - | let B = aw._1 |
---|
182 | | - | let C = aw._2 |
---|
183 | | - | makeString(["votes", B, C], a) |
---|
184 | | - | } |
---|
185 | | - | |
---|
186 | | - | |
---|
187 | | - | func ax (ay) = { |
---|
188 | | - | let az = if ((ay == au)) |
---|
189 | | - | then "%s%s" |
---|
190 | | - | else "%s%s%s%s" |
---|
191 | | - | makeString([az, ay, "head"], a) |
---|
192 | | - | } |
---|
193 | | - | |
---|
194 | | - | |
---|
195 | | - | func aA (ay) = { |
---|
196 | | - | let az = if ((ay == au)) |
---|
197 | | - | then "%s%s" |
---|
198 | | - | else "%s%s%s%s" |
---|
199 | | - | makeString([az, ay, "size"], a) |
---|
200 | | - | } |
---|
201 | | - | |
---|
202 | | - | |
---|
203 | | - | func aB (ay,aC) = { |
---|
204 | | - | let az = if ((ay == au)) |
---|
205 | | - | then "%s%s%s%s" |
---|
206 | | - | else "%s%s%s%s%s" |
---|
207 | | - | makeString([az, ay, aC, "prev"], a) |
---|
208 | | - | } |
---|
209 | | - | |
---|
210 | | - | |
---|
211 | | - | func aD (ay,aC) = { |
---|
212 | | - | let az = if ((ay == au)) |
---|
213 | | - | then "%s%s%s%s" |
---|
214 | | - | else "%s%s%s%s%s" |
---|
215 | | - | makeString([az, ay, aC, "next"], a) |
---|
216 | | - | } |
---|
217 | | - | |
---|
218 | | - | |
---|
219 | | - | func aE (ay,aC) = { |
---|
220 | | - | let aF = getString(this, ax(ay)) |
---|
221 | | - | let aG = getString(this, aB(ay, aC)) |
---|
222 | | - | let aH = getString(this, aD(ay, aC)) |
---|
223 | | - | if (if ((aC == valueOrElse(aF, ""))) |
---|
224 | | - | then true |
---|
225 | | - | else (aG != unit)) |
---|
226 | | - | then true |
---|
227 | | - | else (aH != unit) |
---|
228 | | - | } |
---|
229 | | - | |
---|
230 | | - | |
---|
231 | | - | func aI (ay,aC) = { |
---|
232 | | - | let aF = getString(this, ax(ay)) |
---|
233 | | - | let aJ = valueOrElse(getInteger(this, aA(ay)), 0) |
---|
234 | | - | let aK = if (!(aE(ay, aC))) |
---|
235 | | - | then true |
---|
236 | | - | else throw("Node exists") |
---|
237 | | - | if ((aK == aK)) |
---|
238 | | - | then (([IntegerEntry(aA(ay), (aJ + 1))] ++ (if ((aF != unit)) |
---|
239 | | - | then [StringEntry(aD(ay, aC), value(aF)), StringEntry(aB(ay, value(aF)), aC)] |
---|
240 | | - | else nil)) ++ [StringEntry(ax(ay), aC)]) |
---|
241 | | - | else throw("Strict value is not equal to itself.") |
---|
242 | | - | } |
---|
243 | | - | |
---|
244 | | - | |
---|
245 | | - | func aL (ay,aC) = { |
---|
246 | | - | let aF = getString(this, ax(ay)) |
---|
247 | | - | let aJ = valueOrElse(getInteger(this, aA(ay)), 0) |
---|
248 | | - | let aG = getString(this, aB(ay, aC)) |
---|
249 | | - | let aH = getString(this, aD(ay, aC)) |
---|
250 | | - | ([IntegerEntry(aA(ay), (aJ - 1))] ++ (if (if ((aG != unit)) |
---|
251 | | - | then (aH != unit) |
---|
252 | | - | else false) |
---|
253 | | - | then [StringEntry(aD(ay, value(aG)), value(aH)), StringEntry(aB(ay, value(aH)), value(aG)), DeleteEntry(aB(ay, aC)), DeleteEntry(aD(ay, aC))] |
---|
254 | | - | else if ((aH != unit)) |
---|
255 | | - | then [StringEntry(ax(ay), value(aH)), DeleteEntry(aD(ay, aC)), DeleteEntry(aB(ay, value(aH)))] |
---|
256 | | - | else if ((aG != unit)) |
---|
257 | | - | then [DeleteEntry(aB(ay, aC)), DeleteEntry(aD(ay, value(aG)))] |
---|
258 | | - | else if ((aC == valueOrElse(aF, ""))) |
---|
259 | | - | then [DeleteEntry(ax(ay))] |
---|
260 | | - | else throw(((("invalid node: " + ay) + ".") + aC)))) |
---|
261 | | - | } |
---|
262 | | - | |
---|
263 | | - | |
---|
264 | | - | func aM () = "%s__managerPublicKey" |
---|
265 | | - | |
---|
266 | | - | |
---|
267 | | - | func aN () = "%s__pendingManagerPublicKey" |
---|
268 | | - | |
---|
269 | | - | |
---|
270 | | - | func aO () = { |
---|
271 | | - | let X = getString(aM()) |
---|
272 | | - | if ($isInstanceOf(X, "String")) |
---|
273 | | - | then { |
---|
274 | | - | let aP = X |
---|
275 | | - | fromBase58String(aP) |
---|
276 | | - | } |
---|
277 | | - | else if ($isInstanceOf(X, "Unit")) |
---|
278 | | - | then unit |
---|
279 | | - | else throw("Match error") |
---|
280 | | - | } |
---|
281 | | - | |
---|
282 | | - | |
---|
283 | | - | func aQ () = { |
---|
284 | | - | let X = getString(aN()) |
---|
285 | | - | if ($isInstanceOf(X, "String")) |
---|
286 | | - | then { |
---|
287 | | - | let aP = X |
---|
288 | | - | fromBase58String(aP) |
---|
289 | | - | } |
---|
290 | | - | else if ($isInstanceOf(X, "Unit")) |
---|
291 | | - | then unit |
---|
292 | | - | else throw("Match error") |
---|
293 | | - | } |
---|
294 | | - | |
---|
295 | | - | |
---|
296 | | - | let aR = throw("Permission denied") |
---|
297 | | - | |
---|
298 | | - | func aS (aT) = if ((aT.caller == this)) |
---|
299 | | - | then true |
---|
300 | | - | else aR |
---|
301 | | - | |
---|
302 | | - | |
---|
303 | | - | func aU (aT) = { |
---|
304 | | - | let X = aO() |
---|
305 | | - | if ($isInstanceOf(X, "ByteVector")) |
---|
306 | | - | then { |
---|
307 | | - | let aV = X |
---|
308 | | - | if ((aT.callerPublicKey == aV)) |
---|
309 | | - | then true |
---|
310 | | - | else aR |
---|
311 | | - | } |
---|
312 | | - | else if ($isInstanceOf(X, "Unit")) |
---|
313 | | - | then aS(aT) |
---|
314 | | - | else throw("Match error") |
---|
315 | | - | } |
---|
316 | | - | |
---|
317 | | - | |
---|
318 | | - | @Callable(aT) |
---|
319 | | - | func setManager (aW) = { |
---|
320 | | - | let aX = aU(aT) |
---|
321 | | - | if ((aX == aX)) |
---|
322 | | - | then { |
---|
323 | | - | let aY = fromBase58String(aW) |
---|
324 | | - | if ((aY == aY)) |
---|
325 | | - | then [StringEntry(aN(), aW)] |
---|
326 | | - | else throw("Strict value is not equal to itself.") |
---|
327 | | - | } |
---|
328 | | - | else throw("Strict value is not equal to itself.") |
---|
329 | | - | } |
---|
330 | | - | |
---|
331 | | - | |
---|
332 | | - | |
---|
333 | | - | @Callable(aT) |
---|
334 | | - | func confirmManager () = { |
---|
335 | | - | let aZ = aQ() |
---|
336 | | - | let ba = if (isDefined(aZ)) |
---|
337 | | - | then true |
---|
338 | | - | else throw("No pending manager") |
---|
339 | | - | if ((ba == ba)) |
---|
340 | | - | then { |
---|
341 | | - | let bb = if ((aT.callerPublicKey == value(aZ))) |
---|
342 | | - | then true |
---|
343 | | - | else throw("You are not pending manager") |
---|
344 | | - | if ((bb == bb)) |
---|
345 | | - | then [StringEntry(aM(), toBase58String(value(aZ))), DeleteEntry(aN())] |
---|
346 | | - | else throw("Strict value is not equal to itself.") |
---|
347 | | - | } |
---|
348 | | - | else throw("Strict value is not equal to itself.") |
---|
349 | | - | } |
---|
350 | | - | |
---|
351 | | - | |
---|
352 | | - | |
---|
353 | | - | @Callable(aT) |
---|
354 | | - | func getUserGwxAmountAtHeight (bc,bd) = { |
---|
355 | | - | let be = valueOrErrorMessage(addressFromString(aa(this, n)), "invalid boosting contract address") |
---|
356 | | - | $Tuple2(nil, { |
---|
357 | | - | let ab = invoke(be, "getUserGwxAmountAtHeightREADONLY", [bc, bd], nil) |
---|
358 | | - | if ($isInstanceOf(ab, "Int")) |
---|
359 | | - | then ab |
---|
360 | | - | else throw(($getType(ab) + " couldn't be cast to Int")) |
---|
361 | | - | }) |
---|
362 | | - | } |
---|
363 | | - | |
---|
364 | | - | |
---|
365 | | - | |
---|
366 | | - | @Callable(aT) |
---|
367 | | - | func constructor (ao,bf,bg,bh,bi) = { |
---|
368 | | - | let bj = [aU(aT), if ((addressFromString(ao) != unit)) |
---|
369 | | - | then true |
---|
370 | | - | else "invalid factory contract address", if ((addressFromString(bf) != unit)) |
---|
371 | | - | then true |
---|
372 | | - | else "invalid voting emission candidate contract address", if ((addressFromString(bg) != unit)) |
---|
373 | | - | then true |
---|
374 | | - | else "invalid boosting contract address", if ((addressFromString(bh) != unit)) |
---|
375 | | - | then true |
---|
376 | | - | else "invalid staking contract address", if ((bi > 0)) |
---|
377 | | - | then true |
---|
378 | | - | else throw("invalid epoch length")] |
---|
379 | | - | if ((bj == bj)) |
---|
380 | | - | then $Tuple2([StringEntry(m, ao), StringEntry(l, bf), StringEntry(n, bg), StringEntry(o, bh), IntegerEntry(f, bi)], unit) |
---|
381 | | - | else throw("Strict value is not equal to itself.") |
---|
382 | | - | } |
---|
383 | | - | |
---|
384 | | - | |
---|
385 | | - | |
---|
386 | | - | @Callable(aT) |
---|
387 | | - | func create (B,C) = { |
---|
388 | | - | let bj = [if ((toBase58String(aT.caller.bytes) == valueOrElse(getString(this, l), ""))) |
---|
389 | | - | then true |
---|
390 | | - | else aU(aT)] |
---|
391 | | - | if ((bj == bj)) |
---|
392 | | - | then { |
---|
393 | | - | let z = $Tuple2(B, C) |
---|
394 | | - | let bk = ([BooleanEntry(y(z), true)] ++ aI(au, ad(z))) |
---|
395 | | - | let bl = (getInteger(this, j) == unit) |
---|
396 | | - | let bm = if (bl) |
---|
397 | | - | then { |
---|
398 | | - | let i = 0 |
---|
399 | | - | [IntegerEntry(j, i), IntegerEntry(w(i), height), IntegerEntry(s, height), IntegerEntry(t, i), IntegerEntry(u, height)] |
---|
400 | | - | } |
---|
401 | | - | else nil |
---|
402 | | - | $Tuple2((bk ++ bm), unit) |
---|
403 | | - | } |
---|
404 | | - | else throw("Strict value is not equal to itself.") |
---|
405 | | - | } |
---|
406 | | - | |
---|
407 | | - | |
---|
408 | | - | |
---|
409 | | - | @Callable(aT) |
---|
410 | | - | func vote (B,C,bn) = { |
---|
411 | | - | let z = $Tuple2(B, C) |
---|
412 | | - | let i = valueOrElse(getInteger(this, j), 0) |
---|
413 | | - | let bo = ac(this, w(i)) |
---|
414 | | - | let bi = ac(this, f) |
---|
415 | | - | let bp = (bo + bi) |
---|
416 | | - | let bq = getInteger(this, p) |
---|
417 | | - | let br = valueOrElse(getInteger(this, D(aT.caller, i)), 0) |
---|
418 | | - | let bs = valueOrElse(getInteger(this, F(z, aT.caller, i)), 0) |
---|
419 | | - | let bt = valueOrElse(getInteger(this, H(z, i)), 0) |
---|
420 | | - | let bu = valueOrElse(getInteger(this, N(i)), 0) |
---|
421 | | - | let bv = { |
---|
422 | | - | let ab = invoke(this, "getUserGwxAmountAtHeight", [toBase58String(aT.caller.bytes), bp], nil) |
---|
423 | | - | if ($isInstanceOf(ab, "Int")) |
---|
424 | | - | then ab |
---|
425 | | - | else throw(($getType(ab) + " couldn't be cast to Int")) |
---|
426 | | - | } |
---|
427 | | - | let bw = (bv - br) |
---|
428 | | - | let bx = (bs + bn) |
---|
429 | | - | let by = as(z) |
---|
430 | | - | let bj = [if ((getBoolean(y(z)) != unit)) |
---|
431 | | - | then true |
---|
432 | | - | else throw("invalid assets"), if ((bp > height)) |
---|
433 | | - | then true |
---|
434 | | - | else throw("invalid height"), if ((bq == unit)) |
---|
435 | | - | then true |
---|
436 | | - | else throw("finalization in progress"), if ((bv > 0)) |
---|
437 | | - | then true |
---|
438 | | - | else throw("you do not have gWX"), if (if ((bn > 0)) |
---|
439 | | - | then (bw >= bn) |
---|
440 | | - | else false) |
---|
441 | | - | then true |
---|
442 | | - | else throw("invalid amount"), if (by) |
---|
443 | | - | then true |
---|
444 | | - | else throw("pool hasn't WX_EMISSION label")] |
---|
445 | | - | if ((bj == bj)) |
---|
446 | | - | then { |
---|
447 | | - | let bz = av(z) |
---|
448 | | - | let P = toString(aT.caller) |
---|
449 | | - | let bA = if (aE(bz, P)) |
---|
450 | | - | then nil |
---|
451 | | - | else aI(bz, P) |
---|
452 | | - | $Tuple2(([IntegerEntry(D(aT.caller, i), (br + bn)), IntegerEntry(F(z, aT.caller, i), bx), IntegerEntry(H(z, i), (bt + bn)), IntegerEntry(N(i), (bu + bn))] ++ bA), unit) |
---|
453 | | - | } |
---|
454 | | - | else throw("Strict value is not equal to itself.") |
---|
455 | | - | } |
---|
456 | | - | |
---|
457 | | - | |
---|
458 | | - | |
---|
459 | | - | @Callable(aT) |
---|
460 | | - | func cancelVote (B,C) = { |
---|
461 | | - | let z = $Tuple2(B, C) |
---|
462 | | - | let i = valueOrElse(getInteger(this, j), 0) |
---|
463 | | - | let bo = ac(this, w(i)) |
---|
464 | | - | let bi = ac(this, f) |
---|
465 | | - | let bp = (bo + bi) |
---|
466 | | - | let bq = getInteger(this, p) |
---|
467 | | - | let br = valueOrElse(getInteger(this, D(aT.caller, i)), 0) |
---|
468 | | - | let bs = valueOrElse(getInteger(this, F(z, aT.caller, i)), 0) |
---|
469 | | - | let bt = valueOrElse(getInteger(this, H(z, i)), 0) |
---|
470 | | - | let bu = valueOrElse(getInteger(this, N(i)), 0) |
---|
471 | | - | let bj = [if ((getBoolean(y(z)) != unit)) |
---|
472 | | - | then true |
---|
473 | | - | else throw("invalid assets"), if ((bp > height)) |
---|
474 | | - | then true |
---|
475 | | - | else throw("invalid height"), if ((bq == unit)) |
---|
476 | | - | then true |
---|
477 | | - | else throw("finalization in progress"), if ((bs > 0)) |
---|
478 | | - | then true |
---|
479 | | - | else throw("no vote")] |
---|
480 | | - | if ((bj == bj)) |
---|
481 | | - | then { |
---|
482 | | - | let bz = av(z) |
---|
483 | | - | let P = toString(aT.caller) |
---|
484 | | - | $Tuple2(([IntegerEntry(D(aT.caller, i), max([(br - bs), 0])), DeleteEntry(F(z, aT.caller, i)), IntegerEntry(H(z, i), (bt - bs)), IntegerEntry(N(i), (bu - bs))] ++ aL(bz, P)), unit) |
---|
485 | | - | } |
---|
486 | | - | else throw("Strict value is not equal to itself.") |
---|
487 | | - | } |
---|
488 | | - | |
---|
489 | | - | |
---|
490 | | - | |
---|
491 | | - | @Callable(aT) |
---|
492 | | - | func setEpochLength (bB) = { |
---|
493 | | - | let bj = [aU(aT), if ((bB > 0)) |
---|
494 | | - | then true |
---|
495 | | - | else throw("invalid epoch length")] |
---|
496 | | - | if ((bj == bj)) |
---|
497 | | - | then $Tuple2([IntegerEntry(g, bB)], unit) |
---|
498 | | - | else throw("Strict value is not equal to itself.") |
---|
499 | | - | } |
---|
500 | | - | |
---|
501 | | - | |
---|
502 | | - | |
---|
503 | | - | @Callable(aT) |
---|
504 | | - | func setMaxDepth (bC) = { |
---|
505 | | - | let bj = [aU(aT), if ((bC > 0)) |
---|
506 | | - | then true |
---|
507 | | - | else throw("invalid max depth")] |
---|
508 | | - | if ((bj == bj)) |
---|
509 | | - | then $Tuple2([IntegerEntry(k, bC)], unit) |
---|
510 | | - | else throw("Strict value is not equal to itself.") |
---|
511 | | - | } |
---|
512 | | - | |
---|
513 | | - | |
---|
514 | | - | |
---|
515 | | - | @Callable(aT) |
---|
516 | | - | func processVoteINTERNAL (bD,P) = { |
---|
517 | | - | let aX = aS(aT) |
---|
518 | | - | if ((aX == aX)) |
---|
519 | | - | then { |
---|
520 | | - | let bc = valueOrErrorMessage(addressFromString(P), ("processVoteINTERNAL: invalid user address " + P)) |
---|
521 | | - | let i = ac(this, j) |
---|
522 | | - | let bE = (i - 1) |
---|
523 | | - | let bi = ac(this, f) |
---|
524 | | - | let bo = ac(this, w(i)) |
---|
525 | | - | let bp = (bo + bi) |
---|
526 | | - | let bF = ac(this, w(bE)) |
---|
527 | | - | let bG = ac(this, h(bE)) |
---|
528 | | - | let bH = (bF + bG) |
---|
529 | | - | let bI = if ((bE >= 0)) |
---|
530 | | - | then true |
---|
531 | | - | else throw("processVoteINTERNAL: invalid previous epoch") |
---|
532 | | - | if ((bI == bI)) |
---|
533 | | - | then { |
---|
534 | | - | let z = ae(bD) |
---|
535 | | - | let bJ = z |
---|
536 | | - | let B = bJ._1 |
---|
537 | | - | let C = bJ._2 |
---|
538 | | - | let by = as(z) |
---|
539 | | - | let bv = { |
---|
540 | | - | let ab = invoke(this, "getUserGwxAmountAtHeight", [P, bp], nil) |
---|
541 | | - | if ($isInstanceOf(ab, "Int")) |
---|
542 | | - | then ab |
---|
543 | | - | else throw(($getType(ab) + " couldn't be cast to Int")) |
---|
544 | | - | } |
---|
545 | | - | let bK = { |
---|
546 | | - | let ab = invoke(this, "getUserGwxAmountAtHeight", [P, bH], nil) |
---|
547 | | - | if ($isInstanceOf(ab, "Int")) |
---|
548 | | - | then ab |
---|
549 | | - | else throw(($getType(ab) + " couldn't be cast to Int")) |
---|
550 | | - | } |
---|
551 | | - | let bu = valueOrElse(getInteger(N(i)), 0) |
---|
552 | | - | let bL = valueOrElse(getInteger(H(z, i)), 0) |
---|
553 | | - | let bM = valueOrErrorMessage(getInteger(F(z, bc, bE)), (((("processVoteINTERNAL " + bD) + " ") + P) + ": no previous vote")) |
---|
554 | | - | let br = valueOrElse(getInteger(this, D(bc, i)), 0) |
---|
555 | | - | let K = ag(B, C) |
---|
556 | | - | let bN = valueOrElse(getInteger(J(K, bE)), 0) |
---|
557 | | - | let bh = addressFromStringValue(aa(this, o)) |
---|
558 | | - | let bO = valueOrElse(getInteger(bh, O(K, P)), 0) |
---|
559 | | - | let bP = if ((bO == 0)) |
---|
560 | | - | then nil |
---|
561 | | - | else [IntegerEntry(J(K, bE), (bN + bM))] |
---|
562 | | - | let bx = if ((bK > 0)) |
---|
563 | | - | then fraction(bM, bv, bK) |
---|
564 | | - | else 0 |
---|
565 | | - | let bQ = if (if ((bx > 0)) |
---|
566 | | - | then by |
---|
567 | | - | else false) |
---|
568 | | - | then [IntegerEntry(F(z, bc, i), bx), IntegerEntry(N(i), (bu + bx)), IntegerEntry(H(z, i), (bL + bx)), IntegerEntry(D(bc, i), (br + bx))] |
---|
569 | | - | else aL(av(z), P) |
---|
570 | | - | $Tuple2((bQ ++ bP), unit) |
---|
571 | | - | } |
---|
572 | | - | else throw("Strict value is not equal to itself.") |
---|
573 | | - | } |
---|
574 | | - | else throw("Strict value is not equal to itself.") |
---|
575 | | - | } |
---|
576 | | - | |
---|
577 | | - | |
---|
578 | | - | |
---|
579 | | - | @Callable(aT) |
---|
580 | | - | func processPoolINTERNAL (bD,bR) = { |
---|
581 | | - | let aX = aS(aT) |
---|
582 | | - | if ((aX == aX)) |
---|
583 | | - | then { |
---|
584 | | - | let bS = { |
---|
585 | | - | let bT = ac(this, j) |
---|
586 | | - | if (bR) |
---|
587 | | - | then bT |
---|
588 | | - | else (bT - 1) |
---|
589 | | - | } |
---|
590 | | - | let bI = if ((bS >= 0)) |
---|
591 | | - | then true |
---|
592 | | - | else throw("processPoolINTERNAL: invalid target epoch") |
---|
593 | | - | if ((bI == bI)) |
---|
594 | | - | then { |
---|
595 | | - | let z = ae(bD) |
---|
596 | | - | let bU = z |
---|
597 | | - | let B = bU._1 |
---|
598 | | - | let C = bU._2 |
---|
599 | | - | let bh = addressFromStringValue(aa(this, o)) |
---|
600 | | - | let ao = addressFromStringValue(aa(this, m)) |
---|
601 | | - | let ar = ag(B, C) |
---|
602 | | - | let bV = { |
---|
603 | | - | let ab = invoke(bh, "usersListTraversal", [ar], nil) |
---|
604 | | - | if ($isInstanceOf(ab, "Boolean")) |
---|
605 | | - | then ab |
---|
606 | | - | else throw(($getType(ab) + " couldn't be cast to Boolean")) |
---|
607 | | - | } |
---|
608 | | - | if ((bV == bV)) |
---|
609 | | - | then if (bV) |
---|
610 | | - | then $Tuple2(nil, true) |
---|
611 | | - | else { |
---|
612 | | - | let by = as(z) |
---|
613 | | - | let bu = valueOrElse(getInteger(this, N(bS)), 0) |
---|
614 | | - | let bL = valueOrElse(getInteger(this, H(z, bS)), 0) |
---|
615 | | - | let bW = if (if ((bu == 0)) |
---|
616 | | - | then true |
---|
617 | | - | else !(by)) |
---|
618 | | - | then 0 |
---|
619 | | - | else fraction(bL, b, bu) |
---|
620 | | - | let bX = invoke(ao, "modifyWeight", [ar, bW], nil) |
---|
621 | | - | if ((bX == bX)) |
---|
622 | | - | then { |
---|
623 | | - | let bY = if (if (by) |
---|
624 | | - | then true |
---|
625 | | - | else bR) |
---|
626 | | - | then nil |
---|
627 | | - | else ([DeleteEntry(y(z))] ++ aL(au, bD)) |
---|
628 | | - | $Tuple2(([IntegerEntry(L(z, bS), bW)] ++ bY), false) |
---|
629 | | - | } |
---|
630 | | - | else throw("Strict value is not equal to itself.") |
---|
631 | | - | } |
---|
632 | | - | else throw("Strict value is not equal to itself.") |
---|
633 | | - | } |
---|
634 | | - | else throw("Strict value is not equal to itself.") |
---|
635 | | - | } |
---|
636 | | - | else throw("Strict value is not equal to itself.") |
---|
637 | | - | } |
---|
638 | | - | |
---|
639 | | - | |
---|
640 | | - | |
---|
641 | | - | @Callable(aT) |
---|
642 | | - | func finalizeHelper () = { |
---|
643 | | - | let bR = valueOrElse(getBoolean(v), false) |
---|
644 | | - | let i = valueOrElse(getInteger(this, j), 0) |
---|
645 | | - | let bZ = (i - 1) |
---|
646 | | - | let bo = ac(this, w(i)) |
---|
647 | | - | let bi = ac(this, f) |
---|
648 | | - | let bp = (bo + bi) |
---|
649 | | - | let bq = getInteger(this, p) |
---|
650 | | - | if (if (if ((height >= bp)) |
---|
651 | | - | then (bq == unit) |
---|
652 | | - | else false) |
---|
653 | | - | then !(bR) |
---|
654 | | - | else false) |
---|
655 | | - | then { |
---|
656 | | - | let ca = (i + 1) |
---|
657 | | - | let cb = getInteger(this, g) |
---|
658 | | - | let cc = { |
---|
659 | | - | let X = cb |
---|
660 | | - | if ($isInstanceOf(X, "Int")) |
---|
661 | | - | then { |
---|
662 | | - | let bB = X |
---|
663 | | - | [IntegerEntry(f, bB), DeleteEntry(g)] |
---|
664 | | - | } |
---|
665 | | - | else if ($isInstanceOf(X, "Unit")) |
---|
666 | | - | then nil |
---|
667 | | - | else throw("Match error") |
---|
668 | | - | } |
---|
669 | | - | $Tuple2(([IntegerEntry(w(ca), height), IntegerEntry(s, height), IntegerEntry(j, ca), IntegerEntry(p, d), IntegerEntry(h(i), bi)] ++ cc), true) |
---|
670 | | - | } |
---|
671 | | - | else if (if (bR) |
---|
672 | | - | then (bq == unit) |
---|
673 | | - | else false) |
---|
674 | | - | then $Tuple2([IntegerEntry(p, e)], true) |
---|
675 | | - | else if ((bq == unit)) |
---|
676 | | - | then $Tuple2(nil, false) |
---|
677 | | - | else if ((bq == d)) |
---|
678 | | - | then { |
---|
679 | | - | let cd = getString(q) |
---|
680 | | - | let ce = getString(r) |
---|
681 | | - | let X = cd |
---|
682 | | - | if ($isInstanceOf(X, "Unit")) |
---|
683 | | - | then { |
---|
684 | | - | let cf = getString(ax(au)) |
---|
685 | | - | if ($isInstanceOf(cf, "Unit")) |
---|
686 | | - | then $Tuple2([IntegerEntry(p, e), DeleteEntry(q), DeleteEntry(r)], true) |
---|
687 | | - | else if ($isInstanceOf(cf, "String")) |
---|
688 | | - | then { |
---|
689 | | - | let cg = cf |
---|
690 | | - | $Tuple2([StringEntry(q, cg)], true) |
---|
691 | | - | } |
---|
692 | | - | else throw("Match error") |
---|
693 | | - | } |
---|
694 | | - | else if ($isInstanceOf(X, "String")) |
---|
695 | | - | then { |
---|
696 | | - | let bD = X |
---|
697 | | - | let z = ae(bD) |
---|
698 | | - | let ch = { |
---|
699 | | - | let cf = ce |
---|
700 | | - | if ($isInstanceOf(cf, "Unit")) |
---|
701 | | - | then getString(ax(av(z))) |
---|
702 | | - | else if ($isInstanceOf(cf, "String")) |
---|
703 | | - | then { |
---|
704 | | - | let ci = cf |
---|
705 | | - | let cj = getString(aD(av(z), ci)) |
---|
706 | | - | if ((cj == cj)) |
---|
707 | | - | then { |
---|
708 | | - | let ck = invoke(this, "processVoteINTERNAL", [bD, ci], nil) |
---|
709 | | - | if ((ck == ck)) |
---|
710 | | - | then cj |
---|
711 | | - | else throw("Strict value is not equal to itself.") |
---|
712 | | - | } |
---|
713 | | - | else throw("Strict value is not equal to itself.") |
---|
714 | | - | } |
---|
715 | | - | else throw("Match error") |
---|
716 | | - | } |
---|
717 | | - | let cf = ch |
---|
718 | | - | if ($isInstanceOf(cf, "Unit")) |
---|
719 | | - | then { |
---|
720 | | - | let cl = getString(aD(au, bD)) |
---|
721 | | - | let cm = cl |
---|
722 | | - | if ($isInstanceOf(cm, "Unit")) |
---|
723 | | - | then $Tuple2([IntegerEntry(p, e), DeleteEntry(q), DeleteEntry(r)], true) |
---|
724 | | - | else if ($isInstanceOf(cm, "String")) |
---|
725 | | - | then { |
---|
726 | | - | let aP = cm |
---|
727 | | - | $Tuple2([StringEntry(q, aP), DeleteEntry(r)], true) |
---|
728 | | - | } |
---|
729 | | - | else throw("Match error") |
---|
730 | | - | } |
---|
731 | | - | else if ($isInstanceOf(cf, "String")) |
---|
732 | | - | then { |
---|
733 | | - | let cn = cf |
---|
734 | | - | $Tuple2([StringEntry(r, cn)], true) |
---|
735 | | - | } |
---|
736 | | - | else throw("Match error") |
---|
737 | | - | } |
---|
738 | | - | else throw("Match error") |
---|
739 | | - | } |
---|
740 | | - | else if ((bq == e)) |
---|
741 | | - | then { |
---|
742 | | - | let cd = getString(q) |
---|
743 | | - | let X = cd |
---|
744 | | - | if ($isInstanceOf(X, "Unit")) |
---|
745 | | - | then { |
---|
746 | | - | let cf = getString(ax(au)) |
---|
747 | | - | if ($isInstanceOf(cf, "Unit")) |
---|
748 | | - | then { |
---|
749 | | - | let bQ = if (bR) |
---|
750 | | - | then [DeleteEntry(p), DeleteEntry(v)] |
---|
751 | | - | else [DeleteEntry(p), BooleanEntry(x(bZ), true), IntegerEntry(t, i), IntegerEntry(u, bo)] |
---|
752 | | - | $Tuple2(bQ, true) |
---|
753 | | - | } |
---|
754 | | - | else if ($isInstanceOf(cf, "String")) |
---|
755 | | - | then { |
---|
756 | | - | let co = cf |
---|
757 | | - | $Tuple2([StringEntry(q, co)], true) |
---|
758 | | - | } |
---|
759 | | - | else throw("Match error") |
---|
760 | | - | } |
---|
761 | | - | else if ($isInstanceOf(X, "String")) |
---|
762 | | - | then { |
---|
763 | | - | let bD = X |
---|
764 | | - | let cl = getString(aD(au, bD)) |
---|
765 | | - | if ((cl == cl)) |
---|
766 | | - | then { |
---|
767 | | - | let bV = { |
---|
768 | | - | let ab = invoke(this, "processPoolINTERNAL", [bD, bR], nil) |
---|
769 | | - | if ($isInstanceOf(ab, "Boolean")) |
---|
770 | | - | then ab |
---|
771 | | - | else throw(($getType(ab) + " couldn't be cast to Boolean")) |
---|
772 | | - | } |
---|
773 | | - | if ((bV == bV)) |
---|
774 | | - | then if (bV) |
---|
775 | | - | then $Tuple2(nil, true) |
---|
776 | | - | else { |
---|
777 | | - | let cf = cl |
---|
778 | | - | if ($isInstanceOf(cf, "Unit")) |
---|
779 | | - | then { |
---|
780 | | - | let bQ = if (bR) |
---|
781 | | - | then [DeleteEntry(p), DeleteEntry(v), DeleteEntry(q)] |
---|
782 | | - | else [DeleteEntry(p), BooleanEntry(x(bZ), true), IntegerEntry(t, i), IntegerEntry(u, bo), DeleteEntry(q)] |
---|
783 | | - | $Tuple2(bQ, true) |
---|
784 | | - | } |
---|
785 | | - | else if ($isInstanceOf(cf, "String")) |
---|
786 | | - | then { |
---|
787 | | - | let co = cf |
---|
788 | | - | $Tuple2([StringEntry(q, co)], true) |
---|
789 | | - | } |
---|
790 | | - | else throw("Match error") |
---|
791 | | - | } |
---|
792 | | - | else throw("Strict value is not equal to itself.") |
---|
793 | | - | } |
---|
794 | | - | else throw("Strict value is not equal to itself.") |
---|
795 | | - | } |
---|
796 | | - | else throw("Match error") |
---|
797 | | - | } |
---|
798 | | - | else throw("finalization is broken") |
---|
799 | | - | } |
---|
800 | | - | |
---|
801 | | - | |
---|
802 | | - | |
---|
803 | | - | @Callable(aT) |
---|
804 | | - | func finalizeWrapper (cp) = { |
---|
805 | | - | let cq = { |
---|
806 | | - | let ab = invoke(this, "finalizeHelper", nil, nil) |
---|
807 | | - | if ($isInstanceOf(ab, "Boolean")) |
---|
808 | | - | then ab |
---|
809 | | - | else throw(($getType(ab) + " couldn't be cast to Boolean")) |
---|
810 | | - | } |
---|
811 | | - | if ((cq == cq)) |
---|
812 | | - | then if (!(cq)) |
---|
813 | | - | then if ((cp == 0)) |
---|
814 | | - | then throw("Current voting is not over yet") |
---|
815 | | - | else $Tuple2(nil, unit) |
---|
816 | | - | else { |
---|
817 | | - | let cr = valueOrElse(getInteger(this, k), c) |
---|
818 | | - | if ((cr > cp)) |
---|
819 | | - | then { |
---|
820 | | - | let cs = invoke(this, "finalizeWrapper", [(cp + 1)], nil) |
---|
821 | | - | if ((cs == cs)) |
---|
822 | | - | then $Tuple2(nil, unit) |
---|
823 | | - | else throw("Strict value is not equal to itself.") |
---|
824 | | - | } |
---|
825 | | - | else $Tuple2(nil, unit) |
---|
826 | | - | } |
---|
827 | | - | else throw("Strict value is not equal to itself.") |
---|
828 | | - | } |
---|
829 | | - | |
---|
830 | | - | |
---|
831 | | - | |
---|
832 | | - | @Callable(aT) |
---|
833 | | - | func finalize () = { |
---|
834 | | - | let cs = invoke(this, "finalizeWrapper", [0], nil) |
---|
835 | | - | if ((cs == cs)) |
---|
836 | | - | then $Tuple2(nil, unit) |
---|
837 | | - | else throw("Strict value is not equal to itself.") |
---|
838 | | - | } |
---|
839 | | - | |
---|
840 | | - | |
---|
841 | | - | |
---|
842 | | - | @Callable(aT) |
---|
843 | | - | func containsNodeREADONLY (ay,aC) = $Tuple2(nil, aE(ay, aC)) |
---|
844 | | - | |
---|
845 | | - | |
---|
846 | | - | |
---|
847 | | - | @Callable(aT) |
---|
848 | | - | func insertNode (ay,aC) = { |
---|
849 | | - | let aX = aU(aT) |
---|
850 | | - | if ((aX == aX)) |
---|
851 | | - | then $Tuple2(aI(ay, aC), unit) |
---|
852 | | - | else throw("Strict value is not equal to itself.") |
---|
853 | | - | } |
---|
854 | | - | |
---|
855 | | - | |
---|
856 | | - | |
---|
857 | | - | @Callable(aT) |
---|
858 | | - | func deleteNode (ay,aC) = { |
---|
859 | | - | let aX = aU(aT) |
---|
860 | | - | if ((aX == aX)) |
---|
861 | | - | then $Tuple2(aL(ay, aC), unit) |
---|
862 | | - | else throw("Strict value is not equal to itself.") |
---|
863 | | - | } |
---|
864 | | - | |
---|
865 | | - | |
---|
866 | | - | @Verifier(ct) |
---|
867 | | - | func cu () = { |
---|
868 | | - | let cv = { |
---|
869 | | - | let X = aO() |
---|
870 | | - | if ($isInstanceOf(X, "ByteVector")) |
---|
871 | | - | then { |
---|
872 | | - | let aV = X |
---|
873 | | - | aV |
---|
874 | | - | } |
---|
875 | | - | else if ($isInstanceOf(X, "Unit")) |
---|
876 | | - | then ct.senderPublicKey |
---|
877 | | - | else throw("Match error") |
---|
878 | | - | } |
---|
879 | | - | sigVerify(ct.bodyBytes, ct.proofs[0], cv) |
---|
880 | | - | } |
---|
881 | | - | |
---|
| 1 | + | # no script |
---|