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