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