100 | | - | let U = Address(E(u)) |
---|
101 | | - | |
---|
102 | | - | let V = valueOrErrorMessage(getInteger(O, q), "Empty kBasePeriod") |
---|
103 | | - | |
---|
104 | | - | let W = valueOrErrorMessage(getInteger(O, s), "Empty kStartHeight") |
---|
105 | | - | |
---|
106 | | - | let X = valueOrErrorMessage(getInteger(O, r), "Empty kPeriodLength") |
---|
107 | | - | |
---|
108 | | - | let Y = ((V + ((height - W) / X)) + 3) |
---|
109 | | - | |
---|
110 | | - | let Z = getBooleanValue(this, c) |
---|
111 | | - | |
---|
112 | | - | let aa = getStringValue(this, d) |
---|
113 | | - | |
---|
114 | | - | let ab = getStringValue(this, e) |
---|
115 | | - | |
---|
116 | | - | let ac = if ((aa == "WAVES")) |
---|
117 | | - | then unit |
---|
118 | | - | else fromBase58String(aa) |
---|
119 | | - | |
---|
120 | | - | let ad = if ((ab == "WAVES")) |
---|
121 | | - | then unit |
---|
122 | | - | else fromBase58String(ab) |
---|
123 | | - | |
---|
124 | | - | let ae = { |
---|
125 | | - | let G = ac |
---|
126 | | - | if ($isInstanceOf(G, "ByteVector")) |
---|
127 | | - | then { |
---|
128 | | - | let af = G |
---|
129 | | - | value(assetInfo(af)).name |
---|
130 | | - | } |
---|
131 | | - | else if ($isInstanceOf(G, "Unit")) |
---|
132 | | - | then { |
---|
133 | | - | let ag = G |
---|
134 | | - | "WAVES" |
---|
135 | | - | } |
---|
136 | | - | else throw("Match error") |
---|
137 | | - | } |
---|
138 | | - | |
---|
139 | | - | let ah = { |
---|
140 | | - | let G = ad |
---|
141 | | - | if ($isInstanceOf(G, "ByteVector")) |
---|
142 | | - | then { |
---|
143 | | - | let af = G |
---|
144 | | - | value(assetInfo(af)).name |
---|
145 | | - | } |
---|
146 | | - | else if ($isInstanceOf(G, "Unit")) |
---|
147 | | - | then { |
---|
148 | | - | let ag = G |
---|
149 | | - | "WAVES" |
---|
150 | | - | } |
---|
151 | | - | else throw("Match error") |
---|
152 | | - | } |
---|
153 | | - | |
---|
154 | | - | let ai = getIntegerValue(this, f) |
---|
155 | | - | |
---|
156 | | - | let aj = getIntegerValue(this, g) |
---|
157 | | - | |
---|
158 | | - | let ak = fromBase58String(getStringValue(this, j)) |
---|
159 | | - | |
---|
160 | | - | let al = getIntegerValue(this, k) |
---|
161 | | - | |
---|
162 | | - | let am = getIntegerValue(this, l) |
---|
163 | | - | |
---|
164 | | - | let an = fraction(am, 40, 100) |
---|
165 | | - | |
---|
166 | | - | let ao = 1000000 |
---|
167 | | - | |
---|
168 | | - | let ap = 1000 |
---|
169 | | - | |
---|
170 | | - | let aq = 100000000 |
---|
171 | | - | |
---|
172 | | - | let ar = 1000 |
---|
173 | | - | |
---|
174 | | - | let as = 8 |
---|
175 | | - | |
---|
176 | | - | func at (au) = { |
---|
177 | | - | let G = au |
---|
178 | | - | if ($isInstanceOf(G, "ByteVector")) |
---|
179 | | - | then { |
---|
180 | | - | let af = G |
---|
181 | | - | assetBalance(this, af) |
---|
182 | | - | } |
---|
183 | | - | else if ($isInstanceOf(G, "Unit")) |
---|
184 | | - | then { |
---|
185 | | - | let ag = G |
---|
186 | | - | wavesBalance(this).available |
---|
187 | | - | } |
---|
188 | | - | else throw("Match error") |
---|
189 | | - | } |
---|
190 | | - | |
---|
191 | | - | |
---|
192 | | - | func av (au) = { |
---|
193 | | - | let aw = { |
---|
194 | | - | let G = au |
---|
195 | | - | if ($isInstanceOf(G, "ByteVector")) |
---|
196 | | - | then { |
---|
197 | | - | let ax = G |
---|
198 | | - | if ((ax == P)) |
---|
199 | | - | then getInteger(T, ((("rpd_balance_" + toBase58String(ax)) + "_") + toString(this))) |
---|
200 | | - | else if ((ax == R)) |
---|
201 | | - | then getInteger(U, ((("%s%s%s__stakingBalance__" + toBase58String(ax)) + "__") + toString(this))) |
---|
202 | | - | else 0 |
---|
203 | | - | } |
---|
204 | | - | else if ($isInstanceOf(G, "Unit")) |
---|
205 | | - | then valueOrElse(getInteger(this, w), 0) |
---|
206 | | - | else throw("Match error") |
---|
207 | | - | } |
---|
208 | | - | let G = aw |
---|
209 | | - | if ($isInstanceOf(G, "Int")) |
---|
210 | | - | then { |
---|
211 | | - | let ay = G |
---|
212 | | - | ay |
---|
213 | | - | } |
---|
214 | | - | else 0 |
---|
215 | | - | } |
---|
216 | | - | |
---|
217 | | - | |
---|
218 | | - | let az = av(ac) |
---|
219 | | - | |
---|
220 | | - | let aA = av(ad) |
---|
221 | | - | |
---|
222 | | - | let aB = getIntegerValue(this, h) |
---|
223 | | - | |
---|
224 | | - | let aC = getIntegerValue(this, i) |
---|
225 | | - | |
---|
226 | | - | let aD = (ai - az) |
---|
227 | | - | |
---|
228 | | - | let aE = (aj - aA) |
---|
229 | | - | |
---|
230 | | - | let aF = (at(ac) + az) |
---|
231 | | - | |
---|
232 | | - | let aG = (at(ad) + aA) |
---|
233 | | - | |
---|
234 | | - | let aH = if ((aF >= ai)) |
---|
235 | | - | then (aG >= aj) |
---|
236 | | - | else false |
---|
237 | | - | |
---|
238 | | - | func aI (au) = { |
---|
239 | | - | let G = au |
---|
240 | | - | if ($isInstanceOf(G, "ByteVector")) |
---|
241 | | - | then { |
---|
242 | | - | let af = G |
---|
243 | | - | let aJ = toBase58String(af) |
---|
244 | | - | let aK = valueOrErrorMessage(assetInfo(af), (("Asset " + aJ) + " doesn't exist")) |
---|
245 | | - | $Tuple3(aJ, aK.name, aK.decimals) |
---|
246 | | - | } |
---|
247 | | - | else if ($isInstanceOf(G, "Unit")) |
---|
248 | | - | then { |
---|
249 | | - | let ag = G |
---|
250 | | - | $Tuple3("WAVES", "WAVES", 8) |
---|
251 | | - | } |
---|
252 | | - | else throw("Match error") |
---|
253 | | - | } |
---|
254 | | - | |
---|
255 | | - | |
---|
256 | | - | func aL (aM) = if ((aM == "WAVES")) |
---|
257 | | - | then $Tuple3("WAVES", "WAVES", 8) |
---|
258 | | - | else { |
---|
259 | | - | let aJ = aM |
---|
260 | | - | let af = fromBase58String(aM) |
---|
261 | | - | let aK = valueOrErrorMessage(assetInfo(af), (("Asset " + aJ) + " doesn't exist")) |
---|
262 | | - | $Tuple3(aJ, aK.name, aK.decimals) |
---|
263 | | - | } |
---|
264 | | - | |
---|
265 | | - | |
---|
266 | | - | func aN (aO) = [BooleanEntry(c, false), StringEntry(m, aO)] |
---|
267 | | - | |
---|
268 | | - | |
---|
269 | | - | func aP (aQ,au) = if (aQ) |
---|
270 | | - | then if ((au == P)) |
---|
271 | | - | then $Tuple2("lockNeutrino", T) |
---|
272 | | - | else $Tuple2("startStaking", U) |
---|
273 | | - | else if ((au == P)) |
---|
274 | | - | then $Tuple2("unlockNeutrino", T) |
---|
275 | | - | else $Tuple2("stopStaking", U) |
---|
276 | | - | |
---|
277 | | - | |
---|
278 | | - | func aR (aQ,aS,au) = if (aQ) |
---|
279 | | - | then { |
---|
280 | | - | let aT = aP(aQ, au) |
---|
281 | | - | let aU = aT._1 |
---|
282 | | - | let aV = aT._2 |
---|
283 | | - | $Tuple4(aU, aV, nil, [AttachedPayment(au, aS)]) |
---|
284 | | - | } |
---|
285 | | - | else { |
---|
286 | | - | let aW = aP(aQ, au) |
---|
287 | | - | let aU = aW._1 |
---|
288 | | - | let aV = aW._2 |
---|
289 | | - | $Tuple4(aU, aV, [aS, toBase58String(au)], nil) |
---|
290 | | - | } |
---|
291 | | - | |
---|
292 | | - | |
---|
293 | | - | func aX (aY,aZ,ba,bb) = { |
---|
294 | | - | let bc = fraction(bb, aY, (aY + ba)) |
---|
295 | | - | let bd = fraction(bc, (ao - am), ao) |
---|
296 | | - | let be = fraction(bc, an, ao) |
---|
297 | | - | if ((aZ > bd)) |
---|
298 | | - | then throw(((("Calculated amount to receive " + toString(bd)) + " is less than specified minimum ") + toString(aZ))) |
---|
299 | | - | else $Tuple3(bc, bd, be) |
---|
300 | | - | } |
---|
301 | | - | |
---|
302 | | - | |
---|
303 | | - | func bf () = aN(((((((((((((((("Suspicious state. Actual balances: " + toString(aF)) + " ") + ae) + ", ") + toString(aG)) + " ") + ah) + ". State: ") + toString(ai)) + " ") + ae) + ", ") + toString(aj)) + " ") + ah)) |
---|
304 | | - | |
---|
305 | | - | |
---|
306 | | - | func bg () = if (Z) |
---|
| 72 | + | func G () = if (F) |
---|
311 | | - | @Callable(ay) |
---|
312 | | - | func init (bh) = { |
---|
313 | | - | let bi = $Tuple2(ay.payments[0].amount, ay.payments[0].assetId) |
---|
314 | | - | let bj = bi._1 |
---|
315 | | - | let bk = bi._2 |
---|
316 | | - | let bl = $Tuple2(ay.payments[1].amount, ay.payments[1].assetId) |
---|
317 | | - | let bm = bl._1 |
---|
318 | | - | let bn = bl._2 |
---|
319 | | - | let bo = aI(bk) |
---|
320 | | - | let bp = bo._1 |
---|
321 | | - | let bq = bo._2 |
---|
322 | | - | let br = bo._3 |
---|
323 | | - | let bs = aI(bn) |
---|
324 | | - | let bt = bs._1 |
---|
325 | | - | let bu = bs._2 |
---|
326 | | - | let bv = bs._3 |
---|
327 | | - | if (!(containsElement([J, K, L, M], ay.callerPublicKey))) |
---|
328 | | - | then throw("Only admin can call this function") |
---|
329 | | - | else if (isDefined(getBoolean(this, c))) |
---|
330 | | - | then throw("DApp is already active") |
---|
331 | | - | else if ((bk == bn)) |
---|
332 | | - | then throw("Assets must be different") |
---|
333 | | - | else { |
---|
334 | | - | let bw = ((("s" + take(bq, 7)) + "_") + take(bu, 7)) |
---|
335 | | - | let bx = ((((("ShareToken of SwopFi protocol for " + bq) + " and ") + bu) + " at address ") + toString(this)) |
---|
336 | | - | let by = ((br + bv) / 2) |
---|
337 | | - | let bz = pow(bj, br, 5, 1, br, DOWN) |
---|
338 | | - | let bA = pow(bm, bv, 5, 1, bv, DOWN) |
---|
339 | | - | let bB = pow(10, 0, by, 0, 0, DOWN) |
---|
340 | | - | let bC = fraction(bz, bA, bB) |
---|
341 | | - | let bD = Issue(bw, bx, bC, by, true) |
---|
342 | | - | let bE = calculateAssetId(bD) |
---|
343 | | - | let bF = if (containsElement(S, bp)) |
---|
344 | | - | then invoke(this, "stakeUnstake", [true, bj, bp], nil) |
---|
345 | | - | else 0 |
---|
346 | | - | if ((bF == bF)) |
---|
347 | | - | then { |
---|
348 | | - | let bG = if (containsElement(S, bt)) |
---|
349 | | - | then invoke(this, "stakeUnstake", [true, bm, bt], nil) |
---|
350 | | - | else 0 |
---|
351 | | - | if ((bG == bG)) |
---|
352 | | - | then { |
---|
353 | | - | let bH = [StringEntry(b, a), BooleanEntry(c, true), StringEntry(d, bp), StringEntry(e, bt), IntegerEntry(f, bj), IntegerEntry(g, bm), IntegerEntry(l, getIntegerValue(D, "base_fee_cpmm")), bD, StringEntry(j, toBase58String(bE)), IntegerEntry(k, bC), ScriptTransfer(ay.caller, bC, bE)] |
---|
354 | | - | if (bh) |
---|
355 | | - | then (bH ++ [BooleanEntry(n, bh), IntegerEntry(o, (W + (Y * X)))]) |
---|
356 | | - | else bH |
---|
357 | | - | } |
---|
358 | | - | else throw("Strict value is not equal to itself.") |
---|
359 | | - | } |
---|
360 | | - | else throw("Strict value is not equal to itself.") |
---|
361 | | - | } |
---|
| 77 | + | func H (I) = [BooleanEntry(a, false), StringEntry(b, I)] |
---|
| 78 | + | |
---|
| 79 | + | |
---|
| 80 | + | func J (K,L) = if (K) |
---|
| 81 | + | then if ((L == C)) |
---|
| 82 | + | then $Tuple2("lockNeutrino", z) |
---|
| 83 | + | else $Tuple2("startStaking", A) |
---|
| 84 | + | else if ((L == C)) |
---|
| 85 | + | then $Tuple2("unlockNeutrino", z) |
---|
| 86 | + | else $Tuple2("stopStaking", A) |
---|
| 87 | + | |
---|
| 88 | + | |
---|
| 89 | + | func M (K,N,L) = if (K) |
---|
| 90 | + | then { |
---|
| 91 | + | let O = J(K, L) |
---|
| 92 | + | let P = O._1 |
---|
| 93 | + | let Q = O._2 |
---|
| 94 | + | $Tuple4(P, Q, nil, [AttachedPayment(L, N)]) |
---|
| 95 | + | } |
---|
| 96 | + | else { |
---|
| 97 | + | let R = J(K, L) |
---|
| 98 | + | let P = R._1 |
---|
| 99 | + | let Q = R._2 |
---|
| 100 | + | $Tuple4(P, Q, [N, toBase58String(L)], nil) |
---|
| 101 | + | } |
---|
| 102 | + | |
---|
| 103 | + | |
---|
| 104 | + | func S (T,U) = { |
---|
| 105 | + | let V = T |
---|
| 106 | + | let W = V._1 |
---|
| 107 | + | let X = V._2 |
---|
| 108 | + | $Tuple2((W :+ U.amount), (X :+ U.assetId)) |
---|
365 | | - | |
---|
366 | | - | @Callable(ay) |
---|
367 | | - | func initWithInitRatio (bI,bJ,aa,ab,bh) = { |
---|
368 | | - | let bK = aL(aa) |
---|
369 | | - | let bp = bK._1 |
---|
370 | | - | let bq = bK._2 |
---|
371 | | - | let br = bK._3 |
---|
372 | | - | let bL = aL(ab) |
---|
373 | | - | let bt = bL._1 |
---|
374 | | - | let bu = bL._2 |
---|
375 | | - | let bv = bL._3 |
---|
376 | | - | if (!(containsElement([J, K, L, M], ay.callerPublicKey))) |
---|
377 | | - | then throw("Only admin can call this function") |
---|
378 | | - | else if (isDefined(getBoolean(this, c))) |
---|
379 | | - | then throw("DApp is already active") |
---|
380 | | - | else if ((aa == ab)) |
---|
381 | | - | then throw("Assets must be different") |
---|
382 | | - | else { |
---|
383 | | - | let bw = ((("s" + take(bq, 7)) + "_") + take(bu, 7)) |
---|
384 | | - | let bx = ((((("ShareToken of SwopFi protocol for " + bq) + " and ") + bu) + " at address ") + toString(this)) |
---|
385 | | - | let by = ((br + bv) / 2) |
---|
386 | | - | let bC = 0 |
---|
387 | | - | let bD = Issue(bw, bx, bC, by, true) |
---|
388 | | - | let bE = calculateAssetId(bD) |
---|
389 | | - | let bH = [StringEntry(b, a), BooleanEntry(c, true), StringEntry(d, bp), StringEntry(e, bt), IntegerEntry(h, bI), IntegerEntry(i, bJ), IntegerEntry(f, 0), IntegerEntry(g, 0), IntegerEntry(l, getIntegerValue(D, "base_fee_cpmm")), bD, StringEntry(j, toBase58String(bE)), IntegerEntry(k, bC)] |
---|
390 | | - | if (bh) |
---|
391 | | - | then (bH ++ [BooleanEntry(n, bh), IntegerEntry(o, (W + (Y * X)))]) |
---|
392 | | - | else bH |
---|
393 | | - | } |
---|
| 112 | + | func Y (Z,aa) = { |
---|
| 113 | + | let s = aa |
---|
| 114 | + | if (if ($isInstanceOf(s, "Issue")) |
---|
| 115 | + | then true |
---|
| 116 | + | else if ($isInstanceOf(s, "Burn")) |
---|
| 117 | + | then true |
---|
| 118 | + | else if ($isInstanceOf(s, "Reissue")) |
---|
| 119 | + | then true |
---|
| 120 | + | else if ($isInstanceOf(s, "ScriptTransfer")) |
---|
| 121 | + | then true |
---|
| 122 | + | else if ($isInstanceOf(s, "BinaryEntry")) |
---|
| 123 | + | then true |
---|
| 124 | + | else if ($isInstanceOf(s, "BooleanEntry")) |
---|
| 125 | + | then true |
---|
| 126 | + | else if ($isInstanceOf(s, "StringEntry")) |
---|
| 127 | + | then true |
---|
| 128 | + | else $isInstanceOf(s, "IntegerEntry")) |
---|
| 129 | + | then { |
---|
| 130 | + | let ab = s |
---|
| 131 | + | (Z :+ ab) |
---|
| 132 | + | } |
---|
| 133 | + | else Z |
---|
405 | | - | @Callable(ay) |
---|
406 | | - | func replenishWithTwoTokens (bN) = valueOrElse(bg(), { |
---|
407 | | - | let bk = ay.payments[0].assetId |
---|
408 | | - | let bn = ay.payments[1].assetId |
---|
409 | | - | let bj = ay.payments[0].amount |
---|
410 | | - | let bm = ay.payments[1].amount |
---|
411 | | - | let bO = aI(bk) |
---|
412 | | - | let bp = bO._1 |
---|
413 | | - | let bq = bO._2 |
---|
414 | | - | let br = bO._3 |
---|
415 | | - | let bP = aI(bn) |
---|
416 | | - | let bt = bP._1 |
---|
417 | | - | let bu = bP._2 |
---|
418 | | - | let bv = bP._3 |
---|
419 | | - | let bQ = if (if ((ai == 0)) |
---|
420 | | - | then (aj == 0) |
---|
421 | | - | else false) |
---|
422 | | - | then true |
---|
423 | | - | else false |
---|
424 | | - | let bR = if (bQ) |
---|
425 | | - | then fraction(fraction(aB, aq, bj), ap, fraction(aC, aq, bm)) |
---|
426 | | - | else fraction(fraction(ai, aq, bj), ap, fraction(aj, aq, bm)) |
---|
427 | | - | let by = ((br + bv) / 2) |
---|
428 | | - | let bS = if (bQ) |
---|
429 | | - | then fraction(pow(bj, br, 5, 1, br, DOWN), pow(bm, bv, 5, 1, bv, DOWN), pow(10, 0, by, 0, 0, DOWN)) |
---|
430 | | - | else fraction(min([fraction(bj, aq, ai), fraction(bm, aq, aj)]), al, aq) |
---|
431 | | - | if (if ((0 > bN)) |
---|
432 | | - | then true |
---|
433 | | - | else (bN > ar)) |
---|
434 | | - | then throw(((("Slippage tolerance must be between 0 and " + toString(ar)) + " inclusively. Actual: ") + toString(bN))) |
---|
435 | | - | else if ((size(ay.payments) != 2)) |
---|
436 | | - | then throw("Two attached assets expected") |
---|
437 | | - | else if (if ((bk != ac)) |
---|
438 | | - | then true |
---|
439 | | - | else (bn != ad)) |
---|
440 | | - | then throw(((("Incorrect assets attached. Expected: " + aa) + " and ") + ab)) |
---|
441 | | - | else if (if ((((ap * (ar - bN)) / ar) > bR)) |
---|
442 | | - | then true |
---|
443 | | - | else (bR > ((ap * (ar + bN)) / ar))) |
---|
444 | | - | then throw("Incorrect assets amount: amounts must have the contract ratio") |
---|
445 | | - | else if ((bS == 0)) |
---|
446 | | - | then throw("Too small amount to replenish") |
---|
447 | | - | else if (!(aH)) |
---|
448 | | - | then ([ScriptTransfer(ay.caller, bj, bk), ScriptTransfer(ay.caller, bm, bn)] ++ bf()) |
---|
449 | | - | else { |
---|
450 | | - | let bF = if (containsElement(S, bp)) |
---|
451 | | - | then invoke(this, "stakeUnstake", [true, bj, bp], nil) |
---|
452 | | - | else 0 |
---|
453 | | - | if ((bF == bF)) |
---|
454 | | - | then { |
---|
455 | | - | let bG = if (containsElement(S, bt)) |
---|
456 | | - | then invoke(this, "stakeUnstake", [true, bm, bt], nil) |
---|
457 | | - | else 0 |
---|
458 | | - | if ((bG == bG)) |
---|
459 | | - | then [Reissue(ak, bS, true), IntegerEntry(f, (ai + bj)), IntegerEntry(g, (aj + bm)), IntegerEntry(k, (al + bS)), ScriptTransfer(ay.caller, bS, ak)] |
---|
460 | | - | else throw("Strict value is not equal to itself.") |
---|
461 | | - | } |
---|
462 | | - | else throw("Strict value is not equal to itself.") |
---|
463 | | - | } |
---|
| 174 | + | aq(ap(ap(ap(ap(ap(ap(ap(ap(ap(ap(ap(ap(ap(ap(ap(ai, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) |
---|
| 175 | + | } |
---|
| 176 | + | else throw("Strict value is not equal to itself.") |
---|
468 | | - | @Callable(ay) |
---|
469 | | - | func withdraw () = valueOrElse(bg(), { |
---|
470 | | - | let bT = $Tuple2(ay.payments[0].amount, ay.payments[0].assetId) |
---|
471 | | - | let aY = bT._1 |
---|
472 | | - | let bU = bT._2 |
---|
473 | | - | let bV = fraction(aY, ai, al) |
---|
474 | | - | let bW = fraction(aY, aj, al) |
---|
475 | | - | if ((size(ay.payments) != 1)) |
---|
476 | | - | then throw("One attached payment expected") |
---|
477 | | - | else if ((bU != ak)) |
---|
478 | | - | then throw(("Incorrect asset attached. Expected: " + toBase58String(ak))) |
---|
479 | | - | else if (!(aH)) |
---|
480 | | - | then ([ScriptTransfer(ay.caller, aY, bU)] ++ bf()) |
---|
481 | | - | else { |
---|
482 | | - | let bF = if (containsElement(S, aa)) |
---|
483 | | - | then invoke(this, "stakeUnstake", [false, bV, aa], nil) |
---|
484 | | - | else 0 |
---|
485 | | - | if ((bF == bF)) |
---|
486 | | - | then { |
---|
487 | | - | let bG = if (containsElement(S, ab)) |
---|
488 | | - | then invoke(this, "stakeUnstake", [false, bW, ab], nil) |
---|
489 | | - | else 0 |
---|
490 | | - | if ((bG == bG)) |
---|
491 | | - | then [IntegerEntry(f, (ai - bV)), IntegerEntry(g, (aj - bW)), IntegerEntry(k, (al - aY)), Burn(ak, aY), ScriptTransfer(ay.caller, bV, ac), ScriptTransfer(ay.caller, bW, ad)] |
---|
492 | | - | else throw("Strict value is not equal to itself.") |
---|
493 | | - | } |
---|
494 | | - | else throw("Strict value is not equal to itself.") |
---|
495 | | - | } |
---|
496 | | - | }) |
---|
| 181 | + | @Callable(ac) |
---|
| 182 | + | func shutdown () = if (!(F)) |
---|
| 183 | + | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, b), "the cause wasn't specified"))) |
---|
| 184 | + | else if (!(containsElement([v, w, x], ac.callerPublicKey))) |
---|
| 185 | + | then throw("Only admin can call this function") |
---|
| 186 | + | else H("Paused by admin") |
---|
500 | | - | @Callable(ay) |
---|
501 | | - | func exchange (aZ) = valueOrElse(bg(), { |
---|
502 | | - | let bX = $Tuple2(ay.payments[0].amount, ay.payments[0].assetId) |
---|
503 | | - | let aY = bX._1 |
---|
504 | | - | let bU = bX._2 |
---|
505 | | - | if (if ((ai == 0)) |
---|
506 | | - | then true |
---|
507 | | - | else (aj == 0)) |
---|
508 | | - | then throw("Can't exchange with zero balance") |
---|
509 | | - | else if ((0 >= aZ)) |
---|
510 | | - | then throw(("Minimal amount to receive must be positive. Actual: " + toString(aZ))) |
---|
511 | | - | else if ((size(ay.payments) != 1)) |
---|
512 | | - | then throw("One attached payment expected") |
---|
513 | | - | else if (!(aH)) |
---|
514 | | - | then ([ScriptTransfer(ay.caller, aY, bU)] ++ bf()) |
---|
515 | | - | else if ((bU == ac)) |
---|
516 | | - | then { |
---|
517 | | - | let bY = ad |
---|
518 | | - | let bZ = aX(aY, aZ, ai, aj) |
---|
519 | | - | let bc = bZ._1 |
---|
520 | | - | let bd = bZ._2 |
---|
521 | | - | let be = bZ._3 |
---|
522 | | - | let ca = (ai + aY) |
---|
523 | | - | let cb = ((aj - bd) - be) |
---|
524 | | - | let bF = if (containsElement(S, aa)) |
---|
525 | | - | then invoke(this, "stakeUnstake", [true, aY, aa], nil) |
---|
526 | | - | else 0 |
---|
527 | | - | if ((bF == bF)) |
---|
528 | | - | then { |
---|
529 | | - | let bG = if (containsElement(S, ab)) |
---|
530 | | - | then invoke(this, "stakeUnstake", [false, (bd + be), ab], nil) |
---|
531 | | - | else 0 |
---|
532 | | - | if ((bG == bG)) |
---|
533 | | - | then $Tuple2([IntegerEntry(f, ca), IntegerEntry(g, cb), ScriptTransfer(ay.caller, bd, bY), ScriptTransfer(N, be, bY)], $Tuple2(bd, bY)) |
---|
534 | | - | else throw("Strict value is not equal to itself.") |
---|
535 | | - | } |
---|
536 | | - | else throw("Strict value is not equal to itself.") |
---|
537 | | - | } |
---|
538 | | - | else if ((bU == ad)) |
---|
539 | | - | then { |
---|
540 | | - | let bY = ac |
---|
541 | | - | let cc = aX(aY, aZ, aj, ai) |
---|
542 | | - | let bc = cc._1 |
---|
543 | | - | let bd = cc._2 |
---|
544 | | - | let be = cc._3 |
---|
545 | | - | let ca = ((ai - bd) - be) |
---|
546 | | - | let cb = (aj + aY) |
---|
547 | | - | let bF = if (containsElement(S, aa)) |
---|
548 | | - | then invoke(this, "stakeUnstake", [false, (bd + be), aa], nil) |
---|
549 | | - | else 0 |
---|
550 | | - | if ((bF == bF)) |
---|
551 | | - | then { |
---|
552 | | - | let bG = if (containsElement(S, ab)) |
---|
553 | | - | then invoke(this, "stakeUnstake", [true, aY, ab], nil) |
---|
554 | | - | else 0 |
---|
555 | | - | if ((bG == bG)) |
---|
556 | | - | then $Tuple2([IntegerEntry(f, ca), IntegerEntry(g, cb), ScriptTransfer(ay.caller, bd, bY), ScriptTransfer(N, be, bY)], $Tuple2(bd, bY)) |
---|
557 | | - | else throw("Strict value is not equal to itself.") |
---|
558 | | - | } |
---|
559 | | - | else throw("Strict value is not equal to itself.") |
---|
560 | | - | } |
---|
561 | | - | else throw(((("Incorrect asset attached. Expected: " + aa) + " or ") + ab)) |
---|
562 | | - | }) |
---|
| 190 | + | @Callable(ac) |
---|
| 191 | + | func activate () = if (F) |
---|
| 192 | + | then throw("DApp is already active") |
---|
| 193 | + | else if (!(containsElement([v, w, x], ac.callerPublicKey))) |
---|
| 194 | + | then throw("Only admin can call this function") |
---|
| 195 | + | else [BooleanEntry(a, true), DeleteEntry(b)] |
---|
566 | | - | @Callable(ay) |
---|
567 | | - | func shutdown () = if (!(Z)) |
---|
568 | | - | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, m), "the cause wasn't specified"))) |
---|
569 | | - | else if (!(containsElement([J, K, L], ay.callerPublicKey))) |
---|
570 | | - | then throw("Only admin can call this function") |
---|
571 | | - | else aN("Paused by admin") |
---|
| 199 | + | @Callable(ac) |
---|
| 200 | + | func stakeUnstake (K,N,ar) = valueOrElse(G(), if ((ac.caller != B)) |
---|
| 201 | + | then throw("Only global Contract can invoke this function") |
---|
| 202 | + | else if ((ar == "WAVES")) |
---|
| 203 | + | then { |
---|
| 204 | + | let as = addressFromStringValue(valueOrErrorMessage(getString(p, e), "No leasing pool in oracle")) |
---|
| 205 | + | let at = getBinary(this, g) |
---|
| 206 | + | let au = valueOrElse(getInteger(this, f), 0) |
---|
| 207 | + | let av = if (K) |
---|
| 208 | + | then (au + N) |
---|
| 209 | + | else (au - N) |
---|
| 210 | + | let aw = Lease(as, av) |
---|
| 211 | + | let ax = calculateLeaseId(aw) |
---|
| 212 | + | let ay = [aw, BinaryEntry(g, ax), IntegerEntry(f, av)] |
---|
| 213 | + | let s = at |
---|
| 214 | + | if ($isInstanceOf(s, "ByteVector")) |
---|
| 215 | + | then { |
---|
| 216 | + | let az = s |
---|
| 217 | + | ([LeaseCancel(az)] ++ ay) |
---|
| 218 | + | } |
---|
| 219 | + | else ay |
---|
| 220 | + | } |
---|
| 221 | + | else { |
---|
| 222 | + | let aA = M(K, N, fromBase58String(ar)) |
---|
| 223 | + | let P = aA._1 |
---|
| 224 | + | let aB = aA._2 |
---|
| 225 | + | let aC = aA._3 |
---|
| 226 | + | let aD = aA._4 |
---|
| 227 | + | let aE = invoke(aB, P, aC, aD) |
---|
| 228 | + | if ((aE == aE)) |
---|
| 229 | + | then nil |
---|
| 230 | + | else throw("Strict value is not equal to itself.") |
---|
| 231 | + | }) |
---|
574 | | - | |
---|
575 | | - | @Callable(ay) |
---|
576 | | - | func activate () = if (Z) |
---|
577 | | - | then throw("DApp is already active") |
---|
578 | | - | else if (!(containsElement([J, K, L], ay.callerPublicKey))) |
---|
579 | | - | then throw("Only admin can call this function") |
---|
580 | | - | else [BooleanEntry(c, true), DeleteEntry(m)] |
---|
581 | | - | |
---|
582 | | - | |
---|
583 | | - | |
---|
584 | | - | @Callable(ay) |
---|
585 | | - | func takeIntoAccountExtraFunds () = valueOrElse(bg(), { |
---|
586 | | - | let cd = (aF - ai) |
---|
587 | | - | let ce = (aG - aj) |
---|
588 | | - | if ((ay.caller != N)) |
---|
589 | | - | then throw("Only the wallet can call this function") |
---|
590 | | - | else if (if ((0 > cd)) |
---|
591 | | - | then true |
---|
592 | | - | else (0 > ce)) |
---|
593 | | - | then aN("Enroll amount negative") |
---|
594 | | - | else if (if ((cd == 0)) |
---|
595 | | - | then (ce == 0) |
---|
596 | | - | else false) |
---|
597 | | - | then throw("No money to take") |
---|
598 | | - | else { |
---|
599 | | - | let bF = if (containsElement(S, aa)) |
---|
600 | | - | then invoke(this, "stakeUnstake", [true, cd, aa], nil) |
---|
601 | | - | else 0 |
---|
602 | | - | if ((bF == bF)) |
---|
603 | | - | then { |
---|
604 | | - | let bG = if (containsElement(S, ab)) |
---|
605 | | - | then invoke(this, "stakeUnstake", [true, ce, ab], nil) |
---|
606 | | - | else 0 |
---|
607 | | - | if ((bG == bG)) |
---|
608 | | - | then [IntegerEntry(f, (ai + cd)), IntegerEntry(g, (aj + ce)), IntegerEntry(("last_income_" + aa), cd), IntegerEntry(("last_income_" + ab), ce)] |
---|
609 | | - | else throw("Strict value is not equal to itself.") |
---|
610 | | - | } |
---|
611 | | - | else throw("Strict value is not equal to itself.") |
---|
612 | | - | } |
---|
613 | | - | }) |
---|
614 | | - | |
---|
615 | | - | |
---|
616 | | - | |
---|
617 | | - | @Callable(ay) |
---|
618 | | - | func stakeUnstake (aQ,aS,cf) = if ((ay.caller != this)) |
---|
619 | | - | then throw("Only contract itself can invoke this function") |
---|
620 | | - | else if ((cf == "WAVES")) |
---|
621 | | - | then { |
---|
622 | | - | let cg = addressFromStringValue(valueOrErrorMessage(getString(D, v), "No leasing pool in oracle")) |
---|
623 | | - | let ch = getBinary(this, x) |
---|
624 | | - | let ci = valueOrElse(getInteger(this, w), 0) |
---|
625 | | - | let cj = if (aQ) |
---|
626 | | - | then (ci + aS) |
---|
627 | | - | else (ci - aS) |
---|
628 | | - | let ck = Lease(cg, cj) |
---|
629 | | - | let cl = calculateLeaseId(ck) |
---|
630 | | - | let cm = [ck, BinaryEntry(x, cl), IntegerEntry(w, cj)] |
---|
631 | | - | let G = ch |
---|
632 | | - | if ($isInstanceOf(G, "ByteVector")) |
---|
633 | | - | then { |
---|
634 | | - | let cn = G |
---|
635 | | - | ([LeaseCancel(cn)] ++ cm) |
---|
636 | | - | } |
---|
637 | | - | else cm |
---|
638 | | - | } |
---|
639 | | - | else { |
---|
640 | | - | let co = aR(aQ, aS, fromBase58String(cf)) |
---|
641 | | - | let aU = co._1 |
---|
642 | | - | let cp = co._2 |
---|
643 | | - | let cq = co._3 |
---|
644 | | - | let cr = co._4 |
---|
645 | | - | let cs = invoke(cp, aU, cq, cr) |
---|
646 | | - | if ((cs == cs)) |
---|
647 | | - | then nil |
---|
648 | | - | else throw("Strict value is not equal to itself.") |
---|
649 | | - | } |
---|
650 | | - | |
---|
651 | | - | |
---|
652 | | - | |
---|
653 | | - | @Callable(ay) |
---|
654 | | - | func stakeAll () = valueOrElse(bg(), if (!(containsElement([J, K, L], ay.callerPublicKey))) |
---|
655 | | - | then throw("Only admin can call this function") |
---|
656 | | - | else { |
---|
657 | | - | let bF = if (containsElement(S, aa)) |
---|
658 | | - | then { |
---|
659 | | - | let ct = (ai - az) |
---|
660 | | - | if ((ct > 0)) |
---|
661 | | - | then invoke(this, "stakeUnstake", [true, ct, aa], nil) |
---|
662 | | - | else 0 |
---|
663 | | - | } |
---|
664 | | - | else 0 |
---|
665 | | - | if ((bF == bF)) |
---|
666 | | - | then { |
---|
667 | | - | let bG = if (containsElement(S, ab)) |
---|
668 | | - | then { |
---|
669 | | - | let cu = (aj - aA) |
---|
670 | | - | if ((cu > 0)) |
---|
671 | | - | then invoke(this, "stakeUnstake", [true, cu, ab], nil) |
---|
672 | | - | else 0 |
---|
673 | | - | } |
---|
674 | | - | else 0 |
---|
675 | | - | if ((bG == bG)) |
---|
676 | | - | then nil |
---|
677 | | - | else throw("Strict value is not equal to itself.") |
---|
678 | | - | } |
---|
679 | | - | else throw("Strict value is not equal to itself.") |
---|
680 | | - | }) |
---|
681 | | - | |
---|
682 | | - | |
---|
683 | | - | @Verifier(cv) |
---|
684 | | - | func cw () = { |
---|
685 | | - | let cx = { |
---|
686 | | - | let cy = if (sigVerify(cv.bodyBytes, cv.proofs[0], J)) |
---|
| 234 | + | @Verifier(aF) |
---|
| 235 | + | func aG () = { |
---|
| 236 | + | let aH = { |
---|
| 237 | + | let aI = if (sigVerify(aF.bodyBytes, aF.proofs[0], v)) |
---|