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