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