tx · Gz64QcKwVrRVgTixQCLM99VYeRiAVDayozszDaiZtyQ5 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA: -0.03300000 Waves 2022.10.07 10:21 [2261609] smart account 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA > SELF 0.00000000 Waves
{ "type": 13, "id": "Gz64QcKwVrRVgTixQCLM99VYeRiAVDayozszDaiZtyQ5", "fee": 3300000, "feeAssetId": null, "timestamp": 1665127320656, "version": 1, "sender": "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA", "senderPublicKey": "35yd3qw1gxKDxKwGAykHN9fANbXNWwseaUwbWDj24o3x", "proofs": [ "3Rs61f2BLGdycg2VE4BGcfQbH4GUXRfUnkJtLoz1b6qnz3T59NU9ujXf93qU39gw2GQhs3scdz9woMAf4pRnbYdd" ], "script": "base64:BgK1IQgCEgMKAQgSAwoBCBIAEgQKAgEEEgcKBQEBAQEEEgQKAgEEEgMKAQESABIHCgUBAQEIARIECgIIARIECgIIARIECgIIARIECgIIARIECgIBARIDCgEBEgUKAwEIARIECgIBCBIECgIICBIECgIICBIECgIIARIAEgMKAQgSBQoDAQEBEgQKAggBEgQKAgEBEgQKAggIEgsKCQgBAQIBAggEBBIGCgQICAEIEgAiBnNjYWxlOCIMc2NhbGU4QmlnSW50IgdzY2FsZTE4Igp6ZXJvQmlnSW50IgRiaWcwIgRiaWcxIgRiaWcyIgpzbGlwcGFnZTREIgVBbXVsdCIFRGNvbnYiA1NFUCIFRU1QVFkiClBvb2xBY3RpdmUiClBvb2xQdXREaXMiDlBvb2xNYXRjaGVyRGlzIgxQb29sU2h1dGRvd24iDmlkeFBvb2xBZGRyZXNzIglpZHhQb29sU3QiCWlkeExQQXNJZCIJaWR4QW1Bc0lkIglpZHhQckFzSWQiC2lkeEFtdEFzRGNtIg1pZHhQcmljZUFzRGNtIgtpZHhJQW10QXNJZCINaWR4SVByaWNlQXNJZCIPaWR4RmFjdFN0YWtDbnRyIhBpZHhG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AACAUCZGUPc2VuZGVyUHVibGljS2V5BAJnTwkA9AMDCAUCZGUJYm9keUJ5dGVzCQCRAwIIBQJkZQZwcm9vZnMAAQUCZ0wDAwMFAmdNBQJnTgcFAmdPBwYJAQJhcQMFAmdNBQJnTgUCZ08DCQABAgUCYXYCFFNldFNjcmlwdFRyYW5zYWN0aW9uBAJkRQUCYXYEAmdQCQD2AwEJAQV2YWx1ZQEIBQJkRQZzY3JpcHQEAmdRCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYUIJAQJhbwAEAmdSCQDxBwEFBHRoaXMDAwkAAAIFAmdRBQJnUAkBAiE9AgUCZ1IFAmdQBwYJAPQDAwgFAmdJCWJvZHlCeXRlcwkAkQMCCAUCZ0kGcHJvb2ZzAAAFAmdLCQD0AwMIBQJnSQlib2R5Qnl0ZXMJAJEDAggFAmdJBnByb29mcwAABQJnS0ATk4E=", "chainId": 84, "height": 2261609, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DLRS2yrdxrwTPucfLa2nqdVLujKuymogcB3G4gy6gckq Next: Ex7MCG9jFNn35Ly6TaGzRK9f6u5oSGT8h2Ud2UWJeXD8 Diff:
Old | New | Differences | |
---|---|---|---|
459 | 459 | } | |
460 | 460 | ||
461 | 461 | ||
462 | - | func estimatePutOneTknV2 (pmtAmtRaw,pmtAssetId,userAddress,txId) = { | |
462 | + | func getD (xp) = { | |
463 | + | let n = big2 | |
464 | + | let xp0 = xp[0] | |
465 | + | let xp1 = xp[1] | |
466 | + | let aPrecision = parseBigIntValue(Amult) | |
467 | + | let a = (parseBigIntValue(A) * aPrecision) | |
468 | + | let s = (xp0 + xp1) | |
469 | + | if ((s == big0)) | |
470 | + | then big0 | |
471 | + | else { | |
472 | + | let ann = (a * n) | |
473 | + | func calc (acc,cur) = { | |
474 | + | let $t02109621116 = acc | |
475 | + | let d = $t02109621116._1 | |
476 | + | let found = $t02109621116._2 | |
477 | + | if ((found != unit)) | |
478 | + | then acc | |
479 | + | else { | |
480 | + | let dp = (((d * d) * d) / (((xp0 * xp1) * n) * n)) | |
481 | + | let dNext = (((((ann * s) / aPrecision) + (dp * n)) * d) / ((((ann - aPrecision) * d) / aPrecision) + ((n + big1) * dp))) | |
482 | + | let dDiff = absBigInt((dNext - value(d))) | |
483 | + | if ((big1 >= dDiff)) | |
484 | + | then $Tuple2(dNext, cur) | |
485 | + | else $Tuple2(dNext, unit) | |
486 | + | } | |
487 | + | } | |
488 | + | ||
489 | + | let arr = [0, 1, 2, 3, 4, 5, 6] | |
490 | + | let $t02153221578 = { | |
491 | + | let $l = arr | |
492 | + | let $s = size($l) | |
493 | + | let $acc0 = $Tuple2(s, unit) | |
494 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
495 | + | then $a | |
496 | + | else calc($a, $l[$i]) | |
497 | + | ||
498 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
499 | + | then $a | |
500 | + | else throw("List size exceeds 7") | |
501 | + | ||
502 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7) | |
503 | + | } | |
504 | + | let d = $t02153221578._1 | |
505 | + | let found = $t02153221578._2 | |
506 | + | if ((found != unit)) | |
507 | + | then d | |
508 | + | else throw(("D calculation error, D = " + toString(d))) | |
509 | + | } | |
510 | + | } | |
511 | + | ||
512 | + | ||
513 | + | func getYD (xp,i,D) = { | |
514 | + | let n = big2 | |
515 | + | let x = xp[if ((i == 0)) | |
516 | + | then 1 | |
517 | + | else 0] | |
518 | + | let aPrecision = parseBigIntValue(Amult) | |
519 | + | let a = (parseBigIntValue(A) * aPrecision) | |
520 | + | let s = x | |
521 | + | let ann = (a * n) | |
522 | + | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
523 | + | let b = ((s + ((D * aPrecision) / ann)) - D) | |
524 | + | func calc (acc,cur) = { | |
525 | + | let $t02207822098 = acc | |
526 | + | let y = $t02207822098._1 | |
527 | + | let found = $t02207822098._2 | |
528 | + | if ((found != unit)) | |
529 | + | then acc | |
530 | + | else { | |
531 | + | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
532 | + | let yDiff = absBigInt((yNext - value(y))) | |
533 | + | if ((big1 >= yDiff)) | |
534 | + | then $Tuple2(yNext, cur) | |
535 | + | else $Tuple2(yNext, unit) | |
536 | + | } | |
537 | + | } | |
538 | + | ||
539 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
540 | + | let $t02240522452 = { | |
541 | + | let $l = arr | |
542 | + | let $s = size($l) | |
543 | + | let $acc0 = $Tuple2(D, unit) | |
544 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
545 | + | then $a | |
546 | + | else calc($a, $l[$i]) | |
547 | + | ||
548 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
549 | + | then $a | |
550 | + | else throw("List size exceeds 15") | |
551 | + | ||
552 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
553 | + | } | |
554 | + | let y = $t02240522452._1 | |
555 | + | let found = $t02240522452._2 | |
556 | + | if ((found != unit)) | |
557 | + | then y | |
558 | + | else throw(("Y calculation error, Y = " + toString(y))) | |
559 | + | } | |
560 | + | ||
561 | + | ||
562 | + | func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId) = { | |
463 | 563 | let poolConfig = gpc() | |
464 | 564 | let amId = poolConfig[idxAmAsId] | |
465 | 565 | let prId = poolConfig[idxPrAsId] | |
566 | + | let lpId = poolConfig[idxLPAsId] | |
567 | + | let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm]) | |
568 | + | let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm]) | |
466 | 569 | let amBalance = getAccBalance(amId) | |
467 | 570 | let prBalance = getAccBalance(prId) | |
468 | - | let $ | |
469 | - | let pmtAmt = $ | |
470 | - | let feeAmount = $ | |
471 | - | let $ | |
571 | + | let $t02299423039 = takeFee(pmtAmtRaw) | |
572 | + | let pmtAmt = $t02299423039._1 | |
573 | + | let feeAmount = $t02299423039._2 | |
574 | + | let $t02304323504 = if ((txId == "")) | |
472 | 575 | then $Tuple2(amBalance, prBalance) | |
473 | 576 | else if ((pmtAssetId == amId)) | |
474 | 577 | then if ((pmtAmtRaw > amBalance)) | |
479 | 582 | then throw("invalid payment amount") | |
480 | 583 | else $Tuple2(amBalance, (prBalance - pmtAmtRaw)) | |
481 | 584 | else throw("wrong pmtAssetId") | |
482 | - | let amBalanceNow = $t02107621537._1 | |
483 | - | let prBalanceNow = $t02107621537._2 | |
484 | - | let $t02154121675 = if ((pmtAssetId == amId)) | |
485 | - | then $Tuple2(amBalanceNow, prBalanceNow) | |
486 | - | else $Tuple2(prBalanceNow, amBalanceNow) | |
487 | - | let amBalanceForCalc = $t02154121675._1 | |
488 | - | let prBalanceForCalc = $t02154121675._2 | |
489 | - | let xPrecision = 1 | |
490 | - | let result = { | |
491 | - | let @ = invoke(gwxContract, "calcPutXOnly", [toString(pmtAmt), toString(amBalanceForCalc), toString(prBalanceForCalc), "", A, Amult, toString(xPrecision), Dconv], nil) | |
492 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
493 | - | then @ | |
494 | - | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
495 | - | } | |
496 | - | let $t02214422240 = if ((pmtAssetId == amId)) | |
497 | - | then result | |
498 | - | else $Tuple2(result._2, result._1) | |
499 | - | let amAssetPart = $t02214422240._1 | |
500 | - | let prAssetPart = $t02214422240._2 | |
501 | - | let estPut = cp(userAddress, txId, AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), 0, true, true, false, pmtAmtRaw, pmtAssetId) | |
502 | - | let estimLP = estPut._2 | |
503 | - | let lpAssetId = estPut._7 | |
504 | - | let state = estPut._9 | |
505 | - | let amDiff = estPut._10 | |
506 | - | let prDiff = estPut._11 | |
507 | - | estPut | |
585 | + | let amBalanceOld = $t02304323504._1 | |
586 | + | let prBalanceOld = $t02304323504._2 | |
587 | + | let $t02351023674 = if ((pmtAssetId == amId)) | |
588 | + | then $Tuple2(pmtAmt, 0) | |
589 | + | else if ((pmtAssetId == prId)) | |
590 | + | then $Tuple2(0, pmtAmt) | |
591 | + | else throw("invalid payment") | |
592 | + | let amAmount = $t02351023674._1 | |
593 | + | let prAmount = $t02351023674._2 | |
594 | + | let amBalanceNew = (amBalanceOld + amAmount) | |
595 | + | let prBalanceNew = (prBalanceOld + prAmount) | |
596 | + | let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)]) | |
597 | + | let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)]) | |
598 | + | let checkD = if ((D1 > D0)) | |
599 | + | then true | |
600 | + | else throw() | |
601 | + | if ((checkD == checkD)) | |
602 | + | then { | |
603 | + | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
604 | + | let lpAmount = if ((lpAssetEmission > big0)) | |
605 | + | then fraction(lpAssetEmission, (D1 - D0), D0) | |
606 | + | else throw("initial deposit requires all coins") | |
607 | + | let curPrice = { | |
608 | + | let amBalanceX18 = t1(amBalance, amtDcm) | |
609 | + | let prBalanceX18 = t1(prBalance, priceDcm) | |
610 | + | f1(cpbi(prBalanceX18, amBalanceX18), scale8) | |
611 | + | } | |
612 | + | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId), dataPutActionInfo(amAmount, prAmount, toInt(lpAmount), curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
613 | + | let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld) | |
614 | + | let amountAssetPart = fraction(pmtAmt, scale8, (poolProportion + scale8)) | |
615 | + | let priceAssetPart = (pmtAmt - amountAssetPart) | |
616 | + | let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld)) | |
617 | + | let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth)) | |
618 | + | $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus) | |
619 | + | } | |
620 | + | else throw("Strict value is not equal to itself.") | |
508 | 621 | } | |
509 | 622 | ||
510 | 623 | ||
533 | 646 | else { | |
534 | 647 | let amBalance = getAccBalance(amId) | |
535 | 648 | let prBalance = getAccBalance(prId) | |
536 | - | let $ | |
649 | + | let $t02606926177 = { | |
537 | 650 | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
538 | 651 | if ($isInstanceOf(@, "(Int, Int)")) | |
539 | 652 | then @ | |
540 | 653 | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
541 | 654 | } | |
542 | - | let totalGet = $ | |
543 | - | let feeAmount = $ | |
655 | + | let totalGet = $t02606926177._1 | |
656 | + | let feeAmount = $t02606926177._2 | |
544 | 657 | let totalAmount = if (if ((minOutAmount > 0)) | |
545 | 658 | then (minOutAmount > totalGet) | |
546 | 659 | else false) | |
547 | 660 | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
548 | 661 | else totalGet | |
549 | - | let $ | |
662 | + | let $t02636426451 = if ((outAssetId == amId)) | |
550 | 663 | then $Tuple2(totalAmount, 0) | |
551 | 664 | else $Tuple2(0, totalAmount) | |
552 | - | let outAm = $ | |
553 | - | let outPr = $ | |
665 | + | let outAm = $t02636426451._1 | |
666 | + | let outPr = $t02636426451._2 | |
554 | 667 | let curPrX18 = cpbi(t1(prBalance, prDecimals), t1(amBalance, amDecimals)) | |
555 | 668 | let curPr = f1(curPrX18, scale8) | |
556 | 669 | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
571 | 684 | } | |
572 | 685 | } | |
573 | 686 | } | |
574 | - | ||
575 | - | ||
576 | - | func getD (xp) = { | |
577 | - | let n = big2 | |
578 | - | let xp0 = xp[0] | |
579 | - | let xp1 = xp[1] | |
580 | - | let aPrecision = parseBigIntValue(Amult) | |
581 | - | let a = (parseBigIntValue(A) * aPrecision) | |
582 | - | let s = (xp0 + xp1) | |
583 | - | if ((s == big0)) | |
584 | - | then big0 | |
585 | - | else { | |
586 | - | let ann = (a * n) | |
587 | - | func calc (acc,cur) = { | |
588 | - | let $t02513525155 = acc | |
589 | - | let d = $t02513525155._1 | |
590 | - | let found = $t02513525155._2 | |
591 | - | if ((found != unit)) | |
592 | - | then acc | |
593 | - | else { | |
594 | - | let dp = (((d * d) * d) / (((xp0 * xp1) * n) * n)) | |
595 | - | let dNext = (((((ann * s) / aPrecision) + (dp * n)) * d) / ((((ann - aPrecision) * d) / aPrecision) + ((n + big1) * dp))) | |
596 | - | let dDiff = absBigInt((dNext - value(d))) | |
597 | - | if ((big1 >= dDiff)) | |
598 | - | then $Tuple2(dNext, cur) | |
599 | - | else $Tuple2(dNext, unit) | |
600 | - | } | |
601 | - | } | |
602 | - | ||
603 | - | let arr = [0, 1, 2, 3, 4, 5, 6] | |
604 | - | let $t02557125617 = { | |
605 | - | let $l = arr | |
606 | - | let $s = size($l) | |
607 | - | let $acc0 = $Tuple2(s, unit) | |
608 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
609 | - | then $a | |
610 | - | else calc($a, $l[$i]) | |
611 | - | ||
612 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
613 | - | then $a | |
614 | - | else throw("List size exceeds 7") | |
615 | - | ||
616 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7) | |
617 | - | } | |
618 | - | let d = $t02557125617._1 | |
619 | - | let found = $t02557125617._2 | |
620 | - | if ((found != unit)) | |
621 | - | then d | |
622 | - | else throw(("D calculation error, D = " + toString(d))) | |
623 | - | } | |
624 | - | } | |
625 | - | ||
626 | - | ||
627 | - | func getYD (xp,i,D) = { | |
628 | - | let n = big2 | |
629 | - | let x = xp[if ((i == 0)) | |
630 | - | then 1 | |
631 | - | else 0] | |
632 | - | let aPrecision = parseBigIntValue(Amult) | |
633 | - | let a = (parseBigIntValue(A) * aPrecision) | |
634 | - | let s = x | |
635 | - | let ann = (a * n) | |
636 | - | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
637 | - | let b = ((s + ((D * aPrecision) / ann)) - D) | |
638 | - | func calc (acc,cur) = { | |
639 | - | let $t02611726137 = acc | |
640 | - | let y = $t02611726137._1 | |
641 | - | let found = $t02611726137._2 | |
642 | - | if ((found != unit)) | |
643 | - | then acc | |
644 | - | else { | |
645 | - | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
646 | - | let yDiff = absBigInt((yNext - value(y))) | |
647 | - | if ((big1 >= yDiff)) | |
648 | - | then $Tuple2(yNext, cur) | |
649 | - | else $Tuple2(yNext, unit) | |
650 | - | } | |
651 | - | } | |
652 | - | ||
653 | - | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
654 | - | let $t02644426491 = { | |
655 | - | let $l = arr | |
656 | - | let $s = size($l) | |
657 | - | let $acc0 = $Tuple2(D, unit) | |
658 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
659 | - | then $a | |
660 | - | else calc($a, $l[$i]) | |
661 | - | ||
662 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
663 | - | then $a | |
664 | - | else throw("List size exceeds 15") | |
665 | - | ||
666 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
667 | - | } | |
668 | - | let y = $t02644426491._1 | |
669 | - | let found = $t02644426491._2 | |
670 | - | if ((found != unit)) | |
671 | - | then y | |
672 | - | else throw(("Y calculation error, Y = " + toString(y))) | |
673 | - | } | |
674 | 687 | ||
675 | 688 | ||
676 | 689 | func m () = match getString(mpk()) { | |
844 | 857 | let pmt = value(i.payments[0]) | |
845 | 858 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
846 | 859 | let paymentAmountRaw = pmt.amount | |
847 | - | let $ | |
848 | - | let pmtAmt = $ | |
849 | - | let feeAmount = $ | |
860 | + | let $t03183731889 = takeFee(paymentAmountRaw) | |
861 | + | let pmtAmt = $t03183731889._1 | |
862 | + | let feeAmount = $t03183731889._2 | |
850 | 863 | if ((10000000 > paymentAmountRaw)) | |
851 | 864 | then throw("Wrong pmt amt") | |
852 | 865 | else { | |
853 | 866 | let amBalance = getAccBalance(amId) | |
854 | 867 | let prBalance = getAccBalance(prId) | |
855 | - | let $ | |
868 | + | let $t03204932665 = if ((pmtAssetId == amId)) | |
856 | 869 | then if (if ((paymentAmountRaw > amBalance)) | |
857 | 870 | then true | |
858 | 871 | else (amAssetPart > pmtAmt)) | |
865 | 878 | then throw("invalid payment amount") | |
866 | 879 | else $Tuple6(amBalance, (prBalance - paymentAmountRaw), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
867 | 880 | else throw("wrong pmtAssetId") | |
868 | - | let amBalanceNow = $ | |
869 | - | let prBalanceNow = $ | |
870 | - | let virtSwapInAm = $ | |
871 | - | let virtSwapOutPr = $ | |
872 | - | let virtSwapInPr = $ | |
873 | - | let virtSwapOutAm = $ | |
881 | + | let amBalanceNow = $t03204932665._1 | |
882 | + | let prBalanceNow = $t03204932665._2 | |
883 | + | let virtSwapInAm = $t03204932665._3 | |
884 | + | let virtSwapOutPr = $t03204932665._4 | |
885 | + | let virtSwapInPr = $t03204932665._5 | |
886 | + | let virtSwapOutAm = $t03204932665._6 | |
874 | 887 | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
875 | 888 | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
876 | 889 | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
940 | 953 | let poolConfig = gpc() | |
941 | 954 | let amId = poolConfig[idxAmAsId] | |
942 | 955 | let prId = poolConfig[idxPrAsId] | |
956 | + | let lpId = fromBase58String(poolConfig[idxLPAsId]) | |
943 | 957 | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
944 | 958 | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
945 | 959 | let userAddress = if ((i.caller == this)) | |
951 | 965 | if ((10000000 > pmtAmt)) | |
952 | 966 | then throw("Wrong pmt amt") | |
953 | 967 | else { | |
954 | - | let r = estimatePutOneTknV2(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId)) | |
955 | - | let estimLP = r._2 | |
956 | - | let lpAssetId = r._7 | |
957 | - | let state = r._9 | |
958 | - | let amDiff = r._10 | |
959 | - | let prDiff = r._11 | |
968 | + | let $t03557135696 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId)) | |
969 | + | let estimLP = $t03557135696._1 | |
970 | + | let state = $t03557135696._2 | |
971 | + | let feeAmount = $t03557135696._3 | |
960 | 972 | let emitLpAmt = if (if ((minOutAmount > 0)) | |
961 | 973 | then (minOutAmount > estimLP) | |
962 | 974 | else false) | |
973 | 985 | } | |
974 | 986 | if ((el == el)) | |
975 | 987 | then { | |
976 | - | let sa = if ((amDiff > 0)) | |
977 | - | then invoke(slipageContract, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
978 | - | else nil | |
979 | - | if ((sa == sa)) | |
988 | + | let lpTrnsfr = if (autoStake) | |
980 | 989 | then { | |
981 | - | let sp = if ((prDiff > 0)) | |
982 | - | then invoke(slipageContract, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
983 | - | else nil | |
984 | - | if ((sp == sp)) | |
985 | - | then { | |
986 | - | let lpTrnsfr = if (autoStake) | |
987 | - | then { | |
988 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
989 | - | if ((ss == ss)) | |
990 | - | then nil | |
991 | - | else throw("Strict value is not equal to itself.") | |
992 | - | } | |
993 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
994 | - | let feeAmount = takeFee(pmtAmt)._2 | |
995 | - | let sendFeeToMatcher = if ((feeAmount > 0)) | |
996 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
997 | - | else nil | |
998 | - | $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt) | |
999 | - | } | |
990 | + | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
991 | + | if ((ss == ss)) | |
992 | + | then nil | |
1000 | 993 | else throw("Strict value is not equal to itself.") | |
1001 | 994 | } | |
1002 | - | else throw("Strict value is not equal to itself.") | |
995 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpId)] | |
996 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
997 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
998 | + | else nil | |
999 | + | $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt) | |
1003 | 1000 | } | |
1004 | 1001 | else throw("Strict value is not equal to itself.") | |
1005 | 1002 | } | |
1006 | 1003 | else throw("Strict value is not equal to itself.") | |
1007 | 1004 | } | |
1008 | 1005 | } | |
1009 | - | ||
1010 | - | ||
1011 | - | ||
1012 | - | @Callable(i) | |
1013 | - | func putOneTknV2WithBonusOldREADONLY (paymentAmount,paymentAssetId) = { | |
1014 | - | let poolConfig = gpc() | |
1015 | - | let amId = poolConfig[idxAmAsId] | |
1016 | - | let prId = poolConfig[idxPrAsId] | |
1017 | - | let r = estimatePutOneTknV2(paymentAmount, paymentAssetId, "", "") | |
1018 | - | let estimLP = r._2 | |
1019 | - | let curPrice = r._3 | |
1020 | - | let lpAssetEmission = r._6 | |
1021 | - | let lpAssetId = r._7 | |
1022 | - | let amBalance = getAccBalance(amId) | |
1023 | - | let prBalance = getAccBalance(prId) | |
1024 | - | let poolProportion = fraction(prBalance, scale8, amBalance) | |
1025 | - | let amountAssetPart = fraction(paymentAmount, scale8, (poolProportion + scale8)) | |
1026 | - | let priceAssetPart = (paymentAmount - amountAssetPart) | |
1027 | - | let lpAmtBoth = fraction(lpAssetEmission, priceAssetPart, prBalance) | |
1028 | - | let bonus = fraction((estimLP - lpAmtBoth), scale8, lpAmtBoth) | |
1029 | - | let feeAmount = takeFee(paymentAmount)._2 | |
1030 | - | $Tuple2(nil, $Tuple3(estimLP, feeAmount, bonus)) | |
1031 | - | } | |
1032 | 1006 | ||
1033 | 1007 | ||
1034 | 1008 | ||
1097 | 1071 | let estimPrAmt = r._2 | |
1098 | 1072 | let amBalance = getAccBalance(amId) | |
1099 | 1073 | let prBalance = getAccBalance(prId) | |
1100 | - | let $ | |
1074 | + | let $t03932739787 = if ((outAssetId == amId)) | |
1101 | 1075 | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
1102 | 1076 | else if ((outAssetId == prId)) | |
1103 | 1077 | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
1104 | 1078 | else throw("wrong outAssetId") | |
1105 | - | let amBalanceNow = $ | |
1106 | - | let prBalanceNow = $ | |
1107 | - | let virtSwapInAm = $ | |
1108 | - | let virtSwapOutPr = $ | |
1109 | - | let virtSwapInPr = $ | |
1110 | - | let virtSwapOutAm = $ | |
1111 | - | let totalGetRaw = $ | |
1079 | + | let amBalanceNow = $t03932739787._1 | |
1080 | + | let prBalanceNow = $t03932739787._2 | |
1081 | + | let virtSwapInAm = $t03932739787._3 | |
1082 | + | let virtSwapOutPr = $t03932739787._4 | |
1083 | + | let virtSwapInPr = $t03932739787._5 | |
1084 | + | let virtSwapOutAm = $t03932739787._6 | |
1085 | + | let totalGetRaw = $t03932739787._7 | |
1112 | 1086 | if (if ((0 > virtSwapInAm)) | |
1113 | 1087 | then true | |
1114 | 1088 | else (0 > virtSwapInPr)) | |
1123 | 1097 | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
1124 | 1098 | if ((finalRes == finalRes)) | |
1125 | 1099 | then { | |
1126 | - | let $ | |
1100 | + | let $t04053440638 = if ((outAssetId == amId)) | |
1127 | 1101 | then $Tuple2(toInt(finalRes._2), 0) | |
1128 | 1102 | else $Tuple2(0, toInt(finalRes._2)) | |
1129 | - | let outAm = $ | |
1130 | - | let outPr = $ | |
1103 | + | let outAm = $t04053440638._1 | |
1104 | + | let outPr = $t04053440638._2 | |
1131 | 1105 | let totalAmount = (outAm + outPr) | |
1132 | 1106 | let feeAmount = (totalGetRaw - totalGet) | |
1133 | 1107 | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
1159 | 1133 | ||
1160 | 1134 | @Callable(i) | |
1161 | 1135 | func getOneTknV2 (outAssetId,minOutAmount) = { | |
1162 | - | let $ | |
1163 | - | let state = $ | |
1164 | - | let totalAmount = $ | |
1136 | + | let $t04166341818 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId) | |
1137 | + | let state = $t04166341818._1 | |
1138 | + | let totalAmount = $t04166341818._2 | |
1165 | 1139 | $Tuple2(state, totalAmount) | |
1166 | 1140 | } | |
1167 | 1141 | ||
1180 | 1154 | let prBalance = getAccBalance(prId) | |
1181 | 1155 | let amBalanceNow = (amBalance - estimAmAmt) | |
1182 | 1156 | let prBalanceNow = (prBalance - estimPrAmt) | |
1183 | - | let $ | |
1157 | + | let $t04233142639 = if ((outAssetId == amId)) | |
1184 | 1158 | then $Tuple4(prBalanceNow, amBalanceNow, estimPrAmt, estimAmAmt) | |
1185 | 1159 | else if ((outAssetId == prId)) | |
1186 | 1160 | then $Tuple4(amBalanceNow, prBalanceNow, estimAmAmt, estimPrAmt) | |
1187 | 1161 | else throw("wrong outAssetId") | |
1188 | - | let amountBalanceForSwap = $ | |
1189 | - | let priceBalanceForSwap = $ | |
1190 | - | let amountToSwap = $ | |
1191 | - | let amountToAdd = $ | |
1162 | + | let amountBalanceForSwap = $t04233142639._1 | |
1163 | + | let priceBalanceForSwap = $t04233142639._2 | |
1164 | + | let amountToSwap = $t04233142639._3 | |
1165 | + | let amountToAdd = $t04233142639._4 | |
1192 | 1166 | let yPrecision = 1 | |
1193 | 1167 | let exchResult = { | |
1194 | 1168 | let @ = invoke(gwxContract, "calcSwapXToY", [toString(amountToSwap), toString(amountBalanceForSwap), toString(priceBalanceForSwap), "", A, Amult, toString(yPrecision), Dconv], nil) | |
1197 | 1171 | else throw(($getType(@) + " couldn't be cast to Int")) | |
1198 | 1172 | } | |
1199 | 1173 | let totalGetRaw = (exchResult + amountToAdd) | |
1200 | - | let $ | |
1201 | - | let totalGet = $ | |
1202 | - | let feeAmount = $ | |
1174 | + | let $t04316743216 = takeFee(totalGetRaw) | |
1175 | + | let totalGet = $t04316743216._1 | |
1176 | + | let feeAmount = $t04316743216._2 | |
1203 | 1177 | $Tuple2(nil, $Tuple2(totalGet, feeAmount)) | |
1204 | 1178 | } | |
1205 | 1179 | ||
1221 | 1195 | let newY = getYD(xp, index, D1) | |
1222 | 1196 | let dy = (xp[index] - newY) | |
1223 | 1197 | let totalGetRaw = toInt((dy - big1)) | |
1224 | - | let $ | |
1225 | - | let totalGet = $ | |
1226 | - | let feeAmount = $ | |
1198 | + | let $t04390743956 = takeFee(totalGetRaw) | |
1199 | + | let totalGet = $t04390743956._1 | |
1200 | + | let feeAmount = $t04390743956._2 | |
1227 | 1201 | $Tuple2(nil, $Tuple2(totalGet, feeAmount)) | |
1228 | 1202 | } | |
1229 | 1203 | ||
1237 | 1211 | let lpId = poolConfig[idxLPAsId] | |
1238 | 1212 | let amBalance = getAccBalance(amId) | |
1239 | 1213 | let prBalance = getAccBalance(prId) | |
1240 | - | let $ | |
1214 | + | let $t04430144416 = { | |
1241 | 1215 | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil) | |
1242 | 1216 | if ($isInstanceOf(@, "(Int, Int)")) | |
1243 | 1217 | then @ | |
1244 | 1218 | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
1245 | 1219 | } | |
1246 | - | let totalGet = $ | |
1247 | - | let feeAmount = $ | |
1220 | + | let totalGet = $t04430144416._1 | |
1221 | + | let feeAmount = $t04430144416._2 | |
1248 | 1222 | let r = ego("", lpId, lpAssetAmount, this) | |
1249 | 1223 | let outAmAmt = r._1 | |
1250 | 1224 | let outPrAmt = r._2 | |
1329 | 1303 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil) | |
1330 | 1304 | if ((unstakeInv == unstakeInv)) | |
1331 | 1305 | then { | |
1332 | - | let $ | |
1333 | - | let state = $ | |
1334 | - | let totalAmount = $ | |
1306 | + | let $t04672146909 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId) | |
1307 | + | let state = $t04672146909._1 | |
1308 | + | let totalAmount = $t04672146909._2 | |
1335 | 1309 | $Tuple2(state, totalAmount) | |
1336 | 1310 | } | |
1337 | 1311 | else throw("Strict value is not equal to itself.") | |
1342 | 1316 | ||
1343 | 1317 | ||
1344 | 1318 | @Callable(i) | |
1345 | - | func putOneTknV2WithBonusREADONLY ( | |
1319 | + | func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1346 | 1320 | let poolConfig = gpc() | |
1347 | 1321 | let amId = poolConfig[idxAmAsId] | |
1348 | 1322 | let prId = poolConfig[idxPrAsId] | |
1349 | 1323 | let lpId = poolConfig[idxLPAsId] | |
1350 | - | let paymentAsset = asset | |
1351 | - | let paymentAmountRaw = amount | |
1352 | - | let $t04799448084 = takeFee(paymentAmountRaw) | |
1353 | - | let paymentAmount = $t04799448084._1 | |
1354 | - | let feeAmount = $t04799448084._2 | |
1355 | - | let $t04808848270 = if ((paymentAsset == amId)) | |
1356 | - | then $Tuple2(paymentAmount, 0) | |
1357 | - | else if ((paymentAsset == prId)) | |
1358 | - | then $Tuple2(0, paymentAmount) | |
1359 | - | else throw("invalid payment") | |
1360 | - | let amAmount = $t04808848270._1 | |
1361 | - | let prAmount = $t04808848270._2 | |
1362 | - | let amBalanceOld = getAccBalance(amId) | |
1363 | - | let prBalanceOld = getAccBalance(prId) | |
1364 | - | let amBalanceNew = (amBalanceOld + amAmount) | |
1365 | - | let prBalanceNew = (prBalanceOld + prAmount) | |
1366 | - | let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)]) | |
1367 | - | let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)]) | |
1368 | - | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
1369 | - | let lpAmount = ((lpAssetEmission * (D1 - D0)) / D0) | |
1370 | - | let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld) | |
1371 | - | let amountAssetPart = fraction(paymentAmount, scale8, (poolProportion + scale8)) | |
1372 | - | let priceAssetPart = (paymentAmount - amountAssetPart) | |
1373 | - | let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld)) | |
1374 | - | let bonus = fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth) | |
1375 | - | $Tuple2(nil, $Tuple3(toInt(lpAmount), feeAmount, toInt(bonus))) | |
1324 | + | let $t04716847265 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "") | |
1325 | + | let lpAmount = $t04716847265._1 | |
1326 | + | let state = $t04716847265._2 | |
1327 | + | let feeAmount = $t04716847265._3 | |
1328 | + | let bonus = $t04716847265._4 | |
1329 | + | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1376 | 1330 | } | |
1377 | 1331 | ||
1378 | 1332 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let scale8 = 100000000 | |
5 | 5 | ||
6 | 6 | let scale8BigInt = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | let scale18 = toBigInt(1000000000000000000) | |
9 | 9 | ||
10 | 10 | let zeroBigInt = toBigInt(0) | |
11 | 11 | ||
12 | 12 | let big0 = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big1 = toBigInt(1) | |
15 | 15 | ||
16 | 16 | let big2 = toBigInt(2) | |
17 | 17 | ||
18 | 18 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
19 | 19 | ||
20 | 20 | let Amult = "100" | |
21 | 21 | ||
22 | 22 | let Dconv = "1" | |
23 | 23 | ||
24 | 24 | let SEP = "__" | |
25 | 25 | ||
26 | 26 | let EMPTY = "" | |
27 | 27 | ||
28 | 28 | let PoolActive = 1 | |
29 | 29 | ||
30 | 30 | let PoolPutDis = 2 | |
31 | 31 | ||
32 | 32 | let PoolMatcherDis = 3 | |
33 | 33 | ||
34 | 34 | let PoolShutdown = 4 | |
35 | 35 | ||
36 | 36 | let idxPoolAddress = 1 | |
37 | 37 | ||
38 | 38 | let idxPoolSt = 2 | |
39 | 39 | ||
40 | 40 | let idxLPAsId = 3 | |
41 | 41 | ||
42 | 42 | let idxAmAsId = 4 | |
43 | 43 | ||
44 | 44 | let idxPrAsId = 5 | |
45 | 45 | ||
46 | 46 | let idxAmtAsDcm = 6 | |
47 | 47 | ||
48 | 48 | let idxPriceAsDcm = 7 | |
49 | 49 | ||
50 | 50 | let idxIAmtAsId = 8 | |
51 | 51 | ||
52 | 52 | let idxIPriceAsId = 9 | |
53 | 53 | ||
54 | 54 | let idxFactStakCntr = 1 | |
55 | 55 | ||
56 | 56 | let idxFactSlippCntr = 7 | |
57 | 57 | ||
58 | 58 | let idxFactGwxRewCntr = 10 | |
59 | 59 | ||
60 | 60 | let feeDefault = fraction(5, scale8, 10000) | |
61 | 61 | ||
62 | 62 | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func abs (val) = if ((zeroBigInt > val)) | |
72 | 72 | then -(val) | |
73 | 73 | else val | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func absBigInt (val) = if ((zeroBigInt > val)) | |
77 | 77 | then -(val) | |
78 | 78 | else val | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func fc () = "%s__factoryContract" | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func mpk () = "%s__managerPublicKey" | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func pmpk () = "%s__pendingManagerPublicKey" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func pl () = "%s%s__price__last" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP) | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId) | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func aa () = "%s__amountAsset" | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pa () = "%s__priceAsset" | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | func amp () = "%s__amp" | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | func ada () = "%s__addonAddr" | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | let keyFee = "%s__fee" | |
115 | 115 | ||
116 | 116 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
117 | 117 | ||
118 | 118 | func fcfg () = "%s__factoryConfig" | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | func mtpk () = "%s%s__matcher__publicKey" | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | func aps () = "%s__shutdown" | |
131 | 131 | ||
132 | 132 | ||
133 | 133 | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" | |
134 | 134 | ||
135 | 135 | ||
136 | 136 | func keyFeeCollectorAddress () = "%s__feeCollectorAddress" | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
140 | 140 | ||
141 | 141 | ||
142 | 142 | func str (val) = match val { | |
143 | 143 | case valStr: String => | |
144 | 144 | valStr | |
145 | 145 | case _ => | |
146 | 146 | throw("fail cast to String") | |
147 | 147 | } | |
148 | 148 | ||
149 | 149 | ||
150 | 150 | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
151 | 151 | ||
152 | 152 | ||
153 | 153 | func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
154 | 154 | ||
155 | 155 | ||
156 | 156 | let fca = addressFromStringValue(strf(this, fc())) | |
157 | 157 | ||
158 | 158 | let A = strf(this, amp()) | |
159 | 159 | ||
160 | 160 | func igs () = valueOrElse(getBoolean(fca, aps()), false) | |
161 | 161 | ||
162 | 162 | ||
163 | 163 | func mp () = fromBase58String(strf(fca, mtpk())) | |
164 | 164 | ||
165 | 165 | ||
166 | 166 | let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress())) | |
167 | 167 | ||
168 | 168 | func gpc () = { | |
169 | 169 | let amtAs = strf(this, aa()) | |
170 | 170 | let priceAs = strf(this, pa()) | |
171 | 171 | let iPriceAs = intf(fca, mba(priceAs)) | |
172 | 172 | let iAmtAs = intf(fca, mba(amtAs)) | |
173 | 173 | split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP) | |
174 | 174 | } | |
175 | 175 | ||
176 | 176 | ||
177 | 177 | func gfc () = split(strf(fca, fcfg()), SEP) | |
178 | 178 | ||
179 | 179 | ||
180 | 180 | let factoryConfig = gfc() | |
181 | 181 | ||
182 | 182 | let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address") | |
183 | 183 | ||
184 | 184 | let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address") | |
185 | 185 | ||
186 | 186 | let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address") | |
187 | 187 | ||
188 | 188 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slipByUser,slippageReal,txHeight,txTimestamp,slipageAmAmt,slipagePrAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slipByUser), toString(slippageReal), toString(txHeight), toString(txTimestamp), toString(slipageAmAmt), toString(slipagePrAmt)], SEP) | |
189 | 189 | ||
190 | 190 | ||
191 | 191 | func dataGetActionInfo (outAmtAssetAmt,outPriceAssetAmt,inLpAmt,price,txHeight,txTimestamp) = makeString(["%d%d%d%d%d%d", toString(outAmtAssetAmt), toString(outPriceAssetAmt), toString(inLpAmt), toString(price), toString(txHeight), toString(txTimestamp)], SEP) | |
192 | 192 | ||
193 | 193 | ||
194 | 194 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
195 | 195 | then wavesBalance(this).available | |
196 | 196 | else assetBalance(this, fromBase58String(assetId)) | |
197 | 197 | ||
198 | 198 | ||
199 | 199 | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
200 | 200 | ||
201 | 201 | ||
202 | 202 | func vad (A1,A2,slippage) = { | |
203 | 203 | let diff = fraction((A1 - A2), scale8BigInt, A2) | |
204 | 204 | let pass = ((slippage - abs(diff)) > zeroBigInt) | |
205 | 205 | if (!(pass)) | |
206 | 206 | then throw(("Big slpg: " + toString(diff))) | |
207 | 207 | else $Tuple2(pass, min([A1, A2])) | |
208 | 208 | } | |
209 | 209 | ||
210 | 210 | ||
211 | 211 | func vd (D1,D0,slpg) = { | |
212 | 212 | let diff = fraction(D0, scale8BigInt, D1) | |
213 | 213 | let fail = (slpg > diff) | |
214 | 214 | if (if (fail) | |
215 | 215 | then true | |
216 | 216 | else (D0 > D1)) | |
217 | 217 | then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg))) | |
218 | 218 | else fail | |
219 | 219 | } | |
220 | 220 | ||
221 | 221 | ||
222 | 222 | func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
223 | 223 | let amtAsAmtX18 = t1(amAmt, amAssetDcm) | |
224 | 224 | let prAsAmtX18 = t1(prAmt, prAssetDcm) | |
225 | 225 | cpbi(prAsAmtX18, amtAsAmtX18) | |
226 | 226 | } | |
227 | 227 | ||
228 | 228 | ||
229 | 229 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
230 | 230 | let cfg = gpc() | |
231 | 231 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
232 | 232 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
233 | 233 | let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt) | |
234 | 234 | let amAmtX18 = t1(amAmt, amtAsDcm) | |
235 | 235 | let prAmtX18 = t1(prAmt, prAsDcm) | |
236 | 236 | let lpAmtX18 = t1(lpAmt, scale8) | |
237 | 237 | let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18) | |
238 | 238 | let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18) | |
239 | 239 | [priceX18, lpPrInAmAsX18, lpPrInPrAsX18] | |
240 | 240 | } | |
241 | 241 | ||
242 | 242 | ||
243 | 243 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
244 | 244 | let p = calcPrices(amAmt, prAmt, lpAmt) | |
245 | 245 | [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)] | |
246 | 246 | } | |
247 | 247 | ||
248 | 248 | ||
249 | 249 | func takeFee (amount) = { | |
250 | 250 | let feeAmount = fraction(amount, fee, scale8) | |
251 | 251 | $Tuple2((amount - feeAmount), feeAmount) | |
252 | 252 | } | |
253 | 253 | ||
254 | 254 | ||
255 | 255 | func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
256 | 256 | let cfg = gpc() | |
257 | 257 | let lpId = cfg[idxLPAsId] | |
258 | 258 | let amId = cfg[idxAmAsId] | |
259 | 259 | let prId = cfg[idxPrAsId] | |
260 | 260 | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
261 | 261 | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
262 | 262 | let sts = cfg[idxPoolSt] | |
263 | 263 | let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity | |
264 | 264 | if ((lpId != pmtAssetId)) | |
265 | 265 | then throw("Wrong pmt asset") | |
266 | 266 | else { | |
267 | 267 | let amBalance = getAccBalance(amId) | |
268 | 268 | let amBalanceX18 = t1(amBalance, amDcm) | |
269 | 269 | let prBalance = getAccBalance(prId) | |
270 | 270 | let prBalanceX18 = t1(prBalance, prDcm) | |
271 | 271 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
272 | 272 | let curPrice = f1(curPriceX18, scale8) | |
273 | 273 | let pmtLpAmtX18 = t1(pmtLpAmt, scale8) | |
274 | 274 | let lpEmissX18 = t1(lpEmiss, scale8) | |
275 | 275 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
276 | 276 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
277 | 277 | let outAmAmt = f1(outAmAmtX18, amDcm) | |
278 | 278 | let outPrAmt = f1(outPrAmtX18, prDcm) | |
279 | 279 | let state = if ((txId58 == "")) | |
280 | 280 | then nil | |
281 | 281 | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
282 | 282 | then unit | |
283 | 283 | else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES")) | |
284 | 284 | then unit | |
285 | 285 | else fromBase58String(prId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
286 | 286 | $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state) | |
287 | 287 | } | |
288 | 288 | } | |
289 | 289 | ||
290 | 290 | ||
291 | 291 | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = { | |
292 | 292 | let cfg = gpc() | |
293 | 293 | let lpId = fromBase58String(cfg[idxLPAsId]) | |
294 | 294 | let amIdStr = cfg[idxAmAsId] | |
295 | 295 | let prIdStr = cfg[idxPrAsId] | |
296 | 296 | let inAmIdStr = cfg[idxIAmtAsId] | |
297 | 297 | let inPrIdStr = cfg[idxIPriceAsId] | |
298 | 298 | let amtDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
299 | 299 | let priceDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
300 | 300 | let sts = cfg[idxPoolSt] | |
301 | 301 | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
302 | 302 | let amBalance = if (isEval) | |
303 | 303 | then getAccBalance(amIdStr) | |
304 | 304 | else if (if (isOneAsset) | |
305 | 305 | then (pmtId == amIdStr) | |
306 | 306 | else false) | |
307 | 307 | then (getAccBalance(amIdStr) - pmtAmt) | |
308 | 308 | else if (isOneAsset) | |
309 | 309 | then getAccBalance(amIdStr) | |
310 | 310 | else (getAccBalance(amIdStr) - inAmAmt) | |
311 | 311 | let prBalance = if (isEval) | |
312 | 312 | then getAccBalance(prIdStr) | |
313 | 313 | else if (if (isOneAsset) | |
314 | 314 | then (pmtId == prIdStr) | |
315 | 315 | else false) | |
316 | 316 | then (getAccBalance(prIdStr) - pmtAmt) | |
317 | 317 | else if (isOneAsset) | |
318 | 318 | then getAccBalance(prIdStr) | |
319 | 319 | else (getAccBalance(prIdStr) - inPrAmt) | |
320 | 320 | let inAmAssetAmtX18 = t1(inAmAmt, amtDcm) | |
321 | 321 | let inPrAssetAmtX18 = t1(inPrAmt, priceDcm) | |
322 | 322 | let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18) | |
323 | 323 | let amBalanceX18 = t1(amBalance, amtDcm) | |
324 | 324 | let prBalanceX18 = t1(prBalance, priceDcm) | |
325 | 325 | let r = if ((lpEm == 0)) | |
326 | 326 | then { | |
327 | 327 | let curPriceX18 = zeroBigInt | |
328 | 328 | let slippageX18 = zeroBigInt | |
329 | 329 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
330 | 330 | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
331 | 331 | } | |
332 | 332 | else { | |
333 | 333 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
334 | 334 | let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
335 | 335 | let slippageX18 = t1(slippage, scale8) | |
336 | 336 | if (if (if (validateSlippage) | |
337 | 337 | then (curPriceX18 != zeroBigInt) | |
338 | 338 | else false) | |
339 | 339 | then (slippageRealX18 > slippageX18) | |
340 | 340 | else false) | |
341 | 341 | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
342 | 342 | else { | |
343 | 343 | let lpEmissionX18 = t1(lpEm, scale8) | |
344 | 344 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
345 | 345 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
346 | 346 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
347 | 347 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
348 | 348 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
349 | 349 | let expAmtAssetAmtX18 = expectedAmts._1 | |
350 | 350 | let expPriceAssetAmtX18 = expectedAmts._2 | |
351 | 351 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
352 | 352 | $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18) | |
353 | 353 | } | |
354 | 354 | } | |
355 | 355 | let calcLpAmt = r._1 | |
356 | 356 | let calcAmAssetPmt = r._2 | |
357 | 357 | let calcPrAssetPmt = r._3 | |
358 | 358 | let curPrice = f1(r._4, scale8) | |
359 | 359 | let slippageCalc = f1(r._5, scale8) | |
360 | 360 | if ((0 >= calcLpAmt)) | |
361 | 361 | then throw("LP <= 0") | |
362 | 362 | else { | |
363 | 363 | let emitLpAmt = if (!(emitLp)) | |
364 | 364 | then 0 | |
365 | 365 | else calcLpAmt | |
366 | 366 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
367 | 367 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
368 | 368 | let $t01635116696 = if (if (isOneAsset) | |
369 | 369 | then (pmtId == amIdStr) | |
370 | 370 | else false) | |
371 | 371 | then $Tuple2(pmtAmt, 0) | |
372 | 372 | else if (if (isOneAsset) | |
373 | 373 | then (pmtId == prIdStr) | |
374 | 374 | else false) | |
375 | 375 | then $Tuple2(0, pmtAmt) | |
376 | 376 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
377 | 377 | let writeAmAmt = $t01635116696._1 | |
378 | 378 | let writePrAmt = $t01635116696._2 | |
379 | 379 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
380 | 380 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
381 | 381 | } | |
382 | 382 | } | |
383 | 383 | ||
384 | 384 | ||
385 | 385 | func moa (order) = { | |
386 | 386 | let cfg = gpc() | |
387 | 387 | let amtAsId = cfg[idxAmAsId] | |
388 | 388 | let prAsId = cfg[idxPrAsId] | |
389 | 389 | let sts = parseIntValue(cfg[idxPoolSt]) | |
390 | 390 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
391 | 391 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
392 | 392 | let accAmtAsBalance = getAccBalance(amtAsId) | |
393 | 393 | let accPrAsBalance = getAccBalance(prAsId) | |
394 | 394 | let curPriceX18 = if ((order.orderType == Buy)) | |
395 | 395 | then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance) | |
396 | 396 | else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance) | |
397 | 397 | let curPrice = f1(curPriceX18, scale8) | |
398 | 398 | if (if (if (igs()) | |
399 | 399 | then true | |
400 | 400 | else (sts == PoolMatcherDis)) | |
401 | 401 | then true | |
402 | 402 | else (sts == PoolShutdown)) | |
403 | 403 | then throw("Admin blocked") | |
404 | 404 | else { | |
405 | 405 | let orAmtAsset = order.assetPair.amountAsset | |
406 | 406 | let orAmtAsStr = if ((orAmtAsset == unit)) | |
407 | 407 | then "WAVES" | |
408 | 408 | else toBase58String(value(orAmtAsset)) | |
409 | 409 | let orPrAsset = order.assetPair.priceAsset | |
410 | 410 | let orPrAsStr = if ((orPrAsset == unit)) | |
411 | 411 | then "WAVES" | |
412 | 412 | else toBase58String(value(orPrAsset)) | |
413 | 413 | if (if ((orAmtAsStr != amtAsId)) | |
414 | 414 | then true | |
415 | 415 | else (orPrAsStr != prAsId)) | |
416 | 416 | then throw("Wr assets") | |
417 | 417 | else { | |
418 | 418 | let orderPrice = order.price | |
419 | 419 | let priceDcm = fraction(scale8, prAsDcm, amtAsDcm) | |
420 | 420 | let castOrderPrice = ts(orderPrice, scale8, priceDcm) | |
421 | 421 | let isOrderPriceValid = if ((order.orderType == Buy)) | |
422 | 422 | then (curPrice >= castOrderPrice) | |
423 | 423 | else (castOrderPrice >= curPrice) | |
424 | 424 | true | |
425 | 425 | } | |
426 | 426 | } | |
427 | 427 | } | |
428 | 428 | ||
429 | 429 | ||
430 | 430 | func cg (i) = if ((size(i.payments) != 1)) | |
431 | 431 | then throw("1 pmnt exp") | |
432 | 432 | else { | |
433 | 433 | let pmt = value(i.payments[0]) | |
434 | 434 | let pmtAssetId = value(pmt.assetId) | |
435 | 435 | let pmtAmt = pmt.amount | |
436 | 436 | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
437 | 437 | let outAmAmt = r._1 | |
438 | 438 | let outPrAmt = r._2 | |
439 | 439 | let sts = parseIntValue(r._9) | |
440 | 440 | let state = r._10 | |
441 | 441 | if (if (igs()) | |
442 | 442 | then true | |
443 | 443 | else (sts == PoolShutdown)) | |
444 | 444 | then throw(("Admin blocked: " + toString(sts))) | |
445 | 445 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
446 | 446 | } | |
447 | 447 | ||
448 | 448 | ||
449 | 449 | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = { | |
450 | 450 | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, (txId == ""), emitLp, isOneAsset, validateSlippage, pmtAmt, pmtId) | |
451 | 451 | let sts = parseIntValue(r._8) | |
452 | 452 | if (if (if (igs()) | |
453 | 453 | then true | |
454 | 454 | else (sts == PoolPutDis)) | |
455 | 455 | then true | |
456 | 456 | else (sts == PoolShutdown)) | |
457 | 457 | then throw(("Blocked:" + toString(sts))) | |
458 | 458 | else r | |
459 | 459 | } | |
460 | 460 | ||
461 | 461 | ||
462 | - | func estimatePutOneTknV2 (pmtAmtRaw,pmtAssetId,userAddress,txId) = { | |
462 | + | func getD (xp) = { | |
463 | + | let n = big2 | |
464 | + | let xp0 = xp[0] | |
465 | + | let xp1 = xp[1] | |
466 | + | let aPrecision = parseBigIntValue(Amult) | |
467 | + | let a = (parseBigIntValue(A) * aPrecision) | |
468 | + | let s = (xp0 + xp1) | |
469 | + | if ((s == big0)) | |
470 | + | then big0 | |
471 | + | else { | |
472 | + | let ann = (a * n) | |
473 | + | func calc (acc,cur) = { | |
474 | + | let $t02109621116 = acc | |
475 | + | let d = $t02109621116._1 | |
476 | + | let found = $t02109621116._2 | |
477 | + | if ((found != unit)) | |
478 | + | then acc | |
479 | + | else { | |
480 | + | let dp = (((d * d) * d) / (((xp0 * xp1) * n) * n)) | |
481 | + | let dNext = (((((ann * s) / aPrecision) + (dp * n)) * d) / ((((ann - aPrecision) * d) / aPrecision) + ((n + big1) * dp))) | |
482 | + | let dDiff = absBigInt((dNext - value(d))) | |
483 | + | if ((big1 >= dDiff)) | |
484 | + | then $Tuple2(dNext, cur) | |
485 | + | else $Tuple2(dNext, unit) | |
486 | + | } | |
487 | + | } | |
488 | + | ||
489 | + | let arr = [0, 1, 2, 3, 4, 5, 6] | |
490 | + | let $t02153221578 = { | |
491 | + | let $l = arr | |
492 | + | let $s = size($l) | |
493 | + | let $acc0 = $Tuple2(s, unit) | |
494 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
495 | + | then $a | |
496 | + | else calc($a, $l[$i]) | |
497 | + | ||
498 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
499 | + | then $a | |
500 | + | else throw("List size exceeds 7") | |
501 | + | ||
502 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7) | |
503 | + | } | |
504 | + | let d = $t02153221578._1 | |
505 | + | let found = $t02153221578._2 | |
506 | + | if ((found != unit)) | |
507 | + | then d | |
508 | + | else throw(("D calculation error, D = " + toString(d))) | |
509 | + | } | |
510 | + | } | |
511 | + | ||
512 | + | ||
513 | + | func getYD (xp,i,D) = { | |
514 | + | let n = big2 | |
515 | + | let x = xp[if ((i == 0)) | |
516 | + | then 1 | |
517 | + | else 0] | |
518 | + | let aPrecision = parseBigIntValue(Amult) | |
519 | + | let a = (parseBigIntValue(A) * aPrecision) | |
520 | + | let s = x | |
521 | + | let ann = (a * n) | |
522 | + | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
523 | + | let b = ((s + ((D * aPrecision) / ann)) - D) | |
524 | + | func calc (acc,cur) = { | |
525 | + | let $t02207822098 = acc | |
526 | + | let y = $t02207822098._1 | |
527 | + | let found = $t02207822098._2 | |
528 | + | if ((found != unit)) | |
529 | + | then acc | |
530 | + | else { | |
531 | + | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
532 | + | let yDiff = absBigInt((yNext - value(y))) | |
533 | + | if ((big1 >= yDiff)) | |
534 | + | then $Tuple2(yNext, cur) | |
535 | + | else $Tuple2(yNext, unit) | |
536 | + | } | |
537 | + | } | |
538 | + | ||
539 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
540 | + | let $t02240522452 = { | |
541 | + | let $l = arr | |
542 | + | let $s = size($l) | |
543 | + | let $acc0 = $Tuple2(D, unit) | |
544 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
545 | + | then $a | |
546 | + | else calc($a, $l[$i]) | |
547 | + | ||
548 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
549 | + | then $a | |
550 | + | else throw("List size exceeds 15") | |
551 | + | ||
552 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
553 | + | } | |
554 | + | let y = $t02240522452._1 | |
555 | + | let found = $t02240522452._2 | |
556 | + | if ((found != unit)) | |
557 | + | then y | |
558 | + | else throw(("Y calculation error, Y = " + toString(y))) | |
559 | + | } | |
560 | + | ||
561 | + | ||
562 | + | func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId) = { | |
463 | 563 | let poolConfig = gpc() | |
464 | 564 | let amId = poolConfig[idxAmAsId] | |
465 | 565 | let prId = poolConfig[idxPrAsId] | |
566 | + | let lpId = poolConfig[idxLPAsId] | |
567 | + | let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm]) | |
568 | + | let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm]) | |
466 | 569 | let amBalance = getAccBalance(amId) | |
467 | 570 | let prBalance = getAccBalance(prId) | |
468 | - | let $ | |
469 | - | let pmtAmt = $ | |
470 | - | let feeAmount = $ | |
471 | - | let $ | |
571 | + | let $t02299423039 = takeFee(pmtAmtRaw) | |
572 | + | let pmtAmt = $t02299423039._1 | |
573 | + | let feeAmount = $t02299423039._2 | |
574 | + | let $t02304323504 = if ((txId == "")) | |
472 | 575 | then $Tuple2(amBalance, prBalance) | |
473 | 576 | else if ((pmtAssetId == amId)) | |
474 | 577 | then if ((pmtAmtRaw > amBalance)) | |
475 | 578 | then throw("invalid payment amount") | |
476 | 579 | else $Tuple2((amBalance - pmtAmtRaw), prBalance) | |
477 | 580 | else if ((pmtAssetId == prId)) | |
478 | 581 | then if ((pmtAmtRaw > prBalance)) | |
479 | 582 | then throw("invalid payment amount") | |
480 | 583 | else $Tuple2(amBalance, (prBalance - pmtAmtRaw)) | |
481 | 584 | else throw("wrong pmtAssetId") | |
482 | - | let amBalanceNow = $t02107621537._1 | |
483 | - | let prBalanceNow = $t02107621537._2 | |
484 | - | let $t02154121675 = if ((pmtAssetId == amId)) | |
485 | - | then $Tuple2(amBalanceNow, prBalanceNow) | |
486 | - | else $Tuple2(prBalanceNow, amBalanceNow) | |
487 | - | let amBalanceForCalc = $t02154121675._1 | |
488 | - | let prBalanceForCalc = $t02154121675._2 | |
489 | - | let xPrecision = 1 | |
490 | - | let result = { | |
491 | - | let @ = invoke(gwxContract, "calcPutXOnly", [toString(pmtAmt), toString(amBalanceForCalc), toString(prBalanceForCalc), "", A, Amult, toString(xPrecision), Dconv], nil) | |
492 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
493 | - | then @ | |
494 | - | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
495 | - | } | |
496 | - | let $t02214422240 = if ((pmtAssetId == amId)) | |
497 | - | then result | |
498 | - | else $Tuple2(result._2, result._1) | |
499 | - | let amAssetPart = $t02214422240._1 | |
500 | - | let prAssetPart = $t02214422240._2 | |
501 | - | let estPut = cp(userAddress, txId, AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), 0, true, true, false, pmtAmtRaw, pmtAssetId) | |
502 | - | let estimLP = estPut._2 | |
503 | - | let lpAssetId = estPut._7 | |
504 | - | let state = estPut._9 | |
505 | - | let amDiff = estPut._10 | |
506 | - | let prDiff = estPut._11 | |
507 | - | estPut | |
585 | + | let amBalanceOld = $t02304323504._1 | |
586 | + | let prBalanceOld = $t02304323504._2 | |
587 | + | let $t02351023674 = if ((pmtAssetId == amId)) | |
588 | + | then $Tuple2(pmtAmt, 0) | |
589 | + | else if ((pmtAssetId == prId)) | |
590 | + | then $Tuple2(0, pmtAmt) | |
591 | + | else throw("invalid payment") | |
592 | + | let amAmount = $t02351023674._1 | |
593 | + | let prAmount = $t02351023674._2 | |
594 | + | let amBalanceNew = (amBalanceOld + amAmount) | |
595 | + | let prBalanceNew = (prBalanceOld + prAmount) | |
596 | + | let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)]) | |
597 | + | let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)]) | |
598 | + | let checkD = if ((D1 > D0)) | |
599 | + | then true | |
600 | + | else throw() | |
601 | + | if ((checkD == checkD)) | |
602 | + | then { | |
603 | + | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
604 | + | let lpAmount = if ((lpAssetEmission > big0)) | |
605 | + | then fraction(lpAssetEmission, (D1 - D0), D0) | |
606 | + | else throw("initial deposit requires all coins") | |
607 | + | let curPrice = { | |
608 | + | let amBalanceX18 = t1(amBalance, amtDcm) | |
609 | + | let prBalanceX18 = t1(prBalance, priceDcm) | |
610 | + | f1(cpbi(prBalanceX18, amBalanceX18), scale8) | |
611 | + | } | |
612 | + | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId), dataPutActionInfo(amAmount, prAmount, toInt(lpAmount), curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
613 | + | let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld) | |
614 | + | let amountAssetPart = fraction(pmtAmt, scale8, (poolProportion + scale8)) | |
615 | + | let priceAssetPart = (pmtAmt - amountAssetPart) | |
616 | + | let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld)) | |
617 | + | let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth)) | |
618 | + | $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus) | |
619 | + | } | |
620 | + | else throw("Strict value is not equal to itself.") | |
508 | 621 | } | |
509 | 622 | ||
510 | 623 | ||
511 | 624 | func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = if ((size(payments) != 1)) | |
512 | 625 | then throw("1 pmnt expd") | |
513 | 626 | else { | |
514 | 627 | let poolConfig = gpc() | |
515 | 628 | let lpId = poolConfig[idxLPAsId] | |
516 | 629 | let amId = poolConfig[idxAmAsId] | |
517 | 630 | let prId = poolConfig[idxPrAsId] | |
518 | 631 | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
519 | 632 | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
520 | 633 | let poolStatus = poolConfig[idxPoolSt] | |
521 | 634 | let userAddress = if ((caller == this)) | |
522 | 635 | then originCaller | |
523 | 636 | else caller | |
524 | 637 | let pmt = value(payments[0]) | |
525 | 638 | let pmtAssetId = value(pmt.assetId) | |
526 | 639 | let pmtAmt = pmt.amount | |
527 | 640 | if ((1000000000 > pmtAmt)) | |
528 | 641 | then throw("Min pmt 10 LP") | |
529 | 642 | else { | |
530 | 643 | let txId58 = toBase58String(transactionId) | |
531 | 644 | if ((lpId != toBase58String(pmtAssetId))) | |
532 | 645 | then throw("Wrong LP") | |
533 | 646 | else { | |
534 | 647 | let amBalance = getAccBalance(amId) | |
535 | 648 | let prBalance = getAccBalance(prId) | |
536 | - | let $ | |
649 | + | let $t02606926177 = { | |
537 | 650 | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
538 | 651 | if ($isInstanceOf(@, "(Int, Int)")) | |
539 | 652 | then @ | |
540 | 653 | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
541 | 654 | } | |
542 | - | let totalGet = $ | |
543 | - | let feeAmount = $ | |
655 | + | let totalGet = $t02606926177._1 | |
656 | + | let feeAmount = $t02606926177._2 | |
544 | 657 | let totalAmount = if (if ((minOutAmount > 0)) | |
545 | 658 | then (minOutAmount > totalGet) | |
546 | 659 | else false) | |
547 | 660 | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
548 | 661 | else totalGet | |
549 | - | let $ | |
662 | + | let $t02636426451 = if ((outAssetId == amId)) | |
550 | 663 | then $Tuple2(totalAmount, 0) | |
551 | 664 | else $Tuple2(0, totalAmount) | |
552 | - | let outAm = $ | |
553 | - | let outPr = $ | |
665 | + | let outAm = $t02636426451._1 | |
666 | + | let outPr = $t02636426451._2 | |
554 | 667 | let curPrX18 = cpbi(t1(prBalance, prDecimals), t1(amBalance, amDecimals)) | |
555 | 668 | let curPr = f1(curPrX18, scale8) | |
556 | 669 | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
557 | 670 | then unit | |
558 | 671 | else fromBase58String(outAssetId) | |
559 | 672 | let sendFeeToMatcher = if ((feeAmount > 0)) | |
560 | 673 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
561 | 674 | else nil | |
562 | 675 | let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher) | |
563 | 676 | if ((state == state)) | |
564 | 677 | then { | |
565 | 678 | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
566 | 679 | if ((burn == burn)) | |
567 | 680 | then $Tuple2(state, totalAmount) | |
568 | 681 | else throw("Strict value is not equal to itself.") | |
569 | 682 | } | |
570 | 683 | else throw("Strict value is not equal to itself.") | |
571 | 684 | } | |
572 | 685 | } | |
573 | 686 | } | |
574 | - | ||
575 | - | ||
576 | - | func getD (xp) = { | |
577 | - | let n = big2 | |
578 | - | let xp0 = xp[0] | |
579 | - | let xp1 = xp[1] | |
580 | - | let aPrecision = parseBigIntValue(Amult) | |
581 | - | let a = (parseBigIntValue(A) * aPrecision) | |
582 | - | let s = (xp0 + xp1) | |
583 | - | if ((s == big0)) | |
584 | - | then big0 | |
585 | - | else { | |
586 | - | let ann = (a * n) | |
587 | - | func calc (acc,cur) = { | |
588 | - | let $t02513525155 = acc | |
589 | - | let d = $t02513525155._1 | |
590 | - | let found = $t02513525155._2 | |
591 | - | if ((found != unit)) | |
592 | - | then acc | |
593 | - | else { | |
594 | - | let dp = (((d * d) * d) / (((xp0 * xp1) * n) * n)) | |
595 | - | let dNext = (((((ann * s) / aPrecision) + (dp * n)) * d) / ((((ann - aPrecision) * d) / aPrecision) + ((n + big1) * dp))) | |
596 | - | let dDiff = absBigInt((dNext - value(d))) | |
597 | - | if ((big1 >= dDiff)) | |
598 | - | then $Tuple2(dNext, cur) | |
599 | - | else $Tuple2(dNext, unit) | |
600 | - | } | |
601 | - | } | |
602 | - | ||
603 | - | let arr = [0, 1, 2, 3, 4, 5, 6] | |
604 | - | let $t02557125617 = { | |
605 | - | let $l = arr | |
606 | - | let $s = size($l) | |
607 | - | let $acc0 = $Tuple2(s, unit) | |
608 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
609 | - | then $a | |
610 | - | else calc($a, $l[$i]) | |
611 | - | ||
612 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
613 | - | then $a | |
614 | - | else throw("List size exceeds 7") | |
615 | - | ||
616 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7) | |
617 | - | } | |
618 | - | let d = $t02557125617._1 | |
619 | - | let found = $t02557125617._2 | |
620 | - | if ((found != unit)) | |
621 | - | then d | |
622 | - | else throw(("D calculation error, D = " + toString(d))) | |
623 | - | } | |
624 | - | } | |
625 | - | ||
626 | - | ||
627 | - | func getYD (xp,i,D) = { | |
628 | - | let n = big2 | |
629 | - | let x = xp[if ((i == 0)) | |
630 | - | then 1 | |
631 | - | else 0] | |
632 | - | let aPrecision = parseBigIntValue(Amult) | |
633 | - | let a = (parseBigIntValue(A) * aPrecision) | |
634 | - | let s = x | |
635 | - | let ann = (a * n) | |
636 | - | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
637 | - | let b = ((s + ((D * aPrecision) / ann)) - D) | |
638 | - | func calc (acc,cur) = { | |
639 | - | let $t02611726137 = acc | |
640 | - | let y = $t02611726137._1 | |
641 | - | let found = $t02611726137._2 | |
642 | - | if ((found != unit)) | |
643 | - | then acc | |
644 | - | else { | |
645 | - | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
646 | - | let yDiff = absBigInt((yNext - value(y))) | |
647 | - | if ((big1 >= yDiff)) | |
648 | - | then $Tuple2(yNext, cur) | |
649 | - | else $Tuple2(yNext, unit) | |
650 | - | } | |
651 | - | } | |
652 | - | ||
653 | - | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
654 | - | let $t02644426491 = { | |
655 | - | let $l = arr | |
656 | - | let $s = size($l) | |
657 | - | let $acc0 = $Tuple2(D, unit) | |
658 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
659 | - | then $a | |
660 | - | else calc($a, $l[$i]) | |
661 | - | ||
662 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
663 | - | then $a | |
664 | - | else throw("List size exceeds 15") | |
665 | - | ||
666 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
667 | - | } | |
668 | - | let y = $t02644426491._1 | |
669 | - | let found = $t02644426491._2 | |
670 | - | if ((found != unit)) | |
671 | - | then y | |
672 | - | else throw(("Y calculation error, Y = " + toString(y))) | |
673 | - | } | |
674 | 687 | ||
675 | 688 | ||
676 | 689 | func m () = match getString(mpk()) { | |
677 | 690 | case s: String => | |
678 | 691 | fromBase58String(s) | |
679 | 692 | case _: Unit => | |
680 | 693 | unit | |
681 | 694 | case _ => | |
682 | 695 | throw("Match error") | |
683 | 696 | } | |
684 | 697 | ||
685 | 698 | ||
686 | 699 | func pm () = match getString(pmpk()) { | |
687 | 700 | case s: String => | |
688 | 701 | fromBase58String(s) | |
689 | 702 | case _: Unit => | |
690 | 703 | unit | |
691 | 704 | case _ => | |
692 | 705 | throw("Match error") | |
693 | 706 | } | |
694 | 707 | ||
695 | 708 | ||
696 | 709 | let pd = throw("Permission denied") | |
697 | 710 | ||
698 | 711 | func mm (i) = match m() { | |
699 | 712 | case pk: ByteVector => | |
700 | 713 | if ((i.callerPublicKey == pk)) | |
701 | 714 | then true | |
702 | 715 | else pd | |
703 | 716 | case _: Unit => | |
704 | 717 | if ((i.caller == this)) | |
705 | 718 | then true | |
706 | 719 | else pd | |
707 | 720 | case _ => | |
708 | 721 | throw("Match error") | |
709 | 722 | } | |
710 | 723 | ||
711 | 724 | ||
712 | 725 | @Callable(i) | |
713 | 726 | func constructor (fc) = { | |
714 | 727 | let c = mm(i) | |
715 | 728 | if ((c == c)) | |
716 | 729 | then [StringEntry(fc(), fc)] | |
717 | 730 | else throw("Strict value is not equal to itself.") | |
718 | 731 | } | |
719 | 732 | ||
720 | 733 | ||
721 | 734 | ||
722 | 735 | @Callable(i) | |
723 | 736 | func setManager (pendingManagerPublicKey) = { | |
724 | 737 | let c = mm(i) | |
725 | 738 | if ((c == c)) | |
726 | 739 | then { | |
727 | 740 | let cm = fromBase58String(pendingManagerPublicKey) | |
728 | 741 | if ((cm == cm)) | |
729 | 742 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
730 | 743 | else throw("Strict value is not equal to itself.") | |
731 | 744 | } | |
732 | 745 | else throw("Strict value is not equal to itself.") | |
733 | 746 | } | |
734 | 747 | ||
735 | 748 | ||
736 | 749 | ||
737 | 750 | @Callable(i) | |
738 | 751 | func confirmManager () = { | |
739 | 752 | let p = pm() | |
740 | 753 | let hpm = if (isDefined(p)) | |
741 | 754 | then true | |
742 | 755 | else throw("No pending manager") | |
743 | 756 | if ((hpm == hpm)) | |
744 | 757 | then { | |
745 | 758 | let cpm = if ((i.callerPublicKey == value(p))) | |
746 | 759 | then true | |
747 | 760 | else throw("You are not pending manager") | |
748 | 761 | if ((cpm == cpm)) | |
749 | 762 | then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())] | |
750 | 763 | else throw("Strict value is not equal to itself.") | |
751 | 764 | } | |
752 | 765 | else throw("Strict value is not equal to itself.") | |
753 | 766 | } | |
754 | 767 | ||
755 | 768 | ||
756 | 769 | ||
757 | 770 | @Callable(i) | |
758 | 771 | func put (slip,autoStake) = { | |
759 | 772 | let factCfg = gfc() | |
760 | 773 | let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr") | |
761 | 774 | let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr") | |
762 | 775 | if ((0 > slip)) | |
763 | 776 | then throw("Wrong slippage") | |
764 | 777 | else if ((size(i.payments) != 2)) | |
765 | 778 | then throw("2 pmnts expd") | |
766 | 779 | else { | |
767 | 780 | let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "") | |
768 | 781 | let emitLpAmt = e._2 | |
769 | 782 | let lpAssetId = e._7 | |
770 | 783 | let state = e._9 | |
771 | 784 | let amDiff = e._10 | |
772 | 785 | let prDiff = e._11 | |
773 | 786 | let amId = e._12 | |
774 | 787 | let prId = e._13 | |
775 | 788 | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
776 | 789 | if ((r == r)) | |
777 | 790 | then { | |
778 | 791 | let el = match r { | |
779 | 792 | case legacy: Address => | |
780 | 793 | invoke(legacy, "emit", [emitLpAmt], nil) | |
781 | 794 | case _ => | |
782 | 795 | unit | |
783 | 796 | } | |
784 | 797 | if ((el == el)) | |
785 | 798 | then { | |
786 | 799 | let sa = if ((amDiff > 0)) | |
787 | 800 | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
788 | 801 | else nil | |
789 | 802 | if ((sa == sa)) | |
790 | 803 | then { | |
791 | 804 | let sp = if ((prDiff > 0)) | |
792 | 805 | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
793 | 806 | else nil | |
794 | 807 | if ((sp == sp)) | |
795 | 808 | then { | |
796 | 809 | let lpTrnsfr = if (autoStake) | |
797 | 810 | then { | |
798 | 811 | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
799 | 812 | if ((ss == ss)) | |
800 | 813 | then nil | |
801 | 814 | else throw("Strict value is not equal to itself.") | |
802 | 815 | } | |
803 | 816 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
804 | 817 | (state ++ lpTrnsfr) | |
805 | 818 | } | |
806 | 819 | else throw("Strict value is not equal to itself.") | |
807 | 820 | } | |
808 | 821 | else throw("Strict value is not equal to itself.") | |
809 | 822 | } | |
810 | 823 | else throw("Strict value is not equal to itself.") | |
811 | 824 | } | |
812 | 825 | else throw("Strict value is not equal to itself.") | |
813 | 826 | } | |
814 | 827 | } | |
815 | 828 | ||
816 | 829 | ||
817 | 830 | ||
818 | 831 | @Callable(i) | |
819 | 832 | func putOneTkn (amAssetPart,prAssetPart,outLp,slippage,autoStake) = { | |
820 | 833 | let cfg = gfc() | |
821 | 834 | let stakingCntr = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wr st addr") | |
822 | 835 | let slipCntr = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wr sl addr") | |
823 | 836 | let gwxCntr = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wr gwx addr") | |
824 | 837 | let poolCfg = gpc() | |
825 | 838 | let amId = poolCfg[idxAmAsId] | |
826 | 839 | let prId = poolCfg[idxPrAsId] | |
827 | 840 | let amDcm = parseIntValue(poolCfg[idxAmtAsDcm]) | |
828 | 841 | let prDcm = parseIntValue(poolCfg[idxPriceAsDcm]) | |
829 | 842 | let addon = valueOrElse(getString(this, ada()), "") | |
830 | 843 | let userAddress = if ((addon == toString(i.caller))) | |
831 | 844 | then i.originCaller | |
832 | 845 | else i.caller | |
833 | 846 | if (if (if (if ((0 >= slippage)) | |
834 | 847 | then true | |
835 | 848 | else (0 >= amAssetPart)) | |
836 | 849 | then true | |
837 | 850 | else (0 >= prAssetPart)) | |
838 | 851 | then true | |
839 | 852 | else (0 >= outLp)) | |
840 | 853 | then throw("Wrong params") | |
841 | 854 | else if ((size(i.payments) != 1)) | |
842 | 855 | then throw("1 pmnt expd") | |
843 | 856 | else { | |
844 | 857 | let pmt = value(i.payments[0]) | |
845 | 858 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
846 | 859 | let paymentAmountRaw = pmt.amount | |
847 | - | let $ | |
848 | - | let pmtAmt = $ | |
849 | - | let feeAmount = $ | |
860 | + | let $t03183731889 = takeFee(paymentAmountRaw) | |
861 | + | let pmtAmt = $t03183731889._1 | |
862 | + | let feeAmount = $t03183731889._2 | |
850 | 863 | if ((10000000 > paymentAmountRaw)) | |
851 | 864 | then throw("Wrong pmt amt") | |
852 | 865 | else { | |
853 | 866 | let amBalance = getAccBalance(amId) | |
854 | 867 | let prBalance = getAccBalance(prId) | |
855 | - | let $ | |
868 | + | let $t03204932665 = if ((pmtAssetId == amId)) | |
856 | 869 | then if (if ((paymentAmountRaw > amBalance)) | |
857 | 870 | then true | |
858 | 871 | else (amAssetPart > pmtAmt)) | |
859 | 872 | then throw("invalid payment amount") | |
860 | 873 | else $Tuple6((amBalance - paymentAmountRaw), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
861 | 874 | else if ((pmtAssetId == prId)) | |
862 | 875 | then if (if ((paymentAmountRaw > prBalance)) | |
863 | 876 | then true | |
864 | 877 | else (prAssetPart > pmtAmt)) | |
865 | 878 | then throw("invalid payment amount") | |
866 | 879 | else $Tuple6(amBalance, (prBalance - paymentAmountRaw), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
867 | 880 | else throw("wrong pmtAssetId") | |
868 | - | let amBalanceNow = $ | |
869 | - | let prBalanceNow = $ | |
870 | - | let virtSwapInAm = $ | |
871 | - | let virtSwapOutPr = $ | |
872 | - | let virtSwapInPr = $ | |
873 | - | let virtSwapOutAm = $ | |
881 | + | let amBalanceNow = $t03204932665._1 | |
882 | + | let prBalanceNow = $t03204932665._2 | |
883 | + | let virtSwapInAm = $t03204932665._3 | |
884 | + | let virtSwapOutPr = $t03204932665._4 | |
885 | + | let virtSwapInPr = $t03204932665._5 | |
886 | + | let virtSwapOutAm = $t03204932665._6 | |
874 | 887 | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
875 | 888 | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
876 | 889 | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
877 | 890 | if ((D0vsD1 == D0vsD1)) | |
878 | 891 | then { | |
879 | 892 | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, true, pmtAmt, pmtAssetId) | |
880 | 893 | let estimLP = estPut._2 | |
881 | 894 | let lpAssetId = estPut._7 | |
882 | 895 | let state = estPut._9 | |
883 | 896 | let amDiff = estPut._10 | |
884 | 897 | let prDiff = estPut._11 | |
885 | 898 | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
886 | 899 | let emitLpAmt = toInt(lpCalcRes._2) | |
887 | 900 | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
888 | 901 | if ((e == e)) | |
889 | 902 | then { | |
890 | 903 | let el = match e { | |
891 | 904 | case legacy: Address => | |
892 | 905 | invoke(legacy, "emit", [emitLpAmt], nil) | |
893 | 906 | case _ => | |
894 | 907 | unit | |
895 | 908 | } | |
896 | 909 | if ((el == el)) | |
897 | 910 | then { | |
898 | 911 | let sa = if ((amDiff > 0)) | |
899 | 912 | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
900 | 913 | else nil | |
901 | 914 | if ((sa == sa)) | |
902 | 915 | then { | |
903 | 916 | let sp = if ((prDiff > 0)) | |
904 | 917 | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
905 | 918 | else nil | |
906 | 919 | if ((sp == sp)) | |
907 | 920 | then { | |
908 | 921 | let lpTrnsfr = if (autoStake) | |
909 | 922 | then { | |
910 | 923 | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
911 | 924 | if ((ss == ss)) | |
912 | 925 | then nil | |
913 | 926 | else throw("Strict value is not equal to itself.") | |
914 | 927 | } | |
915 | 928 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
916 | 929 | let sendFeeToMatcher = if ((feeAmount > 0)) | |
917 | 930 | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
918 | 931 | else nil | |
919 | 932 | ((state ++ lpTrnsfr) ++ sendFeeToMatcher) | |
920 | 933 | } | |
921 | 934 | else throw("Strict value is not equal to itself.") | |
922 | 935 | } | |
923 | 936 | else throw("Strict value is not equal to itself.") | |
924 | 937 | } | |
925 | 938 | else throw("Strict value is not equal to itself.") | |
926 | 939 | } | |
927 | 940 | else throw("Strict value is not equal to itself.") | |
928 | 941 | } | |
929 | 942 | else throw("Strict value is not equal to itself.") | |
930 | 943 | } | |
931 | 944 | } | |
932 | 945 | } | |
933 | 946 | ||
934 | 947 | ||
935 | 948 | ||
936 | 949 | @Callable(i) | |
937 | 950 | func putOneTknV2 (minOutAmount,autoStake) = if ((size(i.payments) != 1)) | |
938 | 951 | then throw("1 pmnt expd") | |
939 | 952 | else { | |
940 | 953 | let poolConfig = gpc() | |
941 | 954 | let amId = poolConfig[idxAmAsId] | |
942 | 955 | let prId = poolConfig[idxPrAsId] | |
956 | + | let lpId = fromBase58String(poolConfig[idxLPAsId]) | |
943 | 957 | let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm]) | |
944 | 958 | let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm]) | |
945 | 959 | let userAddress = if ((i.caller == this)) | |
946 | 960 | then i.originCaller | |
947 | 961 | else i.caller | |
948 | 962 | let pmt = value(i.payments[0]) | |
949 | 963 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
950 | 964 | let pmtAmt = pmt.amount | |
951 | 965 | if ((10000000 > pmtAmt)) | |
952 | 966 | then throw("Wrong pmt amt") | |
953 | 967 | else { | |
954 | - | let r = estimatePutOneTknV2(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId)) | |
955 | - | let estimLP = r._2 | |
956 | - | let lpAssetId = r._7 | |
957 | - | let state = r._9 | |
958 | - | let amDiff = r._10 | |
959 | - | let prDiff = r._11 | |
968 | + | let $t03557135696 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId)) | |
969 | + | let estimLP = $t03557135696._1 | |
970 | + | let state = $t03557135696._2 | |
971 | + | let feeAmount = $t03557135696._3 | |
960 | 972 | let emitLpAmt = if (if ((minOutAmount > 0)) | |
961 | 973 | then (minOutAmount > estimLP) | |
962 | 974 | else false) | |
963 | 975 | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
964 | 976 | else estimLP | |
965 | 977 | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
966 | 978 | if ((e == e)) | |
967 | 979 | then { | |
968 | 980 | let el = match e { | |
969 | 981 | case legacy: Address => | |
970 | 982 | invoke(legacy, "emit", [emitLpAmt], nil) | |
971 | 983 | case _ => | |
972 | 984 | unit | |
973 | 985 | } | |
974 | 986 | if ((el == el)) | |
975 | 987 | then { | |
976 | - | let sa = if ((amDiff > 0)) | |
977 | - | then invoke(slipageContract, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
978 | - | else nil | |
979 | - | if ((sa == sa)) | |
988 | + | let lpTrnsfr = if (autoStake) | |
980 | 989 | then { | |
981 | - | let sp = if ((prDiff > 0)) | |
982 | - | then invoke(slipageContract, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
983 | - | else nil | |
984 | - | if ((sp == sp)) | |
985 | - | then { | |
986 | - | let lpTrnsfr = if (autoStake) | |
987 | - | then { | |
988 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
989 | - | if ((ss == ss)) | |
990 | - | then nil | |
991 | - | else throw("Strict value is not equal to itself.") | |
992 | - | } | |
993 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
994 | - | let feeAmount = takeFee(pmtAmt)._2 | |
995 | - | let sendFeeToMatcher = if ((feeAmount > 0)) | |
996 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
997 | - | else nil | |
998 | - | $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt) | |
999 | - | } | |
990 | + | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
991 | + | if ((ss == ss)) | |
992 | + | then nil | |
1000 | 993 | else throw("Strict value is not equal to itself.") | |
1001 | 994 | } | |
1002 | - | else throw("Strict value is not equal to itself.") | |
995 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpId)] | |
996 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
997 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
998 | + | else nil | |
999 | + | $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt) | |
1003 | 1000 | } | |
1004 | 1001 | else throw("Strict value is not equal to itself.") | |
1005 | 1002 | } | |
1006 | 1003 | else throw("Strict value is not equal to itself.") | |
1007 | 1004 | } | |
1008 | 1005 | } | |
1009 | - | ||
1010 | - | ||
1011 | - | ||
1012 | - | @Callable(i) | |
1013 | - | func putOneTknV2WithBonusOldREADONLY (paymentAmount,paymentAssetId) = { | |
1014 | - | let poolConfig = gpc() | |
1015 | - | let amId = poolConfig[idxAmAsId] | |
1016 | - | let prId = poolConfig[idxPrAsId] | |
1017 | - | let r = estimatePutOneTknV2(paymentAmount, paymentAssetId, "", "") | |
1018 | - | let estimLP = r._2 | |
1019 | - | let curPrice = r._3 | |
1020 | - | let lpAssetEmission = r._6 | |
1021 | - | let lpAssetId = r._7 | |
1022 | - | let amBalance = getAccBalance(amId) | |
1023 | - | let prBalance = getAccBalance(prId) | |
1024 | - | let poolProportion = fraction(prBalance, scale8, amBalance) | |
1025 | - | let amountAssetPart = fraction(paymentAmount, scale8, (poolProportion + scale8)) | |
1026 | - | let priceAssetPart = (paymentAmount - amountAssetPart) | |
1027 | - | let lpAmtBoth = fraction(lpAssetEmission, priceAssetPart, prBalance) | |
1028 | - | let bonus = fraction((estimLP - lpAmtBoth), scale8, lpAmtBoth) | |
1029 | - | let feeAmount = takeFee(paymentAmount)._2 | |
1030 | - | $Tuple2(nil, $Tuple3(estimLP, feeAmount, bonus)) | |
1031 | - | } | |
1032 | 1006 | ||
1033 | 1007 | ||
1034 | 1008 | ||
1035 | 1009 | @Callable(i) | |
1036 | 1010 | func putForFree (maxSlpg) = if ((0 > maxSlpg)) | |
1037 | 1011 | then throw("Wrong slpg") | |
1038 | 1012 | else if ((size(i.payments) != 2)) | |
1039 | 1013 | then throw("2 pmnts expd") | |
1040 | 1014 | else { | |
1041 | 1015 | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, true, 0, "") | |
1042 | 1016 | estPut._9 | |
1043 | 1017 | } | |
1044 | 1018 | ||
1045 | 1019 | ||
1046 | 1020 | ||
1047 | 1021 | @Callable(i) | |
1048 | 1022 | func get () = { | |
1049 | 1023 | let r = cg(i) | |
1050 | 1024 | let outAmtAmt = r._1 | |
1051 | 1025 | let outPrAmt = r._2 | |
1052 | 1026 | let pmtAmt = r._3 | |
1053 | 1027 | let pmtAssetId = r._4 | |
1054 | 1028 | let state = r._5 | |
1055 | 1029 | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1056 | 1030 | if ((b == b)) | |
1057 | 1031 | then state | |
1058 | 1032 | else throw("Strict value is not equal to itself.") | |
1059 | 1033 | } | |
1060 | 1034 | ||
1061 | 1035 | ||
1062 | 1036 | ||
1063 | 1037 | @Callable(i) | |
1064 | 1038 | func getOneTkn (exchResult,notUsed,outAmount,outAssetId,slippage) = if ((size(i.payments) != 1)) | |
1065 | 1039 | then throw("1 pmnt expd") | |
1066 | 1040 | else { | |
1067 | 1041 | let cfg = gpc() | |
1068 | 1042 | let lpId = cfg[idxLPAsId] | |
1069 | 1043 | let amId = cfg[idxAmAsId] | |
1070 | 1044 | let prId = cfg[idxPrAsId] | |
1071 | 1045 | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
1072 | 1046 | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
1073 | 1047 | let sts = cfg[idxPoolSt] | |
1074 | 1048 | let factCfg = gfc() | |
1075 | 1049 | let gwxCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactGwxRewCntr]), "Wr sl addr") | |
1076 | 1050 | let pmt = value(i.payments[0]) | |
1077 | 1051 | let addon = valueOrElse(getString(this, ada()), "") | |
1078 | 1052 | let userAddress = if ((addon == toString(i.caller))) | |
1079 | 1053 | then i.originCaller | |
1080 | 1054 | else i.caller | |
1081 | 1055 | let txId58 = toBase58String(i.transactionId) | |
1082 | 1056 | let pmtAssetId = value(pmt.assetId) | |
1083 | 1057 | let pmtAmt = pmt.amount | |
1084 | 1058 | if ((1000000000 > pmtAmt)) | |
1085 | 1059 | then throw("Min pmt 10 LP") | |
1086 | 1060 | else if (if (if ((0 > slippage)) | |
1087 | 1061 | then true | |
1088 | 1062 | else (0 > exchResult)) | |
1089 | 1063 | then true | |
1090 | 1064 | else (0 > outAmount)) | |
1091 | 1065 | then throw("Wrong params") | |
1092 | 1066 | else if ((lpId != toBase58String(pmtAssetId))) | |
1093 | 1067 | then throw("Wrong LP") | |
1094 | 1068 | else { | |
1095 | 1069 | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
1096 | 1070 | let estimAmAmt = r._1 | |
1097 | 1071 | let estimPrAmt = r._2 | |
1098 | 1072 | let amBalance = getAccBalance(amId) | |
1099 | 1073 | let prBalance = getAccBalance(prId) | |
1100 | - | let $ | |
1074 | + | let $t03932739787 = if ((outAssetId == amId)) | |
1101 | 1075 | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
1102 | 1076 | else if ((outAssetId == prId)) | |
1103 | 1077 | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
1104 | 1078 | else throw("wrong outAssetId") | |
1105 | - | let amBalanceNow = $ | |
1106 | - | let prBalanceNow = $ | |
1107 | - | let virtSwapInAm = $ | |
1108 | - | let virtSwapOutPr = $ | |
1109 | - | let virtSwapInPr = $ | |
1110 | - | let virtSwapOutAm = $ | |
1111 | - | let totalGetRaw = $ | |
1079 | + | let amBalanceNow = $t03932739787._1 | |
1080 | + | let prBalanceNow = $t03932739787._2 | |
1081 | + | let virtSwapInAm = $t03932739787._3 | |
1082 | + | let virtSwapOutPr = $t03932739787._4 | |
1083 | + | let virtSwapInPr = $t03932739787._5 | |
1084 | + | let virtSwapOutAm = $t03932739787._6 | |
1085 | + | let totalGetRaw = $t03932739787._7 | |
1112 | 1086 | if (if ((0 > virtSwapInAm)) | |
1113 | 1087 | then true | |
1114 | 1088 | else (0 > virtSwapInPr)) | |
1115 | 1089 | then throw("Wrong calc") | |
1116 | 1090 | else { | |
1117 | 1091 | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
1118 | 1092 | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
1119 | 1093 | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
1120 | 1094 | if ((D0vsD1 == D0vsD1)) | |
1121 | 1095 | then { | |
1122 | 1096 | let totalGet = takeFee(totalGetRaw)._1 | |
1123 | 1097 | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
1124 | 1098 | if ((finalRes == finalRes)) | |
1125 | 1099 | then { | |
1126 | - | let $ | |
1100 | + | let $t04053440638 = if ((outAssetId == amId)) | |
1127 | 1101 | then $Tuple2(toInt(finalRes._2), 0) | |
1128 | 1102 | else $Tuple2(0, toInt(finalRes._2)) | |
1129 | - | let outAm = $ | |
1130 | - | let outPr = $ | |
1103 | + | let outAm = $t04053440638._1 | |
1104 | + | let outPr = $t04053440638._2 | |
1131 | 1105 | let totalAmount = (outAm + outPr) | |
1132 | 1106 | let feeAmount = (totalGetRaw - totalGet) | |
1133 | 1107 | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
1134 | 1108 | then unit | |
1135 | 1109 | else fromBase58String(outAssetId) | |
1136 | 1110 | let sendFeeToMatcher = if ((feeAmount > 0)) | |
1137 | 1111 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
1138 | 1112 | else nil | |
1139 | 1113 | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
1140 | 1114 | let curPr = f1(curPrX18, scale8) | |
1141 | 1115 | let state = [ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] | |
1142 | 1116 | if ((state == state)) | |
1143 | 1117 | then { | |
1144 | 1118 | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1145 | 1119 | if ((burn == burn)) | |
1146 | 1120 | then (state ++ sendFeeToMatcher) | |
1147 | 1121 | else throw("Strict value is not equal to itself.") | |
1148 | 1122 | } | |
1149 | 1123 | else throw("Strict value is not equal to itself.") | |
1150 | 1124 | } | |
1151 | 1125 | else throw("Strict value is not equal to itself.") | |
1152 | 1126 | } | |
1153 | 1127 | else throw("Strict value is not equal to itself.") | |
1154 | 1128 | } | |
1155 | 1129 | } | |
1156 | 1130 | } | |
1157 | 1131 | ||
1158 | 1132 | ||
1159 | 1133 | ||
1160 | 1134 | @Callable(i) | |
1161 | 1135 | func getOneTknV2 (outAssetId,minOutAmount) = { | |
1162 | - | let $ | |
1163 | - | let state = $ | |
1164 | - | let totalAmount = $ | |
1136 | + | let $t04166341818 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId) | |
1137 | + | let state = $t04166341818._1 | |
1138 | + | let totalAmount = $t04166341818._2 | |
1165 | 1139 | $Tuple2(state, totalAmount) | |
1166 | 1140 | } | |
1167 | 1141 | ||
1168 | 1142 | ||
1169 | 1143 | ||
1170 | 1144 | @Callable(i) | |
1171 | 1145 | func getOneTknV2OldREADONLY (outAssetId,lpAssetAmount) = { | |
1172 | 1146 | let poolConfig = gpc() | |
1173 | 1147 | let lpId = poolConfig[idxLPAsId] | |
1174 | 1148 | let amId = poolConfig[idxAmAsId] | |
1175 | 1149 | let prId = poolConfig[idxPrAsId] | |
1176 | 1150 | let r = ego("", lpId, lpAssetAmount, this) | |
1177 | 1151 | let estimAmAmt = r._1 | |
1178 | 1152 | let estimPrAmt = r._2 | |
1179 | 1153 | let amBalance = getAccBalance(amId) | |
1180 | 1154 | let prBalance = getAccBalance(prId) | |
1181 | 1155 | let amBalanceNow = (amBalance - estimAmAmt) | |
1182 | 1156 | let prBalanceNow = (prBalance - estimPrAmt) | |
1183 | - | let $ | |
1157 | + | let $t04233142639 = if ((outAssetId == amId)) | |
1184 | 1158 | then $Tuple4(prBalanceNow, amBalanceNow, estimPrAmt, estimAmAmt) | |
1185 | 1159 | else if ((outAssetId == prId)) | |
1186 | 1160 | then $Tuple4(amBalanceNow, prBalanceNow, estimAmAmt, estimPrAmt) | |
1187 | 1161 | else throw("wrong outAssetId") | |
1188 | - | let amountBalanceForSwap = $ | |
1189 | - | let priceBalanceForSwap = $ | |
1190 | - | let amountToSwap = $ | |
1191 | - | let amountToAdd = $ | |
1162 | + | let amountBalanceForSwap = $t04233142639._1 | |
1163 | + | let priceBalanceForSwap = $t04233142639._2 | |
1164 | + | let amountToSwap = $t04233142639._3 | |
1165 | + | let amountToAdd = $t04233142639._4 | |
1192 | 1166 | let yPrecision = 1 | |
1193 | 1167 | let exchResult = { | |
1194 | 1168 | let @ = invoke(gwxContract, "calcSwapXToY", [toString(amountToSwap), toString(amountBalanceForSwap), toString(priceBalanceForSwap), "", A, Amult, toString(yPrecision), Dconv], nil) | |
1195 | 1169 | if ($isInstanceOf(@, "Int")) | |
1196 | 1170 | then @ | |
1197 | 1171 | else throw(($getType(@) + " couldn't be cast to Int")) | |
1198 | 1172 | } | |
1199 | 1173 | let totalGetRaw = (exchResult + amountToAdd) | |
1200 | - | let $ | |
1201 | - | let totalGet = $ | |
1202 | - | let feeAmount = $ | |
1174 | + | let $t04316743216 = takeFee(totalGetRaw) | |
1175 | + | let totalGet = $t04316743216._1 | |
1176 | + | let feeAmount = $t04316743216._2 | |
1203 | 1177 | $Tuple2(nil, $Tuple2(totalGet, feeAmount)) | |
1204 | 1178 | } | |
1205 | 1179 | ||
1206 | 1180 | ||
1207 | 1181 | ||
1208 | 1182 | @Callable(i) | |
1209 | 1183 | func getOneTknV2READONLY (outAssetId,lpAssetAmount) = { | |
1210 | 1184 | let poolConfig = gpc() | |
1211 | 1185 | let amId = poolConfig[idxAmAsId] | |
1212 | 1186 | let prId = poolConfig[idxPrAsId] | |
1213 | 1187 | let lpId = poolConfig[idxLPAsId] | |
1214 | 1188 | let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))] | |
1215 | 1189 | let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
1216 | 1190 | let D0 = getD(xp) | |
1217 | 1191 | let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission)) | |
1218 | 1192 | let index = if ((outAssetId == amId)) | |
1219 | 1193 | then 0 | |
1220 | 1194 | else 1 | |
1221 | 1195 | let newY = getYD(xp, index, D1) | |
1222 | 1196 | let dy = (xp[index] - newY) | |
1223 | 1197 | let totalGetRaw = toInt((dy - big1)) | |
1224 | - | let $ | |
1225 | - | let totalGet = $ | |
1226 | - | let feeAmount = $ | |
1198 | + | let $t04390743956 = takeFee(totalGetRaw) | |
1199 | + | let totalGet = $t04390743956._1 | |
1200 | + | let feeAmount = $t04390743956._2 | |
1227 | 1201 | $Tuple2(nil, $Tuple2(totalGet, feeAmount)) | |
1228 | 1202 | } | |
1229 | 1203 | ||
1230 | 1204 | ||
1231 | 1205 | ||
1232 | 1206 | @Callable(i) | |
1233 | 1207 | func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = { | |
1234 | 1208 | let poolConfig = gpc() | |
1235 | 1209 | let amId = poolConfig[idxAmAsId] | |
1236 | 1210 | let prId = poolConfig[idxPrAsId] | |
1237 | 1211 | let lpId = poolConfig[idxLPAsId] | |
1238 | 1212 | let amBalance = getAccBalance(amId) | |
1239 | 1213 | let prBalance = getAccBalance(prId) | |
1240 | - | let $ | |
1214 | + | let $t04430144416 = { | |
1241 | 1215 | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil) | |
1242 | 1216 | if ($isInstanceOf(@, "(Int, Int)")) | |
1243 | 1217 | then @ | |
1244 | 1218 | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
1245 | 1219 | } | |
1246 | - | let totalGet = $ | |
1247 | - | let feeAmount = $ | |
1220 | + | let totalGet = $t04430144416._1 | |
1221 | + | let feeAmount = $t04430144416._2 | |
1248 | 1222 | let r = ego("", lpId, lpAssetAmount, this) | |
1249 | 1223 | let outAmAmt = r._1 | |
1250 | 1224 | let outPrAmt = r._2 | |
1251 | 1225 | let sumOfGetAssets = (outAmAmt + outPrAmt) | |
1252 | 1226 | let bonus = fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets) | |
1253 | 1227 | $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus)) | |
1254 | 1228 | } | |
1255 | 1229 | ||
1256 | 1230 | ||
1257 | 1231 | ||
1258 | 1232 | @Callable(i) | |
1259 | 1233 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1260 | 1234 | let r = cg(i) | |
1261 | 1235 | let outAmAmt = r._1 | |
1262 | 1236 | let outPrAmt = r._2 | |
1263 | 1237 | let pmtAmt = r._3 | |
1264 | 1238 | let pmtAssetId = r._4 | |
1265 | 1239 | let state = r._5 | |
1266 | 1240 | if ((noLessThenAmtAsset > outAmAmt)) | |
1267 | 1241 | then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1268 | 1242 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1269 | 1243 | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1270 | 1244 | else { | |
1271 | 1245 | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1272 | 1246 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1273 | 1247 | then state | |
1274 | 1248 | else throw("Strict value is not equal to itself.") | |
1275 | 1249 | } | |
1276 | 1250 | } | |
1277 | 1251 | ||
1278 | 1252 | ||
1279 | 1253 | ||
1280 | 1254 | @Callable(i) | |
1281 | 1255 | func unstakeAndGet (amount) = { | |
1282 | 1256 | let checkPayments = if ((size(i.payments) != 0)) | |
1283 | 1257 | then throw("No pmnts expd") | |
1284 | 1258 | else true | |
1285 | 1259 | if ((checkPayments == checkPayments)) | |
1286 | 1260 | then { | |
1287 | 1261 | let cfg = gpc() | |
1288 | 1262 | let factoryCfg = gfc() | |
1289 | 1263 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1290 | 1264 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1291 | 1265 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1292 | 1266 | if ((unstakeInv == unstakeInv)) | |
1293 | 1267 | then { | |
1294 | 1268 | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1295 | 1269 | let sts = parseIntValue(r._9) | |
1296 | 1270 | let state = r._10 | |
1297 | 1271 | let v = if (if (igs()) | |
1298 | 1272 | then true | |
1299 | 1273 | else (sts == PoolShutdown)) | |
1300 | 1274 | then throw(("Blocked: " + toString(sts))) | |
1301 | 1275 | else true | |
1302 | 1276 | if ((v == v)) | |
1303 | 1277 | then { | |
1304 | 1278 | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1305 | 1279 | if ((burnA == burnA)) | |
1306 | 1280 | then state | |
1307 | 1281 | else throw("Strict value is not equal to itself.") | |
1308 | 1282 | } | |
1309 | 1283 | else throw("Strict value is not equal to itself.") | |
1310 | 1284 | } | |
1311 | 1285 | else throw("Strict value is not equal to itself.") | |
1312 | 1286 | } | |
1313 | 1287 | else throw("Strict value is not equal to itself.") | |
1314 | 1288 | } | |
1315 | 1289 | ||
1316 | 1290 | ||
1317 | 1291 | ||
1318 | 1292 | @Callable(i) | |
1319 | 1293 | func unstakeAndGetOneTkn (unstakeAmount,outAssetId,minOutAmount) = { | |
1320 | 1294 | let checkPayments = if ((size(i.payments) != 0)) | |
1321 | 1295 | then throw("No pmnts expd") | |
1322 | 1296 | else true | |
1323 | 1297 | if ((checkPayments == checkPayments)) | |
1324 | 1298 | then { | |
1325 | 1299 | let cfg = gpc() | |
1326 | 1300 | let factoryCfg = gfc() | |
1327 | 1301 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
1328 | 1302 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1329 | 1303 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil) | |
1330 | 1304 | if ((unstakeInv == unstakeInv)) | |
1331 | 1305 | then { | |
1332 | - | let $ | |
1333 | - | let state = $ | |
1334 | - | let totalAmount = $ | |
1306 | + | let $t04672146909 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId) | |
1307 | + | let state = $t04672146909._1 | |
1308 | + | let totalAmount = $t04672146909._2 | |
1335 | 1309 | $Tuple2(state, totalAmount) | |
1336 | 1310 | } | |
1337 | 1311 | else throw("Strict value is not equal to itself.") | |
1338 | 1312 | } | |
1339 | 1313 | else throw("Strict value is not equal to itself.") | |
1340 | 1314 | } | |
1341 | 1315 | ||
1342 | 1316 | ||
1343 | 1317 | ||
1344 | 1318 | @Callable(i) | |
1345 | - | func putOneTknV2WithBonusREADONLY ( | |
1319 | + | func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1346 | 1320 | let poolConfig = gpc() | |
1347 | 1321 | let amId = poolConfig[idxAmAsId] | |
1348 | 1322 | let prId = poolConfig[idxPrAsId] | |
1349 | 1323 | let lpId = poolConfig[idxLPAsId] | |
1350 | - | let paymentAsset = asset | |
1351 | - | let paymentAmountRaw = amount | |
1352 | - | let $t04799448084 = takeFee(paymentAmountRaw) | |
1353 | - | let paymentAmount = $t04799448084._1 | |
1354 | - | let feeAmount = $t04799448084._2 | |
1355 | - | let $t04808848270 = if ((paymentAsset == amId)) | |
1356 | - | then $Tuple2(paymentAmount, 0) | |
1357 | - | else if ((paymentAsset == prId)) | |
1358 | - | then $Tuple2(0, paymentAmount) | |
1359 | - | else throw("invalid payment") | |
1360 | - | let amAmount = $t04808848270._1 | |
1361 | - | let prAmount = $t04808848270._2 | |
1362 | - | let amBalanceOld = getAccBalance(amId) | |
1363 | - | let prBalanceOld = getAccBalance(prId) | |
1364 | - | let amBalanceNew = (amBalanceOld + amAmount) | |
1365 | - | let prBalanceNew = (prBalanceOld + prAmount) | |
1366 | - | let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)]) | |
1367 | - | let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)]) | |
1368 | - | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
1369 | - | let lpAmount = ((lpAssetEmission * (D1 - D0)) / D0) | |
1370 | - | let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld) | |
1371 | - | let amountAssetPart = fraction(paymentAmount, scale8, (poolProportion + scale8)) | |
1372 | - | let priceAssetPart = (paymentAmount - amountAssetPart) | |
1373 | - | let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld)) | |
1374 | - | let bonus = fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth) | |
1375 | - | $Tuple2(nil, $Tuple3(toInt(lpAmount), feeAmount, toInt(bonus))) | |
1324 | + | let $t04716847265 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "") | |
1325 | + | let lpAmount = $t04716847265._1 | |
1326 | + | let state = $t04716847265._2 | |
1327 | + | let feeAmount = $t04716847265._3 | |
1328 | + | let bonus = $t04716847265._4 | |
1329 | + | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1376 | 1330 | } | |
1377 | 1331 | ||
1378 | 1332 | ||
1379 | 1333 | ||
1380 | 1334 | @Callable(i) | |
1381 | 1335 | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca))) | |
1382 | 1336 | then throw("denied") | |
1383 | 1337 | else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success") | |
1384 | 1338 | ||
1385 | 1339 | ||
1386 | 1340 | ||
1387 | 1341 | @Callable(i) | |
1388 | 1342 | func setS (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1389 | 1343 | then pd | |
1390 | 1344 | else [StringEntry(k, v)] | |
1391 | 1345 | ||
1392 | 1346 | ||
1393 | 1347 | ||
1394 | 1348 | @Callable(i) | |
1395 | 1349 | func setI (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1396 | 1350 | then pd | |
1397 | 1351 | else [IntegerEntry(k, v)] | |
1398 | 1352 | ||
1399 | 1353 | ||
1400 | 1354 | ||
1401 | 1355 | @Callable(i) | |
1402 | 1356 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc()) | |
1403 | 1357 | ||
1404 | 1358 | ||
1405 | 1359 | ||
1406 | 1360 | @Callable(i) | |
1407 | 1361 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1408 | 1362 | ||
1409 | 1363 | ||
1410 | 1364 | ||
1411 | 1365 | @Callable(i) | |
1412 | 1366 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1413 | 1367 | let pr = calcPrices(amAmt, prAmt, lpAmt) | |
1414 | 1368 | $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])]) | |
1415 | 1369 | } | |
1416 | 1370 | ||
1417 | 1371 | ||
1418 | 1372 | ||
1419 | 1373 | @Callable(i) | |
1420 | 1374 | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult)) | |
1421 | 1375 | ||
1422 | 1376 | ||
1423 | 1377 | ||
1424 | 1378 | @Callable(i) | |
1425 | 1379 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult))) | |
1426 | 1380 | ||
1427 | 1381 | ||
1428 | 1382 | ||
1429 | 1383 | @Callable(i) | |
1430 | 1384 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1431 | 1385 | ||
1432 | 1386 | ||
1433 | 1387 | ||
1434 | 1388 | @Callable(i) | |
1435 | 1389 | func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, true, false, 0, "")) | |
1436 | 1390 | ||
1437 | 1391 | ||
1438 | 1392 | ||
1439 | 1393 | @Callable(i) | |
1440 | 1394 | func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = { | |
1441 | 1395 | let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr)) | |
1442 | 1396 | $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10)) | |
1443 | 1397 | } | |
1444 | 1398 | ||
1445 | 1399 | ||
1446 | 1400 | ||
1447 | 1401 | @Callable(i) | |
1448 | 1402 | func getFeeREADONLY () = $Tuple2(nil, fee) | |
1449 | 1403 | ||
1450 | 1404 | ||
1451 | 1405 | @Verifier(tx) | |
1452 | 1406 | func verify () = { | |
1453 | 1407 | let targetPublicKey = match m() { | |
1454 | 1408 | case pk: ByteVector => | |
1455 | 1409 | pk | |
1456 | 1410 | case _: Unit => | |
1457 | 1411 | tx.senderPublicKey | |
1458 | 1412 | case _ => | |
1459 | 1413 | throw("Match error") | |
1460 | 1414 | } | |
1461 | 1415 | match tx { | |
1462 | 1416 | case order: Order => | |
1463 | 1417 | let matcherPub = mp() | |
1464 | 1418 | let orderValid = moa(order) | |
1465 | 1419 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1466 | 1420 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1467 | 1421 | if (if (if (orderValid) | |
1468 | 1422 | then senderValid | |
1469 | 1423 | else false) | |
1470 | 1424 | then matcherValid | |
1471 | 1425 | else false) | |
1472 | 1426 | then true | |
1473 | 1427 | else toe(orderValid, senderValid, matcherValid) | |
1474 | 1428 | case s: SetScriptTransaction => | |
1475 | 1429 | let newHash = blake2b256(value(s.script)) | |
1476 | 1430 | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
1477 | 1431 | let currentHash = scriptHash(this) | |
1478 | 1432 | if (if ((allowedHash == newHash)) | |
1479 | 1433 | then (currentHash != newHash) | |
1480 | 1434 | else false) | |
1481 | 1435 | then true | |
1482 | 1436 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1483 | 1437 | case _ => | |
1484 | 1438 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1485 | 1439 | } | |
1486 | 1440 | } | |
1487 | 1441 |
github/deemru/w8io/026f985 180.57 ms ◑