1 | | - | {-# STDLIB_VERSION 6 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = 1000 |
---|
7 | | - | |
---|
8 | | - | let c = 100000000 |
---|
9 | | - | |
---|
10 | | - | let d = toBigInt(0) |
---|
11 | | - | |
---|
12 | | - | let e = 0 |
---|
13 | | - | |
---|
14 | | - | let f = 1 |
---|
15 | | - | |
---|
16 | | - | func g (h) = valueOrElse(getInteger(this, h), 0) |
---|
17 | | - | |
---|
18 | | - | |
---|
19 | | - | func i (h) = valueOrErrorMessage(getInteger(this, h), (("mandatory this." + h) + " is not defined")) |
---|
20 | | - | |
---|
21 | | - | |
---|
22 | | - | func j (h) = valueOrElse(getString(this, h), "") |
---|
23 | | - | |
---|
24 | | - | |
---|
25 | | - | func k (h) = valueOrErrorMessage(getString(this, h), (("mandatory this." + h) + " is not defined")) |
---|
26 | | - | |
---|
27 | | - | |
---|
28 | | - | func l (m) = if ((0 > m)) |
---|
29 | | - | then -(m) |
---|
30 | | - | else m |
---|
31 | | - | |
---|
32 | | - | |
---|
33 | | - | func n (m) = if ((d > m)) |
---|
34 | | - | then -(m) |
---|
35 | | - | else m |
---|
36 | | - | |
---|
37 | | - | |
---|
38 | | - | let o = "%s__maxDepth" |
---|
39 | | - | |
---|
40 | | - | let p = 30 |
---|
41 | | - | |
---|
42 | | - | let q = valueOrElse(getInteger(this, o), p) |
---|
43 | | - | |
---|
44 | | - | func r () = "%s%s__config__factoryAddress" |
---|
45 | | - | |
---|
46 | | - | |
---|
47 | | - | let s = k(r()) |
---|
48 | | - | |
---|
49 | | - | let t = addressFromStringValue(s) |
---|
50 | | - | |
---|
51 | | - | func u () = "%s%s__config__emissionAddress" |
---|
52 | | - | |
---|
53 | | - | |
---|
54 | | - | func v (w) = makeString(["%s%s%s", "mapping", "num2user", toString(w)], a) |
---|
55 | | - | |
---|
56 | | - | |
---|
57 | | - | let x = makeString(["%s%s", "referral", "programName"], a) |
---|
58 | | - | |
---|
59 | | - | let y = "wxlock" |
---|
60 | | - | |
---|
61 | | - | let z = valueOrElse(getString(this, x), y) |
---|
62 | | - | |
---|
63 | | - | let A = makeString(["%s%s", "referral", "minGWxAmount"], a) |
---|
64 | | - | |
---|
65 | | - | let B = (500 * c) |
---|
66 | | - | |
---|
67 | | - | let C = valueOrElse(getInteger(this, A), B) |
---|
68 | | - | |
---|
69 | | - | let D = makeString(["%s%s", "referral", "referrerRewardPermille"], a) |
---|
70 | | - | |
---|
71 | | - | let E = 50 |
---|
72 | | - | |
---|
73 | | - | let F = valueOrElse(getInteger(this, D), E) |
---|
74 | | - | |
---|
75 | | - | let G = makeString(["%s%s", "referral", "referralRewardPermille"], a) |
---|
76 | | - | |
---|
77 | | - | let H = 50 |
---|
78 | | - | |
---|
79 | | - | let I = valueOrElse(getInteger(this, G), H) |
---|
80 | | - | |
---|
81 | | - | func J (K) = makeString(["%s%s%s", "referrer", z, K], a) |
---|
82 | | - | |
---|
83 | | - | |
---|
84 | | - | func L (M,N) = makeString(["%s%s%s", "unclaimedReferral", M, N], a) |
---|
85 | | - | |
---|
86 | | - | |
---|
87 | | - | let O = k(u()) |
---|
88 | | - | |
---|
89 | | - | let P = addressFromStringValue(O) |
---|
90 | | - | |
---|
91 | | - | let Q = 1 |
---|
92 | | - | |
---|
93 | | - | let R = 2 |
---|
94 | | - | |
---|
95 | | - | let S = 3 |
---|
96 | | - | |
---|
97 | | - | let T = 4 |
---|
98 | | - | |
---|
99 | | - | func U () = "%s__config" |
---|
100 | | - | |
---|
101 | | - | |
---|
102 | | - | func V () = split(k(U()), a) |
---|
103 | | - | |
---|
104 | | - | |
---|
105 | | - | func W (X,Y,Z,q) = makeString(["%s%s%s%d", X, Y, Z, toString(q)], a) |
---|
106 | | - | |
---|
107 | | - | |
---|
108 | | - | func aa () = { |
---|
109 | | - | let ab = V() |
---|
110 | | - | valueOrErrorMessage(addressFromString(ab[S]), "boosting contract address is not defined") |
---|
111 | | - | } |
---|
112 | | - | |
---|
113 | | - | |
---|
114 | | - | func ac () = "%s%s__gwxRewardEmissionPart__startHeight" |
---|
115 | | - | |
---|
116 | | - | |
---|
117 | | - | func ad () = "%s__nextUserNum" |
---|
118 | | - | |
---|
119 | | - | |
---|
120 | | - | func ae () = "%s%s__ratePerBlock__current" |
---|
121 | | - | |
---|
122 | | - | |
---|
123 | | - | func af () = "%s%s__poolWeight__GWXvirtualPOOL" |
---|
124 | | - | |
---|
125 | | - | |
---|
126 | | - | func ag () = "%s__nextProcessedUser" |
---|
127 | | - | |
---|
128 | | - | |
---|
129 | | - | func ah () = "%s__latestPeriod" |
---|
130 | | - | |
---|
131 | | - | |
---|
132 | | - | func ai () = "%s__nextPeriod" |
---|
133 | | - | |
---|
134 | | - | |
---|
135 | | - | func aj () = "%s__processingStage" |
---|
136 | | - | |
---|
137 | | - | |
---|
138 | | - | func ak () = "%s__nextProcessedPeriod" |
---|
139 | | - | |
---|
140 | | - | |
---|
141 | | - | func al (am) = makeString(["%s%d", "userUnclaimed", toString(am)], a) |
---|
142 | | - | |
---|
143 | | - | |
---|
144 | | - | func an (am) = makeString(["%s%d__nextClaimedPeriod", toString(am)], a) |
---|
145 | | - | |
---|
146 | | - | |
---|
147 | | - | func ao (am) = makeString(["%s%d__lastProcessedPeriod", toString(am)], a) |
---|
148 | | - | |
---|
149 | | - | |
---|
150 | | - | func ap (aq) = makeString(["%s%d__startHeightForPeriod", toString(aq)], a) |
---|
151 | | - | |
---|
152 | | - | |
---|
153 | | - | func ar (aq) = makeString(["%s%d__auxEmissionReward", toString(aq)], a) |
---|
154 | | - | |
---|
155 | | - | |
---|
156 | | - | func as (aq) = makeString(["%s%d__totalAmountForPeriod", toString(aq)], a) |
---|
157 | | - | |
---|
158 | | - | |
---|
159 | | - | func at () = "%s__lastPayoutInfo" |
---|
160 | | - | |
---|
161 | | - | |
---|
162 | | - | func au (aq,av,aw) = makeString(["%d%d%d", toString(aq), toString(av), toString(aw)], a) |
---|
163 | | - | |
---|
164 | | - | |
---|
165 | | - | func ax (aq) = makeString(["%s%s%d__payouts__history", toString(aq)], a) |
---|
166 | | - | |
---|
167 | | - | |
---|
168 | | - | func ay (aq) = makeString(["%s%d__totalWeightForPeriod", toString(aq)], a) |
---|
169 | | - | |
---|
170 | | - | |
---|
171 | | - | func az (aq,am) = makeString(["%s%d%s%d__paramByPeriod", toString(am), "k", toString(aq)], a) |
---|
172 | | - | |
---|
173 | | - | |
---|
174 | | - | func aA (aq,am) = makeString(["%s%d%s%d__paramByPeriod", toString(am), "b", toString(aq)], a) |
---|
175 | | - | |
---|
176 | | - | |
---|
177 | | - | func aB (aq,am) = makeString(["%s%d%s%d__paramByPeriod", toString(am), "weight", toString(aq)], a) |
---|
178 | | - | |
---|
179 | | - | |
---|
180 | | - | func aC () = makeString(["%s%s", "config", "referralsContractAddress"], a) |
---|
181 | | - | |
---|
182 | | - | |
---|
183 | | - | let aD = addressFromStringValue(k(aC())) |
---|
184 | | - | |
---|
185 | | - | func aE (aF,aG,aH,aI) = { |
---|
186 | | - | let aJ = makeString(["%s%s%s%s__history", aF, aG, toBase58String(aI.transactionId)], a) |
---|
187 | | - | let aK = makeString(["%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(aH)], a) |
---|
188 | | - | StringEntry(aJ, aK) |
---|
189 | | - | } |
---|
190 | | - | |
---|
191 | | - | |
---|
192 | | - | func aL () = "%s__managerPublicKey" |
---|
193 | | - | |
---|
194 | | - | |
---|
195 | | - | func aM () = "%s__pendingManagerPublicKey" |
---|
196 | | - | |
---|
197 | | - | |
---|
198 | | - | func aN () = { |
---|
199 | | - | let aO = getString(aL()) |
---|
200 | | - | if ($isInstanceOf(aO, "String")) |
---|
201 | | - | then { |
---|
202 | | - | let aP = aO |
---|
203 | | - | fromBase58String(aP) |
---|
204 | | - | } |
---|
205 | | - | else if ($isInstanceOf(aO, "Unit")) |
---|
206 | | - | then unit |
---|
207 | | - | else throw("Match error") |
---|
208 | | - | } |
---|
209 | | - | |
---|
210 | | - | |
---|
211 | | - | func aQ () = { |
---|
212 | | - | let aO = getString(aM()) |
---|
213 | | - | if ($isInstanceOf(aO, "String")) |
---|
214 | | - | then { |
---|
215 | | - | let aP = aO |
---|
216 | | - | fromBase58String(aP) |
---|
217 | | - | } |
---|
218 | | - | else if ($isInstanceOf(aO, "Unit")) |
---|
219 | | - | then unit |
---|
220 | | - | else throw("Match error") |
---|
221 | | - | } |
---|
222 | | - | |
---|
223 | | - | |
---|
224 | | - | func aR (aI) = { |
---|
225 | | - | let aS = throw("Permission denied") |
---|
226 | | - | let aO = aN() |
---|
227 | | - | if ($isInstanceOf(aO, "ByteVector")) |
---|
228 | | - | then { |
---|
229 | | - | let aT = aO |
---|
230 | | - | if ((aI.callerPublicKey == aT)) |
---|
231 | | - | then true |
---|
232 | | - | else aS |
---|
233 | | - | } |
---|
234 | | - | else if ($isInstanceOf(aO, "Unit")) |
---|
235 | | - | then if ((aI.caller == this)) |
---|
236 | | - | then true |
---|
237 | | - | else aS |
---|
238 | | - | else throw("Match error") |
---|
239 | | - | } |
---|
240 | | - | |
---|
241 | | - | |
---|
242 | | - | func aU (aV,aW,aq,am) = { |
---|
243 | | - | let aX = ao(am) |
---|
244 | | - | let aY = az(aq, am) |
---|
245 | | - | let aZ = getInteger(aV, aY) |
---|
246 | | - | let ba = aB(aq, am) |
---|
247 | | - | if (isDefined(aZ)) |
---|
248 | | - | then { |
---|
249 | | - | let bb = value(aZ) |
---|
250 | | - | let bc = value(getInteger(aV, aA(aq, am))) |
---|
251 | | - | let bd = ((bb * aW) + bc) |
---|
252 | | - | if ((bd > 0)) |
---|
253 | | - | then $Tuple2((bd / b), [IntegerEntry(aX, aq), IntegerEntry(ba, bd)]) |
---|
254 | | - | else $Tuple2(0, nil) |
---|
255 | | - | } |
---|
256 | | - | else { |
---|
257 | | - | let be = getInteger(this, aX) |
---|
258 | | - | if (if (isDefined(be)) |
---|
259 | | - | then (aq >= value(be)) |
---|
260 | | - | else false) |
---|
261 | | - | then { |
---|
262 | | - | let bf = value(be) |
---|
263 | | - | let bb = value(getInteger(aV, az(bf, am))) |
---|
264 | | - | let bc = value(getInteger(aV, aA(bf, am))) |
---|
265 | | - | let bd = ((bb * aW) + bc) |
---|
266 | | - | if ((bd > 0)) |
---|
267 | | - | then $Tuple2((bd / b), [IntegerEntry(ba, bd)]) |
---|
268 | | - | else $Tuple2(0, nil) |
---|
269 | | - | } |
---|
270 | | - | else $Tuple2(0, nil) |
---|
271 | | - | } |
---|
272 | | - | } |
---|
273 | | - | |
---|
274 | | - | |
---|
275 | | - | func bg (aV,aW,aq,am) = { |
---|
276 | | - | let ba = aB(aq, am) |
---|
277 | | - | let bh = getInteger(ba) |
---|
278 | | - | let aO = bh |
---|
279 | | - | if ($isInstanceOf(aO, "Unit")) |
---|
280 | | - | then 0 |
---|
281 | | - | else if ($isInstanceOf(aO, "Int")) |
---|
282 | | - | then { |
---|
283 | | - | let bd = aO |
---|
284 | | - | (bd / b) |
---|
285 | | - | } |
---|
286 | | - | else throw("Match error") |
---|
287 | | - | } |
---|
288 | | - | |
---|
289 | | - | |
---|
290 | | - | func bi (Z,bj) = { |
---|
291 | | - | let h = makeString(["%s%s%s", "mapping", "user2num", bj], a) |
---|
292 | | - | parseIntValue(valueOrErrorMessage(getString(Address(fromBase58String(Z)), h), ((("User address " + bj) + " is not found in boosting contract data, key=") + h))) |
---|
293 | | - | } |
---|
294 | | - | |
---|
295 | | - | |
---|
296 | | - | func bk () = g(ai()) |
---|
297 | | - | |
---|
298 | | - | |
---|
299 | | - | func bl (bj) = { |
---|
300 | | - | let ab = V() |
---|
301 | | - | let bm = bi(ab[S], bj) |
---|
302 | | - | let bn = getInteger(al(bm)) |
---|
303 | | - | let aO = bn |
---|
304 | | - | if ($isInstanceOf(aO, "Unit")) |
---|
305 | | - | then $Tuple2(0, nil) |
---|
306 | | - | else if ($isInstanceOf(aO, "Int")) |
---|
307 | | - | then { |
---|
308 | | - | let bo = aO |
---|
309 | | - | $Tuple2(bo, [IntegerEntry(al(bm), 0)]) |
---|
310 | | - | } |
---|
311 | | - | else throw("Match error") |
---|
312 | | - | } |
---|
313 | | - | |
---|
314 | | - | |
---|
315 | | - | @Callable(aI) |
---|
316 | | - | func updateReferralActivity (bj,bp) = { |
---|
317 | | - | let bq = getString(aD, J(bj)) |
---|
318 | | - | let br = if ((bq == unit)) |
---|
319 | | - | then unit |
---|
320 | | - | else invoke(aD, "updateReferralActivity", [z, bj, (bp >= C)], nil) |
---|
321 | | - | if ((br == br)) |
---|
322 | | - | then $Tuple2(nil, unit) |
---|
323 | | - | else throw("Strict value is not equal to itself.") |
---|
324 | | - | } |
---|
325 | | - | |
---|
326 | | - | |
---|
327 | | - | |
---|
328 | | - | @Callable(aI) |
---|
329 | | - | func finalizeHelper () = { |
---|
330 | | - | let bs = valueOrElse(getInteger(aj()), e) |
---|
331 | | - | let bt = g(ak()) |
---|
332 | | - | let bu = g(ag()) |
---|
333 | | - | let bv = g(ah()) |
---|
334 | | - | let bw = valueOrElse(getInteger(aa(), ad()), 0) |
---|
335 | | - | let bx = ay(bt) |
---|
336 | | - | let by = g(ay(bt)) |
---|
337 | | - | let aW = g(ap(bt)) |
---|
338 | | - | if ((bt > bv)) |
---|
339 | | - | then $Tuple2(nil, false) |
---|
340 | | - | else if ((bs == e)) |
---|
341 | | - | then { |
---|
342 | | - | let bz = aU(aa(), aW, bt, bu) |
---|
343 | | - | let bA = bz._1 |
---|
344 | | - | let bB = bz._2 |
---|
345 | | - | let bC = (by + bA) |
---|
346 | | - | let bD = if (((bw - 1) > bu)) |
---|
347 | | - | then [IntegerEntry(ag(), (bu + 1))] |
---|
348 | | - | else [IntegerEntry(aj(), f), IntegerEntry(ag(), 0)] |
---|
349 | | - | $Tuple2((([IntegerEntry(bx, bC)] ++ bD) ++ bB), true) |
---|
350 | | - | } |
---|
351 | | - | else if ((bs == f)) |
---|
352 | | - | then { |
---|
353 | | - | let bA = bg(aa(), aW, bt, bu) |
---|
354 | | - | let bE = fraction(g(as(bt)), bA, by) |
---|
355 | | - | let bF = fraction(g(ar(bt)), bA, by) |
---|
356 | | - | let bG = (bF + bE) |
---|
357 | | - | let bn = getInteger(al(bu)) |
---|
358 | | - | let bj = getStringValue(aa(), v(bu)) |
---|
359 | | - | let bq = getString(aD, J(bj)) |
---|
360 | | - | let br = if ((bq == unit)) |
---|
361 | | - | then unit |
---|
362 | | - | else invoke(aD, "updateReferralActivity", [z, bj, (bA >= C)], nil) |
---|
363 | | - | if ((br == br)) |
---|
364 | | - | then { |
---|
365 | | - | let bH = if (if ((bq == unit)) |
---|
366 | | - | then true |
---|
367 | | - | else (C > bA)) |
---|
368 | | - | then unit |
---|
369 | | - | else { |
---|
370 | | - | let bI = fraction(bG, F, b) |
---|
371 | | - | let bJ = fraction(bG, I, b) |
---|
372 | | - | invoke(aD, "incUnclaimed", [z, bj, bI, bJ], nil) |
---|
373 | | - | } |
---|
374 | | - | if ((bH == bH)) |
---|
375 | | - | then { |
---|
376 | | - | let bK = [IntegerEntry(al(bu), (valueOrElse(bn, 0) + bG))] |
---|
377 | | - | let bD = if (((bw - 1) > bu)) |
---|
378 | | - | then [IntegerEntry(ag(), (bu + 1))] |
---|
379 | | - | else [IntegerEntry(ak(), (bt + 1)), IntegerEntry(ag(), 0), DeleteEntry(aj())] |
---|
380 | | - | $Tuple2((bK ++ bD), true) |
---|
381 | | - | } |
---|
382 | | - | else throw("Strict value is not equal to itself.") |
---|
383 | | - | } |
---|
384 | | - | else throw("Strict value is not equal to itself.") |
---|
385 | | - | } |
---|
386 | | - | else throw("invalid processing stage") |
---|
387 | | - | } |
---|
388 | | - | |
---|
389 | | - | |
---|
390 | | - | |
---|
391 | | - | @Callable(aI) |
---|
392 | | - | func finalizeWrapper (bL) = { |
---|
393 | | - | let bM = { |
---|
394 | | - | let bN = invoke(this, "finalizeHelper", nil, nil) |
---|
395 | | - | if ($isInstanceOf(bN, "Boolean")) |
---|
396 | | - | then bN |
---|
397 | | - | else throw(($getType(bN) + " couldn't be cast to Boolean")) |
---|
398 | | - | } |
---|
399 | | - | if ((bM == bM)) |
---|
400 | | - | then if (!(bM)) |
---|
401 | | - | then if ((bL == q)) |
---|
402 | | - | then throw("Nothing to process") |
---|
403 | | - | else $Tuple2(nil, unit) |
---|
404 | | - | else if ((bL > 0)) |
---|
405 | | - | then $Tuple2(nil, invoke(this, "finalizeWrapper", [(bL - 1)], nil)) |
---|
406 | | - | else $Tuple2(nil, unit) |
---|
407 | | - | else throw("Strict value is not equal to itself.") |
---|
408 | | - | } |
---|
409 | | - | |
---|
410 | | - | |
---|
411 | | - | |
---|
412 | | - | @Callable(aI) |
---|
413 | | - | func processPendingPeriodsAndUsers () = $Tuple2(nil, invoke(this, "finalizeWrapper", [q], nil)) |
---|
414 | | - | |
---|
415 | | - | |
---|
416 | | - | |
---|
417 | | - | @Callable(aI) |
---|
418 | | - | func deposit () = { |
---|
419 | | - | let ab = V() |
---|
420 | | - | if ((aI.caller != Address(fromBase58String(ab[R])))) |
---|
421 | | - | then throw("Wrong caller address") |
---|
422 | | - | else { |
---|
423 | | - | let bO = value(value(aI.payments[0]).assetId) |
---|
424 | | - | if ((bO != fromBase58String(ab[Q]))) |
---|
425 | | - | then throw("Wrong payment asset") |
---|
426 | | - | else { |
---|
427 | | - | let aq = bk() |
---|
428 | | - | let bP = (height - i(ac())) |
---|
429 | | - | let bQ = valueOrErrorMessage(getInteger(P, ae()), (("mandatory emission_contract." + ae()) + " is not defined")) |
---|
430 | | - | let bR = valueOrErrorMessage(getInteger(t, af()), (("mandatory factory_contract." + af()) + " is not defined")) |
---|
431 | | - | let bS = fraction((bP * bR), bQ, c) |
---|
432 | | - | let bT = invoke(P, "emit", [bS], nil) |
---|
433 | | - | if ((bT == bT)) |
---|
434 | | - | then { |
---|
435 | | - | let bU = value(aI.payments[0]).amount |
---|
436 | | - | let bV = au(aq, bU, bS) |
---|
437 | | - | [IntegerEntry(ah(), aq), IntegerEntry(ap(aq), height), IntegerEntry(ar(aq), bS), IntegerEntry(ac(), height), IntegerEntry(as(aq), bU), IntegerEntry(ai(), (aq + 1)), StringEntry(at(), bV), StringEntry(ax(aq), bV)] |
---|
438 | | - | } |
---|
439 | | - | else throw("Strict value is not equal to itself.") |
---|
440 | | - | } |
---|
441 | | - | } |
---|
442 | | - | } |
---|
443 | | - | |
---|
444 | | - | |
---|
445 | | - | |
---|
446 | | - | @Callable(aI) |
---|
447 | | - | func claimReward () = { |
---|
448 | | - | let ab = V() |
---|
449 | | - | let bW = toString(aI.caller) |
---|
450 | | - | let bX = bl(bW) |
---|
451 | | - | let aH = bX._1 |
---|
452 | | - | let bY = bX._2 |
---|
453 | | - | let bZ = if ((aH > 0)) |
---|
454 | | - | then true |
---|
455 | | - | else throw("Nothing to claim") |
---|
456 | | - | if ((bZ == bZ)) |
---|
457 | | - | then { |
---|
458 | | - | let ca = 0 |
---|
459 | | - | let cb = { |
---|
460 | | - | let bN = invoke(aD, "claim", [z], nil) |
---|
461 | | - | if ($isInstanceOf(bN, "Int")) |
---|
462 | | - | then bN |
---|
463 | | - | else throw(($getType(bN) + " couldn't be cast to Int")) |
---|
464 | | - | } |
---|
465 | | - | let cc = (aH + cb) |
---|
466 | | - | $Tuple2(([ScriptTransfer(aI.caller, cc, fromBase58String(ab[Q])), aE("claim", bW, aH, aI)] ++ bY), [cc, ca]) |
---|
467 | | - | } |
---|
468 | | - | else throw("Strict value is not equal to itself.") |
---|
469 | | - | } |
---|
470 | | - | |
---|
471 | | - | |
---|
472 | | - | |
---|
473 | | - | @Callable(aI) |
---|
474 | | - | func claimRewardREADONLY (bW) = { |
---|
475 | | - | let cd = bl(bW) |
---|
476 | | - | let aH = cd._1 |
---|
477 | | - | let bY = cd._2 |
---|
478 | | - | let ce = valueOrElse(getInteger(aD, L(z, bW)), 0) |
---|
479 | | - | let cc = (aH + ce) |
---|
480 | | - | $Tuple2(nil, cc) |
---|
481 | | - | } |
---|
482 | | - | |
---|
483 | | - | |
---|
484 | | - | |
---|
485 | | - | @Callable(aI) |
---|
486 | | - | func latestFinalizedPeriodREADONLY (bW) = $Tuple2(nil, valueOrElse(getInteger(this, ah()), -1)) |
---|
487 | | - | |
---|
488 | | - | |
---|
489 | | - | |
---|
490 | | - | @Callable(aI) |
---|
491 | | - | func latestFinalizedPeriodInfoREADONLY (bW) = $Tuple2(nil, j(at())) |
---|
492 | | - | |
---|
493 | | - | |
---|
494 | | - | |
---|
495 | | - | @Callable(aI) |
---|
496 | | - | func calcGwxParamsREADONLY (cf,cg,ch) = { |
---|
497 | | - | let ci = (cg + ch) |
---|
498 | | - | let cj = -(fraction(cf, b, ch)) |
---|
499 | | - | let ck = (fraction(cf, b, ch) * ci) |
---|
500 | | - | $Tuple2(nil, [cj, ck, bk()]) |
---|
501 | | - | } |
---|
502 | | - | |
---|
503 | | - | |
---|
504 | | - | |
---|
505 | | - | @Callable(aI) |
---|
506 | | - | func calcGwxAmountStartREADONLY (cl,cm,cn) = { |
---|
507 | | - | let co = fraction(cm, c, cn) |
---|
508 | | - | let bp = fraction(cl, co, c) |
---|
509 | | - | $Tuple2(nil, [bp]) |
---|
510 | | - | } |
---|
511 | | - | |
---|
512 | | - | |
---|
513 | | - | |
---|
514 | | - | @Callable(aI) |
---|
515 | | - | func onEmissionForGwxStart () = if ((aI.caller != t)) |
---|
516 | | - | then throw("permissions denied") |
---|
517 | | - | else [IntegerEntry(ac(), height)] |
---|
518 | | - | |
---|
519 | | - | |
---|
520 | | - | |
---|
521 | | - | @Callable(aI) |
---|
522 | | - | func latestPeriodEmissionRewardsREADONLY (bW) = { |
---|
523 | | - | let aq = bk() |
---|
524 | | - | $Tuple2(nil, [g(ar(aq))]) |
---|
525 | | - | } |
---|
526 | | - | |
---|
527 | | - | |
---|
528 | | - | |
---|
529 | | - | @Callable(aI) |
---|
530 | | - | func calcD (cp,cq,cr,cs,ct) = { |
---|
531 | | - | let cu = toBigInt(2) |
---|
532 | | - | let cv = parseBigIntValue(cs) |
---|
533 | | - | let cw = parseBigIntValue(ct) |
---|
534 | | - | let cx = parseBigIntValue(cp) |
---|
535 | | - | let cy = parseBigIntValue(cq) |
---|
536 | | - | let cz = (parseBigIntValue(cr) * cv) |
---|
537 | | - | let aP = (cx + cy) |
---|
538 | | - | if ((aP == d)) |
---|
539 | | - | then $Tuple2(nil, toString(d)) |
---|
540 | | - | else { |
---|
541 | | - | let cA = (cz * cu) |
---|
542 | | - | let cB = [0, 1, 2, 3, 4, 5, 6] |
---|
543 | | - | func cC (cD,cE) = { |
---|
544 | | - | let cF = cD |
---|
545 | | - | let cG = cF._1 |
---|
546 | | - | let cH = cF._2 |
---|
547 | | - | let cI = cF._3 |
---|
548 | | - | if ((cI != unit)) |
---|
549 | | - | then cD |
---|
550 | | - | else { |
---|
551 | | - | let cJ = (((cG * cG) * cG) / (((cx * cy) * cu) * cu)) |
---|
552 | | - | let cK = (((((cA * aP) / cv) + (cJ * cu)) * cG) / ((((cA - cv) * cG) / cv) + ((cu + toBigInt(1)) * cJ))) |
---|
553 | | - | let cL = n((cK - value(cG))) |
---|
554 | | - | if ((cw >= cL)) |
---|
555 | | - | then $Tuple3(cK, cG, cE) |
---|
556 | | - | else $Tuple3(cK, cG, unit) |
---|
557 | | - | } |
---|
558 | | - | } |
---|
559 | | - | |
---|
560 | | - | let cM = { |
---|
561 | | - | let cN = cB |
---|
562 | | - | let cO = size(cN) |
---|
563 | | - | let cP = $Tuple3(aP, unit, unit) |
---|
564 | | - | func cQ (cR,cS) = if ((cS >= cO)) |
---|
565 | | - | then cR |
---|
566 | | - | else cC(cR, cN[cS]) |
---|
567 | | - | |
---|
568 | | - | func cT (cR,cS) = if ((cS >= cO)) |
---|
569 | | - | then cR |
---|
570 | | - | else throw("List size exceeds 7") |
---|
571 | | - | |
---|
572 | | - | cT(cQ(cQ(cQ(cQ(cQ(cQ(cQ(cP, 0), 1), 2), 3), 4), 5), 6), 7) |
---|
573 | | - | } |
---|
574 | | - | let cK = cM._1 |
---|
575 | | - | let cH = cM._2 |
---|
576 | | - | let cI = cM._3 |
---|
577 | | - | if ((cI != unit)) |
---|
578 | | - | then $Tuple2(nil, toString(cK)) |
---|
579 | | - | else { |
---|
580 | | - | let cL = n((cK - value(cH))) |
---|
581 | | - | throw(("D calculation error, dDiff = " + toString(cL))) |
---|
582 | | - | } |
---|
583 | | - | } |
---|
584 | | - | } |
---|
585 | | - | |
---|
586 | | - | |
---|
587 | | - | |
---|
588 | | - | @Callable(aI) |
---|
589 | | - | func setManager (cU) = { |
---|
590 | | - | let cV = aR(aI) |
---|
591 | | - | if ((cV == cV)) |
---|
592 | | - | then { |
---|
593 | | - | let cW = fromBase58String(cU) |
---|
594 | | - | if ((cW == cW)) |
---|
595 | | - | then [StringEntry(aM(), cU)] |
---|
596 | | - | else throw("Strict value is not equal to itself.") |
---|
597 | | - | } |
---|
598 | | - | else throw("Strict value is not equal to itself.") |
---|
599 | | - | } |
---|
600 | | - | |
---|
601 | | - | |
---|
602 | | - | |
---|
603 | | - | @Callable(aI) |
---|
604 | | - | func confirmManager () = { |
---|
605 | | - | let cX = aQ() |
---|
606 | | - | let cY = if (isDefined(cX)) |
---|
607 | | - | then true |
---|
608 | | - | else throw("No pending manager") |
---|
609 | | - | if ((cY == cY)) |
---|
610 | | - | then { |
---|
611 | | - | let cZ = if ((aI.callerPublicKey == value(cX))) |
---|
612 | | - | then true |
---|
613 | | - | else throw("You are not pending manager") |
---|
614 | | - | if ((cZ == cZ)) |
---|
615 | | - | then [StringEntry(aL(), toBase58String(value(cX))), DeleteEntry(aM())] |
---|
616 | | - | else throw("Strict value is not equal to itself.") |
---|
617 | | - | } |
---|
618 | | - | else throw("Strict value is not equal to itself.") |
---|
619 | | - | } |
---|
620 | | - | |
---|
621 | | - | |
---|
622 | | - | @Verifier(da) |
---|
623 | | - | func db () = { |
---|
624 | | - | let dc = { |
---|
625 | | - | let aO = aN() |
---|
626 | | - | if ($isInstanceOf(aO, "ByteVector")) |
---|
627 | | - | then { |
---|
628 | | - | let aT = aO |
---|
629 | | - | aT |
---|
630 | | - | } |
---|
631 | | - | else if ($isInstanceOf(aO, "Unit")) |
---|
632 | | - | then da.senderPublicKey |
---|
633 | | - | else throw("Match error") |
---|
634 | | - | } |
---|
635 | | - | sigVerify(da.bodyBytes, da.proofs[0], dc) |
---|
636 | | - | } |
---|
637 | | - | |
---|
| 1 | + | # no script |
---|