131 | | - | else if ($isInstanceOf(B, "Unit")) |
---|
132 | | - | then { |
---|
133 | | - | let ag = B |
---|
134 | | - | "WAVES" |
---|
135 | | - | } |
---|
136 | | - | else throw("Match error") |
---|
137 | | - | } |
---|
138 | | - | |
---|
139 | | - | let ah = { |
---|
140 | | - | let B = ad |
---|
141 | | - | if ($isInstanceOf(B, "ByteVector")) |
---|
142 | | - | then { |
---|
143 | | - | let af = B |
---|
144 | | - | value(assetInfo(af)).name |
---|
145 | | - | } |
---|
146 | | - | else if ($isInstanceOf(B, "Unit")) |
---|
147 | | - | then { |
---|
148 | | - | let ag = B |
---|
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 = 3000 |
---|
163 | | - | |
---|
164 | | - | let an = 1200 |
---|
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 B = au |
---|
178 | | - | if ($isInstanceOf(B, "ByteVector")) |
---|
179 | | - | then { |
---|
180 | | - | let af = B |
---|
181 | | - | assetBalance(this, af) |
---|
182 | | - | } |
---|
183 | | - | else if ($isInstanceOf(B, "Unit")) |
---|
184 | | - | then { |
---|
185 | | - | let ag = B |
---|
186 | | - | wavesBalance(this).available |
---|
187 | | - | } |
---|
188 | | - | else throw("Match error") |
---|
189 | | - | } |
---|
190 | | - | |
---|
191 | | - | |
---|
192 | | - | func av (au) = { |
---|
193 | | - | let aw = { |
---|
194 | | - | let B = au |
---|
195 | | - | if ($isInstanceOf(B, "ByteVector")) |
---|
196 | | - | then { |
---|
197 | | - | let ax = B |
---|
198 | | - | if (if ((ax == L)) |
---|
199 | | - | then true |
---|
200 | | - | else (ax == M)) |
---|
201 | | - | then getInteger(P, ((("rpd_balance_" + toBase58String(ax)) + "_") + toString(this))) |
---|
202 | | - | else if ((ax == O)) |
---|
203 | | - | then getInteger(Q, ((("%s%s%s__stakingBalance__" + toBase58String(ax)) + "__") + toString(this))) |
---|
204 | | - | else 0 |
---|
205 | | - | } |
---|
206 | | - | else if ($isInstanceOf(B, "Unit")) |
---|
207 | | - | then 0 |
---|
208 | | - | else throw("Match error") |
---|
209 | | - | } |
---|
210 | | - | let B = aw |
---|
211 | | - | if ($isInstanceOf(B, "Int")) |
---|
212 | | - | then { |
---|
213 | | - | let ay = B |
---|
214 | | - | ay |
---|
215 | | - | } |
---|
216 | | - | else 0 |
---|
217 | | - | } |
---|
218 | | - | |
---|
219 | | - | |
---|
220 | | - | let az = av(ac) |
---|
221 | | - | |
---|
222 | | - | let aA = av(ad) |
---|
223 | | - | |
---|
224 | | - | let aB = getIntegerValue(this, h) |
---|
225 | | - | |
---|
226 | | - | let aC = getIntegerValue(this, i) |
---|
227 | | - | |
---|
228 | | - | let aD = (ai - az) |
---|
229 | | - | |
---|
230 | | - | let aE = (aj - aA) |
---|
231 | | - | |
---|
232 | | - | let aF = (at(ac) + az) |
---|
233 | | - | |
---|
234 | | - | let aG = (at(ad) + aA) |
---|
235 | | - | |
---|
236 | | - | let aH = if ((aF >= ai)) |
---|
237 | | - | then (aG >= aj) |
---|
238 | | - | else false |
---|
239 | | - | |
---|
240 | | - | func aI (au) = { |
---|
241 | | - | let B = au |
---|
242 | | - | if ($isInstanceOf(B, "ByteVector")) |
---|
243 | | - | then { |
---|
244 | | - | let af = B |
---|
245 | | - | let aJ = toBase58String(af) |
---|
246 | | - | let aK = valueOrErrorMessage(assetInfo(af), (("Asset " + aJ) + " doesn't exist")) |
---|
247 | | - | $Tuple3(aJ, aK.name, aK.decimals) |
---|
248 | | - | } |
---|
249 | | - | else if ($isInstanceOf(B, "Unit")) |
---|
250 | | - | then { |
---|
251 | | - | let ag = B |
---|
252 | | - | $Tuple3("WAVES", "WAVES", 8) |
---|
253 | | - | } |
---|
254 | | - | else throw("Match error") |
---|
255 | | - | } |
---|
256 | | - | |
---|
257 | | - | |
---|
258 | | - | func aL (aM) = if ((aM == "WAVES")) |
---|
259 | | - | then $Tuple3("WAVES", "WAVES", 8) |
---|
260 | | - | else { |
---|
261 | | - | let aJ = aM |
---|
262 | | - | let af = fromBase58String(aM) |
---|
263 | | - | let aK = valueOrErrorMessage(assetInfo(af), (("Asset " + aJ) + " doesn't exist")) |
---|
264 | | - | $Tuple3(aJ, aK.name, aK.decimals) |
---|
265 | | - | } |
---|
266 | | - | |
---|
267 | | - | |
---|
268 | | - | func aN (aO) = [BooleanEntry(c, false), StringEntry(n, aO)] |
---|
269 | | - | |
---|
270 | | - | |
---|
271 | | - | func aP (aQ,au,aR) = if (if ((au == L)) |
---|
272 | | - | then true |
---|
273 | | - | else (au == O)) |
---|
274 | | - | then { |
---|
275 | | - | let aS = if ((au == L)) |
---|
276 | | - | then (T * (if ((aR == M)) |
---|
277 | | - | then 2 |
---|
278 | | - | else 1)) |
---|
279 | | - | else if ((au == O)) |
---|
280 | | - | then U |
---|
281 | | - | else 0 |
---|
282 | | - | let aT = (aQ - aS) |
---|
283 | | - | if ((0 >= aT)) |
---|
284 | | - | then throw((((("Insufficient amount " + toString(aQ)) + " to deduct staking fee ") + toString(aS)) + "USDN/EURN")) |
---|
285 | | - | else aT |
---|
286 | | - | } |
---|
287 | | - | else aQ |
---|
288 | | - | |
---|
289 | | - | |
---|
290 | | - | func aU (au,aR) = if ((au == L)) |
---|
291 | | - | then (T * (if ((aR == M)) |
---|
292 | | - | then 2 |
---|
293 | | - | else 1)) |
---|
294 | | - | else if ((au == O)) |
---|
295 | | - | then U |
---|
296 | | - | else 0 |
---|
297 | | - | |
---|
298 | | - | |
---|
299 | | - | func aV (aQ,aW,aX) = throw((((((((("Insufficient DApp balance to pay " + toString(aQ)) + " ") + aX) + " due to staking. Available: ") + toString(aW)) + " ") + aX) + ". Please contact support in Telegram: https://t.me/swopfisupport")) |
---|
300 | | - | |
---|
301 | | - | |
---|
302 | | - | func aY (aZ,ba) = throw((((((((((((((((("Insufficient DApp balance to pay " + toString(aZ)) + " ") + ae) + " and ") + toString(ba)) + " ") + ah) + " due to staking. Available: ") + toString(aD)) + " ") + ae) + " and ") + toString(aE)) + " ") + ah) + ". Please contact support in Telegram: https://t.me/swopfisupport")) |
---|
303 | | - | |
---|
304 | | - | |
---|
305 | | - | func bb () = aN(((((((((((((((("Suspicious state. Actual balances: " + toString(aF)) + " ") + ae) + ", ") + toString(aG)) + " ") + ah) + ". State: ") + toString(ai)) + " ") + ae) + ", ") + toString(aj)) + " ") + ah)) |
---|
306 | | - | |
---|
307 | | - | |
---|
308 | | - | @Callable(ay) |
---|
309 | | - | func init (bc) = { |
---|
310 | | - | let bd = $Tuple2(ay.payments[0].amount, ay.payments[0].assetId) |
---|
311 | | - | let be = bd._1 |
---|
312 | | - | let bf = bd._2 |
---|
313 | | - | let bg = $Tuple2(ay.payments[1].amount, ay.payments[1].assetId) |
---|
314 | | - | let bh = bg._1 |
---|
315 | | - | let bi = bg._2 |
---|
316 | | - | let bj = aI(bf) |
---|
317 | | - | let bk = bj._1 |
---|
318 | | - | let bl = bj._2 |
---|
319 | | - | let bm = bj._3 |
---|
320 | | - | let bn = aI(bi) |
---|
321 | | - | let bo = bn._1 |
---|
322 | | - | let bp = bn._2 |
---|
323 | | - | let bq = bn._3 |
---|
324 | | - | if (isDefined(getBoolean(this, c))) |
---|
325 | | - | then throw("DApp is already active") |
---|
326 | | - | else if ((bf == bi)) |
---|
327 | | - | then throw("Assets must be different") |
---|
328 | | - | else { |
---|
329 | | - | let br = ((("s" + take(bl, 7)) + "_") + take(bp, 7)) |
---|
330 | | - | let bs = ((((("ShareToken of SwopFi protocol for " + bl) + " and ") + bp) + " at address ") + toString(this)) |
---|
331 | | - | let bt = ((bm + bq) / 2) |
---|
332 | | - | let bu = pow(be, bm, 5, 1, bm, DOWN) |
---|
333 | | - | let bv = pow(bh, bq, 5, 1, bq, DOWN) |
---|
334 | | - | let bw = pow(10, 0, bt, 0, 0, DOWN) |
---|
335 | | - | let bx = fraction(bu, bv, bw) |
---|
336 | | - | let by = Issue(br, bs, bx, bt, true) |
---|
337 | | - | let bz = calculateAssetId(by) |
---|
338 | | - | let bA = [StringEntry(b, a), BooleanEntry(c, true), StringEntry(d, bk), StringEntry(e, bo), IntegerEntry(f, be), IntegerEntry(g, bh), IntegerEntry(l, am), IntegerEntry(m, ao), by, StringEntry(j, toBase58String(bz)), IntegerEntry(k, bx), ScriptTransfer(ay.caller, bx, bz)] |
---|
339 | | - | if (bc) |
---|
340 | | - | then (bA ++ [BooleanEntry(o, bc), IntegerEntry(p, (W + (Y * X)))]) |
---|
341 | | - | else bA |
---|
342 | | - | } |
---|
343 | | - | } |
---|
344 | | - | |
---|
345 | | - | |
---|
346 | | - | |
---|
347 | | - | @Callable(ay) |
---|
348 | | - | func initWithInitRatio (bB,bC,aa,ab,bc) = { |
---|
349 | | - | let bD = aL(aa) |
---|
350 | | - | let bk = bD._1 |
---|
351 | | - | let bl = bD._2 |
---|
352 | | - | let bm = bD._3 |
---|
353 | | - | let bE = aL(ab) |
---|
354 | | - | let bo = bE._1 |
---|
355 | | - | let bp = bE._2 |
---|
356 | | - | let bq = bE._3 |
---|
357 | | - | if (!(containsElement([E, F, G, I], ay.callerPublicKey))) |
---|
358 | | - | then throw("Only admin can call this function") |
---|
359 | | - | else if (isDefined(getBoolean(this, c))) |
---|
360 | | - | then throw("DApp is already active") |
---|
361 | | - | else if ((aa == ab)) |
---|
362 | | - | then throw("Assets must be different") |
---|
363 | | - | else { |
---|
364 | | - | let br = ((("s" + take(bl, 7)) + "_") + take(bp, 7)) |
---|
365 | | - | let bs = ((((("ShareToken of SwopFi protocol for " + bl) + " and ") + bp) + " at address ") + toString(this)) |
---|
366 | | - | let bt = ((bm + bq) / 2) |
---|
367 | | - | let bx = 0 |
---|
368 | | - | let by = Issue(br, bs, bx, bt, true) |
---|
369 | | - | let bz = calculateAssetId(by) |
---|
370 | | - | let bA = [StringEntry(b, a), BooleanEntry(c, true), StringEntry(d, bk), StringEntry(e, bo), IntegerEntry(h, bB), IntegerEntry(i, bC), IntegerEntry(f, 0), IntegerEntry(g, 0), IntegerEntry(l, am), IntegerEntry(m, ao), by, StringEntry(j, toBase58String(bz)), IntegerEntry(k, bx)] |
---|
371 | | - | if (bc) |
---|
372 | | - | then (bA ++ [BooleanEntry(o, bc), IntegerEntry(p, (W + (Y * X)))]) |
---|
373 | | - | else bA |
---|
374 | | - | } |
---|
375 | | - | } |
---|
376 | | - | |
---|
377 | | - | |
---|
378 | | - | |
---|
379 | | - | @Callable(ay) |
---|
380 | | - | func keepLimitForFirstHarvest (bF) = if (!(Z)) |
---|
381 | | - | then throw("DApp is inactive at this moment") |
---|
382 | | - | else if (!(containsElement([E, F, G, I], ay.callerPublicKey))) |
---|
383 | | - | then throw("Only admin can call this function") |
---|
384 | | - | else [IntegerEntry(q, bF)] |
---|
385 | | - | |
---|
386 | | - | |
---|
387 | | - | |
---|
388 | | - | @Callable(ay) |
---|
389 | | - | func replenishWithTwoTokens (bG) = { |
---|
390 | | - | let bf = ay.payments[0].assetId |
---|
391 | | - | let bi = ay.payments[1].assetId |
---|
392 | | - | let be = aP(ay.payments[0].amount, bf, bi) |
---|
393 | | - | let bh = aP(ay.payments[1].amount, bi, bf) |
---|
394 | | - | if (if ((ai == 0)) |
---|
395 | | - | then (aj == 0) |
---|
396 | | - | else false) |
---|
397 | | - | then { |
---|
398 | | - | let bH = aI(bf) |
---|
399 | | - | let bk = bH._1 |
---|
400 | | - | let bl = bH._2 |
---|
401 | | - | let bm = bH._3 |
---|
402 | | - | let bI = aI(bi) |
---|
403 | | - | let bo = bI._1 |
---|
404 | | - | let bp = bI._2 |
---|
405 | | - | let bq = bI._3 |
---|
406 | | - | let bJ = fraction(fraction(aB, aq, be), ap, fraction(aC, aq, bh)) |
---|
407 | | - | if ((bf == bi)) |
---|
408 | | - | then throw("Assets must be different") |
---|
409 | | - | else { |
---|
410 | | - | let bt = ((bm + bq) / 2) |
---|
411 | | - | let bx = fraction(pow(be, bm, 5, 1, bm, DOWN), pow(bh, bq, 5, 1, bq, DOWN), pow(10, 0, bt, 0, 0, DOWN)) |
---|
412 | | - | if (!(Z)) |
---|
413 | | - | then throw("DApp is inactive at this moment") |
---|
414 | | - | else if (if ((0 > bG)) |
---|
415 | | - | then true |
---|
416 | | - | else (bG > ar)) |
---|
417 | | - | then throw(((("Slippage tolerance must be between 0 and " + toString(ar)) + " inclusively. Actual: ") + toString(bG))) |
---|
418 | | - | else if ((size(ay.payments) != 2)) |
---|
419 | | - | then throw("Two attached assets expected") |
---|
420 | | - | else if (if ((((ap * (ar - bG)) / ar) > bJ)) |
---|
421 | | - | then true |
---|
422 | | - | else (bJ > ((ap * (ar + bG)) / ar))) |
---|
423 | | - | then throw("Incorrect assets amount: amounts must have the contract ratio") |
---|
424 | | - | else if (if ((bf != ac)) |
---|
425 | | - | then true |
---|
426 | | - | else (bi != ad)) |
---|
427 | | - | then throw(((("Incorrect assets attached. Expected: " + aa) + " and ") + ab)) |
---|
428 | | - | else if ((bx == 0)) |
---|
429 | | - | then throw("Too small amount to replenish") |
---|
430 | | - | else if (!(aH)) |
---|
431 | | - | then ([ScriptTransfer(ay.caller, be, bf), ScriptTransfer(ay.caller, bh, bi)] ++ bb()) |
---|
432 | | - | else [Reissue(ak, bx, true), IntegerEntry(f, be), IntegerEntry(g, bh), IntegerEntry(k, bx), ScriptTransfer(ay.caller, bx, ak)] |
---|
433 | | - | } |
---|
434 | | - | } |
---|
435 | | - | else { |
---|
436 | | - | let bJ = fraction(fraction(ai, aq, be), ap, fraction(aj, aq, bh)) |
---|
437 | | - | let bK = fraction(be, aq, ai) |
---|
438 | | - | let bL = fraction(bh, aq, aj) |
---|
439 | | - | let bM = fraction(min([bK, bL]), al, aq) |
---|
440 | | - | if (!(Z)) |
---|
441 | | - | then throw("DApp is inactive at this moment") |
---|
442 | | - | else if (if ((0 > bG)) |
---|
443 | | - | then true |
---|
444 | | - | else (bG > ar)) |
---|
445 | | - | then throw(((("Slippage tolerance must be between 0 and " + toString(ar)) + " inclusively. Actual: ") + toString(bG))) |
---|
446 | | - | else if ((size(ay.payments) != 2)) |
---|
447 | | - | then throw("Two attached assets expected") |
---|
448 | | - | else if (if ((bf != ac)) |
---|
449 | | - | then true |
---|
450 | | - | else (bi != ad)) |
---|
451 | | - | then throw(((("Incorrect assets attached. Expected: " + aa) + " and ") + ab)) |
---|
452 | | - | else if (if ((((ap * (ar - bG)) / ar) > bJ)) |
---|
453 | | - | then true |
---|
454 | | - | else (bJ > ((ap * (ar + bG)) / ar))) |
---|
455 | | - | then throw("Incorrect assets amount: amounts must have the contract ratio") |
---|
456 | | - | else if ((bM == 0)) |
---|
457 | | - | then throw("Too small amount to replenish") |
---|
458 | | - | else if (!(aH)) |
---|
459 | | - | then ([ScriptTransfer(ay.caller, be, bf), ScriptTransfer(ay.caller, bh, bi)] ++ bb()) |
---|
460 | | - | else [IntegerEntry(f, (ai + be)), IntegerEntry(g, (aj + bh)), IntegerEntry(k, (al + bM)), Reissue(ak, bM, true), ScriptTransfer(ay.caller, bM, ak)] |
---|
461 | | - | } |
---|
462 | | - | } |
---|
463 | | - | |
---|
464 | | - | |
---|
465 | | - | |
---|
466 | | - | @Callable(ay) |
---|
467 | | - | func withdraw () = { |
---|
468 | | - | let bN = $Tuple2(ay.payments[0].amount, ay.payments[0].assetId) |
---|
469 | | - | let bO = bN._1 |
---|
470 | | - | let bP = bN._2 |
---|
471 | | - | let bQ = aP(fraction(bO, ai, al), ac, ad) |
---|
472 | | - | let bR = aP(fraction(bO, aj, al), ad, ac) |
---|
473 | | - | if (!(Z)) |
---|
474 | | - | then throw("DApp is inactive at this moment") |
---|
475 | | - | else if ((size(ay.payments) != 1)) |
---|
476 | | - | then throw("One attached payment expected") |
---|
477 | | - | else if ((bP != ak)) |
---|
478 | | - | then throw(("Incorrect asset attached. Expected: " + toBase58String(ak))) |
---|
479 | | - | else if (!(aH)) |
---|
480 | | - | then ([ScriptTransfer(ay.caller, bO, bP)] ++ bb()) |
---|
481 | | - | else if (if ((bQ > aD)) |
---|
482 | | - | then true |
---|
483 | | - | else (bR > aE)) |
---|
484 | | - | then aY(bQ, bR) |
---|
485 | | - | else [IntegerEntry(f, (ai - bQ)), IntegerEntry(g, (aj - bR)), IntegerEntry(k, (al - bO)), Burn(ak, bO), ScriptTransfer(ay.caller, bQ, ac), ScriptTransfer(ay.caller, bR, ad)] |
---|
486 | | - | } |
---|
487 | | - | |
---|
488 | | - | |
---|
489 | | - | |
---|
490 | | - | @Callable(ay) |
---|
491 | | - | func exchange (bS) = { |
---|
492 | | - | let bT = $Tuple2(ay.payments[0].amount, ay.payments[0].assetId) |
---|
493 | | - | let bO = bT._1 |
---|
494 | | - | let bP = bT._2 |
---|
495 | | - | func bU (bV,bW) = { |
---|
496 | | - | let bX = fraction(bW, bO, (bO + bV)) |
---|
497 | | - | let bY = fraction(bX, (ao - am), ao) |
---|
498 | | - | let bZ = fraction(bX, an, ao) |
---|
499 | | - | if ((bS > bY)) |
---|
500 | | - | then throw(((("Calculated amount to receive " + toString(bY)) + " is less than specified minimum ") + toString(bS))) |
---|
501 | | - | else $Tuple3(bX, bY, bZ) |
---|
502 | | - | } |
---|
503 | | - | |
---|
504 | | - | if (!(Z)) |
---|
505 | | - | then throw("DApp is inactive at this moment") |
---|
506 | | - | else if (if ((ai == 0)) |
---|
507 | | - | then true |
---|
508 | | - | else (aj == 0)) |
---|
509 | | - | then throw("Can't exchange with zero balance") |
---|
510 | | - | else if ((0 >= bS)) |
---|
511 | | - | then throw(("Minimal amount to receive must be positive. Actual: " + toString(bS))) |
---|
512 | | - | else if ((size(ay.payments) != 1)) |
---|
513 | | - | then throw("One attached payment expected") |
---|
514 | | - | else if (!(aH)) |
---|
515 | | - | then ([ScriptTransfer(ay.caller, bO, bP)] ++ bb()) |
---|
516 | | - | else if ((bP == ac)) |
---|
517 | | - | then { |
---|
518 | | - | let ca = ad |
---|
519 | | - | let cb = bU(ai, aj) |
---|
520 | | - | let bX = cb._1 |
---|
521 | | - | let bY = cb._2 |
---|
522 | | - | let bZ = cb._3 |
---|
523 | | - | let cc = (ai + bO) |
---|
524 | | - | let cd = ((aj - bY) - bZ) |
---|
525 | | - | if (if ((az >= cc)) |
---|
526 | | - | then true |
---|
527 | | - | else (aA >= cd)) |
---|
528 | | - | then aV(bY, aE, ah) |
---|
529 | | - | else [IntegerEntry(f, cc), IntegerEntry(g, cd), ScriptTransfer(ay.caller, bY, ca), ScriptTransfer(J, bZ, ca)] |
---|
530 | | - | } |
---|
531 | | - | else if ((bP == ad)) |
---|
532 | | - | then { |
---|
533 | | - | let ca = ac |
---|
534 | | - | let ce = bU(aj, ai) |
---|
535 | | - | let bX = ce._1 |
---|
536 | | - | let bY = ce._2 |
---|
537 | | - | let bZ = ce._3 |
---|
538 | | - | let cc = ((ai - bY) - bZ) |
---|
539 | | - | let cd = (aj + bO) |
---|
540 | | - | if (if ((az >= cc)) |
---|
541 | | - | then true |
---|
542 | | - | else (aA >= cd)) |
---|
543 | | - | then aV(bY, aD, ae) |
---|
544 | | - | else [IntegerEntry(f, cc), IntegerEntry(g, cd), ScriptTransfer(ay.caller, bY, ca), ScriptTransfer(J, bZ, ca)] |
---|
545 | | - | } |
---|
546 | | - | else throw(((("Incorrect asset attached. Expected: " + aa) + " or ") + ab)) |
---|
547 | | - | } |
---|
548 | | - | |
---|
549 | | - | |
---|
550 | | - | |
---|
551 | | - | @Callable(ay) |
---|
552 | | - | func shutdown () = if (!(Z)) |
---|
553 | | - | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, n), "the cause wasn't specified"))) |
---|
554 | | - | else if (!(containsElement([E, F, G, H], ay.callerPublicKey))) |
---|
555 | | - | then throw("Only admin can call this function") |
---|
556 | | - | else aN("Paused by admin") |
---|
557 | | - | |
---|
558 | | - | |
---|
559 | | - | |
---|
560 | | - | @Callable(ay) |
---|
561 | | - | func activate () = if (Z) |
---|
562 | | - | then throw("DApp is already active") |
---|
563 | | - | else if (!(containsElement([E, F, G, H], ay.callerPublicKey))) |
---|
564 | | - | then throw("Only admin can call this function") |
---|
565 | | - | else [BooleanEntry(c, true), DeleteEntry(n)] |
---|
566 | | - | |
---|
567 | | - | |
---|
568 | | - | |
---|
569 | | - | @Callable(ay) |
---|
570 | | - | func takeIntoAccountExtraFunds (cf) = { |
---|
571 | | - | let cg = (aF - ai) |
---|
572 | | - | let ch = (aG - aj) |
---|
573 | | - | let ci = (cg - (if ((ac == unit)) |
---|
574 | | - | then cf |
---|
575 | | - | else 0)) |
---|
576 | | - | let cj = (ch - (if ((ad == unit)) |
---|
577 | | - | then cf |
---|
578 | | - | else 0)) |
---|
579 | | - | if (!(Z)) |
---|
580 | | - | then throw("DApp is inactive at this moment") |
---|
581 | | - | else if ((ay.caller != this)) |
---|
582 | | - | then throw("Only the DApp itself can call this function") |
---|
583 | | - | else if ((0 > cf)) |
---|
584 | | - | then throw(("Argument 'amountLeave' cannot be negative. Actual: " + toString(cf))) |
---|
585 | | - | else if (if ((0 > cg)) |
---|
586 | | - | then true |
---|
587 | | - | else (0 > ch)) |
---|
588 | | - | then aN("Enroll amount negative") |
---|
589 | | - | else if (if ((0 > ci)) |
---|
590 | | - | then true |
---|
591 | | - | else (0 > cj)) |
---|
592 | | - | then throw("Too large amountLeave") |
---|
593 | | - | else [IntegerEntry(f, (ai + ci)), IntegerEntry(g, (aj + cj)), IntegerEntry(("last_income_" + aa), ci), IntegerEntry(("last_income_" + ab), cj)] |
---|
| 41 | + | else nil |
---|