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