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