tx · J5Lh9MkQ91t9KECkv7tAdt17itVkLFbzdZMGejJ2G3RB 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA: -0.02900000 Waves 2022.09.12 17:24 [2226003] smart account 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA > SELF 0.00000000 Waves
{ "type": 13, "id": "J5Lh9MkQ91t9KECkv7tAdt17itVkLFbzdZMGejJ2G3RB", "fee": 2900000, "feeAssetId": null, "timestamp": 1662992756587, "version": 1, "sender": "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA", "senderPublicKey": "35yd3qw1gxKDxKwGAykHN9fANbXNWwseaUwbWDj24o3x", "proofs": [ "2mCyJRU8eUmxJzfXbFvsqyVHASyNERrZpJvc3SrfARmjE6qA5RbADyXkM5d5PTkpCq3YozsA7nngTDPzwoApb9oM" ], "script": "base64:BgJ/CAISAwoBCBIDCgEIEgASBAoCAQQSBwoFAQEBAQQSAwoBARIAEgcKBQEBAQgBEgQKAgEBEgMKAQESBAoCCAgSBAoCCAgSBAoCCAESABIDCgEIEgUKAwEBARIECgIIARIECgIBARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCFIABnNjYWxlOACAwtcvAAxzY2FsZThCaWdJbnQJALYCAQCAwtcvAAdzY2FsZTE4CQC2AgEAgICQu7rWrfANAAh0aG91c2FuZADoBwAKemVyb0JpZ0ludAkAtgIBAAAACW9uZUJpZ0ludAkAtgIBAAEACnNsaXBwYWdlNEQJALYCAQkAZQIFBnNjYWxlOAkAaQIJAGgCBQZzY2FsZTgAAQUGc2NhbGU4AAVBbXVsdAIDMTAwAAVEY29udgIBMQADU0VQAgJfXwAFRU1QVFkCAAAKUG9vbEFjdGl2ZQABAApQb29sUHV0RGlzAAIADlBvb2xNYXRjaGVyRGlzAAMADFBvb2xTaHV0ZG93bgAEAA5pZHhQb29sQWRkcmVzcwABAAlpZHhQb29sU3QAAgAJaWR4TFBBc0lkAAMACWlkeEFtQXNJZAAEAAlpZHhQckFz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4BnByb29mcwAABQ90YXJnZXRQdWJsaWNLZXkJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFD3RhcmdldFB1YmxpY0tleei8Leo=", "chainId": 84, "height": 2226003, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Hmt2U1HBWakXvid12118nvFqEyxFqneteFfGBCYMEsos Next: 5kH5x73nCt9s9dRMZ7VFN2GWQ6AyeAiCMReMkWsNFbdw Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | let scale8BigInt = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | let scale18 = toBigInt(1000000000000000000) | |
9 | + | ||
10 | + | let thousand = 1000 | |
9 | 11 | ||
10 | 12 | let zeroBigInt = toBigInt(0) | |
11 | 13 | ||
53 | 55 | ||
54 | 56 | let idxFactGwxRewCntr = 10 | |
55 | 57 | ||
56 | - | let | |
58 | + | let feePermilleDefault = 0 | |
57 | 59 | ||
58 | 60 | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
59 | 61 | ||
102 | 104 | func ada () = "%s__addonAddr" | |
103 | 105 | ||
104 | 106 | ||
105 | - | ||
107 | + | let keyFeePermille = "%s__feePermille" | |
106 | 108 | ||
107 | - | ||
108 | - | func lsotc (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP) | |
109 | - | ||
109 | + | let feePermille = valueOrElse(getInteger(this, keyFeePermille), feePermilleDefault) | |
110 | 110 | ||
111 | 111 | func fcfg () = "%s__factoryConfig" | |
112 | 112 | ||
124 | 124 | ||
125 | 125 | ||
126 | 126 | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" | |
127 | + | ||
128 | + | ||
129 | + | func keyFeeCollectorAddress () = "%s__feeCollectorAddress" | |
127 | 130 | ||
128 | 131 | ||
129 | 132 | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
152 | 155 | ||
153 | 156 | func mp () = fromBase58String(strf(fca, mtpk())) | |
154 | 157 | ||
158 | + | ||
159 | + | let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress())) | |
155 | 160 | ||
156 | 161 | func gpc () = { | |
157 | 162 | let amtAs = strf(this, aa()) | |
337 | 342 | else calcLpAmt | |
338 | 343 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
339 | 344 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
340 | - | let $ | |
345 | + | let $t01568216027 = if (if (isOneAsset) | |
341 | 346 | then (pmtId == amIdStr) | |
342 | 347 | else false) | |
343 | 348 | then $Tuple2(pmtAmt, 0) | |
346 | 351 | else false) | |
347 | 352 | then $Tuple2(0, pmtAmt) | |
348 | 353 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
349 | - | let writeAmAmt = $ | |
350 | - | let writePrAmt = $ | |
354 | + | let writeAmAmt = $t01568216027._1 | |
355 | + | let writePrAmt = $t01568216027._2 | |
351 | 356 | 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))] | |
352 | 357 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
353 | 358 | } | |
428 | 433 | else (sts == PoolShutdown)) | |
429 | 434 | then throw(("Blocked:" + toString(sts))) | |
430 | 435 | else r | |
436 | + | } | |
437 | + | ||
438 | + | ||
439 | + | func takeFee (amount) = { | |
440 | + | let fee = fraction(amount, feePermille, thousand) | |
441 | + | $Tuple2((amount - fee), fee) | |
431 | 442 | } | |
432 | 443 | ||
433 | 444 | ||
588 | 599 | let userAddress = if ((addon == toString(i.caller))) | |
589 | 600 | then i.originCaller | |
590 | 601 | else i.caller | |
591 | - | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
592 | - | let check = reentrantInvoke(addonContract, "ensureCanPutOneTkn", [toString(userAddress)], nil) | |
593 | - | if ((check == check)) | |
594 | - | then if (if (if (if ((0 >= slippage)) | |
595 | - | then true | |
596 | - | else (0 >= amAssetPart)) | |
597 | - | then true | |
598 | - | else (0 >= prAssetPart)) | |
599 | - | then true | |
600 | - | else (0 >= outLp)) | |
601 | - | then throw("Wrong params") | |
602 | - | else if ((size(i.payments) != 1)) | |
603 | - | then throw("1 pmnt expd") | |
604 | - | else { | |
605 | - | let pmt = value(i.payments[0]) | |
606 | - | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
607 | - | let pmtAmt = pmt.amount | |
608 | - | if ((10000000 > pmtAmt)) | |
609 | - | then throw("Wrong pmt amt") | |
610 | - | else { | |
611 | - | let amBalance = getAccBalance(amId) | |
612 | - | let prBalance = getAccBalance(prId) | |
613 | - | let $t02485925435 = if ((pmtAssetId == amId)) | |
614 | - | then if (if ((pmtAmt > amBalance)) | |
602 | + | if (if (if (if ((0 >= slippage)) | |
603 | + | then true | |
604 | + | else (0 >= amAssetPart)) | |
605 | + | then true | |
606 | + | else (0 >= prAssetPart)) | |
607 | + | then true | |
608 | + | else (0 >= outLp)) | |
609 | + | then throw("Wrong params") | |
610 | + | else if ((size(i.payments) != 1)) | |
611 | + | then throw("1 pmnt expd") | |
612 | + | else { | |
613 | + | let pmt = value(i.payments[0]) | |
614 | + | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
615 | + | let paymentAmountRaw = pmt.amount | |
616 | + | let $t02464424696 = takeFee(paymentAmountRaw) | |
617 | + | let pmtAmt = $t02464424696._1 | |
618 | + | let feeAmount = $t02464424696._2 | |
619 | + | if ((10000000 > paymentAmountRaw)) | |
620 | + | then throw("Wrong pmt amt") | |
621 | + | else { | |
622 | + | let amBalance = getAccBalance(amId) | |
623 | + | let prBalance = getAccBalance(prId) | |
624 | + | let $t02485625472 = if ((pmtAssetId == amId)) | |
625 | + | then if (if ((paymentAmountRaw > amBalance)) | |
626 | + | then true | |
627 | + | else (amAssetPart > pmtAmt)) | |
628 | + | then throw("invalid payment amount") | |
629 | + | else $Tuple6((amBalance - paymentAmountRaw), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
630 | + | else if ((pmtAssetId == prId)) | |
631 | + | then if (if ((paymentAmountRaw > prBalance)) | |
615 | 632 | then true | |
616 | - | else ( | |
633 | + | else (prAssetPart > pmtAmt)) | |
617 | 634 | then throw("invalid payment amount") | |
618 | - | else $Tuple6((amBalance - pmtAmt), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
619 | - | else if ((pmtAssetId == prId)) | |
620 | - | then if (if ((pmtAmt > prBalance)) | |
621 | - | then true | |
622 | - | else (prAssetPart > pmtAmt)) | |
623 | - | then throw("invalid payment amount") | |
624 | - | else $Tuple6(amBalance, (prBalance - pmtAmt), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
625 | - | else throw("wrong pmtAssetId") | |
626 | - | let amBalanceNow = $t02485925435._1 | |
627 | - | let prBalanceNow = $t02485925435._2 | |
628 | - | let virtSwapInAm = $t02485925435._3 | |
629 | - | let virtSwapOutPr = $t02485925435._4 | |
630 | - | let virtSwapInPr = $t02485925435._5 | |
631 | - | let virtSwapOutAm = $t02485925435._6 | |
632 | - | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
633 | - | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
634 | - | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
635 | - | if ((D0vsD1 == D0vsD1)) | |
636 | - | then { | |
637 | - | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId) | |
638 | - | let estimLP = estPut._2 | |
639 | - | let lpAssetId = estPut._7 | |
640 | - | let state = estPut._9 | |
641 | - | let amDiff = estPut._10 | |
642 | - | let prDiff = estPut._11 | |
643 | - | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
644 | - | let emitLpAmt = toInt(lpCalcRes._2) | |
645 | - | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
646 | - | if ((e == e)) | |
647 | - | then { | |
648 | - | let el = match e { | |
649 | - | case legacy: Address => | |
650 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
651 | - | case _ => | |
652 | - | unit | |
653 | - | } | |
654 | - | if ((el == el)) | |
655 | - | then { | |
656 | - | let sa = if ((amDiff > 0)) | |
657 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
658 | - | else nil | |
659 | - | if ((sa == sa)) | |
660 | - | then { | |
661 | - | let sp = if ((prDiff > 0)) | |
662 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
663 | - | else nil | |
664 | - | if ((sp == sp)) | |
665 | - | then { | |
666 | - | let lpTrnsfr = if (autoStake) | |
667 | - | then { | |
668 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
669 | - | if ((ss == ss)) | |
670 | - | then nil | |
671 | - | else throw("Strict value is not equal to itself.") | |
672 | - | } | |
673 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
674 | - | (state ++ lpTrnsfr) | |
675 | - | } | |
676 | - | else throw("Strict value is not equal to itself.") | |
677 | - | } | |
678 | - | else throw("Strict value is not equal to itself.") | |
679 | - | } | |
680 | - | else throw("Strict value is not equal to itself.") | |
681 | - | } | |
682 | - | else throw("Strict value is not equal to itself.") | |
683 | - | } | |
684 | - | else throw("Strict value is not equal to itself.") | |
685 | - | } | |
686 | - | } | |
687 | - | else throw("Strict value is not equal to itself.") | |
688 | - | } | |
689 | - | ||
690 | - | ||
691 | - | ||
692 | - | @Callable(i) | |
693 | - | func putOneTknV2 (outLp,slippage,autoStake) = { | |
694 | - | let cfg = gfc() | |
695 | - | let stakingCntr = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wr st addr") | |
696 | - | let slipCntr = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wr sl addr") | |
697 | - | let gwxCntr = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wr gwx addr") | |
698 | - | let poolCfg = gpc() | |
699 | - | let amId = poolCfg[idxAmAsId] | |
700 | - | let prId = poolCfg[idxPrAsId] | |
701 | - | let amDcm = parseIntValue(poolCfg[idxAmtAsDcm]) | |
702 | - | let prDcm = parseIntValue(poolCfg[idxPriceAsDcm]) | |
703 | - | let addon = valueOrElse(getString(this, ada()), "") | |
704 | - | let userAddress = if ((addon == toString(i.caller))) | |
705 | - | then i.originCaller | |
706 | - | else i.caller | |
707 | - | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
708 | - | if ((size(i.payments) != 1)) | |
709 | - | then throw("1 pmnt expd") | |
710 | - | else { | |
711 | - | let pmt = value(i.payments[0]) | |
712 | - | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
713 | - | let pmtAmt = pmt.amount | |
714 | - | if ((10000000 > pmtAmt)) | |
715 | - | then throw("Wrong pmt amt") | |
716 | - | else { | |
717 | - | let amBalance = getAccBalance(amId) | |
718 | - | let prBalance = getAccBalance(prId) | |
719 | - | let $t02878529173 = if ((pmtAssetId == amId)) | |
720 | - | then if ((pmtAmt > amBalance)) | |
721 | - | then throw("invalid payment amount") | |
722 | - | else $Tuple2((amBalance - pmtAmt), prBalance) | |
723 | - | else if ((pmtAssetId == prId)) | |
724 | - | then if ((pmtAmt > prBalance)) | |
725 | - | then throw("invalid payment amount") | |
726 | - | else $Tuple2(amBalance, (prBalance - pmtAmt)) | |
727 | - | else throw("wrong pmtAssetId") | |
728 | - | let amBalanceNow = $t02878529173._1 | |
729 | - | let prBalanceNow = $t02878529173._2 | |
730 | - | let $t02917929313 = if ((pmtAssetId == amId)) | |
731 | - | then $Tuple2(amBalanceNow, prBalanceNow) | |
732 | - | else $Tuple2(prBalanceNow, amBalanceNow) | |
733 | - | let amBalanceForCalc = $t02917929313._1 | |
734 | - | let prBalanceForCalc = $t02917929313._2 | |
735 | - | let xPrecision = 1 | |
736 | - | let result = { | |
737 | - | let @ = invoke(gwxCntr, "calcPutXOnly", [toString(pmtAmt), toString(amBalanceForCalc), toString(prBalanceForCalc), "", A, Amult, toString(xPrecision), Dconv], nil) | |
738 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
739 | - | then @ | |
740 | - | else throw(($getType(invoke(gwxCntr, "calcPutXOnly", [toString(pmtAmt), toString(amBalanceForCalc), toString(prBalanceForCalc), "", A, Amult, toString(xPrecision), Dconv], nil)) + " couldn't be cast to (Int, Int)")) | |
635 | + | else $Tuple6(amBalance, (prBalance - paymentAmountRaw), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
636 | + | else throw("wrong pmtAssetId") | |
637 | + | let amBalanceNow = $t02485625472._1 | |
638 | + | let prBalanceNow = $t02485625472._2 | |
639 | + | let virtSwapInAm = $t02485625472._3 | |
640 | + | let virtSwapOutPr = $t02485625472._4 | |
641 | + | let virtSwapInPr = $t02485625472._5 | |
642 | + | let virtSwapOutAm = $t02485625472._6 | |
643 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
644 | + | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
645 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
646 | + | if ((D0vsD1 == D0vsD1)) | |
647 | + | then { | |
648 | + | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId) | |
649 | + | let estimLP = estPut._2 | |
650 | + | let lpAssetId = estPut._7 | |
651 | + | let state = estPut._9 | |
652 | + | let amDiff = estPut._10 | |
653 | + | let prDiff = estPut._11 | |
654 | + | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
655 | + | let emitLpAmt = toInt(lpCalcRes._2) | |
656 | + | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
657 | + | if ((e == e)) | |
658 | + | then { | |
659 | + | let el = match e { | |
660 | + | case legacy: Address => | |
661 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
662 | + | case _ => | |
663 | + | unit | |
664 | + | } | |
665 | + | if ((el == el)) | |
666 | + | then { | |
667 | + | let sa = if ((amDiff > 0)) | |
668 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
669 | + | else nil | |
670 | + | if ((sa == sa)) | |
671 | + | then { | |
672 | + | let sp = if ((prDiff > 0)) | |
673 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
674 | + | else nil | |
675 | + | if ((sp == sp)) | |
676 | + | then { | |
677 | + | let lpTrnsfr = if (autoStake) | |
678 | + | then { | |
679 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
680 | + | if ((ss == ss)) | |
681 | + | then nil | |
682 | + | else throw("Strict value is not equal to itself.") | |
683 | + | } | |
684 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
685 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
686 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
687 | + | else nil | |
688 | + | ((state ++ lpTrnsfr) ++ sendFeeToMatcher) | |
689 | + | } | |
690 | + | else throw("Strict value is not equal to itself.") | |
691 | + | } | |
692 | + | else throw("Strict value is not equal to itself.") | |
693 | + | } | |
694 | + | else throw("Strict value is not equal to itself.") | |
695 | + | } | |
696 | + | else throw("Strict value is not equal to itself.") | |
697 | + | } | |
698 | + | else throw("Strict value is not equal to itself.") | |
741 | 699 | } | |
742 | - | let $t02982529921 = if ((pmtAssetId == amId)) | |
743 | - | then result | |
744 | - | else $Tuple2(result._2, result._1) | |
745 | - | let amAssetPart = $t02982529921._1 | |
746 | - | let prAssetPart = $t02982529921._2 | |
747 | - | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId) | |
748 | - | let estimLP = estPut._2 | |
749 | - | let lpAssetId = estPut._7 | |
750 | - | let state = estPut._9 | |
751 | - | let amDiff = estPut._10 | |
752 | - | let prDiff = estPut._11 | |
753 | - | let emitLpAmt = if ((outLp > 0)) | |
754 | - | then { | |
755 | - | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
756 | - | toInt(lpCalcRes._2) | |
757 | - | } | |
758 | - | else estimLP | |
759 | - | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
760 | - | if ((e == e)) | |
761 | - | then { | |
762 | - | let el = match e { | |
763 | - | case legacy: Address => | |
764 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
765 | - | case _ => | |
766 | - | unit | |
767 | - | } | |
768 | - | if ((el == el)) | |
769 | - | then { | |
770 | - | let sa = if ((amDiff > 0)) | |
771 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
772 | - | else nil | |
773 | - | if ((sa == sa)) | |
774 | - | then { | |
775 | - | let sp = if ((prDiff > 0)) | |
776 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
777 | - | else nil | |
778 | - | if ((sp == sp)) | |
779 | - | then { | |
780 | - | let lpTrnsfr = if (autoStake) | |
781 | - | then { | |
782 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
783 | - | if ((ss == ss)) | |
784 | - | then nil | |
785 | - | else throw("Strict value is not equal to itself.") | |
786 | - | } | |
787 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
788 | - | (state ++ lpTrnsfr) | |
789 | - | } | |
790 | - | else throw("Strict value is not equal to itself.") | |
791 | - | } | |
792 | - | else throw("Strict value is not equal to itself.") | |
793 | - | } | |
794 | - | else throw("Strict value is not equal to itself.") | |
795 | - | } | |
796 | - | else throw("Strict value is not equal to itself.") | |
797 | - | } | |
798 | - | } | |
700 | + | } | |
799 | 701 | } | |
800 | 702 | ||
801 | 703 | ||
849 | 751 | let txId58 = toBase58String(i.transactionId) | |
850 | 752 | let pmtAssetId = value(pmt.assetId) | |
851 | 753 | let pmtAmt = pmt.amount | |
852 | - | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
853 | - | let check = reentrantInvoke(addonContract, "ensureCanGetOneTkn", [toString(userAddress)], nil) | |
854 | - | if ((check == check)) | |
855 | - | then if ((1000000000 > pmtAmt)) | |
856 | - | then throw("Min pmt 10 LP") | |
857 | - | else if (if (if ((0 > slippage)) | |
858 | - | then true | |
859 | - | else (0 > exchResult)) | |
860 | - | then true | |
861 | - | else (0 > outAmount)) | |
862 | - | then throw("Wrong params") | |
863 | - | else if ((lpId != toBase58String(pmtAssetId))) | |
864 | - | then throw("Wrong LP") | |
865 | - | else { | |
866 | - | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
867 | - | let estimAmAmt = r._1 | |
868 | - | let estimPrAmt = r._2 | |
869 | - | let amBalance = getAccBalance(amId) | |
870 | - | let prBalance = getAccBalance(prId) | |
871 | - | let $t03449034947 = if ((outAssetId == amId)) | |
872 | - | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
873 | - | else if ((outAssetId == prId)) | |
874 | - | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
875 | - | else throw("wrong outAssetId") | |
876 | - | let amBalanceNow = $t03449034947._1 | |
877 | - | let prBalanceNow = $t03449034947._2 | |
878 | - | let virtSwapInAm = $t03449034947._3 | |
879 | - | let virtSwapOutPr = $t03449034947._4 | |
880 | - | let virtSwapInPr = $t03449034947._5 | |
881 | - | let virtSwapOutAm = $t03449034947._6 | |
882 | - | let totalGet = $t03449034947._7 | |
883 | - | if (if ((0 > virtSwapInAm)) | |
884 | - | then true | |
885 | - | else (0 > virtSwapInPr)) | |
886 | - | then throw("Wrong calc") | |
887 | - | else { | |
888 | - | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
889 | - | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
890 | - | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
891 | - | if ((D0vsD1 == D0vsD1)) | |
892 | - | then { | |
893 | - | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
894 | - | if ((finalRes == finalRes)) | |
895 | - | then { | |
896 | - | let $t03565235756 = if ((outAssetId == amId)) | |
897 | - | then $Tuple2(toInt(finalRes._2), 0) | |
898 | - | else $Tuple2(0, toInt(finalRes._2)) | |
899 | - | let outAm = $t03565235756._1 | |
900 | - | let outPr = $t03565235756._2 | |
901 | - | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
902 | - | let curPr = f1(curPrX18, scale8) | |
903 | - | let state = [ScriptTransfer(userAddress, (outAm + outPr), if ((outAssetId == "WAVES")) | |
904 | - | then unit | |
905 | - | else fromBase58String(outAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] | |
906 | - | if ((state == state)) | |
907 | - | then { | |
908 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
909 | - | if ((burn == burn)) | |
910 | - | then state | |
911 | - | else throw("Strict value is not equal to itself.") | |
912 | - | } | |
913 | - | else throw("Strict value is not equal to itself.") | |
914 | - | } | |
915 | - | else throw("Strict value is not equal to itself.") | |
916 | - | } | |
917 | - | else throw("Strict value is not equal to itself.") | |
918 | - | } | |
919 | - | } | |
920 | - | else throw("Strict value is not equal to itself.") | |
754 | + | if ((1000000000 > pmtAmt)) | |
755 | + | then throw("Min pmt 10 LP") | |
756 | + | else if (if (if ((0 > slippage)) | |
757 | + | then true | |
758 | + | else (0 > exchResult)) | |
759 | + | then true | |
760 | + | else (0 > outAmount)) | |
761 | + | then throw("Wrong params") | |
762 | + | else if ((lpId != toBase58String(pmtAssetId))) | |
763 | + | then throw("Wrong LP") | |
764 | + | else { | |
765 | + | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
766 | + | let estimAmAmt = r._1 | |
767 | + | let estimPrAmt = r._2 | |
768 | + | let amBalance = getAccBalance(amId) | |
769 | + | let prBalance = getAccBalance(prId) | |
770 | + | let $t03041530875 = if ((outAssetId == amId)) | |
771 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
772 | + | else if ((outAssetId == prId)) | |
773 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
774 | + | else throw("wrong outAssetId") | |
775 | + | let amBalanceNow = $t03041530875._1 | |
776 | + | let prBalanceNow = $t03041530875._2 | |
777 | + | let virtSwapInAm = $t03041530875._3 | |
778 | + | let virtSwapOutPr = $t03041530875._4 | |
779 | + | let virtSwapInPr = $t03041530875._5 | |
780 | + | let virtSwapOutAm = $t03041530875._6 | |
781 | + | let totalGetRaw = $t03041530875._7 | |
782 | + | if (if ((0 > virtSwapInAm)) | |
783 | + | then true | |
784 | + | else (0 > virtSwapInPr)) | |
785 | + | then throw("Wrong calc") | |
786 | + | else { | |
787 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
788 | + | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
789 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
790 | + | if ((D0vsD1 == D0vsD1)) | |
791 | + | then { | |
792 | + | let totalGet = takeFee(totalGetRaw)._1 | |
793 | + | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
794 | + | if ((finalRes == finalRes)) | |
795 | + | then { | |
796 | + | let $t03162231726 = if ((outAssetId == amId)) | |
797 | + | then $Tuple2(toInt(finalRes._2), 0) | |
798 | + | else $Tuple2(0, toInt(finalRes._2)) | |
799 | + | let outAm = $t03162231726._1 | |
800 | + | let outPr = $t03162231726._2 | |
801 | + | let totalAmount = (outAm + outPr) | |
802 | + | let feeAmount = (totalGetRaw - totalGet) | |
803 | + | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
804 | + | then unit | |
805 | + | else fromBase58String(outAssetId) | |
806 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
807 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
808 | + | else nil | |
809 | + | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
810 | + | let curPr = f1(curPrX18, scale8) | |
811 | + | 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)] | |
812 | + | if ((state == state)) | |
813 | + | then { | |
814 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
815 | + | if ((burn == burn)) | |
816 | + | then (state ++ sendFeeToMatcher) | |
817 | + | else throw("Strict value is not equal to itself.") | |
818 | + | } | |
819 | + | else throw("Strict value is not equal to itself.") | |
820 | + | } | |
821 | + | else throw("Strict value is not equal to itself.") | |
822 | + | } | |
823 | + | else throw("Strict value is not equal to itself.") | |
824 | + | } | |
825 | + | } | |
921 | 826 | } | |
922 | 827 | ||
923 | 828 |
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 | + | ||
10 | + | let thousand = 1000 | |
9 | 11 | ||
10 | 12 | let zeroBigInt = toBigInt(0) | |
11 | 13 | ||
12 | 14 | let oneBigInt = toBigInt(1) | |
13 | 15 | ||
14 | 16 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
15 | 17 | ||
16 | 18 | let Amult = "100" | |
17 | 19 | ||
18 | 20 | let Dconv = "1" | |
19 | 21 | ||
20 | 22 | let SEP = "__" | |
21 | 23 | ||
22 | 24 | let EMPTY = "" | |
23 | 25 | ||
24 | 26 | let PoolActive = 1 | |
25 | 27 | ||
26 | 28 | let PoolPutDis = 2 | |
27 | 29 | ||
28 | 30 | let PoolMatcherDis = 3 | |
29 | 31 | ||
30 | 32 | let PoolShutdown = 4 | |
31 | 33 | ||
32 | 34 | let idxPoolAddress = 1 | |
33 | 35 | ||
34 | 36 | let idxPoolSt = 2 | |
35 | 37 | ||
36 | 38 | let idxLPAsId = 3 | |
37 | 39 | ||
38 | 40 | let idxAmAsId = 4 | |
39 | 41 | ||
40 | 42 | let idxPrAsId = 5 | |
41 | 43 | ||
42 | 44 | let idxAmtAsDcm = 6 | |
43 | 45 | ||
44 | 46 | let idxPriceAsDcm = 7 | |
45 | 47 | ||
46 | 48 | let idxIAmtAsId = 8 | |
47 | 49 | ||
48 | 50 | let idxIPriceAsId = 9 | |
49 | 51 | ||
50 | 52 | let idxFactStakCntr = 1 | |
51 | 53 | ||
52 | 54 | let idxFactSlippCntr = 7 | |
53 | 55 | ||
54 | 56 | let idxFactGwxRewCntr = 10 | |
55 | 57 | ||
56 | - | let | |
58 | + | let feePermilleDefault = 0 | |
57 | 59 | ||
58 | 60 | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
59 | 61 | ||
60 | 62 | ||
61 | 63 | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
62 | 64 | ||
63 | 65 | ||
64 | 66 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
65 | 67 | ||
66 | 68 | ||
67 | 69 | func abs (val) = if ((zeroBigInt > val)) | |
68 | 70 | then -(val) | |
69 | 71 | else val | |
70 | 72 | ||
71 | 73 | ||
72 | 74 | func fc () = "%s__factoryContract" | |
73 | 75 | ||
74 | 76 | ||
75 | 77 | func mpk () = "%s__managerPublicKey" | |
76 | 78 | ||
77 | 79 | ||
78 | 80 | func pmpk () = "%s__pendingManagerPublicKey" | |
79 | 81 | ||
80 | 82 | ||
81 | 83 | func pl () = "%s%s__price__last" | |
82 | 84 | ||
83 | 85 | ||
84 | 86 | func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP) | |
85 | 87 | ||
86 | 88 | ||
87 | 89 | func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId) | |
88 | 90 | ||
89 | 91 | ||
90 | 92 | func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId) | |
91 | 93 | ||
92 | 94 | ||
93 | 95 | func aa () = "%s__amountAsset" | |
94 | 96 | ||
95 | 97 | ||
96 | 98 | func pa () = "%s__priceAsset" | |
97 | 99 | ||
98 | 100 | ||
99 | 101 | func amp () = "%s__amp" | |
100 | 102 | ||
101 | 103 | ||
102 | 104 | func ada () = "%s__addonAddr" | |
103 | 105 | ||
104 | 106 | ||
105 | - | ||
107 | + | let keyFeePermille = "%s__feePermille" | |
106 | 108 | ||
107 | - | ||
108 | - | func lsotc (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP) | |
109 | - | ||
109 | + | let feePermille = valueOrElse(getInteger(this, keyFeePermille), feePermilleDefault) | |
110 | 110 | ||
111 | 111 | func fcfg () = "%s__factoryConfig" | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | func mtpk () = "%s%s__matcher__publicKey" | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
118 | 118 | ||
119 | 119 | ||
120 | 120 | func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
121 | 121 | ||
122 | 122 | ||
123 | 123 | func aps () = "%s__shutdown" | |
124 | 124 | ||
125 | 125 | ||
126 | 126 | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" | |
127 | + | ||
128 | + | ||
129 | + | func keyFeeCollectorAddress () = "%s__feeCollectorAddress" | |
127 | 130 | ||
128 | 131 | ||
129 | 132 | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
130 | 133 | ||
131 | 134 | ||
132 | 135 | func str (val) = match val { | |
133 | 136 | case valStr: String => | |
134 | 137 | valStr | |
135 | 138 | case _ => | |
136 | 139 | throw("fail cast to String") | |
137 | 140 | } | |
138 | 141 | ||
139 | 142 | ||
140 | 143 | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
141 | 144 | ||
142 | 145 | ||
143 | 146 | func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
144 | 147 | ||
145 | 148 | ||
146 | 149 | let fca = addressFromStringValue(strf(this, fc())) | |
147 | 150 | ||
148 | 151 | let A = strf(this, amp()) | |
149 | 152 | ||
150 | 153 | func igs () = valueOrElse(getBoolean(fca, aps()), false) | |
151 | 154 | ||
152 | 155 | ||
153 | 156 | func mp () = fromBase58String(strf(fca, mtpk())) | |
154 | 157 | ||
158 | + | ||
159 | + | let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress())) | |
155 | 160 | ||
156 | 161 | func gpc () = { | |
157 | 162 | let amtAs = strf(this, aa()) | |
158 | 163 | let priceAs = strf(this, pa()) | |
159 | 164 | let iPriceAs = intf(fca, mba(priceAs)) | |
160 | 165 | let iAmtAs = intf(fca, mba(amtAs)) | |
161 | 166 | split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP) | |
162 | 167 | } | |
163 | 168 | ||
164 | 169 | ||
165 | 170 | func gfc () = split(strf(fca, fcfg()), SEP) | |
166 | 171 | ||
167 | 172 | ||
168 | 173 | 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) | |
169 | 174 | ||
170 | 175 | ||
171 | 176 | 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) | |
172 | 177 | ||
173 | 178 | ||
174 | 179 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
175 | 180 | then wavesBalance(this).available | |
176 | 181 | else assetBalance(this, fromBase58String(assetId)) | |
177 | 182 | ||
178 | 183 | ||
179 | 184 | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
180 | 185 | ||
181 | 186 | ||
182 | 187 | func vad (A1,A2,slippage) = { | |
183 | 188 | let diff = fraction((A1 - A2), scale8BigInt, A2) | |
184 | 189 | let pass = ((slippage - abs(diff)) > zeroBigInt) | |
185 | 190 | if (!(pass)) | |
186 | 191 | then throw(("Big slpg: " + toString(diff))) | |
187 | 192 | else $Tuple2(pass, min([A1, A2])) | |
188 | 193 | } | |
189 | 194 | ||
190 | 195 | ||
191 | 196 | func vd (D1,D0,slpg) = { | |
192 | 197 | let diff = fraction(D0, scale8BigInt, D1) | |
193 | 198 | let fail = (slpg > diff) | |
194 | 199 | if (if (fail) | |
195 | 200 | then true | |
196 | 201 | else (D0 > D1)) | |
197 | 202 | then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg))) | |
198 | 203 | else fail | |
199 | 204 | } | |
200 | 205 | ||
201 | 206 | ||
202 | 207 | func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
203 | 208 | let amtAsAmtX18 = t1(amAmt, amAssetDcm) | |
204 | 209 | let prAsAmtX18 = t1(prAmt, prAssetDcm) | |
205 | 210 | cpbi(prAsAmtX18, amtAsAmtX18) | |
206 | 211 | } | |
207 | 212 | ||
208 | 213 | ||
209 | 214 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
210 | 215 | let cfg = gpc() | |
211 | 216 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
212 | 217 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
213 | 218 | let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt) | |
214 | 219 | let amAmtX18 = t1(amAmt, amtAsDcm) | |
215 | 220 | let prAmtX18 = t1(prAmt, prAsDcm) | |
216 | 221 | let lpAmtX18 = t1(lpAmt, scale8) | |
217 | 222 | let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18) | |
218 | 223 | let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18) | |
219 | 224 | [priceX18, lpPrInAmAsX18, lpPrInPrAsX18] | |
220 | 225 | } | |
221 | 226 | ||
222 | 227 | ||
223 | 228 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
224 | 229 | let p = calcPrices(amAmt, prAmt, lpAmt) | |
225 | 230 | [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)] | |
226 | 231 | } | |
227 | 232 | ||
228 | 233 | ||
229 | 234 | func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
230 | 235 | let cfg = gpc() | |
231 | 236 | let lpId = cfg[idxLPAsId] | |
232 | 237 | let amId = cfg[idxAmAsId] | |
233 | 238 | let prId = cfg[idxPrAsId] | |
234 | 239 | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
235 | 240 | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
236 | 241 | let sts = cfg[idxPoolSt] | |
237 | 242 | let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity | |
238 | 243 | if ((lpId != pmtAssetId)) | |
239 | 244 | then throw("Wrong pmt asset") | |
240 | 245 | else { | |
241 | 246 | let amBalance = getAccBalance(amId) | |
242 | 247 | let amBalanceX18 = t1(amBalance, amDcm) | |
243 | 248 | let prBalance = getAccBalance(prId) | |
244 | 249 | let prBalanceX18 = t1(prBalance, prDcm) | |
245 | 250 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
246 | 251 | let curPrice = f1(curPriceX18, scale8) | |
247 | 252 | let pmtLpAmtX18 = t1(pmtLpAmt, scale8) | |
248 | 253 | let lpEmissX18 = t1(lpEmiss, scale8) | |
249 | 254 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
250 | 255 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
251 | 256 | let outAmAmt = f1(outAmAmtX18, amDcm) | |
252 | 257 | let outPrAmt = f1(outPrAmtX18, prDcm) | |
253 | 258 | let state = if ((txId58 == "")) | |
254 | 259 | then nil | |
255 | 260 | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
256 | 261 | then unit | |
257 | 262 | else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES")) | |
258 | 263 | then unit | |
259 | 264 | 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)] | |
260 | 265 | $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state) | |
261 | 266 | } | |
262 | 267 | } | |
263 | 268 | ||
264 | 269 | ||
265 | 270 | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,pmtAmt,pmtId) = { | |
266 | 271 | let cfg = gpc() | |
267 | 272 | let lpId = fromBase58String(cfg[idxLPAsId]) | |
268 | 273 | let amIdStr = cfg[idxAmAsId] | |
269 | 274 | let prIdStr = cfg[idxPrAsId] | |
270 | 275 | let inAmIdStr = cfg[idxIAmtAsId] | |
271 | 276 | let inPrIdStr = cfg[idxIPriceAsId] | |
272 | 277 | let amtDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
273 | 278 | let priceDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
274 | 279 | let sts = cfg[idxPoolSt] | |
275 | 280 | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
276 | 281 | let amBalance = if (isEval) | |
277 | 282 | then getAccBalance(amIdStr) | |
278 | 283 | else if (if (isOneAsset) | |
279 | 284 | then (pmtId == amIdStr) | |
280 | 285 | else false) | |
281 | 286 | then (getAccBalance(amIdStr) - pmtAmt) | |
282 | 287 | else if (isOneAsset) | |
283 | 288 | then getAccBalance(amIdStr) | |
284 | 289 | else (getAccBalance(amIdStr) - inAmAmt) | |
285 | 290 | let prBalance = if (isEval) | |
286 | 291 | then getAccBalance(prIdStr) | |
287 | 292 | else if (if (isOneAsset) | |
288 | 293 | then (pmtId == prIdStr) | |
289 | 294 | else false) | |
290 | 295 | then (getAccBalance(prIdStr) - pmtAmt) | |
291 | 296 | else if (isOneAsset) | |
292 | 297 | then getAccBalance(prIdStr) | |
293 | 298 | else (getAccBalance(prIdStr) - inPrAmt) | |
294 | 299 | let inAmAssetAmtX18 = t1(inAmAmt, amtDcm) | |
295 | 300 | let inPrAssetAmtX18 = t1(inPrAmt, priceDcm) | |
296 | 301 | let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18) | |
297 | 302 | let amBalanceX18 = t1(amBalance, amtDcm) | |
298 | 303 | let prBalanceX18 = t1(prBalance, priceDcm) | |
299 | 304 | let r = if ((lpEm == 0)) | |
300 | 305 | then { | |
301 | 306 | let curPriceX18 = zeroBigInt | |
302 | 307 | let slippageX18 = zeroBigInt | |
303 | 308 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
304 | 309 | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
305 | 310 | } | |
306 | 311 | else { | |
307 | 312 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
308 | 313 | let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
309 | 314 | let slippageX18 = t1(slippage, scale8) | |
310 | 315 | if (if ((curPriceX18 != zeroBigInt)) | |
311 | 316 | then (slippageRealX18 > slippageX18) | |
312 | 317 | else false) | |
313 | 318 | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
314 | 319 | else { | |
315 | 320 | let lpEmissionX18 = t1(lpEm, scale8) | |
316 | 321 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
317 | 322 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
318 | 323 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
319 | 324 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
320 | 325 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
321 | 326 | let expAmtAssetAmtX18 = expectedAmts._1 | |
322 | 327 | let expPriceAssetAmtX18 = expectedAmts._2 | |
323 | 328 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
324 | 329 | $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18) | |
325 | 330 | } | |
326 | 331 | } | |
327 | 332 | let calcLpAmt = r._1 | |
328 | 333 | let calcAmAssetPmt = r._2 | |
329 | 334 | let calcPrAssetPmt = r._3 | |
330 | 335 | let curPrice = f1(r._4, scale8) | |
331 | 336 | let slippageCalc = f1(r._5, scale8) | |
332 | 337 | if ((0 >= calcLpAmt)) | |
333 | 338 | then throw("LP <= 0") | |
334 | 339 | else { | |
335 | 340 | let emitLpAmt = if (!(emitLp)) | |
336 | 341 | then 0 | |
337 | 342 | else calcLpAmt | |
338 | 343 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
339 | 344 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
340 | - | let $ | |
345 | + | let $t01568216027 = if (if (isOneAsset) | |
341 | 346 | then (pmtId == amIdStr) | |
342 | 347 | else false) | |
343 | 348 | then $Tuple2(pmtAmt, 0) | |
344 | 349 | else if (if (isOneAsset) | |
345 | 350 | then (pmtId == prIdStr) | |
346 | 351 | else false) | |
347 | 352 | then $Tuple2(0, pmtAmt) | |
348 | 353 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
349 | - | let writeAmAmt = $ | |
350 | - | let writePrAmt = $ | |
354 | + | let writeAmAmt = $t01568216027._1 | |
355 | + | let writePrAmt = $t01568216027._2 | |
351 | 356 | 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))] | |
352 | 357 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
353 | 358 | } | |
354 | 359 | } | |
355 | 360 | ||
356 | 361 | ||
357 | 362 | func moa (order) = { | |
358 | 363 | let cfg = gpc() | |
359 | 364 | let amtAsId = cfg[idxAmAsId] | |
360 | 365 | let prAsId = cfg[idxPrAsId] | |
361 | 366 | let sts = parseIntValue(cfg[idxPoolSt]) | |
362 | 367 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
363 | 368 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
364 | 369 | let accAmtAsBalance = getAccBalance(amtAsId) | |
365 | 370 | let accPrAsBalance = getAccBalance(prAsId) | |
366 | 371 | let curPriceX18 = if ((order.orderType == Buy)) | |
367 | 372 | then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance) | |
368 | 373 | else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance) | |
369 | 374 | let curPrice = f1(curPriceX18, scale8) | |
370 | 375 | if (if (if (igs()) | |
371 | 376 | then true | |
372 | 377 | else (sts == PoolMatcherDis)) | |
373 | 378 | then true | |
374 | 379 | else (sts == PoolShutdown)) | |
375 | 380 | then throw("Admin blocked") | |
376 | 381 | else { | |
377 | 382 | let orAmtAsset = order.assetPair.amountAsset | |
378 | 383 | let orAmtAsStr = if ((orAmtAsset == unit)) | |
379 | 384 | then "WAVES" | |
380 | 385 | else toBase58String(value(orAmtAsset)) | |
381 | 386 | let orPrAsset = order.assetPair.priceAsset | |
382 | 387 | let orPrAsStr = if ((orPrAsset == unit)) | |
383 | 388 | then "WAVES" | |
384 | 389 | else toBase58String(value(orPrAsset)) | |
385 | 390 | if (if ((orAmtAsStr != amtAsId)) | |
386 | 391 | then true | |
387 | 392 | else (orPrAsStr != prAsId)) | |
388 | 393 | then throw("Wr assets") | |
389 | 394 | else { | |
390 | 395 | let orderPrice = order.price | |
391 | 396 | let priceDcm = fraction(scale8, prAsDcm, amtAsDcm) | |
392 | 397 | let castOrderPrice = ts(orderPrice, scale8, priceDcm) | |
393 | 398 | let isOrderPriceValid = if ((order.orderType == Buy)) | |
394 | 399 | then (curPrice >= castOrderPrice) | |
395 | 400 | else (castOrderPrice >= curPrice) | |
396 | 401 | true | |
397 | 402 | } | |
398 | 403 | } | |
399 | 404 | } | |
400 | 405 | ||
401 | 406 | ||
402 | 407 | func cg (i) = if ((size(i.payments) != 1)) | |
403 | 408 | then throw("1 pmnt exp") | |
404 | 409 | else { | |
405 | 410 | let pmt = value(i.payments[0]) | |
406 | 411 | let pmtAssetId = value(pmt.assetId) | |
407 | 412 | let pmtAmt = pmt.amount | |
408 | 413 | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
409 | 414 | let outAmAmt = r._1 | |
410 | 415 | let outPrAmt = r._2 | |
411 | 416 | let sts = parseIntValue(r._9) | |
412 | 417 | let state = r._10 | |
413 | 418 | if (if (igs()) | |
414 | 419 | then true | |
415 | 420 | else (sts == PoolShutdown)) | |
416 | 421 | then throw(("Admin blocked: " + toString(sts))) | |
417 | 422 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
418 | 423 | } | |
419 | 424 | ||
420 | 425 | ||
421 | 426 | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,pmtAmt,pmtId) = { | |
422 | 427 | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, false, emitLp, isOneAsset, pmtAmt, pmtId) | |
423 | 428 | let sts = parseIntValue(r._8) | |
424 | 429 | if (if (if (igs()) | |
425 | 430 | then true | |
426 | 431 | else (sts == PoolPutDis)) | |
427 | 432 | then true | |
428 | 433 | else (sts == PoolShutdown)) | |
429 | 434 | then throw(("Blocked:" + toString(sts))) | |
430 | 435 | else r | |
436 | + | } | |
437 | + | ||
438 | + | ||
439 | + | func takeFee (amount) = { | |
440 | + | let fee = fraction(amount, feePermille, thousand) | |
441 | + | $Tuple2((amount - fee), fee) | |
431 | 442 | } | |
432 | 443 | ||
433 | 444 | ||
434 | 445 | func m () = match getString(mpk()) { | |
435 | 446 | case s: String => | |
436 | 447 | fromBase58String(s) | |
437 | 448 | case _: Unit => | |
438 | 449 | unit | |
439 | 450 | case _ => | |
440 | 451 | throw("Match error") | |
441 | 452 | } | |
442 | 453 | ||
443 | 454 | ||
444 | 455 | func pm () = match getString(pmpk()) { | |
445 | 456 | case s: String => | |
446 | 457 | fromBase58String(s) | |
447 | 458 | case _: Unit => | |
448 | 459 | unit | |
449 | 460 | case _ => | |
450 | 461 | throw("Match error") | |
451 | 462 | } | |
452 | 463 | ||
453 | 464 | ||
454 | 465 | let pd = throw("Permission denied") | |
455 | 466 | ||
456 | 467 | func mm (i) = match m() { | |
457 | 468 | case pk: ByteVector => | |
458 | 469 | if ((i.callerPublicKey == pk)) | |
459 | 470 | then true | |
460 | 471 | else pd | |
461 | 472 | case _: Unit => | |
462 | 473 | if ((i.caller == this)) | |
463 | 474 | then true | |
464 | 475 | else pd | |
465 | 476 | case _ => | |
466 | 477 | throw("Match error") | |
467 | 478 | } | |
468 | 479 | ||
469 | 480 | ||
470 | 481 | @Callable(i) | |
471 | 482 | func constructor (fc) = { | |
472 | 483 | let c = mm(i) | |
473 | 484 | if ((c == c)) | |
474 | 485 | then [StringEntry(fc(), fc)] | |
475 | 486 | else throw("Strict value is not equal to itself.") | |
476 | 487 | } | |
477 | 488 | ||
478 | 489 | ||
479 | 490 | ||
480 | 491 | @Callable(i) | |
481 | 492 | func setManager (pendingManagerPublicKey) = { | |
482 | 493 | let c = mm(i) | |
483 | 494 | if ((c == c)) | |
484 | 495 | then { | |
485 | 496 | let cm = fromBase58String(pendingManagerPublicKey) | |
486 | 497 | if ((cm == cm)) | |
487 | 498 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
488 | 499 | else throw("Strict value is not equal to itself.") | |
489 | 500 | } | |
490 | 501 | else throw("Strict value is not equal to itself.") | |
491 | 502 | } | |
492 | 503 | ||
493 | 504 | ||
494 | 505 | ||
495 | 506 | @Callable(i) | |
496 | 507 | func confirmManager () = { | |
497 | 508 | let p = pm() | |
498 | 509 | let hpm = if (isDefined(p)) | |
499 | 510 | then true | |
500 | 511 | else throw("No pending manager") | |
501 | 512 | if ((hpm == hpm)) | |
502 | 513 | then { | |
503 | 514 | let cpm = if ((i.callerPublicKey == value(p))) | |
504 | 515 | then true | |
505 | 516 | else throw("You are not pending manager") | |
506 | 517 | if ((cpm == cpm)) | |
507 | 518 | then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())] | |
508 | 519 | else throw("Strict value is not equal to itself.") | |
509 | 520 | } | |
510 | 521 | else throw("Strict value is not equal to itself.") | |
511 | 522 | } | |
512 | 523 | ||
513 | 524 | ||
514 | 525 | ||
515 | 526 | @Callable(i) | |
516 | 527 | func put (slip,autoStake) = { | |
517 | 528 | let factCfg = gfc() | |
518 | 529 | let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr") | |
519 | 530 | let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr") | |
520 | 531 | if ((0 > slip)) | |
521 | 532 | then throw("Wrong slippage") | |
522 | 533 | else if ((size(i.payments) != 2)) | |
523 | 534 | then throw("2 pmnts expd") | |
524 | 535 | else { | |
525 | 536 | 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, 0, "") | |
526 | 537 | let emitLpAmt = e._2 | |
527 | 538 | let lpAssetId = e._7 | |
528 | 539 | let state = e._9 | |
529 | 540 | let amDiff = e._10 | |
530 | 541 | let prDiff = e._11 | |
531 | 542 | let amId = e._12 | |
532 | 543 | let prId = e._13 | |
533 | 544 | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
534 | 545 | if ((r == r)) | |
535 | 546 | then { | |
536 | 547 | let el = match r { | |
537 | 548 | case legacy: Address => | |
538 | 549 | invoke(legacy, "emit", [emitLpAmt], nil) | |
539 | 550 | case _ => | |
540 | 551 | unit | |
541 | 552 | } | |
542 | 553 | if ((el == el)) | |
543 | 554 | then { | |
544 | 555 | let sa = if ((amDiff > 0)) | |
545 | 556 | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
546 | 557 | else nil | |
547 | 558 | if ((sa == sa)) | |
548 | 559 | then { | |
549 | 560 | let sp = if ((prDiff > 0)) | |
550 | 561 | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
551 | 562 | else nil | |
552 | 563 | if ((sp == sp)) | |
553 | 564 | then { | |
554 | 565 | let lpTrnsfr = if (autoStake) | |
555 | 566 | then { | |
556 | 567 | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
557 | 568 | if ((ss == ss)) | |
558 | 569 | then nil | |
559 | 570 | else throw("Strict value is not equal to itself.") | |
560 | 571 | } | |
561 | 572 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
562 | 573 | (state ++ lpTrnsfr) | |
563 | 574 | } | |
564 | 575 | else throw("Strict value is not equal to itself.") | |
565 | 576 | } | |
566 | 577 | else throw("Strict value is not equal to itself.") | |
567 | 578 | } | |
568 | 579 | else throw("Strict value is not equal to itself.") | |
569 | 580 | } | |
570 | 581 | else throw("Strict value is not equal to itself.") | |
571 | 582 | } | |
572 | 583 | } | |
573 | 584 | ||
574 | 585 | ||
575 | 586 | ||
576 | 587 | @Callable(i) | |
577 | 588 | func putOneTkn (amAssetPart,prAssetPart,outLp,slippage,autoStake) = { | |
578 | 589 | let cfg = gfc() | |
579 | 590 | let stakingCntr = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wr st addr") | |
580 | 591 | let slipCntr = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wr sl addr") | |
581 | 592 | let gwxCntr = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wr gwx addr") | |
582 | 593 | let poolCfg = gpc() | |
583 | 594 | let amId = poolCfg[idxAmAsId] | |
584 | 595 | let prId = poolCfg[idxPrAsId] | |
585 | 596 | let amDcm = parseIntValue(poolCfg[idxAmtAsDcm]) | |
586 | 597 | let prDcm = parseIntValue(poolCfg[idxPriceAsDcm]) | |
587 | 598 | let addon = valueOrElse(getString(this, ada()), "") | |
588 | 599 | let userAddress = if ((addon == toString(i.caller))) | |
589 | 600 | then i.originCaller | |
590 | 601 | else i.caller | |
591 | - | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
592 | - | let check = reentrantInvoke(addonContract, "ensureCanPutOneTkn", [toString(userAddress)], nil) | |
593 | - | if ((check == check)) | |
594 | - | then if (if (if (if ((0 >= slippage)) | |
595 | - | then true | |
596 | - | else (0 >= amAssetPart)) | |
597 | - | then true | |
598 | - | else (0 >= prAssetPart)) | |
599 | - | then true | |
600 | - | else (0 >= outLp)) | |
601 | - | then throw("Wrong params") | |
602 | - | else if ((size(i.payments) != 1)) | |
603 | - | then throw("1 pmnt expd") | |
604 | - | else { | |
605 | - | let pmt = value(i.payments[0]) | |
606 | - | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
607 | - | let pmtAmt = pmt.amount | |
608 | - | if ((10000000 > pmtAmt)) | |
609 | - | then throw("Wrong pmt amt") | |
610 | - | else { | |
611 | - | let amBalance = getAccBalance(amId) | |
612 | - | let prBalance = getAccBalance(prId) | |
613 | - | let $t02485925435 = if ((pmtAssetId == amId)) | |
614 | - | then if (if ((pmtAmt > amBalance)) | |
602 | + | if (if (if (if ((0 >= slippage)) | |
603 | + | then true | |
604 | + | else (0 >= amAssetPart)) | |
605 | + | then true | |
606 | + | else (0 >= prAssetPart)) | |
607 | + | then true | |
608 | + | else (0 >= outLp)) | |
609 | + | then throw("Wrong params") | |
610 | + | else if ((size(i.payments) != 1)) | |
611 | + | then throw("1 pmnt expd") | |
612 | + | else { | |
613 | + | let pmt = value(i.payments[0]) | |
614 | + | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
615 | + | let paymentAmountRaw = pmt.amount | |
616 | + | let $t02464424696 = takeFee(paymentAmountRaw) | |
617 | + | let pmtAmt = $t02464424696._1 | |
618 | + | let feeAmount = $t02464424696._2 | |
619 | + | if ((10000000 > paymentAmountRaw)) | |
620 | + | then throw("Wrong pmt amt") | |
621 | + | else { | |
622 | + | let amBalance = getAccBalance(amId) | |
623 | + | let prBalance = getAccBalance(prId) | |
624 | + | let $t02485625472 = if ((pmtAssetId == amId)) | |
625 | + | then if (if ((paymentAmountRaw > amBalance)) | |
626 | + | then true | |
627 | + | else (amAssetPart > pmtAmt)) | |
628 | + | then throw("invalid payment amount") | |
629 | + | else $Tuple6((amBalance - paymentAmountRaw), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
630 | + | else if ((pmtAssetId == prId)) | |
631 | + | then if (if ((paymentAmountRaw > prBalance)) | |
615 | 632 | then true | |
616 | - | else ( | |
633 | + | else (prAssetPart > pmtAmt)) | |
617 | 634 | then throw("invalid payment amount") | |
618 | - | else $Tuple6((amBalance - pmtAmt), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
619 | - | else if ((pmtAssetId == prId)) | |
620 | - | then if (if ((pmtAmt > prBalance)) | |
621 | - | then true | |
622 | - | else (prAssetPart > pmtAmt)) | |
623 | - | then throw("invalid payment amount") | |
624 | - | else $Tuple6(amBalance, (prBalance - pmtAmt), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
625 | - | else throw("wrong pmtAssetId") | |
626 | - | let amBalanceNow = $t02485925435._1 | |
627 | - | let prBalanceNow = $t02485925435._2 | |
628 | - | let virtSwapInAm = $t02485925435._3 | |
629 | - | let virtSwapOutPr = $t02485925435._4 | |
630 | - | let virtSwapInPr = $t02485925435._5 | |
631 | - | let virtSwapOutAm = $t02485925435._6 | |
632 | - | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
633 | - | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
634 | - | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
635 | - | if ((D0vsD1 == D0vsD1)) | |
636 | - | then { | |
637 | - | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId) | |
638 | - | let estimLP = estPut._2 | |
639 | - | let lpAssetId = estPut._7 | |
640 | - | let state = estPut._9 | |
641 | - | let amDiff = estPut._10 | |
642 | - | let prDiff = estPut._11 | |
643 | - | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
644 | - | let emitLpAmt = toInt(lpCalcRes._2) | |
645 | - | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
646 | - | if ((e == e)) | |
647 | - | then { | |
648 | - | let el = match e { | |
649 | - | case legacy: Address => | |
650 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
651 | - | case _ => | |
652 | - | unit | |
653 | - | } | |
654 | - | if ((el == el)) | |
655 | - | then { | |
656 | - | let sa = if ((amDiff > 0)) | |
657 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
658 | - | else nil | |
659 | - | if ((sa == sa)) | |
660 | - | then { | |
661 | - | let sp = if ((prDiff > 0)) | |
662 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
663 | - | else nil | |
664 | - | if ((sp == sp)) | |
665 | - | then { | |
666 | - | let lpTrnsfr = if (autoStake) | |
667 | - | then { | |
668 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
669 | - | if ((ss == ss)) | |
670 | - | then nil | |
671 | - | else throw("Strict value is not equal to itself.") | |
672 | - | } | |
673 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
674 | - | (state ++ lpTrnsfr) | |
675 | - | } | |
676 | - | else throw("Strict value is not equal to itself.") | |
677 | - | } | |
678 | - | else throw("Strict value is not equal to itself.") | |
679 | - | } | |
680 | - | else throw("Strict value is not equal to itself.") | |
681 | - | } | |
682 | - | else throw("Strict value is not equal to itself.") | |
683 | - | } | |
684 | - | else throw("Strict value is not equal to itself.") | |
685 | - | } | |
686 | - | } | |
687 | - | else throw("Strict value is not equal to itself.") | |
688 | - | } | |
689 | - | ||
690 | - | ||
691 | - | ||
692 | - | @Callable(i) | |
693 | - | func putOneTknV2 (outLp,slippage,autoStake) = { | |
694 | - | let cfg = gfc() | |
695 | - | let stakingCntr = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wr st addr") | |
696 | - | let slipCntr = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wr sl addr") | |
697 | - | let gwxCntr = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wr gwx addr") | |
698 | - | let poolCfg = gpc() | |
699 | - | let amId = poolCfg[idxAmAsId] | |
700 | - | let prId = poolCfg[idxPrAsId] | |
701 | - | let amDcm = parseIntValue(poolCfg[idxAmtAsDcm]) | |
702 | - | let prDcm = parseIntValue(poolCfg[idxPriceAsDcm]) | |
703 | - | let addon = valueOrElse(getString(this, ada()), "") | |
704 | - | let userAddress = if ((addon == toString(i.caller))) | |
705 | - | then i.originCaller | |
706 | - | else i.caller | |
707 | - | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
708 | - | if ((size(i.payments) != 1)) | |
709 | - | then throw("1 pmnt expd") | |
710 | - | else { | |
711 | - | let pmt = value(i.payments[0]) | |
712 | - | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
713 | - | let pmtAmt = pmt.amount | |
714 | - | if ((10000000 > pmtAmt)) | |
715 | - | then throw("Wrong pmt amt") | |
716 | - | else { | |
717 | - | let amBalance = getAccBalance(amId) | |
718 | - | let prBalance = getAccBalance(prId) | |
719 | - | let $t02878529173 = if ((pmtAssetId == amId)) | |
720 | - | then if ((pmtAmt > amBalance)) | |
721 | - | then throw("invalid payment amount") | |
722 | - | else $Tuple2((amBalance - pmtAmt), prBalance) | |
723 | - | else if ((pmtAssetId == prId)) | |
724 | - | then if ((pmtAmt > prBalance)) | |
725 | - | then throw("invalid payment amount") | |
726 | - | else $Tuple2(amBalance, (prBalance - pmtAmt)) | |
727 | - | else throw("wrong pmtAssetId") | |
728 | - | let amBalanceNow = $t02878529173._1 | |
729 | - | let prBalanceNow = $t02878529173._2 | |
730 | - | let $t02917929313 = if ((pmtAssetId == amId)) | |
731 | - | then $Tuple2(amBalanceNow, prBalanceNow) | |
732 | - | else $Tuple2(prBalanceNow, amBalanceNow) | |
733 | - | let amBalanceForCalc = $t02917929313._1 | |
734 | - | let prBalanceForCalc = $t02917929313._2 | |
735 | - | let xPrecision = 1 | |
736 | - | let result = { | |
737 | - | let @ = invoke(gwxCntr, "calcPutXOnly", [toString(pmtAmt), toString(amBalanceForCalc), toString(prBalanceForCalc), "", A, Amult, toString(xPrecision), Dconv], nil) | |
738 | - | if ($isInstanceOf(@, "(Int, Int)")) | |
739 | - | then @ | |
740 | - | else throw(($getType(invoke(gwxCntr, "calcPutXOnly", [toString(pmtAmt), toString(amBalanceForCalc), toString(prBalanceForCalc), "", A, Amult, toString(xPrecision), Dconv], nil)) + " couldn't be cast to (Int, Int)")) | |
635 | + | else $Tuple6(amBalance, (prBalance - paymentAmountRaw), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
636 | + | else throw("wrong pmtAssetId") | |
637 | + | let amBalanceNow = $t02485625472._1 | |
638 | + | let prBalanceNow = $t02485625472._2 | |
639 | + | let virtSwapInAm = $t02485625472._3 | |
640 | + | let virtSwapOutPr = $t02485625472._4 | |
641 | + | let virtSwapInPr = $t02485625472._5 | |
642 | + | let virtSwapOutAm = $t02485625472._6 | |
643 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
644 | + | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
645 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
646 | + | if ((D0vsD1 == D0vsD1)) | |
647 | + | then { | |
648 | + | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId) | |
649 | + | let estimLP = estPut._2 | |
650 | + | let lpAssetId = estPut._7 | |
651 | + | let state = estPut._9 | |
652 | + | let amDiff = estPut._10 | |
653 | + | let prDiff = estPut._11 | |
654 | + | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
655 | + | let emitLpAmt = toInt(lpCalcRes._2) | |
656 | + | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
657 | + | if ((e == e)) | |
658 | + | then { | |
659 | + | let el = match e { | |
660 | + | case legacy: Address => | |
661 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
662 | + | case _ => | |
663 | + | unit | |
664 | + | } | |
665 | + | if ((el == el)) | |
666 | + | then { | |
667 | + | let sa = if ((amDiff > 0)) | |
668 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
669 | + | else nil | |
670 | + | if ((sa == sa)) | |
671 | + | then { | |
672 | + | let sp = if ((prDiff > 0)) | |
673 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
674 | + | else nil | |
675 | + | if ((sp == sp)) | |
676 | + | then { | |
677 | + | let lpTrnsfr = if (autoStake) | |
678 | + | then { | |
679 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
680 | + | if ((ss == ss)) | |
681 | + | then nil | |
682 | + | else throw("Strict value is not equal to itself.") | |
683 | + | } | |
684 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
685 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
686 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
687 | + | else nil | |
688 | + | ((state ++ lpTrnsfr) ++ sendFeeToMatcher) | |
689 | + | } | |
690 | + | else throw("Strict value is not equal to itself.") | |
691 | + | } | |
692 | + | else throw("Strict value is not equal to itself.") | |
693 | + | } | |
694 | + | else throw("Strict value is not equal to itself.") | |
695 | + | } | |
696 | + | else throw("Strict value is not equal to itself.") | |
697 | + | } | |
698 | + | else throw("Strict value is not equal to itself.") | |
741 | 699 | } | |
742 | - | let $t02982529921 = if ((pmtAssetId == amId)) | |
743 | - | then result | |
744 | - | else $Tuple2(result._2, result._1) | |
745 | - | let amAssetPart = $t02982529921._1 | |
746 | - | let prAssetPart = $t02982529921._2 | |
747 | - | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId) | |
748 | - | let estimLP = estPut._2 | |
749 | - | let lpAssetId = estPut._7 | |
750 | - | let state = estPut._9 | |
751 | - | let amDiff = estPut._10 | |
752 | - | let prDiff = estPut._11 | |
753 | - | let emitLpAmt = if ((outLp > 0)) | |
754 | - | then { | |
755 | - | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
756 | - | toInt(lpCalcRes._2) | |
757 | - | } | |
758 | - | else estimLP | |
759 | - | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
760 | - | if ((e == e)) | |
761 | - | then { | |
762 | - | let el = match e { | |
763 | - | case legacy: Address => | |
764 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
765 | - | case _ => | |
766 | - | unit | |
767 | - | } | |
768 | - | if ((el == el)) | |
769 | - | then { | |
770 | - | let sa = if ((amDiff > 0)) | |
771 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
772 | - | else nil | |
773 | - | if ((sa == sa)) | |
774 | - | then { | |
775 | - | let sp = if ((prDiff > 0)) | |
776 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
777 | - | else nil | |
778 | - | if ((sp == sp)) | |
779 | - | then { | |
780 | - | let lpTrnsfr = if (autoStake) | |
781 | - | then { | |
782 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
783 | - | if ((ss == ss)) | |
784 | - | then nil | |
785 | - | else throw("Strict value is not equal to itself.") | |
786 | - | } | |
787 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
788 | - | (state ++ lpTrnsfr) | |
789 | - | } | |
790 | - | else throw("Strict value is not equal to itself.") | |
791 | - | } | |
792 | - | else throw("Strict value is not equal to itself.") | |
793 | - | } | |
794 | - | else throw("Strict value is not equal to itself.") | |
795 | - | } | |
796 | - | else throw("Strict value is not equal to itself.") | |
797 | - | } | |
798 | - | } | |
700 | + | } | |
799 | 701 | } | |
800 | 702 | ||
801 | 703 | ||
802 | 704 | ||
803 | 705 | @Callable(i) | |
804 | 706 | func putForFree (maxSlpg) = if ((0 > maxSlpg)) | |
805 | 707 | then throw("Wrong slpg") | |
806 | 708 | else if ((size(i.payments) != 2)) | |
807 | 709 | then throw("2 pmnts expd") | |
808 | 710 | else { | |
809 | 711 | 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, 0, "") | |
810 | 712 | estPut._9 | |
811 | 713 | } | |
812 | 714 | ||
813 | 715 | ||
814 | 716 | ||
815 | 717 | @Callable(i) | |
816 | 718 | func get () = { | |
817 | 719 | let r = cg(i) | |
818 | 720 | let outAmtAmt = r._1 | |
819 | 721 | let outPrAmt = r._2 | |
820 | 722 | let pmtAmt = r._3 | |
821 | 723 | let pmtAssetId = r._4 | |
822 | 724 | let state = r._5 | |
823 | 725 | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
824 | 726 | if ((b == b)) | |
825 | 727 | then state | |
826 | 728 | else throw("Strict value is not equal to itself.") | |
827 | 729 | } | |
828 | 730 | ||
829 | 731 | ||
830 | 732 | ||
831 | 733 | @Callable(i) | |
832 | 734 | func getOneTkn (exchResult,notUsed,outAmount,outAssetId,slippage) = if ((size(i.payments) != 1)) | |
833 | 735 | then throw("1 pmnt expd") | |
834 | 736 | else { | |
835 | 737 | let cfg = gpc() | |
836 | 738 | let lpId = cfg[idxLPAsId] | |
837 | 739 | let amId = cfg[idxAmAsId] | |
838 | 740 | let prId = cfg[idxPrAsId] | |
839 | 741 | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
840 | 742 | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
841 | 743 | let sts = cfg[idxPoolSt] | |
842 | 744 | let factCfg = gfc() | |
843 | 745 | let gwxCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactGwxRewCntr]), "Wr sl addr") | |
844 | 746 | let pmt = value(i.payments[0]) | |
845 | 747 | let addon = valueOrElse(getString(this, ada()), "") | |
846 | 748 | let userAddress = if ((addon == toString(i.caller))) | |
847 | 749 | then i.originCaller | |
848 | 750 | else i.caller | |
849 | 751 | let txId58 = toBase58String(i.transactionId) | |
850 | 752 | let pmtAssetId = value(pmt.assetId) | |
851 | 753 | let pmtAmt = pmt.amount | |
852 | - | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
853 | - | let check = reentrantInvoke(addonContract, "ensureCanGetOneTkn", [toString(userAddress)], nil) | |
854 | - | if ((check == check)) | |
855 | - | then if ((1000000000 > pmtAmt)) | |
856 | - | then throw("Min pmt 10 LP") | |
857 | - | else if (if (if ((0 > slippage)) | |
858 | - | then true | |
859 | - | else (0 > exchResult)) | |
860 | - | then true | |
861 | - | else (0 > outAmount)) | |
862 | - | then throw("Wrong params") | |
863 | - | else if ((lpId != toBase58String(pmtAssetId))) | |
864 | - | then throw("Wrong LP") | |
865 | - | else { | |
866 | - | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
867 | - | let estimAmAmt = r._1 | |
868 | - | let estimPrAmt = r._2 | |
869 | - | let amBalance = getAccBalance(amId) | |
870 | - | let prBalance = getAccBalance(prId) | |
871 | - | let $t03449034947 = if ((outAssetId == amId)) | |
872 | - | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
873 | - | else if ((outAssetId == prId)) | |
874 | - | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
875 | - | else throw("wrong outAssetId") | |
876 | - | let amBalanceNow = $t03449034947._1 | |
877 | - | let prBalanceNow = $t03449034947._2 | |
878 | - | let virtSwapInAm = $t03449034947._3 | |
879 | - | let virtSwapOutPr = $t03449034947._4 | |
880 | - | let virtSwapInPr = $t03449034947._5 | |
881 | - | let virtSwapOutAm = $t03449034947._6 | |
882 | - | let totalGet = $t03449034947._7 | |
883 | - | if (if ((0 > virtSwapInAm)) | |
884 | - | then true | |
885 | - | else (0 > virtSwapInPr)) | |
886 | - | then throw("Wrong calc") | |
887 | - | else { | |
888 | - | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
889 | - | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
890 | - | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
891 | - | if ((D0vsD1 == D0vsD1)) | |
892 | - | then { | |
893 | - | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
894 | - | if ((finalRes == finalRes)) | |
895 | - | then { | |
896 | - | let $t03565235756 = if ((outAssetId == amId)) | |
897 | - | then $Tuple2(toInt(finalRes._2), 0) | |
898 | - | else $Tuple2(0, toInt(finalRes._2)) | |
899 | - | let outAm = $t03565235756._1 | |
900 | - | let outPr = $t03565235756._2 | |
901 | - | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
902 | - | let curPr = f1(curPrX18, scale8) | |
903 | - | let state = [ScriptTransfer(userAddress, (outAm + outPr), if ((outAssetId == "WAVES")) | |
904 | - | then unit | |
905 | - | else fromBase58String(outAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] | |
906 | - | if ((state == state)) | |
907 | - | then { | |
908 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
909 | - | if ((burn == burn)) | |
910 | - | then state | |
911 | - | else throw("Strict value is not equal to itself.") | |
912 | - | } | |
913 | - | else throw("Strict value is not equal to itself.") | |
914 | - | } | |
915 | - | else throw("Strict value is not equal to itself.") | |
916 | - | } | |
917 | - | else throw("Strict value is not equal to itself.") | |
918 | - | } | |
919 | - | } | |
920 | - | else throw("Strict value is not equal to itself.") | |
754 | + | if ((1000000000 > pmtAmt)) | |
755 | + | then throw("Min pmt 10 LP") | |
756 | + | else if (if (if ((0 > slippage)) | |
757 | + | then true | |
758 | + | else (0 > exchResult)) | |
759 | + | then true | |
760 | + | else (0 > outAmount)) | |
761 | + | then throw("Wrong params") | |
762 | + | else if ((lpId != toBase58String(pmtAssetId))) | |
763 | + | then throw("Wrong LP") | |
764 | + | else { | |
765 | + | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
766 | + | let estimAmAmt = r._1 | |
767 | + | let estimPrAmt = r._2 | |
768 | + | let amBalance = getAccBalance(amId) | |
769 | + | let prBalance = getAccBalance(prId) | |
770 | + | let $t03041530875 = if ((outAssetId == amId)) | |
771 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
772 | + | else if ((outAssetId == prId)) | |
773 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
774 | + | else throw("wrong outAssetId") | |
775 | + | let amBalanceNow = $t03041530875._1 | |
776 | + | let prBalanceNow = $t03041530875._2 | |
777 | + | let virtSwapInAm = $t03041530875._3 | |
778 | + | let virtSwapOutPr = $t03041530875._4 | |
779 | + | let virtSwapInPr = $t03041530875._5 | |
780 | + | let virtSwapOutAm = $t03041530875._6 | |
781 | + | let totalGetRaw = $t03041530875._7 | |
782 | + | if (if ((0 > virtSwapInAm)) | |
783 | + | then true | |
784 | + | else (0 > virtSwapInPr)) | |
785 | + | then throw("Wrong calc") | |
786 | + | else { | |
787 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
788 | + | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
789 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
790 | + | if ((D0vsD1 == D0vsD1)) | |
791 | + | then { | |
792 | + | let totalGet = takeFee(totalGetRaw)._1 | |
793 | + | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
794 | + | if ((finalRes == finalRes)) | |
795 | + | then { | |
796 | + | let $t03162231726 = if ((outAssetId == amId)) | |
797 | + | then $Tuple2(toInt(finalRes._2), 0) | |
798 | + | else $Tuple2(0, toInt(finalRes._2)) | |
799 | + | let outAm = $t03162231726._1 | |
800 | + | let outPr = $t03162231726._2 | |
801 | + | let totalAmount = (outAm + outPr) | |
802 | + | let feeAmount = (totalGetRaw - totalGet) | |
803 | + | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
804 | + | then unit | |
805 | + | else fromBase58String(outAssetId) | |
806 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
807 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
808 | + | else nil | |
809 | + | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
810 | + | let curPr = f1(curPrX18, scale8) | |
811 | + | 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)] | |
812 | + | if ((state == state)) | |
813 | + | then { | |
814 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
815 | + | if ((burn == burn)) | |
816 | + | then (state ++ sendFeeToMatcher) | |
817 | + | else throw("Strict value is not equal to itself.") | |
818 | + | } | |
819 | + | else throw("Strict value is not equal to itself.") | |
820 | + | } | |
821 | + | else throw("Strict value is not equal to itself.") | |
822 | + | } | |
823 | + | else throw("Strict value is not equal to itself.") | |
824 | + | } | |
825 | + | } | |
921 | 826 | } | |
922 | 827 | ||
923 | 828 | ||
924 | 829 | ||
925 | 830 | @Callable(i) | |
926 | 831 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
927 | 832 | let r = cg(i) | |
928 | 833 | let outAmAmt = r._1 | |
929 | 834 | let outPrAmt = r._2 | |
930 | 835 | let pmtAmt = r._3 | |
931 | 836 | let pmtAssetId = r._4 | |
932 | 837 | let state = r._5 | |
933 | 838 | if ((noLessThenAmtAsset > outAmAmt)) | |
934 | 839 | then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
935 | 840 | else if ((noLessThenPriceAsset > outPrAmt)) | |
936 | 841 | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
937 | 842 | else { | |
938 | 843 | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
939 | 844 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
940 | 845 | then state | |
941 | 846 | else throw("Strict value is not equal to itself.") | |
942 | 847 | } | |
943 | 848 | } | |
944 | 849 | ||
945 | 850 | ||
946 | 851 | ||
947 | 852 | @Callable(i) | |
948 | 853 | func unstakeAndGet (amount) = { | |
949 | 854 | let checkPayments = if ((size(i.payments) != 0)) | |
950 | 855 | then throw("No pmnts expd") | |
951 | 856 | else true | |
952 | 857 | if ((checkPayments == checkPayments)) | |
953 | 858 | then { | |
954 | 859 | let cfg = gpc() | |
955 | 860 | let factoryCfg = gfc() | |
956 | 861 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
957 | 862 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
958 | 863 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
959 | 864 | if ((unstakeInv == unstakeInv)) | |
960 | 865 | then { | |
961 | 866 | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
962 | 867 | let sts = parseIntValue(r._9) | |
963 | 868 | let state = r._10 | |
964 | 869 | let v = if (if (igs()) | |
965 | 870 | then true | |
966 | 871 | else (sts == PoolShutdown)) | |
967 | 872 | then throw(("Blocked: " + toString(sts))) | |
968 | 873 | else true | |
969 | 874 | if ((v == v)) | |
970 | 875 | then { | |
971 | 876 | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
972 | 877 | if ((burnA == burnA)) | |
973 | 878 | then state | |
974 | 879 | else throw("Strict value is not equal to itself.") | |
975 | 880 | } | |
976 | 881 | else throw("Strict value is not equal to itself.") | |
977 | 882 | } | |
978 | 883 | else throw("Strict value is not equal to itself.") | |
979 | 884 | } | |
980 | 885 | else throw("Strict value is not equal to itself.") | |
981 | 886 | } | |
982 | 887 | ||
983 | 888 | ||
984 | 889 | ||
985 | 890 | @Callable(i) | |
986 | 891 | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca))) | |
987 | 892 | then throw("denied") | |
988 | 893 | else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success") | |
989 | 894 | ||
990 | 895 | ||
991 | 896 | ||
992 | 897 | @Callable(i) | |
993 | 898 | func setS (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
994 | 899 | then pd | |
995 | 900 | else [StringEntry(k, v)] | |
996 | 901 | ||
997 | 902 | ||
998 | 903 | ||
999 | 904 | @Callable(i) | |
1000 | 905 | func setI (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1001 | 906 | then pd | |
1002 | 907 | else [IntegerEntry(k, v)] | |
1003 | 908 | ||
1004 | 909 | ||
1005 | 910 | ||
1006 | 911 | @Callable(i) | |
1007 | 912 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc()) | |
1008 | 913 | ||
1009 | 914 | ||
1010 | 915 | ||
1011 | 916 | @Callable(i) | |
1012 | 917 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1013 | 918 | ||
1014 | 919 | ||
1015 | 920 | ||
1016 | 921 | @Callable(i) | |
1017 | 922 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1018 | 923 | let pr = calcPrices(amAmt, prAmt, lpAmt) | |
1019 | 924 | $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])]) | |
1020 | 925 | } | |
1021 | 926 | ||
1022 | 927 | ||
1023 | 928 | ||
1024 | 929 | @Callable(i) | |
1025 | 930 | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult)) | |
1026 | 931 | ||
1027 | 932 | ||
1028 | 933 | ||
1029 | 934 | @Callable(i) | |
1030 | 935 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult))) | |
1031 | 936 | ||
1032 | 937 | ||
1033 | 938 | ||
1034 | 939 | @Callable(i) | |
1035 | 940 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1036 | 941 | ||
1037 | 942 | ||
1038 | 943 | ||
1039 | 944 | @Callable(i) | |
1040 | 945 | func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, false, 0, "")) | |
1041 | 946 | ||
1042 | 947 | ||
1043 | 948 | ||
1044 | 949 | @Callable(i) | |
1045 | 950 | func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = { | |
1046 | 951 | let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr)) | |
1047 | 952 | $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10)) | |
1048 | 953 | } | |
1049 | 954 | ||
1050 | 955 | ||
1051 | 956 | @Verifier(tx) | |
1052 | 957 | func verify () = { | |
1053 | 958 | let targetPublicKey = match m() { | |
1054 | 959 | case pk: ByteVector => | |
1055 | 960 | pk | |
1056 | 961 | case _: Unit => | |
1057 | 962 | tx.senderPublicKey | |
1058 | 963 | case _ => | |
1059 | 964 | throw("Match error") | |
1060 | 965 | } | |
1061 | 966 | match tx { | |
1062 | 967 | case order: Order => | |
1063 | 968 | let matcherPub = mp() | |
1064 | 969 | let orderValid = moa(order) | |
1065 | 970 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1066 | 971 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1067 | 972 | if (if (if (orderValid) | |
1068 | 973 | then senderValid | |
1069 | 974 | else false) | |
1070 | 975 | then matcherValid | |
1071 | 976 | else false) | |
1072 | 977 | then true | |
1073 | 978 | else toe(orderValid, senderValid, matcherValid) | |
1074 | 979 | case s: SetScriptTransaction => | |
1075 | 980 | let newHash = blake2b256(value(s.script)) | |
1076 | 981 | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
1077 | 982 | let currentHash = scriptHash(this) | |
1078 | 983 | if (if ((allowedHash == newHash)) | |
1079 | 984 | then (currentHash != newHash) | |
1080 | 985 | else false) | |
1081 | 986 | then true | |
1082 | 987 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1083 | 988 | case _ => | |
1084 | 989 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1085 | 990 | } | |
1086 | 991 | } | |
1087 | 992 |
github/deemru/w8io/026f985 110.07 ms ◑