46 | | - | let n = 1 |
---|
47 | | - | |
---|
48 | | - | let o = 2 |
---|
49 | | - | |
---|
50 | | - | let p = 4 |
---|
51 | | - | |
---|
52 | | - | let q = 5 |
---|
53 | | - | |
---|
54 | | - | func r () = "%s__restConfig" |
---|
55 | | - | |
---|
56 | | - | |
---|
57 | | - | func s () = "%s__restAddr" |
---|
58 | | - | |
---|
59 | | - | |
---|
60 | | - | func t (u) = split_4C(k(u, r()), a) |
---|
61 | | - | |
---|
62 | | - | |
---|
63 | | - | func v (w,x) = valueOrErrorMessage(addressFromString(w[x]), ("Rest cfg doesn't contain address at index " + toString(x))) |
---|
64 | | - | |
---|
65 | | - | |
---|
66 | | - | let y = addressFromStringValue(valueOrElse(getString(this, s()), i)) |
---|
67 | | - | |
---|
68 | | - | let w = t(y) |
---|
69 | | - | |
---|
70 | | - | let z = v(w, n) |
---|
71 | | - | |
---|
72 | | - | let A = v(w, o) |
---|
73 | | - | |
---|
74 | | - | let B = v(w, p) |
---|
75 | | - | |
---|
76 | | - | let C = v(w, q) |
---|
77 | | - | |
---|
78 | | - | let D = "wlg_assetId" |
---|
79 | | - | |
---|
80 | | - | let E = valueOrErrorMessage(getBinary(A, D), "WLGOLD is not issued yet") |
---|
81 | | - | |
---|
82 | | - | func F (G) = { |
---|
83 | | - | let h = G |
---|
84 | | - | if ($isInstanceOf(h, "Int")) |
---|
85 | | - | then { |
---|
86 | | - | let H = h |
---|
87 | | - | H |
---|
88 | | - | } |
---|
89 | | - | else throw("fail to cast into Int") |
---|
90 | | - | } |
---|
91 | | - | |
---|
92 | | - | |
---|
93 | | - | let I = 0 |
---|
94 | | - | |
---|
95 | | - | let J = 1 |
---|
96 | | - | |
---|
97 | | - | let K = 2 |
---|
98 | | - | |
---|
99 | | - | let L = 6 |
---|
100 | | - | |
---|
101 | | - | let M = 9 |
---|
102 | | - | |
---|
103 | | - | let N = 10 |
---|
104 | | - | |
---|
105 | | - | let O = 13 |
---|
106 | | - | |
---|
107 | | - | let P = 14 |
---|
108 | | - | |
---|
109 | | - | let Q = 17 |
---|
110 | | - | |
---|
111 | | - | let R = 18 |
---|
112 | | - | |
---|
113 | | - | let S = 21 |
---|
114 | | - | |
---|
115 | | - | let T = 24 |
---|
116 | | - | |
---|
117 | | - | let U = 26 |
---|
118 | | - | |
---|
119 | | - | let V = 27 |
---|
120 | | - | |
---|
121 | | - | let W = 28 |
---|
122 | | - | |
---|
123 | | - | func X (Y,Z) = { |
---|
124 | | - | let aa = pow(10, 0, Z, 0, 0, DOWN) |
---|
125 | | - | let ab = toString((Y % aa)) |
---|
126 | | - | let ac = drop(toString(aa), (1 + size(ab))) |
---|
127 | | - | (((toString((Y / aa)) + ".") + ac) + ab) |
---|
128 | | - | } |
---|
129 | | - | |
---|
130 | | - | |
---|
131 | | - | let ad = 1000000 |
---|
132 | | - | |
---|
133 | | - | let ae = 100000000 |
---|
134 | | - | |
---|
135 | | - | let af = 100000000000000 |
---|
136 | | - | |
---|
137 | | - | let ag = 100000 |
---|
138 | | - | |
---|
139 | | - | let ah = 200000 |
---|
140 | | - | |
---|
141 | | - | let ai = 100000 |
---|
142 | | - | |
---|
143 | | - | let aj = 400000 |
---|
144 | | - | |
---|
145 | | - | let ak = 31557600000 |
---|
146 | | - | |
---|
147 | | - | let al = 50000 |
---|
148 | | - | |
---|
149 | | - | let am = take(drop(this.bytes, 1), 1) |
---|
150 | | - | |
---|
151 | | - | let an = { |
---|
152 | | - | let h = am |
---|
153 | | - | if ((base58'2W' == h)) |
---|
154 | | - | then 1208630000 |
---|
155 | | - | else if ((base58'2T' == h)) |
---|
156 | | - | then 0 |
---|
157 | | - | else throw("Unknown chain") |
---|
158 | | - | } |
---|
159 | | - | |
---|
160 | | - | let ao = "marketingAddr" |
---|
161 | | - | |
---|
162 | | - | let ap = "teamAddr" |
---|
163 | | - | |
---|
164 | | - | let aq = "lastClaimedTime_marketing" |
---|
165 | | - | |
---|
166 | | - | let ar = "marketingAmountLeft" |
---|
167 | | - | |
---|
168 | | - | let as = "lastClaimedTime_team" |
---|
169 | | - | |
---|
170 | | - | let at = "teamAmountLeft" |
---|
171 | | - | |
---|
172 | | - | let au = "lastClaimedTime_activities" |
---|
173 | | - | |
---|
174 | | - | let av = "activitiesAmountLeft" |
---|
175 | | - | |
---|
176 | | - | let aw = "stakersAmountLeft" |
---|
177 | | - | |
---|
178 | | - | func ax (ay) = ("lastClaimedTimeUser_" + ay) |
---|
179 | | - | |
---|
180 | | - | |
---|
181 | | - | func az (ay) = ("lastArbTimeUser_" + ay) |
---|
182 | | - | |
---|
183 | | - | |
---|
184 | | - | func aA (aB) = fraction(af, (aj * (aB + 1)), (6 * ad)) |
---|
185 | | - | |
---|
186 | | - | |
---|
187 | | - | let aC = "wlg_issueTime" |
---|
188 | | - | |
---|
189 | | - | let aD = "wlg_issuedAmount" |
---|
190 | | - | |
---|
191 | | - | let aE = "zbill_issuedAmount" |
---|
192 | | - | |
---|
193 | | - | func aF (ay) = ("acresStakedAmountByUser_" + ay) |
---|
194 | | - | |
---|
195 | | - | |
---|
196 | | - | let aG = "acresStakedAmountTotal" |
---|
197 | | - | |
---|
198 | | - | let aH = 0 |
---|
199 | | - | |
---|
200 | | - | let aI = 1 |
---|
201 | | - | |
---|
202 | | - | let aJ = 2 |
---|
203 | | - | |
---|
204 | | - | let aK = 3 |
---|
205 | | - | |
---|
206 | | - | let aL = 4 |
---|
207 | | - | |
---|
208 | | - | func aM (aN,z) = { |
---|
209 | | - | let aO = valueOrElse(getInteger(z, aG), 0) |
---|
210 | | - | let aP = valueOrElse(getInteger(z, aF(aN)), 0) |
---|
211 | | - | [aO, aP] |
---|
212 | | - | } |
---|
213 | | - | |
---|
214 | | - | |
---|
215 | | - | let aQ = 0 |
---|
216 | | - | |
---|
217 | | - | let aR = 1 |
---|
218 | | - | |
---|
219 | | - | func aS (aT,aU,aV,aW,aX) = { |
---|
220 | | - | let aY = valueOrErrorMessage(getInteger(aU[aJ], aD), "WLGOLD is not issued yet") |
---|
221 | | - | let aZ = assetBalance(aU[aH], aV) |
---|
222 | | - | let ba = (assetBalance(aU[aJ], aV) - aW) |
---|
223 | | - | let bb = assetBalance(aU[aK], aV) |
---|
224 | | - | let bc = aU[aL] |
---|
225 | | - | let bd = (assetBalance(bc, aV) + valueOrElse(getInteger(bc, aE), 0)) |
---|
226 | | - | let be = (ba + bd) |
---|
227 | | - | let bf = valueOrErrorMessage(getBinary(aU[aJ], "wlg_assetId"), "Not initialized yet") |
---|
228 | | - | let bg = lastBlock.timestamp |
---|
229 | | - | let bh = valueOrErrorMessage(getInteger(aU[aJ], aC), "Not initialized") |
---|
230 | | - | let bi = fraction(af, ag, ad) |
---|
231 | | - | let bj = valueOrElse(getInteger(aU[aJ], ar), bi) |
---|
232 | | - | let bk = valueOrElse(getInteger(aU[aJ], aq), bh) |
---|
233 | | - | let bl = addressFromStringValue(value(getString(aU[aJ], ao))) |
---|
234 | | - | let bm = min([fraction(bi, (bg - bk), ak), bj]) |
---|
235 | | - | let bn = fraction(bm, al, ad) |
---|
236 | | - | let bo = (bm - bn) |
---|
237 | | - | let bp = assetBalance(bl, bf) |
---|
238 | | - | let bq = assetBalance(aU[aI], bf) |
---|
239 | | - | let br = fraction(af, ah, ad) |
---|
240 | | - | let bs = valueOrElse(getInteger(aU[aJ], at), br) |
---|
241 | | - | let bt = valueOrElse(getInteger(aU[aJ], as), bh) |
---|
242 | | - | let bu = addressFromStringValue(value(getString(aU[aJ], ap))) |
---|
243 | | - | let bv = min([fraction(br, (bg - bt), (3 * ak)), bs]) |
---|
244 | | - | let bw = assetBalance(bu, bf) |
---|
245 | | - | let bx = fraction(af, ai, ad) |
---|
246 | | - | let by = valueOrElse(getInteger(aU[aJ], av), bx) |
---|
247 | | - | let bz = valueOrElse(getInteger(aU[aJ], au), bh) |
---|
248 | | - | let bA = min([fraction(bx, (bg - bz), (3 * ak)), by]) |
---|
249 | | - | let bB = assetBalance(aU[aH], bf) |
---|
250 | | - | let bC = valueOrElse(getInteger(aU[aJ], ax(aT)), bh) |
---|
251 | | - | let bD = ((bC - bh) / ak) |
---|
252 | | - | let bE = min([bg, (bh + (3 * ak))]) |
---|
253 | | - | let bF = min([((bg - bh) / ak), 2]) |
---|
254 | | - | let bG = aM(aT, aU[aI]) |
---|
255 | | - | let bH = aA(bF) |
---|
256 | | - | let bI = if ((bD == bF)) |
---|
257 | | - | then { |
---|
258 | | - | let bJ = fraction(bH, (bE - bC), ak) |
---|
259 | | - | let bK = fraction(bJ, aX, ad) |
---|
260 | | - | let bL = (bC + fraction((bE - bC), aX, ad)) |
---|
261 | | - | $Tuple3(bK, bJ, bL) |
---|
262 | | - | } |
---|
263 | | - | else if ((bD == (bF - 1))) |
---|
264 | | - | then { |
---|
265 | | - | let bM = fraction(aA((bF - 1)), ((bh + (ak * bF)) - bC), ak) |
---|
266 | | - | let bJ = fraction(bH, (bE - (bh + (ak * bF))), ak) |
---|
267 | | - | let bN = (bM + bJ) |
---|
268 | | - | let bK = fraction(bN, aX, ad) |
---|
269 | | - | let bL = if ((bM >= bK)) |
---|
270 | | - | then (bC + fraction(ak, bK, aA((bF - 1)))) |
---|
271 | | - | else ((bh + (ak * bF)) + fraction(ak, (bK - bM), bH)) |
---|
272 | | - | $Tuple3(bK, bN, bL) |
---|
273 | | - | } |
---|
274 | | - | else { |
---|
275 | | - | let bO = fraction(aA((bF - 2)), ((bh + (ak * (bF - 1))) - bC), ak) |
---|
276 | | - | let bM = aA((bF - 1)) |
---|
277 | | - | let bJ = fraction(bH, (bE - (bh + (ak * bF))), ak) |
---|
278 | | - | let bN = ((bO + bM) + bJ) |
---|
279 | | - | let bK = fraction(bN, aX, ad) |
---|
280 | | - | let bL = if ((bO >= bK)) |
---|
281 | | - | then (bC + fraction(ak, bK, aA((bF - 2)))) |
---|
282 | | - | else if (((bO + bM) >= bK)) |
---|
283 | | - | then ((bh + (ak * (bF - 1))) + fraction(ak, (bK - bO), aA((bF - 1)))) |
---|
284 | | - | else ((bh + (ak * bF)) + fraction(ak, ((bK - bO) - bM), bH)) |
---|
285 | | - | $Tuple3(bK, bN, bL) |
---|
286 | | - | } |
---|
287 | | - | let bP = bI._1 |
---|
288 | | - | let bQ = bI._2 |
---|
289 | | - | let bR = bI._3 |
---|
290 | | - | let bS = valueOrElse(getInteger(aU[aJ], aw), 0) |
---|
291 | | - | let bT = fraction(bP, bG[aR], bG[aQ]) |
---|
292 | | - | let bU = fraction(bT, al, ad) |
---|
293 | | - | let bV = (bT - bU) |
---|
294 | | - | let bW = fraction(bQ, bG[aR], bG[aQ]) |
---|
295 | | - | [aY, fraction((be - an), ae, aY), be, aZ, ba, bb, bh, bk, bi, bj, bo, bp, br, bs, bv, bw, bx, by, bA, bB, bF, bS, bH, bC, bV, bd, bW, bR, (bn + bU), bq] |
---|
296 | | - | } |
---|
297 | | - | |
---|
298 | | - | |
---|
299 | | - | let bX = "profitAddr" |
---|
300 | | - | |
---|
301 | | - | let bY = "stakersAmountPaidTotal" |
---|
302 | | - | |
---|
303 | | - | func bZ (ay) = ("stakersAmountPaidUser_" + ay) |
---|
304 | | - | |
---|
305 | | - | |
---|
306 | | - | func ca () = F(reentrantInvoke(z, "saveLastTx", nil, nil)) |
---|
307 | | - | |
---|
308 | | - | |
---|
309 | | - | func cb (ay) = { |
---|
310 | | - | let cc = valueOrElse(getInteger(az(ay)), 0) |
---|
311 | | - | let bg = lastBlock.timestamp |
---|
312 | | - | if ((j > (bg - cc))) |
---|
313 | | - | then throw((("Arbitrages are possible once a " + toString((j / 60000))) + "min")) |
---|
314 | | - | else { |
---|
315 | | - | let cd = valueOrElse(getInteger(z, aF(ay)), 0) |
---|
316 | | - | cd |
---|
317 | | - | } |
---|
318 | | - | } |
---|
319 | | - | |
---|
320 | | - | |
---|
321 | | - | func ce (ay,cf) = { |
---|
322 | | - | let cg = addressFromStringValue(ay) |
---|
323 | | - | let ch = aS(ay, [y, z, A, B, C], g, 0, cf) |
---|
324 | | - | let bg = lastBlock.timestamp |
---|
325 | | - | let bh = ch[L] |
---|
326 | | - | let bj = ch[M] |
---|
327 | | - | let ci = ch[N] |
---|
328 | | - | let bs = ch[O] |
---|
329 | | - | let cj = ch[P] |
---|
330 | | - | let by = ch[Q] |
---|
331 | | - | let ck = ch[R] |
---|
332 | | - | let bP = ch[T] |
---|
333 | | - | let cl = bZ(ay) |
---|
334 | | - | let cm = ch[U] |
---|
335 | | - | let cn = ch[V] |
---|
336 | | - | let co = ch[W] |
---|
337 | | - | $Tuple2([ScriptTransfer(addressFromStringValue(value(getString(ao))), ci, E), ScriptTransfer(addressFromStringValue(value(getString(ap))), cj, E), ScriptTransfer(y, ck, E), IntegerEntry(cl, (valueOrElse(getInteger(cl), 0) + bP)), IntegerEntry(bY, (valueOrElse(getInteger(bY), 0) + cm)), IntegerEntry(aw, (ch[S] - cm)), IntegerEntry(ar, (bj - ci)), IntegerEntry(aq, bg), IntegerEntry(at, (bs - cj)), IntegerEntry(as, bg), IntegerEntry(av, (by - ck)), IntegerEntry(au, bg), IntegerEntry(ax(ay), cn)], $Tuple2(bP, co)) |
---|
338 | | - | } |
---|
339 | | - | |
---|
340 | | - | |
---|
341 | | - | @Callable(cp) |
---|
342 | | - | func constructorV1 (cq,bl,bu,cr,cs) = if ((cp.caller != this)) |
---|
343 | | - | then throw("Permission denied") |
---|
344 | | - | else { |
---|
345 | | - | let ct = addressFromStringValue(cs) |
---|
346 | | - | [IntegerEntry(aC, valueOrElse(getInteger(ct, aC), 0)), IntegerEntry(aD, valueOrElse(getInteger(ct, aD), 0)), IntegerEntry(bY, valueOrElse(getInteger(ct, bY), 0)), IntegerEntry(aw, valueOrElse(getInteger(ct, aw), 0)), BinaryEntry(D, getBinaryValue(ct, D)), StringEntry(s(), cq), StringEntry(ao, bl), StringEntry(ap, bu), StringEntry(bX, cr)] |
---|
347 | | - | } |
---|
348 | | - | |
---|
349 | | - | |
---|
350 | | - | |
---|
351 | | - | @Callable(cp) |
---|
352 | | - | func buyWlg (cu) = { |
---|
353 | | - | let cv = ca() |
---|
354 | | - | if ((cv == cv)) |
---|
355 | | - | then if ((size(cp.payments) != 1)) |
---|
356 | | - | then throw("exactly 1 payment must be attached") |
---|
357 | | - | else { |
---|
358 | | - | let cw = cp.payments[0] |
---|
359 | | - | let cx = cw.amount |
---|
360 | | - | if (if (!(isDefined(cw.assetId))) |
---|
361 | | - | then true |
---|
362 | | - | else (value(cw.assetId) != g)) |
---|
363 | | - | then throw("USDT payments only!") |
---|
364 | | - | else { |
---|
365 | | - | let cg = cp.caller |
---|
366 | | - | let ay = toString(cg) |
---|
367 | | - | if ((d > cx)) |
---|
368 | | - | then throw((("You can trade min " + X(d, 6)) + " USDT")) |
---|
369 | | - | else { |
---|
370 | | - | let ch = aS("", [y, z, A, B, C], g, cx, b) |
---|
371 | | - | let cy = ch[I] |
---|
372 | | - | let cz = ch[K] |
---|
373 | | - | let cA = fraction(cz, c, cy) |
---|
374 | | - | let cB = fraction(cA, 6, 5) |
---|
375 | | - | let cC = fraction(cx, c, cB) |
---|
376 | | - | let cD = cb(ay) |
---|
377 | | - | if ((cC > cD)) |
---|
378 | | - | then throw((("You can get max " + X(cD, 8)) + " WLGOLD")) |
---|
379 | | - | else if ((cu > cC)) |
---|
380 | | - | then throw("Price changed during operation, please try again") |
---|
381 | | - | else { |
---|
382 | | - | let cE = (cx / 6) |
---|
383 | | - | let cF = (cx - cE) |
---|
384 | | - | let cG = fraction(cy, cF, cz) |
---|
385 | | - | $Tuple2([Reissue(E, cG, true), IntegerEntry(aD, (cy + cG)), IntegerEntry(az(ay), lastBlock.timestamp), ScriptTransfer(addressFromStringValue(value(getString(bX))), cE, g), ScriptTransfer(cg, cC, E)], cv) |
---|
386 | | - | } |
---|
387 | | - | } |
---|
388 | | - | } |
---|
389 | | - | } |
---|
390 | | - | else throw("Strict value is not equal to itself.") |
---|
391 | | - | } |
---|
392 | | - | |
---|
393 | | - | |
---|
394 | | - | |
---|
395 | | - | @Callable(cp) |
---|
396 | | - | func sellWlg (cu) = { |
---|
397 | | - | let cv = ca() |
---|
398 | | - | if ((cv == cv)) |
---|
399 | | - | then if ((size(cp.payments) != 1)) |
---|
400 | | - | then throw("exactly 1 payment must be attached") |
---|
401 | | - | else { |
---|
402 | | - | let cw = cp.payments[0] |
---|
403 | | - | let cH = cw.amount |
---|
404 | | - | let cg = cp.caller |
---|
405 | | - | let ay = toString(cg) |
---|
406 | | - | let cD = cb(ay) |
---|
407 | | - | if ((cH > cD)) |
---|
408 | | - | then throw((("You can spend max " + X(cD, 8)) + " WLGOLD")) |
---|
409 | | - | else if (if (!(isDefined(cw.assetId))) |
---|
410 | | - | then true |
---|
411 | | - | else (value(cw.assetId) != E)) |
---|
412 | | - | then throw("WLGOLD payments only!") |
---|
413 | | - | else { |
---|
414 | | - | let ch = aS("", [y, z, A, B, C], g, 0, b) |
---|
415 | | - | let cy = ch[I] |
---|
416 | | - | let cI = fraction(ch[J], 4, 5) |
---|
417 | | - | let cx = fraction(cH, cI, c) |
---|
418 | | - | if ((d > cx)) |
---|
419 | | - | then throw((("You can trade min " + X(d, 6)) + " USDT")) |
---|
420 | | - | else if ((cu > cx)) |
---|
421 | | - | then throw("Price changed during operation, please try again") |
---|
422 | | - | else { |
---|
423 | | - | let cE = (cx / 4) |
---|
424 | | - | $Tuple2([Burn(E, cH), IntegerEntry(aD, (cy - cH)), IntegerEntry(az(ay), lastBlock.timestamp), ScriptTransfer(addressFromStringValue(value(getString(bX))), cE, g), ScriptTransfer(cg, cx, g)], cv) |
---|
425 | | - | } |
---|
426 | | - | } |
---|
427 | | - | } |
---|
428 | | - | else throw("Strict value is not equal to itself.") |
---|
429 | | - | } |
---|
430 | | - | |
---|
431 | | - | |
---|
432 | | - | |
---|
433 | | - | @Callable(cp) |
---|
434 | | - | func claim () = { |
---|
435 | | - | let cv = ca() |
---|
436 | | - | if ((cv == cv)) |
---|
437 | | - | then if ((size(cp.payments) != 0)) |
---|
438 | | - | then throw("No payments required") |
---|
439 | | - | else { |
---|
440 | | - | let cJ = ce(toString(cp.caller), b) |
---|
441 | | - | let cK = cJ._1 |
---|
442 | | - | $Tuple2(((cK :+ ScriptTransfer(cp.caller, cJ._2._1, E)) :+ ScriptTransfer(z, cJ._2._2, E)), cv) |
---|
443 | | - | } |
---|
444 | | - | else throw("Strict value is not equal to itself.") |
---|
445 | | - | } |
---|
446 | | - | |
---|
447 | | - | |
---|
448 | | - | |
---|
449 | | - | @Callable(cp) |
---|
450 | | - | func onStakeUnstakeLand (ay) = if ((cp.caller != z)) |
---|
451 | | - | then throw("Permission denied") |
---|
452 | | - | else { |
---|
453 | | - | let cJ = ce(ay, b) |
---|
454 | | - | let cK = cJ._1 |
---|
455 | | - | $Tuple2(((cK :+ ScriptTransfer(addressFromStringValue(ay), cJ._2._1, E)) :+ ScriptTransfer(z, cJ._2._2, E)), cJ._2) |
---|
456 | | - | } |
---|
| 6 | + | @Callable(a) |
---|
| 7 | + | func testArgs (b,c,d,e,f,g,h,i) = nil |
---|