tx · 4YUtsyZEmLdsL5pDMSneqduN4oX6954sPMMW9kN4R7sJ 3NCUrmBwKvfQDkfTg1gL8BPKZid8fC4YDx3: -0.03100000 Waves 2022.11.24 17:14 [2331285] smart account 3NCUrmBwKvfQDkfTg1gL8BPKZid8fC4YDx3 > SELF 0.00000000 Waves
{ "type": 13, "id": "4YUtsyZEmLdsL5pDMSneqduN4oX6954sPMMW9kN4R7sJ", "fee": 3100000, "feeAssetId": null, "timestamp": 1669299317042, "version": 1, "sender": "3NCUrmBwKvfQDkfTg1gL8BPKZid8fC4YDx3", "senderPublicKey": "DnbhDz6GvchfLCy83fxyPKD7SoAmXD6DrJ5ubi3LXtgM", "proofs": [ "2T2oLCtKeMCFrKYvkm3gBqPZsqp86kHfqVnfP82NKdRHGpSv4xs5ECBdRkS1M6BWbCpP7ZM3wiBSPHitd6eTkTau" ], "script": "base64:BgLYKQgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlke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yUHVibGljS2V5BAJhegkA9AMDCAUCY1kJYm9keUJ5dGVzCQCRAwIIBQJjWQZwcm9vZnMAAQUCZ2MDAwMFAmF4BQJheQcFAmF6BwYJAQJhdwMFAmF4BQJheQUCYXoDCQABAgUCYUkCFFNldFNjcmlwdFRyYW5zYWN0aW9uBAJlSgUCYUkEAmdkCQD2AwEJAQV2YWx1ZQEIBQJlSgZzY3JpcHQEAmdlCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYUsJAQJhdQAEAmdmCQDxBwEFBHRoaXMDAwkAAAIFAmdlBQJnZAkBAiE9AgUCZ2YFAmdkBwYJAPQDAwgFAmZaCWJvZHlCeXRlcwkAkQMCCAUCZloGcHJvb2ZzAAAFAmdiCQD0AwMIBQJmWglib2R5Qnl0ZXMJAJEDAggFAmZaBnByb29mcwAABQJnYl7L510=", "chainId": 84, "height": 2331285, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 82iXsfDj2sztG87bzuy3eCDqw2vDeMJczPBP3kYHE8ZC Next: GFvYDswMhGbdXVkvKu28YefYuHJvjDXgNhfeFzbj8Njp Diff:
Old | New | Differences | |
---|---|---|---|
111 | 111 | ||
112 | 112 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
113 | 113 | ||
114 | + | let keyKLp = makeString(["%s", "keyKlp"], SEP) | |
115 | + | ||
116 | + | let keyLastKLpRefreshed = makeString(["%s", "keyLastKLpRefreshed"], SEP) | |
117 | + | ||
118 | + | let keyRefreshKLpDelay = makeString(["%s", "keyRefreshKLpDelay"], SEP) | |
119 | + | ||
114 | 120 | func keyFactoryConfig () = "%s__factoryConfig" | |
115 | 121 | ||
116 | 122 | ||
149 | 155 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
150 | 156 | ||
151 | 157 | ||
158 | + | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
159 | + | ||
160 | + | ||
161 | + | func asInt (val) = match val { | |
162 | + | case valInt: Int => | |
163 | + | valInt | |
164 | + | case _ => | |
165 | + | throw("fail to cast into Int") | |
166 | + | } | |
167 | + | ||
168 | + | ||
152 | 169 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
153 | 170 | ||
154 | 171 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
183 | 200 | ||
184 | 201 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
185 | 202 | ||
186 | - | let $ | |
203 | + | let $t079168082 = poolConfigParsed | |
187 | 204 | ||
188 | - | let cfgPoolAddress = $ | |
205 | + | let cfgPoolAddress = $t079168082._1 | |
189 | 206 | ||
190 | - | let cfgPoolStatus = $ | |
207 | + | let cfgPoolStatus = $t079168082._2 | |
191 | 208 | ||
192 | - | let cfgLpAssetId = $ | |
209 | + | let cfgLpAssetId = $t079168082._3 | |
193 | 210 | ||
194 | - | let cfgAmountAssetId = $ | |
211 | + | let cfgAmountAssetId = $t079168082._4 | |
195 | 212 | ||
196 | - | let cfgPriceAssetId = $ | |
213 | + | let cfgPriceAssetId = $t079168082._5 | |
197 | 214 | ||
198 | - | let cfgAmountAssetDecimals = $ | |
215 | + | let cfgAmountAssetDecimals = $t079168082._6 | |
199 | 216 | ||
200 | - | let cfgPriceAssetDecimals = $ | |
217 | + | let cfgPriceAssetDecimals = $t079168082._7 | |
201 | 218 | ||
202 | 219 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
203 | 220 | ||
474 | 491 | else if ((paymentAssetId == cfgPriceAssetId)) | |
475 | 492 | then false | |
476 | 493 | else throwErr("invalid asset") | |
477 | - | let $ | |
494 | + | let $t02294323236 = if (isEval) | |
478 | 495 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
479 | 496 | else if (paymentInAmountAsset) | |
480 | 497 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
481 | 498 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
482 | - | let amountBalanceOld = $ | |
483 | - | let priceBalanceOld = $ | |
484 | - | let $ | |
499 | + | let amountBalanceOld = $t02294323236._1 | |
500 | + | let priceBalanceOld = $t02294323236._2 | |
501 | + | let $t02324023389 = if (paymentInAmountAsset) | |
485 | 502 | then $Tuple2(paymentAmountRaw, 0) | |
486 | 503 | else $Tuple2(0, paymentAmountRaw) | |
487 | - | let amountAssetAmountRaw = $ | |
488 | - | let priceAssetAmountRaw = $ | |
504 | + | let amountAssetAmountRaw = $t02324023389._1 | |
505 | + | let priceAssetAmountRaw = $t02324023389._2 | |
489 | 506 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
490 | 507 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
491 | - | let $ | |
492 | - | let paymentAmount = $ | |
493 | - | let feeAmount = $ | |
508 | + | let $t02351123570 = takeFee(paymentAmountRaw) | |
509 | + | let paymentAmount = $t02351123570._1 | |
510 | + | let feeAmount = $t02351123570._2 | |
494 | 511 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
495 | 512 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
496 | 513 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
513 | 530 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
514 | 531 | let priceOld = fromX18(priceOldX18, scale8) | |
515 | 532 | let loss = { | |
516 | - | let $ | |
533 | + | let $t02504725214 = if (paymentInAmountAsset) | |
517 | 534 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
518 | 535 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
519 | - | let amount = $ | |
520 | - | let balance = $ | |
536 | + | let amount = $t02504725214._1 | |
537 | + | let balance = $t02504725214._2 | |
521 | 538 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
522 | 539 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
523 | 540 | } | |
551 | 568 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
552 | 569 | let redeemedBigInt = toBigInt(paymentAmount) | |
553 | 570 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
554 | - | let $ | |
555 | - | let totalAmount = $ | |
556 | - | let feeAmount = $ | |
557 | - | let $ | |
571 | + | let $t02679426844 = takeFee(amountRaw) | |
572 | + | let totalAmount = $t02679426844._1 | |
573 | + | let feeAmount = $t02679426844._2 | |
574 | + | let $t02684827074 = if (outInAmountAsset) | |
558 | 575 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
559 | 576 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
560 | - | let outAmAmount = $ | |
561 | - | let outPrAmount = $ | |
562 | - | let amBalanceNew = $ | |
563 | - | let prBalanceNew = $ | |
577 | + | let outAmAmount = $t02684827074._1 | |
578 | + | let outPrAmount = $t02684827074._2 | |
579 | + | let amBalanceNew = $t02684827074._3 | |
580 | + | let prBalanceNew = $t02684827074._4 | |
564 | 581 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
565 | 582 | let priceNew = fromX18(priceNewX18, scale8) | |
566 | 583 | let commonState = if (isEval) | |
575 | 592 | $Tuple4(totalAmount, commonState, feeAmount, loss) | |
576 | 593 | } | |
577 | 594 | else throw("Strict value is not equal to itself.") | |
595 | + | } | |
596 | + | ||
597 | + | ||
598 | + | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
599 | + | let updatedKLp = (pow((amountBalance * priceBalance), 0, 5, 1, 0, DOWN) / lpEmission) | |
600 | + | updatedKLp | |
601 | + | } | |
602 | + | ||
603 | + | ||
604 | + | func refreshKLpInternal () = { | |
605 | + | let cfg = getPoolConfig() | |
606 | + | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
607 | + | let amountAssetId = cfg[idxAmtAssetId] | |
608 | + | let priceAssetId = cfg[idxPriceAssetId] | |
609 | + | let amountAssetBalance = getAccBalance(amountAssetId) | |
610 | + | let priceAssetBalance = getAccBalance(priceAssetId) | |
611 | + | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
612 | + | let updatedKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpEmission) | |
613 | + | updatedKLp | |
578 | 614 | } | |
579 | 615 | ||
580 | 616 | ||
753 | 789 | let paymentAmountRaw = payment.amount | |
754 | 790 | let userAddress = i.caller | |
755 | 791 | let txId = i.transactionId | |
756 | - | let $t03160931739 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
757 | - | if (($t03160931739 == $t03160931739)) | |
792 | + | let $t03269232819 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
793 | + | let emitAmountEstimated = $t03269232819._1 | |
794 | + | let commonState = $t03269232819._2 | |
795 | + | let feeAmount = $t03269232819._3 | |
796 | + | let bonus = $t03269232819._4 | |
797 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
798 | + | then (minOutAmount > emitAmountEstimated) | |
799 | + | else false) | |
800 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
801 | + | else emitAmountEstimated | |
802 | + | let emitInv = emit(emitAmount) | |
803 | + | if ((emitInv == emitInv)) | |
758 | 804 | then { | |
759 | - | let bonus = $t03160931739._4 | |
760 | - | let feeAmount = $t03160931739._3 | |
761 | - | let commonState = $t03160931739._2 | |
762 | - | let emitAmountEstimated = $t03160931739._1 | |
763 | - | let emitAmount = if (if ((minOutAmount > 0)) | |
764 | - | then (minOutAmount > emitAmountEstimated) | |
765 | - | else false) | |
766 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
767 | - | else emitAmountEstimated | |
768 | - | let emitInv = emit(emitAmount) | |
769 | - | if ((emitInv == emitInv)) | |
805 | + | let lpTransfer = if (autoStake) | |
770 | 806 | then { | |
771 | - | let lpTransfer = if (autoStake) | |
772 | - | then { | |
773 | - | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
774 | - | if ((stakeInv == stakeInv)) | |
775 | - | then nil | |
776 | - | else throw("Strict value is not equal to itself.") | |
777 | - | } | |
778 | - | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
779 | - | let sendFee = if ((feeAmount > 0)) | |
780 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
781 | - | else nil | |
782 | - | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
807 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
808 | + | if ((stakeInv == stakeInv)) | |
809 | + | then nil | |
810 | + | else throw("Strict value is not equal to itself.") | |
783 | 811 | } | |
784 | - | else throw("Strict value is not equal to itself.") | |
812 | + | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
813 | + | let sendFee = if ((feeAmount > 0)) | |
814 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
815 | + | else nil | |
816 | + | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
785 | 817 | } | |
786 | 818 | else throw("Strict value is not equal to itself.") | |
787 | 819 | } | |
792 | 824 | ||
793 | 825 | @Callable(i) | |
794 | 826 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
795 | - | let $ | |
796 | - | let emitAmountEstimated = $ | |
797 | - | let commonState = $ | |
798 | - | let feeAmount = $ | |
799 | - | let bonus = $ | |
827 | + | let $t03354833683 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
828 | + | let emitAmountEstimated = $t03354833683._1 | |
829 | + | let commonState = $t03354833683._2 | |
830 | + | let feeAmount = $t03354833683._3 | |
831 | + | let bonus = $t03354833683._4 | |
800 | 832 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
801 | 833 | } | |
802 | 834 | ||
830 | 862 | let paymentAmount = payment.amount | |
831 | 863 | let userAddress = i.caller | |
832 | 864 | let txId = i.transactionId | |
833 | - | let $t03340833543 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
834 | - | if (($t03340833543 == $t03340833543)) | |
865 | + | let $t03448834620 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
866 | + | let amountEstimated = $t03448834620._1 | |
867 | + | let commonState = $t03448834620._2 | |
868 | + | let feeAmount = $t03448834620._3 | |
869 | + | let bonus = $t03448834620._4 | |
870 | + | let amount = if (if ((minOutAmount > 0)) | |
871 | + | then (minOutAmount > amountEstimated) | |
872 | + | else false) | |
873 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
874 | + | else amountEstimated | |
875 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
876 | + | if ((burnInv == burnInv)) | |
835 | 877 | then { | |
836 | - | let bonus = $t03340833543._4 | |
837 | - | let feeAmount = $t03340833543._3 | |
838 | - | let commonState = $t03340833543._2 | |
839 | - | let amountEstimated = $t03340833543._1 | |
840 | - | let amount = if (if ((minOutAmount > 0)) | |
841 | - | then (minOutAmount > amountEstimated) | |
842 | - | else false) | |
843 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
844 | - | else amountEstimated | |
845 | - | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
846 | - | if ((burnInv == burnInv)) | |
847 | - | then { | |
848 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
849 | - | let sendFee = if ((feeAmount > 0)) | |
850 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
851 | - | else nil | |
852 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
853 | - | } | |
854 | - | else throw("Strict value is not equal to itself.") | |
878 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
879 | + | let sendFee = if ((feeAmount > 0)) | |
880 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
881 | + | else nil | |
882 | + | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
855 | 883 | } | |
856 | 884 | else throw("Strict value is not equal to itself.") | |
857 | 885 | } | |
862 | 890 | ||
863 | 891 | @Callable(i) | |
864 | 892 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
865 | - | let $ | |
866 | - | let amountEstimated = $ | |
867 | - | let commonState = $ | |
868 | - | let feeAmount = $ | |
869 | - | let bonus = $ | |
893 | + | let $t03525535393 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
894 | + | let amountEstimated = $t03525535393._1 | |
895 | + | let commonState = $t03525535393._2 | |
896 | + | let feeAmount = $t03525535393._3 | |
897 | + | let bonus = $t03525535393._4 | |
870 | 898 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
871 | 899 | } | |
872 | 900 | ||
900 | 928 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
901 | 929 | if ((unstakeInv == unstakeInv)) | |
902 | 930 | then { | |
903 | - | let $t03514135274 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
904 | - | if (($t03514135274 == $t03514135274)) | |
931 | + | let $t03621836348 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
932 | + | let amountEstimated = $t03621836348._1 | |
933 | + | let commonState = $t03621836348._2 | |
934 | + | let feeAmount = $t03621836348._3 | |
935 | + | let bonus = $t03621836348._4 | |
936 | + | let amount = if (if ((minOutAmount > 0)) | |
937 | + | then (minOutAmount > amountEstimated) | |
938 | + | else false) | |
939 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
940 | + | else amountEstimated | |
941 | + | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
942 | + | if ((burnInv == burnInv)) | |
905 | 943 | then { | |
906 | - | let bonus = $t03514135274._4 | |
907 | - | let feeAmount = $t03514135274._3 | |
908 | - | let commonState = $t03514135274._2 | |
909 | - | let amountEstimated = $t03514135274._1 | |
910 | - | let amount = if (if ((minOutAmount > 0)) | |
911 | - | then (minOutAmount > amountEstimated) | |
912 | - | else false) | |
913 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
914 | - | else amountEstimated | |
915 | - | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
916 | - | if ((burnInv == burnInv)) | |
917 | - | then { | |
918 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
919 | - | let sendFee = if ((feeAmount > 0)) | |
920 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
921 | - | else nil | |
922 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
923 | - | } | |
924 | - | else throw("Strict value is not equal to itself.") | |
944 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
945 | + | let sendFee = if ((feeAmount > 0)) | |
946 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
947 | + | else nil | |
948 | + | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
925 | 949 | } | |
926 | 950 | else throw("Strict value is not equal to itself.") | |
927 | 951 | } | |
1050 | 1074 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1051 | 1075 | then throw("permissions denied") | |
1052 | 1076 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1077 | + | ||
1078 | + | ||
1079 | + | ||
1080 | + | @Callable(i) | |
1081 | + | func refreshKLp () = { | |
1082 | + | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyLastKLpRefreshed), 0) | |
1083 | + | let delayNotReachedErrorMessage = throwErr(makeString([value(getString(keyRefreshKLpDelay)), "blocks have not passed since the previous call"], " ")) | |
1084 | + | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= 30)) | |
1085 | + | then true | |
1086 | + | else delayNotReachedErrorMessage | |
1087 | + | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1088 | + | then { | |
1089 | + | let updatedKLp = asInt(refreshKLpInternal()) | |
1090 | + | [IntegerEntry(keyLastKLpRefreshed, height), IntegerEntry(keyKLp, updatedKLp)] | |
1091 | + | } | |
1092 | + | else throw("Strict value is not equal to itself.") | |
1093 | + | } | |
1053 | 1094 | ||
1054 | 1095 | ||
1055 | 1096 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lPdecimals = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale8BigInt = toBigInt(100000000) | |
9 | 9 | ||
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big0 = toBigInt(0) | |
15 | 15 | ||
16 | 16 | let big1 = toBigInt(1) | |
17 | 17 | ||
18 | 18 | let big2 = toBigInt(2) | |
19 | 19 | ||
20 | 20 | let wavesString = "WAVES" | |
21 | 21 | ||
22 | 22 | let SEP = "__" | |
23 | 23 | ||
24 | 24 | let PoolActive = 1 | |
25 | 25 | ||
26 | 26 | let PoolPutDisabled = 2 | |
27 | 27 | ||
28 | 28 | let PoolMatcherDisabled = 3 | |
29 | 29 | ||
30 | 30 | let PoolShutdown = 4 | |
31 | 31 | ||
32 | 32 | let idxPoolAddress = 1 | |
33 | 33 | ||
34 | 34 | let idxPoolStatus = 2 | |
35 | 35 | ||
36 | 36 | let idxPoolLPAssetId = 3 | |
37 | 37 | ||
38 | 38 | let idxAmtAssetId = 4 | |
39 | 39 | ||
40 | 40 | let idxPriceAssetId = 5 | |
41 | 41 | ||
42 | 42 | let idxAmtAssetDcm = 6 | |
43 | 43 | ||
44 | 44 | let idxPriceAssetDcm = 7 | |
45 | 45 | ||
46 | 46 | let idxIAmtAssetId = 8 | |
47 | 47 | ||
48 | 48 | let idxIPriceAssetId = 9 | |
49 | 49 | ||
50 | 50 | let idxLPAssetDcm = 10 | |
51 | 51 | ||
52 | 52 | let idxPoolAmtAssetAmt = 1 | |
53 | 53 | ||
54 | 54 | let idxPoolPriceAssetAmt = 2 | |
55 | 55 | ||
56 | 56 | let idxPoolLPAssetAmt = 3 | |
57 | 57 | ||
58 | 58 | let idxFactoryStakingContract = 1 | |
59 | 59 | ||
60 | 60 | let idxFactorySlippageContract = 7 | |
61 | 61 | ||
62 | 62 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func abs (val) = if ((0 > val)) | |
72 | 72 | then -(val) | |
73 | 73 | else val | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func absBigInt (val) = if ((zeroBigInt > val)) | |
77 | 77 | then -(val) | |
78 | 78 | else val | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func fc () = "%s__factoryContract" | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func mpk () = "%s__managerPublicKey" | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func pmpk () = "%s__pendingManagerPublicKey" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func pl () = "%s%s__price__last" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func aa () = "%s__amountAsset" | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pa () = "%s__priceAsset" | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | let keyFee = "%s__fee" | |
109 | 109 | ||
110 | 110 | let feeDefault = fraction(10, scale8, 10000) | |
111 | 111 | ||
112 | 112 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
113 | 113 | ||
114 | + | let keyKLp = makeString(["%s", "keyKlp"], SEP) | |
115 | + | ||
116 | + | let keyLastKLpRefreshed = makeString(["%s", "keyLastKLpRefreshed"], SEP) | |
117 | + | ||
118 | + | let keyRefreshKLpDelay = makeString(["%s", "keyRefreshKLpDelay"], SEP) | |
119 | + | ||
114 | 120 | func keyFactoryConfig () = "%s__factoryConfig" | |
115 | 121 | ||
116 | 122 | ||
117 | 123 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
118 | 124 | ||
119 | 125 | ||
120 | 126 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
121 | 127 | ||
122 | 128 | ||
123 | 129 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
124 | 130 | ||
125 | 131 | ||
126 | 132 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
127 | 133 | ||
128 | 134 | ||
129 | 135 | func keyAllPoolsShutdown () = "%s__shutdown" | |
130 | 136 | ||
131 | 137 | ||
132 | 138 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
133 | 139 | ||
134 | 140 | ||
135 | 141 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
136 | 142 | ||
137 | 143 | ||
138 | 144 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
139 | 145 | ||
140 | 146 | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
141 | 147 | ||
142 | 148 | ||
143 | 149 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
144 | 150 | ||
145 | 151 | ||
146 | 152 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
147 | 153 | ||
148 | 154 | ||
149 | 155 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
150 | 156 | ||
151 | 157 | ||
158 | + | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
159 | + | ||
160 | + | ||
161 | + | func asInt (val) = match val { | |
162 | + | case valInt: Int => | |
163 | + | valInt | |
164 | + | case _ => | |
165 | + | throw("fail to cast into Int") | |
166 | + | } | |
167 | + | ||
168 | + | ||
152 | 169 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
153 | 170 | ||
154 | 171 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
155 | 172 | ||
156 | 173 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
157 | 174 | ||
158 | 175 | ||
159 | 176 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
160 | 177 | ||
161 | 178 | ||
162 | 179 | func getPoolConfig () = { | |
163 | 180 | let amtAsset = getStringOrFail(this, aa()) | |
164 | 181 | let priceAsset = getStringOrFail(this, pa()) | |
165 | 182 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
166 | 183 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
167 | 184 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
168 | 185 | } | |
169 | 186 | ||
170 | 187 | ||
171 | 188 | func parseAssetId (input) = if ((input == wavesString)) | |
172 | 189 | then unit | |
173 | 190 | else fromBase58String(input) | |
174 | 191 | ||
175 | 192 | ||
176 | 193 | func assetIdToString (input) = if ((input == unit)) | |
177 | 194 | then wavesString | |
178 | 195 | else toBase58String(value(input)) | |
179 | 196 | ||
180 | 197 | ||
181 | 198 | func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolStatus]), fromBase58String(poolConfig[idxPoolLPAssetId]), parseAssetId(poolConfig[idxAmtAssetId]), parseAssetId(poolConfig[idxPriceAssetId]), parseIntValue(poolConfig[idxAmtAssetDcm]), parseIntValue(poolConfig[idxPriceAssetDcm])) | |
182 | 199 | ||
183 | 200 | ||
184 | 201 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
185 | 202 | ||
186 | - | let $ | |
203 | + | let $t079168082 = poolConfigParsed | |
187 | 204 | ||
188 | - | let cfgPoolAddress = $ | |
205 | + | let cfgPoolAddress = $t079168082._1 | |
189 | 206 | ||
190 | - | let cfgPoolStatus = $ | |
207 | + | let cfgPoolStatus = $t079168082._2 | |
191 | 208 | ||
192 | - | let cfgLpAssetId = $ | |
209 | + | let cfgLpAssetId = $t079168082._3 | |
193 | 210 | ||
194 | - | let cfgAmountAssetId = $ | |
211 | + | let cfgAmountAssetId = $t079168082._4 | |
195 | 212 | ||
196 | - | let cfgPriceAssetId = $ | |
213 | + | let cfgPriceAssetId = $t079168082._5 | |
197 | 214 | ||
198 | - | let cfgAmountAssetDecimals = $ | |
215 | + | let cfgAmountAssetDecimals = $t079168082._6 | |
199 | 216 | ||
200 | - | let cfgPriceAssetDecimals = $ | |
217 | + | let cfgPriceAssetDecimals = $t079168082._7 | |
201 | 218 | ||
202 | 219 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
203 | 220 | ||
204 | 221 | ||
205 | 222 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
206 | 223 | ||
207 | 224 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
208 | 225 | ||
209 | 226 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP) | |
210 | 227 | ||
211 | 228 | ||
212 | 229 | 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) | |
213 | 230 | ||
214 | 231 | ||
215 | 232 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
216 | 233 | then wavesBalance(this).available | |
217 | 234 | else assetBalance(this, fromBase58String(assetId)) | |
218 | 235 | ||
219 | 236 | ||
220 | 237 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
221 | 238 | ||
222 | 239 | ||
223 | 240 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
224 | 241 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
225 | 242 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
226 | 243 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
227 | 244 | } | |
228 | 245 | ||
229 | 246 | ||
230 | 247 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
231 | 248 | let cfg = getPoolConfig() | |
232 | 249 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
233 | 250 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
234 | 251 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
235 | 252 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
236 | 253 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
237 | 254 | let lpAmtX18 = toX18(lpAmt, scale8) | |
238 | 255 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
239 | 256 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
240 | 257 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
241 | 258 | } | |
242 | 259 | ||
243 | 260 | ||
244 | 261 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
245 | 262 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
246 | 263 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
247 | 264 | } | |
248 | 265 | ||
249 | 266 | ||
250 | 267 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
251 | 268 | let cfg = getPoolConfig() | |
252 | 269 | let lpAssetId = cfg[idxPoolLPAssetId] | |
253 | 270 | let amAssetId = cfg[idxAmtAssetId] | |
254 | 271 | let prAssetId = cfg[idxPriceAssetId] | |
255 | 272 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
256 | 273 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
257 | 274 | let poolStatus = cfg[idxPoolStatus] | |
258 | 275 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
259 | 276 | if ((lpAssetId != pmtAssetId)) | |
260 | 277 | then throw("Invalid asset passed.") | |
261 | 278 | else { | |
262 | 279 | let amBalance = getAccBalance(amAssetId) | |
263 | 280 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
264 | 281 | let prBalance = getAccBalance(prAssetId) | |
265 | 282 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
266 | 283 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
267 | 284 | let curPrice = fromX18(curPriceX18, scale8) | |
268 | 285 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
269 | 286 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
270 | 287 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
271 | 288 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
272 | 289 | let outAmAmt = fromX18(outAmAmtX18, amAssetDcm) | |
273 | 290 | let outPrAmt = fromX18(outPrAmtX18, prAssetDcm) | |
274 | 291 | let state = if ((txId58 == "")) | |
275 | 292 | then nil | |
276 | 293 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
277 | 294 | then unit | |
278 | 295 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
279 | 296 | then unit | |
280 | 297 | else fromBase58String(prAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
281 | 298 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
282 | 299 | } | |
283 | 300 | } | |
284 | 301 | ||
285 | 302 | ||
286 | 303 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
287 | 304 | let cfg = getPoolConfig() | |
288 | 305 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
289 | 306 | let amAssetIdStr = cfg[idxAmtAssetId] | |
290 | 307 | let prAssetIdStr = cfg[idxPriceAssetId] | |
291 | 308 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
292 | 309 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
293 | 310 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
294 | 311 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
295 | 312 | let poolStatus = cfg[idxPoolStatus] | |
296 | 313 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
297 | 314 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
298 | 315 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
299 | 316 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
300 | 317 | then true | |
301 | 318 | else (prAssetIdStr != inPrAssetIdStr)) | |
302 | 319 | then throw("Invalid amt or price asset passed.") | |
303 | 320 | else { | |
304 | 321 | let amBalance = if (isEvaluate) | |
305 | 322 | then getAccBalance(amAssetIdStr) | |
306 | 323 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
307 | 324 | let prBalance = if (isEvaluate) | |
308 | 325 | then getAccBalance(prAssetIdStr) | |
309 | 326 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
310 | 327 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
311 | 328 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
312 | 329 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
313 | 330 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
314 | 331 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
315 | 332 | let res = if ((lpEmission == 0)) | |
316 | 333 | then { | |
317 | 334 | let curPriceX18 = zeroBigInt | |
318 | 335 | let slippageX18 = zeroBigInt | |
319 | 336 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
320 | 337 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
321 | 338 | } | |
322 | 339 | else { | |
323 | 340 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
324 | 341 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
325 | 342 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
326 | 343 | if (if ((curPriceX18 != zeroBigInt)) | |
327 | 344 | then (slippageX18 > slippageToleranceX18) | |
328 | 345 | else false) | |
329 | 346 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
330 | 347 | else { | |
331 | 348 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
332 | 349 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
333 | 350 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
334 | 351 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
335 | 352 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
336 | 353 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
337 | 354 | let expAmtAssetAmtX18 = expectedAmts._1 | |
338 | 355 | let expPriceAssetAmtX18 = expectedAmts._2 | |
339 | 356 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
340 | 357 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18) | |
341 | 358 | } | |
342 | 359 | } | |
343 | 360 | let calcLpAmt = res._1 | |
344 | 361 | let calcAmAssetPmt = res._2 | |
345 | 362 | let calcPrAssetPmt = res._3 | |
346 | 363 | let curPrice = fromX18(res._4, scale8) | |
347 | 364 | let slippageCalc = fromX18(res._5, scale8) | |
348 | 365 | if ((0 >= calcLpAmt)) | |
349 | 366 | then throw("Invalid calculations. LP calculated is less than zero.") | |
350 | 367 | else { | |
351 | 368 | let emitLpAmt = if (!(emitLp)) | |
352 | 369 | then 0 | |
353 | 370 | else calcLpAmt | |
354 | 371 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
355 | 372 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
356 | 373 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(calcAmAssetPmt, calcPrAssetPmt, emitLpAmt, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
357 | 374 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
358 | 375 | } | |
359 | 376 | } | |
360 | 377 | } | |
361 | 378 | ||
362 | 379 | ||
363 | 380 | func validateMatcherOrderAllowed (order) = { | |
364 | 381 | let cfg = getPoolConfig() | |
365 | 382 | let amtAssetId = cfg[idxAmtAssetId] | |
366 | 383 | let priceAssetId = cfg[idxPriceAssetId] | |
367 | 384 | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
368 | 385 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
369 | 386 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
370 | 387 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
371 | 388 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
372 | 389 | let curPriceX18 = if ((order.orderType == Buy)) | |
373 | 390 | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
374 | 391 | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
375 | 392 | let curPrice = fromX18(curPriceX18, scale8) | |
376 | 393 | if (if (if (isGlobalShutdown()) | |
377 | 394 | then true | |
378 | 395 | else (poolStatus == PoolMatcherDisabled)) | |
379 | 396 | then true | |
380 | 397 | else (poolStatus == PoolShutdown)) | |
381 | 398 | then throw("Exchange operations disabled") | |
382 | 399 | else { | |
383 | 400 | let orderAmtAsset = order.assetPair.amountAsset | |
384 | 401 | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
385 | 402 | then "WAVES" | |
386 | 403 | else toBase58String(value(orderAmtAsset)) | |
387 | 404 | let orderPriceAsset = order.assetPair.priceAsset | |
388 | 405 | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
389 | 406 | then "WAVES" | |
390 | 407 | else toBase58String(value(orderPriceAsset)) | |
391 | 408 | if (if ((orderAmtAssetStr != amtAssetId)) | |
392 | 409 | then true | |
393 | 410 | else (orderPriceAssetStr != priceAssetId)) | |
394 | 411 | then throw("Wrong order assets.") | |
395 | 412 | else { | |
396 | 413 | let orderPrice = order.price | |
397 | 414 | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
398 | 415 | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
399 | 416 | let isOrderPriceValid = if ((order.orderType == Buy)) | |
400 | 417 | then (curPrice >= castedOrderPrice) | |
401 | 418 | else (castedOrderPrice >= curPrice) | |
402 | 419 | true | |
403 | 420 | } | |
404 | 421 | } | |
405 | 422 | } | |
406 | 423 | ||
407 | 424 | ||
408 | 425 | func commonGet (i) = if ((size(i.payments) != 1)) | |
409 | 426 | then throw("exactly 1 payment is expected") | |
410 | 427 | else { | |
411 | 428 | let pmt = value(i.payments[0]) | |
412 | 429 | let pmtAssetId = value(pmt.assetId) | |
413 | 430 | let pmtAmt = pmt.amount | |
414 | 431 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
415 | 432 | let outAmAmt = res._1 | |
416 | 433 | let outPrAmt = res._2 | |
417 | 434 | let poolStatus = parseIntValue(res._9) | |
418 | 435 | let state = res._10 | |
419 | 436 | if (if (isGlobalShutdown()) | |
420 | 437 | then true | |
421 | 438 | else (poolStatus == PoolShutdown)) | |
422 | 439 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
423 | 440 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
424 | 441 | } | |
425 | 442 | ||
426 | 443 | ||
427 | 444 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
428 | 445 | then throw("exactly 2 payments are expected") | |
429 | 446 | else { | |
430 | 447 | let amAssetPmt = value(i.payments[0]) | |
431 | 448 | let prAssetPmt = value(i.payments[1]) | |
432 | 449 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
433 | 450 | let poolStatus = parseIntValue(estPut._8) | |
434 | 451 | if (if (if (isGlobalShutdown()) | |
435 | 452 | then true | |
436 | 453 | else (poolStatus == PoolPutDisabled)) | |
437 | 454 | then true | |
438 | 455 | else (poolStatus == PoolShutdown)) | |
439 | 456 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
440 | 457 | else estPut | |
441 | 458 | } | |
442 | 459 | ||
443 | 460 | ||
444 | 461 | func emit (amount) = { | |
445 | 462 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
446 | 463 | if ((emitInv == emitInv)) | |
447 | 464 | then { | |
448 | 465 | let emitInvLegacy = match emitInv { | |
449 | 466 | case legacyFactoryContract: Address => | |
450 | 467 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
451 | 468 | case _ => | |
452 | 469 | unit | |
453 | 470 | } | |
454 | 471 | if ((emitInvLegacy == emitInvLegacy)) | |
455 | 472 | then amount | |
456 | 473 | else throw("Strict value is not equal to itself.") | |
457 | 474 | } | |
458 | 475 | else throw("Strict value is not equal to itself.") | |
459 | 476 | } | |
460 | 477 | ||
461 | 478 | ||
462 | 479 | func takeFee (amount) = { | |
463 | 480 | let feeAmount = fraction(amount, fee, scale8) | |
464 | 481 | $Tuple2((amount - feeAmount), feeAmount) | |
465 | 482 | } | |
466 | 483 | ||
467 | 484 | ||
468 | 485 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
469 | 486 | let isEval = (txId == unit) | |
470 | 487 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
471 | 488 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
472 | 489 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
473 | 490 | then true | |
474 | 491 | else if ((paymentAssetId == cfgPriceAssetId)) | |
475 | 492 | then false | |
476 | 493 | else throwErr("invalid asset") | |
477 | - | let $ | |
494 | + | let $t02294323236 = if (isEval) | |
478 | 495 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
479 | 496 | else if (paymentInAmountAsset) | |
480 | 497 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
481 | 498 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
482 | - | let amountBalanceOld = $ | |
483 | - | let priceBalanceOld = $ | |
484 | - | let $ | |
499 | + | let amountBalanceOld = $t02294323236._1 | |
500 | + | let priceBalanceOld = $t02294323236._2 | |
501 | + | let $t02324023389 = if (paymentInAmountAsset) | |
485 | 502 | then $Tuple2(paymentAmountRaw, 0) | |
486 | 503 | else $Tuple2(0, paymentAmountRaw) | |
487 | - | let amountAssetAmountRaw = $ | |
488 | - | let priceAssetAmountRaw = $ | |
504 | + | let amountAssetAmountRaw = $t02324023389._1 | |
505 | + | let priceAssetAmountRaw = $t02324023389._2 | |
489 | 506 | let amountAssetAmount = takeFee(amountAssetAmountRaw)._1 | |
490 | 507 | let priceAssetAmount = takeFee(priceAssetAmountRaw)._1 | |
491 | - | let $ | |
492 | - | let paymentAmount = $ | |
493 | - | let feeAmount = $ | |
508 | + | let $t02351123570 = takeFee(paymentAmountRaw) | |
509 | + | let paymentAmount = $t02351123570._1 | |
510 | + | let feeAmount = $t02351123570._2 | |
494 | 511 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
495 | 512 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
496 | 513 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
497 | 514 | let priceNew = fromX18(priceNewX18, scale8) | |
498 | 515 | let paymentBalance = if (paymentInAmountAsset) | |
499 | 516 | then amountBalanceOld | |
500 | 517 | else priceBalanceOld | |
501 | 518 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
502 | 519 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
503 | 520 | let chechSupply = if ((supplyBigInt > big0)) | |
504 | 521 | then true | |
505 | 522 | else throwErr("initial deposit requires all coins") | |
506 | 523 | if ((chechSupply == chechSupply)) | |
507 | 524 | then { | |
508 | 525 | let depositBigInt = toBigInt(paymentAmount) | |
509 | 526 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
510 | 527 | let commonState = if (isEval) | |
511 | 528 | then nil | |
512 | 529 | else [IntegerEntry(pl(), priceNew), IntegerEntry(ph(height, lastBlock.timestamp), priceNew), StringEntry(pau(toString(value(userAddress)), toBase58String(value(txId))), dataPutActionInfo(amountAssetAmountRaw, priceAssetAmountRaw, issueAmount, priceNew, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
513 | 530 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
514 | 531 | let priceOld = fromX18(priceOldX18, scale8) | |
515 | 532 | let loss = { | |
516 | - | let $ | |
533 | + | let $t02504725214 = if (paymentInAmountAsset) | |
517 | 534 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
518 | 535 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
519 | - | let amount = $ | |
520 | - | let balance = $ | |
536 | + | let amount = $t02504725214._1 | |
537 | + | let balance = $t02504725214._2 | |
521 | 538 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
522 | 539 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
523 | 540 | } | |
524 | 541 | $Tuple4(issueAmount, commonState, feeAmount, loss) | |
525 | 542 | } | |
526 | 543 | else throw("Strict value is not equal to itself.") | |
527 | 544 | } | |
528 | 545 | ||
529 | 546 | ||
530 | 547 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
531 | 548 | let isEval = (txId == unit) | |
532 | 549 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
533 | 550 | then true | |
534 | 551 | else throwErr("invalid lp asset")] | |
535 | 552 | if ((checks == checks)) | |
536 | 553 | then { | |
537 | 554 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
538 | 555 | then true | |
539 | 556 | else if ((outAssetId == cfgPriceAssetId)) | |
540 | 557 | then false | |
541 | 558 | else throwErr("invalid asset") | |
542 | 559 | let balanceBigInt = if (outInAmountAsset) | |
543 | 560 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
544 | 561 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
545 | 562 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
546 | 563 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
547 | 564 | let outBalance = if (outInAmountAsset) | |
548 | 565 | then amBalanceOld | |
549 | 566 | else prBalanceOld | |
550 | 567 | let outBalanceBigInt = toBigInt(outBalance) | |
551 | 568 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
552 | 569 | let redeemedBigInt = toBigInt(paymentAmount) | |
553 | 570 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
554 | - | let $ | |
555 | - | let totalAmount = $ | |
556 | - | let feeAmount = $ | |
557 | - | let $ | |
571 | + | let $t02679426844 = takeFee(amountRaw) | |
572 | + | let totalAmount = $t02679426844._1 | |
573 | + | let feeAmount = $t02679426844._2 | |
574 | + | let $t02684827074 = if (outInAmountAsset) | |
558 | 575 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
559 | 576 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
560 | - | let outAmAmount = $ | |
561 | - | let outPrAmount = $ | |
562 | - | let amBalanceNew = $ | |
563 | - | let prBalanceNew = $ | |
577 | + | let outAmAmount = $t02684827074._1 | |
578 | + | let outPrAmount = $t02684827074._2 | |
579 | + | let amBalanceNew = $t02684827074._3 | |
580 | + | let prBalanceNew = $t02684827074._4 | |
564 | 581 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
565 | 582 | let priceNew = fromX18(priceNewX18, scale8) | |
566 | 583 | let commonState = if (isEval) | |
567 | 584 | then nil | |
568 | 585 | else [StringEntry(gau(toString(value(userAddress)), toBase58String(value(txId))), dataGetActionInfo(outAmAmount, outPrAmount, paymentAmount, priceNew, height, lastBlock.timestamp)), IntegerEntry(pl(), priceNew), IntegerEntry(ph(height, lastBlock.timestamp), priceNew)] | |
569 | 586 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
570 | 587 | let priceOld = fromX18(priceOldX18, scale8) | |
571 | 588 | let loss = { | |
572 | 589 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
573 | 590 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
574 | 591 | } | |
575 | 592 | $Tuple4(totalAmount, commonState, feeAmount, loss) | |
576 | 593 | } | |
577 | 594 | else throw("Strict value is not equal to itself.") | |
595 | + | } | |
596 | + | ||
597 | + | ||
598 | + | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
599 | + | let updatedKLp = (pow((amountBalance * priceBalance), 0, 5, 1, 0, DOWN) / lpEmission) | |
600 | + | updatedKLp | |
601 | + | } | |
602 | + | ||
603 | + | ||
604 | + | func refreshKLpInternal () = { | |
605 | + | let cfg = getPoolConfig() | |
606 | + | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
607 | + | let amountAssetId = cfg[idxAmtAssetId] | |
608 | + | let priceAssetId = cfg[idxPriceAssetId] | |
609 | + | let amountAssetBalance = getAccBalance(amountAssetId) | |
610 | + | let priceAssetBalance = getAccBalance(priceAssetId) | |
611 | + | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
612 | + | let updatedKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpEmission) | |
613 | + | updatedKLp | |
578 | 614 | } | |
579 | 615 | ||
580 | 616 | ||
581 | 617 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
582 | 618 | case s: String => | |
583 | 619 | fromBase58String(s) | |
584 | 620 | case _: Unit => | |
585 | 621 | unit | |
586 | 622 | case _ => | |
587 | 623 | throw("Match error") | |
588 | 624 | } | |
589 | 625 | ||
590 | 626 | ||
591 | 627 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
592 | 628 | case s: String => | |
593 | 629 | fromBase58String(s) | |
594 | 630 | case _: Unit => | |
595 | 631 | unit | |
596 | 632 | case _ => | |
597 | 633 | throw("Match error") | |
598 | 634 | } | |
599 | 635 | ||
600 | 636 | ||
601 | 637 | func isManager (i) = match managerPublicKeyOrUnit() { | |
602 | 638 | case pk: ByteVector => | |
603 | 639 | (i.callerPublicKey == pk) | |
604 | 640 | case _: Unit => | |
605 | 641 | (i.caller == this) | |
606 | 642 | case _ => | |
607 | 643 | throw("Match error") | |
608 | 644 | } | |
609 | 645 | ||
610 | 646 | ||
611 | 647 | func mustManager (i) = { | |
612 | 648 | let pd = throw("Permission denied") | |
613 | 649 | match managerPublicKeyOrUnit() { | |
614 | 650 | case pk: ByteVector => | |
615 | 651 | if ((i.callerPublicKey == pk)) | |
616 | 652 | then true | |
617 | 653 | else pd | |
618 | 654 | case _: Unit => | |
619 | 655 | if ((i.caller == this)) | |
620 | 656 | then true | |
621 | 657 | else pd | |
622 | 658 | case _ => | |
623 | 659 | throw("Match error") | |
624 | 660 | } | |
625 | 661 | } | |
626 | 662 | ||
627 | 663 | ||
628 | 664 | @Callable(i) | |
629 | 665 | func setManager (pendingManagerPublicKey) = { | |
630 | 666 | let checkCaller = mustManager(i) | |
631 | 667 | if ((checkCaller == checkCaller)) | |
632 | 668 | then { | |
633 | 669 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
634 | 670 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
635 | 671 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
636 | 672 | else throw("Strict value is not equal to itself.") | |
637 | 673 | } | |
638 | 674 | else throw("Strict value is not equal to itself.") | |
639 | 675 | } | |
640 | 676 | ||
641 | 677 | ||
642 | 678 | ||
643 | 679 | @Callable(i) | |
644 | 680 | func confirmManager () = { | |
645 | 681 | let pm = pendingManagerPublicKeyOrUnit() | |
646 | 682 | let hasPM = if (isDefined(pm)) | |
647 | 683 | then true | |
648 | 684 | else throw("No pending manager") | |
649 | 685 | if ((hasPM == hasPM)) | |
650 | 686 | then { | |
651 | 687 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
652 | 688 | then true | |
653 | 689 | else throw("You are not pending manager") | |
654 | 690 | if ((checkPM == checkPM)) | |
655 | 691 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
656 | 692 | else throw("Strict value is not equal to itself.") | |
657 | 693 | } | |
658 | 694 | else throw("Strict value is not equal to itself.") | |
659 | 695 | } | |
660 | 696 | ||
661 | 697 | ||
662 | 698 | ||
663 | 699 | @Callable(i) | |
664 | 700 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
665 | 701 | then throw("Invalid slippageTolerance passed") | |
666 | 702 | else { | |
667 | 703 | let estPut = commonPut(i, slippageTolerance, true) | |
668 | 704 | let emitLpAmt = estPut._2 | |
669 | 705 | let lpAssetId = estPut._7 | |
670 | 706 | let state = estPut._9 | |
671 | 707 | let amDiff = estPut._10 | |
672 | 708 | let prDiff = estPut._11 | |
673 | 709 | let amId = estPut._12 | |
674 | 710 | let prId = estPut._13 | |
675 | 711 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
676 | 712 | if ((emitInv == emitInv)) | |
677 | 713 | then { | |
678 | 714 | let emitInvLegacy = match emitInv { | |
679 | 715 | case legacyFactoryContract: Address => | |
680 | 716 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
681 | 717 | case _ => | |
682 | 718 | unit | |
683 | 719 | } | |
684 | 720 | if ((emitInvLegacy == emitInvLegacy)) | |
685 | 721 | then { | |
686 | 722 | let slippageAInv = if ((amDiff > 0)) | |
687 | 723 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
688 | 724 | else nil | |
689 | 725 | if ((slippageAInv == slippageAInv)) | |
690 | 726 | then { | |
691 | 727 | let slippagePInv = if ((prDiff > 0)) | |
692 | 728 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
693 | 729 | else nil | |
694 | 730 | if ((slippagePInv == slippagePInv)) | |
695 | 731 | then { | |
696 | 732 | let lpTransfer = if (shouldAutoStake) | |
697 | 733 | then { | |
698 | 734 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
699 | 735 | if ((slpStakeInv == slpStakeInv)) | |
700 | 736 | then nil | |
701 | 737 | else throw("Strict value is not equal to itself.") | |
702 | 738 | } | |
703 | 739 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
704 | 740 | (state ++ lpTransfer) | |
705 | 741 | } | |
706 | 742 | else throw("Strict value is not equal to itself.") | |
707 | 743 | } | |
708 | 744 | else throw("Strict value is not equal to itself.") | |
709 | 745 | } | |
710 | 746 | else throw("Strict value is not equal to itself.") | |
711 | 747 | } | |
712 | 748 | else throw("Strict value is not equal to itself.") | |
713 | 749 | } | |
714 | 750 | ||
715 | 751 | ||
716 | 752 | ||
717 | 753 | @Callable(i) | |
718 | 754 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
719 | 755 | then throw("Invalid value passed") | |
720 | 756 | else { | |
721 | 757 | let estPut = commonPut(i, maxSlippage, false) | |
722 | 758 | estPut._9 | |
723 | 759 | } | |
724 | 760 | ||
725 | 761 | ||
726 | 762 | ||
727 | 763 | @Callable(i) | |
728 | 764 | func putOneTkn (minOutAmount,autoStake) = { | |
729 | 765 | let isPoolOneTokenOperationsDisabled = { | |
730 | 766 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
731 | 767 | if ($isInstanceOf(@, "Boolean")) | |
732 | 768 | then @ | |
733 | 769 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
734 | 770 | } | |
735 | 771 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
736 | 772 | then true | |
737 | 773 | else (cfgPoolStatus == PoolPutDisabled)) | |
738 | 774 | then true | |
739 | 775 | else (cfgPoolStatus == PoolShutdown)) | |
740 | 776 | then true | |
741 | 777 | else isPoolOneTokenOperationsDisabled | |
742 | 778 | let checks = [if (if (!(isPutDisabled)) | |
743 | 779 | then true | |
744 | 780 | else isManager(i)) | |
745 | 781 | then true | |
746 | 782 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
747 | 783 | then true | |
748 | 784 | else throwErr("exactly 1 payment are expected")] | |
749 | 785 | if ((checks == checks)) | |
750 | 786 | then { | |
751 | 787 | let payment = i.payments[0] | |
752 | 788 | let paymentAssetId = payment.assetId | |
753 | 789 | let paymentAmountRaw = payment.amount | |
754 | 790 | let userAddress = i.caller | |
755 | 791 | let txId = i.transactionId | |
756 | - | let $t03160931739 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
757 | - | if (($t03160931739 == $t03160931739)) | |
792 | + | let $t03269232819 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
793 | + | let emitAmountEstimated = $t03269232819._1 | |
794 | + | let commonState = $t03269232819._2 | |
795 | + | let feeAmount = $t03269232819._3 | |
796 | + | let bonus = $t03269232819._4 | |
797 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
798 | + | then (minOutAmount > emitAmountEstimated) | |
799 | + | else false) | |
800 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
801 | + | else emitAmountEstimated | |
802 | + | let emitInv = emit(emitAmount) | |
803 | + | if ((emitInv == emitInv)) | |
758 | 804 | then { | |
759 | - | let bonus = $t03160931739._4 | |
760 | - | let feeAmount = $t03160931739._3 | |
761 | - | let commonState = $t03160931739._2 | |
762 | - | let emitAmountEstimated = $t03160931739._1 | |
763 | - | let emitAmount = if (if ((minOutAmount > 0)) | |
764 | - | then (minOutAmount > emitAmountEstimated) | |
765 | - | else false) | |
766 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
767 | - | else emitAmountEstimated | |
768 | - | let emitInv = emit(emitAmount) | |
769 | - | if ((emitInv == emitInv)) | |
805 | + | let lpTransfer = if (autoStake) | |
770 | 806 | then { | |
771 | - | let lpTransfer = if (autoStake) | |
772 | - | then { | |
773 | - | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
774 | - | if ((stakeInv == stakeInv)) | |
775 | - | then nil | |
776 | - | else throw("Strict value is not equal to itself.") | |
777 | - | } | |
778 | - | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
779 | - | let sendFee = if ((feeAmount > 0)) | |
780 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
781 | - | else nil | |
782 | - | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
807 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
808 | + | if ((stakeInv == stakeInv)) | |
809 | + | then nil | |
810 | + | else throw("Strict value is not equal to itself.") | |
783 | 811 | } | |
784 | - | else throw("Strict value is not equal to itself.") | |
812 | + | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
813 | + | let sendFee = if ((feeAmount > 0)) | |
814 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
815 | + | else nil | |
816 | + | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
785 | 817 | } | |
786 | 818 | else throw("Strict value is not equal to itself.") | |
787 | 819 | } | |
788 | 820 | else throw("Strict value is not equal to itself.") | |
789 | 821 | } | |
790 | 822 | ||
791 | 823 | ||
792 | 824 | ||
793 | 825 | @Callable(i) | |
794 | 826 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
795 | - | let $ | |
796 | - | let emitAmountEstimated = $ | |
797 | - | let commonState = $ | |
798 | - | let feeAmount = $ | |
799 | - | let bonus = $ | |
827 | + | let $t03354833683 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
828 | + | let emitAmountEstimated = $t03354833683._1 | |
829 | + | let commonState = $t03354833683._2 | |
830 | + | let feeAmount = $t03354833683._3 | |
831 | + | let bonus = $t03354833683._4 | |
800 | 832 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
801 | 833 | } | |
802 | 834 | ||
803 | 835 | ||
804 | 836 | ||
805 | 837 | @Callable(i) | |
806 | 838 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
807 | 839 | let isPoolOneTokenOperationsDisabled = { | |
808 | 840 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
809 | 841 | if ($isInstanceOf(@, "Boolean")) | |
810 | 842 | then @ | |
811 | 843 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
812 | 844 | } | |
813 | 845 | let isGetDisabled = if (if (isGlobalShutdown()) | |
814 | 846 | then true | |
815 | 847 | else (cfgPoolStatus == PoolShutdown)) | |
816 | 848 | then true | |
817 | 849 | else isPoolOneTokenOperationsDisabled | |
818 | 850 | let checks = [if (if (!(isGetDisabled)) | |
819 | 851 | then true | |
820 | 852 | else isManager(i)) | |
821 | 853 | then true | |
822 | 854 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
823 | 855 | then true | |
824 | 856 | else throwErr("exactly 1 payment are expected")] | |
825 | 857 | if ((checks == checks)) | |
826 | 858 | then { | |
827 | 859 | let outAssetId = parseAssetId(outAssetIdStr) | |
828 | 860 | let payment = i.payments[0] | |
829 | 861 | let paymentAssetId = payment.assetId | |
830 | 862 | let paymentAmount = payment.amount | |
831 | 863 | let userAddress = i.caller | |
832 | 864 | let txId = i.transactionId | |
833 | - | let $t03340833543 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
834 | - | if (($t03340833543 == $t03340833543)) | |
865 | + | let $t03448834620 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
866 | + | let amountEstimated = $t03448834620._1 | |
867 | + | let commonState = $t03448834620._2 | |
868 | + | let feeAmount = $t03448834620._3 | |
869 | + | let bonus = $t03448834620._4 | |
870 | + | let amount = if (if ((minOutAmount > 0)) | |
871 | + | then (minOutAmount > amountEstimated) | |
872 | + | else false) | |
873 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
874 | + | else amountEstimated | |
875 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
876 | + | if ((burnInv == burnInv)) | |
835 | 877 | then { | |
836 | - | let bonus = $t03340833543._4 | |
837 | - | let feeAmount = $t03340833543._3 | |
838 | - | let commonState = $t03340833543._2 | |
839 | - | let amountEstimated = $t03340833543._1 | |
840 | - | let amount = if (if ((minOutAmount > 0)) | |
841 | - | then (minOutAmount > amountEstimated) | |
842 | - | else false) | |
843 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
844 | - | else amountEstimated | |
845 | - | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
846 | - | if ((burnInv == burnInv)) | |
847 | - | then { | |
848 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
849 | - | let sendFee = if ((feeAmount > 0)) | |
850 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
851 | - | else nil | |
852 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
853 | - | } | |
854 | - | else throw("Strict value is not equal to itself.") | |
878 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
879 | + | let sendFee = if ((feeAmount > 0)) | |
880 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
881 | + | else nil | |
882 | + | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
855 | 883 | } | |
856 | 884 | else throw("Strict value is not equal to itself.") | |
857 | 885 | } | |
858 | 886 | else throw("Strict value is not equal to itself.") | |
859 | 887 | } | |
860 | 888 | ||
861 | 889 | ||
862 | 890 | ||
863 | 891 | @Callable(i) | |
864 | 892 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
865 | - | let $ | |
866 | - | let amountEstimated = $ | |
867 | - | let commonState = $ | |
868 | - | let feeAmount = $ | |
869 | - | let bonus = $ | |
893 | + | let $t03525535393 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
894 | + | let amountEstimated = $t03525535393._1 | |
895 | + | let commonState = $t03525535393._2 | |
896 | + | let feeAmount = $t03525535393._3 | |
897 | + | let bonus = $t03525535393._4 | |
870 | 898 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
871 | 899 | } | |
872 | 900 | ||
873 | 901 | ||
874 | 902 | ||
875 | 903 | @Callable(i) | |
876 | 904 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
877 | 905 | let isPoolOneTokenOperationsDisabled = { | |
878 | 906 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
879 | 907 | if ($isInstanceOf(@, "Boolean")) | |
880 | 908 | then @ | |
881 | 909 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
882 | 910 | } | |
883 | 911 | let isGetDisabled = if (if (isGlobalShutdown()) | |
884 | 912 | then true | |
885 | 913 | else (cfgPoolStatus == PoolShutdown)) | |
886 | 914 | then true | |
887 | 915 | else isPoolOneTokenOperationsDisabled | |
888 | 916 | let checks = [if (if (!(isGetDisabled)) | |
889 | 917 | then true | |
890 | 918 | else isManager(i)) | |
891 | 919 | then true | |
892 | 920 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
893 | 921 | then true | |
894 | 922 | else throwErr("no payments are expected")] | |
895 | 923 | if ((checks == checks)) | |
896 | 924 | then { | |
897 | 925 | let outAssetId = parseAssetId(outAssetIdStr) | |
898 | 926 | let userAddress = i.caller | |
899 | 927 | let txId = i.transactionId | |
900 | 928 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
901 | 929 | if ((unstakeInv == unstakeInv)) | |
902 | 930 | then { | |
903 | - | let $t03514135274 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
904 | - | if (($t03514135274 == $t03514135274)) | |
931 | + | let $t03621836348 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
932 | + | let amountEstimated = $t03621836348._1 | |
933 | + | let commonState = $t03621836348._2 | |
934 | + | let feeAmount = $t03621836348._3 | |
935 | + | let bonus = $t03621836348._4 | |
936 | + | let amount = if (if ((minOutAmount > 0)) | |
937 | + | then (minOutAmount > amountEstimated) | |
938 | + | else false) | |
939 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
940 | + | else amountEstimated | |
941 | + | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
942 | + | if ((burnInv == burnInv)) | |
905 | 943 | then { | |
906 | - | let bonus = $t03514135274._4 | |
907 | - | let feeAmount = $t03514135274._3 | |
908 | - | let commonState = $t03514135274._2 | |
909 | - | let amountEstimated = $t03514135274._1 | |
910 | - | let amount = if (if ((minOutAmount > 0)) | |
911 | - | then (minOutAmount > amountEstimated) | |
912 | - | else false) | |
913 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
914 | - | else amountEstimated | |
915 | - | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
916 | - | if ((burnInv == burnInv)) | |
917 | - | then { | |
918 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
919 | - | let sendFee = if ((feeAmount > 0)) | |
920 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
921 | - | else nil | |
922 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
923 | - | } | |
924 | - | else throw("Strict value is not equal to itself.") | |
944 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
945 | + | let sendFee = if ((feeAmount > 0)) | |
946 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
947 | + | else nil | |
948 | + | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
925 | 949 | } | |
926 | 950 | else throw("Strict value is not equal to itself.") | |
927 | 951 | } | |
928 | 952 | else throw("Strict value is not equal to itself.") | |
929 | 953 | } | |
930 | 954 | else throw("Strict value is not equal to itself.") | |
931 | 955 | } | |
932 | 956 | ||
933 | 957 | ||
934 | 958 | ||
935 | 959 | @Callable(i) | |
936 | 960 | func get () = { | |
937 | 961 | let res = commonGet(i) | |
938 | 962 | let outAmtAmt = res._1 | |
939 | 963 | let outPrAmt = res._2 | |
940 | 964 | let pmtAmt = res._3 | |
941 | 965 | let pmtAssetId = res._4 | |
942 | 966 | let state = res._5 | |
943 | 967 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
944 | 968 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
945 | 969 | then state | |
946 | 970 | else throw("Strict value is not equal to itself.") | |
947 | 971 | } | |
948 | 972 | ||
949 | 973 | ||
950 | 974 | ||
951 | 975 | @Callable(i) | |
952 | 976 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
953 | 977 | let res = commonGet(i) | |
954 | 978 | let outAmAmt = res._1 | |
955 | 979 | let outPrAmt = res._2 | |
956 | 980 | let pmtAmt = res._3 | |
957 | 981 | let pmtAssetId = res._4 | |
958 | 982 | let state = res._5 | |
959 | 983 | if ((noLessThenAmtAsset > outAmAmt)) | |
960 | 984 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
961 | 985 | else if ((noLessThenPriceAsset > outPrAmt)) | |
962 | 986 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
963 | 987 | else { | |
964 | 988 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
965 | 989 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
966 | 990 | then state | |
967 | 991 | else throw("Strict value is not equal to itself.") | |
968 | 992 | } | |
969 | 993 | } | |
970 | 994 | ||
971 | 995 | ||
972 | 996 | ||
973 | 997 | @Callable(i) | |
974 | 998 | func unstakeAndGet (amount) = { | |
975 | 999 | let checkPayments = if ((size(i.payments) != 0)) | |
976 | 1000 | then throw("No payments are expected") | |
977 | 1001 | else true | |
978 | 1002 | if ((checkPayments == checkPayments)) | |
979 | 1003 | then { | |
980 | 1004 | let cfg = getPoolConfig() | |
981 | 1005 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
982 | 1006 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
983 | 1007 | if ((unstakeInv == unstakeInv)) | |
984 | 1008 | then { | |
985 | 1009 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
986 | 1010 | let poolStatus = parseIntValue(res._9) | |
987 | 1011 | let state = res._10 | |
988 | 1012 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
989 | 1013 | then true | |
990 | 1014 | else (poolStatus == PoolShutdown)) | |
991 | 1015 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
992 | 1016 | else true | |
993 | 1017 | if ((checkPoolStatus == checkPoolStatus)) | |
994 | 1018 | then { | |
995 | 1019 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
996 | 1020 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
997 | 1021 | then state | |
998 | 1022 | else throw("Strict value is not equal to itself.") | |
999 | 1023 | } | |
1000 | 1024 | else throw("Strict value is not equal to itself.") | |
1001 | 1025 | } | |
1002 | 1026 | else throw("Strict value is not equal to itself.") | |
1003 | 1027 | } | |
1004 | 1028 | else throw("Strict value is not equal to itself.") | |
1005 | 1029 | } | |
1006 | 1030 | ||
1007 | 1031 | ||
1008 | 1032 | ||
1009 | 1033 | @Callable(i) | |
1010 | 1034 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1011 | 1035 | let isGetDisabled = if (isGlobalShutdown()) | |
1012 | 1036 | then true | |
1013 | 1037 | else (cfgPoolStatus == PoolShutdown) | |
1014 | 1038 | let checks = [if (!(isGetDisabled)) | |
1015 | 1039 | then true | |
1016 | 1040 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1017 | 1041 | then true | |
1018 | 1042 | else throw("no payments are expected")] | |
1019 | 1043 | if ((checks == checks)) | |
1020 | 1044 | then { | |
1021 | 1045 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1022 | 1046 | if ((unstakeInv == unstakeInv)) | |
1023 | 1047 | then { | |
1024 | 1048 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1025 | 1049 | let outAmAmt = res._1 | |
1026 | 1050 | let outPrAmt = res._2 | |
1027 | 1051 | let state = res._10 | |
1028 | 1052 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1029 | 1053 | then true | |
1030 | 1054 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1031 | 1055 | then true | |
1032 | 1056 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1033 | 1057 | if ((checkAmounts == checkAmounts)) | |
1034 | 1058 | then { | |
1035 | 1059 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1036 | 1060 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1037 | 1061 | then state | |
1038 | 1062 | else throw("Strict value is not equal to itself.") | |
1039 | 1063 | } | |
1040 | 1064 | else throw("Strict value is not equal to itself.") | |
1041 | 1065 | } | |
1042 | 1066 | else throw("Strict value is not equal to itself.") | |
1043 | 1067 | } | |
1044 | 1068 | else throw("Strict value is not equal to itself.") | |
1045 | 1069 | } | |
1046 | 1070 | ||
1047 | 1071 | ||
1048 | 1072 | ||
1049 | 1073 | @Callable(i) | |
1050 | 1074 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1051 | 1075 | then throw("permissions denied") | |
1052 | 1076 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1077 | + | ||
1078 | + | ||
1079 | + | ||
1080 | + | @Callable(i) | |
1081 | + | func refreshKLp () = { | |
1082 | + | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyLastKLpRefreshed), 0) | |
1083 | + | let delayNotReachedErrorMessage = throwErr(makeString([value(getString(keyRefreshKLpDelay)), "blocks have not passed since the previous call"], " ")) | |
1084 | + | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= 30)) | |
1085 | + | then true | |
1086 | + | else delayNotReachedErrorMessage | |
1087 | + | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1088 | + | then { | |
1089 | + | let updatedKLp = asInt(refreshKLpInternal()) | |
1090 | + | [IntegerEntry(keyLastKLpRefreshed, height), IntegerEntry(keyKLp, updatedKLp)] | |
1091 | + | } | |
1092 | + | else throw("Strict value is not equal to itself.") | |
1093 | + | } | |
1053 | 1094 | ||
1054 | 1095 | ||
1055 | 1096 | ||
1056 | 1097 | @Callable(i) | |
1057 | 1098 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1058 | 1099 | ||
1059 | 1100 | ||
1060 | 1101 | ||
1061 | 1102 | @Callable(i) | |
1062 | 1103 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1063 | 1104 | ||
1064 | 1105 | ||
1065 | 1106 | ||
1066 | 1107 | @Callable(i) | |
1067 | 1108 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1068 | 1109 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1069 | 1110 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1070 | 1111 | } | |
1071 | 1112 | ||
1072 | 1113 | ||
1073 | 1114 | ||
1074 | 1115 | @Callable(i) | |
1075 | 1116 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1076 | 1117 | ||
1077 | 1118 | ||
1078 | 1119 | ||
1079 | 1120 | @Callable(i) | |
1080 | 1121 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1081 | 1122 | ||
1082 | 1123 | ||
1083 | 1124 | ||
1084 | 1125 | @Callable(i) | |
1085 | 1126 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1086 | 1127 | ||
1087 | 1128 | ||
1088 | 1129 | ||
1089 | 1130 | @Callable(i) | |
1090 | 1131 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1091 | 1132 | ||
1092 | 1133 | ||
1093 | 1134 | ||
1094 | 1135 | @Callable(i) | |
1095 | 1136 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1096 | 1137 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1097 | 1138 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1098 | 1139 | } | |
1099 | 1140 | ||
1100 | 1141 | ||
1101 | 1142 | ||
1102 | 1143 | @Callable(i) | |
1103 | 1144 | func statsREADONLY () = { | |
1104 | 1145 | let cfg = getPoolConfig() | |
1105 | 1146 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1106 | 1147 | let amtAssetId = cfg[idxAmtAssetId] | |
1107 | 1148 | let priceAssetId = cfg[idxPriceAssetId] | |
1108 | 1149 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1109 | 1150 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1110 | 1151 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1111 | 1152 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1112 | 1153 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1113 | 1154 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1114 | 1155 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1115 | 1156 | let pricesList = if ((poolLPBalance == 0)) | |
1116 | 1157 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1117 | 1158 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1118 | 1159 | let curPrice = 0 | |
1119 | 1160 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1120 | 1161 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1121 | 1162 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1122 | 1163 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP)) | |
1123 | 1164 | } | |
1124 | 1165 | ||
1125 | 1166 | ||
1126 | 1167 | ||
1127 | 1168 | @Callable(i) | |
1128 | 1169 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1129 | 1170 | let cfg = getPoolConfig() | |
1130 | 1171 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1131 | 1172 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1132 | 1173 | let amAssetId = fromBase58String(amAssetIdStr) | |
1133 | 1174 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1134 | 1175 | let prAssetId = fromBase58String(prAssetIdStr) | |
1135 | 1176 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1136 | 1177 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1137 | 1178 | let poolStatus = cfg[idxPoolStatus] | |
1138 | 1179 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1139 | 1180 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1140 | 1181 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1141 | 1182 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1142 | 1183 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1143 | 1184 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1144 | 1185 | then zeroBigInt | |
1145 | 1186 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1146 | 1187 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1147 | 1188 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1148 | 1189 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1149 | 1190 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1150 | 1191 | let calcLpAmt = estPut._1 | |
1151 | 1192 | let curPriceCalc = estPut._3 | |
1152 | 1193 | let amBalance = estPut._4 | |
1153 | 1194 | let prBalance = estPut._5 | |
1154 | 1195 | let lpEmission = estPut._6 | |
1155 | 1196 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
1156 | 1197 | } | |
1157 | 1198 | ||
1158 | 1199 | ||
1159 | 1200 | ||
1160 | 1201 | @Callable(i) | |
1161 | 1202 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1162 | 1203 | let cfg = getPoolConfig() | |
1163 | 1204 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1164 | 1205 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1165 | 1206 | let amAssetId = fromBase58String(amAssetIdStr) | |
1166 | 1207 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1167 | 1208 | let prAssetId = fromBase58String(prAssetIdStr) | |
1168 | 1209 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1169 | 1210 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1170 | 1211 | let poolStatus = cfg[idxPoolStatus] | |
1171 | 1212 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1172 | 1213 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1173 | 1214 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1174 | 1215 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1175 | 1216 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1176 | 1217 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1177 | 1218 | then zeroBigInt | |
1178 | 1219 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1179 | 1220 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1180 | 1221 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1181 | 1222 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1182 | 1223 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1183 | 1224 | let calcLpAmt = estPut._1 | |
1184 | 1225 | let curPriceCalc = estPut._3 | |
1185 | 1226 | let amBalance = estPut._4 | |
1186 | 1227 | let prBalance = estPut._5 | |
1187 | 1228 | let lpEmission = estPut._6 | |
1188 | 1229 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
1189 | 1230 | } | |
1190 | 1231 | ||
1191 | 1232 | ||
1192 | 1233 | ||
1193 | 1234 | @Callable(i) | |
1194 | 1235 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1195 | 1236 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1196 | 1237 | let outAmAmt = res._1 | |
1197 | 1238 | let outPrAmt = res._2 | |
1198 | 1239 | let amBalance = res._5 | |
1199 | 1240 | let prBalance = res._6 | |
1200 | 1241 | let lpEmission = res._7 | |
1201 | 1242 | let curPrice = res._8 | |
1202 | 1243 | let poolStatus = parseIntValue(res._9) | |
1203 | 1244 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), toString(curPrice), toString(poolStatus)], SEP)) | |
1204 | 1245 | } | |
1205 | 1246 | ||
1206 | 1247 | ||
1207 | 1248 | @Verifier(tx) | |
1208 | 1249 | func verify () = { | |
1209 | 1250 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1210 | 1251 | case pk: ByteVector => | |
1211 | 1252 | pk | |
1212 | 1253 | case _: Unit => | |
1213 | 1254 | tx.senderPublicKey | |
1214 | 1255 | case _ => | |
1215 | 1256 | throw("Match error") | |
1216 | 1257 | } | |
1217 | 1258 | match tx { | |
1218 | 1259 | case order: Order => | |
1219 | 1260 | let matcherPub = getMatcherPubOrFail() | |
1220 | 1261 | let orderValid = validateMatcherOrderAllowed(order) | |
1221 | 1262 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1222 | 1263 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1223 | 1264 | if (if (if (orderValid) | |
1224 | 1265 | then senderValid | |
1225 | 1266 | else false) | |
1226 | 1267 | then matcherValid | |
1227 | 1268 | else false) | |
1228 | 1269 | then true | |
1229 | 1270 | else throwOrderError(orderValid, senderValid, matcherValid) | |
1230 | 1271 | case s: SetScriptTransaction => | |
1231 | 1272 | let newHash = blake2b256(value(s.script)) | |
1232 | 1273 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1233 | 1274 | let currentHash = scriptHash(this) | |
1234 | 1275 | if (if ((allowedHash == newHash)) | |
1235 | 1276 | then (currentHash != newHash) | |
1236 | 1277 | else false) | |
1237 | 1278 | then true | |
1238 | 1279 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1239 | 1280 | case _ => | |
1240 | 1281 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1241 | 1282 | } | |
1242 | 1283 | } | |
1243 | 1284 |
github/deemru/w8io/169f3d6 138.92 ms ◑