1 | | - | {-# STDLIB_VERSION 6 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let a = "__" |
---|
5 | | - | |
---|
6 | | - | let b = 8 |
---|
7 | | - | |
---|
8 | | - | let c = 100000000 |
---|
9 | | - | |
---|
10 | | - | let d = c |
---|
11 | | - | |
---|
12 | | - | func e (f) = makeString(["boosting.ride:", f], " ") |
---|
13 | | - | |
---|
14 | | - | |
---|
15 | | - | func g (f) = throw(e(f)) |
---|
16 | | - | |
---|
17 | | - | |
---|
18 | | - | func h (i,j) = valueOrErrorMessage(getString(i, j), (("mandatory this." + j) + " is not defined")) |
---|
19 | | - | |
---|
20 | | - | |
---|
21 | | - | func k (i,j) = valueOrElse(getInteger(i, j), 0) |
---|
22 | | - | |
---|
23 | | - | |
---|
24 | | - | func l (i,j,m) = valueOrElse(getInteger(i, j), m) |
---|
25 | | - | |
---|
26 | | - | |
---|
27 | | - | func n (i,j) = valueOrErrorMessage(getInteger(i, j), (("mandatory this." + j) + " is not defined")) |
---|
28 | | - | |
---|
29 | | - | |
---|
30 | | - | func o (p) = if ((0 > p)) |
---|
31 | | - | then -(p) |
---|
32 | | - | else p |
---|
33 | | - | |
---|
34 | | - | |
---|
35 | | - | func q (p) = { |
---|
36 | | - | let r = p |
---|
37 | | - | if ($isInstanceOf(r, "List[Any]")) |
---|
38 | | - | then { |
---|
39 | | - | let s = r |
---|
40 | | - | s |
---|
41 | | - | } |
---|
42 | | - | else throw("fail to cast into List[Any]") |
---|
43 | | - | } |
---|
44 | | - | |
---|
45 | | - | |
---|
46 | | - | func t (p) = { |
---|
47 | | - | let r = p |
---|
48 | | - | if ($isInstanceOf(r, "Int")) |
---|
49 | | - | then { |
---|
50 | | - | let u = r |
---|
51 | | - | u |
---|
52 | | - | } |
---|
53 | | - | else throw("fail to cast into Int") |
---|
54 | | - | } |
---|
55 | | - | |
---|
56 | | - | |
---|
57 | | - | func v () = makeString(["%s%s", "config", "referralsContractAddress"], a) |
---|
58 | | - | |
---|
59 | | - | |
---|
60 | | - | let w = addressFromStringValue(h(this, v())) |
---|
61 | | - | |
---|
62 | | - | let x = makeString(["%s%s", "referral", "programName"], a) |
---|
63 | | - | |
---|
64 | | - | let y = "wxlock" |
---|
65 | | - | |
---|
66 | | - | let z = valueOrElse(getString(this, x), y) |
---|
67 | | - | |
---|
68 | | - | func A () = "%s%s__config__factoryAddress" |
---|
69 | | - | |
---|
70 | | - | |
---|
71 | | - | let B = 1 |
---|
72 | | - | |
---|
73 | | - | let C = 2 |
---|
74 | | - | |
---|
75 | | - | let D = 3 |
---|
76 | | - | |
---|
77 | | - | let E = 4 |
---|
78 | | - | |
---|
79 | | - | let F = 5 |
---|
80 | | - | |
---|
81 | | - | let G = 6 |
---|
82 | | - | |
---|
83 | | - | let H = 7 |
---|
84 | | - | |
---|
85 | | - | let I = 8 |
---|
86 | | - | |
---|
87 | | - | let J = 9 |
---|
88 | | - | |
---|
89 | | - | let K = 10 |
---|
90 | | - | |
---|
91 | | - | let L = 11 |
---|
92 | | - | |
---|
93 | | - | func M () = "%s__factoryConfig" |
---|
94 | | - | |
---|
95 | | - | |
---|
96 | | - | func N (O) = makeString(["%s%s%s", O, "mappings__lpAsset2PoolContract"], a) |
---|
97 | | - | |
---|
98 | | - | |
---|
99 | | - | func P () = "%s__lpTokensList" |
---|
100 | | - | |
---|
101 | | - | |
---|
102 | | - | func Q (O) = makeString(["%s%s%s", O, "mappings__lpAsset2PoolContract"], a) |
---|
103 | | - | |
---|
104 | | - | |
---|
105 | | - | func R (S) = makeString(["%s%s", "poolWeight", S], a) |
---|
106 | | - | |
---|
107 | | - | |
---|
108 | | - | func T (U,V) = ((("%s%s__poolWeight__" + U) + "__") + toString(V)) |
---|
109 | | - | |
---|
110 | | - | |
---|
111 | | - | func W () = addressFromStringValue(h(this, A())) |
---|
112 | | - | |
---|
113 | | - | |
---|
114 | | - | func X () = split(valueOrElse(getString(W(), P()), ""), a) |
---|
115 | | - | |
---|
116 | | - | |
---|
117 | | - | func Y (Z) = split(h(Z, M()), a) |
---|
118 | | - | |
---|
119 | | - | |
---|
120 | | - | func aa (ab) = addressFromStringValue(ab[C]) |
---|
121 | | - | |
---|
122 | | - | |
---|
123 | | - | func ac (ab) = addressFromStringValue(ab[F]) |
---|
124 | | - | |
---|
125 | | - | |
---|
126 | | - | func ad (ab) = addressFromStringValue(ab[B]) |
---|
127 | | - | |
---|
128 | | - | |
---|
129 | | - | func ae (ab) = addressFromStringValue(ab[K]) |
---|
130 | | - | |
---|
131 | | - | |
---|
132 | | - | func af () = "%s__managerPublicKey" |
---|
133 | | - | |
---|
134 | | - | |
---|
135 | | - | func ag () = "%s__pendingManagerPublicKey" |
---|
136 | | - | |
---|
137 | | - | |
---|
138 | | - | func ah () = "%s%s__ratePerBlock__current" |
---|
139 | | - | |
---|
140 | | - | |
---|
141 | | - | func ai () = "%s%s__ratePerBlockMax__current" |
---|
142 | | - | |
---|
143 | | - | |
---|
144 | | - | func aj () = "%s%s__emission__startBlock" |
---|
145 | | - | |
---|
146 | | - | |
---|
147 | | - | func ak () = "%s%s__emission__duration" |
---|
148 | | - | |
---|
149 | | - | |
---|
150 | | - | func al () = "%s%s__emission__endBlock" |
---|
151 | | - | |
---|
152 | | - | |
---|
153 | | - | func am () = "%s__nextPeriod" |
---|
154 | | - | |
---|
155 | | - | |
---|
156 | | - | func an () = "%s%s__gwxRewardEmissionPart__startHeight" |
---|
157 | | - | |
---|
158 | | - | |
---|
159 | | - | let ao = 1 |
---|
160 | | - | |
---|
161 | | - | let ap = 2 |
---|
162 | | - | |
---|
163 | | - | let aq = 3 |
---|
164 | | - | |
---|
165 | | - | let ar = 4 |
---|
166 | | - | |
---|
167 | | - | let as = 5 |
---|
168 | | - | |
---|
169 | | - | func at () = "%s__config" |
---|
170 | | - | |
---|
171 | | - | |
---|
172 | | - | func au () = split(h(this, at()), a) |
---|
173 | | - | |
---|
174 | | - | |
---|
175 | | - | let av = addressFromStringValue(au()[as]) |
---|
176 | | - | |
---|
177 | | - | func aw (ax,ay,az,aA,av) = makeString(["%s%d%d%d", ax, ay, az, aA, av], a) |
---|
178 | | - | |
---|
179 | | - | |
---|
180 | | - | func aB (ax,ay,az,aA,av) = aw(ax, toString(ay), toString(az), toString(aA), av) |
---|
181 | | - | |
---|
182 | | - | |
---|
183 | | - | func aC () = { |
---|
184 | | - | let r = getString(af()) |
---|
185 | | - | if ($isInstanceOf(r, "String")) |
---|
186 | | - | then { |
---|
187 | | - | let aD = r |
---|
188 | | - | fromBase58String(aD) |
---|
189 | | - | } |
---|
190 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
191 | | - | then unit |
---|
192 | | - | else throw("Match error") |
---|
193 | | - | } |
---|
194 | | - | |
---|
195 | | - | |
---|
196 | | - | func aE () = { |
---|
197 | | - | let r = getString(ag()) |
---|
198 | | - | if ($isInstanceOf(r, "String")) |
---|
199 | | - | then { |
---|
200 | | - | let aD = r |
---|
201 | | - | fromBase58String(aD) |
---|
202 | | - | } |
---|
203 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
204 | | - | then unit |
---|
205 | | - | else throw("Match error") |
---|
206 | | - | } |
---|
207 | | - | |
---|
208 | | - | |
---|
209 | | - | func aF (aG) = { |
---|
210 | | - | let aH = throw("Permission denied") |
---|
211 | | - | let r = aC() |
---|
212 | | - | if ($isInstanceOf(r, "ByteVector")) |
---|
213 | | - | then { |
---|
214 | | - | let aI = r |
---|
215 | | - | if ((aG.callerPublicKey == aI)) |
---|
216 | | - | then true |
---|
217 | | - | else aH |
---|
218 | | - | } |
---|
219 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
220 | | - | then if ((aG.caller == this)) |
---|
221 | | - | then true |
---|
222 | | - | else aH |
---|
223 | | - | else throw("Match error") |
---|
224 | | - | } |
---|
225 | | - | |
---|
226 | | - | |
---|
227 | | - | let aJ = 1 |
---|
228 | | - | |
---|
229 | | - | let aK = 2 |
---|
230 | | - | |
---|
231 | | - | let aL = 3 |
---|
232 | | - | |
---|
233 | | - | let aM = 4 |
---|
234 | | - | |
---|
235 | | - | let aN = 5 |
---|
236 | | - | |
---|
237 | | - | let aO = 6 |
---|
238 | | - | |
---|
239 | | - | func aP (aQ) = makeString(["%s%s__lock", aQ], a) |
---|
240 | | - | |
---|
241 | | - | |
---|
242 | | - | func aR (aQ) = split(h(this, aP(aQ)), a) |
---|
243 | | - | |
---|
244 | | - | |
---|
245 | | - | func aS (aT,aU,aV,aW,aX,aY,aZ,ba) = makeString(["%d%d%d%d%d%d%d%d", aT, aU, aV, aW, aX, aY, aZ, ba], a) |
---|
246 | | - | |
---|
247 | | - | |
---|
248 | | - | func bb (aT,aU,aV,aW,aX,aY,ba) = aS(aT, toString(aU), toString(aV), toString(aW), toString(aX), toString(aY), toString(lastBlock.timestamp), toString(ba)) |
---|
249 | | - | |
---|
250 | | - | |
---|
251 | | - | func bc () = "%s__nextUserNum" |
---|
252 | | - | |
---|
253 | | - | |
---|
254 | | - | func bd (aQ) = makeString(["%s%s%s__mapping__user2num", aQ], a) |
---|
255 | | - | |
---|
256 | | - | |
---|
257 | | - | func be (V) = makeString(["%s%s%s__mapping__num2user", V], a) |
---|
258 | | - | |
---|
259 | | - | |
---|
260 | | - | func bf (aT) = makeString(["%s%d%s__paramByUserNum", aT, "amount"], a) |
---|
261 | | - | |
---|
262 | | - | |
---|
263 | | - | func bg (aT) = makeString(["%s%d%s__paramByUserNum", aT, "start"], a) |
---|
264 | | - | |
---|
265 | | - | |
---|
266 | | - | func bh (aT) = makeString(["%s%d%s__paramByUserNum", aT, "duration"], a) |
---|
267 | | - | |
---|
268 | | - | |
---|
269 | | - | func bi (aT) = makeString(["%s%d%s__paramByUserNum", aT, "k"], a) |
---|
270 | | - | |
---|
271 | | - | |
---|
272 | | - | func bj (aT) = makeString(["%s%d%s__paramByUserNum", aT, "b"], a) |
---|
273 | | - | |
---|
274 | | - | |
---|
275 | | - | func bk (aT,bl) = makeString(["%s%d%s%d__paramByPeriod", aT, "k", bl], a) |
---|
276 | | - | |
---|
277 | | - | |
---|
278 | | - | func bm (aT,bl) = makeString(["%s%d%s%d__paramByPeriod", aT, "b", bl], a) |
---|
279 | | - | |
---|
280 | | - | |
---|
281 | | - | func bn () = "%s%s__stats__activeTotalLocked" |
---|
282 | | - | |
---|
283 | | - | |
---|
284 | | - | func bo () = "%s%s__stats__locksDurationSumInBlocks" |
---|
285 | | - | |
---|
286 | | - | |
---|
287 | | - | func bp () = "%s%s__stats__locksCount" |
---|
288 | | - | |
---|
289 | | - | |
---|
290 | | - | func bq () = "%s%s__stats__activeUsersCount" |
---|
291 | | - | |
---|
292 | | - | |
---|
293 | | - | func br (aT) = makeString(["%s%d__userBoostEmissionLastInt", aT], a) |
---|
294 | | - | |
---|
295 | | - | |
---|
296 | | - | func bs (aT,bt) = makeString(["%s%d__userBoostEmissionLastInt", aT, bt], a) |
---|
297 | | - | |
---|
298 | | - | |
---|
299 | | - | func bu (aT) = makeString(["%s%d__maxBoostInt", aT], a) |
---|
300 | | - | |
---|
301 | | - | |
---|
302 | | - | func bv () = "%s%s__maxBoostInt__total" |
---|
303 | | - | |
---|
304 | | - | |
---|
305 | | - | func bw (aT) = makeString(["%s%d__userBoostAvaliableToClaimTotal", aT], a) |
---|
306 | | - | |
---|
307 | | - | |
---|
308 | | - | func bx (aT) = makeString(["%s%d__userBoostClaimed", aT], a) |
---|
309 | | - | |
---|
310 | | - | |
---|
311 | | - | func by () = "%s%s__gwxCached__total" |
---|
312 | | - | |
---|
313 | | - | |
---|
314 | | - | func bz () = "%s__gwxCachedTotalCorrective" |
---|
315 | | - | |
---|
316 | | - | |
---|
317 | | - | let bA = W() |
---|
318 | | - | |
---|
319 | | - | let ab = Y(bA) |
---|
320 | | - | |
---|
321 | | - | let bB = ac(ab) |
---|
322 | | - | |
---|
323 | | - | let bC = ad(ab) |
---|
324 | | - | |
---|
325 | | - | let bD = ae(ab) |
---|
326 | | - | |
---|
327 | | - | let bE = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(makeString(["%s", "lpStakingPoolsContract"], a)), e("lp_staking_pools contract address is undefined"))), e("invalid lp_staking_pools contract address")) |
---|
328 | | - | |
---|
329 | | - | func bF (bG) = { |
---|
330 | | - | let bH = makeString(["%s", "votingEmissionContract"], a) |
---|
331 | | - | let bI = addressFromStringValue(getStringValue(bA, bH)) |
---|
332 | | - | let bJ = makeString(["%s", "currentEpochUi"], a) |
---|
333 | | - | let bK = getIntegerValue(bI, bJ) |
---|
334 | | - | let bL = makeString(["%s%s", "totalCachedGwxCorrection__activationEpoch"], a) |
---|
335 | | - | let bM = getInteger(this, bL) |
---|
336 | | - | let bN = valueOrElse(getInteger(this, by()), 0) |
---|
337 | | - | let bO = if (isDefined(bM)) |
---|
338 | | - | then (bK >= value(bM)) |
---|
339 | | - | else false |
---|
340 | | - | let bP = if (if (bO) |
---|
341 | | - | then bG |
---|
342 | | - | else false) |
---|
343 | | - | then valueOrElse(getInteger(this, bz()), 0) |
---|
344 | | - | else 0 |
---|
345 | | - | max([0, (bN + bP)]) |
---|
346 | | - | } |
---|
347 | | - | |
---|
348 | | - | |
---|
349 | | - | func bQ (bR,bS,aU,bT,aW,bU,bV,aG) = { |
---|
350 | | - | let bW = makeString(["%s%s%s%s__history", bR, bS, toBase58String(aG.transactionId)], a) |
---|
351 | | - | let bX = makeString(["%d%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(aU), toString(bT), toString(aW), toString(bU), toString(bV)], a) |
---|
352 | | - | StringEntry(bW, bX) |
---|
353 | | - | } |
---|
354 | | - | |
---|
355 | | - | |
---|
356 | | - | func bY (bZ,ca,cb,cc) = { |
---|
357 | | - | let cd = bo() |
---|
358 | | - | let ce = bp() |
---|
359 | | - | let cf = bq() |
---|
360 | | - | let cg = bn() |
---|
361 | | - | let ch = k(this, cd) |
---|
362 | | - | let ci = k(this, ce) |
---|
363 | | - | let cj = k(this, cf) |
---|
364 | | - | let ck = k(this, cg) |
---|
365 | | - | [IntegerEntry(cd, (ch + ca)), IntegerEntry(ce, (ci + cb)), IntegerEntry(cf, (cj + cc)), IntegerEntry(cg, (ck + bZ))] |
---|
366 | | - | } |
---|
367 | | - | |
---|
368 | | - | |
---|
369 | | - | func cl (cm,cn,co) = { |
---|
370 | | - | let cp = 1000 |
---|
371 | | - | (((cm * co) + cn) / cp) |
---|
372 | | - | } |
---|
373 | | - | |
---|
374 | | - | |
---|
375 | | - | func cq (aQ,aT,aU,aV,aW,bU,bV,bl) = { |
---|
376 | | - | let cr = bf(aT) |
---|
377 | | - | let cs = bg(aT) |
---|
378 | | - | let ct = bh(aT) |
---|
379 | | - | let cu = bi(aT) |
---|
380 | | - | let cv = bj(aT) |
---|
381 | | - | let cw = bk(aT, bl) |
---|
382 | | - | let cx = bm(aT, bl) |
---|
383 | | - | let ba = cl(bU, bV, height) |
---|
384 | | - | [IntegerEntry(cr, aU), IntegerEntry(cs, aV), IntegerEntry(ct, aW), IntegerEntry(cu, bU), IntegerEntry(cv, bV), IntegerEntry(cw, bU), IntegerEntry(cx, bV), StringEntry(aP(aQ), bb(aT, aU, aV, aW, bU, bV, ba))] |
---|
385 | | - | } |
---|
386 | | - | |
---|
387 | | - | |
---|
388 | | - | func cy (aG,cz) = if ((size(aG.payments) > 1)) |
---|
389 | | - | then throw("only one payment is allowed") |
---|
390 | | - | else if ((size(aG.payments) == 0)) |
---|
391 | | - | then 0 |
---|
392 | | - | else { |
---|
393 | | - | let cA = aG.payments[0] |
---|
394 | | - | if ((value(cA.assetId) != cz)) |
---|
395 | | - | then throw("invalid asset id in payment") |
---|
396 | | - | else cA.amount |
---|
397 | | - | } |
---|
398 | | - | |
---|
399 | | - | |
---|
400 | | - | func cB (aQ,cC) = { |
---|
401 | | - | let cD = "empty" |
---|
402 | | - | let cE = bd(aQ) |
---|
403 | | - | let aT = valueOrElse(getString(cE), cD) |
---|
404 | | - | let bU = valueOrElse(getInteger(bi(aT)), 0) |
---|
405 | | - | let bV = valueOrElse(getInteger(bj(aT)), 0) |
---|
406 | | - | let cF = cl(bU, bV, cC) |
---|
407 | | - | let ba = if ((0 > cF)) |
---|
408 | | - | then 0 |
---|
409 | | - | else cF |
---|
410 | | - | ba |
---|
411 | | - | } |
---|
412 | | - | |
---|
413 | | - | |
---|
414 | | - | func cG (aQ) = cB(aQ, height) |
---|
415 | | - | |
---|
416 | | - | |
---|
417 | | - | func cH (cI,cJ,cK) = { |
---|
418 | | - | let cD = "EMPTY" |
---|
419 | | - | let cL = valueOrElse(getString(this, aP(cJ)), cD) |
---|
420 | | - | if ((cL == cD)) |
---|
421 | | - | then $Tuple3(0, nil, "userRecord::is::empty") |
---|
422 | | - | else { |
---|
423 | | - | let cM = split(cL, a) |
---|
424 | | - | let cN = cM[aJ] |
---|
425 | | - | let cO = valueOrElse(getInteger(bD, an()), 0) |
---|
426 | | - | let cP = "empty" |
---|
427 | | - | let cQ = if ((cI != cP)) |
---|
428 | | - | then { |
---|
429 | | - | let cR = valueOrErrorMessage(getString(bA, N(cI)), ("unsupported lp asset " + cI)) |
---|
430 | | - | let cS = getIntegerValue(bA, R(cR)) |
---|
431 | | - | let cT = valueOrElse(getInteger(bA, T(cR, 0)), cS) |
---|
432 | | - | $Tuple2(cT, cS) |
---|
433 | | - | } |
---|
434 | | - | else if (cK) |
---|
435 | | - | then $Tuple2(0, 0) |
---|
436 | | - | else throw(("not readonly mode: unsupported lp asset " + cI)) |
---|
437 | | - | let cU = cQ._1 |
---|
438 | | - | let cV = cQ._2 |
---|
439 | | - | let cW = n(bB, ah()) |
---|
440 | | - | let cX = n(bB, aj()) |
---|
441 | | - | let cY = n(bB, al()) |
---|
442 | | - | let co = if ((height > cY)) |
---|
443 | | - | then cY |
---|
444 | | - | else height |
---|
445 | | - | let cZ = max([(co - cX), 0]) |
---|
446 | | - | let da = bs(cN, cI) |
---|
447 | | - | let db = br(cN) |
---|
448 | | - | let dc = valueOrElse(getInteger(this, da), k(this, db)) |
---|
449 | | - | let dd = (((cW * cZ) * 2) / 3) |
---|
450 | | - | let de = (dd - dc) |
---|
451 | | - | let df = fraction(de, 3, (2 * cW)) |
---|
452 | | - | let dg = (co - df) |
---|
453 | | - | let dh = max([(cO - dg), 0]) |
---|
454 | | - | let di = ((co - dg) - dh) |
---|
455 | | - | if (if (if ((0 > dg)) |
---|
456 | | - | then true |
---|
457 | | - | else (0 > di)) |
---|
458 | | - | then true |
---|
459 | | - | else (o(((dh + di) - df)) >= 1)) |
---|
460 | | - | then throw(((((((((((("invalid udh calc: udh=" + toString(df)) + " uLastH=") + toString(dg)) + " udh0=") + toString(dh)) + " udh1=") + toString(di)) + " lpAssetId=") + cI) + " userAddress=") + cJ)) |
---|
461 | | - | else if ((0 > de)) |
---|
462 | | - | then throw("wrong calculations") |
---|
463 | | - | else { |
---|
464 | | - | let dj = bu(cN) |
---|
465 | | - | let dk = bv() |
---|
466 | | - | let dl = k(this, dj) |
---|
467 | | - | let dm = k(this, dk) |
---|
468 | | - | let dn = bF(true) |
---|
469 | | - | let do = cG(cJ) |
---|
470 | | - | let dp = bw(cN) |
---|
471 | | - | let dq = k(this, dp) |
---|
472 | | - | let dr = if ((df == 0)) |
---|
473 | | - | then 0 |
---|
474 | | - | else fraction(de, dh, df) |
---|
475 | | - | let ds = if ((df == 0)) |
---|
476 | | - | then 0 |
---|
477 | | - | else fraction(de, di, df) |
---|
478 | | - | let dt = fraction(dr, cU, d) |
---|
479 | | - | let du = fraction(ds, cV, d) |
---|
480 | | - | let dv = if ((dn == 0)) |
---|
481 | | - | then 0 |
---|
482 | | - | else fraction(dt, do, dn) |
---|
483 | | - | let dw = if ((dn == 0)) |
---|
484 | | - | then 0 |
---|
485 | | - | else fraction(du, do, dn) |
---|
486 | | - | let dx = (dv + dw) |
---|
487 | | - | let dy = bx(cN) |
---|
488 | | - | let dz = k(this, dy) |
---|
489 | | - | let dA = (dx - dz) |
---|
490 | | - | let dB = [IntegerEntry(da, dd)] |
---|
491 | | - | let dC = makeString([toString(dc), toString(de), toString(dz), toString(dA), toString(cU), toString(cV), toString(co), toString(df), toString(dg), toString(dh), toString(di), toString(do), toString(dn)], ":") |
---|
492 | | - | $Tuple3(dx, dB, dC) |
---|
493 | | - | } |
---|
494 | | - | } |
---|
495 | | - | } |
---|
496 | | - | |
---|
497 | | - | |
---|
498 | | - | func dD (aG,aW) = { |
---|
499 | | - | let dE = au() |
---|
500 | | - | let dF = dE[ao] |
---|
501 | | - | let ax = fromBase58String(dF) |
---|
502 | | - | let ay = parseIntValue(dE[ap]) |
---|
503 | | - | let az = parseIntValue(dE[aq]) |
---|
504 | | - | let aA = parseIntValue(dE[ar]) |
---|
505 | | - | if ((size(aG.payments) != 1)) |
---|
506 | | - | then throw("invalid payment - exact one payment must be attached") |
---|
507 | | - | else { |
---|
508 | | - | let cA = aG.payments[0] |
---|
509 | | - | let dG = cA.amount |
---|
510 | | - | if ((ax != value(cA.assetId))) |
---|
511 | | - | then throw((("invalid asset is in payment - " + dF) + " is expected")) |
---|
512 | | - | else { |
---|
513 | | - | let dH = bc() |
---|
514 | | - | let cJ = toString(aG.caller) |
---|
515 | | - | let dI = isDefined(getString(bd(cJ))) |
---|
516 | | - | let cN = if (dI) |
---|
517 | | - | then value(getString(bd(cJ))) |
---|
518 | | - | else toString(n(this, dH)) |
---|
519 | | - | let aT = parseIntValue(cN) |
---|
520 | | - | let bT = height |
---|
521 | | - | let cs = bg(cN) |
---|
522 | | - | let ct = bh(cN) |
---|
523 | | - | let cr = bf(cN) |
---|
524 | | - | if (if ((ay > dG)) |
---|
525 | | - | then (aG.caller != bE) |
---|
526 | | - | else false) |
---|
527 | | - | then throw(("amount is less then minLockAmount=" + toString(ay))) |
---|
528 | | - | else if ((az > aW)) |
---|
529 | | - | then throw(("passed duration is less then minLockDuration=" + toString(az))) |
---|
530 | | - | else if ((aW > aA)) |
---|
531 | | - | then throw(("passed duration is greater then maxLockDuration=" + toString(aA))) |
---|
532 | | - | else if (if (dI) |
---|
533 | | - | then ((n(this, cs) + n(this, ct)) >= bT) |
---|
534 | | - | else false) |
---|
535 | | - | then throw("there is an active lock - consider to use increaseLock") |
---|
536 | | - | else if ((k(this, cr) > 0)) |
---|
537 | | - | then throw(("there are locked WXs - consider to use increaseLock " + cr)) |
---|
538 | | - | else { |
---|
539 | | - | let dJ = fraction(aW, c, aA) |
---|
540 | | - | let dK = fraction(dG, dJ, c) |
---|
541 | | - | let dL = q(invoke(av, "calcGwxParamsREADONLY", [dK, bT, aW], nil)) |
---|
542 | | - | let bU = t(dL[0]) |
---|
543 | | - | let bV = t(dL[1]) |
---|
544 | | - | let bl = toString(t(dL[2])) |
---|
545 | | - | let cW = n(bB, ah()) |
---|
546 | | - | let cX = n(bB, aj()) |
---|
547 | | - | let cY = n(bB, al()) |
---|
548 | | - | let co = if ((height > cY)) |
---|
549 | | - | then cY |
---|
550 | | - | else height |
---|
551 | | - | let cZ = max([(co - cX), 0]) |
---|
552 | | - | let db = br(cN) |
---|
553 | | - | let dd = (((cW * cZ) * 2) / 3) |
---|
554 | | - | let dj = bu(cN) |
---|
555 | | - | let dk = bv() |
---|
556 | | - | let dl = ((dK * aW) / 2) |
---|
557 | | - | let dm = k(this, dk) |
---|
558 | | - | let bN = bF(false) |
---|
559 | | - | let dM = if (dI) |
---|
560 | | - | then nil |
---|
561 | | - | else [IntegerEntry(dH, (aT + 1)), StringEntry(bd(cJ), cN), StringEntry(be(cN), cJ)] |
---|
562 | | - | $Tuple2(((((dM ++ cq(cJ, cN, dG, bT, aW, bU, bV, bl)) ++ bY(dG, aW, 1, if (dI) |
---|
563 | | - | then 0 |
---|
564 | | - | else 1)) :+ bQ("lock", cJ, dG, bT, aW, bU, bV, aG)) ++ [IntegerEntry(db, dd), IntegerEntry(by(), (bN + dK))]), dK) |
---|
565 | | - | } |
---|
566 | | - | } |
---|
567 | | - | } |
---|
568 | | - | } |
---|
569 | | - | |
---|
570 | | - | |
---|
571 | | - | @Callable(aG) |
---|
572 | | - | func constructor (dN,dO,ay,dP,dQ,av) = { |
---|
573 | | - | let dR = aF(aG) |
---|
574 | | - | if ((dR == dR)) |
---|
575 | | - | then ([IntegerEntry(bc(), 0), StringEntry(at(), aB(dO, ay, dP, dQ, av)), StringEntry(A(), dN)] ++ bY(0, 0, 0, 0)) |
---|
576 | | - | else throw("Strict value is not equal to itself.") |
---|
577 | | - | } |
---|
578 | | - | |
---|
579 | | - | |
---|
580 | | - | |
---|
581 | | - | @Callable(aG) |
---|
582 | | - | func lockRef (aW,dS,dT) = { |
---|
583 | | - | let dU = dD(aG, aW) |
---|
584 | | - | let dV = dU._1 |
---|
585 | | - | let dK = dU._2 |
---|
586 | | - | let dW = toString(aG.caller) |
---|
587 | | - | let dX = if (if ((dS == "")) |
---|
588 | | - | then true |
---|
589 | | - | else (dT == base58'')) |
---|
590 | | - | then unit |
---|
591 | | - | else invoke(w, "createPair", [z, dS, dW, dT], nil) |
---|
592 | | - | if ((dX == dX)) |
---|
593 | | - | then { |
---|
594 | | - | let dY = invoke(av, "updateReferralActivity", [toString(aG.caller), dK], nil) |
---|
595 | | - | if ((dY == dY)) |
---|
596 | | - | then $Tuple2(dV, unit) |
---|
597 | | - | else throw("Strict value is not equal to itself.") |
---|
598 | | - | } |
---|
599 | | - | else throw("Strict value is not equal to itself.") |
---|
600 | | - | } |
---|
601 | | - | |
---|
602 | | - | |
---|
603 | | - | |
---|
604 | | - | @Callable(aG) |
---|
605 | | - | func lock (aW) = { |
---|
606 | | - | let dZ = dD(aG, aW) |
---|
607 | | - | let dV = dZ._1 |
---|
608 | | - | let dK = dZ._2 |
---|
609 | | - | let dY = invoke(av, "updateReferralActivity", [toString(aG.caller), dK], nil) |
---|
610 | | - | if ((dY == dY)) |
---|
611 | | - | then $Tuple2(dV, unit) |
---|
612 | | - | else throw("Strict value is not equal to itself.") |
---|
613 | | - | } |
---|
614 | | - | |
---|
615 | | - | |
---|
616 | | - | |
---|
617 | | - | @Callable(aG) |
---|
618 | | - | func increaseLock (ea) = { |
---|
619 | | - | let dE = au() |
---|
620 | | - | let dF = dE[ao] |
---|
621 | | - | let ax = fromBase58String(dF) |
---|
622 | | - | let az = parseIntValue(dE[aq]) |
---|
623 | | - | let aA = parseIntValue(dE[ar]) |
---|
624 | | - | let dG = cy(aG, ax) |
---|
625 | | - | let cJ = toString(aG.caller) |
---|
626 | | - | let cM = aR(cJ) |
---|
627 | | - | let cN = cM[aJ] |
---|
628 | | - | let eb = parseIntValue(cM[aK]) |
---|
629 | | - | let bT = parseIntValue(cM[aL]) |
---|
630 | | - | let ec = parseIntValue(cM[aM]) |
---|
631 | | - | let ed = (bT + ec) |
---|
632 | | - | let ee = max([(ed - height), 0]) |
---|
633 | | - | let ef = (eb + dG) |
---|
634 | | - | let eg = (ee + ea) |
---|
635 | | - | if ((0 > ea)) |
---|
636 | | - | then throw("duration is less then zero") |
---|
637 | | - | else if ((az > eg)) |
---|
638 | | - | then throw(("lockDurationNew is less then minLockDuration=" + toString(az))) |
---|
639 | | - | else if ((eg > aA)) |
---|
640 | | - | then throw(("deltaDuration + existedLockDuration is greater then maxLockDuration=" + toString(aA))) |
---|
641 | | - | else { |
---|
642 | | - | let dJ = fraction(eg, c, aA) |
---|
643 | | - | let dK = fraction(ef, dJ, c) |
---|
644 | | - | let dY = invoke(av, "updateReferralActivity", [toString(aG.caller), dK], nil) |
---|
645 | | - | if ((dY == dY)) |
---|
646 | | - | then { |
---|
647 | | - | let eh = height |
---|
648 | | - | let dL = q(invoke(av, "calcGwxParamsREADONLY", [dK, eh, eg], nil)) |
---|
649 | | - | let bU = t(dL[0]) |
---|
650 | | - | let bV = t(dL[1]) |
---|
651 | | - | let bl = toString(t(dL[2])) |
---|
652 | | - | let cW = n(bB, ah()) |
---|
653 | | - | let cX = n(bB, aj()) |
---|
654 | | - | let cY = n(bB, al()) |
---|
655 | | - | let co = if ((height > cY)) |
---|
656 | | - | then cY |
---|
657 | | - | else height |
---|
658 | | - | let cZ = max([(co - cX), 0]) |
---|
659 | | - | let db = br(cN) |
---|
660 | | - | let dc = k(this, db) |
---|
661 | | - | let dd = (((cW * cZ) * 2) / 3) |
---|
662 | | - | let de = (dd - dc) |
---|
663 | | - | if ((0 > de)) |
---|
664 | | - | then throw("wrong calculations") |
---|
665 | | - | else { |
---|
666 | | - | let dj = bu(cN) |
---|
667 | | - | let dk = bv() |
---|
668 | | - | let dl = k(this, dj) |
---|
669 | | - | let dm = k(this, dk) |
---|
670 | | - | let ei = cG(cJ) |
---|
671 | | - | let ej = (dK - ei) |
---|
672 | | - | if ((0 > ej)) |
---|
673 | | - | then throw(("gwxDiff is less then 0: " + toString(ej))) |
---|
674 | | - | else { |
---|
675 | | - | let bN = bF(false) |
---|
676 | | - | let dn = bF(true) |
---|
677 | | - | let dp = bw(cN) |
---|
678 | | - | let dq = k(this, dp) |
---|
679 | | - | let dx = fraction(de, ei, dn) |
---|
680 | | - | let ek = ((dK * eg) / 2) |
---|
681 | | - | let el = ((ei * ee) / 2) |
---|
682 | | - | let em = (ek - el) |
---|
683 | | - | (((cq(cJ, cN, ef, eh, eg, bU, bV, bl) ++ bY(dG, ea, 0, 0)) :+ bQ("lock", cJ, dG, bT, eg, bU, bV, aG)) ++ [IntegerEntry(by(), (bN + ej))]) |
---|
684 | | - | } |
---|
685 | | - | } |
---|
686 | | - | } |
---|
687 | | - | else throw("Strict value is not equal to itself.") |
---|
688 | | - | } |
---|
689 | | - | } |
---|
690 | | - | |
---|
691 | | - | |
---|
692 | | - | |
---|
693 | | - | @Callable(aG) |
---|
694 | | - | func claimWxBoost (cI,cJ) = if ((bC != aG.caller)) |
---|
695 | | - | then throw("permissions denied") |
---|
696 | | - | else { |
---|
697 | | - | let en = cH(cI, cJ, false) |
---|
698 | | - | let dA = en._1 |
---|
699 | | - | let dB = en._2 |
---|
700 | | - | let dC = en._3 |
---|
701 | | - | $Tuple2(dB, [dA]) |
---|
702 | | - | } |
---|
703 | | - | |
---|
704 | | - | |
---|
705 | | - | |
---|
706 | | - | @Callable(aG) |
---|
707 | | - | func claimWxBoostREADONLY (cI,cJ) = { |
---|
708 | | - | let eo = cH(cI, cJ, true) |
---|
709 | | - | let dA = eo._1 |
---|
710 | | - | let dB = eo._2 |
---|
711 | | - | let dC = eo._3 |
---|
712 | | - | $Tuple2(nil, [dA, dC]) |
---|
713 | | - | } |
---|
714 | | - | |
---|
715 | | - | |
---|
716 | | - | |
---|
717 | | - | @Callable(aG) |
---|
718 | | - | func unlock (aQ) = { |
---|
719 | | - | let cM = aR(aQ) |
---|
720 | | - | let cN = cM[aJ] |
---|
721 | | - | let eb = parseIntValue(cM[aK]) |
---|
722 | | - | let bT = parseIntValue(cM[aL]) |
---|
723 | | - | let ec = parseIntValue(cM[aM]) |
---|
724 | | - | let ed = (bT + ec) |
---|
725 | | - | let dE = au() |
---|
726 | | - | let ax = fromBase58String(dE[ao]) |
---|
727 | | - | if ((ed >= height)) |
---|
728 | | - | then throw((("wait " + toString(ed)) + " to unlock")) |
---|
729 | | - | else if ((0 >= eb)) |
---|
730 | | - | then throw("nothing to unlock") |
---|
731 | | - | else { |
---|
732 | | - | let bl = valueOrElse(getInteger(av, am()), 0) |
---|
733 | | - | (((cq(aQ, cN, 0, bT, ec, 0, 0, toString(bl)) ++ bY(-(eb), 0, 0, -1)) :+ bQ("unlock", aQ, eb, bT, ec, 0, 0, aG)) :+ ScriptTransfer(addressFromStringValue(aQ), eb, ax)) |
---|
734 | | - | } |
---|
735 | | - | } |
---|
736 | | - | |
---|
737 | | - | |
---|
738 | | - | |
---|
739 | | - | @Callable(aG) |
---|
740 | | - | func gwxUserInfoREADONLY (aQ) = { |
---|
741 | | - | let ba = cG(aQ) |
---|
742 | | - | $Tuple2(nil, [ba]) |
---|
743 | | - | } |
---|
744 | | - | |
---|
745 | | - | |
---|
746 | | - | |
---|
747 | | - | @Callable(aG) |
---|
748 | | - | func userMaxDurationREADONLY (cJ) = { |
---|
749 | | - | let dE = au() |
---|
750 | | - | let aA = parseIntValue(dE[ar]) |
---|
751 | | - | let ep = getString(this, aP(cJ)) |
---|
752 | | - | if ((ep == unit)) |
---|
753 | | - | then $Tuple2(nil, $Tuple2("lock", aA)) |
---|
754 | | - | else { |
---|
755 | | - | let cM = split(value(ep), a) |
---|
756 | | - | let bT = parseIntValue(cM[aL]) |
---|
757 | | - | let ec = parseIntValue(cM[aM]) |
---|
758 | | - | let ed = (bT + ec) |
---|
759 | | - | let ee = max([(ed - height), 0]) |
---|
760 | | - | let eq = (aA - ee) |
---|
761 | | - | $Tuple2(nil, $Tuple2("increaseLock", eq)) |
---|
762 | | - | } |
---|
763 | | - | } |
---|
764 | | - | |
---|
765 | | - | |
---|
766 | | - | |
---|
767 | | - | @Callable(aG) |
---|
768 | | - | func getUserGwxAmountAtHeightREADONLY (aQ,cC) = { |
---|
769 | | - | let ba = cB(aQ, cC) |
---|
770 | | - | $Tuple2(nil, ba) |
---|
771 | | - | } |
---|
772 | | - | |
---|
773 | | - | |
---|
774 | | - | |
---|
775 | | - | @Callable(aG) |
---|
776 | | - | func getTotalCachedGwxREADONLY () = $Tuple2(nil, bF(true)) |
---|
777 | | - | |
---|
778 | | - | |
---|
779 | | - | |
---|
780 | | - | @Callable(aG) |
---|
781 | | - | func setManager (er) = { |
---|
782 | | - | let dR = aF(aG) |
---|
783 | | - | if ((dR == dR)) |
---|
784 | | - | then { |
---|
785 | | - | let es = fromBase58String(er) |
---|
786 | | - | if ((es == es)) |
---|
787 | | - | then [StringEntry(ag(), er)] |
---|
788 | | - | else throw("Strict value is not equal to itself.") |
---|
789 | | - | } |
---|
790 | | - | else throw("Strict value is not equal to itself.") |
---|
791 | | - | } |
---|
792 | | - | |
---|
793 | | - | |
---|
794 | | - | |
---|
795 | | - | @Callable(aG) |
---|
796 | | - | func confirmManager () = { |
---|
797 | | - | let et = aE() |
---|
798 | | - | let eu = if (isDefined(et)) |
---|
799 | | - | then true |
---|
800 | | - | else throw("No pending manager") |
---|
801 | | - | if ((eu == eu)) |
---|
802 | | - | then { |
---|
803 | | - | let ev = if ((aG.callerPublicKey == value(et))) |
---|
804 | | - | then true |
---|
805 | | - | else throw("You are not pending manager") |
---|
806 | | - | if ((ev == ev)) |
---|
807 | | - | then [StringEntry(af(), toBase58String(value(et))), DeleteEntry(ag())] |
---|
808 | | - | else throw("Strict value is not equal to itself.") |
---|
809 | | - | } |
---|
810 | | - | else throw("Strict value is not equal to itself.") |
---|
811 | | - | } |
---|
812 | | - | |
---|
813 | | - | |
---|
814 | | - | @Verifier(ew) |
---|
815 | | - | func ex () = { |
---|
816 | | - | let ey = { |
---|
817 | | - | let r = aC() |
---|
818 | | - | if ($isInstanceOf(r, "ByteVector")) |
---|
819 | | - | then { |
---|
820 | | - | let aI = r |
---|
821 | | - | aI |
---|
822 | | - | } |
---|
823 | | - | else if ($isInstanceOf(r, "Unit")) |
---|
824 | | - | then ew.senderPublicKey |
---|
825 | | - | else throw("Match error") |
---|
826 | | - | } |
---|
827 | | - | sigVerify(ew.bodyBytes, ew.proofs[0], ey) |
---|
828 | | - | } |
---|
829 | | - | |
---|
| 1 | + | # no script |
---|