303 | | - | |
---|
304 | | - | func ce (cf,cg,ch,ci) = { |
---|
305 | | - | let cj = H(ch, cf) |
---|
306 | | - | let ck = H(ci, cg) |
---|
307 | | - | bP(ck, cj) |
---|
308 | | - | } |
---|
309 | | - | |
---|
310 | | - | |
---|
311 | | - | func cl (ch,ci,cm) = { |
---|
312 | | - | let cn = bo |
---|
313 | | - | let co = bp |
---|
314 | | - | let cp = ce(cn, co, ch, ci) |
---|
315 | | - | let bR = H(ch, cn) |
---|
316 | | - | let bQ = H(ci, co) |
---|
317 | | - | let cq = H(cm, a) |
---|
318 | | - | let cr = bP(bR, cq) |
---|
319 | | - | let cs = bP(bQ, cq) |
---|
320 | | - | [cp, cr, cs] |
---|
321 | | - | } |
---|
322 | | - | |
---|
323 | | - | |
---|
324 | | - | func ct (ch,ci,cm) = { |
---|
325 | | - | let cu = cl(ch, ci, cm) |
---|
326 | | - | [L(cu[0], a), L(cu[1], a), L(cu[2], a)] |
---|
327 | | - | } |
---|
328 | | - | |
---|
329 | | - | |
---|
330 | | - | func cv (cw,ao) = { |
---|
331 | | - | let cx = if ((ao == 0)) |
---|
332 | | - | then 0 |
---|
333 | | - | else fraction(cw, ao, a) |
---|
334 | | - | $Tuple2((cw - cx), cx) |
---|
335 | | - | } |
---|
336 | | - | |
---|
337 | | - | |
---|
338 | | - | func cy (cz) = { |
---|
339 | | - | let cA = cz[0] |
---|
340 | | - | let cB = cz[1] |
---|
341 | | - | let cC = (cA + cB) |
---|
342 | | - | if ((cC == e)) |
---|
343 | | - | then e |
---|
344 | | - | else { |
---|
345 | | - | let cD = parseIntValue(aU) |
---|
346 | | - | let cE = (cD * 2) |
---|
347 | | - | let cu = fraction(cA, cB, f) |
---|
348 | | - | let cF = fraction(cu, i, f) |
---|
349 | | - | let cG = fraction(toBigInt(cE), cC, f) |
---|
350 | | - | let cH = toBigInt((cE - 1)) |
---|
351 | | - | func cI (cJ) = { |
---|
352 | | - | let cK = fraction(cJ, cJ, f) |
---|
353 | | - | let cL = fraction(cK, cJ, f) |
---|
354 | | - | let cM = fraction(cL, f, cF) |
---|
355 | | - | fraction((cG + fraction(cM, g, f)), cJ, (fraction(cH, cJ, f) + fraction(h, cM, f))) |
---|
356 | | - | } |
---|
357 | | - | |
---|
358 | | - | func cN (cO,cP) = if (cO._2) |
---|
359 | | - | then cO |
---|
360 | | - | else { |
---|
361 | | - | let cJ = cO._1 |
---|
362 | | - | let cQ = cI(cJ) |
---|
363 | | - | let cR = (cQ - value(cJ)) |
---|
364 | | - | let cS = if ((e > cR)) |
---|
365 | | - | then -(cR) |
---|
366 | | - | else cR |
---|
367 | | - | if ((f >= cS)) |
---|
368 | | - | then $Tuple2(cQ, true) |
---|
369 | | - | else $Tuple2(cQ, false) |
---|
370 | | - | } |
---|
371 | | - | |
---|
372 | | - | let cT = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] |
---|
373 | | - | let cU = { |
---|
374 | | - | let cV = cT |
---|
375 | | - | let cW = size(cV) |
---|
376 | | - | let cX = $Tuple2(cC, false) |
---|
377 | | - | func cY (cZ,da) = if ((da >= cW)) |
---|
378 | | - | then cZ |
---|
379 | | - | else cN(cZ, cV[da]) |
---|
380 | | - | |
---|
381 | | - | func db (cZ,da) = if ((da >= cW)) |
---|
382 | | - | then cZ |
---|
383 | | - | else throw("List size exceeds 18") |
---|
384 | | - | |
---|
385 | | - | db(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cX, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18) |
---|
386 | | - | } |
---|
387 | | - | let cJ = cU._1 |
---|
388 | | - | let dc = cU._2 |
---|
389 | | - | if (dc) |
---|
390 | | - | then cJ |
---|
391 | | - | else throw(("D calculation error, D = " + toString(cJ))) |
---|
392 | | - | } |
---|
393 | | - | } |
---|
394 | | - | |
---|
395 | | - | |
---|
396 | | - | func dd (de,df,dg,dh) = { |
---|
397 | | - | let di = bl |
---|
398 | | - | let dj = toBase58String(value(bm)) |
---|
399 | | - | let dk = toBase58String(value(bn)) |
---|
400 | | - | let dl = bo |
---|
401 | | - | let dm = bp |
---|
402 | | - | let dn = toString(bk) |
---|
403 | | - | let do = valueOrErrorMessage(assetInfo(di), "Wrong LP id").quantity |
---|
404 | | - | if ((toBase58String(di) != df)) |
---|
405 | | - | then throw("Wrong pmt asset") |
---|
406 | | - | else { |
---|
407 | | - | let dp = bN(dj) |
---|
408 | | - | let dq = H(dp, dl) |
---|
409 | | - | let dr = bN(dk) |
---|
410 | | - | let ds = H(dr, dm) |
---|
411 | | - | let dt = bP(ds, dq) |
---|
412 | | - | let du = L(dt, a) |
---|
413 | | - | let dv = H(dg, a) |
---|
414 | | - | let dw = H(do, a) |
---|
415 | | - | let dx = fraction(dq, dv, dw) |
---|
416 | | - | let dy = fraction(ds, dv, dw) |
---|
417 | | - | let dz = O(dx, dl, FLOOR) |
---|
418 | | - | let dA = O(dy, dm, FLOOR) |
---|
419 | | - | let dB = if ((de == "")) |
---|
420 | | - | then nil |
---|
421 | | - | else [ScriptTransfer(dh, dz, if ((dj == "WAVES")) |
---|
422 | | - | then unit |
---|
423 | | - | else fromBase58String(dj)), ScriptTransfer(dh, dA, if ((dk == "WAVES")) |
---|
424 | | - | then unit |
---|
425 | | - | else fromBase58String(dk)), StringEntry(ai(toString(dh), de), bJ(dz, dA, dg, du, height, lastBlock.timestamp)), IntegerEntry(ab(), du), IntegerEntry(ac(height, lastBlock.timestamp), du)] |
---|
426 | | - | $Tuple10(dz, dA, dj, dk, dp, dr, do, dt, dn, dB) |
---|
427 | | - | } |
---|
428 | | - | } |
---|
429 | | - | |
---|
430 | | - | |
---|
431 | | - | func dC (de,bW,dD,dE,dF,dG,dh,dH,dI,dJ,dK,dL,dM) = { |
---|
432 | | - | let di = bl |
---|
433 | | - | let dN = toBase58String(value(bm)) |
---|
434 | | - | let dO = toBase58String(value(bn)) |
---|
435 | | - | let dP = bq |
---|
436 | | - | let dQ = br |
---|
437 | | - | let dR = bo |
---|
438 | | - | let dS = bp |
---|
439 | | - | let dn = toString(bk) |
---|
440 | | - | let dT = valueOrErrorMessage(assetInfo(di), "Wr lp as").quantity |
---|
441 | | - | let dp = if (dH) |
---|
442 | | - | then bN(dN) |
---|
443 | | - | else if (if (dJ) |
---|
444 | | - | then (dM == dN) |
---|
445 | | - | else false) |
---|
446 | | - | then (bN(dN) - dL) |
---|
447 | | - | else if (dJ) |
---|
448 | | - | then bN(dN) |
---|
449 | | - | else (bN(dN) - dD) |
---|
450 | | - | let dr = if (dH) |
---|
451 | | - | then bN(dO) |
---|
452 | | - | else if (if (dJ) |
---|
453 | | - | then (dM == dO) |
---|
454 | | - | else false) |
---|
455 | | - | then (bN(dO) - dL) |
---|
456 | | - | else if (dJ) |
---|
457 | | - | then bN(dO) |
---|
458 | | - | else (bN(dO) - dF) |
---|
459 | | - | let dU = H(dD, dR) |
---|
460 | | - | let dV = H(dF, dS) |
---|
461 | | - | let dW = bP(dV, dU) |
---|
462 | | - | let dq = H(dp, dR) |
---|
463 | | - | let ds = H(dr, dS) |
---|
464 | | - | let cb = cy([dq, ds]) |
---|
465 | | - | let dX = if ((dT == 0)) |
---|
466 | | - | then { |
---|
467 | | - | let ca = cy([(dq + dU), (ds + dV)]) |
---|
468 | | - | let dY = if ((ca > cb)) |
---|
469 | | - | then true |
---|
470 | | - | else throw("D1 should be greater than D0") |
---|
471 | | - | if ((dY == dY)) |
---|
472 | | - | then { |
---|
473 | | - | let dt = d |
---|
474 | | - | let dZ = d |
---|
475 | | - | let cq = ca |
---|
476 | | - | $Tuple5(L(cq, a), L(dU, dR), L(dV, dS), bP((ds + dV), (dq + dU)), dZ) |
---|
477 | | - | } |
---|
478 | | - | else throw("Strict value is not equal to itself.") |
---|
479 | | - | } |
---|
480 | | - | else { |
---|
481 | | - | let dt = bP(ds, dq) |
---|
482 | | - | let ea = fraction(W((dt - dW)), c, dt) |
---|
483 | | - | let dZ = H(bW, a) |
---|
484 | | - | if (if (if (dK) |
---|
485 | | - | then (dt != d) |
---|
486 | | - | else false) |
---|
487 | | - | then (ea > dZ) |
---|
488 | | - | else false) |
---|
489 | | - | then throw(((("Price slippage " + toString(ea)) + " > ") + toString(dZ))) |
---|
490 | | - | else { |
---|
491 | | - | let eb = H(dT, a) |
---|
492 | | - | let ec = fraction(dU, bS(ds, dq, CEILING), c, CEILING) |
---|
493 | | - | let ed = fraction(dV, c, bS(ds, dq, FLOOR), CEILING) |
---|
494 | | - | let ee = if ((ec > dV)) |
---|
495 | | - | then $Tuple2(ed, dV) |
---|
496 | | - | else $Tuple2(dU, ec) |
---|
497 | | - | let ef = ee._1 |
---|
498 | | - | let eg = ee._2 |
---|
499 | | - | let ca = cy([(dq + ef), (ds + eg)]) |
---|
500 | | - | let dY = if ((ca > cb)) |
---|
501 | | - | then true |
---|
502 | | - | else throw("D1 should be greater than D0") |
---|
503 | | - | if ((dY == dY)) |
---|
504 | | - | then { |
---|
505 | | - | let cq = fraction(eb, (ca - cb), cb) |
---|
506 | | - | $Tuple5(O(cq, a, FLOOR), O(ef, dR, CEILING), O(eg, dS, CEILING), dt, dZ) |
---|
507 | | - | } |
---|
508 | | - | else throw("Strict value is not equal to itself.") |
---|
509 | | - | } |
---|
510 | | - | } |
---|
511 | | - | let eh = dX._1 |
---|
512 | | - | let ei = dX._2 |
---|
513 | | - | let ej = dX._3 |
---|
514 | | - | let du = L(dX._4, a) |
---|
515 | | - | let ek = L(dX._5, a) |
---|
516 | | - | if ((0 >= eh)) |
---|
517 | | - | then throw("LP <= 0") |
---|
518 | | - | else { |
---|
519 | | - | let el = if (!(dI)) |
---|
520 | | - | then 0 |
---|
521 | | - | else eh |
---|
522 | | - | let em = (dD - ei) |
---|
523 | | - | let en = (dF - ej) |
---|
524 | | - | let eo = if (if (dJ) |
---|
525 | | - | then (dM == dN) |
---|
526 | | - | else false) |
---|
527 | | - | then $Tuple2(dL, 0) |
---|
528 | | - | else if (if (dJ) |
---|
529 | | - | then (dM == dO) |
---|
530 | | - | else false) |
---|
531 | | - | then $Tuple2(0, dL) |
---|
532 | | - | else $Tuple2(ei, ej) |
---|
533 | | - | let ep = eo._1 |
---|
534 | | - | let eq = eo._2 |
---|
535 | | - | let er = [IntegerEntry(ab(), du), IntegerEntry(ac(height, lastBlock.timestamp), du), StringEntry(af(dh, de), by(ep, eq, el, du, bW, ek, height, lastBlock.timestamp, em, en))] |
---|
536 | | - | $Tuple13(eh, el, du, dp, dr, dT, di, dn, er, em, en, dE, dG) |
---|
537 | | - | } |
---|
538 | | - | } |
---|
539 | | - | |
---|
540 | | - | |
---|
541 | | - | func es (cz,cP,et) = { |
---|
542 | | - | let eu = g |
---|
543 | | - | let ev = cz[if ((cP == 0)) |
---|
544 | | - | then 1 |
---|
545 | | - | else 0] |
---|
546 | | - | let ew = parseBigIntValue(l) |
---|
547 | | - | let cD = (parseBigIntValue(aU) * ew) |
---|
548 | | - | let cC = ev |
---|
549 | | - | let cE = (cD * eu) |
---|
550 | | - | let ex = (((((et * et) / (ev * eu)) * et) * ew) / (cE * eu)) |
---|
551 | | - | let ey = ((cC + ((et * ew) / cE)) - et) |
---|
552 | | - | func cN (cO,ez) = { |
---|
553 | | - | let eA = cO |
---|
554 | | - | let eB = eA._1 |
---|
555 | | - | let dc = eA._2 |
---|
556 | | - | if ((dc != unit)) |
---|
557 | | - | then cO |
---|
558 | | - | else { |
---|
559 | | - | let eC = (((eB * eB) + ex) / ((g * eB) + ey)) |
---|
560 | | - | let eD = X((eC - value(eB))) |
---|
561 | | - | if ((f >= eD)) |
---|
562 | | - | then $Tuple2(eC, ez) |
---|
563 | | - | else $Tuple2(eC, unit) |
---|
564 | | - | } |
---|
565 | | - | } |
---|
566 | | - | |
---|
567 | | - | let cT = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] |
---|
568 | | - | let eE = { |
---|
569 | | - | let cV = cT |
---|
570 | | - | let cW = size(cV) |
---|
571 | | - | let cX = $Tuple2(et, unit) |
---|
572 | | - | func cY (cZ,da) = if ((da >= cW)) |
---|
573 | | - | then cZ |
---|
574 | | - | else cN(cZ, cV[da]) |
---|
575 | | - | |
---|
576 | | - | func db (cZ,da) = if ((da >= cW)) |
---|
577 | | - | then cZ |
---|
578 | | - | else throw("List size exceeds 15") |
---|
579 | | - | |
---|
580 | | - | db(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cX, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) |
---|
581 | | - | } |
---|
582 | | - | let eB = eE._1 |
---|
583 | | - | let dc = eE._2 |
---|
584 | | - | if ((dc != unit)) |
---|
585 | | - | then eB |
---|
586 | | - | else throw(("Y calculation error, Y = " + toString(eB))) |
---|
587 | | - | } |
---|
588 | | - | |
---|
589 | | - | |
---|
590 | | - | func eF (eG,eH,eI) = { |
---|
591 | | - | let eJ = fraction(cy([K(eG, toBigInt(bo)), K(eH, toBigInt(bp))]), c, eI) |
---|
592 | | - | if ((eI == e)) |
---|
593 | | - | then e |
---|
594 | | - | else eJ |
---|
595 | | - | } |
---|
596 | | - | |
---|
597 | | - | |
---|
598 | | - | func eK (eL,eM,eN) = { |
---|
599 | | - | let eO = (toBigInt(bN(be(bm))) - eL) |
---|
600 | | - | let eP = (toBigInt(bN(be(bn))) - eM) |
---|
601 | | - | let eQ = (toBigInt(value(assetInfo(bl)).quantity) - eN) |
---|
602 | | - | let eR = eF(eO, eP, eQ) |
---|
603 | | - | eR |
---|
604 | | - | } |
---|
605 | | - | |
---|
606 | | - | |
---|
607 | | - | func eS (eT,eU,eN) = { |
---|
608 | | - | let eO = (bN(be(bm)) + eT) |
---|
609 | | - | let eP = (bN(be(bn)) + eU) |
---|
610 | | - | let eQ = (value(assetInfo(bl)).quantity + eN) |
---|
611 | | - | let eJ = eF(toBigInt(eO), toBigInt(eP), toBigInt(eQ)) |
---|
612 | | - | let eV = [IntegerEntry(aq, height), StringEntry(ap, toString(eJ))] |
---|
613 | | - | $Tuple2(eV, eJ) |
---|
614 | | - | } |
---|
615 | | - | |
---|
616 | | - | |
---|
617 | | - | func eW (eX,eJ) = if ((eJ >= eX)) |
---|
618 | | - | then true |
---|
619 | | - | else aN("updated DLp lower than current DLp") |
---|
620 | | - | |
---|
621 | | - | |
---|
622 | | - | func eY (eZ) = { |
---|
623 | | - | let eO = bN(be(bm)) |
---|
624 | | - | let eP = bN(be(bn)) |
---|
625 | | - | let fa = eZ.amount |
---|
626 | | - | let fb = fraction(eZ.amount, eZ.price, a, FLOOR) |
---|
627 | | - | let fc = if ((eZ.orderType == Buy)) |
---|
628 | | - | then $Tuple2(fa, -(fb)) |
---|
629 | | - | else $Tuple2(-(fa), fb) |
---|
630 | | - | let eT = fc._1 |
---|
631 | | - | let eU = fc._2 |
---|
632 | | - | if (if (if (aV()) |
---|
633 | | - | then true |
---|
634 | | - | else (bk == r)) |
---|
635 | | - | then true |
---|
636 | | - | else (bk == s)) |
---|
637 | | - | then throw("Admin blocked") |
---|
638 | | - | else if (if ((eZ.assetPair.amountAsset != bm)) |
---|
639 | | - | then true |
---|
640 | | - | else (eZ.assetPair.priceAsset != bn)) |
---|
641 | | - | then throw("Wr assets") |
---|
642 | | - | else { |
---|
643 | | - | let fd = parseBigIntValue(valueOrElse(getString(this, ap), "0")) |
---|
644 | | - | let fe = eS(eT, eU, 0) |
---|
645 | | - | let ff = fe._1 |
---|
646 | | - | let fg = fe._2 |
---|
647 | | - | let fh = (fg >= fd) |
---|
648 | | - | let fi = makeString(["dLp=", toString(fd), " dLpNew=", toString(fg), " amountAssetBalance=", toString(eO), " priceAssetBalance=", toString(eP), " amountAssetBalanceDelta=", toString(eT), " priceAssetBalanceDelta=", toString(eU), " height=", toString(height)], "") |
---|
649 | | - | $Tuple2(fh, fi) |
---|
650 | | - | } |
---|
651 | | - | } |
---|
652 | | - | |
---|
653 | | - | |
---|
654 | | - | func fj (cP) = if ((size(cP.payments) != 1)) |
---|
655 | | - | then throw("1 pmnt exp") |
---|
656 | | - | else { |
---|
657 | | - | let fk = value(cP.payments[0]) |
---|
658 | | - | let df = value(fk.assetId) |
---|
659 | | - | let dL = fk.amount |
---|
660 | | - | let dX = dd(toBase58String(cP.transactionId), toBase58String(df), dL, cP.caller) |
---|
661 | | - | let dz = dX._1 |
---|
662 | | - | let dA = dX._2 |
---|
663 | | - | let dn = parseIntValue(dX._9) |
---|
664 | | - | let dB = dX._10 |
---|
665 | | - | if (if (aV()) |
---|
666 | | - | then true |
---|
667 | | - | else (dn == s)) |
---|
668 | | - | then throw(("Admin blocked: " + toString(dn))) |
---|
669 | | - | else $Tuple5(dz, dA, dL, df, dB) |
---|
670 | | - | } |
---|
671 | | - | |
---|
672 | | - | |
---|
673 | | - | func fl (fm,ah,fn,fo,bW,dI,dJ,dK,dL,dM) = { |
---|
674 | | - | let dX = dC(ah, bW, value(fn).amount, value(fn).assetId, value(fo).amount, value(fo).assetId, fm, (ah == ""), dI, dJ, dK, dL, dM) |
---|
675 | | - | let dn = parseIntValue(dX._8) |
---|
676 | | - | if (if (if (aV()) |
---|
677 | | - | then true |
---|
678 | | - | else (dn == q)) |
---|
679 | | - | then true |
---|
680 | | - | else (dn == s)) |
---|
681 | | - | then throw(("Blocked:" + toString(dn))) |
---|
682 | | - | else dX |
---|
683 | | - | } |
---|
684 | | - | |
---|
685 | | - | |
---|
686 | | - | func fp (fq,df,dh,ah,fr) = { |
---|
687 | | - | let dj = toBase58String(value(bm)) |
---|
688 | | - | let dk = toBase58String(value(bn)) |
---|
689 | | - | let di = bl |
---|
690 | | - | let dR = bo |
---|
691 | | - | let dS = bp |
---|
692 | | - | let eQ = toBigInt(valueOrErrorMessage(assetInfo(di), "invalid lp asset").quantity) |
---|
693 | | - | let fs = if ((eQ > e)) |
---|
694 | | - | then true |
---|
695 | | - | else throw("initial deposit requires all coins") |
---|
696 | | - | if ((fs == fs)) |
---|
697 | | - | then { |
---|
698 | | - | let dp = bN(dj) |
---|
699 | | - | let dr = bN(dk) |
---|
700 | | - | let ft = if ((ah == "")) |
---|
701 | | - | then $Tuple2(dp, dr) |
---|
702 | | - | else if ((df == dj)) |
---|
703 | | - | then if ((fq > dp)) |
---|
704 | | - | then throw("invalid payment amount") |
---|
705 | | - | else $Tuple2((dp - fq), dr) |
---|
706 | | - | else if ((df == dk)) |
---|
707 | | - | then if ((fq > dr)) |
---|
708 | | - | then throw("invalid payment amount") |
---|
709 | | - | else $Tuple2(dp, (dr - fq)) |
---|
710 | | - | else throw("wrong pmtAssetId") |
---|
711 | | - | let fu = ft._1 |
---|
712 | | - | let fv = ft._2 |
---|
713 | | - | let fw = if ((df == dj)) |
---|
714 | | - | then $Tuple2(fq, 0) |
---|
715 | | - | else if ((df == dk)) |
---|
716 | | - | then $Tuple2(0, fq) |
---|
717 | | - | else throw("invalid payment") |
---|
718 | | - | let fx = fw._1 |
---|
719 | | - | let fy = fw._2 |
---|
720 | | - | let fz = if (fr) |
---|
721 | | - | then $Tuple3(cv(fx, aR)._1, cv(fy, aR)._1, cv(fq, aR)._2) |
---|
722 | | - | else $Tuple3(fx, fy, 0) |
---|
723 | | - | let fA = fz._1 |
---|
724 | | - | let fB = fz._2 |
---|
725 | | - | let cx = fz._3 |
---|
726 | | - | let fC = (fu + fA) |
---|
727 | | - | let fD = (fv + fB) |
---|
728 | | - | let cb = cy([H(fu, bo), H(fv, bp)]) |
---|
729 | | - | let ca = cy([H(fC, bo), H(fD, bp)]) |
---|
730 | | - | let dY = if ((ca > cb)) |
---|
731 | | - | then true |
---|
732 | | - | else throw() |
---|
733 | | - | if ((dY == dY)) |
---|
734 | | - | then { |
---|
735 | | - | let fE = fraction(eQ, (ca - cb), cb, FLOOR) |
---|
736 | | - | let du = L(bP(H(fD, dS), H(fC, dR)), a) |
---|
737 | | - | let er = [IntegerEntry(ab(), du), IntegerEntry(ac(height, lastBlock.timestamp), du), StringEntry(af(dh, ah), by(fx, fy, toInt(fE), du, 0, 0, height, lastBlock.timestamp, 0, 0))] |
---|
738 | | - | let fF = fraction(fv, a, fu) |
---|
739 | | - | let fG = fraction(fq, a, (fF + a)) |
---|
740 | | - | let fH = (fq - fG) |
---|
741 | | - | let fI = fraction(eQ, toBigInt(fH), toBigInt(fv)) |
---|
742 | | - | let fJ = toInt(fraction((fE - fI), b, fI)) |
---|
743 | | - | $Tuple4(toInt(fE), er, cx, fJ) |
---|
744 | | - | } |
---|
745 | | - | else throw("Strict value is not equal to itself.") |
---|
746 | | - | } |
---|
747 | | - | else throw("Strict value is not equal to itself.") |
---|
748 | | - | } |
---|
749 | | - | |
---|
750 | | - | |
---|
751 | | - | func fK (fL,fM,fN,fm,fO,fP) = { |
---|
752 | | - | let di = toBase58String(value(bl)) |
---|
753 | | - | let dj = toBase58String(value(bm)) |
---|
754 | | - | let dk = toBase58String(value(bn)) |
---|
755 | | - | let fQ = bo |
---|
756 | | - | let fR = bp |
---|
757 | | - | let fS = bk |
---|
758 | | - | let dh = if ((fm == bx)) |
---|
759 | | - | then fO |
---|
760 | | - | else fm |
---|
761 | | - | let fk = value(fN[0]) |
---|
762 | | - | let df = value(fk.assetId) |
---|
763 | | - | let dL = fk.amount |
---|
764 | | - | let eR = eK(e, e, e) |
---|
765 | | - | if ((eR == eR)) |
---|
766 | | - | then { |
---|
767 | | - | let de = toBase58String(fP) |
---|
768 | | - | if ((di != toBase58String(df))) |
---|
769 | | - | then throw("Wrong LP") |
---|
770 | | - | else { |
---|
771 | | - | let dp = bN(dj) |
---|
772 | | - | let dr = bN(dk) |
---|
773 | | - | let fT = { |
---|
774 | | - | let aS = invoke(this, "getOneTknV2READONLY", [fL, dL], nil) |
---|
775 | | - | if ($isInstanceOf(aS, "(Int, Int)")) |
---|
776 | | - | then aS |
---|
777 | | - | else throw(($getType(aS) + " couldn't be cast to (Int, Int)")) |
---|
778 | | - | } |
---|
779 | | - | if ((fT == fT)) |
---|
780 | | - | then { |
---|
781 | | - | let cx = fT._2 |
---|
782 | | - | let fU = fT._1 |
---|
783 | | - | let fV = if (if ((fM > 0)) |
---|
784 | | - | then (fM > fU) |
---|
785 | | - | else false) |
---|
786 | | - | then aN(makeString(["amount to receive is less than ", toString(fM)], "")) |
---|
787 | | - | else fU |
---|
788 | | - | let fW = if ((fL == dj)) |
---|
789 | | - | then $Tuple4(fV, 0, ((dp - fV) - cx), dr) |
---|
790 | | - | else if ((fL == dk)) |
---|
791 | | - | then $Tuple4(0, fV, dp, ((dr - fV) - cx)) |
---|
792 | | - | else throw("invalid out asset id") |
---|
793 | | - | let fX = fW._1 |
---|
794 | | - | let fY = fW._2 |
---|
795 | | - | let fC = fW._3 |
---|
796 | | - | let fD = fW._4 |
---|
797 | | - | let fZ = bP(H(fD, fR), H(fC, fQ)) |
---|
798 | | - | let ga = L(fZ, a) |
---|
799 | | - | let gb = if ((fL == "WAVES")) |
---|
800 | | - | then unit |
---|
801 | | - | else fromBase58String(fL) |
---|
802 | | - | let gc = if ((cx > 0)) |
---|
803 | | - | then [ScriptTransfer(aX, cx, gb)] |
---|
804 | | - | else nil |
---|
805 | | - | let dB = ([ScriptTransfer(dh, fV, gb), StringEntry(ai(toString(dh), de), bJ(fX, fY, dL, ga, height, lastBlock.timestamp)), IntegerEntry(ab(), ga), IntegerEntry(ac(height, lastBlock.timestamp), ga)] ++ gc) |
---|
806 | | - | if ((dB == dB)) |
---|
807 | | - | then { |
---|
808 | | - | let gd = invoke(aQ, "burn", [dL], [AttachedPayment(df, dL)]) |
---|
809 | | - | if ((gd == gd)) |
---|
810 | | - | then { |
---|
811 | | - | let ge = { |
---|
812 | | - | let gf = if ((this == aX)) |
---|
813 | | - | then 0 |
---|
814 | | - | else cx |
---|
815 | | - | let gg = if ((bc(fL) == bm)) |
---|
816 | | - | then true |
---|
817 | | - | else false |
---|
818 | | - | if (gg) |
---|
819 | | - | then $Tuple2(-((fU + gf)), 0) |
---|
820 | | - | else $Tuple2(0, -((fU + gf))) |
---|
821 | | - | } |
---|
822 | | - | let eT = ge._1 |
---|
823 | | - | let eU = ge._2 |
---|
824 | | - | let gh = eS(eT, eU, 0) |
---|
825 | | - | let gi = gh._1 |
---|
826 | | - | let eJ = gh._2 |
---|
827 | | - | let gj = eW(eR, eJ) |
---|
828 | | - | if ((gj == gj)) |
---|
829 | | - | then $Tuple2((dB ++ gi), fV) |
---|
830 | | - | else throw("Strict value is not equal to itself.") |
---|
831 | | - | } |
---|
832 | | - | else throw("Strict value is not equal to itself.") |
---|
833 | | - | } |
---|
834 | | - | else throw("Strict value is not equal to itself.") |
---|
835 | | - | } |
---|
836 | | - | else throw("Strict value is not equal to itself.") |
---|
837 | | - | } |
---|
838 | | - | } |
---|
839 | | - | else throw("Strict value is not equal to itself.") |
---|
840 | | - | } |
---|
841 | | - | |
---|
842 | | - | |
---|
843 | | - | func gk () = { |
---|
844 | | - | let gl = getString(Z()) |
---|
845 | | - | if ($isInstanceOf(gl, "String")) |
---|
846 | | - | then { |
---|
847 | | - | let cC = gl |
---|
848 | | - | fromBase58String(cC) |
---|
849 | | - | } |
---|
850 | | - | else if ($isInstanceOf(gl, "Unit")) |
---|
851 | | - | then unit |
---|
852 | | - | else throw("Match error") |
---|
853 | | - | } |
---|
854 | | - | |
---|
855 | | - | |
---|
856 | | - | func gm () = { |
---|
857 | | - | let gl = getString(aa()) |
---|
858 | | - | if ($isInstanceOf(gl, "String")) |
---|
859 | | - | then { |
---|
860 | | - | let cC = gl |
---|
861 | | - | fromBase58String(cC) |
---|
862 | | - | } |
---|
863 | | - | else if ($isInstanceOf(gl, "Unit")) |
---|
864 | | - | then unit |
---|
865 | | - | else throw("Match error") |
---|
866 | | - | } |
---|
867 | | - | |
---|
868 | | - | |
---|
869 | | - | let gn = throw("Permission denied") |
---|
870 | | - | |
---|
871 | | - | func go (cP) = { |
---|
872 | | - | let gl = gk() |
---|
873 | | - | if ($isInstanceOf(gl, "ByteVector")) |
---|
874 | | - | then { |
---|
875 | | - | let gp = gl |
---|
876 | | - | (cP.callerPublicKey == gp) |
---|
877 | | - | } |
---|
878 | | - | else if ($isInstanceOf(gl, "Unit")) |
---|
879 | | - | then (cP.caller == this) |
---|
880 | | - | else throw("Match error") |
---|
881 | | - | } |
---|
882 | | - | |
---|
883 | | - | |
---|
884 | | - | func gq (cP) = { |
---|
885 | | - | let gl = gk() |
---|
886 | | - | if ($isInstanceOf(gl, "ByteVector")) |
---|
887 | | - | then { |
---|
888 | | - | let gp = gl |
---|
889 | | - | if ((cP.callerPublicKey == gp)) |
---|
890 | | - | then true |
---|
891 | | - | else gn |
---|
892 | | - | } |
---|
893 | | - | else if ($isInstanceOf(gl, "Unit")) |
---|
894 | | - | then if ((cP.caller == this)) |
---|
895 | | - | then true |
---|
896 | | - | else gn |
---|
897 | | - | else throw("Match error") |
---|
898 | | - | } |
---|
899 | | - | |
---|
900 | | - | |
---|
901 | | - | func gr (gs,et,gt) = { |
---|
902 | | - | let bg = aY() |
---|
903 | | - | let dj = bg[w] |
---|
904 | | - | let dk = bg[x] |
---|
905 | | - | let eu = g |
---|
906 | | - | let ew = parseBigIntValue(l) |
---|
907 | | - | let cD = (parseBigIntValue(aU) * ew) |
---|
908 | | - | let cz = if ((gs == false)) |
---|
909 | | - | then [(toBigInt(bN(dj)) + gt), toBigInt(bN(dk))] |
---|
910 | | - | else [(toBigInt(bN(dk)) + gt), toBigInt(bN(dj))] |
---|
911 | | - | let ev = cz[0] |
---|
912 | | - | let cC = ev |
---|
913 | | - | let cE = (cD * eu) |
---|
914 | | - | let ex = (((((et * et) / (ev * eu)) * et) * ew) / (cE * eu)) |
---|
915 | | - | let ey = ((cC + ((et * ew) / cE)) - et) |
---|
916 | | - | func cN (cO,ez) = { |
---|
917 | | - | let gu = cO |
---|
918 | | - | let eB = gu._1 |
---|
919 | | - | let dc = gu._2 |
---|
920 | | - | if ((dc != unit)) |
---|
921 | | - | then cO |
---|
922 | | - | else { |
---|
923 | | - | let eC = (((eB * eB) + ex) / ((g * eB) + ey)) |
---|
924 | | - | let eD = X((eC - value(eB))) |
---|
925 | | - | if ((f >= eD)) |
---|
926 | | - | then $Tuple2(eC, ez) |
---|
927 | | - | else $Tuple2(eC, unit) |
---|
928 | | - | } |
---|
929 | | - | } |
---|
930 | | - | |
---|
931 | | - | let cT = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] |
---|
932 | | - | let gv = { |
---|
933 | | - | let cV = cT |
---|
934 | | - | let cW = size(cV) |
---|
935 | | - | let cX = $Tuple2(et, unit) |
---|
936 | | - | func cY (cZ,da) = if ((da >= cW)) |
---|
937 | | - | then cZ |
---|
938 | | - | else cN(cZ, cV[da]) |
---|
939 | | - | |
---|
940 | | - | func db (cZ,da) = if ((da >= cW)) |
---|
941 | | - | then cZ |
---|
942 | | - | else throw("List size exceeds 15") |
---|
943 | | - | |
---|
944 | | - | db(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cY(cX, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) |
---|
945 | | - | } |
---|
946 | | - | let eB = gv._1 |
---|
947 | | - | let dc = gv._2 |
---|
948 | | - | if ((dc != unit)) |
---|
949 | | - | then eB |
---|
950 | | - | else throw(("Y calculation error, Y = " + toString(eB))) |
---|
951 | | - | } |
---|
952 | | - | |
---|
953 | | - | |
---|
954 | | - | @Callable(cP) |
---|
955 | | - | func calculateAmountOutForSwapREADONLY (gw,gs,gx) = { |
---|
956 | | - | let gy = if ((gs == false)) |
---|
957 | | - | then { |
---|
958 | | - | let gz = aJ(this, ak()) |
---|
959 | | - | let gt = (toBigInt(bN(aJ(this, aj()))) + toBigInt(gw)) |
---|
960 | | - | $Tuple2(gz, gt) |
---|
961 | | - | } |
---|
962 | | - | else { |
---|
963 | | - | let gz = aJ(this, aj()) |
---|
964 | | - | let gt = (toBigInt(bN(aJ(this, ak()))) + toBigInt(gw)) |
---|
965 | | - | $Tuple2(gz, gt) |
---|
966 | | - | } |
---|
967 | | - | let gz = gy._1 |
---|
968 | | - | let gt = gy._2 |
---|
969 | | - | let bg = aY() |
---|
970 | | - | let dj = bg[w] |
---|
971 | | - | let dk = bg[x] |
---|
972 | | - | let cz = [toBigInt(bN(dj)), toBigInt(bN(dk))] |
---|
973 | | - | let et = cy(cz) |
---|
974 | | - | let eB = gr(gs, et, toBigInt(gw)) |
---|
975 | | - | let gA = ((toBigInt(bN(gz)) - eB) - toBigInt(1)) |
---|
976 | | - | let gB = max([0, toInt(gA)]) |
---|
977 | | - | let gC = if ((gs == false)) |
---|
978 | | - | then [((toBigInt(bN(dj)) + toBigInt(gw)) + toBigInt(gx)), (toBigInt(bN(dk)) - gA)] |
---|
979 | | - | else [(toBigInt(bN(dj)) - gA), ((toBigInt(bN(dk)) + toBigInt(gw)) + toBigInt(gx))] |
---|
980 | | - | let gD = cy(gC) |
---|
981 | | - | let dY = if ((gD >= et)) |
---|
982 | | - | then true |
---|
983 | | - | else throw(makeString(["new D is fewer error", toString(et), toString(gD)], "__")) |
---|
984 | | - | if ((dY == dY)) |
---|
985 | | - | then $Tuple2(nil, gB) |
---|
986 | | - | else throw("Strict value is not equal to itself.") |
---|
987 | | - | } |
---|
988 | | - | |
---|
989 | | - | |
---|
990 | | - | |
---|
991 | | - | @Callable(cP) |
---|
992 | | - | func calculateAmountOutForSwapAndSendTokens (gw,gs,gE,gF,gx) = { |
---|
993 | | - | let gG = { |
---|
994 | | - | let aS = invoke(aQ, "getSwapContractREADONLY", nil, nil) |
---|
995 | | - | if ($isInstanceOf(aS, "String")) |
---|
996 | | - | then aS |
---|
997 | | - | else throw(($getType(aS) + " couldn't be cast to String")) |
---|
998 | | - | } |
---|
999 | | - | let gH = [if ((value(cP.payments[0]).amount >= gw)) |
---|
1000 | | - | then true |
---|
1001 | | - | else aN("Wrong amount"), if ((cP.caller == addressFromStringValue(gG))) |
---|
1002 | | - | then true |
---|
1003 | | - | else aN("Permission denied")] |
---|
1004 | | - | if ((gH == gH)) |
---|
1005 | | - | then { |
---|
1006 | | - | let fk = value(cP.payments[0]) |
---|
1007 | | - | let gI = be(fk.assetId) |
---|
1008 | | - | let gJ = if ((gs == false)) |
---|
1009 | | - | then { |
---|
1010 | | - | let gz = aJ(this, ak()) |
---|
1011 | | - | let gt = (bN(gI) - value(cP.payments[0]).amount) |
---|
1012 | | - | $Tuple2(gz, gt) |
---|
1013 | | - | } |
---|
1014 | | - | else { |
---|
1015 | | - | let gz = aJ(this, aj()) |
---|
1016 | | - | let gt = (bN(gI) - value(cP.payments[0]).amount) |
---|
1017 | | - | $Tuple2(gz, gt) |
---|
1018 | | - | } |
---|
1019 | | - | let gz = gJ._1 |
---|
1020 | | - | let gt = gJ._2 |
---|
1021 | | - | let bg = aY() |
---|
1022 | | - | let dj = bg[w] |
---|
1023 | | - | let dk = bg[x] |
---|
1024 | | - | let cz = if ((gs == false)) |
---|
1025 | | - | then [(toBigInt(bN(dj)) - toBigInt(value(cP.payments[0]).amount)), toBigInt(bN(dk))] |
---|
1026 | | - | else [toBigInt(bN(dj)), (toBigInt(bN(dk)) - toBigInt(value(cP.payments[0]).amount))] |
---|
1027 | | - | let et = cy(cz) |
---|
1028 | | - | let eB = gr(gs, et, toBigInt(0)) |
---|
1029 | | - | let gA = ((toBigInt(bN(gz)) - eB) - toBigInt(1)) |
---|
1030 | | - | let gB = max([0, toInt(gA)]) |
---|
1031 | | - | let gK = if ((gB >= gE)) |
---|
1032 | | - | then true |
---|
1033 | | - | else throw("Exchange result is fewer coins than expected") |
---|
1034 | | - | if ((gK == gK)) |
---|
1035 | | - | then { |
---|
1036 | | - | let gC = if ((gs == false)) |
---|
1037 | | - | then [(toBigInt(bN(dj)) + toBigInt(gx)), (toBigInt(bN(dk)) - gA)] |
---|
1038 | | - | else [(toBigInt(bN(dj)) - gA), (toBigInt(bN(dk)) + toBigInt(gx))] |
---|
1039 | | - | let gD = cy(gC) |
---|
1040 | | - | let dY = if ((gD >= et)) |
---|
1041 | | - | then true |
---|
1042 | | - | else throw("new D is fewer error") |
---|
1043 | | - | if ((dY == dY)) |
---|
1044 | | - | then $Tuple2([ScriptTransfer(addressFromStringValue(gF), gB, bc(gz))], gB) |
---|
1045 | | - | else throw("Strict value is not equal to itself.") |
---|
1046 | | - | } |
---|
1047 | | - | else throw("Strict value is not equal to itself.") |
---|
1048 | | - | } |
---|
1049 | | - | else throw("Strict value is not equal to itself.") |
---|
1050 | | - | } |
---|
1051 | | - | |
---|
1052 | | - | |
---|
1053 | | - | |
---|
1054 | | - | @Callable(cP) |
---|
1055 | | - | func constructor (Y) = { |
---|
1056 | | - | let ex = gq(cP) |
---|
1057 | | - | if ((ex == ex)) |
---|
1058 | | - | then [StringEntry(Y(), Y)] |
---|
1059 | | - | else throw("Strict value is not equal to itself.") |
---|
1060 | | - | } |
---|
1061 | | - | |
---|
1062 | | - | |
---|
1063 | | - | |
---|
1064 | | - | @Callable(cP) |
---|
1065 | | - | func setManager (gL) = { |
---|
1066 | | - | let ex = gq(cP) |
---|
1067 | | - | if ((ex == ex)) |
---|
1068 | | - | then { |
---|
1069 | | - | let gM = fromBase58String(gL) |
---|
1070 | | - | if ((gM == gM)) |
---|
1071 | | - | then [StringEntry(aa(), gL)] |
---|
1072 | | - | else throw("Strict value is not equal to itself.") |
---|
1073 | | - | } |
---|
1074 | | - | else throw("Strict value is not equal to itself.") |
---|
1075 | | - | } |
---|
1076 | | - | |
---|
1077 | | - | |
---|
1078 | | - | |
---|
1079 | | - | @Callable(cP) |
---|
1080 | | - | func confirmManager () = { |
---|
1081 | | - | let cu = gm() |
---|
1082 | | - | let gN = if (isDefined(cu)) |
---|
1083 | | - | then true |
---|
1084 | | - | else throw("No pending manager") |
---|
1085 | | - | if ((gN == gN)) |
---|
1086 | | - | then { |
---|
1087 | | - | let gO = if ((cP.callerPublicKey == value(cu))) |
---|
1088 | | - | then true |
---|
1089 | | - | else throw("You are not pending manager") |
---|
1090 | | - | if ((gO == gO)) |
---|
1091 | | - | then [StringEntry(Z(), toBase58String(value(cu))), DeleteEntry(aa())] |
---|
1092 | | - | else throw("Strict value is not equal to itself.") |
---|
1093 | | - | } |
---|
1094 | | - | else throw("Strict value is not equal to itself.") |
---|
1095 | | - | } |
---|
1096 | | - | |
---|
1097 | | - | |
---|
1098 | | - | |
---|
1099 | | - | @Callable(cP) |
---|
1100 | | - | func put (gP,gQ) = { |
---|
1101 | | - | let gR = bs() |
---|
1102 | | - | let gS = valueOrErrorMessage(addressFromString(gR[C]), "Wr st addr") |
---|
1103 | | - | let gT = valueOrErrorMessage(addressFromString(gR[E]), "Wr sl addr") |
---|
1104 | | - | if ((0 > gP)) |
---|
1105 | | - | then throw("Wrong slippage") |
---|
1106 | | - | else if ((size(cP.payments) != 2)) |
---|
1107 | | - | then throw("2 pmnts expd") |
---|
1108 | | - | else { |
---|
1109 | | - | let gU = toBigInt(value(cP.payments[0]).amount) |
---|
1110 | | - | let gV = toBigInt(value(cP.payments[1]).amount) |
---|
1111 | | - | let eO = (toBigInt(bN(be(bm))) - gU) |
---|
1112 | | - | if ((eO == eO)) |
---|
1113 | | - | then { |
---|
1114 | | - | let eP = (toBigInt(bN(be(bn))) - gV) |
---|
1115 | | - | if ((eP == eP)) |
---|
1116 | | - | then { |
---|
1117 | | - | let eQ = toBigInt(value(assetInfo(bl)).quantity) |
---|
1118 | | - | if ((eQ == eQ)) |
---|
1119 | | - | then { |
---|
1120 | | - | let eR = eK(gU, gV, toBigInt(0)) |
---|
1121 | | - | if ((eR == eR)) |
---|
1122 | | - | then { |
---|
1123 | | - | let gW = fl(toString(cP.caller), toBase58String(cP.transactionId), AttachedPayment(value(cP.payments[0]).assetId, value(cP.payments[0]).amount), cP.payments[1], gP, true, false, true, 0, "") |
---|
1124 | | - | let el = gW._2 |
---|
1125 | | - | let gX = gW._7 |
---|
1126 | | - | let dB = gW._9 |
---|
1127 | | - | let em = gW._10 |
---|
1128 | | - | let en = gW._11 |
---|
1129 | | - | let dj = gW._12 |
---|
1130 | | - | let dk = gW._13 |
---|
1131 | | - | let dX = invoke(aQ, "emit", [el], nil) |
---|
1132 | | - | if ((dX == dX)) |
---|
1133 | | - | then { |
---|
1134 | | - | let gY = { |
---|
1135 | | - | let gl = dX |
---|
1136 | | - | if ($isInstanceOf(gl, "Address")) |
---|
1137 | | - | then { |
---|
1138 | | - | let gZ = gl |
---|
1139 | | - | invoke(gZ, "emit", [el], nil) |
---|
1140 | | - | } |
---|
1141 | | - | else unit |
---|
1142 | | - | } |
---|
1143 | | - | if ((gY == gY)) |
---|
1144 | | - | then { |
---|
1145 | | - | let ha = if ((em > 0)) |
---|
1146 | | - | then invoke(gT, "put", nil, [AttachedPayment(dj, em)]) |
---|
1147 | | - | else nil |
---|
1148 | | - | if ((ha == ha)) |
---|
1149 | | - | then { |
---|
1150 | | - | let hb = if ((en > 0)) |
---|
1151 | | - | then invoke(gT, "put", nil, [AttachedPayment(dk, en)]) |
---|
1152 | | - | else nil |
---|
1153 | | - | if ((hb == hb)) |
---|
1154 | | - | then { |
---|
1155 | | - | let hc = if (gQ) |
---|
1156 | | - | then { |
---|
1157 | | - | let hd = invoke(gS, "stake", nil, [AttachedPayment(gX, el)]) |
---|
1158 | | - | if ((hd == hd)) |
---|
1159 | | - | then nil |
---|
1160 | | - | else throw("Strict value is not equal to itself.") |
---|
1161 | | - | } |
---|
1162 | | - | else [ScriptTransfer(cP.caller, el, gX)] |
---|
1163 | | - | let he = eS(0, 0, 0) |
---|
1164 | | - | let gi = he._1 |
---|
1165 | | - | let eJ = he._2 |
---|
1166 | | - | let hf = if ((eJ >= eR)) |
---|
1167 | | - | then true |
---|
1168 | | - | else aN(makeString(["updated DLp lower than current DLp", toString(eO), toString(eP), toString(eQ), toString(eR), toString(eJ), toString(em), toString(en)], " ")) |
---|
1169 | | - | if ((hf == hf)) |
---|
1170 | | - | then { |
---|
1171 | | - | let hg = value(assetInfo(bl)).quantity |
---|
1172 | | - | if ((hg == hg)) |
---|
1173 | | - | then ((dB ++ hc) ++ gi) |
---|
1174 | | - | else throw("Strict value is not equal to itself.") |
---|
1175 | | - | } |
---|
1176 | | - | else throw("Strict value is not equal to itself.") |
---|
1177 | | - | } |
---|
1178 | | - | else throw("Strict value is not equal to itself.") |
---|
1179 | | - | } |
---|
1180 | | - | else throw("Strict value is not equal to itself.") |
---|
1181 | | - | } |
---|
1182 | | - | else throw("Strict value is not equal to itself.") |
---|
1183 | | - | } |
---|
1184 | | - | else throw("Strict value is not equal to itself.") |
---|
1185 | | - | } |
---|
1186 | | - | else throw("Strict value is not equal to itself.") |
---|
1187 | | - | } |
---|
1188 | | - | else throw("Strict value is not equal to itself.") |
---|
1189 | | - | } |
---|
1190 | | - | else throw("Strict value is not equal to itself.") |
---|
1191 | | - | } |
---|
1192 | | - | else throw("Strict value is not equal to itself.") |
---|
1193 | | - | } |
---|
1194 | | - | } |
---|
1195 | | - | |
---|
1196 | | - | |
---|
1197 | | - | |
---|
1198 | | - | @Callable(cP) |
---|
1199 | | - | func putOneTknV2 (fM,gQ) = { |
---|
1200 | | - | let hh = { |
---|
1201 | | - | let aS = invoke(aQ, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) |
---|
1202 | | - | if ($isInstanceOf(aS, "Boolean")) |
---|
1203 | | - | then aS |
---|
1204 | | - | else throw(($getType(aS) + " couldn't be cast to Boolean")) |
---|
1205 | | - | } |
---|
1206 | | - | let hi = if (if (if (aV()) |
---|
1207 | | - | then true |
---|
1208 | | - | else (bk == q)) |
---|
1209 | | - | then true |
---|
1210 | | - | else (bk == s)) |
---|
1211 | | - | then true |
---|
1212 | | - | else hh |
---|
1213 | | - | let gH = [if (if (!(hi)) |
---|
1214 | | - | then true |
---|
1215 | | - | else go(cP)) |
---|
1216 | | - | then true |
---|
1217 | | - | else aN("put operation is blocked by admin"), if ((size(cP.payments) == 1)) |
---|
1218 | | - | then true |
---|
1219 | | - | else aN("exactly 1 payment are expected")] |
---|
1220 | | - | if ((gH == gH)) |
---|
1221 | | - | then { |
---|
1222 | | - | let dj = toBase58String(value(bm)) |
---|
1223 | | - | let dk = toBase58String(value(bn)) |
---|
1224 | | - | let di = bl |
---|
1225 | | - | let fQ = bo |
---|
1226 | | - | let fR = bp |
---|
1227 | | - | let dh = if ((cP.caller == this)) |
---|
1228 | | - | then cP.originCaller |
---|
1229 | | - | else cP.caller |
---|
1230 | | - | let fk = value(cP.payments[0]) |
---|
1231 | | - | let df = toBase58String(value(fk.assetId)) |
---|
1232 | | - | let dL = fk.amount |
---|
1233 | | - | let eR = if ((fk.assetId == bm)) |
---|
1234 | | - | then eK(toBigInt(dL), toBigInt(0), toBigInt(0)) |
---|
1235 | | - | else eK(toBigInt(0), toBigInt(dL), toBigInt(0)) |
---|
1236 | | - | if ((eR == eR)) |
---|
1237 | | - | then { |
---|
1238 | | - | let hj = fp(dL, df, toString(dh), toBase58String(cP.transactionId), true) |
---|
1239 | | - | if ((hj == hj)) |
---|
1240 | | - | then { |
---|
1241 | | - | let cx = hj._3 |
---|
1242 | | - | let dB = hj._2 |
---|
1243 | | - | let hk = hj._1 |
---|
1244 | | - | let el = if (if ((fM > 0)) |
---|
1245 | | - | then (fM > hk) |
---|
1246 | | - | else false) |
---|
1247 | | - | then aN(makeString(["amount to receive is less than ", toString(fM)], "")) |
---|
1248 | | - | else hk |
---|
1249 | | - | let gW = invoke(aQ, "emit", [el], nil) |
---|
1250 | | - | if ((gW == gW)) |
---|
1251 | | - | then { |
---|
1252 | | - | let gY = { |
---|
1253 | | - | let gl = gW |
---|
1254 | | - | if ($isInstanceOf(gl, "Address")) |
---|
1255 | | - | then { |
---|
1256 | | - | let gZ = gl |
---|
1257 | | - | invoke(gZ, "emit", [el], nil) |
---|
1258 | | - | } |
---|
1259 | | - | else unit |
---|
1260 | | - | } |
---|
1261 | | - | if ((gY == gY)) |
---|
1262 | | - | then { |
---|
1263 | | - | let hc = if (gQ) |
---|
1264 | | - | then { |
---|
1265 | | - | let hd = invoke(bu, "stake", nil, [AttachedPayment(di, el)]) |
---|
1266 | | - | if ((hd == hd)) |
---|
1267 | | - | then nil |
---|
1268 | | - | else throw("Strict value is not equal to itself.") |
---|
1269 | | - | } |
---|
1270 | | - | else [ScriptTransfer(cP.caller, el, di)] |
---|
1271 | | - | let gc = if ((cx > 0)) |
---|
1272 | | - | then [ScriptTransfer(aX, cx, fromBase58String(df))] |
---|
1273 | | - | else nil |
---|
1274 | | - | let hl = if ((this == aX)) |
---|
1275 | | - | then $Tuple2(0, 0) |
---|
1276 | | - | else { |
---|
1277 | | - | let hm = if ((fk.assetId == bm)) |
---|
1278 | | - | then true |
---|
1279 | | - | else false |
---|
1280 | | - | if (hm) |
---|
1281 | | - | then $Tuple2(-(cx), 0) |
---|
1282 | | - | else $Tuple2(0, -(cx)) |
---|
1283 | | - | } |
---|
1284 | | - | let eT = hl._1 |
---|
1285 | | - | let eU = hl._2 |
---|
1286 | | - | let hn = eS(eT, eU, 0) |
---|
1287 | | - | let gi = hn._1 |
---|
1288 | | - | let eJ = hn._2 |
---|
1289 | | - | let gj = eW(eR, eJ) |
---|
1290 | | - | if ((gj == gj)) |
---|
1291 | | - | then $Tuple2((((dB ++ hc) ++ gc) ++ gi), el) |
---|
1292 | | - | else throw("Strict value is not equal to itself.") |
---|
1293 | | - | } |
---|
1294 | | - | else throw("Strict value is not equal to itself.") |
---|
1295 | | - | } |
---|
1296 | | - | else throw("Strict value is not equal to itself.") |
---|
1297 | | - | } |
---|
1298 | | - | else throw("Strict value is not equal to itself.") |
---|
1299 | | - | } |
---|
1300 | | - | else throw("Strict value is not equal to itself.") |
---|
1301 | | - | } |
---|
1302 | | - | else throw("Strict value is not equal to itself.") |
---|
1303 | | - | } |
---|
1304 | | - | |
---|
1305 | | - | |
---|
1306 | | - | |
---|
1307 | | - | @Callable(cP) |
---|
1308 | | - | func putForFree (ho) = if ((0 > ho)) |
---|
1309 | | - | then throw("Wrong slpg") |
---|
1310 | | - | else if ((size(cP.payments) != 2)) |
---|
1311 | | - | then throw("2 pmnts expd") |
---|
1312 | | - | else { |
---|
1313 | | - | let hp = fl(toString(cP.caller), toBase58String(cP.transactionId), AttachedPayment(value(cP.payments[0]).assetId, value(cP.payments[0]).amount), cP.payments[1], ho, false, false, true, 0, "") |
---|
1314 | | - | let dB = hp._9 |
---|
1315 | | - | let gU = toBigInt(value(cP.payments[0]).amount) |
---|
1316 | | - | let gV = toBigInt(value(cP.payments[1]).amount) |
---|
1317 | | - | let eR = eK(gU, gV, toBigInt(0)) |
---|
1318 | | - | if ((eR == eR)) |
---|
1319 | | - | then { |
---|
1320 | | - | let hq = eS(0, 0, 0) |
---|
1321 | | - | let gi = hq._1 |
---|
1322 | | - | let eJ = hq._2 |
---|
1323 | | - | let gj = eW(eR, eJ) |
---|
1324 | | - | if ((gj == gj)) |
---|
1325 | | - | then (dB ++ gi) |
---|
1326 | | - | else throw("Strict value is not equal to itself.") |
---|
1327 | | - | } |
---|
1328 | | - | else throw("Strict value is not equal to itself.") |
---|
1329 | | - | } |
---|
1330 | | - | |
---|
1331 | | - | |
---|
1332 | | - | |
---|
1333 | | - | @Callable(cP) |
---|
1334 | | - | func get () = { |
---|
1335 | | - | let eR = eK(toBigInt(0), toBigInt(0), toBigInt(0)) |
---|
1336 | | - | if ((eR == eR)) |
---|
1337 | | - | then { |
---|
1338 | | - | let dX = fj(cP) |
---|
1339 | | - | let hr = dX._1 |
---|
1340 | | - | let dA = dX._2 |
---|
1341 | | - | let dL = dX._3 |
---|
1342 | | - | let df = dX._4 |
---|
1343 | | - | let dB = dX._5 |
---|
1344 | | - | let ey = invoke(aQ, "burn", [dL], [AttachedPayment(df, dL)]) |
---|
1345 | | - | if ((ey == ey)) |
---|
1346 | | - | then { |
---|
1347 | | - | let hs = eS(-(hr), -(dA), 0) |
---|
1348 | | - | let gi = hs._1 |
---|
1349 | | - | let eJ = hs._2 |
---|
1350 | | - | let gj = eW(eR, eJ) |
---|
1351 | | - | if ((gj == gj)) |
---|
1352 | | - | then (dB ++ gi) |
---|
1353 | | - | else throw("Strict value is not equal to itself.") |
---|
1354 | | - | } |
---|
1355 | | - | else throw("Strict value is not equal to itself.") |
---|
1356 | | - | } |
---|
1357 | | - | else throw("Strict value is not equal to itself.") |
---|
1358 | | - | } |
---|
1359 | | - | |
---|
1360 | | - | |
---|
1361 | | - | |
---|
1362 | | - | @Callable(cP) |
---|
1363 | | - | func getOneTknV2 (fL,fM) = { |
---|
1364 | | - | let hh = { |
---|
1365 | | - | let aS = invoke(aQ, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) |
---|
1366 | | - | if ($isInstanceOf(aS, "Boolean")) |
---|
1367 | | - | then aS |
---|
1368 | | - | else throw(($getType(aS) + " couldn't be cast to Boolean")) |
---|
1369 | | - | } |
---|
1370 | | - | let ht = if (if (aV()) |
---|
1371 | | - | then true |
---|
1372 | | - | else (bk == s)) |
---|
1373 | | - | then true |
---|
1374 | | - | else hh |
---|
1375 | | - | let gH = [if (if (!(ht)) |
---|
1376 | | - | then true |
---|
1377 | | - | else go(cP)) |
---|
1378 | | - | then true |
---|
1379 | | - | else aN("get operation is blocked by admin"), if ((size(cP.payments) == 1)) |
---|
1380 | | - | then true |
---|
1381 | | - | else aN("exactly 1 payment are expected")] |
---|
1382 | | - | if ((gH == gH)) |
---|
1383 | | - | then { |
---|
1384 | | - | let hu = fK(fL, fM, cP.payments, cP.caller, cP.originCaller, cP.transactionId) |
---|
1385 | | - | let dB = hu._1 |
---|
1386 | | - | let fV = hu._2 |
---|
1387 | | - | $Tuple2(dB, fV) |
---|
1388 | | - | } |
---|
1389 | | - | else throw("Strict value is not equal to itself.") |
---|
1390 | | - | } |
---|
1391 | | - | |
---|
1392 | | - | |
---|
1393 | | - | |
---|
1394 | | - | @Callable(cP) |
---|
1395 | | - | func refreshDLp () = { |
---|
1396 | | - | let hv = valueOrElse(getInteger(aq), 0) |
---|
1397 | | - | let hw = if (((height - hv) >= at)) |
---|
1398 | | - | then unit |
---|
1399 | | - | else aN(makeString([toString(at), " blocks have not passed since the previous call"], "")) |
---|
1400 | | - | if ((hw == hw)) |
---|
1401 | | - | then { |
---|
1402 | | - | let fd = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, ap), "0")), aP("invalid dLp")) |
---|
1403 | | - | let hx = eS(0, 0, 0) |
---|
1404 | | - | let hy = hx._1 |
---|
1405 | | - | let eJ = hx._2 |
---|
1406 | | - | let eV = if ((fd != eJ)) |
---|
1407 | | - | then hy |
---|
1408 | | - | else aN("nothing to refresh") |
---|
1409 | | - | $Tuple2(eV, toString(eJ)) |
---|
1410 | | - | } |
---|
1411 | | - | else throw("Strict value is not equal to itself.") |
---|
1412 | | - | } |
---|
1413 | | - | |
---|
1414 | | - | |
---|
1415 | | - | |
---|
1416 | | - | @Callable(cP) |
---|
1417 | | - | func getOneTknV2READONLY (fL,hz) = { |
---|
1418 | | - | let dj = toBase58String(value(bm)) |
---|
1419 | | - | let dk = toBase58String(value(bn)) |
---|
1420 | | - | let di = toBase58String(value(bl)) |
---|
1421 | | - | let cz = [toBigInt(bN(dj)), toBigInt(bN(dk))] |
---|
1422 | | - | let eI = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(di)), "invalid lp asset").quantity) |
---|
1423 | | - | let cb = cy(cz) |
---|
1424 | | - | let ca = (cb - fraction(toBigInt(hz), cb, eI)) |
---|
1425 | | - | let hA = if ((fL == dj)) |
---|
1426 | | - | then 0 |
---|
1427 | | - | else if ((fL == dk)) |
---|
1428 | | - | then 1 |
---|
1429 | | - | else throw("invalid out asset id") |
---|
1430 | | - | let hB = es(cz, hA, ca) |
---|
1431 | | - | let gA = (cz[hA] - hB) |
---|
1432 | | - | let gB = max([0, toInt((gA - f))]) |
---|
1433 | | - | let hC = cv(gB, aT) |
---|
1434 | | - | let fU = hC._1 |
---|
1435 | | - | let cx = hC._2 |
---|
1436 | | - | $Tuple2(nil, $Tuple2(fU, cx)) |
---|
1437 | | - | } |
---|
1438 | | - | |
---|
1439 | | - | |
---|
1440 | | - | |
---|
1441 | | - | @Callable(cP) |
---|
1442 | | - | func getOneTknV2WithBonusREADONLY (fL,hz) = { |
---|
1443 | | - | let dj = toBase58String(value(bm)) |
---|
1444 | | - | let dk = toBase58String(value(bn)) |
---|
1445 | | - | let di = toBase58String(value(bl)) |
---|
1446 | | - | let dp = bN(dj) |
---|
1447 | | - | let dr = bN(dk) |
---|
1448 | | - | let hD = { |
---|
1449 | | - | let aS = invoke(this, "getOneTknV2READONLY", [fL, hz], nil) |
---|
1450 | | - | if ($isInstanceOf(aS, "(Int, Int)")) |
---|
1451 | | - | then aS |
---|
1452 | | - | else throw(($getType(aS) + " couldn't be cast to (Int, Int)")) |
---|
1453 | | - | } |
---|
1454 | | - | let fU = hD._1 |
---|
1455 | | - | let cx = hD._2 |
---|
1456 | | - | let dX = dd("", di, hz, this) |
---|
1457 | | - | let dz = dX._1 |
---|
1458 | | - | let dA = dX._2 |
---|
1459 | | - | let hE = (dz + dA) |
---|
1460 | | - | let fJ = if ((hE == 0)) |
---|
1461 | | - | then if ((fU == 0)) |
---|
1462 | | - | then 0 |
---|
1463 | | - | else throw("bonus calculation error") |
---|
1464 | | - | else fraction((fU - hE), a, hE) |
---|
1465 | | - | $Tuple2(nil, $Tuple3(fU, cx, fJ)) |
---|
1466 | | - | } |
---|
1467 | | - | |
---|
1468 | | - | |
---|
1469 | | - | |
---|
1470 | | - | @Callable(cP) |
---|
1471 | | - | func getNoLess (hF,hG) = { |
---|
1472 | | - | let dX = fj(cP) |
---|
1473 | | - | let dz = dX._1 |
---|
1474 | | - | let dA = dX._2 |
---|
1475 | | - | let dL = dX._3 |
---|
1476 | | - | let df = dX._4 |
---|
1477 | | - | let dB = dX._5 |
---|
1478 | | - | if ((hF > dz)) |
---|
1479 | | - | then throw(((("Failed: " + toString(dz)) + " < ") + toString(hF))) |
---|
1480 | | - | else if ((hG > dA)) |
---|
1481 | | - | then throw(((("Failed: " + toString(dA)) + " < ") + toString(hG))) |
---|
1482 | | - | else { |
---|
1483 | | - | let eR = eK(toBigInt(0), toBigInt(0), toBigInt(0)) |
---|
1484 | | - | if ((eR == eR)) |
---|
1485 | | - | then { |
---|
1486 | | - | let hH = invoke(aQ, "burn", [dL], [AttachedPayment(df, dL)]) |
---|
1487 | | - | if ((hH == hH)) |
---|
1488 | | - | then { |
---|
1489 | | - | let hI = eS(-(dz), -(dA), 0) |
---|
1490 | | - | let gi = hI._1 |
---|
1491 | | - | let eJ = hI._2 |
---|
1492 | | - | let gj = eW(eR, eJ) |
---|
1493 | | - | if ((gj == gj)) |
---|
1494 | | - | then (dB ++ gi) |
---|
1495 | | - | else throw("Strict value is not equal to itself.") |
---|
1496 | | - | } |
---|
1497 | | - | else throw("Strict value is not equal to itself.") |
---|
1498 | | - | } |
---|
1499 | | - | else throw("Strict value is not equal to itself.") |
---|
1500 | | - | } |
---|
1501 | | - | } |
---|
1502 | | - | |
---|
1503 | | - | |
---|
1504 | | - | |
---|
1505 | | - | @Callable(cP) |
---|
1506 | | - | func unstakeAndGet (cw) = { |
---|
1507 | | - | let hJ = if ((size(cP.payments) != 0)) |
---|
1508 | | - | then throw("No pmnts expd") |
---|
1509 | | - | else true |
---|
1510 | | - | if ((hJ == hJ)) |
---|
1511 | | - | then { |
---|
1512 | | - | let hK = bs() |
---|
1513 | | - | let gX = bl |
---|
1514 | | - | let hL = valueOrErrorMessage(addressFromString(hK[C]), "Wr st addr") |
---|
1515 | | - | let eR = eK(toBigInt(0), toBigInt(0), toBigInt(0)) |
---|
1516 | | - | if ((eR == eR)) |
---|
1517 | | - | then { |
---|
1518 | | - | let hM = invoke(hL, "unstake", [toBase58String(gX), cw], nil) |
---|
1519 | | - | if ((hM == hM)) |
---|
1520 | | - | then { |
---|
1521 | | - | let dX = dd(toBase58String(cP.transactionId), toBase58String(gX), cw, cP.caller) |
---|
1522 | | - | let dz = dX._1 |
---|
1523 | | - | let dA = dX._2 |
---|
1524 | | - | let dn = parseIntValue(dX._9) |
---|
1525 | | - | let dB = dX._10 |
---|
1526 | | - | let hN = if (if (aV()) |
---|
1527 | | - | then true |
---|
1528 | | - | else (dn == s)) |
---|
1529 | | - | then throw(("Blocked: " + toString(dn))) |
---|
1530 | | - | else true |
---|
1531 | | - | if ((hN == hN)) |
---|
1532 | | - | then { |
---|
1533 | | - | let hO = invoke(aQ, "burn", [cw], [AttachedPayment(gX, cw)]) |
---|
1534 | | - | if ((hO == hO)) |
---|
1535 | | - | then { |
---|
1536 | | - | let hP = eS(-(dz), -(dA), 0) |
---|
1537 | | - | let gi = hP._1 |
---|
1538 | | - | let eJ = hP._2 |
---|
1539 | | - | let gj = eW(eR, eJ) |
---|
1540 | | - | if ((gj == gj)) |
---|
1541 | | - | then (dB ++ gi) |
---|
1542 | | - | else throw("Strict value is not equal to itself.") |
---|
1543 | | - | } |
---|
1544 | | - | else throw("Strict value is not equal to itself.") |
---|
1545 | | - | } |
---|
1546 | | - | else throw("Strict value is not equal to itself.") |
---|
1547 | | - | } |
---|
1548 | | - | else throw("Strict value is not equal to itself.") |
---|
1549 | | - | } |
---|
1550 | | - | else throw("Strict value is not equal to itself.") |
---|
1551 | | - | } |
---|
1552 | | - | else throw("Strict value is not equal to itself.") |
---|
1553 | | - | } |
---|
1554 | | - | |
---|
1555 | | - | |
---|
1556 | | - | |
---|
1557 | | - | @Callable(cP) |
---|
1558 | | - | func unstakeAndGetNoLess (hQ,hR,hG) = { |
---|
1559 | | - | let ht = if (aV()) |
---|
1560 | | - | then true |
---|
1561 | | - | else (bk == s) |
---|
1562 | | - | let gH = [if (!(ht)) |
---|
1563 | | - | then true |
---|
1564 | | - | else throw("get operation is blocked by admin"), if ((size(cP.payments) == 0)) |
---|
1565 | | - | then true |
---|
1566 | | - | else throw("no payments are expected")] |
---|
1567 | | - | if ((gH == gH)) |
---|
1568 | | - | then { |
---|
1569 | | - | let eR = eK(toBigInt(0), toBigInt(0), toBigInt(0)) |
---|
1570 | | - | if ((eR == eR)) |
---|
1571 | | - | then { |
---|
1572 | | - | let hM = invoke(bu, "unstake", [toBase58String(bl), hQ], nil) |
---|
1573 | | - | if ((hM == hM)) |
---|
1574 | | - | then { |
---|
1575 | | - | let hS = dd(toBase58String(cP.transactionId), toBase58String(bl), hQ, cP.caller) |
---|
1576 | | - | let dz = hS._1 |
---|
1577 | | - | let dA = hS._2 |
---|
1578 | | - | let dB = hS._10 |
---|
1579 | | - | let hT = [if ((dz >= hR)) |
---|
1580 | | - | then true |
---|
1581 | | - | else throw(makeString(["amount asset amount to receive is less than ", toString(hR)], "")), if ((dA >= hG)) |
---|
1582 | | - | then true |
---|
1583 | | - | else throw(makeString(["price asset amount to receive is less than ", toString(hG)], ""))] |
---|
1584 | | - | if ((hT == hT)) |
---|
1585 | | - | then { |
---|
1586 | | - | let hH = invoke(aQ, "burn", [hQ], [AttachedPayment(bl, hQ)]) |
---|
1587 | | - | if ((hH == hH)) |
---|
1588 | | - | then { |
---|
1589 | | - | let hU = eS(-(dz), -(dA), 0) |
---|
1590 | | - | let gi = hU._1 |
---|
1591 | | - | let eJ = hU._2 |
---|
1592 | | - | let gj = eW(eR, eJ) |
---|
1593 | | - | if ((gj == gj)) |
---|
1594 | | - | then (dB ++ gi) |
---|
1595 | | - | else throw("Strict value is not equal to itself.") |
---|
1596 | | - | } |
---|
1597 | | - | else throw("Strict value is not equal to itself.") |
---|
1598 | | - | } |
---|
1599 | | - | else throw("Strict value is not equal to itself.") |
---|
1600 | | - | } |
---|
1601 | | - | else throw("Strict value is not equal to itself.") |
---|
1602 | | - | } |
---|
1603 | | - | else throw("Strict value is not equal to itself.") |
---|
1604 | | - | } |
---|
1605 | | - | else throw("Strict value is not equal to itself.") |
---|
1606 | | - | } |
---|
1607 | | - | |
---|
1608 | | - | |
---|
1609 | | - | |
---|
1610 | | - | @Callable(cP) |
---|
1611 | | - | func unstakeAndGetOneTknV2 (hQ,fL,fM) = { |
---|
1612 | | - | let hh = { |
---|
1613 | | - | let aS = invoke(aQ, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) |
---|
1614 | | - | if ($isInstanceOf(aS, "Boolean")) |
---|
1615 | | - | then aS |
---|
1616 | | - | else throw(($getType(aS) + " couldn't be cast to Boolean")) |
---|
1617 | | - | } |
---|
1618 | | - | let ht = if (if (aV()) |
---|
1619 | | - | then true |
---|
1620 | | - | else (bk == s)) |
---|
1621 | | - | then true |
---|
1622 | | - | else hh |
---|
1623 | | - | let gH = [if (if (!(ht)) |
---|
1624 | | - | then true |
---|
1625 | | - | else go(cP)) |
---|
1626 | | - | then true |
---|
1627 | | - | else aN("get operation is blocked by admin"), if ((size(cP.payments) == 0)) |
---|
1628 | | - | then true |
---|
1629 | | - | else aN("no payments are expected")] |
---|
1630 | | - | if ((gH == gH)) |
---|
1631 | | - | then { |
---|
1632 | | - | let hK = bs() |
---|
1633 | | - | let gX = bl |
---|
1634 | | - | let hL = valueOrErrorMessage(addressFromString(hK[C]), "Wr st addr") |
---|
1635 | | - | let dh = cP.caller |
---|
1636 | | - | let hV = this |
---|
1637 | | - | let hM = invoke(hL, "unstakeINTERNAL", [gX, hQ, dh.bytes, hV.bytes], nil) |
---|
1638 | | - | if ((hM == hM)) |
---|
1639 | | - | then { |
---|
1640 | | - | let hW = fK(fL, fM, [AttachedPayment(gX, hQ)], cP.caller, cP.originCaller, cP.transactionId) |
---|
1641 | | - | let dB = hW._1 |
---|
1642 | | - | let fV = hW._2 |
---|
1643 | | - | $Tuple2(dB, fV) |
---|
1644 | | - | } |
---|
1645 | | - | else throw("Strict value is not equal to itself.") |
---|
1646 | | - | } |
---|
1647 | | - | else throw("Strict value is not equal to itself.") |
---|
1648 | | - | } |
---|
1649 | | - | |
---|
1650 | | - | |
---|
1651 | | - | |
---|
1652 | | - | @Callable(cP) |
---|
1653 | | - | func putOneTknV2WithBonusREADONLY (hX,hY) = { |
---|
1654 | | - | let hZ = fp(hX, hY, "", "", true) |
---|
1655 | | - | let fE = hZ._1 |
---|
1656 | | - | let dB = hZ._2 |
---|
1657 | | - | let cx = hZ._3 |
---|
1658 | | - | let fJ = hZ._4 |
---|
1659 | | - | $Tuple2(nil, $Tuple3(fE, cx, fJ)) |
---|
1660 | | - | } |
---|
1661 | | - | |
---|
1662 | | - | |
---|
1663 | | - | |
---|
1664 | | - | @Callable(cP) |
---|
1665 | | - | func putOneTknV2WithoutTakeFeeREADONLY (hX,hY) = { |
---|
1666 | | - | let ia = fp(hX, hY, "", "", false) |
---|
1667 | | - | let fE = ia._1 |
---|
1668 | | - | let dB = ia._2 |
---|
1669 | | - | let cx = ia._3 |
---|
1670 | | - | let fJ = ia._4 |
---|
1671 | | - | $Tuple2(nil, $Tuple3(fE, cx, fJ)) |
---|
1672 | | - | } |
---|
1673 | | - | |
---|
1674 | | - | |
---|
1675 | | - | |
---|
1676 | | - | @Callable(cP) |
---|
1677 | | - | func activate (ib,ic) = if ((toString(cP.caller) != toString(aQ))) |
---|
1678 | | - | then throw("denied") |
---|
1679 | | - | else $Tuple2([StringEntry(aj(), ib), StringEntry(ak(), ic)], "success") |
---|
1680 | | - | |
---|
1681 | | - | |
---|
1682 | | - | |
---|
1683 | | - | @Callable(cP) |
---|
1684 | | - | func setS (id,hN) = if ((toString(cP.caller) != aJ(this, am()))) |
---|
1685 | | - | then gn |
---|
1686 | | - | else [StringEntry(id, hN)] |
---|
1687 | | - | |
---|
1688 | | - | |
---|
1689 | | - | |
---|
1690 | | - | @Callable(cP) |
---|
1691 | | - | func setI (id,hN) = if ((toString(cP.caller) != aJ(this, am()))) |
---|
1692 | | - | then gn |
---|
1693 | | - | else [IntegerEntry(id, hN)] |
---|
1694 | | - | |
---|
1695 | | - | |
---|
1696 | | - | |
---|
1697 | | - | @Callable(cP) |
---|
1698 | | - | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, aY()) |
---|
1699 | | - | |
---|
1700 | | - | |
---|
1701 | | - | |
---|
1702 | | - | @Callable(cP) |
---|
1703 | | - | func getAccBalanceWrapperREADONLY (bO) = $Tuple2(nil, bN(bO)) |
---|
1704 | | - | |
---|
1705 | | - | |
---|
1706 | | - | |
---|
1707 | | - | @Callable(cP) |
---|
1708 | | - | func calcPricesWrapperREADONLY (ch,ci,cm) = { |
---|
1709 | | - | let ie = cl(ch, ci, cm) |
---|
1710 | | - | $Tuple2(nil, [toString(ie[0]), toString(ie[1]), toString(ie[2])]) |
---|
1711 | | - | } |
---|
1712 | | - | |
---|
1713 | | - | |
---|
1714 | | - | |
---|
1715 | | - | @Callable(cP) |
---|
1716 | | - | func fromX18WrapperREADONLY (M,if) = $Tuple2(nil, L(parseBigIntValue(M), if)) |
---|
1717 | | - | |
---|
1718 | | - | |
---|
1719 | | - | |
---|
1720 | | - | @Callable(cP) |
---|
1721 | | - | func toX18WrapperREADONLY (I,J) = $Tuple2(nil, toString(H(I, J))) |
---|
1722 | | - | |
---|
1723 | | - | |
---|
1724 | | - | |
---|
1725 | | - | @Callable(cP) |
---|
1726 | | - | func calcPriceBigIntWrapperREADONLY (bQ,bR) = $Tuple2(nil, toString(bP(parseBigIntValue(bQ), parseBigIntValue(bR)))) |
---|
1727 | | - | |
---|
1728 | | - | |
---|
1729 | | - | |
---|
1730 | | - | @Callable(cP) |
---|
1731 | | - | func estimatePutOperationWrapperREADONLY (de,bW,dD,dE,dF,dG,ig,dH,dI) = $Tuple2(nil, dC(de, bW, dD, dE, dF, dG, ig, dH, dI, true, false, 0, "")) |
---|
1732 | | - | |
---|
1733 | | - | |
---|
1734 | | - | |
---|
1735 | | - | @Callable(cP) |
---|
1736 | | - | func estimateGetOperationWrapperREADONLY (de,ih,dg,ig) = { |
---|
1737 | | - | let dX = dd(de, ih, dg, addressFromStringValue(ig)) |
---|
1738 | | - | $Tuple2(nil, $Tuple10(dX._1, dX._2, dX._3, dX._4, dX._5, dX._6, dX._7, toString(dX._8), dX._9, dX._10)) |
---|
1739 | | - | } |
---|